Skip to content

Merge all block unblinding code into a single unblinder struct#12232

Merged
terencechain merged 7 commits intoeip4844from
eip4844-unblinder
Apr 5, 2023
Merged

Merge all block unblinding code into a single unblinder struct#12232
terencechain merged 7 commits intoeip4844from
eip4844-unblinder

Conversation

@rkapka
Copy link
Contributor

@rkapka rkapka commented Apr 3, 2023

What type of PR is this?

Other

What does this PR do? Why is it needed?

This PR creates a new unblinder type responsible for (wait for it...) unblinding blocks. The main purpose of the type is to reduce code duplication and keep unblinding logic in one place. It can easily be extended for Deneb blocks.

@rkapka rkapka requested a review from a team as a code owner April 3, 2023 15:55
@rkapka rkapka requested review from potuz, saolyn and terencechain and removed request for a team April 3, 2023 15:55
@rkapka rkapka force-pushed the eip4844-unblinder branch from 456ff44 to ceddae7 Compare April 3, 2023 16:06
if !u.b.IsBlinded() {
return u.b, nil
}
if u.b.Version() != u.version {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should never happen when using newUnblinder because u.version is set from u.b.Version(), but it might happen when setting fields by hand. We could also remove the version field all together and always read the block's version.

@rkapka rkapka marked this pull request as draft April 3, 2023 21:52
@rkapka
Copy link
Contributor Author

rkapka commented Apr 3, 2023

Converted to draft because there is a failing test

@rkapka rkapka marked this pull request as ready for review April 4, 2023 09:59
Copy link
Collaborator

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

Lgtm, a minor feedback on potentially removing separate version tracking

)

type unblinder struct {
version int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't we just read block's version directly?

Comment on lines +35 to +37
if !u.b.IsBlinded() || !u.builder.Configured() || u.version < version.Bellatrix {
return u.b, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I reckon if today we are stuck with the following

  • block is blinded
  • builder is not configured

The function should probably explicitly error out. It's better than broadcasting a blind block

@rkapka rkapka changed the base branch from eip4844 to develop April 5, 2023 13:19
@rkapka rkapka requested a review from prestonvanloon as a code owner April 5, 2023 13:19
@rkapka rkapka changed the base branch from develop to eip4844 April 5, 2023 13:20
@terencechain terencechain merged commit ffacd27 into eip4844 Apr 5, 2023
@delete-merged-branch delete-merged-branch bot deleted the eip4844-unblinder branch April 5, 2023 13:49
rkapka added a commit that referenced this pull request Apr 5, 2023
)

# Conflicts:
#	beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go
#	beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix_test.go
#	beacon-chain/rpc/prysm/v1alpha1/validator/proposer_capella.go
#	beacon-chain/rpc/prysm/v1alpha1/validator/proposer_capella_test.go
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.

2 participants