-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
skip eth1data voting after electra #14835
Merged
Merged
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3332fd4
wip skip eth1data voting after electra
james-prysm 66b3a9f
updating technique
james-prysm 8f7c646
adding fix for electra eth1 voting
james-prysm 4af4b28
fixing linting on test
james-prysm e62fd0f
Merge branch 'develop' into electra-eth1voting
james-prysm 71d07f8
seeing if reversing genesis state fixes problem
james-prysm 8c6eb5a
increasing safety of legacy check
james-prysm addcd96
review feedback
james-prysm e47f6a5
forgot to fix tests
james-prysm d7360c6
Merge branch 'develop' into electra-eth1voting
james-prysm 63a18cb
nishant's feedback
james-prysm d5f1ee4
nishant's feedback
james-prysm 765629a
rename function a little
james-prysm e165797
Update beacon-chain/core/helpers/legacy.go
james-prysm ea62405
fixing naming
james-prysm 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 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 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package helpers | ||
|
||
import ( | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
"github.com/prysmaticlabs/prysm/v5/math" | ||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/v5/runtime/version" | ||
) | ||
|
||
// IsLegacyDepositProcessPeriod determines if the current state should use the legacy deposit process. | ||
func IsLegacyDepositProcessPeriod(beaconState state.BeaconState, canonicalEth1Data *ethpb.Eth1Data) bool { | ||
// Before the Electra upgrade, always use the legacy deposit process. | ||
if beaconState.Version() < version.Electra { | ||
return true | ||
} | ||
|
||
// Handle the transition period between the legacy and the new deposit process. | ||
requestsStartIndex, err := beaconState.DepositRequestsStartIndex() | ||
if err != nil { | ||
// If we can't get the deposit requests start index, | ||
// we should default to the legacy deposit process. | ||
return true | ||
} | ||
|
||
//canonicalEth1Data should never be nil | ||
eth1DepositIndexLimit := math.Min(canonicalEth1Data.DepositCount, requestsStartIndex) | ||
return beaconState.Eth1DepositIndex() < eth1DepositIndexLimit | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package helpers_test | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" | ||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIsLegacyDepositProcessPeriod(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
state state.BeaconState | ||
canonicalEth1Data *ethpb.Eth1Data | ||
want bool | ||
}{ | ||
{ | ||
name: "pre-electra", | ||
state: func() state.BeaconState { | ||
st, err := state_native.InitializeFromProtoDeneb(ðpb.BeaconStateDeneb{ | ||
Eth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
Eth1DepositIndex: 1, | ||
}) | ||
require.NoError(t, err) | ||
return st | ||
}(), | ||
canonicalEth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "post-electra, pending deposits from pre-electra", | ||
state: func() state.BeaconState { | ||
st, err := state_native.InitializeFromProtoElectra(ðpb.BeaconStateElectra{ | ||
Eth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
DepositRequestsStartIndex: math.MaxUint64, | ||
Eth1DepositIndex: 1, | ||
}) | ||
require.NoError(t, err) | ||
return st | ||
}(), | ||
canonicalEth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "post-electra, no pending deposits from pre-alpaca", | ||
state: func() state.BeaconState { | ||
st, err := state_native.InitializeFromProtoElectra(ðpb.BeaconStateElectra{ | ||
Eth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
DepositRequestsStartIndex: 1, | ||
Eth1DepositIndex: 5, | ||
}) | ||
require.NoError(t, err) | ||
return st | ||
}(), | ||
canonicalEth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := helpers.IsLegacyDepositProcessPeriod(tt.state, tt.canonicalEth1Data); got != tt.want { | ||
t.Errorf("isLegacyDepositProcessPeriod() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### Added | ||
|
||
- check to stop eth1 voting after electra and eth1 deposits stop |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets align with the spec here:
https://github.com/ethereum/consensus-specs/pull/4106/files#diff-e19b9b12060b1ca6cb9d3d340e2c770d227a4c602fa7ec7781be400ba8662aa2R161