-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Merge all block unblinding code into a single unblinder struct
#12240
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
Changes from 7 commits
e98fd03
3d50a53
a8e5f83
ce43b80
1dc7d34
4f807f8
567dcd3
1be2490
5932e6b
693b686
11a856b
f6f3ba6
8c921f8
c47e2b4
6b5e6aa
27a1890
56ebe39
477e1f4
f53ef0b
7bee6af
d8b8239
da6d0bc
305d816
3e8f976
5805ef4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import ( | |
| mockp2p "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/testing" | ||
| "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/prysm/v1alpha1/validator" | ||
| "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/testutil" | ||
| fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" | ||
| "github.com/prysmaticlabs/prysm/v4/config/params" | ||
| "github.com/prysmaticlabs/prysm/v4/consensus-types/blocks" | ||
| "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" | ||
|
|
@@ -407,7 +408,7 @@ func TestServer_SubmitBlindedBlockSSZ_OK(t *testing.T) { | |
| alphaServer := &validator.Server{ | ||
| SyncCommitteePool: synccommittee.NewStore(), | ||
| P2P: &mockp2p.MockBroadcaster{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{HasConfigured: true, Payload: emptyPayload()}, | ||
| BlockReceiver: c, | ||
| BlockNotifier: &mock.MockBlockNotifier{}, | ||
| } | ||
|
|
@@ -423,6 +424,9 @@ func TestServer_SubmitBlindedBlockSSZ_OK(t *testing.T) { | |
| req := util.NewBlindedBeaconBlockBellatrix() | ||
| req.Block.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().BellatrixForkEpoch)) | ||
| req.Block.ParentRoot = bsRoot[:] | ||
| transactionsRoot, err := ssz.TransactionsRoot([][]byte{}) | ||
| require.NoError(t, err) | ||
| req.Block.Body.ExecutionPayloadHeader.TransactionsRoot = transactionsRoot[:] | ||
| util.SaveBlock(t, ctx, beaconDB, req) | ||
| blockSsz, err := req.MarshalSSZ() | ||
| require.NoError(t, err) | ||
|
|
@@ -455,7 +459,7 @@ func TestServer_SubmitBlindedBlockSSZ_OK(t *testing.T) { | |
| alphaServer := &validator.Server{ | ||
| SyncCommitteePool: synccommittee.NewStore(), | ||
| P2P: &mockp2p.MockBroadcaster{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{HasConfigured: true, PayloadCapella: emptyPayloadCapella()}, | ||
| BlockReceiver: c, | ||
| BlockNotifier: &mock.MockBlockNotifier{}, | ||
| } | ||
|
|
@@ -471,6 +475,12 @@ func TestServer_SubmitBlindedBlockSSZ_OK(t *testing.T) { | |
| req := util.NewBlindedBeaconBlockCapella() | ||
| req.Block.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().CapellaForkEpoch)) | ||
| req.Block.ParentRoot = bsRoot[:] | ||
| transactionsRoot, err := ssz.TransactionsRoot([][]byte{}) | ||
| require.NoError(t, err) | ||
| req.Block.Body.ExecutionPayloadHeader.TransactionsRoot = transactionsRoot[:] | ||
| withdrawalsRoot, err := ssz.WithdrawalSliceRoot([]*enginev1.Withdrawal{}, fieldparams.MaxWithdrawalsPerPayload) | ||
| require.NoError(t, err) | ||
| req.Block.Body.ExecutionPayloadHeader.WithdrawalsRoot = withdrawalsRoot[:] | ||
| util.SaveBlock(t, ctx, beaconDB, req) | ||
| blockSsz, err := req.MarshalSSZ() | ||
| require.NoError(t, err) | ||
|
|
@@ -580,10 +590,12 @@ func TestSubmitBlindedBlock(t *testing.T) { | |
| require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state") | ||
|
|
||
| c := &mock.ChainService{Root: bsRoot[:], State: beaconState} | ||
| p := emptyPayload() | ||
| p.Transactions = transactions | ||
| alphaServer := &validator.Server{ | ||
| SyncCommitteePool: synccommittee.NewStore(), | ||
| P2P: &mockp2p.MockBroadcaster{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{HasConfigured: true, Payload: p}, | ||
| BlockReceiver: c, | ||
| BlockNotifier: &mock.MockBlockNotifier{}, | ||
| } | ||
|
|
@@ -651,10 +663,13 @@ func TestSubmitBlindedBlock(t *testing.T) { | |
| require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state") | ||
|
|
||
| c := &mock.ChainService{Root: bsRoot[:], State: beaconState} | ||
| p := emptyPayloadCapella() | ||
| p.Transactions = transactions | ||
| p.Withdrawals = withdrawals | ||
| alphaServer := &validator.Server{ | ||
| SyncCommitteePool: synccommittee.NewStore(), | ||
| P2P: &mockp2p.MockBroadcaster{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{}, | ||
| BlockBuilder: &builderTest.MockBuilderService{HasConfigured: true, PayloadCapella: p}, | ||
| BlockReceiver: c, | ||
| BlockNotifier: &mock.MockBlockNotifier{}, | ||
| } | ||
|
|
@@ -687,3 +702,34 @@ func TestSubmitBlindedBlock(t *testing.T) { | |
| assert.NoError(t, err) | ||
| }) | ||
| } | ||
|
|
||
| func emptyPayload() *enginev1.ExecutionPayload { | ||
| return &enginev1.ExecutionPayload{ | ||
| ParentHash: make([]byte, fieldparams.RootLength), | ||
| FeeRecipient: make([]byte, fieldparams.FeeRecipientLength), | ||
| StateRoot: make([]byte, fieldparams.RootLength), | ||
| ReceiptsRoot: make([]byte, fieldparams.RootLength), | ||
| LogsBloom: make([]byte, fieldparams.LogsBloomLength), | ||
| PrevRandao: make([]byte, fieldparams.RootLength), | ||
| BaseFeePerGas: make([]byte, fieldparams.RootLength), | ||
| BlockHash: make([]byte, fieldparams.RootLength), | ||
| Transactions: make([][]byte, 0), | ||
| ExtraData: make([]byte, 0), | ||
| } | ||
| } | ||
|
|
||
| func emptyPayloadCapella() *enginev1.ExecutionPayloadCapella { | ||
| return &enginev1.ExecutionPayloadCapella{ | ||
| ParentHash: make([]byte, fieldparams.RootLength), | ||
| FeeRecipient: make([]byte, fieldparams.FeeRecipientLength), | ||
| StateRoot: make([]byte, fieldparams.RootLength), | ||
| ReceiptsRoot: make([]byte, fieldparams.RootLength), | ||
| LogsBloom: make([]byte, fieldparams.LogsBloomLength), | ||
| PrevRandao: make([]byte, fieldparams.RootLength), | ||
| BaseFeePerGas: make([]byte, fieldparams.RootLength), | ||
| BlockHash: make([]byte, fieldparams.RootLength), | ||
| Transactions: make([][]byte, 0), | ||
| Withdrawals: make([]*enginev1.Withdrawal, 0), | ||
| ExtraData: make([]byte, 0), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we put these fields in the same order as the consensus types? That would make this code a little easier to compare to generated protobuf code.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean exactly? In consensus types we have an |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presumably this omits BlockNumber, GasLimit, GasUsed, Timestamp because they are uint64s so they receive zero values, but we may want to always include all fields in functions like this as a matter of course to help verify completeness.