Skip to content

Commit

Permalink
Update signed block conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonche committed Jan 4, 2024
1 parent 35e54c9 commit 29c51bd
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ linters-settings:
replace-allow-list:
- github.com/attestantio/go-eth2-client
- github.com/attestantio/go-builder-client
- github.com/ethereum/go-ethereum

maintidx:
under: 5
Expand Down
6 changes: 2 additions & 4 deletions common/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import (
"github.com/attestantio/go-builder-client/spec"
consensusspec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
capellaspec "github.com/attestantio/go-eth2-client/spec/capella"
consensuscapella "github.com/attestantio/go-eth2-client/spec/capella"
consensusdeneb "github.com/attestantio/go-eth2-client/spec/deneb"
denebspec "github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/flashbots/go-boost-utils/bls"
"github.com/flashbots/go-boost-utils/ssz"
Expand Down Expand Up @@ -184,7 +182,7 @@ func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint25
Version: version,
Deneb: &deneb.SubmitBlockRequest{
Message: bidTrace,
ExecutionPayload: &denebspec.ExecutionPayload{ //nolint:exhaustruct
ExecutionPayload: &consensusdeneb.ExecutionPayload{ //nolint:exhaustruct
BaseFeePerGas: uint256.NewInt(0),
},
BlobsBundle: &deneb.BlobsBundle{}, //nolint:exhaustruct
Expand All @@ -198,7 +196,7 @@ func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint25
Version: version,
Capella: &capella.SubmitBlockRequest{
Message: bidTrace,
ExecutionPayload: &capellaspec.ExecutionPayload{}, //nolint:exhaustruct
ExecutionPayload: &consensuscapella.ExecutionPayload{}, //nolint:exhaustruct
Signature: phase0.BLSSignature{},
},
},
Expand Down
31 changes: 17 additions & 14 deletions common/types_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,26 @@ func CapellaUnblindSignedBlock(blindedBlock *apiv1capella.SignedBlindedBeaconBlo
}

func DenebUnblindSignedBlock(blindedBlock *apiv1deneb.SignedBlindedBeaconBlock, blockPayload *deneb.ExecutionPayloadAndBlobsBundle, blockRoot phase0.Root) *apiv1deneb.SignedBlockContents {
denebBlobSidecars := make([]*consensusdeneb.BlobSidecar, len(blockPayload.BlobsBundle.Blobs))
denebBlobSidecars := make([]*consensusdeneb.SignedBlobSidecar, len(blockPayload.BlobsBundle.Blobs))

for i := range denebBlobSidecars {
denebBlobSidecars[i] = &consensusdeneb.BlobSidecar{
BlockRoot: blockRoot,
Index: consensusdeneb.BlobIndex(i),
Slot: blindedBlock.Message.Slot,
BlockParentRoot: blindedBlock.Message.ParentRoot,
ProposerIndex: blindedBlock.Message.ProposerIndex,
Blob: blockPayload.BlobsBundle.Blobs[i],
KzgCommitment: blockPayload.BlobsBundle.Commitments[i],
KzgProof: blockPayload.BlobsBundle.Proofs[i],
denebBlobSidecars[i] = &consensusdeneb.SignedBlobSidecar{
Message: &consensusdeneb.BlobSidecar{
BlockRoot: blockRoot,
Index: consensusdeneb.BlobIndex(i),
Slot: blindedBlock.Message.Slot,
BlockParentRoot: blindedBlock.Message.ParentRoot,
ProposerIndex: blindedBlock.Message.ProposerIndex,
Blob: blockPayload.BlobsBundle.Blobs[i],
KzgCommitment: blockPayload.BlobsBundle.Commitments[i],
KzgProof: blockPayload.BlobsBundle.Proofs[i],
},
Signature: denebBlobSidecars[i].Signature,
}
}
return &apiv1deneb.SignedBlockContents{
Message: &apiv1deneb.BlockContents{
Block: &consensusdeneb.BeaconBlock{
SignedBlock: &consensusdeneb.SignedBeaconBlock{
Message: &consensusdeneb.BeaconBlock{
Slot: blindedBlock.Message.Slot,
ProposerIndex: blindedBlock.Message.ProposerIndex,
ParentRoot: blindedBlock.Message.ParentRoot,
Expand All @@ -259,9 +262,9 @@ func DenebUnblindSignedBlock(blindedBlock *apiv1deneb.SignedBlindedBeaconBlock,
BlobKzgCommitments: blockPayload.BlobsBundle.Commitments,
},
},
BlobSidecars: denebBlobSidecars,
Signature: blindedBlock.Signature,
},
Signature: blindedBlock.Signature,
SignedBlobSidecars: denebBlobSidecars,
}
}

Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/NYTimes/gziphandler v1.1.1
github.com/alicebob/miniredis/v2 v2.31.0
github.com/attestantio/go-builder-client v0.3.2-0.20230701110827-d0ecfee1ab62
github.com/attestantio/go-eth2-client v0.18.1-0.20230728160410-bc2888aaf7d7
github.com/attestantio/go-eth2-client v0.18.1
github.com/bradfitz/gomemcache v0.0.0-20230124162541-5f7a7d875746
github.com/btcsuite/btcd/btcutil v1.1.2
github.com/buger/jsonparser v1.1.1
Expand Down Expand Up @@ -124,4 +124,6 @@ retract (

replace github.com/attestantio/go-builder-client => github.com/avalonche/go-builder-client v0.0.0-20230802220600-85be1e39d33b

replace github.com/attestantio/go-eth2-client => github.com/avalonche/go-eth2-client v0.0.0-20230801235812-ab38c7f8cba1
replace github.com/attestantio/go-eth2-client => github.com/avalonche/go-eth2-client v0.0.0-20230810012152-c934f6ee3bee

replace github.com/ethereum/go-ethereum => github.com/MariusVanDerWijden/go-ethereum v1.8.22-0.20230807121326-6861f29a109a
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/DmitriyVTitov/size v1.5.0/go.mod h1:le6rNI4CoLQV1b9gzp1+3d7hMAD/uu2QcJ+aYbNgiU0=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
github.com/MariusVanDerWijden/go-ethereum v1.8.22-0.20230807121326-6861f29a109a h1:ccacEL6nX56gb/p5GnTG+bl+rIWCQqIWPx/YELbHPd4=
github.com/MariusVanDerWijden/go-ethereum v1.8.22-0.20230807121326-6861f29a109a/go.mod h1:zKetLweqBR8ZS+1O9iJWI8DvmmD2NzD19apjEWDCsnw=
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
Expand All @@ -25,8 +27,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/avalonche/go-builder-client v0.0.0-20230802220600-85be1e39d33b h1:DNO0BuKEbXLabPbAw+EvojBfwYjHBWrqCF9xg/XPfqM=
github.com/avalonche/go-builder-client v0.0.0-20230802220600-85be1e39d33b/go.mod h1:8NZx9L/rC7nLhSMbbVR6PXr37tC28wTE4u65n+Pa3BQ=
github.com/avalonche/go-eth2-client v0.0.0-20230801235812-ab38c7f8cba1 h1:jLmNo92ji/g8pdnA+Nuc9b7rTC6BZCv0POhmiFqX9cY=
github.com/avalonche/go-eth2-client v0.0.0-20230801235812-ab38c7f8cba1/go.mod h1:KSVlZSW1A3jUg5H8O89DLtqxgJprRfTtI7k89fLdhu0=
github.com/avalonche/go-eth2-client v0.0.0-20230810012152-c934f6ee3bee h1:+Z2E/TGJW7k+MSPWPLvwsOm4SLcRgMeO02WUjDwC8OI=
github.com/avalonche/go-eth2-client v0.0.0-20230810012152-c934f6ee3bee/go.mod h1:KSVlZSW1A3jUg5H8O89DLtqxgJprRfTtI7k89fLdhu0=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -118,8 +120,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg=
github.com/ethereum/c-kzg-4844 v0.3.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.13.4 h1:25HJnaWVg3q1O7Z62LaaI6S9wVq8QCw3K88g8wEzrcM=
github.com/ethereum/go-ethereum v1.13.4/go.mod h1:I0U5VewuuTzvBtVzKo7b3hJzDhXOUtn9mJW7SsIPB0Q=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
Expand Down
5 changes: 2 additions & 3 deletions services/api/blocksim_ratelimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ func (b *BlockSimulationRateLimiter) Send(context context.Context, payload *comm
}

// Create and fire off JSON-RPC request
switch payload.Version {
case spec.DataVersionCapella:
if payload.Version == spec.DataVersionDeneb {
simReq = jsonrpc.NewJSONRPCRequest("1", "flashbots_validateBuilderSubmissionV2", payload)
case spec.DataVersionDeneb:
} else {
simReq = jsonrpc.NewJSONRPCRequest("1", "flashbots_validateBuilderSubmissionV3", payload)
}
_, requestErr, validationErr = SendJSONRPCRequest(&b.client, *simReq, b.blockSimURL, headers)
Expand Down

0 comments on commit 29c51bd

Please sign in to comment.