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

Implement and add changes for EIPs 7002, 6110, 7685 #10533

Merged
merged 26 commits into from
Jun 5, 2024
Merged

Conversation

somnathb1
Copy link
Contributor

@somnathb1 somnathb1 commented May 28, 2024

Context
The three EIPs are inter-linked through EIP-7685. Withdrawal requests (EIP-7002) are to be dequeued from execution through system call, and deposit requests (EIP-6110) are to be extracted from logs; both updated into Requests list in the block and custom RLP-encoded

Summary of changes

  • Make Request an interface and can be either Deposit or Withdrawal
  • Requests is an array of requests with custom encoding rules
  • Move logic for handling these to Finalize in merge.go - the only consensus for supporting these
  • Regenerate gencodec
  • Add four execution spec test files - the ones related to EIP-6110 and EIP-7002

@somnathb1 somnathb1 marked this pull request as draft May 28, 2024 21:29
@yperbasis yperbasis added the pectra The Prague/Electra protocol upgrade label May 29, 2024
@somnathb1 somnathb1 marked this pull request as ready for review June 3, 2024 12:08
@somnathb1
Copy link
Contributor Author

P.S. There would be subsequent PRs/Changes for accommodating other protocol changes around these EIPs, this one adds type and execution support

@@ -65,6 +65,7 @@ type Genesis struct {
BlobGasUsed *uint64 `json:"blobGasUsed"` // EIP-4844
ExcessBlobGas *uint64 `json:"excessBlobGas"` // EIP-4844
ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"` // EIP-4788
RequestsRoot *common.Hash `json:"requestsRoot"` // EIP-7685
Copy link
Member

@yperbasis yperbasis Jun 4, 2024

Choose a reason for hiding this comment

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

Do we actually need to support non-default (nil pre-Pectra, empty post-Pectra) RequestsRoot in genesis?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The genesis block could be Pectra

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but GenesisToBlock already correctly sets requests to empty (but non-nil) for Pectra. head.RequestsRoot will be set accordingly by NewBlock at the end of GenesisToBlock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, this has been kept at the moment as support for the type, as the spec tests have requestsRoot in genesis header. Could be removed in a later PR

consensus/merge/merge.go Outdated Show resolved Hide resolved
consensus/merge/merge.go Show resolved Hide resolved
core/blockchain.go Show resolved Hide resolved
return nil, nil, nil, fmt.Errorf("error: invalid requests root hash in header, expected: %v, got :%v", header.RequestsRoot, rh)
}
sds := requests.Deposits()
if !reflect.DeepEqual(sds, ds.Deposits()) {
Copy link
Member

Choose a reason for hiding this comment

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

We probably need a similar check for withdrawal requests - see https://discord.com/channels/595666850260713488/892088344438255616/1247841586147229696

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Withdrawal request validations are done at the smart contract itself, so dequeue would get out the exact set of withdrawals.
Deposits are obtained from logs, which happens outside of EVM and in the above lines, and must be checked.
However, this check is already embedded with checking the requestsRoot as there is no scenario in which a different set of deposits passed in would lead to the same requestsRoot.

Copy link
Member

Choose a reason for hiding this comment

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

I still don't understand why there should be a difference between deposit and withdrawal requests in terms of checks. At the end of a block expected deposit requests are calculated by ParseDepositLogs(logs), while withdrawal requests are calculated by DequeueWithdrawalRequests7002(syscall). If we rely solely on the *header.RequestsRoot != rh check for withdrawal requests, then we should do the same for deposit ones and remove the !reflect.DeepEqual(sds, ds.Deposits()) check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will add the DeepEqual check for withdrawal_requests in a later PR - under the assumption that there can be other request types in future.
Alternatively, until there is another type of request introduced, we can remove this check altogether and rely on block.HashCheck() combined with the root check above

Copy link
Member

@yperbasis yperbasis left a comment

Choose a reason for hiding this comment

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

Overall, the PR looks good IMO. We can probably merge it and iron out small details later.

@somnathb1 somnathb1 enabled auto-merge (squash) June 5, 2024 15:36
@somnathb1 somnathb1 merged commit 366b109 into main Jun 5, 2024
10 checks passed
@somnathb1 somnathb1 deleted the som/eip7002 branch June 5, 2024 16:02
yperbasis added a commit that referenced this pull request Oct 1, 2024
AskAlexSharov pushed a commit that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pectra The Prague/Electra protocol upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement EIP-7002: Execution layer triggerable exits Implement EIP-6110: Supply validator deposits on chain
2 participants