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

Reconstruct full Capella block #11732

Merged
merged 21 commits into from
Dec 14, 2022
Merged

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Dec 7, 2022

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Extends the engine client with the ability to reconstruct full Capella blocks from blinded Capella blocks.

Which issues(s) does this PR fix?

Part of Capella

(cherry picked from commit b060158)

# Conflicts:
#	beacon-chain/rpc/eth/beacon/blocks.go
#	proto/engine/v1/json_marshal_unmarshal.go
@rkapka rkapka requested a review from a team as a code owner December 7, 2022 15:16
@rkapka rkapka requested review from kasey, potuz and symbolpunk December 7, 2022 15:16
@rkapka rkapka changed the title Merge branch 'reconstruct-capella-block' into capella Recontruct full Capella block Dec 7, 2022
@rkapka rkapka added Withdrawals Ready For Review A pull request ready for code review labels Dec 7, 2022
@rkapka rkapka changed the title Recontruct full Capella block Reconstruct full Capella block Dec 9, 2022
@@ -92,6 +93,7 @@ func (s *Service) getBlkParentHashAndTD(ctx context.Context, blkHash []byte) ([]
if blk == nil {
return nil, nil, errors.New("pow block is nil")
}
blk.Version = version.Bellatrix
Copy link
Member

Choose a reason for hiding this comment

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

Why set this ? Shouldn't it already have its version set in the ExecutionBlockByHash method ? Or are you not able to infer that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not able to infer from how ExecutionBlockByHash is implemented. I can add a version argument, but this seems cleaner to me.

@@ -437,11 +437,12 @@ func (s *Service) ReconstructFullBellatrixBlock(
if executionBlock == nil {
return nil, fmt.Errorf("received nil execution block for request by hash %#x", executionBlockHash)
}
executionBlock.Version = blindedBlock.Version()
Copy link
Member

Choose a reason for hiding this comment

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

Same question here

// ToBytes20 is a convenience method for converting a byte slice to a fix
// sized 20 byte array. This method will truncate the input if it is larger
// than 20 bytes.
func ToBytes20(x []byte) [20]byte {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some unit tests for this ?


rawWithdrawals, ok := decoded["withdrawals"]
if !ok || rawWithdrawals == nil {
e.Version = version.Bellatrix
Copy link
Member

Choose a reason for hiding this comment

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

Do we know this for sure ? This just means there are 0 withdrawals in the payload.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I asked on Discord and we have this now: ethereum/execution-apis#334.

@rkapka rkapka mentioned this pull request Dec 13, 2022
28 tasks
return w, nil
}

func (w *Withdrawal) toWithdrawalJSON() (*withdrawalJSON, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This is an odd method, why do we have it ?

Copy link
Contributor Author

@rkapka rkapka Dec 13, 2022

Choose a reason for hiding this comment

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

I use it here:

ws := make([]*withdrawalJSON, len(e.Withdrawals))
for i, w := range e.Withdrawals {
	ws[i], err = w.toWithdrawalJSON() <-- HERE
	if err != nil {
		return nil, err
	}
}
decoded["withdrawals"] = ws

@prylabs-bulldozer prylabs-bulldozer bot merged commit 1fbb3f3 into develop Dec 14, 2022
@delete-merged-branch delete-merged-branch bot deleted the recontruct-capella-blinded branch December 14, 2022 13:42
roberto-bayardo pushed a commit to roberto-bayardo/prysm that referenced this pull request Dec 17, 2022
* Merge branch 'reconstruct-capella-block' into capella

(cherry picked from commit b060158)

# Conflicts:
#	beacon-chain/rpc/eth/beacon/blocks.go
#	proto/engine/v1/json_marshal_unmarshal.go

* remove unneeded test

* rename methods

* add doc to interface

* deepsource

(cherry picked from commit 903cab7)

# Conflicts:
#	beacon-chain/execution/testing/mock_engine_client.go

* bzl

* fix failing tests

* single ExecutionBlockByHash function

* fix engine mock

* deepsource

* reorder checks

* single execution block type

* update tests

* update doc

* bytes test

* remove toWithdrawalJSON

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants