mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 05:47:59 -05:00
Compare commits
4 Commits
eas
...
use-read-o
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
788c6914f7 | ||
|
|
201297bf46 | ||
|
|
4ee7066bbe | ||
|
|
1a894bb98d |
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/container/slice"
|
||||
@@ -34,6 +35,20 @@ func ValidatorFromConsensus(v *eth.Validator) *Validator {
|
||||
}
|
||||
}
|
||||
|
||||
func ValidatorFromConsensusReadOnly(v interfaces.ReadOnlyValidator) *Validator {
|
||||
pk := v.PublicKey()
|
||||
return &Validator{
|
||||
Pubkey: hexutil.Encode(pk[:]),
|
||||
WithdrawalCredentials: hexutil.Encode(v.GetWithdrawalCredentials()),
|
||||
EffectiveBalance: fmt.Sprintf("%d", v.EffectiveBalance()),
|
||||
Slashed: v.Slashed(),
|
||||
ActivationEligibilityEpoch: fmt.Sprintf("%d", v.ActivationEligibilityEpoch()),
|
||||
ActivationEpoch: fmt.Sprintf("%d", v.ActivationEpoch()),
|
||||
ExitEpoch: fmt.Sprintf("%d", v.ExitEpoch()),
|
||||
WithdrawableEpoch: fmt.Sprintf("%d", v.WithdrawableEpoch()),
|
||||
}
|
||||
}
|
||||
|
||||
func PendingAttestationFromConsensus(a *eth.PendingAttestation) *PendingAttestation {
|
||||
return &PendingAttestation{
|
||||
AggregationBits: hexutil.Encode(a.AggregationBits),
|
||||
|
||||
@@ -35,10 +35,10 @@ func BeaconStateFromConsensus(st beaconState.BeaconState) (*BeaconState, error)
|
||||
for i, e := range srcVotes {
|
||||
votes[i] = Eth1DataFromConsensus(e)
|
||||
}
|
||||
srcVals := st.Validators()
|
||||
srcVals := st.ValidatorsReadOnly()
|
||||
vals := make([]*Validator, len(srcVals))
|
||||
for i, v := range srcVals {
|
||||
vals[i] = ValidatorFromConsensus(v)
|
||||
vals[i] = ValidatorFromConsensusReadOnly(v)
|
||||
}
|
||||
srcBals := st.Balances()
|
||||
bals := make([]string, len(srcBals))
|
||||
@@ -121,10 +121,10 @@ func BeaconStateAltairFromConsensus(st beaconState.BeaconState) (*BeaconStateAlt
|
||||
for i, e := range srcVotes {
|
||||
votes[i] = Eth1DataFromConsensus(e)
|
||||
}
|
||||
srcVals := st.Validators()
|
||||
srcVals := st.ValidatorsReadOnly()
|
||||
vals := make([]*Validator, len(srcVals))
|
||||
for i, v := range srcVals {
|
||||
vals[i] = ValidatorFromConsensus(v)
|
||||
vals[i] = ValidatorFromConsensusReadOnly(v)
|
||||
}
|
||||
srcBals := st.Balances()
|
||||
bals := make([]string, len(srcBals))
|
||||
@@ -226,10 +226,10 @@ func BeaconStateBellatrixFromConsensus(st beaconState.BeaconState) (*BeaconState
|
||||
for i, e := range srcVotes {
|
||||
votes[i] = Eth1DataFromConsensus(e)
|
||||
}
|
||||
srcVals := st.Validators()
|
||||
srcVals := st.ValidatorsReadOnly()
|
||||
vals := make([]*Validator, len(srcVals))
|
||||
for i, v := range srcVals {
|
||||
vals[i] = ValidatorFromConsensus(v)
|
||||
vals[i] = ValidatorFromConsensusReadOnly(v)
|
||||
}
|
||||
srcBals := st.Balances()
|
||||
bals := make([]string, len(srcBals))
|
||||
@@ -344,10 +344,10 @@ func BeaconStateCapellaFromConsensus(st beaconState.BeaconState) (*BeaconStateCa
|
||||
for i, e := range srcVotes {
|
||||
votes[i] = Eth1DataFromConsensus(e)
|
||||
}
|
||||
srcVals := st.Validators()
|
||||
srcVals := st.ValidatorsReadOnly()
|
||||
vals := make([]*Validator, len(srcVals))
|
||||
for i, v := range srcVals {
|
||||
vals[i] = ValidatorFromConsensus(v)
|
||||
vals[i] = ValidatorFromConsensusReadOnly(v)
|
||||
}
|
||||
srcBals := st.Balances()
|
||||
bals := make([]string, len(srcBals))
|
||||
@@ -481,10 +481,10 @@ func BeaconStateDenebFromConsensus(st beaconState.BeaconState) (*BeaconStateDene
|
||||
for i, e := range srcVotes {
|
||||
votes[i] = Eth1DataFromConsensus(e)
|
||||
}
|
||||
srcVals := st.Validators()
|
||||
srcVals := st.ValidatorsReadOnly()
|
||||
vals := make([]*Validator, len(srcVals))
|
||||
for i, v := range srcVals {
|
||||
vals[i] = ValidatorFromConsensus(v)
|
||||
vals[i] = ValidatorFromConsensusReadOnly(v)
|
||||
}
|
||||
srcBals := st.Balances()
|
||||
bals := make([]string, len(srcBals))
|
||||
@@ -618,10 +618,10 @@ func BeaconStateElectraFromConsensus(st beaconState.BeaconState) (*BeaconStateEl
|
||||
for i, e := range srcVotes {
|
||||
votes[i] = Eth1DataFromConsensus(e)
|
||||
}
|
||||
srcVals := st.Validators()
|
||||
srcVals := st.ValidatorsReadOnly()
|
||||
vals := make([]*Validator, len(srcVals))
|
||||
for i, v := range srcVals {
|
||||
vals[i] = ValidatorFromConsensus(v)
|
||||
vals[i] = ValidatorFromConsensusReadOnly(v)
|
||||
}
|
||||
srcBals := st.Balances()
|
||||
bals := make([]string, len(srcBals))
|
||||
|
||||
@@ -301,7 +301,7 @@ func (s *Service) headGenesisValidatorsRoot() [32]byte {
|
||||
// This returns the validator referenced by the provided index in
|
||||
// the head state.
|
||||
// This is a lock free version.
|
||||
func (s *Service) headValidatorAtIndex(index primitives.ValidatorIndex) (state.ReadOnlyValidator, error) {
|
||||
func (s *Service) headValidatorAtIndex(index primitives.ValidatorIndex) (interfaces.ReadOnlyValidator, error) {
|
||||
return s.head.state.ValidatorAtIndexReadOnly(index)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/math"
|
||||
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
|
||||
)
|
||||
@@ -41,7 +42,7 @@ func InitializePrecomputeValidators(ctx context.Context, beaconState state.Beaco
|
||||
if beaconState.NumValidators() != len(inactivityScores) {
|
||||
return nil, nil, errors.New("num of validators is different than num of inactivity scores")
|
||||
}
|
||||
if err := beaconState.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := beaconState.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
// Set validator's balance, inactivity score and slashed/withdrawable status.
|
||||
v := &precompute.Validator{
|
||||
CurrentEpochEffectiveBalance: val.EffectiveBalance(),
|
||||
|
||||
@@ -92,6 +92,7 @@ go_test(
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//container/trie:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/bls/common:go_default_library",
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/container/slice"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -68,7 +69,7 @@ func ProcessAttesterSlashing(
|
||||
currentEpoch := slots.ToEpoch(beaconState.Slot())
|
||||
var err error
|
||||
var slashedAny bool
|
||||
var val state.ReadOnlyValidator
|
||||
var val interfaces.ReadOnlyValidator
|
||||
for _, validatorIndex := range slashableIndices {
|
||||
val, err = beaconState.ValidatorAtIndexReadOnly(primitives.ValidatorIndex(validatorIndex))
|
||||
if err != nil {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
)
|
||||
@@ -365,7 +366,7 @@ func TestFuzzVerifyExit_10000(t *testing.T) {
|
||||
s, err := state_native.InitializeFromProtoUnsafePhase0(state)
|
||||
require.NoError(t, err)
|
||||
|
||||
val, err := state_native.NewValidator(ðpb.Validator{})
|
||||
val, err := validator.NewValidator(ðpb.Validator{})
|
||||
_ = err
|
||||
err = VerifyExitAndSignature(val, s, ve)
|
||||
_ = err
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
v "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/validators"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
||||
@@ -107,7 +108,7 @@ func ProcessVoluntaryExits(
|
||||
// # Initiate exit
|
||||
// initiate_validator_exit(state, voluntary_exit.validator_index)
|
||||
func VerifyExitAndSignature(
|
||||
validator state.ReadOnlyValidator,
|
||||
validator interfaces.ReadOnlyValidator,
|
||||
state state.ReadOnlyBeaconState,
|
||||
signed *ethpb.SignedVoluntaryExit,
|
||||
) error {
|
||||
@@ -166,7 +167,7 @@ func VerifyExitAndSignature(
|
||||
// assert bls.Verify(validator.pubkey, signing_root, signed_voluntary_exit.signature)
|
||||
// # Initiate exit
|
||||
// initiate_validator_exit(state, voluntary_exit.validator_index)
|
||||
func verifyExitConditions(st state.ReadOnlyBeaconState, validator state.ReadOnlyValidator, exit *ethpb.VoluntaryExit) error {
|
||||
func verifyExitConditions(st state.ReadOnlyBeaconState, validator interfaces.ReadOnlyValidator, exit *ethpb.VoluntaryExit) error {
|
||||
currentEpoch := slots.ToEpoch(st.Slot())
|
||||
// Verify the validator is active.
|
||||
if !helpers.IsActiveValidatorUsingTrie(validator, currentEpoch) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
validator2 "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/bls"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
@@ -333,7 +334,7 @@ func TestVerifyExitAndSignature(t *testing.T) {
|
||||
params.BeaconConfig().ShardCommitteePeriod = 0
|
||||
validator, signedExit, st, err := tt.setup()
|
||||
require.NoError(t, err)
|
||||
rvalidator, err := state_native.NewValidator(validator)
|
||||
rvalidator, err := validator2.NewValidator(validator)
|
||||
require.NoError(t, err)
|
||||
err = blocks.VerifyExitAndSignature(
|
||||
rvalidator,
|
||||
|
||||
@@ -73,12 +73,12 @@ func VerifyBlockSignature(beaconState state.ReadOnlyBeaconState,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposer, err := beaconState.ValidatorAtIndex(proposerIndex)
|
||||
proposer, err := beaconState.ValidatorAtIndexReadOnly(proposerIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposerPubKey := proposer.PublicKey
|
||||
return signing.VerifyBlockSigningRoot(proposerPubKey, sig, domain, rootFunc)
|
||||
proposerPubKey := proposer.PublicKey()
|
||||
return signing.VerifyBlockSigningRoot(proposerPubKey[:], sig, domain, rootFunc)
|
||||
}
|
||||
|
||||
// VerifyBlockHeaderSignature verifies the proposer signature of a beacon block header.
|
||||
@@ -88,12 +88,12 @@ func VerifyBlockHeaderSignature(beaconState state.BeaconState, header *ethpb.Sig
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposer, err := beaconState.ValidatorAtIndex(header.Header.ProposerIndex)
|
||||
proposer, err := beaconState.ValidatorAtIndexReadOnly(header.Header.ProposerIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposerPubKey := proposer.PublicKey
|
||||
return signing.VerifyBlockHeaderSigningRoot(header.Header, proposerPubKey, header.Signature, domain)
|
||||
proposerPubKey := proposer.PublicKey()
|
||||
return signing.VerifyBlockHeaderSigningRoot(header.Header, proposerPubKey[:], header.Signature, domain)
|
||||
}
|
||||
|
||||
// VerifyBlockSignatureUsingCurrentFork verifies the proposer signature of a beacon block. This differs
|
||||
@@ -109,13 +109,13 @@ func VerifyBlockSignatureUsingCurrentFork(beaconState state.ReadOnlyBeaconState,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposer, err := beaconState.ValidatorAtIndex(blk.Block().ProposerIndex())
|
||||
proposer, err := beaconState.ValidatorAtIndexReadOnly(blk.Block().ProposerIndex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposerPubKey := proposer.PublicKey
|
||||
proposerPubKey := proposer.PublicKey()
|
||||
sig := blk.Signature()
|
||||
return signing.VerifyBlockSigningRoot(proposerPubKey, sig[:], domain, func() ([32]byte, error) {
|
||||
return signing.VerifyBlockSigningRoot(proposerPubKey[:], sig[:], domain, func() ([32]byte, error) {
|
||||
return blkRoot, nil
|
||||
})
|
||||
}
|
||||
@@ -130,12 +130,12 @@ func BlockSignatureBatch(beaconState state.ReadOnlyBeaconState,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
proposer, err := beaconState.ValidatorAtIndex(proposerIndex)
|
||||
proposer, err := beaconState.ValidatorAtIndexReadOnly(proposerIndex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
proposerPubKey := proposer.PublicKey
|
||||
return signing.BlockSignatureBatch(proposerPubKey, sig, domain, rootFunc)
|
||||
proposerPubKey := proposer.PublicKey()
|
||||
return signing.BlockSignatureBatch(proposerPubKey[:], sig, domain, rootFunc)
|
||||
}
|
||||
|
||||
// RandaoSignatureBatch retrieves the relevant randao specific signature batch object
|
||||
|
||||
@@ -31,6 +31,7 @@ go_library(
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//contracts/deposit:go_default_library",
|
||||
"//crypto/bls/common:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/signing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
state_native "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/contracts/deposit"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
@@ -39,7 +40,7 @@ func ProcessEffectiveBalanceUpdates(st state.BeaconState) error {
|
||||
bals := st.Balances()
|
||||
|
||||
// Update effective balances with hysteresis.
|
||||
validatorFunc := func(idx int, val state.ReadOnlyValidator) (newVal *ethpb.Validator, err error) {
|
||||
validatorFunc := func(idx int, val interfaces.ReadOnlyValidator) (newVal *ethpb.Validator, err error) {
|
||||
if val == nil {
|
||||
return nil, fmt.Errorf("validator %d is nil in state", idx)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/validators"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
)
|
||||
|
||||
@@ -47,7 +48,7 @@ func ProcessRegistryUpdates(ctx context.Context, st state.BeaconState) error {
|
||||
eligibleForEjection := make([]primitives.ValidatorIndex, 0)
|
||||
eligibleForActivation := make([]primitives.ValidatorIndex, 0)
|
||||
|
||||
if err := st.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := st.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
// Collect validators eligible to enter the activation queue.
|
||||
if helpers.IsEligibleForActivationQueue(val, currentEpoch) {
|
||||
eligibleForActivationQ = append(eligibleForActivationQ, primitives.ValidatorIndex(idx))
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -190,7 +191,7 @@ func UpgradeToElectra(beaconState state.BeaconState) (state.BeaconState, error)
|
||||
earliestExitEpoch := time.CurrentEpoch(beaconState)
|
||||
preActivationIndices := make([]primitives.ValidatorIndex, 0)
|
||||
compoundWithdrawalIndices := make([]primitives.ValidatorIndex, 0)
|
||||
if err = beaconState.ReadFromEveryValidator(func(index int, val state.ReadOnlyValidator) error {
|
||||
if err = beaconState.ReadFromEveryValidator(func(index int, val interfaces.ReadOnlyValidator) error {
|
||||
if val.ExitEpoch() != params.BeaconConfig().FarFutureEpoch && val.ExitEpoch() > earliestExitEpoch {
|
||||
earliestExitEpoch = val.ExitEpoch()
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ go_library(
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state/stateutil"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/math"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -59,7 +60,7 @@ func ProcessRegistryUpdates(ctx context.Context, st state.BeaconState) (state.Be
|
||||
eligibleForActivation := make([]primitives.ValidatorIndex, 0)
|
||||
eligibleForEjection := make([]primitives.ValidatorIndex, 0)
|
||||
|
||||
if err := st.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := st.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
// Collect validators eligible to enter the activation queue.
|
||||
if helpers.IsEligibleForActivationQueue(val, currentEpoch) {
|
||||
eligibleForActivationQ = append(eligibleForActivationQ, primitives.ValidatorIndex(idx))
|
||||
@@ -192,7 +193,7 @@ func ProcessSlashings(st state.BeaconState, slashingMultiplier uint64) (state.Be
|
||||
|
||||
bals := st.Balances()
|
||||
changed := false
|
||||
err = st.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
err = st.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
correctEpoch := (currentEpoch + exitLength/2) == val.WithdrawableEpoch()
|
||||
if val.Slashed() && correctEpoch {
|
||||
var penalty uint64
|
||||
@@ -268,7 +269,7 @@ func ProcessEffectiveBalanceUpdates(st state.BeaconState) (state.BeaconState, er
|
||||
bals := st.Balances()
|
||||
|
||||
// Update effective balances with hysteresis.
|
||||
validatorFunc := func(idx int, val state.ReadOnlyValidator) (newVal *ethpb.Validator, err error) {
|
||||
validatorFunc := func(idx int, val interfaces.ReadOnlyValidator) (newVal *ethpb.Validator, err error) {
|
||||
if val == nil {
|
||||
return nil, fmt.Errorf("validator %d is nil in state", idx)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ go_library(
|
||||
"//beacon-chain/core/time:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//monitoring/tracing:go_default_library",
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
|
||||
)
|
||||
|
||||
@@ -27,7 +28,7 @@ func New(ctx context.Context, s state.BeaconState) ([]*Validator, *Balance, erro
|
||||
currentEpoch := time.CurrentEpoch(s)
|
||||
prevEpoch := time.PrevEpoch(s)
|
||||
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
// Was validator withdrawable or slashed
|
||||
withdrawable := prevEpoch+1 >= val.WithdrawableEpoch()
|
||||
pVal := &Validator{
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/math"
|
||||
)
|
||||
|
||||
@@ -26,7 +27,7 @@ func ProcessSlashingsPrecompute(s state.BeaconState, pBal *Balance) error {
|
||||
|
||||
var hasSlashing bool
|
||||
// Iterate through validator list in state, stop until a validator satisfies slashing condition of current epoch.
|
||||
err := s.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
err := s.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
correctEpoch := epochToWithdraw == val.WithdrawableEpoch()
|
||||
if val.Slashed() && correctEpoch {
|
||||
hasSlashing = true
|
||||
@@ -43,7 +44,7 @@ func ProcessSlashingsPrecompute(s state.BeaconState, pBal *Balance) error {
|
||||
|
||||
increment := params.BeaconConfig().EffectiveBalanceIncrement
|
||||
bals := s.Balances()
|
||||
validatorFunc := func(idx int, val state.ReadOnlyValidator) error {
|
||||
validatorFunc := func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
correctEpoch := epochToWithdraw == val.WithdrawableEpoch()
|
||||
if val.Slashed() && correctEpoch {
|
||||
penaltyNumerator := val.EffectiveBalance() / increment * minSlashing
|
||||
|
||||
@@ -76,6 +76,7 @@ go_test(
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//container/slice:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/container/slice"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/hash"
|
||||
@@ -346,7 +347,7 @@ func ShuffledIndices(s state.ReadOnlyBeaconState, epoch primitives.Epoch) ([]pri
|
||||
}
|
||||
|
||||
indices := make([]primitives.ValidatorIndex, 0, s.NumValidators())
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
if IsActiveValidatorUsingTrie(val, epoch) {
|
||||
indices = append(indices, primitives.ValidatorIndex(idx))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/cache"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
mathutil "github.com/prysmaticlabs/prysm/v5/math"
|
||||
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
||||
@@ -69,7 +70,7 @@ func TotalActiveBalance(s state.ReadOnlyBeaconState) (uint64, error) {
|
||||
|
||||
total := uint64(0)
|
||||
epoch := slots.ToEpoch(s.Slot())
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
if IsActiveValidatorUsingTrie(val, epoch) {
|
||||
total += val.EffectiveBalance()
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func IsCurrentPeriodSyncCommittee(st state.BeaconState, valIdx primitives.Valida
|
||||
}
|
||||
indices, err := syncCommitteeCache.CurrentPeriodIndexPosition(root, valIdx)
|
||||
if errors.Is(err, cache.ErrNonExistingSyncCommitteeKey) {
|
||||
val, err := st.ValidatorAtIndex(valIdx)
|
||||
val, err := st.ValidatorAtIndexReadOnly(valIdx)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -48,7 +48,8 @@ func IsCurrentPeriodSyncCommittee(st state.BeaconState, valIdx primitives.Valida
|
||||
}
|
||||
}()
|
||||
|
||||
return len(findSubCommitteeIndices(val.PublicKey, committee.Pubkeys)) > 0, nil
|
||||
pk := val.PublicKey()
|
||||
return len(findSubCommitteeIndices(pk[:], committee.Pubkeys)) > 0, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -47,12 +47,12 @@ func IsActiveValidator(validator *ethpb.Validator, epoch primitives.Epoch) bool
|
||||
}
|
||||
|
||||
// IsActiveValidatorUsingTrie checks if a read only validator is active.
|
||||
func IsActiveValidatorUsingTrie(validator state.ReadOnlyValidator, epoch primitives.Epoch) bool {
|
||||
func IsActiveValidatorUsingTrie(validator interfaces.ReadOnlyValidator, epoch primitives.Epoch) bool {
|
||||
return checkValidatorActiveStatus(validator.ActivationEpoch(), validator.ExitEpoch(), epoch)
|
||||
}
|
||||
|
||||
// IsActiveNonSlashedValidatorUsingTrie checks if a read only validator is active and not slashed
|
||||
func IsActiveNonSlashedValidatorUsingTrie(validator state.ReadOnlyValidator, epoch primitives.Epoch) bool {
|
||||
func IsActiveNonSlashedValidatorUsingTrie(validator interfaces.ReadOnlyValidator, epoch primitives.Epoch) bool {
|
||||
active := checkValidatorActiveStatus(validator.ActivationEpoch(), validator.ExitEpoch(), epoch)
|
||||
return active && !validator.Slashed()
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func IsSlashableValidator(activationEpoch, withdrawableEpoch primitives.Epoch, s
|
||||
}
|
||||
|
||||
// IsSlashableValidatorUsingTrie checks if a read only validator is slashable.
|
||||
func IsSlashableValidatorUsingTrie(val state.ReadOnlyValidator, epoch primitives.Epoch) bool {
|
||||
func IsSlashableValidatorUsingTrie(val interfaces.ReadOnlyValidator, epoch primitives.Epoch) bool {
|
||||
return checkValidatorSlashable(val.ActivationEpoch(), val.WithdrawableEpoch(), val.Slashed(), epoch)
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func ActiveValidatorIndices(ctx context.Context, s state.ReadOnlyBeaconState, ep
|
||||
}()
|
||||
|
||||
var indices []primitives.ValidatorIndex
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
if IsActiveValidatorUsingTrie(val, epoch) {
|
||||
indices = append(indices, primitives.ValidatorIndex(idx))
|
||||
}
|
||||
@@ -187,7 +187,7 @@ func ActiveValidatorCount(ctx context.Context, s state.ReadOnlyBeaconState, epoc
|
||||
}()
|
||||
|
||||
count := uint64(0)
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if err := s.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
if IsActiveValidatorUsingTrie(val, epoch) {
|
||||
count++
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func ComputeProposerIndex(bState state.ReadOnlyBeaconState, activeIndices []prim
|
||||
// validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH
|
||||
// and validator.effective_balance >= MIN_ACTIVATION_BALANCE # [Modified in Electra:EIP7251]
|
||||
// )
|
||||
func IsEligibleForActivationQueue(validator state.ReadOnlyValidator, currentEpoch primitives.Epoch) bool {
|
||||
func IsEligibleForActivationQueue(validator interfaces.ReadOnlyValidator, currentEpoch primitives.Epoch) bool {
|
||||
if currentEpoch >= params.BeaconConfig().ElectraForkEpoch {
|
||||
return isEligibleForActivationQueueElectra(validator.ActivationEligibilityEpoch(), validator.EffectiveBalance())
|
||||
}
|
||||
@@ -471,7 +471,7 @@ func IsEligibleForActivation(state state.ReadOnlyCheckpoint, validator *ethpb.Va
|
||||
}
|
||||
|
||||
// IsEligibleForActivationUsingROVal checks if the validator is eligible for activation using the provided read only validator.
|
||||
func IsEligibleForActivationUsingROVal(state state.ReadOnlyCheckpoint, validator state.ReadOnlyValidator) bool {
|
||||
func IsEligibleForActivationUsingROVal(state state.ReadOnlyCheckpoint, validator interfaces.ReadOnlyValidator) bool {
|
||||
return isEligibleForActivation(validator.ActivationEligibilityEpoch(), validator.ActivationEpoch(), state.FinalizedCheckpointEpoch())
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ func IsSameWithdrawalCredentials(a, b *ethpb.Validator) bool {
|
||||
// and validator.withdrawable_epoch <= epoch
|
||||
// and balance > 0
|
||||
// )
|
||||
func IsFullyWithdrawableValidator(val state.ReadOnlyValidator, balance uint64, epoch primitives.Epoch, fork int) bool {
|
||||
func IsFullyWithdrawableValidator(val interfaces.ReadOnlyValidator, balance uint64, epoch primitives.Epoch, fork int) bool {
|
||||
if val == nil || balance <= 0 {
|
||||
return false
|
||||
}
|
||||
@@ -600,7 +600,7 @@ func IsFullyWithdrawableValidator(val state.ReadOnlyValidator, balance uint64, e
|
||||
// IsPartiallyWithdrawableValidator returns whether the validator is able to perform a
|
||||
// partial withdrawal. This function assumes that the caller has a lock on the state.
|
||||
// This method conditionally calls the fork appropriate implementation based on the epoch argument.
|
||||
func IsPartiallyWithdrawableValidator(val state.ReadOnlyValidator, balance uint64, epoch primitives.Epoch, fork int) bool {
|
||||
func IsPartiallyWithdrawableValidator(val interfaces.ReadOnlyValidator, balance uint64, epoch primitives.Epoch, fork int) bool {
|
||||
if val == nil {
|
||||
return false
|
||||
}
|
||||
@@ -630,7 +630,7 @@ func IsPartiallyWithdrawableValidator(val state.ReadOnlyValidator, balance uint6
|
||||
// and has_max_effective_balance
|
||||
// and has_excess_balance
|
||||
// )
|
||||
func isPartiallyWithdrawableValidatorElectra(val state.ReadOnlyValidator, balance uint64, epoch primitives.Epoch) bool {
|
||||
func isPartiallyWithdrawableValidatorElectra(val interfaces.ReadOnlyValidator, balance uint64, epoch primitives.Epoch) bool {
|
||||
maxEB := ValidatorMaxEffectiveBalance(val)
|
||||
hasMaxBalance := val.EffectiveBalance() == maxEB
|
||||
hasExcessBalance := balance > maxEB
|
||||
@@ -652,7 +652,7 @@ func isPartiallyWithdrawableValidatorElectra(val state.ReadOnlyValidator, balanc
|
||||
// has_max_effective_balance = validator.effective_balance == MAX_EFFECTIVE_BALANCE
|
||||
// has_excess_balance = balance > MAX_EFFECTIVE_BALANCE
|
||||
// return has_eth1_withdrawal_credential(validator) and has_max_effective_balance and has_excess_balance
|
||||
func isPartiallyWithdrawableValidatorCapella(val state.ReadOnlyValidator, balance uint64, epoch primitives.Epoch) bool {
|
||||
func isPartiallyWithdrawableValidatorCapella(val interfaces.ReadOnlyValidator, balance uint64, epoch primitives.Epoch) bool {
|
||||
hasMaxBalance := val.EffectiveBalance() == params.BeaconConfig().MaxEffectiveBalance
|
||||
hasExcessBalance := balance > params.BeaconConfig().MaxEffectiveBalance
|
||||
return HasETH1WithdrawalCredential(val) && hasExcessBalance && hasMaxBalance
|
||||
@@ -670,7 +670,7 @@ func isPartiallyWithdrawableValidatorCapella(val state.ReadOnlyValidator, balanc
|
||||
// return MAX_EFFECTIVE_BALANCE_ELECTRA
|
||||
// else:
|
||||
// return MIN_ACTIVATION_BALANCE
|
||||
func ValidatorMaxEffectiveBalance(val state.ReadOnlyValidator) uint64 {
|
||||
func ValidatorMaxEffectiveBalance(val interfaces.ReadOnlyValidator) uint64 {
|
||||
if HasCompoundingWithdrawalCredential(val) {
|
||||
return params.BeaconConfig().MaxEffectiveBalanceElectra
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/hash"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -798,7 +799,7 @@ func TestIsEligibleForActivationQueue(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
helpers.ClearCache()
|
||||
|
||||
v, err := state_native.NewValidator(tt.validator)
|
||||
v, err := validator.NewValidator(tt.validator)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.want, helpers.IsEligibleForActivationQueue(v, tt.currentEpoch), "IsEligibleForActivationQueue()")
|
||||
})
|
||||
@@ -1029,7 +1030,7 @@ func TestIsFullyWithdrawableValidator(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v, err := state_native.NewValidator(tt.validator)
|
||||
v, err := validator.NewValidator(tt.validator)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.want, helpers.IsFullyWithdrawableValidator(v, tt.balance, tt.epoch, tt.fork))
|
||||
})
|
||||
@@ -1101,7 +1102,7 @@ func TestIsPartiallyWithdrawableValidator(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v, err := state_native.NewValidator(tt.validator)
|
||||
v, err := validator.NewValidator(tt.validator)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.want, helpers.IsPartiallyWithdrawableValidator(v, tt.balance, tt.epoch, tt.fork))
|
||||
})
|
||||
@@ -1160,7 +1161,7 @@ func TestValidatorMaxEffectiveBalance(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v, err := state_native.NewValidator(tt.validator)
|
||||
v, err := validator.NewValidator(tt.validator)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.want, helpers.ValidatorMaxEffectiveBalance(v))
|
||||
})
|
||||
|
||||
@@ -120,7 +120,7 @@ func ComputeSigningRootForRoot(root [32]byte, domain []byte) ([32]byte, error) {
|
||||
|
||||
// ComputeDomainVerifySigningRoot computes domain and verifies signing root of an object given the beacon state, validator index and signature.
|
||||
func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index primitives.ValidatorIndex, epoch primitives.Epoch, obj fssz.HashRoot, domain [4]byte, sig []byte) error {
|
||||
v, err := st.ValidatorAtIndex(index)
|
||||
v, err := st.ValidatorAtIndexReadOnly(index)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -128,7 +128,8 @@ func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index primitiv
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return VerifySigningRoot(obj, v.PublicKey, sig, d)
|
||||
pk := v.PublicKey()
|
||||
return VerifySigningRoot(obj, pk[:], sig, d)
|
||||
}
|
||||
|
||||
// VerifySigningRoot verifies the signing root of an object given its public key, signature and domain.
|
||||
|
||||
@@ -120,7 +120,7 @@ func OptimizedGenesisBeaconStateBellatrix(genesisTime uint64, preState state.Bea
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func OptimizedGenesisBeaconStateBellatrix(genesisTime uint64, preState state.Bea
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scoresMissing := len(preState.Validators()) - len(scores)
|
||||
scoresMissing := len(preState.ValidatorsReadOnly()) - len(scores)
|
||||
if scoresMissing > 0 {
|
||||
for i := 0; i < scoresMissing; i++ {
|
||||
scores = append(scores, 0)
|
||||
|
||||
@@ -147,7 +147,7 @@ func OptimizedGenesisBeaconState(genesisTime uint64, preState state.BeaconState,
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ go_library(
|
||||
"//beacon-chain/core/time:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/math"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
||||
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
||||
)
|
||||
@@ -27,7 +27,7 @@ var ErrValidatorAlreadyExited = errors.New("validator already exited")
|
||||
// epoch and the number of them
|
||||
func MaxExitEpochAndChurn(s state.BeaconState) (maxExitEpoch primitives.Epoch, churn uint64) {
|
||||
farFutureEpoch := params.BeaconConfig().FarFutureEpoch
|
||||
err := s.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
err := s.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
e := val.ExitEpoch()
|
||||
if e != farFutureEpoch {
|
||||
if e > maxExitEpoch {
|
||||
@@ -217,11 +217,11 @@ func SlashValidator(
|
||||
}
|
||||
|
||||
// ActivatedValidatorIndices determines the indices activated during the given epoch.
|
||||
func ActivatedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validator) []primitives.ValidatorIndex {
|
||||
func ActivatedValidatorIndices(epoch primitives.Epoch, validators []interfaces.ReadOnlyValidator) []primitives.ValidatorIndex {
|
||||
activations := make([]primitives.ValidatorIndex, 0)
|
||||
for i := 0; i < len(validators); i++ {
|
||||
val := validators[i]
|
||||
if val.ActivationEpoch <= epoch && epoch < val.ExitEpoch {
|
||||
if val.ActivationEpoch() <= epoch && epoch < val.ExitEpoch() {
|
||||
activations = append(activations, primitives.ValidatorIndex(i))
|
||||
}
|
||||
}
|
||||
@@ -229,12 +229,12 @@ func ActivatedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Valid
|
||||
}
|
||||
|
||||
// SlashedValidatorIndices determines the indices slashed during the given epoch.
|
||||
func SlashedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validator) []primitives.ValidatorIndex {
|
||||
func SlashedValidatorIndices(epoch primitives.Epoch, validators []interfaces.ReadOnlyValidator) []primitives.ValidatorIndex {
|
||||
slashed := make([]primitives.ValidatorIndex, 0)
|
||||
for i := 0; i < len(validators); i++ {
|
||||
val := validators[i]
|
||||
maxWithdrawableEpoch := primitives.MaxEpoch(val.WithdrawableEpoch, epoch+params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
if val.WithdrawableEpoch == maxWithdrawableEpoch && val.Slashed {
|
||||
maxWithdrawableEpoch := primitives.MaxEpoch(val.WithdrawableEpoch(), epoch+params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
if val.WithdrawableEpoch() == maxWithdrawableEpoch && val.Slashed() {
|
||||
slashed = append(slashed, primitives.ValidatorIndex(i))
|
||||
}
|
||||
}
|
||||
@@ -242,13 +242,13 @@ func SlashedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validat
|
||||
}
|
||||
|
||||
// ExitedValidatorIndices determines the indices exited during the current epoch.
|
||||
func ExitedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validator, activeValidatorCount uint64) ([]primitives.ValidatorIndex, error) {
|
||||
func ExitedValidatorIndices(epoch primitives.Epoch, validators []interfaces.ReadOnlyValidator, activeValidatorCount uint64) ([]primitives.ValidatorIndex, error) {
|
||||
exited := make([]primitives.ValidatorIndex, 0)
|
||||
exitEpochs := make([]primitives.Epoch, 0)
|
||||
for i := 0; i < len(validators); i++ {
|
||||
val := validators[i]
|
||||
if val.ExitEpoch != params.BeaconConfig().FarFutureEpoch {
|
||||
exitEpochs = append(exitEpochs, val.ExitEpoch)
|
||||
if val.ExitEpoch() != params.BeaconConfig().FarFutureEpoch {
|
||||
exitEpochs = append(exitEpochs, val.ExitEpoch())
|
||||
}
|
||||
}
|
||||
exitQueueEpoch := primitives.Epoch(0)
|
||||
@@ -261,7 +261,7 @@ func ExitedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validato
|
||||
// We use the exit queue churn to determine if we have passed a churn limit.
|
||||
exitQueueChurn := uint64(0)
|
||||
for _, val := range validators {
|
||||
if val.ExitEpoch == exitQueueEpoch {
|
||||
if val.ExitEpoch() == exitQueueEpoch {
|
||||
exitQueueChurn++
|
||||
}
|
||||
}
|
||||
@@ -271,8 +271,8 @@ func ExitedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validato
|
||||
}
|
||||
withdrawableEpoch := exitQueueEpoch + params.BeaconConfig().MinValidatorWithdrawabilityDelay
|
||||
for i, val := range validators {
|
||||
if val.ExitEpoch == epoch && val.WithdrawableEpoch == withdrawableEpoch &&
|
||||
val.EffectiveBalance > params.BeaconConfig().EjectionBalance {
|
||||
if val.ExitEpoch() == epoch && val.WithdrawableEpoch() == withdrawableEpoch &&
|
||||
val.EffectiveBalance() > params.BeaconConfig().EjectionBalance {
|
||||
exited = append(exited, primitives.ValidatorIndex(i))
|
||||
}
|
||||
}
|
||||
@@ -288,10 +288,10 @@ func ExitedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validato
|
||||
// This function simplifies the ejection determination by directly checking the validator's ExitEpoch
|
||||
// and EffectiveBalance, avoiding the complexities and potential inaccuracies of calculating
|
||||
// withdrawable epochs.
|
||||
func EjectedValidatorIndices(epoch primitives.Epoch, validators []*ethpb.Validator) ([]primitives.ValidatorIndex, error) {
|
||||
func EjectedValidatorIndices(epoch primitives.Epoch, validators []interfaces.ReadOnlyValidator) ([]primitives.ValidatorIndex, error) {
|
||||
ejected := make([]primitives.ValidatorIndex, 0)
|
||||
for i, val := range validators {
|
||||
if val.ExitEpoch == epoch && val.EffectiveBalance <= params.BeaconConfig().EjectionBalance {
|
||||
if val.ExitEpoch() == epoch && val.EffectiveBalance() <= params.BeaconConfig().EjectionBalance {
|
||||
ejected = append(ejected, primitives.ValidatorIndex(i))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +876,7 @@ func (s *Service) ValidatorActiveSetChanges(
|
||||
Reason: Internal,
|
||||
}
|
||||
}
|
||||
vs := requestedState.Validators()
|
||||
vs := requestedState.ValidatorsReadOnly()
|
||||
activatedIndices := validators.ActivatedValidatorIndices(coreTime.CurrentEpoch(requestedState), vs)
|
||||
exitedIndices, err := validators.ExitedValidatorIndices(coreTime.CurrentEpoch(requestedState), vs, activeValidatorCount)
|
||||
if err != nil {
|
||||
|
||||
@@ -39,7 +39,6 @@ go_library(
|
||||
"//beacon-chain/rpc/lookup:go_default_library",
|
||||
"//beacon-chain/rpc/prysm/v1alpha1/validator:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/sync:go_default_library",
|
||||
"//config/features:go_default_library",
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
statenative "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
@@ -366,25 +366,19 @@ func decodeIds(w http.ResponseWriter, st state.BeaconState, rawIds []string, ign
|
||||
}
|
||||
|
||||
// valsFromIds returns read-only validators based on the supplied validator indices.
|
||||
func valsFromIds(w http.ResponseWriter, st state.BeaconState, ids []primitives.ValidatorIndex) ([]state.ReadOnlyValidator, bool) {
|
||||
var vals []state.ReadOnlyValidator
|
||||
func valsFromIds(w http.ResponseWriter, st state.BeaconState, ids []primitives.ValidatorIndex) ([]interfaces.ReadOnlyValidator, bool) {
|
||||
var vals []interfaces.ReadOnlyValidator
|
||||
if len(ids) == 0 {
|
||||
vals = st.ValidatorsReadOnly()
|
||||
} else {
|
||||
vals = make([]state.ReadOnlyValidator, 0, len(ids))
|
||||
vals = make([]interfaces.ReadOnlyValidator, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
val, err := st.ValidatorAtIndex(id)
|
||||
val, err := st.ValidatorAtIndexReadOnly(id)
|
||||
if err != nil {
|
||||
httputil.HandleError(w, fmt.Sprintf("Could not get validator at index %d: %s", id, err.Error()), http.StatusInternalServerError)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
readOnlyVal, err := statenative.NewValidator(val)
|
||||
if err != nil {
|
||||
httputil.HandleError(w, "Could not convert validator: "+err.Error(), http.StatusInternalServerError)
|
||||
return nil, false
|
||||
}
|
||||
vals = append(vals, readOnlyVal)
|
||||
vals = append(vals, val)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +386,7 @@ func valsFromIds(w http.ResponseWriter, st state.BeaconState, ids []primitives.V
|
||||
}
|
||||
|
||||
func valContainerFromReadOnlyVal(
|
||||
val state.ReadOnlyValidator,
|
||||
val interfaces.ReadOnlyValidator,
|
||||
id primitives.ValidatorIndex,
|
||||
bal uint64,
|
||||
valStatus validator.Status,
|
||||
|
||||
@@ -13,7 +13,6 @@ go_library(
|
||||
"//beacon-chain/blockchain:go_default_library",
|
||||
"//beacon-chain/db:go_default_library",
|
||||
"//beacon-chain/rpc/lookup:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
|
||||
@@ -2,14 +2,14 @@ package helpers
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
)
|
||||
|
||||
// ValidatorStatus returns a validator's status at the given epoch.
|
||||
func ValidatorStatus(val state.ReadOnlyValidator, epoch primitives.Epoch) (validator.Status, error) {
|
||||
func ValidatorStatus(val interfaces.ReadOnlyValidator, epoch primitives.Epoch) (validator.Status, error) {
|
||||
valStatus, err := ValidatorSubStatus(val, epoch)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "could not get validator sub status")
|
||||
@@ -28,7 +28,7 @@ func ValidatorStatus(val state.ReadOnlyValidator, epoch primitives.Epoch) (valid
|
||||
}
|
||||
|
||||
// ValidatorSubStatus returns a validator's sub-status at the given epoch.
|
||||
func ValidatorSubStatus(val state.ReadOnlyValidator, epoch primitives.Epoch) (validator.Status, error) {
|
||||
func ValidatorSubStatus(val interfaces.ReadOnlyValidator, epoch primitives.Epoch) (validator.Status, error) {
|
||||
farFutureEpoch := params.BeaconConfig().FarFutureEpoch
|
||||
|
||||
// Pending.
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
@@ -141,7 +140,7 @@ func Test_ValidatorStatus(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
readOnlyVal, err := state_native.NewValidator(migration.V1ValidatorToV1Alpha1(tt.args.validator))
|
||||
readOnlyVal, err := validator.NewValidator(migration.V1ValidatorToV1Alpha1(tt.args.validator))
|
||||
require.NoError(t, err)
|
||||
got, err := ValidatorStatus(readOnlyVal, tt.args.epoch)
|
||||
require.NoError(t, err)
|
||||
@@ -279,7 +278,7 @@ func Test_ValidatorSubStatus(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
readOnlyVal, err := state_native.NewValidator(migration.V1ValidatorToV1Alpha1(tt.args.validator))
|
||||
readOnlyVal, err := validator.NewValidator(migration.V1ValidatorToV1Alpha1(tt.args.validator))
|
||||
require.NoError(t, err)
|
||||
got, err := ValidatorSubStatus(readOnlyVal, tt.args.epoch)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -34,6 +34,7 @@ go_library(
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
validator2 "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
@@ -312,7 +313,7 @@ func (s *Server) SubmitSyncCommitteeSubscription(w http.ResponseWriter, r *http.
|
||||
return
|
||||
}
|
||||
currEpoch := slots.ToEpoch(st.Slot())
|
||||
validators := make([]state.ReadOnlyValidator, len(req.Data))
|
||||
validators := make([]interfaces.ReadOnlyValidator, len(req.Data))
|
||||
subscriptions := make([]*validator2.SyncCommitteeSubscription, len(req.Data))
|
||||
for i, item := range req.Data {
|
||||
consensusItem, err := item.ToConsensus()
|
||||
@@ -423,7 +424,7 @@ func (s *Server) SubmitBeaconCommitteeSubscription(w http.ResponseWriter, r *htt
|
||||
}
|
||||
|
||||
// Verify validators at the beginning to return early if request is invalid.
|
||||
validators := make([]state.ReadOnlyValidator, len(req.Data))
|
||||
validators := make([]interfaces.ReadOnlyValidator, len(req.Data))
|
||||
subscriptions := make([]*validator2.BeaconCommitteeSubscription, len(req.Data))
|
||||
for i, item := range req.Data {
|
||||
consensusItem, err := item.ToConsensus()
|
||||
@@ -1257,9 +1258,9 @@ func syncCommitteeDutiesAndVals(
|
||||
st state.BeaconState,
|
||||
requestedValIndices []primitives.ValidatorIndex,
|
||||
committeePubkeys map[[fieldparams.BLSPubkeyLength]byte][]string,
|
||||
) ([]*structs.SyncCommitteeDuty, []state.ReadOnlyValidator, error) {
|
||||
) ([]*structs.SyncCommitteeDuty, []interfaces.ReadOnlyValidator, error) {
|
||||
duties := make([]*structs.SyncCommitteeDuty, 0)
|
||||
vals := make([]state.ReadOnlyValidator, 0)
|
||||
vals := make([]interfaces.ReadOnlyValidator, 0)
|
||||
for _, index := range requestedValIndices {
|
||||
duty := &structs.SyncCommitteeDuty{
|
||||
ValidatorIndex: strconv.FormatUint(uint64(index), 10),
|
||||
|
||||
@@ -19,11 +19,11 @@ go_library(
|
||||
"//beacon-chain/rpc/eth/helpers:go_default_library",
|
||||
"//beacon-chain/rpc/eth/shared:go_default_library",
|
||||
"//beacon-chain/rpc/lookup:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/sync:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
|
||||
@@ -10,13 +10,12 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared"
|
||||
statenative "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
|
||||
"github.com/prysmaticlabs/prysm/v5/network/httputil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
|
||||
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
||||
)
|
||||
|
||||
@@ -105,7 +104,7 @@ func (s *Server) GetValidatorCount(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
epoch := slots.ToEpoch(st.Slot())
|
||||
valCount, err := validatorCountByStatus(st.Validators(), statusVals, epoch)
|
||||
valCount, err := validatorCountByStatus(st.ValidatorsReadOnly(), statusVals, epoch)
|
||||
if err != nil {
|
||||
errJson := &httputil.DefaultJsonError{
|
||||
Message: fmt.Sprintf("could not get validator count: %v", err),
|
||||
@@ -125,18 +124,14 @@ func (s *Server) GetValidatorCount(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// validatorCountByStatus returns a slice of validator count for each status in the given epoch.
|
||||
func validatorCountByStatus(validators []*eth.Validator, statuses []validator.Status, epoch primitives.Epoch) ([]*structs.ValidatorCount, error) {
|
||||
func validatorCountByStatus(validators []interfaces.ReadOnlyValidator, statuses []validator.Status, epoch primitives.Epoch) ([]*structs.ValidatorCount, error) {
|
||||
countByStatus := make(map[validator.Status]uint64)
|
||||
for _, val := range validators {
|
||||
readOnlyVal, err := statenative.NewValidator(val)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not convert validator: %w", err)
|
||||
}
|
||||
valStatus, err := helpers.ValidatorStatus(readOnlyVal, epoch)
|
||||
valStatus, err := helpers.ValidatorStatus(val, epoch)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get validator status: %w", err)
|
||||
}
|
||||
valSubStatus, err := helpers.ValidatorSubStatus(readOnlyVal, epoch)
|
||||
valSubStatus, err := helpers.ValidatorSubStatus(val, epoch)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get validator sub status: %w", err)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/cmd"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -68,7 +69,7 @@ func (bs *Server) ListValidatorBalances(
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("error replaying blocks for state at slot %d: %v", startSlot, err))
|
||||
}
|
||||
|
||||
vals := requestedState.Validators()
|
||||
vals := requestedState.ValidatorsReadOnly()
|
||||
balances := requestedState.Balances()
|
||||
balancesCount := len(balances)
|
||||
for _, pubKey := range req.PublicKeys {
|
||||
@@ -113,8 +114,9 @@ func (bs *Server) ListValidatorBalances(
|
||||
if !filtered[index] {
|
||||
val := vals[index]
|
||||
st := validatorStatus(val, requestedEpoch)
|
||||
pk := vals[index].PublicKey()
|
||||
res = append(res, ðpb.ValidatorBalances_Balance{
|
||||
PublicKey: vals[index].PublicKey,
|
||||
PublicKey: pk[:],
|
||||
Index: index,
|
||||
Balance: balances[index],
|
||||
Status: st.String(),
|
||||
@@ -370,13 +372,21 @@ func (bs *Server) GetValidator(
|
||||
headState.NumValidators(),
|
||||
)
|
||||
}
|
||||
return headState.ValidatorAtIndex(index)
|
||||
v, err := headState.ValidatorAtIndex(index)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get validator from state: %v", err)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
pk48 := bytesutil.ToBytes48(pubKey)
|
||||
for i := primitives.ValidatorIndex(0); uint64(i) < uint64(headState.NumValidators()); i++ {
|
||||
keyFromState := headState.PubkeyAtIndex(i)
|
||||
if keyFromState == pk48 {
|
||||
return headState.ValidatorAtIndex(i)
|
||||
v, err := headState.ValidatorAtIndex(i)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get validator from state: %v", err)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
return nil, status.Error(codes.NotFound, "No validator matched filter criteria")
|
||||
@@ -446,23 +456,23 @@ func (bs *Server) GetValidatorQueue(
|
||||
awaitingExit := make([]primitives.ValidatorIndex, 0)
|
||||
exitEpochs := make([]primitives.Epoch, 0)
|
||||
activationQ := make([]primitives.ValidatorIndex, 0)
|
||||
vals := headState.Validators()
|
||||
vals := headState.ValidatorsReadOnly()
|
||||
for idx, validator := range vals {
|
||||
eligibleActivated := validator.ActivationEligibilityEpoch != params.BeaconConfig().FarFutureEpoch
|
||||
canBeActive := validator.ActivationEpoch >= helpers.ActivationExitEpoch(headState.FinalizedCheckpointEpoch())
|
||||
eligibleActivated := validator.ActivationEligibilityEpoch() != params.BeaconConfig().FarFutureEpoch
|
||||
canBeActive := validator.ActivationEpoch() >= helpers.ActivationExitEpoch(headState.FinalizedCheckpointEpoch())
|
||||
if eligibleActivated && canBeActive {
|
||||
activationQ = append(activationQ, primitives.ValidatorIndex(idx))
|
||||
}
|
||||
if validator.ExitEpoch != params.BeaconConfig().FarFutureEpoch {
|
||||
exitEpochs = append(exitEpochs, validator.ExitEpoch)
|
||||
if validator.ExitEpoch() != params.BeaconConfig().FarFutureEpoch {
|
||||
exitEpochs = append(exitEpochs, validator.ExitEpoch())
|
||||
awaitingExit = append(awaitingExit, primitives.ValidatorIndex(idx))
|
||||
}
|
||||
}
|
||||
sort.Slice(activationQ, func(i, j int) bool {
|
||||
return vals[i].ActivationEligibilityEpoch < vals[j].ActivationEligibilityEpoch
|
||||
return vals[i].ActivationEligibilityEpoch() < vals[j].ActivationEligibilityEpoch()
|
||||
})
|
||||
sort.Slice(awaitingExit, func(i, j int) bool {
|
||||
return vals[i].WithdrawableEpoch < vals[j].WithdrawableEpoch
|
||||
return vals[i].WithdrawableEpoch() < vals[j].WithdrawableEpoch()
|
||||
})
|
||||
|
||||
// Only activate just enough validators according to the activation churn limit.
|
||||
@@ -479,7 +489,7 @@ func (bs *Server) GetValidatorQueue(
|
||||
}
|
||||
exitQueueChurn := uint64(0)
|
||||
for _, val := range vals {
|
||||
if val.ExitEpoch == exitQueueEpoch {
|
||||
if val.ExitEpoch() == exitQueueEpoch {
|
||||
exitQueueChurn++
|
||||
}
|
||||
}
|
||||
@@ -496,7 +506,7 @@ func (bs *Server) GetValidatorQueue(
|
||||
for _, valIdx := range awaitingExit {
|
||||
val := vals[valIdx]
|
||||
// Ensure the validator has not yet exited before adding its index to the exit queue.
|
||||
if val.WithdrawableEpoch < minEpoch && !validatorHasExited(val, coreTime.CurrentEpoch(headState)) {
|
||||
if val.WithdrawableEpoch() < minEpoch && !validatorHasExited(val, coreTime.CurrentEpoch(headState)) {
|
||||
exitQueueIndices = append(exitQueueIndices, valIdx)
|
||||
}
|
||||
}
|
||||
@@ -505,10 +515,12 @@ func (bs *Server) GetValidatorQueue(
|
||||
activationQueueKeys := make([][]byte, len(activationQ))
|
||||
exitQueueKeys := make([][]byte, len(exitQueueIndices))
|
||||
for i, idx := range activationQ {
|
||||
activationQueueKeys[i] = vals[idx].PublicKey
|
||||
pk := vals[idx].PublicKey()
|
||||
activationQueueKeys[i] = pk[:]
|
||||
}
|
||||
for i, idx := range exitQueueIndices {
|
||||
exitQueueKeys[i] = vals[idx].PublicKey
|
||||
pk := vals[idx].PublicKey()
|
||||
exitQueueKeys[i] = pk[:]
|
||||
}
|
||||
|
||||
churnLimit := helpers.ValidatorActivationChurnLimit(activeValidatorCount)
|
||||
@@ -549,19 +561,19 @@ func (bs *Server) GetIndividualVotes(
|
||||
}
|
||||
|
||||
// Determines whether a validator has already exited.
|
||||
func validatorHasExited(validator *ethpb.Validator, currentEpoch primitives.Epoch) bool {
|
||||
func validatorHasExited(validator interfaces.ReadOnlyValidator, currentEpoch primitives.Epoch) bool {
|
||||
farFutureEpoch := params.BeaconConfig().FarFutureEpoch
|
||||
if currentEpoch < validator.ActivationEligibilityEpoch {
|
||||
if currentEpoch < validator.ActivationEligibilityEpoch() {
|
||||
return false
|
||||
}
|
||||
if currentEpoch < validator.ActivationEpoch {
|
||||
if currentEpoch < validator.ActivationEpoch() {
|
||||
return false
|
||||
}
|
||||
if validator.ExitEpoch == farFutureEpoch {
|
||||
if validator.ExitEpoch() == farFutureEpoch {
|
||||
return false
|
||||
}
|
||||
if currentEpoch < validator.ExitEpoch {
|
||||
if validator.Slashed {
|
||||
if currentEpoch < validator.ExitEpoch() {
|
||||
if validator.Slashed() {
|
||||
return false
|
||||
}
|
||||
return false
|
||||
@@ -569,22 +581,22 @@ func validatorHasExited(validator *ethpb.Validator, currentEpoch primitives.Epoc
|
||||
return true
|
||||
}
|
||||
|
||||
func validatorStatus(validator *ethpb.Validator, epoch primitives.Epoch) ethpb.ValidatorStatus {
|
||||
func validatorStatus(validator interfaces.ReadOnlyValidator, epoch primitives.Epoch) ethpb.ValidatorStatus {
|
||||
farFutureEpoch := params.BeaconConfig().FarFutureEpoch
|
||||
if validator == nil {
|
||||
return ethpb.ValidatorStatus_UNKNOWN_STATUS
|
||||
}
|
||||
if epoch < validator.ActivationEligibilityEpoch {
|
||||
if epoch < validator.ActivationEligibilityEpoch() {
|
||||
return ethpb.ValidatorStatus_DEPOSITED
|
||||
}
|
||||
if epoch < validator.ActivationEpoch {
|
||||
if epoch < validator.ActivationEpoch() {
|
||||
return ethpb.ValidatorStatus_PENDING
|
||||
}
|
||||
if validator.ExitEpoch == farFutureEpoch {
|
||||
if validator.ExitEpoch() == farFutureEpoch {
|
||||
return ethpb.ValidatorStatus_ACTIVE
|
||||
}
|
||||
if epoch < validator.ExitEpoch {
|
||||
if validator.Slashed {
|
||||
if epoch < validator.ExitEpoch() {
|
||||
if validator.Slashed() {
|
||||
return ethpb.ValidatorStatus_SLASHING
|
||||
}
|
||||
return ethpb.ValidatorStatus_EXITING
|
||||
|
||||
@@ -12,6 +12,8 @@ go_library(
|
||||
"//beacon-chain/state/state-native/custom-types:go_default_library",
|
||||
"//beacon-chain/state/state-native/types:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//container/multi-value-slice:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
customtypes "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native/custom-types"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native/types"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state/stateutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
state_native "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
multi_value_slice "github.com/prysmaticlabs/prysm/v5/container/multi-value-slice"
|
||||
pmath "github.com/prysmaticlabs/prysm/v5/math"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -163,7 +165,16 @@ func handle32ByteMVslice(mv multi_value_slice.MultiValueSliceComposite[[32]byte]
|
||||
func handleValidatorMVSlice(mv multi_value_slice.MultiValueSliceComposite[*ethpb.Validator], indices []uint64, convertAll bool) ([][32]byte, error) {
|
||||
length := len(indices)
|
||||
if convertAll {
|
||||
return stateutil.OptimizedValidatorRoots(mv.Value(mv.State()))
|
||||
var err error
|
||||
vals := mv.Value(mv.State())
|
||||
roVals := make([]interfaces.ReadOnlyValidator, 0, len(vals))
|
||||
for i := range vals {
|
||||
roVals[i], err = state_native.NewValidator(vals[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return stateutil.OptimizedValidatorRoots(roVals)
|
||||
}
|
||||
roots := make([][32]byte, 0, length)
|
||||
rootCreator := func(input *ethpb.Validator) error {
|
||||
|
||||
@@ -107,32 +107,18 @@ type WriteOnlyBeaconState interface {
|
||||
SetLatestExecutionPayloadHeader(payload interfaces.ExecutionData) error
|
||||
}
|
||||
|
||||
// ReadOnlyValidator defines a struct which only has read access to validator methods.
|
||||
type ReadOnlyValidator interface {
|
||||
EffectiveBalance() uint64
|
||||
ActivationEligibilityEpoch() primitives.Epoch
|
||||
ActivationEpoch() primitives.Epoch
|
||||
WithdrawableEpoch() primitives.Epoch
|
||||
ExitEpoch() primitives.Epoch
|
||||
PublicKey() [fieldparams.BLSPubkeyLength]byte
|
||||
GetWithdrawalCredentials() []byte
|
||||
Copy() *ethpb.Validator
|
||||
Slashed() bool
|
||||
IsNil() bool
|
||||
}
|
||||
|
||||
// ReadOnlyValidators defines a struct which only has read access to validators methods.
|
||||
type ReadOnlyValidators interface {
|
||||
Validators() []*ethpb.Validator
|
||||
ValidatorsReadOnly() []ReadOnlyValidator
|
||||
ValidatorsReadOnly() []interfaces.ReadOnlyValidator
|
||||
ValidatorAtIndex(idx primitives.ValidatorIndex) (*ethpb.Validator, error)
|
||||
ValidatorAtIndexReadOnly(idx primitives.ValidatorIndex) (ReadOnlyValidator, error)
|
||||
ValidatorAtIndexReadOnly(idx primitives.ValidatorIndex) (interfaces.ReadOnlyValidator, error)
|
||||
ValidatorIndexByPubkey(key [fieldparams.BLSPubkeyLength]byte) (primitives.ValidatorIndex, bool)
|
||||
PublicKeys() ([][fieldparams.BLSPubkeyLength]byte, error)
|
||||
PubkeyAtIndex(idx primitives.ValidatorIndex) [fieldparams.BLSPubkeyLength]byte
|
||||
AggregateKeyFromIndices(idxs []uint64) (bls.PublicKey, error)
|
||||
NumValidators() int
|
||||
ReadFromEveryValidator(f func(idx int, val ReadOnlyValidator) error) error
|
||||
ReadFromEveryValidator(f func(idx int, val interfaces.ReadOnlyValidator) error) error
|
||||
}
|
||||
|
||||
// ReadOnlyBalances defines a struct which only has read access to balances methods.
|
||||
@@ -257,7 +243,7 @@ type WriteOnlyEth1Data interface {
|
||||
// WriteOnlyValidators defines a struct which only has write access to validators methods.
|
||||
type WriteOnlyValidators interface {
|
||||
SetValidators(val []*ethpb.Validator) error
|
||||
ApplyToEveryValidator(f func(idx int, val ReadOnlyValidator) (*ethpb.Validator, error)) error
|
||||
ApplyToEveryValidator(f func(idx int, val interfaces.ReadOnlyValidator) (*ethpb.Validator, error)) error
|
||||
UpdateValidatorAtIndex(idx primitives.ValidatorIndex, val *ethpb.Validator) error
|
||||
AppendValidator(val *ethpb.Validator) error
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ go_library(
|
||||
"hasher.go",
|
||||
"multi_value_slices.go",
|
||||
"proofs.go",
|
||||
"readonly_validator.go",
|
||||
"setters_attestation.go",
|
||||
"setters_block.go",
|
||||
"setters_checkpoint.go",
|
||||
@@ -64,6 +63,7 @@ go_library(
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//container/multi-value-slice:go_default_library",
|
||||
"//container/slice:go_default_library",
|
||||
"//container/trie:go_default_library",
|
||||
@@ -103,7 +103,6 @@ go_test(
|
||||
"hasher_test.go",
|
||||
"mvslice_fuzz_test.go",
|
||||
"proofs_test.go",
|
||||
"readonly_validator_test.go",
|
||||
"references_test.go",
|
||||
"setters_attestation_test.go",
|
||||
"setters_churn_test.go",
|
||||
|
||||
@@ -7,7 +7,9 @@ import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -23,7 +25,7 @@ func (b *BeaconState) Validators() []*ethpb.Validator {
|
||||
}
|
||||
|
||||
// ValidatorsReadOnly participating in consensus on the beacon chain.
|
||||
func (b *BeaconState) ValidatorsReadOnly() []state.ReadOnlyValidator {
|
||||
func (b *BeaconState) ValidatorsReadOnly() []interfaces.ReadOnlyValidator {
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
|
||||
@@ -55,7 +57,7 @@ func (b *BeaconState) validatorsVal() []*ethpb.Validator {
|
||||
return res
|
||||
}
|
||||
|
||||
func (b *BeaconState) validatorsReadOnlyVal() []state.ReadOnlyValidator {
|
||||
func (b *BeaconState) validatorsReadOnlyVal() []interfaces.ReadOnlyValidator {
|
||||
var v []*ethpb.Validator
|
||||
if features.Get().EnableExperimentalState {
|
||||
if b.validatorsMultiValue == nil {
|
||||
@@ -69,14 +71,14 @@ func (b *BeaconState) validatorsReadOnlyVal() []state.ReadOnlyValidator {
|
||||
v = b.validators
|
||||
}
|
||||
|
||||
res := make([]state.ReadOnlyValidator, len(v))
|
||||
res := make([]interfaces.ReadOnlyValidator, len(v))
|
||||
var err error
|
||||
for i := 0; i < len(res); i++ {
|
||||
val := v[i]
|
||||
if val == nil {
|
||||
continue
|
||||
}
|
||||
res[i], err = NewValidator(val)
|
||||
res[i], err = validator.NewValidator(val)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -146,14 +148,14 @@ func (b *BeaconState) validatorAtIndex(idx primitives.ValidatorIndex) (*ethpb.Va
|
||||
|
||||
// ValidatorAtIndexReadOnly is the validator at the provided index. This method
|
||||
// doesn't clone the validator.
|
||||
func (b *BeaconState) ValidatorAtIndexReadOnly(idx primitives.ValidatorIndex) (state.ReadOnlyValidator, error) {
|
||||
func (b *BeaconState) ValidatorAtIndexReadOnly(idx primitives.ValidatorIndex) (interfaces.ReadOnlyValidator, error) {
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
|
||||
return b.validatorAtIndexReadOnly(idx)
|
||||
}
|
||||
|
||||
func (b *BeaconState) validatorAtIndexReadOnly(idx primitives.ValidatorIndex) (state.ReadOnlyValidator, error) {
|
||||
func (b *BeaconState) validatorAtIndexReadOnly(idx primitives.ValidatorIndex) (interfaces.ReadOnlyValidator, error) {
|
||||
if features.Get().EnableExperimentalState {
|
||||
if b.validatorsMultiValue == nil {
|
||||
return nil, state.ErrNilValidatorsInState
|
||||
@@ -162,7 +164,7 @@ func (b *BeaconState) validatorAtIndexReadOnly(idx primitives.ValidatorIndex) (s
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewValidator(v)
|
||||
return validator.NewValidator(v)
|
||||
}
|
||||
|
||||
if b.validators == nil {
|
||||
@@ -172,7 +174,7 @@ func (b *BeaconState) validatorAtIndexReadOnly(idx primitives.ValidatorIndex) (s
|
||||
return nil, errors.Wrapf(consensus_types.ErrOutOfBounds, "validator index %d does not exist", idx)
|
||||
}
|
||||
val := b.validators[idx]
|
||||
return NewValidator(val)
|
||||
return validator.NewValidator(val)
|
||||
}
|
||||
|
||||
// ValidatorIndexByPubkey returns a given validator by its 48-byte public key.
|
||||
@@ -246,7 +248,7 @@ func (b *BeaconState) AggregateKeyFromIndices(idxs []uint64) (bls.PublicKey, err
|
||||
}
|
||||
|
||||
if v == nil {
|
||||
return nil, ErrNilWrappedValidator
|
||||
return nil, validator.ErrNilWrappedValidator
|
||||
}
|
||||
pubKeys[i] = v.PublicKey
|
||||
}
|
||||
@@ -285,7 +287,7 @@ func (b *BeaconState) NumValidators() int {
|
||||
// ReadFromEveryValidator reads values from every validator and applies it to the provided function.
|
||||
//
|
||||
// WARNING: This method is potentially unsafe, as it exposes the actual validator registry.
|
||||
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyValidator) error) error {
|
||||
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val interfaces.ReadOnlyValidator) error) error {
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
|
||||
@@ -300,7 +302,7 @@ func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyV
|
||||
validators := b.validators
|
||||
|
||||
for i, v := range validators {
|
||||
v, err := NewValidator(v)
|
||||
v, err := validator.NewValidator(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -312,7 +314,7 @@ func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyV
|
||||
}
|
||||
|
||||
// WARNING: This function works only for the multi-value slice feature.
|
||||
func (b *BeaconState) readFromEveryValidatorMVSlice(f func(idx int, val state.ReadOnlyValidator) error) error {
|
||||
func (b *BeaconState) readFromEveryValidatorMVSlice(f func(idx int, val interfaces.ReadOnlyValidator) error) error {
|
||||
if b.validatorsMultiValue == nil {
|
||||
return state.ErrNilValidatorsInState
|
||||
}
|
||||
@@ -322,7 +324,7 @@ func (b *BeaconState) readFromEveryValidatorMVSlice(f func(idx int, val state.Re
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rov, err := NewValidator(v)
|
||||
rov, err := validator.NewValidator(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]b
|
||||
fieldRoots[types.Eth1DepositIndex.RealPosition()] = eth1DepositBuf[:]
|
||||
|
||||
// Validators slice root.
|
||||
validatorsRoot, err := stateutil.ValidatorRegistryRoot(state.validatorsVal())
|
||||
validatorsRoot, err := stateutil.ValidatorRegistryRoot(state.validatorsReadOnlyVal())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not compute validator registry merkleization")
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@ package state_native
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native/types"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state/stateutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
||||
@@ -39,7 +40,7 @@ func (b *BeaconState) SetValidators(val []*ethpb.Validator) error {
|
||||
|
||||
// ApplyToEveryValidator applies the provided callback function to each validator in the
|
||||
// validator registry.
|
||||
func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val state.ReadOnlyValidator) (*ethpb.Validator, error)) error {
|
||||
func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val interfaces.ReadOnlyValidator) (*ethpb.Validator, error)) error {
|
||||
var changedVals []uint64
|
||||
if features.Get().EnableExperimentalState {
|
||||
l := b.validatorsMultiValue.Len(b)
|
||||
@@ -48,7 +49,7 @@ func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val state.ReadOnlyVa
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ro, err := NewValidator(v)
|
||||
ro, err := validator.NewValidator(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -76,7 +77,7 @@ func (b *BeaconState) ApplyToEveryValidator(f func(idx int, val state.ReadOnlyVa
|
||||
b.lock.Unlock()
|
||||
|
||||
for i, val := range v {
|
||||
ro, err := NewValidator(val)
|
||||
ro, err := validator.NewValidator(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
|
||||
@@ -79,7 +80,7 @@ func (s *State) ActiveNonSlashedBalancesByRoot(ctx context.Context, blockRoot [3
|
||||
epoch := time.CurrentEpoch(st)
|
||||
|
||||
balances := make([]uint64, st.NumValidators())
|
||||
var balanceAccretor = func(idx int, val state.ReadOnlyValidator) error {
|
||||
var balanceAccretor = func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
if helpers.IsActiveNonSlashedValidatorUsingTrie(val, epoch) {
|
||||
balances[idx] = val.EffectiveBalance()
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/backfill/coverage"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
@@ -153,7 +154,7 @@ func (s *State) Resume(ctx context.Context, fState state.BeaconState) (state.Bea
|
||||
go populatePubkeyCacheOnce.Do(func() {
|
||||
log.Debug("Populating pubkey cache")
|
||||
start := time.Now()
|
||||
if err := fState.ReadFromEveryValidator(func(_ int, val state.ReadOnlyValidator) error {
|
||||
if err := fState.ReadFromEveryValidator(func(_ int, val interfaces.ReadOnlyValidator) error {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
@@ -29,7 +29,9 @@ go_library(
|
||||
"//beacon-chain/core/transition/stateutils:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//container/multi-value-slice:go_default_library",
|
||||
"//container/trie:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/hash/htr"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/ssz"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -28,11 +28,11 @@ const (
|
||||
// ValidatorRegistryRoot computes the HashTreeRoot Merkleization of
|
||||
// a list of validator structs according to the Ethereum
|
||||
// Simple Serialize specification.
|
||||
func ValidatorRegistryRoot(vals []*ethpb.Validator) ([32]byte, error) {
|
||||
func ValidatorRegistryRoot(vals []interfaces.ReadOnlyValidator) ([32]byte, error) {
|
||||
return validatorRegistryRoot(vals)
|
||||
}
|
||||
|
||||
func validatorRegistryRoot(validators []*ethpb.Validator) ([32]byte, error) {
|
||||
func validatorRegistryRoot(validators []interfaces.ReadOnlyValidator) ([32]byte, error) {
|
||||
roots, err := OptimizedValidatorRoots(validators)
|
||||
if err != nil {
|
||||
return [32]byte{}, err
|
||||
@@ -54,7 +54,7 @@ func validatorRegistryRoot(validators []*ethpb.Validator) ([32]byte, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func hashValidatorHelper(validators []*ethpb.Validator, roots [][32]byte, j int, groupSize int, wg *sync.WaitGroup) {
|
||||
func hashValidatorHelper(validators []interfaces.ReadOnlyValidator, roots [][32]byte, j int, groupSize int, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
for i := 0; i < groupSize; i++ {
|
||||
fRoots, err := ValidatorFieldRoots(validators[j*groupSize+i])
|
||||
@@ -70,7 +70,7 @@ func hashValidatorHelper(validators []*ethpb.Validator, roots [][32]byte, j int,
|
||||
|
||||
// OptimizedValidatorRoots uses an optimized routine with gohashtree in order to
|
||||
// derive a list of validator roots from a list of validator objects.
|
||||
func OptimizedValidatorRoots(validators []*ethpb.Validator) ([][32]byte, error) {
|
||||
func OptimizedValidatorRoots(validators []interfaces.ReadOnlyValidator) ([][32]byte, error) {
|
||||
// Exit early if no validators are provided.
|
||||
if len(validators) == 0 {
|
||||
return [][32]byte{}, nil
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
state_native "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/ssz"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
@@ -13,7 +15,11 @@ import (
|
||||
// ValidatorRootWithHasher describes a method from which the hash tree root
|
||||
// of a validator is returned.
|
||||
func ValidatorRootWithHasher(validator *ethpb.Validator) ([32]byte, error) {
|
||||
fieldRoots, err := ValidatorFieldRoots(validator)
|
||||
roValidator, err := state_native.NewValidator(validator)
|
||||
if err != nil {
|
||||
return [32]byte{}, err
|
||||
}
|
||||
fieldRoots, err := ValidatorFieldRoots(roValidator)
|
||||
if err != nil {
|
||||
return [32]byte{}, err
|
||||
}
|
||||
@@ -22,34 +28,34 @@ func ValidatorRootWithHasher(validator *ethpb.Validator) ([32]byte, error) {
|
||||
|
||||
// ValidatorFieldRoots describes a method from which the hash tree root
|
||||
// of a validator is returned.
|
||||
func ValidatorFieldRoots(validator *ethpb.Validator) ([][32]byte, error) {
|
||||
func ValidatorFieldRoots(validator interfaces.ReadOnlyValidator) ([][32]byte, error) {
|
||||
var fieldRoots [][32]byte
|
||||
if validator != nil {
|
||||
pubkey := bytesutil.ToBytes48(validator.PublicKey)
|
||||
withdrawCreds := bytesutil.ToBytes32(validator.WithdrawalCredentials)
|
||||
withdrawCreds := bytesutil.ToBytes32(validator.GetWithdrawalCredentials())
|
||||
var effectiveBalanceBuf [32]byte
|
||||
binary.LittleEndian.PutUint64(effectiveBalanceBuf[:8], validator.EffectiveBalance)
|
||||
binary.LittleEndian.PutUint64(effectiveBalanceBuf[:8], validator.EffectiveBalance())
|
||||
// Slashed.
|
||||
var slashBuf [32]byte
|
||||
if validator.Slashed {
|
||||
if validator.Slashed() {
|
||||
slashBuf[0] = uint8(1)
|
||||
} else {
|
||||
slashBuf[0] = uint8(0)
|
||||
}
|
||||
var activationEligibilityBuf [32]byte
|
||||
binary.LittleEndian.PutUint64(activationEligibilityBuf[:8], uint64(validator.ActivationEligibilityEpoch))
|
||||
binary.LittleEndian.PutUint64(activationEligibilityBuf[:8], uint64(validator.ActivationEligibilityEpoch()))
|
||||
|
||||
var activationBuf [32]byte
|
||||
binary.LittleEndian.PutUint64(activationBuf[:8], uint64(validator.ActivationEpoch))
|
||||
binary.LittleEndian.PutUint64(activationBuf[:8], uint64(validator.ActivationEpoch()))
|
||||
|
||||
var exitBuf [32]byte
|
||||
binary.LittleEndian.PutUint64(exitBuf[:8], uint64(validator.ExitEpoch))
|
||||
binary.LittleEndian.PutUint64(exitBuf[:8], uint64(validator.ExitEpoch()))
|
||||
|
||||
var withdrawalBuf [32]byte
|
||||
binary.LittleEndian.PutUint64(withdrawalBuf[:8], uint64(validator.WithdrawableEpoch))
|
||||
binary.LittleEndian.PutUint64(withdrawalBuf[:8], uint64(validator.WithdrawableEpoch()))
|
||||
|
||||
// Public key.
|
||||
pubKeyRoot, err := merkleizePubkey(pubkey[:])
|
||||
pk := validator.PublicKey()
|
||||
pubKeyRoot, err := merkleizePubkey(pk[:])
|
||||
if err != nil {
|
||||
return [][32]byte{}, err
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ go_library(
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//io/file:go_default_library",
|
||||
"//io/prompt:go_default_library",
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/api/client/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/cmd/validator/flags"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
validatorType "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
validatorType "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/io/file"
|
||||
"github.com/prysmaticlabs/prysm/v5/io/prompt"
|
||||
|
||||
@@ -8,7 +8,7 @@ go_library(
|
||||
deps = [
|
||||
"//config:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//proto/prysm/v1alpha1/validator-client:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
@@ -24,7 +24,7 @@ go_test(
|
||||
deps = [
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
|
||||
@@ -11,7 +11,7 @@ go_test(
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//config/proposer:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
@@ -34,7 +34,7 @@ go_library(
|
||||
"//config:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//config/proposer:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//proto/prysm/v1alpha1/validator-client:go_default_library",
|
||||
"//validator/db/iface:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/config"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/proposer"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
validatorpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/validator-client"
|
||||
"github.com/prysmaticlabs/prysm/v5/validator/db/iface"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -37,7 +37,7 @@ type settingsLoader struct {
|
||||
|
||||
type flagOptions struct {
|
||||
builderConfig *proposer.BuilderConfig
|
||||
gasLimit *validator.Uint64
|
||||
gasLimit *primitives.Uint64
|
||||
}
|
||||
|
||||
// SettingsLoaderOption sets additional options that affect the proposer settings
|
||||
@@ -49,7 +49,7 @@ func WithBuilderConfig() SettingsLoaderOption {
|
||||
if cliCtx.Bool(flags.EnableBuilderFlag.Name) {
|
||||
psl.options.builderConfig = &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -68,7 +68,7 @@ func WithGasLimit() SettingsLoaderOption {
|
||||
if gl == 0 {
|
||||
log.Warnf("Gas limit was intentionally set to 0, this will be replaced with the default gas limit of %d", params.BeaconConfig().DefaultBuilderGasLimit)
|
||||
}
|
||||
rgl := reviewGasLimit(validator.Uint64(gl))
|
||||
rgl := reviewGasLimit(primitives.Uint64(gl))
|
||||
psl.options.gasLimit = &rgl
|
||||
}
|
||||
return nil
|
||||
@@ -224,7 +224,7 @@ func (psl *settingsLoader) processProposerSettings(loadedSettings, dbSettings *v
|
||||
newSettings := &validatorpb.ProposerSettingsPayload{}
|
||||
|
||||
var builderConfig *validatorpb.BuilderConfig
|
||||
var gasLimitOnly *validator.Uint64
|
||||
var gasLimitOnly *primitives.Uint64
|
||||
|
||||
if psl.options != nil {
|
||||
if psl.options.builderConfig != nil {
|
||||
@@ -277,7 +277,7 @@ func (psl *settingsLoader) processProposerSettings(loadedSettings, dbSettings *v
|
||||
return newSettings
|
||||
}
|
||||
|
||||
func processBuilderConfig(current *validatorpb.BuilderConfig, override *validatorpb.BuilderConfig, gasLimitOnly *validator.Uint64) *validatorpb.BuilderConfig {
|
||||
func processBuilderConfig(current *validatorpb.BuilderConfig, override *validatorpb.BuilderConfig, gasLimitOnly *primitives.Uint64) *validatorpb.BuilderConfig {
|
||||
if current != nil {
|
||||
current.GasLimit = reviewGasLimit(current.GasLimit)
|
||||
if override != nil {
|
||||
@@ -291,10 +291,10 @@ func processBuilderConfig(current *validatorpb.BuilderConfig, override *validato
|
||||
return override
|
||||
}
|
||||
|
||||
func reviewGasLimit(gasLimit validator.Uint64) validator.Uint64 {
|
||||
func reviewGasLimit(gasLimit primitives.Uint64) primitives.Uint64 {
|
||||
// sets gas limit to default if not defined or set to 0
|
||||
if gasLimit == 0 {
|
||||
return validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit)
|
||||
return primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit)
|
||||
}
|
||||
// TODO(10810): add in warning for ranges
|
||||
return gasLimit
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/proposer"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
@@ -109,7 +109,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(30000000),
|
||||
GasLimit: primitives.Uint64(30000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -119,7 +119,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -160,7 +160,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -187,7 +187,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -197,7 +197,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -254,7 +254,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -312,7 +312,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
bytesutil.ToBytes48(key2): {
|
||||
@@ -321,7 +321,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(35000000),
|
||||
GasLimit: primitives.Uint64(35000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -331,7 +331,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -397,7 +397,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: false,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -443,7 +443,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -509,7 +509,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: false,
|
||||
GasLimit: validator.Uint64(50000000),
|
||||
GasLimit: primitives.Uint64(50000000),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -565,7 +565,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -575,7 +575,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -603,7 +603,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -613,7 +613,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -640,7 +640,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -650,7 +650,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -671,7 +671,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
DefaultConfig: &proposer.Option{
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -717,7 +717,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -727,7 +727,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -754,7 +754,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -764,7 +764,7 @@ func TestProposerSettingsLoader(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -994,7 +994,7 @@ func Test_ProposerSettingsLoaderWithOnlyBuilder_DoesNotSaveInDB(t *testing.T) {
|
||||
DefaultConfig: &proposer.Option{
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
Relays: nil,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/config"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
validatorpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/validator-client"
|
||||
)
|
||||
@@ -79,9 +79,9 @@ func verifyOption(key string, option *validatorpb.ProposerOptionPayload) error {
|
||||
// BuilderConfig is the struct representation of the JSON config file set in the validator through the CLI.
|
||||
// GasLimit is a number set to help the network decide on the maximum gas in each block.
|
||||
type BuilderConfig struct {
|
||||
Enabled bool `json:"enabled" yaml:"enabled"`
|
||||
GasLimit validator.Uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"`
|
||||
Relays []string `json:"relays,omitempty" yaml:"relays,omitempty"`
|
||||
Enabled bool `json:"enabled" yaml:"enabled"`
|
||||
GasLimit primitives.Uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"`
|
||||
Relays []string `json:"relays,omitempty" yaml:"relays,omitempty"`
|
||||
}
|
||||
|
||||
// BuilderConfigFromConsensus converts protobuf to a builder config used in in-memory storage
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
)
|
||||
@@ -24,7 +24,7 @@ func Test_Proposer_Setting_Cloning(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
Relays: []string{"https://example-relay.com"},
|
||||
},
|
||||
},
|
||||
@@ -35,7 +35,7 @@ func Test_Proposer_Setting_Cloning(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &BuilderConfig{
|
||||
Enabled: false,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
Relays: []string{"https://example-relay.com"},
|
||||
},
|
||||
},
|
||||
@@ -110,7 +110,7 @@ func TestProposerSettings_ShouldBeSaved(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
Relays: []string{"https://example-relay.com"},
|
||||
},
|
||||
},
|
||||
@@ -129,7 +129,7 @@ func TestProposerSettings_ShouldBeSaved(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
Relays: []string{"https://example-relay.com"},
|
||||
},
|
||||
},
|
||||
@@ -146,7 +146,7 @@ func TestProposerSettings_ShouldBeSaved(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
Relays: []string{"https://example-relay.com"},
|
||||
},
|
||||
},
|
||||
@@ -157,7 +157,7 @@ func TestProposerSettings_ShouldBeSaved(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
Relays: []string{"https://example-relay.com"},
|
||||
},
|
||||
},
|
||||
@@ -180,7 +180,7 @@ func TestProposerSettings_ShouldBeSaved(t *testing.T) {
|
||||
DefaultConfig: &Option{
|
||||
BuilderConfig: &BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
Relays: []string{"https://example-relay.com"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
package interfaces
|
||||
|
||||
import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
// ReadOnlyValidator defines a struct which only has read access to validator methods.
|
||||
type ReadOnlyValidator interface {
|
||||
EffectiveBalance() uint64
|
||||
ActivationEligibilityEpoch() primitives.Epoch
|
||||
ActivationEpoch() primitives.Epoch
|
||||
WithdrawableEpoch() primitives.Epoch
|
||||
ExitEpoch() primitives.Epoch
|
||||
PublicKey() [fieldparams.BLSPubkeyLength]byte
|
||||
GetWithdrawalCredentials() []byte
|
||||
Copy() *ethpb.Validator
|
||||
Slashed() bool
|
||||
IsNil() bool
|
||||
}
|
||||
|
||||
type WithWithdrawalCredentials interface {
|
||||
GetWithdrawalCredentials() []byte
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ go_library(
|
||||
"slot.go",
|
||||
"sszbytes.go",
|
||||
"sszuint64.go",
|
||||
"uint64.go",
|
||||
"validator.go",
|
||||
"wei.go",
|
||||
],
|
||||
@@ -37,6 +38,7 @@ go_test(
|
||||
"slot_test.go",
|
||||
"sszbytes_test.go",
|
||||
"sszuint64_test.go",
|
||||
"uint64_test.go",
|
||||
"validator_test.go",
|
||||
"wei_test.go",
|
||||
],
|
||||
@@ -44,5 +46,6 @@ go_test(
|
||||
deps = [
|
||||
"//math:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/util/yaml:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package validator
|
||||
package primitives
|
||||
|
||||
import "strconv"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package validator
|
||||
package primitives
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -3,20 +3,29 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"custom_types.go",
|
||||
"readonly_validator.go",
|
||||
"types.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/consensus-types/validator",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//consensus-types/primitives:go_default_library"],
|
||||
deps = [
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["custom_types_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
srcs = ["readonly_validator_test.go"],
|
||||
deps = [
|
||||
":go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/util/yaml:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package state_native
|
||||
package validator
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
@@ -19,10 +19,10 @@ type readOnlyValidator struct {
|
||||
validator *ethpb.Validator
|
||||
}
|
||||
|
||||
var _ = state.ReadOnlyValidator(readOnlyValidator{})
|
||||
var _ = interfaces.ReadOnlyValidator(readOnlyValidator{})
|
||||
|
||||
// NewValidator initializes the read only wrapper for validator.
|
||||
func NewValidator(v *ethpb.Validator) (state.ReadOnlyValidator, error) {
|
||||
func NewValidator(v *ethpb.Validator) (interfaces.ReadOnlyValidator, error) {
|
||||
if v == nil {
|
||||
return nil, ErrNilWrappedValidator
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package state_native_test
|
||||
package validator_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
statenative "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
statenative "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
@@ -23,8 +23,8 @@ proto_library(
|
||||
"@com_google_protobuf//:any_proto",
|
||||
"@com_google_protobuf//:descriptor_proto",
|
||||
"@com_google_protobuf//:empty_proto",
|
||||
"@com_google_protobuf//:wrappers_proto",
|
||||
"@com_google_protobuf//:timestamp_proto",
|
||||
"@com_google_protobuf//:wrappers_proto",
|
||||
"@googleapis//google/api:annotations_proto",
|
||||
],
|
||||
)
|
||||
@@ -39,7 +39,6 @@ go_proto_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//proto/eth/ext:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"@com_github_golang_protobuf//proto:go_default_library",
|
||||
@@ -47,12 +46,12 @@ go_proto_library(
|
||||
"@googleapis//google/api:annotations_go_proto",
|
||||
"@io_bazel_rules_go//proto/wkt:descriptor_go_proto",
|
||||
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
|
||||
"@org_golang_google_protobuf//types/known/wrapperspb:go_default_library",
|
||||
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
|
||||
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library",
|
||||
"@org_golang_google_protobuf//runtime/protoimpl:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/wrapperspb:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
sync "sync"
|
||||
|
||||
github_com_prysmaticlabs_prysm_v5_consensus_types_primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
github_com_prysmaticlabs_prysm_v5_consensus_types_validator "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
_ "github.com/prysmaticlabs/prysm/v5/proto/eth/ext"
|
||||
v1alpha1 "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -565,9 +564,9 @@ type BuilderConfig struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
|
||||
GasLimit github_com_prysmaticlabs_prysm_v5_consensus_types_validator.Uint64 `protobuf:"varint,2,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/validator.Uint64"`
|
||||
Relays []string `protobuf:"bytes,3,rep,name=relays,proto3" json:"relays,omitempty"`
|
||||
Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
|
||||
GasLimit github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Uint64 `protobuf:"varint,2,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Uint64"`
|
||||
Relays []string `protobuf:"bytes,3,rep,name=relays,proto3" json:"relays,omitempty"`
|
||||
}
|
||||
|
||||
func (x *BuilderConfig) Reset() {
|
||||
@@ -609,11 +608,11 @@ func (x *BuilderConfig) GetEnabled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *BuilderConfig) GetGasLimit() github_com_prysmaticlabs_prysm_v5_consensus_types_validator.Uint64 {
|
||||
func (x *BuilderConfig) GetGasLimit() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Uint64 {
|
||||
if x != nil {
|
||||
return x.GasLimit
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_validator.Uint64(0)
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Uint64(0)
|
||||
}
|
||||
|
||||
func (x *BuilderConfig) GetRelays() []string {
|
||||
@@ -853,54 +852,54 @@ var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDesc = []byte
|
||||
0x66, 0x69, 0x67, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x08,
|
||||
0x67, 0x72, 0x61, 0x66, 0x66, 0x69, 0x74, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00,
|
||||
0x52, 0x08, 0x67, 0x72, 0x61, 0x66, 0x66, 0x69, 0x74, 0x69, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a,
|
||||
0x09, 0x5f, 0x67, 0x72, 0x61, 0x66, 0x66, 0x69, 0x74, 0x69, 0x22, 0xa6, 0x01, 0x0a, 0x0d, 0x42,
|
||||
0x09, 0x5f, 0x67, 0x72, 0x61, 0x66, 0x66, 0x69, 0x74, 0x69, 0x22, 0xa7, 0x01, 0x0a, 0x0d, 0x42,
|
||||
0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65,
|
||||
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x63, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69,
|
||||
0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, 0x67,
|
||||
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x64, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69,
|
||||
0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x47, 0x82, 0xb5, 0x18, 0x43, 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, 0x35,
|
||||
0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73,
|
||||
0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x55, 0x69, 0x6e, 0x74, 0x36,
|
||||
0x34, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72,
|
||||
0x65, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x6c,
|
||||
0x61, 0x79, 0x73, 0x22, 0xe7, 0x02, 0x0a, 0x17, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72,
|
||||
0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12,
|
||||
0x74, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x66,
|
||||
0x69, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73,
|
||||
0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
|
||||
0x64, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
||||
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x43,
|
||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x5c, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,
|
||||
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
||||
0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50,
|
||||
0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79,
|
||||
0x6c, 0x6f, 0x61, 0x64, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e,
|
||||
0x66, 0x69, 0x67, 0x1a, 0x78, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x43,
|
||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
|
||||
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x4b, 0x0a, 0x05,
|
||||
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72,
|
||||
0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x6f,
|
||||
0x70, 0x6f, 0x73, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f,
|
||||
0x61, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0xce, 0x01,
|
||||
0x0a, 0x22, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x73, 0x2e, 0x76, 0x32, 0x42, 0x0f, 0x4b, 0x65, 0x79, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 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, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f,
|
||||
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74,
|
||||
0x3b, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xaa, 0x02, 0x1e, 0x45,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
|
||||
0x72, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x1e,
|
||||
0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
||||
0x6f, 0x72, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x32, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x55, 0x69, 0x6e, 0x74,
|
||||
0x36, 0x34, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x72, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65,
|
||||
0x6c, 0x61, 0x79, 0x73, 0x22, 0xe7, 0x02, 0x0a, 0x17, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65,
|
||||
0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
|
||||
0x12, 0x74, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e,
|
||||
0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4b, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f,
|
||||
0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f,
|
||||
0x61, 0x64, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||
0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72,
|
||||
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x5c, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c,
|
||||
0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e,
|
||||
0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61,
|
||||
0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f,
|
||||
0x6e, 0x66, 0x69, 0x67, 0x1a, 0x78, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72,
|
||||
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x4b, 0x0a,
|
||||
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
|
||||
0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72,
|
||||
0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c,
|
||||
0x6f, 0x61, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0xce,
|
||||
0x01, 0x0a, 0x22, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0f, 0x4b, 0x65, 0x79, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65,
|
||||
0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 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, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e,
|
||||
0x74, 0x3b, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xaa, 0x02, 0x1e,
|
||||
0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
||||
0x6f, 0x72, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02,
|
||||
0x1e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x32, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -98,7 +98,7 @@ message ProposerOptionPayload {
|
||||
// BuilderConfig is a property of ProposerOptionPayload
|
||||
message BuilderConfig {
|
||||
bool enabled = 1;
|
||||
uint64 gas_limit = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/validator.Uint64"];
|
||||
uint64 gas_limit = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Uint64"];
|
||||
repeated string relays = 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ func (s *PremineGenesisConfig) populate(g state.BeaconState) error {
|
||||
}
|
||||
|
||||
func (s *PremineGenesisConfig) setGenesisValidatorsRoot(g state.BeaconState) error {
|
||||
vroot, err := stateutil.ValidatorRegistryRoot(g.Validators())
|
||||
vroot, err := stateutil.ValidatorRegistryRoot(g.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -363,7 +363,7 @@ func (s *PremineGenesisConfig) setInactivityScores(g state.BeaconState) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
scoresMissing := len(g.Validators()) - len(scores)
|
||||
scoresMissing := len(g.ValidatorsReadOnly()) - len(scores)
|
||||
if scoresMissing > 0 {
|
||||
for i := 0; i < scoresMissing; i++ {
|
||||
scores = append(scores, 0)
|
||||
@@ -381,7 +381,7 @@ func (s *PremineGenesisConfig) setCurrentEpochParticipation(g state.BeaconState)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
missing := len(g.Validators()) - len(p)
|
||||
missing := len(g.ValidatorsReadOnly()) - len(p)
|
||||
if missing > 0 {
|
||||
for i := 0; i < missing; i++ {
|
||||
p = append(p, 0)
|
||||
@@ -399,7 +399,7 @@ func (s *PremineGenesisConfig) setPrevEpochParticipation(g state.BeaconState) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
missing := len(g.Validators()) - len(p)
|
||||
missing := len(g.ValidatorsReadOnly()) - len(p)
|
||||
if missing > 0 {
|
||||
for i := 0; i < missing; i++ {
|
||||
p = append(p, 0)
|
||||
|
||||
@@ -27,7 +27,6 @@ go_library(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/signing:go_default_library",
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||
corehelpers "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/signing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/ssz/detect"
|
||||
@@ -364,7 +364,7 @@ func proposeVoluntaryExit(ec *e2etypes.EvaluationContext, conns ...*grpc.ClientC
|
||||
return errors.Wrap(err, "could not get state")
|
||||
}
|
||||
var execIndices []int
|
||||
err = st.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
err = st.ReadFromEveryValidator(func(idx int, val interfaces.ReadOnlyValidator) error {
|
||||
if val.GetWithdrawalCredentials()[0] == params.BeaconConfig().ETH1AddressWithdrawalPrefixByte {
|
||||
execIndices = append(execIndices, idx)
|
||||
}
|
||||
@@ -595,15 +595,16 @@ func submitWithdrawal(ec *e2etypes.EvaluationContext, conns ...*grpc.ClientConn)
|
||||
if len(changes) >= wantedChanges {
|
||||
break
|
||||
}
|
||||
val, err := st.ValidatorAtIndex(idx)
|
||||
val, err := st.ValidatorAtIndexReadOnly(idx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if val.WithdrawalCredentials[0] == params.BeaconConfig().ETH1AddressWithdrawalPrefixByte {
|
||||
if val.GetWithdrawalCredentials()[0] == params.BeaconConfig().ETH1AddressWithdrawalPrefixByte {
|
||||
continue
|
||||
}
|
||||
if !bytes.Equal(val.PublicKey, privKeys[idx].PublicKey().Marshal()) {
|
||||
return errors.Errorf("pubkey is not equal, wanted %#x but received %#x", val.PublicKey, privKeys[idx].PublicKey().Marshal())
|
||||
pk := val.PublicKey()
|
||||
if !bytes.Equal(pk[:], privKeys[idx].PublicKey().Marshal()) {
|
||||
return errors.Errorf("pubkey is not equal, wanted %#x but received %#x", pk[:], privKeys[idx].PublicKey().Marshal())
|
||||
}
|
||||
message := ðpb.BLSToExecutionChange{
|
||||
ValidatorIndex: idx,
|
||||
|
||||
@@ -113,7 +113,7 @@ func buildGenesisBeaconState(genesisTime uint64, preState state.BeaconState, eth
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func buildGenesisBeaconStateBellatrix(genesisTime uint64, preState state.BeaconS
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
@@ -134,7 +134,7 @@ func buildGenesisBeaconStateBellatrix(genesisTime uint64, preState state.BeaconS
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scoresMissing := len(preState.Validators()) - len(scores)
|
||||
scoresMissing := len(preState.ValidatorsReadOnly()) - len(scores)
|
||||
if scoresMissing > 0 {
|
||||
for i := 0; i < scoresMissing; i++ {
|
||||
scores = append(scores, 0)
|
||||
|
||||
@@ -116,7 +116,7 @@ func buildGenesisBeaconStateCapella(genesisTime uint64, preState state.BeaconSta
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func buildGenesisBeaconStateDeneb(genesisTime uint64, preState state.BeaconState
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func buildGenesisBeaconStateElectra(genesisTime uint64, preState state.BeaconSta
|
||||
|
||||
slashings := make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector)
|
||||
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.Validators())
|
||||
genesisValidatorsRoot, err := stateutil.ValidatorRegistryRoot(preState.ValidatorsReadOnly())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not hash tree root genesis validators %v", err)
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ func printStates(stateC <-chan *modifiedState, doneC chan<- bool) {
|
||||
size, count = sizeAndCountGeneric(st.Eth1DataVotes(), nil)
|
||||
log.Infof("eth1_data_votes : sizeSSZ = %s, count = %d", humanize.Bytes(size), count)
|
||||
log.Infof("eth1_deposit_index : %d", st.Eth1DepositIndex())
|
||||
size, count = sizeAndCountGeneric(st.Validators(), nil)
|
||||
size, count = sizeAndCountGeneric(st.ValidatorsReadOnly(), nil)
|
||||
log.Infof("validators : sizeSSZ = %s, count = %d", humanize.Bytes(size), count)
|
||||
size, count = sizeAndCountOfUin64List(st.Balances())
|
||||
log.Infof("balances : size = %s, count = %d", humanize.Bytes(size), count)
|
||||
@@ -434,8 +434,8 @@ func checkValidatorMigration(dbNameWithPath, destDbNameWithPath string) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(sourceState.Validators()) != len(destinationState.Validators()) {
|
||||
log.Fatalf("validator mismatch : source = %d, dest = %d", len(sourceState.Validators()), len(destinationState.Validators()))
|
||||
if len(sourceState.ValidatorsReadOnly()) != len(destinationState.ValidatorsReadOnly()) {
|
||||
log.Fatalf("validator mismatch : source = %d, dest = %d", len(sourceState.ValidatorsReadOnly()), len(destinationState.ValidatorsReadOnly()))
|
||||
}
|
||||
sourceStateHash, err := sourceState.HashTreeRoot(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,7 +16,6 @@ go_library(
|
||||
"//api/client/event:go_default_library",
|
||||
"//api/server/structs:go_default_library",
|
||||
"//beacon-chain/rpc/eth/helpers:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//monitoring/tracing/trace:go_default_library",
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/helpers"
|
||||
statenative "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
eth "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
|
||||
@@ -55,7 +54,7 @@ func (g grpcPrysmChainClient) ValidatorCount(ctx context.Context, _ string, stat
|
||||
func validatorCountByStatus(validators []*ethpb.Validator, statuses []validator.Status, epoch primitives.Epoch) ([]iface.ValidatorCount, error) {
|
||||
countByStatus := make(map[validator.Status]uint64)
|
||||
for _, val := range validators {
|
||||
readOnlyVal, err := statenative.NewValidator(val)
|
||||
readOnlyVal, err := validator.NewValidator(val)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not convert validator: %w", err)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/proposer"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
validatorType "github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/bls"
|
||||
blsmock "github.com/prysmaticlabs/prysm/v5/crypto/bls/common/mock"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
@@ -1745,7 +1744,7 @@ func TestValidator_PushSettings(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validatorType.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -80,7 +80,6 @@ go_test(
|
||||
"//config/proposer:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/proposer"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
)
|
||||
@@ -28,7 +28,7 @@ func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -38,7 +38,7 @@ func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: false,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: false,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
GasLimit: primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit),
|
||||
},
|
||||
}
|
||||
settings.DefaultConfig = updatedDefault
|
||||
@@ -90,7 +90,7 @@ func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) {
|
||||
},
|
||||
BuilderConfig: &proposer.BuilderConfig{
|
||||
Enabled: true,
|
||||
GasLimit: validator.Uint64(40000000),
|
||||
GasLimit: primitives.Uint64(40000000),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ go_library(
|
||||
"//config/params:go_default_library",
|
||||
"//config/proposer:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//io/file:go_default_library",
|
||||
@@ -111,7 +110,6 @@ go_test(
|
||||
"//config/params:go_default_library",
|
||||
"//config/proposer:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/rand:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/proposer"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
|
||||
"github.com/prysmaticlabs/prysm/v5/network/httputil"
|
||||
@@ -788,7 +787,7 @@ func (s *Server) SetGasLimit(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*proposer.Option)
|
||||
option := settings.DefaultConfig.Clone()
|
||||
option.BuilderConfig.GasLimit = validator.Uint64(gasLimit)
|
||||
option.BuilderConfig.GasLimit = primitives.Uint64(gasLimit)
|
||||
settings.ProposeConfig[bytesutil.ToBytes48(pubkey)] = option
|
||||
} else {
|
||||
proposerOption, found := settings.ProposeConfig[bytesutil.ToBytes48(pubkey)]
|
||||
@@ -797,7 +796,7 @@ func (s *Server) SetGasLimit(w http.ResponseWriter, r *http.Request) {
|
||||
httputil.HandleError(w, "Gas limit changes only apply when builder is enabled", http.StatusInternalServerError)
|
||||
return
|
||||
} else {
|
||||
proposerOption.BuilderConfig.GasLimit = validator.Uint64(gasLimit)
|
||||
proposerOption.BuilderConfig.GasLimit = primitives.Uint64(gasLimit)
|
||||
}
|
||||
} else {
|
||||
if settings.DefaultConfig == nil {
|
||||
@@ -805,7 +804,7 @@ func (s *Server) SetGasLimit(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
option := settings.DefaultConfig.Clone()
|
||||
option.BuilderConfig.GasLimit = validator.Uint64(gasLimit)
|
||||
option.BuilderConfig.GasLimit = primitives.Uint64(gasLimit)
|
||||
settings.ProposeConfig[bytesutil.ToBytes48(pubkey)] = option
|
||||
}
|
||||
}
|
||||
@@ -840,7 +839,7 @@ func (s *Server) DeleteGasLimit(w http.ResponseWriter, r *http.Request) {
|
||||
proposerOption.BuilderConfig.GasLimit = proposerSettings.DefaultConfig.BuilderConfig.GasLimit
|
||||
} else {
|
||||
// Fallback to using global default.
|
||||
proposerOption.BuilderConfig.GasLimit = validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit)
|
||||
proposerOption.BuilderConfig.GasLimit = primitives.Uint64(params.BeaconConfig().DefaultBuilderGasLimit)
|
||||
}
|
||||
// save the settings
|
||||
if err := s.validatorService.SetProposerSettings(ctx, proposerSettings); err != nil {
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/proposer"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
@@ -1198,11 +1197,11 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
params.BeaconConfig().DefaultBuilderGasLimit = originBeaconChainGasLimit
|
||||
}()
|
||||
|
||||
globalDefaultGasLimit := validator.Uint64(0xbbdd)
|
||||
globalDefaultGasLimit := primitives.Uint64(0xbbdd)
|
||||
|
||||
type want struct {
|
||||
pubkey []byte
|
||||
gaslimit validator.Uint64
|
||||
gaslimit primitives.Uint64
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -1218,14 +1217,14 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
proposerSettings: &proposer.Settings{
|
||||
ProposeConfig: map[[48]byte]*proposer.Option{
|
||||
bytesutil.ToBytes48(pubkey1): {
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: validator.Uint64(987654321)},
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: primitives.Uint64(987654321)},
|
||||
},
|
||||
bytesutil.ToBytes48(pubkey2): {
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: validator.Uint64(123456789)},
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: primitives.Uint64(123456789)},
|
||||
},
|
||||
},
|
||||
DefaultConfig: &proposer.Option{
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: validator.Uint64(5555)},
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: primitives.Uint64(5555)},
|
||||
},
|
||||
},
|
||||
wantError: nil,
|
||||
@@ -1233,11 +1232,11 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
{
|
||||
pubkey: pubkey1,
|
||||
// After deletion, use DefaultConfig.BuilderConfig.GasLimitMetaData.
|
||||
gaslimit: validator.Uint64(5555),
|
||||
gaslimit: primitives.Uint64(5555),
|
||||
},
|
||||
{
|
||||
pubkey: pubkey2,
|
||||
gaslimit: validator.Uint64(123456789),
|
||||
gaslimit: primitives.Uint64(123456789),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1247,10 +1246,10 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
proposerSettings: &proposer.Settings{
|
||||
ProposeConfig: map[[48]byte]*proposer.Option{
|
||||
bytesutil.ToBytes48(pubkey1): {
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: validator.Uint64(987654321)},
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: primitives.Uint64(987654321)},
|
||||
},
|
||||
bytesutil.ToBytes48(pubkey2): {
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: validator.Uint64(123456789)},
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: primitives.Uint64(123456789)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1263,7 +1262,7 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
},
|
||||
{
|
||||
pubkey: pubkey2,
|
||||
gaslimit: validator.Uint64(123456789),
|
||||
gaslimit: primitives.Uint64(123456789),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1273,7 +1272,7 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
proposerSettings: &proposer.Settings{
|
||||
ProposeConfig: map[[48]byte]*proposer.Option{
|
||||
bytesutil.ToBytes48(pubkey1): {
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: validator.Uint64(987654321)},
|
||||
BuilderConfig: &proposer.BuilderConfig{GasLimit: primitives.Uint64(987654321)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1282,7 +1281,7 @@ func TestServer_DeleteGasLimit(t *testing.T) {
|
||||
// pubkey1's gaslimit is unaffected
|
||||
{
|
||||
pubkey: pubkey1,
|
||||
gaslimit: validator.Uint64(987654321),
|
||||
gaslimit: primitives.Uint64(987654321),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user