-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add block setters for consensus type #11751
Conversation
This reverts commit 1ae5db7.
a565392
to
1df6f2e
Compare
9cddfd2
to
490d110
Compare
490d110
to
f7142a6
Compare
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.
I think the title of the PR should indicate that this also implements block setters
consensus-types/blocks/getters.go
Outdated
@@ -751,6 +786,11 @@ func (b *BeaconBlockBody) Graffiti() [field_params.RootLength]byte { | |||
return b.graffiti | |||
} | |||
|
|||
// SetGraffiti sets the graffiti in the block. | |||
func (b *BeaconBlockBody) SetGraffiti(g []byte) { |
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.
this isnt a getter
Big typo for the title. It's meant to write block setters lol |
@@ -39,7 +39,9 @@ func TestExecuteStateTransitionNoVerify_FullProcess(t *testing.T) { | |||
require.NoError(t, err) | |||
require.NoError(t, beaconState.SetSlot(beaconState.Slot()-1)) | |||
|
|||
nextSlotState, err := transition.ProcessSlots(context.Background(), beaconState.Copy(), beaconState.Slot()+1) |
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.
Why these changes?
@@ -95,7 +97,9 @@ func TestExecuteStateTransitionNoVerifySignature_CouldNotVerifyStateRoot(t *test | |||
require.NoError(t, err) | |||
require.NoError(t, beaconState.SetSlot(beaconState.Slot()-1)) | |||
|
|||
nextSlotState, err := transition.ProcessSlots(context.Background(), beaconState.Copy(), beaconState.Slot()+1) |
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.
Why these changes?
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.
Sorry. It's meant for another PR
consensus-types/blocks/execution.go
Outdated
@@ -155,6 +155,16 @@ func (e executionPayload) WithdrawalsRoot() ([]byte, error) { | |||
return nil, ErrUnsupportedGetter | |||
} | |||
|
|||
// PbV1 -- | |||
func (e executionPayload) PbV1() (*enginev1.ExecutionPayload, error) { |
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.
All these PbVx from the different targets are not tested.
@@ -731,6 +731,41 @@ func (b *BeaconBlock) AsSignRequestObject() (validatorpb.SignRequestObject, erro | |||
} | |||
} | |||
|
|||
func (b *BeaconBlock) Copy() (interfaces.BeaconBlock, error) { |
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.
This is not tested
consensus-types/blocks/execution.go
Outdated
@@ -155,6 +155,16 @@ func (e executionPayload) WithdrawalsRoot() ([]byte, error) { | |||
return nil, ErrUnsupportedGetter | |||
} | |||
|
|||
// PbV1 -- | |||
func (e executionPayload) PbV1() (*enginev1.ExecutionPayload, error) { |
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.
Do we really want to name things PbV1
/PbV2
instead of Pb
/PbCapella
or PbBellatrix
/PbCapella
? It might be misleading because all protobufs are under the enginev1
package. I understand this convention comes from the builder API?
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
…to add-block-getters
* Add block getters * Rm changes * Rm changes * Revert "Rm changes" This reverts commit 1ae5db7. * Fix tests * Set graffiti right place * Potuz feedback * Update consensus-types/blocks/setters.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Radek feedback * Fix comments Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Pat of #11629
This PR adds block setters which is very useful for block construction for validators. We no longer need to duplicate every protobuf-specific functions for every hard fork.
Note: Setting a field in a block as currently designed is not thread-safe, the only caller is the proposer at the block construction stage. This is similar to what we have today with setting state root. I'll be happy to change this to a thread-safe model with lock if there's feedback