-
Notifications
You must be signed in to change notification settings - Fork 257
[WIP] feat(deposits): Introduce Electra1 fork for EIP-6110 style processing #2794
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
Draft
calbera
wants to merge
22
commits into
main
Choose a base branch
from
tmp-6110-poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a86f4b7
bet
calbera 275e139
nit
calbera fbfdcc5
empty eth1data
calbera d39fb79
nit
calbera a6f4d3b
more simplifications
calbera 65c201c
lint
calbera 2e3098d
process electra1 fork
calbera b7dae5e
EL genesis config update
calbera 9ea411b
lint
calbera 2b364dd
upgradeToElectra1
calbera c847971
Merge branch 'main' of github.com:berachain/beacon-kit into tmp-6110-poc
calbera 2df992f
fix some unit tests
calbera 3b0912a
fix withdrawals fork handling
calbera 3a88dba
refactor for readability
calbera af9313c
nit
calbera 741e0d0
fix nilaway
calbera d7d485c
Merge branch 'main' of github.com:berachain/beacon-kit into tmp-6110-poc
calbera fdac98b
handle all fork versions
calbera 3b9f7f0
Merge branch 'main' of github.com:berachain/beacon-kit into tmp-6110-poc
calbera e283f37
lint
calbera f544fc1
Merge branch 'main' into tmp-6110-poc
calbera 9742809
Merge branch 'main' into tmp-6110-poc
calbera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,50 +37,63 @@ func (sp *StateProcessor) processOperations( | |
| st *state.StateDB, | ||
| blk *ctypes.BeaconBlock, | ||
| ) error { | ||
| // Verify that outstanding deposits are processed up to the maximum number of deposits. | ||
| // | ||
| // Unlike Eth 2.0 specs we don't check that | ||
| // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)` | ||
| deposits := blk.GetBody().GetDeposits() | ||
| if uint64(len(deposits)) > sp.cs.MaxDepositsPerBlock() { | ||
| return errors.Wrapf( | ||
| ErrExceedsBlockDepositLimit, "expected: %d, got: %d", | ||
| sp.cs.MaxDepositsPerBlock(), len(deposits), | ||
| ) | ||
| // Before Electra1, deposits are processed from the beacon block body directly. | ||
| if version.IsBefore(blk.GetForkVersion(), version.Electra1()) { | ||
| // Verify that outstanding deposits are processed up to the maximum number of deposits. | ||
| // | ||
| // Unlike Ethereum 2.0 specs, we don't check that | ||
| // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)`. | ||
| deposits := blk.GetBody().GetDeposits() | ||
| if uint64(len(deposits)) > sp.cs.MaxDepositsPerBlock() { | ||
| return errors.Wrapf( | ||
| ErrExceedsBlockDepositLimit, "expected: %d, got: %d", | ||
| sp.cs.MaxDepositsPerBlock(), len(deposits), | ||
| ) | ||
| } | ||
|
|
||
| // Instead, we directly compare block deposits with our local store ones. | ||
| if err := ValidateNonGenesisDeposits( | ||
| ctx.ConsensusCtx(), | ||
| st, | ||
| sp.ds, | ||
| sp.cs.MaxDepositsPerBlock(), | ||
| deposits, | ||
| blk.GetBody().GetEth1Data().DepositRoot, | ||
| ); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| for _, dep := range deposits { | ||
| if err := sp.processDeposit(st, dep); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| return st.SetEth1Data(blk.GetBody().Eth1Data) | ||
| } | ||
|
|
||
| // Instead we directly compare block deposits with our local store ones. | ||
| if err := ValidateNonGenesisDeposits( | ||
| ctx.ConsensusCtx(), | ||
| st, | ||
| sp.ds, | ||
| sp.cs.MaxDepositsPerBlock(), | ||
| deposits, | ||
| blk.GetBody().GetEth1Data().DepositRoot, | ||
| ); err != nil { | ||
| // After Electra1, validators increase/decrease stake through execution requests which must | ||
| // be handled. | ||
| requests, err := blk.GetBody().GetExecutionRequests() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| for _, dep := range deposits { | ||
| if err := sp.processDeposit(st, dep); err != nil { | ||
| return err | ||
| // EIP-7002 Withdrawals. | ||
| for _, withdrawal := range requests.Withdrawals { | ||
| if withdrawErr := sp.processWithdrawalRequest(st, withdrawal); withdrawErr != nil { | ||
| return withdrawErr | ||
| } | ||
| } | ||
|
|
||
| if version.EqualsOrIsAfter(blk.GetForkVersion(), version.Electra()) { | ||
| // After Electra, validators can request withdrawals through execution requests which must be handled. | ||
| requests, err := blk.GetBody().GetExecutionRequests() | ||
| if err != nil { | ||
| // EIP-6110 Deposits. | ||
| for _, dep := range requests.Deposits { | ||
|
||
| if err = sp.processDeposit(st, dep); err != nil { | ||
| return err | ||
| } | ||
| for _, withdrawal := range requests.Withdrawals { | ||
| if withdrawErr := sp.processWithdrawalRequest(st, withdrawal); withdrawErr != nil { | ||
| return withdrawErr | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return st.SetEth1Data(blk.GetBody().Eth1Data) | ||
| return st.SetEth1Data(ctypes.NewEmptyEth1Data()) | ||
| } | ||
|
|
||
| // processDeposit processes the deposit and ensures it matches the local state. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.