Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update eth2-go-client #22

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/deneb/blindedblobsbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

// BlindedBlobsBundle is the structure used to store the blobs bundle.
type BlindedBlobsBundle struct {
Commitments []deneb.KzgCommitment `ssz-max:"6" ssz-size:"?,48"`
Proofs []deneb.KzgProof `ssz-max:"6" ssz-size:"?,48"`
BlobRoots []phase0.Root `ssz-max:"6" ssz-size:"?,32"`
Commitments []deneb.KZGCommitment `ssz-max:"4096" ssz-size:"?,48"`
Proofs []deneb.KZGProof `ssz-max:"4096" ssz-size:"?,48"`
BlobRoots []phase0.Root `ssz-max:"4096" ssz-size:"?,32"`
}

// String returns a string version of the structure.
Expand Down
4 changes: 2 additions & 2 deletions api/deneb/blindedblobsbundle_ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/deneb/blindedblobsbundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestBlindedBlobsBundleJSON(t *testing.T) {
{
name: "CommitmentsWrongType",
input: []byte(`{"commitments":true,"proofs":["0xc6e27a3ae80243ba7ea88eab107a0675020e0745d75ab6a1553691007a50f7f99f597693ac33ae3cea63bf0b90a734ff","0xc6e27a3ae80243ba7ea88eab107a0675020e0745d75ab6a1553691007a50f7f99f597693ac33ae3cea63bf0b90a734ff"],"blob_roots":["0x3c1820c62034fc45c10abc983dbce08de28f303192dea32371a902b3e6a1fc29","0xba4d784293df28bab771a14df58cdbed9d8d64afd0ddf1c52dff3e25fcdd51df"]}`),
err: "commitments: json: cannot unmarshal bool into Go value of type []deneb.KzgCommitment",
err: "commitments: json: cannot unmarshal bool into Go value of type []deneb.KZGCommitment",
},
{
name: "CommitmentWrongType",
Expand All @@ -71,7 +71,7 @@ func TestBlindedBlobsBundleJSON(t *testing.T) {
{
name: "ProofsWrongType",
input: []byte(`{"commitments":["0x95cc5099bbd8420d8ebade383c00a2346dace60a7604f768cd71501757b4d72eeb7d5474a6b615af10379d69aa9f478f","0xae9f2d2217013ef61f995f9074faead9ec24e8048440164ec3d6029b87d43686dd0c97c2df9554fc997d0d66c3a78929"],"proofs":true,"blob_roots":["0x3c1820c62034fc45c10abc983dbce08de28f303192dea32371a902b3e6a1fc29","0xba4d784293df28bab771a14df58cdbed9d8d64afd0ddf1c52dff3e25fcdd51df"]}`),
err: "proofs: json: cannot unmarshal bool into Go value of type []deneb.KzgProof",
err: "proofs: json: cannot unmarshal bool into Go value of type []deneb.KZGProof",
},
{
name: "ProofWrongType",
Expand Down
6 changes: 3 additions & 3 deletions api/deneb/blobsbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (

// BlobsBundle is the structure used to store the blobs bundle.
type BlobsBundle struct {
Commitments []deneb.KzgCommitment `ssz-max:"6" ssz-size:"?,48"`
Proofs []deneb.KzgProof `ssz-max:"6" ssz-size:"?,48"`
Blobs []deneb.Blob `ssz-max:"6" ssz-size:"?,131072"`
Commitments []deneb.KZGCommitment `ssz-max:"4096" ssz-size:"?,48"`
Proofs []deneb.KZGProof `ssz-max:"4096" ssz-size:"?,48"`
Blobs []deneb.Blob `ssz-max:"4096" ssz-size:"?,131072"`
}

// String returns a string version of the structure.
Expand Down
42 changes: 21 additions & 21 deletions api/deneb/blobsbundle_ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/deneb/blobsbundle_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/attestantio/go-builder-client
go 1.20

require (
github.com/attestantio/go-eth2-client v0.19.0
github.com/attestantio/go-eth2-client v0.19.5
github.com/ferranbt/fastssz v0.1.3
github.com/goccy/go-yaml v1.11.2
github.com/holiman/uint256 v1.2.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/attestantio/go-eth2-client v0.19.0 h1:R0SS4PY0W22ntOEvh9F9tajY2tH4oZm3Y5FxFMk6Nrg=
github.com/attestantio/go-eth2-client v0.19.0/go.mod h1:mZve1kV9Ctj0I1HH9gdg+MnI8lZ+Cb2EktEtOYrBlsM=
github.com/attestantio/go-eth2-client v0.19.5 h1:4V+vhXsCYji5jWrlONbr03GV7qoLRdzq96dLgXaqmek=
github.com/attestantio/go-eth2-client v0.19.5/go.mod h1:mZve1kV9Ctj0I1HH9gdg+MnI8lZ+Cb2EktEtOYrBlsM=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
Expand Down
67 changes: 24 additions & 43 deletions http/unblindproposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type denebBundle struct {

// UnblindProposal unblinds a proposal.
func (s *Service) UnblindProposal(ctx context.Context,
proposal *consensusapi.VersionedSignedBlindedProposal,
proposal *consensusapi.VersionedSignedBlindedBeaconBlock,
) (
*consensusapi.VersionedSignedProposal,
error,
Expand Down Expand Up @@ -234,7 +234,7 @@ func (s *Service) unblindCapellaProposal(ctx context.Context,

func (s *Service) unblindDenebProposal(ctx context.Context,
started time.Time,
proposal *consensusapiv1deneb.SignedBlindedBlockContents,
proposal *consensusapiv1deneb.SignedBlindedBeaconBlock,
) (
*consensusapi.VersionedSignedProposal,
error,
Expand All @@ -259,40 +259,32 @@ func (s *Service) unblindDenebProposal(ctx context.Context,
return nil, errors.Wrap(err, "failed to parse response")
}

signedBlobSidecars := make([]*deneb.SignedBlobSidecar, len(proposal.SignedBlindedBlobSidecars))
for i := range proposal.SignedBlindedBlobSidecars {
signedBlobSidecars[i] = &deneb.SignedBlobSidecar{
Signature: proposal.SignedBlindedBlobSidecars[i].Signature,
}
}

// Reconstruct proposal.
res := &consensusapi.VersionedSignedProposal{
Version: consensusspec.DataVersionDeneb,
Deneb: &consensusapiv1deneb.SignedBlockContents{
SignedBlock: &deneb.SignedBeaconBlock{
Message: &deneb.BeaconBlock{
Slot: proposal.SignedBlindedBlock.Message.Slot,
ProposerIndex: proposal.SignedBlindedBlock.Message.ProposerIndex,
ParentRoot: proposal.SignedBlindedBlock.Message.ParentRoot,
StateRoot: proposal.SignedBlindedBlock.Message.StateRoot,
Slot: proposal.Message.Slot,
ProposerIndex: proposal.Message.ProposerIndex,
ParentRoot: proposal.Message.ParentRoot,
StateRoot: proposal.Message.StateRoot,
Body: &deneb.BeaconBlockBody{
RANDAOReveal: proposal.SignedBlindedBlock.Message.Body.RANDAOReveal,
ETH1Data: proposal.SignedBlindedBlock.Message.Body.ETH1Data,
Graffiti: proposal.SignedBlindedBlock.Message.Body.Graffiti,
ProposerSlashings: proposal.SignedBlindedBlock.Message.Body.ProposerSlashings,
AttesterSlashings: proposal.SignedBlindedBlock.Message.Body.AttesterSlashings,
Attestations: proposal.SignedBlindedBlock.Message.Body.Attestations,
Deposits: proposal.SignedBlindedBlock.Message.Body.Deposits,
VoluntaryExits: proposal.SignedBlindedBlock.Message.Body.VoluntaryExits,
SyncAggregate: proposal.SignedBlindedBlock.Message.Body.SyncAggregate,
BLSToExecutionChanges: proposal.SignedBlindedBlock.Message.Body.BLSToExecutionChanges,
BlobKzgCommitments: proposal.SignedBlindedBlock.Message.Body.BlobKzgCommitments,
RANDAOReveal: proposal.Message.Body.RANDAOReveal,
ETH1Data: proposal.Message.Body.ETH1Data,
Graffiti: proposal.Message.Body.Graffiti,
ProposerSlashings: proposal.Message.Body.ProposerSlashings,
AttesterSlashings: proposal.Message.Body.AttesterSlashings,
Attestations: proposal.Message.Body.Attestations,
Deposits: proposal.Message.Body.Deposits,
VoluntaryExits: proposal.Message.Body.VoluntaryExits,
SyncAggregate: proposal.Message.Body.SyncAggregate,
BLSToExecutionChanges: proposal.Message.Body.BLSToExecutionChanges,
BlobKZGCommitments: proposal.Message.Body.BlobKZGCommitments,
},
},
Signature: proposal.SignedBlindedBlock.Signature,
Signature: proposal.Signature,
},
SignedBlobSidecars: signedBlobSidecars,
},
}

Expand All @@ -303,7 +295,7 @@ func (s *Service) unblindDenebProposal(ctx context.Context,
return nil, errors.Wrap(err, "failed to parse deneb response")
}
// Ensure that the data returned is what we expect.
ourExecutionPayloadHash, err := proposal.SignedBlindedBlock.Message.Body.ExecutionPayloadHeader.HashTreeRoot()
ourExecutionPayloadHash, err := proposal.Message.Body.ExecutionPayloadHeader.HashTreeRoot()
if err != nil {
return nil, errors.Wrap(err, "failed to generate hash tree root for our execution payload header")
}
Expand All @@ -316,27 +308,16 @@ func (s *Service) unblindDenebProposal(ctx context.Context,
}
res.Deneb.SignedBlock.Message.Body.ExecutionPayload = resp.Bundle.ExecutionPayload

root, err := proposal.SignedBlindedBlock.Message.HashTreeRoot()
if err != nil {
return nil, errors.Wrap(err, "failed to generate hash tree root for proposal")
}

// Reconstruct blobs.
res.Deneb.KZGProofs = make([]deneb.KZGProof, len(resp.Bundle.BlobsBundle.Proofs))
res.Deneb.Blobs = make([]deneb.Blob, len(resp.Bundle.BlobsBundle.Blobs))
for i := range resp.Bundle.BlobsBundle.Blobs {
if !bytes.Equal(resp.Bundle.BlobsBundle.Commitments[i][:], res.Deneb.SignedBlock.Message.Body.BlobKzgCommitments[i][:]) {
if !bytes.Equal(resp.Bundle.BlobsBundle.Commitments[i][:], res.Deneb.SignedBlock.Message.Body.BlobKZGCommitments[i][:]) {
return nil, fmt.Errorf("blob %d commitment mismatch", i)
}

res.Deneb.SignedBlobSidecars[i].Message = &deneb.BlobSidecar{
BlockRoot: root,
Index: deneb.BlobIndex(i),
Slot: proposal.SignedBlindedBlock.Message.Slot,
BlockParentRoot: res.Deneb.SignedBlock.Message.ParentRoot,
ProposerIndex: res.Deneb.SignedBlock.Message.ProposerIndex,
Blob: resp.Bundle.BlobsBundle.Blobs[i],
KzgCommitment: resp.Bundle.BlobsBundle.Commitments[i],
KzgProof: resp.Bundle.BlobsBundle.Proofs[i],
}
res.Deneb.KZGProofs[i] = resp.Bundle.BlobsBundle.Proofs[i]
res.Deneb.Blobs[i] = resp.Bundle.BlobsBundle.Blobs[i]
}
default:
return nil, fmt.Errorf("unsupported content type %v", contentType)
Expand Down
4 changes: 2 additions & 2 deletions spec/versionedsubmitblockrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2437,8 +2437,8 @@ func TestVersionedSubmitBlockRequestString(t *testing.T) {
Withdrawals: make([]*consensuscapella.Withdrawal, 0),
},
BlobsBundle: &deneb.BlobsBundle{
Commitments: make([]consensusdeneb.KzgCommitment, 0),
Proofs: make([]consensusdeneb.KzgProof, 0),
Commitments: make([]consensusdeneb.KZGCommitment, 0),
Proofs: make([]consensusdeneb.KZGProof, 0),
Blobs: make([]consensusdeneb.Blob, 0),
},
Signature: phase0.BLSSignature{
Expand Down