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

Add block setters for consensus type #11751

Merged
merged 13 commits into from
Dec 13, 2022
Merged

Conversation

terencechain
Copy link
Member

@terencechain terencechain commented Dec 10, 2022

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

@terencechain terencechain self-assigned this Dec 10, 2022
@terencechain terencechain force-pushed the add-block-getters branch 2 times, most recently from a565392 to 1df6f2e Compare December 11, 2022 09:08
@terencechain terencechain marked this pull request as ready for review December 11, 2022 10:11
@terencechain terencechain requested a review from a team as a code owner December 11, 2022 10:11
Copy link
Member

@nisdas nisdas left a 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

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt a getter

@terencechain
Copy link
Member Author

I think the title of the PR should indicate that this also implements block setters

Big typo for the title. It's meant to write block setters lol

@terencechain terencechain changed the title Add block getters Add block setters Dec 12, 2022
@terencechain terencechain changed the title Add block setters Add block setters for consensus type Dec 12, 2022
@@ -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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these changes?

Copy link
Member Author

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

@@ -155,6 +155,16 @@ func (e executionPayload) WithdrawalsRoot() ([]byte, error) {
return nil, ErrUnsupportedGetter
}

// PbV1 --
func (e executionPayload) PbV1() (*enginev1.ExecutionPayload, error) {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not tested

@@ -155,6 +155,16 @@ func (e executionPayload) WithdrawalsRoot() ([]byte, error) {
return nil, ErrUnsupportedGetter
}

// PbV1 --
func (e executionPayload) PbV1() (*enginev1.ExecutionPayload, error) {
Copy link
Contributor

@rkapka rkapka Dec 12, 2022

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?

consensus-types/blocks/setters.go Outdated Show resolved Hide resolved
@prylabs-bulldozer prylabs-bulldozer bot merged commit 3fcdd58 into develop Dec 13, 2022
@delete-merged-branch delete-merged-branch bot deleted the add-block-getters branch December 13, 2022 00:03
roberto-bayardo pushed a commit to roberto-bayardo/prysm that referenced this pull request Dec 17, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants