-
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
Changes from 7 commits
3332fd4
66b3a9f
8f7c646
4af4b28
e62fd0f
71d07f8
8c6eb5a
addcd96
e47f6a5
d7360c6
63a18cb
d5f1ee4
765629a
e165797
ea62405
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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 | ||
} | ||
|
||
// Should not happen, but if the canonicalEth1Data is nil | ||
// default to legacy | ||
if canonicalEth1Data == nil { | ||
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 | ||
} | ||
eth1DepositIndexLimit := math.Min(canonicalEth1Data.DepositCount, requestsStartIndex) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return beaconState.Eth1DepositIndex() < eth1DepositIndexLimit | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
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: "nil canonicalEth1Data defaults to legacy", | ||
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: nil, | ||
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) | ||
} | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"github.com/pkg/errors" | ||
fastssz "github.com/prysmaticlabs/fastssz" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/blocks" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
"github.com/prysmaticlabs/prysm/v5/config/features" | ||
"github.com/prysmaticlabs/prysm/v5/config/params" | ||
|
@@ -30,10 +31,17 @@ import ( | |
// - Otherwise: | ||
// - Determine the vote with the highest count. Prefer the vote with the highest eth1 block height in the event of a tie. | ||
// - This vote's block is the eth1 block to use for the block proposal. | ||
// | ||
// After Electra and eth1 deposit transition period voting will no longer be needed | ||
func (vs *Server) eth1DataMajorityVote(ctx context.Context, beaconState state.BeaconState) (*ethpb.Eth1Data, error) { | ||
ctx, cancel := context.WithTimeout(ctx, eth1dataTimeout) | ||
defer cancel() | ||
|
||
// post eth1 deposits, the Eth 1 data will then be frozen | ||
if !helpers.IsLegacyDepositProcessPeriod(beaconState, vs.HeadFetcher.HeadETH1Data()) { | ||
return vs.HeadFetcher.HeadETH1Data(), nil | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First, I'm not quite sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats's a good point should just do it from beacon state. there is an update to the spec here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i should rename to Requests oops |
||
slot := beaconState.Slot() | ||
votingPeriodStartTime := vs.slotStartTime(slot) | ||
|
||
|
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 |
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.
is this fine?
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.
This should be impossible, I don't think this is the right approach