mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 15:13:57 -05:00
Update 3068 (#11656)
* rename last_withdrawal_validator_index * Update Capella methods to Specs #3068 * Add missing renames * rename minimal state Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash/htr"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
@@ -110,7 +111,11 @@ func ProcessWithdrawals(st state.BeaconState, withdrawals []*enginev1.Withdrawal
|
||||
if err := st.SetNextWithdrawalIndex(withdrawals[len(withdrawals)-1].WithdrawalIndex + 1); err != nil {
|
||||
return nil, errors.Wrap(err, "could not set next withdrawal index")
|
||||
}
|
||||
if err := st.SetLastWithdrawalValidatorIndex(withdrawals[len(withdrawals)-1].ValidatorIndex); err != nil {
|
||||
nextValidatorIndex := withdrawals[len(withdrawals)-1].ValidatorIndex + 1
|
||||
if nextValidatorIndex == types.ValidatorIndex(st.NumValidators()) {
|
||||
nextValidatorIndex = 0
|
||||
}
|
||||
if err := st.SetNextWithdrawalValidatorIndex(nextValidatorIndex); err != nil {
|
||||
return nil, errors.Wrap(err, "could not set latest withdrawal validator index")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,14 +210,14 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
|
||||
type args struct {
|
||||
Name string
|
||||
LastWithdrawalValidatorIndex types.ValidatorIndex
|
||||
NextWithdrawalValidatorIndex types.ValidatorIndex
|
||||
NextWithdrawalIndex uint64
|
||||
FullWithdrawalIndices []types.ValidatorIndex
|
||||
PartialWithdrawalIndices []types.ValidatorIndex
|
||||
Withdrawals []*enginev1.Withdrawal
|
||||
}
|
||||
type control struct {
|
||||
LastWithdrawalValidatorIndex types.ValidatorIndex
|
||||
NextWithdrawalValidatorIndex types.ValidatorIndex
|
||||
NextWithdrawalIndex uint64
|
||||
ExpectedError bool
|
||||
Balances map[uint64]uint64
|
||||
@@ -254,11 +254,11 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
{
|
||||
Args: args{
|
||||
Name: "success no withdrawals",
|
||||
LastWithdrawalValidatorIndex: 10,
|
||||
NextWithdrawalValidatorIndex: 10,
|
||||
NextWithdrawalIndex: 3,
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 10,
|
||||
NextWithdrawalValidatorIndex: 10,
|
||||
NextWithdrawalIndex: 3,
|
||||
},
|
||||
},
|
||||
@@ -266,14 +266,14 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "success one full withdrawal",
|
||||
NextWithdrawalIndex: 3,
|
||||
LastWithdrawalValidatorIndex: 5,
|
||||
NextWithdrawalValidatorIndex: 5,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{1},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(1, 3),
|
||||
},
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 1,
|
||||
NextWithdrawalValidatorIndex: 2,
|
||||
NextWithdrawalIndex: 4,
|
||||
Balances: map[uint64]uint64{1: 0},
|
||||
},
|
||||
@@ -282,14 +282,14 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "success one partial withdrawal",
|
||||
NextWithdrawalIndex: 21,
|
||||
LastWithdrawalValidatorIndex: 37,
|
||||
NextWithdrawalValidatorIndex: 37,
|
||||
PartialWithdrawalIndices: []types.ValidatorIndex{7},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
partialWithdrawal(7, 21),
|
||||
},
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 7,
|
||||
NextWithdrawalValidatorIndex: 8,
|
||||
NextWithdrawalIndex: 22,
|
||||
Balances: map[uint64]uint64{7: maxEffectiveBalance},
|
||||
},
|
||||
@@ -298,7 +298,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "success many full withdrawals",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 4,
|
||||
NextWithdrawalValidatorIndex: 4,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{7, 19, 28, 1},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(7, 22), fullWithdrawal(19, 23), fullWithdrawal(28, 24),
|
||||
@@ -306,7 +306,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 1,
|
||||
NextWithdrawalValidatorIndex: 2,
|
||||
NextWithdrawalIndex: 26,
|
||||
Balances: map[uint64]uint64{7: 0, 19: 0, 28: 0, 1: 0},
|
||||
},
|
||||
@@ -315,7 +315,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "success many partial withdrawals",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 4,
|
||||
NextWithdrawalValidatorIndex: 4,
|
||||
PartialWithdrawalIndices: []types.ValidatorIndex{7, 19, 28, 1},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
partialWithdrawal(7, 22), partialWithdrawal(19, 23), partialWithdrawal(28, 24),
|
||||
@@ -323,7 +323,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 1,
|
||||
NextWithdrawalValidatorIndex: 2,
|
||||
NextWithdrawalIndex: 26,
|
||||
Balances: map[uint64]uint64{
|
||||
7: maxEffectiveBalance,
|
||||
@@ -337,7 +337,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "success many withdrawals",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 12,
|
||||
NextWithdrawalValidatorIndex: 12,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{7, 19, 28},
|
||||
PartialWithdrawalIndices: []types.ValidatorIndex{2, 1, 89, 15},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
@@ -347,7 +347,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 7,
|
||||
NextWithdrawalValidatorIndex: 8,
|
||||
NextWithdrawalIndex: 29,
|
||||
Balances: map[uint64]uint64{
|
||||
7: 0, 19: 0, 28: 0,
|
||||
@@ -360,7 +360,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "success more than max fully withdrawals",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 0,
|
||||
NextWithdrawalValidatorIndex: 0,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{1, 2, 3, 4, 5, 6, 7, 8, 9, 21, 22, 23, 24, 25, 26, 27, 29, 35, 89},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(1, 22), fullWithdrawal(2, 23), fullWithdrawal(3, 24),
|
||||
@@ -372,7 +372,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 27,
|
||||
NextWithdrawalValidatorIndex: 28,
|
||||
NextWithdrawalIndex: 38,
|
||||
Balances: map[uint64]uint64{
|
||||
1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,
|
||||
@@ -384,7 +384,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "success more than max partially withdrawals",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 0,
|
||||
NextWithdrawalValidatorIndex: 0,
|
||||
PartialWithdrawalIndices: []types.ValidatorIndex{1, 2, 3, 4, 5, 6, 7, 8, 9, 21, 22, 23, 24, 25, 26, 27, 29, 35, 89},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
partialWithdrawal(1, 22), partialWithdrawal(2, 23), partialWithdrawal(3, 24),
|
||||
@@ -396,7 +396,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Control: control{
|
||||
LastWithdrawalValidatorIndex: 27,
|
||||
NextWithdrawalValidatorIndex: 28,
|
||||
NextWithdrawalIndex: 38,
|
||||
Balances: map[uint64]uint64{
|
||||
1: maxEffectiveBalance,
|
||||
@@ -422,7 +422,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "failure wrong number of partial withdrawal",
|
||||
NextWithdrawalIndex: 21,
|
||||
LastWithdrawalValidatorIndex: 37,
|
||||
NextWithdrawalValidatorIndex: 37,
|
||||
PartialWithdrawalIndices: []types.ValidatorIndex{7},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
partialWithdrawal(7, 21), partialWithdrawal(9, 22),
|
||||
@@ -436,7 +436,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "failure invalid withdrawal index",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 4,
|
||||
NextWithdrawalValidatorIndex: 4,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{7, 19, 28, 1},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(7, 22), fullWithdrawal(19, 23), fullWithdrawal(28, 25),
|
||||
@@ -451,7 +451,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "failure invalid validator index",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 4,
|
||||
NextWithdrawalValidatorIndex: 4,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{7, 19, 28, 1},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(7, 22), fullWithdrawal(19, 23), fullWithdrawal(27, 24),
|
||||
@@ -466,7 +466,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "failure invalid withdrawal amount",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 4,
|
||||
NextWithdrawalValidatorIndex: 4,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{7, 19, 28, 1},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(7, 22), fullWithdrawal(19, 23), partialWithdrawal(28, 24),
|
||||
@@ -481,7 +481,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "failure validator not fully withdrawable",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 4,
|
||||
NextWithdrawalValidatorIndex: 4,
|
||||
FullWithdrawalIndices: []types.ValidatorIndex{notWithdrawableIndex},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(notWithdrawableIndex, 22),
|
||||
@@ -495,7 +495,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
Args: args{
|
||||
Name: "failure validator not partially withdrawable",
|
||||
NextWithdrawalIndex: 22,
|
||||
LastWithdrawalValidatorIndex: 4,
|
||||
NextWithdrawalValidatorIndex: 4,
|
||||
PartialWithdrawalIndices: []types.ValidatorIndex{notPartiallyWithdrawable},
|
||||
Withdrawals: []*enginev1.Withdrawal{
|
||||
fullWithdrawal(notPartiallyWithdrawable, 22),
|
||||
@@ -510,7 +510,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
checkPostState := func(t *testing.T, expected control, st state.BeaconState) {
|
||||
l, err := st.LastWithdrawalValidatorIndex()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected.LastWithdrawalValidatorIndex, l)
|
||||
require.Equal(t, expected.NextWithdrawalValidatorIndex, l)
|
||||
|
||||
n, err := st.NextWithdrawalIndex()
|
||||
require.NoError(t, err)
|
||||
@@ -563,7 +563,7 @@ func TestProcessWithdrawals(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
spb := ðpb.BeaconStateCapella{
|
||||
Slot: slot,
|
||||
LastWithdrawalValidatorIndex: test.Args.LastWithdrawalValidatorIndex,
|
||||
NextWithdrawalValidatorIndex: test.Args.NextWithdrawalValidatorIndex,
|
||||
NextWithdrawalIndex: test.Args.NextWithdrawalIndex,
|
||||
}
|
||||
st, err := prepareValidators(spb, test.Args)
|
||||
|
||||
@@ -89,7 +89,7 @@ func UpgradeToCapella(state state.BeaconState) (state.BeaconState, error) {
|
||||
WithdrawalsRoot: make([]byte, 32),
|
||||
},
|
||||
NextWithdrawalIndex: 0,
|
||||
LastWithdrawalValidatorIndex: 0,
|
||||
NextWithdrawalValidatorIndex: 0,
|
||||
}
|
||||
|
||||
return state_native.InitializeFromProtoUnsafeCapella(s)
|
||||
|
||||
@@ -87,7 +87,7 @@ type WriteOnlyBeaconState interface {
|
||||
AppendHistoricalRoots(root [32]byte) error
|
||||
SetLatestExecutionPayloadHeader(payload interfaces.ExecutionData) error
|
||||
SetNextWithdrawalIndex(i uint64) error
|
||||
SetLastWithdrawalValidatorIndex(i types.ValidatorIndex) error
|
||||
SetNextWithdrawalValidatorIndex(i types.ValidatorIndex) error
|
||||
}
|
||||
|
||||
// ReadOnlyValidator defines a struct which only has read access to validator methods.
|
||||
|
||||
@@ -48,7 +48,7 @@ type BeaconState struct {
|
||||
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader
|
||||
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
|
||||
nextWithdrawalIndex uint64
|
||||
lastWithdrawalValidatorIndex eth2types.ValidatorIndex
|
||||
nextWithdrawalValidatorIndex eth2types.ValidatorIndex
|
||||
|
||||
lock sync.RWMutex
|
||||
dirtyFields map[nativetypes.FieldIndex]bool
|
||||
|
||||
@@ -48,7 +48,7 @@ type BeaconState struct {
|
||||
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader
|
||||
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
|
||||
nextWithdrawalIndex uint64
|
||||
lastWithdrawalValidatorIndex eth2types.ValidatorIndex
|
||||
nextWithdrawalValidatorIndex eth2types.ValidatorIndex
|
||||
|
||||
lock sync.RWMutex
|
||||
dirtyFields map[nativetypes.FieldIndex]bool
|
||||
|
||||
@@ -125,7 +125,7 @@ func (b *BeaconState) ToProtoUnsafe() interface{} {
|
||||
NextSyncCommittee: b.nextSyncCommittee,
|
||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderCapella,
|
||||
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||
LastWithdrawalValidatorIndex: b.lastWithdrawalValidatorIndex,
|
||||
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
@@ -251,7 +251,7 @@ func (b *BeaconState) ToProto() interface{} {
|
||||
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderCapellaVal(),
|
||||
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||
LastWithdrawalValidatorIndex: b.lastWithdrawalValidatorIndex,
|
||||
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
|
||||
@@ -34,7 +34,7 @@ func (b *BeaconState) LastWithdrawalValidatorIndex() (types.ValidatorIndex, erro
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
|
||||
return b.lastWithdrawalValidatorIndex, nil
|
||||
return b.nextWithdrawalValidatorIndex, nil
|
||||
}
|
||||
|
||||
// ExpectedWithdrawals returns the withdrawals that a proposer will need to pack in the next block
|
||||
@@ -49,14 +49,13 @@ func (b *BeaconState) ExpectedWithdrawals() ([]*enginev1.Withdrawal, error) {
|
||||
defer b.lock.RUnlock()
|
||||
|
||||
withdrawals := make([]*enginev1.Withdrawal, 0, params.BeaconConfig().MaxWithdrawalsPerPayload)
|
||||
validatorIndex := b.lastWithdrawalValidatorIndex
|
||||
validatorIndex := b.nextWithdrawalValidatorIndex + 1
|
||||
if uint64(validatorIndex) == uint64(len(b.validators)) {
|
||||
validatorIndex = 0
|
||||
}
|
||||
withdrawalIndex := b.nextWithdrawalIndex
|
||||
epoch := slots.ToEpoch(b.slot)
|
||||
for range b.validators {
|
||||
validatorIndex += 1
|
||||
if uint64(validatorIndex) == uint64(len(b.validators)) {
|
||||
validatorIndex = types.ValidatorIndex(0)
|
||||
}
|
||||
val := b.validators[validatorIndex]
|
||||
balance := b.balances[validatorIndex]
|
||||
if isFullyWithdrawableValidator(val, epoch) {
|
||||
@@ -79,6 +78,10 @@ func (b *BeaconState) ExpectedWithdrawals() ([]*enginev1.Withdrawal, error) {
|
||||
if uint64(len(withdrawals)) == params.BeaconConfig().MaxWithdrawalsPerPayload {
|
||||
break
|
||||
}
|
||||
validatorIndex += 1
|
||||
if uint64(validatorIndex) == uint64(len(b.validators)) {
|
||||
validatorIndex = 0
|
||||
}
|
||||
}
|
||||
return withdrawals, nil
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestNextWithdrawalIndex(t *testing.T) {
|
||||
|
||||
func TestLastWithdrawalValidatorIndex(t *testing.T) {
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
s := BeaconState{version: version.Capella, lastWithdrawalValidatorIndex: 123}
|
||||
s := BeaconState{version: version.Capella, nextWithdrawalValidatorIndex: 123}
|
||||
i, err := s.LastWithdrawalValidatorIndex()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, types.ValidatorIndex(123), i)
|
||||
@@ -136,7 +136,7 @@ func TestExpectedWithdrawals(t *testing.T) {
|
||||
version: version.Capella,
|
||||
validators: make([]*ethpb.Validator, 100),
|
||||
balances: make([]uint64, 100),
|
||||
lastWithdrawalValidatorIndex: 20,
|
||||
nextWithdrawalValidatorIndex: 20,
|
||||
}
|
||||
for i := range s.validators {
|
||||
s.balances[i] = params.BeaconConfig().MaxEffectiveBalance
|
||||
|
||||
@@ -253,8 +253,8 @@ func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]b
|
||||
|
||||
// Next partial withdrawal validator index root.
|
||||
nextPartialWithdrawalValidatorIndexRoot := make([]byte, 32)
|
||||
binary.LittleEndian.PutUint64(nextPartialWithdrawalValidatorIndexRoot, uint64(state.lastWithdrawalValidatorIndex))
|
||||
fieldRoots[nativetypes.LastWithdrawalValidatorIndex.RealPosition()] = nextPartialWithdrawalValidatorIndexRoot
|
||||
binary.LittleEndian.PutUint64(nextPartialWithdrawalValidatorIndexRoot, uint64(state.nextWithdrawalValidatorIndex))
|
||||
fieldRoots[nativetypes.NextWithdrawalValidatorIndex.RealPosition()] = nextPartialWithdrawalValidatorIndexRoot
|
||||
}
|
||||
|
||||
return fieldRoots, nil
|
||||
|
||||
@@ -257,7 +257,7 @@ func TestComputeFieldRootsWithHasher_Capella(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconState.SetLatestExecutionPayloadHeader(wrappedHeader))
|
||||
require.NoError(t, beaconState.SetNextWithdrawalIndex(123))
|
||||
require.NoError(t, beaconState.SetLastWithdrawalValidatorIndex(123))
|
||||
require.NoError(t, beaconState.SetNextWithdrawalValidatorIndex(123))
|
||||
|
||||
nativeState, ok := beaconState.(*statenative.BeaconState)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
@@ -20,14 +20,14 @@ func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error {
|
||||
|
||||
// SetLastWithdrawalValidatorIndex sets the index of the validator which is
|
||||
// next in line for a partial withdrawal.
|
||||
func (b *BeaconState) SetLastWithdrawalValidatorIndex(i types.ValidatorIndex) error {
|
||||
func (b *BeaconState) SetNextWithdrawalValidatorIndex(i types.ValidatorIndex) error {
|
||||
if b.version < version.Capella {
|
||||
return errNotSupported("SetNextPartialWithdrawalValidatorIndex", b.version)
|
||||
return errNotSupported("SetNextWithdrawalValidatorIndex", b.version)
|
||||
}
|
||||
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
||||
b.lastWithdrawalValidatorIndex = i
|
||||
b.nextWithdrawalValidatorIndex = i
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ func TestSetNextWithdrawalIndex(t *testing.T) {
|
||||
func TestSetLastWithdrawalValidatorIndex(t *testing.T) {
|
||||
s := BeaconState{
|
||||
version: version.Capella,
|
||||
lastWithdrawalValidatorIndex: 3,
|
||||
nextWithdrawalValidatorIndex: 3,
|
||||
}
|
||||
require.NoError(t, s.SetLastWithdrawalValidatorIndex(5))
|
||||
require.Equal(t, types.ValidatorIndex(5), s.lastWithdrawalValidatorIndex)
|
||||
require.NoError(t, s.SetNextWithdrawalValidatorIndex(5))
|
||||
require.Equal(t, types.ValidatorIndex(5), s.nextWithdrawalValidatorIndex)
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ var capellaFields = append(
|
||||
altairFields,
|
||||
nativetypes.LatestExecutionPayloadHeaderCapella,
|
||||
nativetypes.NextWithdrawalIndex,
|
||||
nativetypes.LastWithdrawalValidatorIndex,
|
||||
nativetypes.NextWithdrawalValidatorIndex,
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -432,7 +432,7 @@ func InitializeFromProtoUnsafeCapella(st *ethpb.BeaconStateCapella) (state.Beaco
|
||||
nextSyncCommittee: st.NextSyncCommittee,
|
||||
latestExecutionPayloadHeaderCapella: st.LatestExecutionPayloadHeader,
|
||||
nextWithdrawalIndex: st.NextWithdrawalIndex,
|
||||
lastWithdrawalValidatorIndex: st.LastWithdrawalValidatorIndex,
|
||||
nextWithdrawalValidatorIndex: st.NextWithdrawalValidatorIndex,
|
||||
|
||||
dirtyFields: make(map[nativetypes.FieldIndex]bool, fieldCount),
|
||||
dirtyIndices: make(map[nativetypes.FieldIndex][]uint64, fieldCount),
|
||||
@@ -498,7 +498,7 @@ func (b *BeaconState) Copy() state.BeaconState {
|
||||
slot: b.slot,
|
||||
eth1DepositIndex: b.eth1DepositIndex,
|
||||
nextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||
lastWithdrawalValidatorIndex: b.lastWithdrawalValidatorIndex,
|
||||
nextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||
|
||||
// Large arrays, infrequently changed, constant size.
|
||||
blockRoots: b.blockRoots,
|
||||
@@ -831,8 +831,8 @@ func (b *BeaconState) rootSelector(ctx context.Context, field nativetypes.FieldI
|
||||
return b.latestExecutionPayloadHeaderCapella.HashTreeRoot()
|
||||
case nativetypes.NextWithdrawalIndex:
|
||||
return ssz.Uint64Root(b.nextWithdrawalIndex), nil
|
||||
case nativetypes.LastWithdrawalValidatorIndex:
|
||||
return ssz.Uint64Root(uint64(b.lastWithdrawalValidatorIndex)), nil
|
||||
case nativetypes.NextWithdrawalValidatorIndex:
|
||||
return ssz.Uint64Root(uint64(b.nextWithdrawalValidatorIndex)), nil
|
||||
}
|
||||
return [32]byte{}, errors.New("invalid field index provided")
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func (f FieldIndex) String(_ int) string {
|
||||
return "LatestExecutionPayloadHeaderCapella"
|
||||
case NextWithdrawalIndex:
|
||||
return "NextWithdrawalIndex"
|
||||
case LastWithdrawalValidatorIndex:
|
||||
case NextWithdrawalValidatorIndex:
|
||||
return "LastWithdrawalValidatorIndex"
|
||||
default:
|
||||
return ""
|
||||
@@ -132,7 +132,7 @@ func (f FieldIndex) RealPosition() int {
|
||||
return 24
|
||||
case NextWithdrawalIndex:
|
||||
return 25
|
||||
case LastWithdrawalValidatorIndex:
|
||||
case NextWithdrawalValidatorIndex:
|
||||
return 26
|
||||
default:
|
||||
return -1
|
||||
@@ -190,5 +190,5 @@ const (
|
||||
LatestExecutionPayloadHeader
|
||||
LatestExecutionPayloadHeaderCapella
|
||||
NextWithdrawalIndex
|
||||
LastWithdrawalValidatorIndex
|
||||
NextWithdrawalValidatorIndex
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 4e8004aa4b0d6e4e28f371cdc26af4fa63db0b593f92b190ebe7ad8897e76d91
|
||||
// Hash: 0861ebfee0a62ce9e10d8b677c0f8aa1f12c99ee69d3a864018818270a981c57
|
||||
package enginev1
|
||||
|
||||
import (
|
||||
|
||||
14
proto/eth/ext/options.pb.go
generated
14
proto/eth/ext/options.pb.go
generated
@@ -9,9 +9,9 @@ package ext
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
descriptorpb "google.golang.org/protobuf/types/descriptorpb"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
|
||||
var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50000,
|
||||
Name: "ethereum.eth.ext.cast_type",
|
||||
@@ -31,7 +31,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
Filename: "proto/eth/ext/options.proto",
|
||||
},
|
||||
{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50001,
|
||||
Name: "ethereum.eth.ext.ssz_size",
|
||||
@@ -39,7 +39,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
Filename: "proto/eth/ext/options.proto",
|
||||
},
|
||||
{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50002,
|
||||
Name: "ethereum.eth.ext.ssz_max",
|
||||
@@ -47,7 +47,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
Filename: "proto/eth/ext/options.proto",
|
||||
},
|
||||
{
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50003,
|
||||
Name: "ethereum.eth.ext.spec_name",
|
||||
@@ -56,7 +56,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
},
|
||||
}
|
||||
|
||||
// Extension fields to descriptor.FieldOptions.
|
||||
// Extension fields to descriptorpb.FieldOptions.
|
||||
var (
|
||||
// optional string cast_type = 50000;
|
||||
E_CastType = &file_proto_eth_ext_options_proto_extTypes[0]
|
||||
@@ -103,7 +103,7 @@ var file_proto_eth_ext_options_proto_rawDesc = []byte{
|
||||
}
|
||||
|
||||
var file_proto_eth_ext_options_proto_goTypes = []interface{}{
|
||||
(*descriptor.FieldOptions)(nil), // 0: google.protobuf.FieldOptions
|
||||
(*descriptorpb.FieldOptions)(nil), // 0: google.protobuf.FieldOptions
|
||||
}
|
||||
var file_proto_eth_ext_options_proto_depIdxs = []int32{
|
||||
0, // 0: ethereum.eth.ext.cast_type:extendee -> google.protobuf.FieldOptions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 3678f7a589562bfa6f57a029a8af1b650a425ceaac9640563f0c6acbe4605afb
|
||||
// Hash: ea151ac65a951845c7bff5e78aea6951ca6a0674af711b1b14fea69df1829e84
|
||||
package v1
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 5c8f9b4b976753e80d600bd0a18f70be6d3021b18e7d4b82a5ab22e5c521f061
|
||||
// Hash: 659a6a0cf6db5ac28f8999f1649a50f2feebffc84f3bb8a20e4b124c88015253
|
||||
package eth
|
||||
|
||||
import (
|
||||
|
||||
12
proto/prysm/v1alpha1/beacon_state.pb.go
generated
12
proto/prysm/v1alpha1/beacon_state.pb.go
generated
@@ -1339,7 +1339,7 @@ type BeaconStateCapella struct {
|
||||
NextSyncCommittee *SyncCommittee `protobuf:"bytes,9003,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"`
|
||||
LatestExecutionPayloadHeader *v1.ExecutionPayloadHeaderCapella `protobuf:"bytes,10001,opt,name=latest_execution_payload_header,json=latestExecutionPayloadHeader,proto3" json:"latest_execution_payload_header,omitempty"`
|
||||
NextWithdrawalIndex uint64 `protobuf:"varint,11001,opt,name=next_withdrawal_index,json=nextWithdrawalIndex,proto3" json:"next_withdrawal_index,omitempty"`
|
||||
LastWithdrawalValidatorIndex github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=last_withdrawal_validator_index,json=lastWithdrawalValidatorIndex,proto3" json:"last_withdrawal_validator_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"`
|
||||
NextWithdrawalValidatorIndex github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=next_withdrawal_validator_index,json=nextWithdrawalValidatorIndex,proto3" json:"next_withdrawal_validator_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"`
|
||||
}
|
||||
|
||||
func (x *BeaconStateCapella) Reset() {
|
||||
@@ -1556,9 +1556,9 @@ func (x *BeaconStateCapella) GetNextWithdrawalIndex() uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *BeaconStateCapella) GetLastWithdrawalValidatorIndex() github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex {
|
||||
func (x *BeaconStateCapella) GetNextWithdrawalValidatorIndex() github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex {
|
||||
if x != nil {
|
||||
return x.LastWithdrawalValidatorIndex
|
||||
return x.NextWithdrawalValidatorIndex
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex(0)
|
||||
}
|
||||
@@ -2194,15 +2194,15 @@ var file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = []byte{
|
||||
0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f,
|
||||
0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xf9, 0x55, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, 0x6e, 0x65,
|
||||
0x78, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x49, 0x6e, 0x64, 0x65,
|
||||
0x78, 0x12, 0x97, 0x01, 0x0a, 0x1f, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64,
|
||||
0x78, 0x12, 0x97, 0x01, 0x0a, 0x1f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64,
|
||||
0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f,
|
||||
0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xfa, 0x55, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5,
|
||||
0x18, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79,
|
||||
0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
|
||||
0x2f, 0x76, 0x33, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79,
|
||||
0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x1c, 0x6c,
|
||||
0x61, 0x73, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x56, 0x61, 0x6c,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x1c, 0x6e,
|
||||
0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x56, 0x61, 0x6c,
|
||||
0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x8d, 0x01, 0x0a, 0x08,
|
||||
0x50, 0x6f, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5,
|
||||
|
||||
@@ -285,7 +285,7 @@ message BeaconStateCapella {
|
||||
|
||||
// Capella fields [11001-12000]
|
||||
uint64 next_withdrawal_index = 11001; // [New in Capella]
|
||||
uint64 last_withdrawal_validator_index = 11002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"]; // [New in Capella]
|
||||
uint64 next_withdrawal_validator_index = 11002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"]; // [New in Capella]
|
||||
}
|
||||
|
||||
// PowBlock is a definition from Bellatrix fork choice spec to represent a block with total difficulty in the PoW chain.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: e37978aba7c76852f838285a3da40b5f5269ec01320882c5a6c557e84ab7ddd1
|
||||
// Hash: 8962105c98680286d2c628c358c5a37aeef5a3f92bfab69b89b13a7510b05da4
|
||||
package eth
|
||||
|
||||
import (
|
||||
@@ -10245,8 +10245,8 @@ func (b *BeaconStateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
// Field (25) 'NextWithdrawalIndex'
|
||||
dst = ssz.MarshalUint64(dst, b.NextWithdrawalIndex)
|
||||
|
||||
// Field (26) 'LastWithdrawalValidatorIndex'
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.LastWithdrawalValidatorIndex))
|
||||
// Field (26) 'NextWithdrawalValidatorIndex'
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.NextWithdrawalValidatorIndex))
|
||||
|
||||
// Field (7) 'HistoricalRoots'
|
||||
if size := len(b.HistoricalRoots); size > 16777216 {
|
||||
@@ -10499,8 +10499,8 @@ func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error {
|
||||
// Field (25) 'NextWithdrawalIndex'
|
||||
b.NextWithdrawalIndex = ssz.UnmarshallUint64(buf[2736633:2736641])
|
||||
|
||||
// Field (26) 'LastWithdrawalValidatorIndex'
|
||||
b.LastWithdrawalValidatorIndex = github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[2736641:2736649]))
|
||||
// Field (26) 'NextWithdrawalValidatorIndex'
|
||||
b.NextWithdrawalValidatorIndex = github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[2736641:2736649]))
|
||||
|
||||
// Field (7) 'HistoricalRoots'
|
||||
{
|
||||
@@ -10950,8 +10950,8 @@ func (b *BeaconStateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
// Field (25) 'NextWithdrawalIndex'
|
||||
hh.PutUint64(b.NextWithdrawalIndex)
|
||||
|
||||
// Field (26) 'LastWithdrawalValidatorIndex'
|
||||
hh.PutUint64(uint64(b.LastWithdrawalValidatorIndex))
|
||||
// Field (26) 'NextWithdrawalValidatorIndex'
|
||||
hh.PutUint64(uint64(b.NextWithdrawalValidatorIndex))
|
||||
|
||||
if ssz.EnableVectorizedHTR {
|
||||
hh.MerkleizeVectorizedHTR(indx)
|
||||
|
||||
Reference in New Issue
Block a user