mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
Add Capella state changes (#11688)
* Add Capella state changes * Use params.configs
This commit is contained in:
parent
a525fad0ea
commit
a0c0706224
@ -252,9 +252,9 @@ func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]b
|
||||
fieldRoots[nativetypes.NextWithdrawalIndex.RealPosition()] = nextWithdrawalIndexRoot
|
||||
|
||||
// Next partial withdrawal validator index root.
|
||||
nextPartialWithdrawalValidatorIndexRoot := make([]byte, 32)
|
||||
binary.LittleEndian.PutUint64(nextPartialWithdrawalValidatorIndexRoot, uint64(state.nextWithdrawalValidatorIndex))
|
||||
fieldRoots[nativetypes.NextWithdrawalValidatorIndex.RealPosition()] = nextPartialWithdrawalValidatorIndexRoot
|
||||
nextWithdrawalValidatorIndexRoot := make([]byte, 32)
|
||||
binary.LittleEndian.PutUint64(nextWithdrawalValidatorIndexRoot, uint64(state.nextWithdrawalValidatorIndex))
|
||||
fieldRoots[nativetypes.NextWithdrawalValidatorIndex.RealPosition()] = nextWithdrawalValidatorIndexRoot
|
||||
}
|
||||
|
||||
return fieldRoots, nil
|
||||
|
@ -1,6 +1,7 @@
|
||||
package state_native
|
||||
|
||||
import (
|
||||
nativetypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
)
|
||||
@ -15,6 +16,7 @@ func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error {
|
||||
defer b.lock.Unlock()
|
||||
|
||||
b.nextWithdrawalIndex = i
|
||||
b.markFieldAsDirty(nativetypes.NextWithdrawalIndex)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -29,5 +31,6 @@ func (b *BeaconState) SetNextWithdrawalValidatorIndex(i types.ValidatorIndex) er
|
||||
defer b.lock.Unlock()
|
||||
|
||||
b.nextWithdrawalValidatorIndex = i
|
||||
b.markFieldAsDirty(nativetypes.NextWithdrawalValidatorIndex)
|
||||
return nil
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package state_native
|
||||
import (
|
||||
"testing"
|
||||
|
||||
nativetypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
@ -12,15 +13,20 @@ func TestSetNextWithdrawalIndex(t *testing.T) {
|
||||
s := BeaconState{
|
||||
version: version.Capella,
|
||||
nextWithdrawalIndex: 3,
|
||||
dirtyFields: make(map[nativetypes.FieldIndex]bool),
|
||||
}
|
||||
require.NoError(t, s.SetNextWithdrawalIndex(5))
|
||||
require.Equal(t, uint64(5), s.nextWithdrawalIndex)
|
||||
require.Equal(t, true, s.dirtyFields[nativetypes.NextWithdrawalIndex])
|
||||
}
|
||||
|
||||
func TestSetLastWithdrawalValidatorIndex(t *testing.T) {
|
||||
s := BeaconState{
|
||||
version: version.Capella,
|
||||
nextWithdrawalValidatorIndex: 3,
|
||||
dirtyFields: make(map[nativetypes.FieldIndex]bool),
|
||||
}
|
||||
require.NoError(t, s.SetNextWithdrawalValidatorIndex(5))
|
||||
require.Equal(t, types.ValidatorIndex(5), s.nextWithdrawalValidatorIndex)
|
||||
require.Equal(t, true, s.dirtyFields[nativetypes.NextWithdrawalValidatorIndex])
|
||||
}
|
||||
|
@ -67,12 +67,12 @@ func (f FieldIndex) String(stateVersion int) string {
|
||||
case Slashings:
|
||||
return "slashings"
|
||||
case PreviousEpochAttestations:
|
||||
if version.Altair == stateVersion || version.Bellatrix == stateVersion {
|
||||
if stateVersion > version.Phase0 {
|
||||
return "previousEpochParticipationBits"
|
||||
}
|
||||
return "previousEpochAttestations"
|
||||
case CurrentEpochAttestations:
|
||||
if version.Altair == stateVersion || version.Bellatrix == stateVersion {
|
||||
if stateVersion > version.Phase0 {
|
||||
return "currentEpochParticipationBits"
|
||||
}
|
||||
return "currentEpochAttestations"
|
||||
@ -92,6 +92,12 @@ func (f FieldIndex) String(stateVersion int) string {
|
||||
return "nextSyncCommittee"
|
||||
case LatestExecutionPayloadHeader:
|
||||
return "latestExecutionPayloadHeader"
|
||||
case LatestExecutionPayloadHeaderCapella:
|
||||
return "latestExecutionPayloadHeaderCapella"
|
||||
case NextWithdrawalIndex:
|
||||
return "nextWithdrawalIndex"
|
||||
case NextWithdrawalValidatorIndex:
|
||||
return "nextWithdrawalValidatorIndex"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@ -152,6 +158,10 @@ const (
|
||||
NextSyncCommittee
|
||||
// State fields added in Bellatrix.
|
||||
LatestExecutionPayloadHeader
|
||||
// State fields added in Capella
|
||||
LatestExecutionPayloadHeaderCapella
|
||||
NextWithdrawalIndex
|
||||
NextWithdrawalValidatorIndex
|
||||
)
|
||||
|
||||
// Altair fields which replaced previous phase 0 fields.
|
||||
|
Loading…
Reference in New Issue
Block a user