diff --git a/api/client/builder/bid.go b/api/client/builder/bid.go index df4b92fb31b7..50e3e21952f2 100644 --- a/api/client/builder/bid.go +++ b/api/client/builder/bid.go @@ -6,6 +6,7 @@ import ( consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "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" ) @@ -165,7 +166,7 @@ func WrappedBuilderBidCapella(p *ethpb.BuilderBidCapella) (Bid, error) { // Header returns the execution data interface. func (b builderBidCapella) Header() (interfaces.ExecutionData, error) { // We have to convert big endian to little endian because the value is coming from the execution layer. - return blocks.WrappedExecutionPayloadHeaderCapella(b.p.Header, blocks.PayloadValueToWei(b.p.Value)) + return blocks.WrappedExecutionPayloadHeaderCapella(b.p.Header, primitives.BigEndianBytesToWei(b.p.Value)) } // BlobKzgCommitments -- diff --git a/beacon-chain/core/electra/BUILD.bazel b/beacon-chain/core/electra/BUILD.bazel index ac9e5de4a526..1d8ad06b35d8 100644 --- a/beacon-chain/core/electra/BUILD.bazel +++ b/beacon-chain/core/electra/BUILD.bazel @@ -55,7 +55,6 @@ go_test( "//crypto/bls/blst:go_default_library", "//crypto/bls/common:go_default_library", "//encoding/bytesutil:go_default_library", - "//math:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//runtime/interop:go_default_library", diff --git a/beacon-chain/core/electra/balance_deposits.go b/beacon-chain/core/electra/balance_deposits.go index 75ef2a8ea949..6f1874e9a318 100644 --- a/beacon-chain/core/electra/balance_deposits.go +++ b/beacon-chain/core/electra/balance_deposits.go @@ -6,7 +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/math" + "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "go.opencensus.io/trace" ) @@ -32,7 +32,7 @@ import ( // state.deposit_balance_to_consume = Gwei(0) // else: // state.deposit_balance_to_consume = available_for_processing - processed_amount -func ProcessPendingBalanceDeposits(ctx context.Context, st state.BeaconState, activeBalance math.Gwei) error { +func ProcessPendingBalanceDeposits(ctx context.Context, st state.BeaconState, activeBalance primitives.Gwei) error { _, span := trace.StartSpan(ctx, "electra.ProcessPendingBalanceDeposits") defer span.End() @@ -54,13 +54,13 @@ func ProcessPendingBalanceDeposits(ctx context.Context, st state.BeaconState, ac } for _, deposit := range deposits { - if math.Gwei(deposit.Amount) > availableForProcessing { + if primitives.Gwei(deposit.Amount) > availableForProcessing { break } if err := helpers.IncreaseBalance(st, deposit.Index, deposit.Amount); err != nil { return err } - availableForProcessing -= math.Gwei(deposit.Amount) + availableForProcessing -= primitives.Gwei(deposit.Amount) nextDepositIndex++ } diff --git a/beacon-chain/core/electra/balance_deposits_test.go b/beacon-chain/core/electra/balance_deposits_test.go index 980785d86b46..552ef548c54b 100644 --- a/beacon-chain/core/electra/balance_deposits_test.go +++ b/beacon-chain/core/electra/balance_deposits_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" ) @@ -36,7 +35,7 @@ func TestProcessPendingBalanceDeposits(t *testing.T) { check: func(t *testing.T, st state.BeaconState) { res, err := st.DepositBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(0), res) + require.Equal(t, primitives.Gwei(0), res) }, }, { @@ -59,7 +58,7 @@ func TestProcessPendingBalanceDeposits(t *testing.T) { amountAvailForProcessing := helpers.ActivationExitChurnLimit(1_000 * 1e9) res, err := st.DepositBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(100), res) + require.Equal(t, primitives.Gwei(100), res) // Validators 0..9 should have their balance increased for i := primitives.ValidatorIndex(0); i < 10; i++ { b, err := st.BalanceAtIndex(i) @@ -93,7 +92,7 @@ func TestProcessPendingBalanceDeposits(t *testing.T) { amountAvailForProcessing := helpers.ActivationExitChurnLimit(1_000 * 1e9) res, err := st.DepositBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(0), res) + require.Equal(t, primitives.Gwei(0), res) // Validators 0..4 should have their balance increased for i := primitives.ValidatorIndex(0); i < 4; i++ { b, err := st.BalanceAtIndex(i) @@ -119,7 +118,7 @@ func TestProcessPendingBalanceDeposits(t *testing.T) { tab, err = helpers.TotalActiveBalance(tt.state) } require.NoError(t, err) - err = electra.ProcessPendingBalanceDeposits(context.TODO(), tt.state, math.Gwei(tab)) + err = electra.ProcessPendingBalanceDeposits(context.TODO(), tt.state, primitives.Gwei(tab)) require.Equal(t, tt.wantErr, err != nil, "wantErr=%v, got err=%s", tt.wantErr, err) if tt.check != nil { tt.check(t, tt.state) diff --git a/beacon-chain/core/electra/churn.go b/beacon-chain/core/electra/churn.go index bde3fe912516..8903ec54b531 100644 --- a/beacon-chain/core/electra/churn.go +++ b/beacon-chain/core/electra/churn.go @@ -37,7 +37,7 @@ import ( // state.earliest_consolidation_epoch = earliest_consolidation_epoch // // return state.earliest_consolidation_epoch -func ComputeConsolidationEpochAndUpdateChurn(ctx context.Context, s state.BeaconState, consolidationBalance math.Gwei) (primitives.Epoch, error) { +func ComputeConsolidationEpochAndUpdateChurn(ctx context.Context, s state.BeaconState, consolidationBalance primitives.Gwei) (primitives.Epoch, error) { earliestEpoch, err := s.EarliestConsolidationEpoch() if err != nil { return 0, err @@ -47,10 +47,10 @@ func ComputeConsolidationEpochAndUpdateChurn(ctx context.Context, s state.Beacon if err != nil { return 0, err } - perEpochConsolidationChurn := helpers.ConsolidationChurnLimit(math.Gwei(activeBal)) + perEpochConsolidationChurn := helpers.ConsolidationChurnLimit(primitives.Gwei(activeBal)) // New epoch for consolidations. - var consolidationBalanceToConsume math.Gwei + var consolidationBalanceToConsume primitives.Gwei if earliestEpoch < earliestConsolidationEpoch { consolidationBalanceToConsume = perEpochConsolidationChurn } else { @@ -70,7 +70,7 @@ func ComputeConsolidationEpochAndUpdateChurn(ctx context.Context, s state.Beacon } additionalEpochs++ earliestConsolidationEpoch += primitives.Epoch(additionalEpochs) - consolidationBalanceToConsume += math.Gwei(additionalEpochs) * perEpochConsolidationChurn + consolidationBalanceToConsume += primitives.Gwei(additionalEpochs) * perEpochConsolidationChurn } // Consume the balance and update state variables. diff --git a/beacon-chain/core/electra/churn_test.go b/beacon-chain/core/electra/churn_test.go index 3ce9d839c629..d1920229ca3b 100644 --- a/beacon-chain/core/electra/churn_test.go +++ b/beacon-chain/core/electra/churn_test.go @@ -9,14 +9,13 @@ 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" - "github.com/prysmaticlabs/prysm/v5/math" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/time/slots" ) -func createValidatorsWithTotalActiveBalance(totalBal math.Gwei) []*eth.Validator { - num := totalBal / math.Gwei(params.BeaconConfig().MinActivationBalance) +func createValidatorsWithTotalActiveBalance(totalBal primitives.Gwei) []*eth.Validator { + num := totalBal / primitives.Gwei(params.BeaconConfig().MinActivationBalance) vals := make([]*eth.Validator, num) for i := range vals { vals[i] = ð.Validator{ @@ -25,7 +24,7 @@ func createValidatorsWithTotalActiveBalance(totalBal math.Gwei) []*eth.Validator EffectiveBalance: params.BeaconConfig().MinActivationBalance, } } - if totalBal%math.Gwei(params.BeaconConfig().MinActivationBalance) != 0 { + if totalBal%primitives.Gwei(params.BeaconConfig().MinActivationBalance) != 0 { vals = append(vals, ð.Validator{ ActivationEpoch: primitives.Epoch(0), ExitEpoch: params.BeaconConfig().FarFutureEpoch, @@ -41,9 +40,9 @@ func TestComputeConsolidationEpochAndUpdateChurn(t *testing.T) { tests := []struct { name string state state.BeaconState - consolidationBalance math.Gwei + consolidationBalance primitives.Gwei expectedEpoch primitives.Epoch - expectedConsolidationBalanceToConsume math.Gwei + expectedConsolidationBalanceToConsume primitives.Gwei }{ { name: "compute consolidation with no consolidation balance", diff --git a/beacon-chain/core/electra/consolidations.go b/beacon-chain/core/electra/consolidations.go index 603e40d893e0..37145c29a519 100644 --- a/beacon-chain/core/electra/consolidations.go +++ b/beacon-chain/core/electra/consolidations.go @@ -8,8 +8,8 @@ import ( "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/primitives" "github.com/prysmaticlabs/prysm/v5/crypto/bls" - "github.com/prysmaticlabs/prysm/v5/math" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/time/slots" "go.opencensus.io/trace" @@ -166,7 +166,7 @@ func ProcessConsolidations(ctx context.Context, st state.BeaconState, cs []*ethp return err } - if helpers.ConsolidationChurnLimit(math.Gwei(totalBalance)) <= math.Gwei(params.BeaconConfig().MinActivationBalance) { + if helpers.ConsolidationChurnLimit(primitives.Gwei(totalBalance)) <= primitives.Gwei(params.BeaconConfig().MinActivationBalance) { return errors.New("too little available consolidation churn limit") } @@ -240,7 +240,7 @@ func ProcessConsolidations(ctx context.Context, st state.BeaconState, cs []*ethp return errors.New("consolidation signature verification failed") } - sEE, err := ComputeConsolidationEpochAndUpdateChurn(ctx, st, math.Gwei(source.EffectiveBalance)) + sEE, err := ComputeConsolidationEpochAndUpdateChurn(ctx, st, primitives.Gwei(source.EffectiveBalance)) if err != nil { return err } diff --git a/beacon-chain/core/electra/upgrade.go b/beacon-chain/core/electra/upgrade.go index 3ef96449c40f..cfb625cfeec9 100644 --- a/beacon-chain/core/electra/upgrade.go +++ b/beacon-chain/core/electra/upgrade.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" - "github.com/prysmaticlabs/prysm/v5/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/time/slots" @@ -271,9 +270,9 @@ func UpgradeToElectra(beaconState state.BeaconState) (state.BeaconState, error) DepositReceiptsStartIndex: params.BeaconConfig().UnsetDepositReceiptsStartIndex, DepositBalanceToConsume: 0, - ExitBalanceToConsume: helpers.ActivationExitChurnLimit(math.Gwei(tab)), + ExitBalanceToConsume: helpers.ActivationExitChurnLimit(primitives.Gwei(tab)), EarliestExitEpoch: earliestExitEpoch, - ConsolidationBalanceToConsume: helpers.ConsolidationChurnLimit(math.Gwei(tab)), + ConsolidationBalanceToConsume: helpers.ConsolidationChurnLimit(primitives.Gwei(tab)), EarliestConsolidationEpoch: helpers.ActivationExitEpoch(slots.ToEpoch(beaconState.Slot())), PendingBalanceDeposits: make([]*ethpb.PendingBalanceDeposit, 0), PendingPartialWithdrawals: make([]*ethpb.PendingPartialWithdrawal, 0), diff --git a/beacon-chain/core/electra/upgrade_test.go b/beacon-chain/core/electra/upgrade_test.go index ee180189e10a..4193b6b9ce7a 100644 --- a/beacon-chain/core/electra/upgrade_test.go +++ b/beacon-chain/core/electra/upgrade_test.go @@ -9,7 +9,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" - "github.com/prysmaticlabs/prysm/v5/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" @@ -152,14 +151,14 @@ func TestUpgradeToElectra(t *testing.T) { balance, err := mSt.DepositBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(0), balance) + require.Equal(t, primitives.Gwei(0), balance) tab, err := helpers.TotalActiveBalance(mSt) require.NoError(t, err) ebtc, err := mSt.ExitBalanceToConsume() require.NoError(t, err) - require.Equal(t, helpers.ActivationExitChurnLimit(math.Gwei(tab)), ebtc) + require.Equal(t, helpers.ActivationExitChurnLimit(primitives.Gwei(tab)), ebtc) eee, err := mSt.EarliestExitEpoch() require.NoError(t, err) @@ -167,7 +166,7 @@ func TestUpgradeToElectra(t *testing.T) { cbtc, err := mSt.ConsolidationBalanceToConsume() require.NoError(t, err) - require.Equal(t, helpers.ConsolidationChurnLimit(math.Gwei(tab)), cbtc) + require.Equal(t, helpers.ConsolidationChurnLimit(primitives.Gwei(tab)), cbtc) earliestConsolidationEpoch, err := mSt.EarliestConsolidationEpoch() require.NoError(t, err) diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 1b5709add134..1912d6c2998c 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -78,7 +78,6 @@ go_test( "//container/slice:go_default_library", "//crypto/hash:go_default_library", "//encoding/bytesutil:go_default_library", - "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//testing/assert:go_default_library", "//testing/require:go_default_library", diff --git a/beacon-chain/core/helpers/validator_churn.go b/beacon-chain/core/helpers/validator_churn.go index 04409f08112a..a038e32b7db8 100644 --- a/beacon-chain/core/helpers/validator_churn.go +++ b/beacon-chain/core/helpers/validator_churn.go @@ -2,7 +2,7 @@ package helpers import ( "github.com/prysmaticlabs/prysm/v5/config/params" - "github.com/prysmaticlabs/prysm/v5/math" + "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" ) // BalanceChurnLimit for the current active balance, in gwei. @@ -19,12 +19,12 @@ import ( // get_total_active_balance(state) // CHURN_LIMIT_QUOTIENT // ) // return churn - churn % EFFECTIVE_BALANCE_INCREMENT -func BalanceChurnLimit(activeBalance math.Gwei) math.Gwei { +func BalanceChurnLimit(activeBalance primitives.Gwei) primitives.Gwei { churn := max( params.BeaconConfig().MinPerEpochChurnLimitElectra, (uint64(activeBalance) / params.BeaconConfig().ChurnLimitQuotient), ) - return math.Gwei(churn - churn%params.BeaconConfig().EffectiveBalanceIncrement) + return primitives.Gwei(churn - churn%params.BeaconConfig().EffectiveBalanceIncrement) } // ActivationExitChurnLimit for the current active balance, in gwei. @@ -37,8 +37,8 @@ func BalanceChurnLimit(activeBalance math.Gwei) math.Gwei { // Return the churn limit for the current epoch dedicated to activations and exits. // """ // return min(MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT, get_balance_churn_limit(state)) -func ActivationExitChurnLimit(activeBalance math.Gwei) math.Gwei { - return min(math.Gwei(params.BeaconConfig().MaxPerEpochActivationExitChurnLimit), BalanceChurnLimit(activeBalance)) +func ActivationExitChurnLimit(activeBalance primitives.Gwei) primitives.Gwei { + return min(primitives.Gwei(params.BeaconConfig().MaxPerEpochActivationExitChurnLimit), BalanceChurnLimit(activeBalance)) } // ConsolidationChurnLimit for the current active balance, in gwei. @@ -48,6 +48,6 @@ func ActivationExitChurnLimit(activeBalance math.Gwei) math.Gwei { // // def get_consolidation_churn_limit(state: BeaconState) -> Gwei: // return get_balance_churn_limit(state) - get_activation_exit_churn_limit(state) -func ConsolidationChurnLimit(activeBalance math.Gwei) math.Gwei { +func ConsolidationChurnLimit(activeBalance primitives.Gwei) primitives.Gwei { return BalanceChurnLimit(activeBalance) - ActivationExitChurnLimit(activeBalance) } diff --git a/beacon-chain/core/helpers/validator_churn_test.go b/beacon-chain/core/helpers/validator_churn_test.go index 6a83b4f0168c..9b5fac3d6cee 100644 --- a/beacon-chain/core/helpers/validator_churn_test.go +++ b/beacon-chain/core/helpers/validator_churn_test.go @@ -5,30 +5,30 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v5/config/params" - "github.com/prysmaticlabs/prysm/v5/math" + "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/testing/assert" ) func TestBalanceChurnLimit(t *testing.T) { tests := []struct { name string - activeBalance math.Gwei - expected math.Gwei + activeBalance primitives.Gwei + expected primitives.Gwei }{ { name: "less than MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA", activeBalance: 111, - expected: math.Gwei(params.BeaconConfig().MinPerEpochChurnLimitElectra), + expected: primitives.Gwei(params.BeaconConfig().MinPerEpochChurnLimitElectra), }, { name: "modulo EFFECTIVE_BALANCE_INCREMENT", - activeBalance: math.Gwei(111 + params.BeaconConfig().MinPerEpochChurnLimitElectra*params.BeaconConfig().ChurnLimitQuotient), - expected: math.Gwei(params.BeaconConfig().MinPerEpochChurnLimitElectra), + activeBalance: primitives.Gwei(111 + params.BeaconConfig().MinPerEpochChurnLimitElectra*params.BeaconConfig().ChurnLimitQuotient), + expected: primitives.Gwei(params.BeaconConfig().MinPerEpochChurnLimitElectra), }, { name: "more than MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA", - activeBalance: math.Gwei(2000 * params.BeaconConfig().EffectiveBalanceIncrement * params.BeaconConfig().ChurnLimitQuotient), - expected: math.Gwei(2000 * params.BeaconConfig().EffectiveBalanceIncrement), + activeBalance: primitives.Gwei(2000 * params.BeaconConfig().EffectiveBalanceIncrement * params.BeaconConfig().ChurnLimitQuotient), + expected: primitives.Gwei(2000 * params.BeaconConfig().EffectiveBalanceIncrement), }, } @@ -42,18 +42,18 @@ func TestBalanceChurnLimit(t *testing.T) { func TestActivationExitChurnLimit(t *testing.T) { tests := []struct { name string - activeBalance math.Gwei - expected math.Gwei + activeBalance primitives.Gwei + expected primitives.Gwei }{ { name: "less than MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT", activeBalance: 1, - expected: math.Gwei(params.BeaconConfig().MinPerEpochChurnLimitElectra), + expected: primitives.Gwei(params.BeaconConfig().MinPerEpochChurnLimitElectra), }, { name: "more than MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT", - activeBalance: math.Gwei(2000 * params.BeaconConfig().EffectiveBalanceIncrement * params.BeaconConfig().ChurnLimitQuotient), - expected: math.Gwei(params.BeaconConfig().MaxPerEpochActivationExitChurnLimit), + activeBalance: primitives.Gwei(2000 * params.BeaconConfig().EffectiveBalanceIncrement * params.BeaconConfig().ChurnLimitQuotient), + expected: primitives.Gwei(params.BeaconConfig().MaxPerEpochActivationExitChurnLimit), }, } @@ -67,6 +67,6 @@ func TestActivationExitChurnLimit(t *testing.T) { // FuzzConsolidationChurnLimit exercises BalanceChurnLimit and ActivationExitChurnLimit func FuzzConsolidationChurnLimit(f *testing.F) { f.Fuzz(func(t *testing.T, activeBalance uint64) { - helpers.ConsolidationChurnLimit(math.Gwei(activeBalance)) + helpers.ConsolidationChurnLimit(primitives.Gwei(activeBalance)) }) } diff --git a/beacon-chain/core/validators/BUILD.bazel b/beacon-chain/core/validators/BUILD.bazel index 6096f2aea509..8c341f4c791d 100644 --- a/beacon-chain/core/validators/BUILD.bazel +++ b/beacon-chain/core/validators/BUILD.bazel @@ -40,7 +40,6 @@ go_test( "//beacon-chain/state/state-native:go_default_library", "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", - "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//runtime/version:go_default_library", "//testing/assert:go_default_library", diff --git a/beacon-chain/core/validators/validator.go b/beacon-chain/core/validators/validator.go index c7a2f61015c1..33f4c57b1ed3 100644 --- a/beacon-chain/core/validators/validator.go +++ b/beacon-chain/core/validators/validator.go @@ -103,7 +103,7 @@ func InitiateValidatorExit(ctx context.Context, s state.BeaconState, idx primiti // [Modified in Electra:EIP7251] // exit_queue_epoch = compute_exit_epoch_and_update_churn(state, validator.effective_balance) var err error - exitQueueEpoch, err = s.ExitEpochAndUpdateChurn(math.Gwei(validator.EffectiveBalance)) + exitQueueEpoch, err = s.ExitEpochAndUpdateChurn(primitives.Gwei(validator.EffectiveBalance)) if err != nil { return nil, 0, err } diff --git a/beacon-chain/core/validators/validator_test.go b/beacon-chain/core/validators/validator_test.go index e4220f7128a9..f68634541255 100644 --- a/beacon-chain/core/validators/validator_test.go +++ b/beacon-chain/core/validators/validator_test.go @@ -10,7 +10,6 @@ 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" - "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/testing/assert" @@ -146,7 +145,7 @@ func TestInitiateValidatorExit_ProperExit_Electra(t *testing.T) { // Pre-check: Exit balance to consume should be zero. ebtc, err := state.ExitBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(0), ebtc) + require.Equal(t, primitives.Gwei(0), ebtc) newState, epoch, err := validators.InitiateValidatorExit(context.Background(), state, idx, 0, 0) // exitQueueEpoch and churn are not used in electra require.NoError(t, err) @@ -161,7 +160,7 @@ func TestInitiateValidatorExit_ProperExit_Electra(t *testing.T) { // Check that the exit balance to consume has been updated on the state. ebtc, err = state.ExitBalanceToConsume() require.NoError(t, err) - require.NotEqual(t, math.Gwei(0), ebtc, "Exit balance to consume was not updated") + require.NotEqual(t, primitives.Gwei(0), ebtc, "Exit balance to consume was not updated") } func TestSlashValidator_OK(t *testing.T) { diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/construct_generic_block.go b/beacon-chain/rpc/prysm/v1alpha1/validator/construct_generic_block.go index 88e935e118f4..e90f3859dde6 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/construct_generic_block.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/construct_generic_block.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" - "github.com/prysmaticlabs/prysm/v5/math" + "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" "github.com/prysmaticlabs/prysm/v5/runtime/version" @@ -44,7 +44,7 @@ func (vs *Server) constructGenericBeaconBlock(sBlk interfaces.SignedBeaconBlock, } // Helper functions for constructing blocks for each version -func (vs *Server) constructElectraBlock(blockProto proto.Message, isBlinded bool, payloadValue math.Wei, bundle *enginev1.BlobsBundle) *ethpb.GenericBeaconBlock { +func (vs *Server) constructElectraBlock(blockProto proto.Message, isBlinded bool, payloadValue primitives.Wei, bundle *enginev1.BlobsBundle) *ethpb.GenericBeaconBlock { if isBlinded { return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_BlindedElectra{BlindedElectra: blockProto.(*ethpb.BlindedBeaconBlockElectra)}, IsBlinded: true, PayloadValue: (*payloadValue).String()} } @@ -56,7 +56,7 @@ func (vs *Server) constructElectraBlock(blockProto proto.Message, isBlinded bool return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Electra{Electra: electraContents}, IsBlinded: false, PayloadValue: (*payloadValue).String()} } -func (vs *Server) constructDenebBlock(blockProto proto.Message, isBlinded bool, payloadValue math.Wei, bundle *enginev1.BlobsBundle) *ethpb.GenericBeaconBlock { +func (vs *Server) constructDenebBlock(blockProto proto.Message, isBlinded bool, payloadValue primitives.Wei, bundle *enginev1.BlobsBundle) *ethpb.GenericBeaconBlock { if isBlinded { return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_BlindedDeneb{BlindedDeneb: blockProto.(*ethpb.BlindedBeaconBlockDeneb)}, IsBlinded: true, PayloadValue: (*payloadValue).String()} } @@ -68,14 +68,14 @@ func (vs *Server) constructDenebBlock(blockProto proto.Message, isBlinded bool, return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Deneb{Deneb: denebContents}, IsBlinded: false, PayloadValue: (*payloadValue).String()} } -func (vs *Server) constructCapellaBlock(pb proto.Message, isBlinded bool, payloadValue math.Wei) *ethpb.GenericBeaconBlock { +func (vs *Server) constructCapellaBlock(pb proto.Message, isBlinded bool, payloadValue primitives.Wei) *ethpb.GenericBeaconBlock { if isBlinded { return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_BlindedCapella{BlindedCapella: pb.(*ethpb.BlindedBeaconBlockCapella)}, IsBlinded: true, PayloadValue: (*payloadValue).String()} } return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Capella{Capella: pb.(*ethpb.BeaconBlockCapella)}, IsBlinded: false, PayloadValue: (*payloadValue).String()} } -func (vs *Server) constructBellatrixBlock(pb proto.Message, isBlinded bool, payloadValue math.Wei) *ethpb.GenericBeaconBlock { +func (vs *Server) constructBellatrixBlock(pb proto.Message, isBlinded bool, payloadValue primitives.Wei) *ethpb.GenericBeaconBlock { if isBlinded { return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_BlindedBellatrix{BlindedBellatrix: pb.(*ethpb.BlindedBeaconBlockBellatrix)}, IsBlinded: true, PayloadValue: (*payloadValue).String()} } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go index c7baa85b3fb8..907dbadf9132 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go @@ -18,7 +18,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v5/encoding/ssz" - "github.com/prysmaticlabs/prysm/v5/math" "github.com/prysmaticlabs/prysm/v5/monitoring/tracing" "github.com/prysmaticlabs/prysm/v5/network/forks" "github.com/prysmaticlabs/prysm/v5/runtime/version" @@ -243,7 +242,7 @@ func (vs *Server) getPayloadHeaderFromBuilder(ctx context.Context, slot primitiv } l := log.WithFields(logrus.Fields{ - "gweiValue": math.WeiToGwei(v), + "gweiValue": primitives.WeiToGwei(v), "builderPubKey": fmt.Sprintf("%#x", bid.Pubkey()), "blockHash": fmt.Sprintf("%#x", header.BlockHash()), "slot": slot, diff --git a/beacon-chain/state/BUILD.bazel b/beacon-chain/state/BUILD.bazel index 95af0712b819..fa1ee84cff41 100644 --- a/beacon-chain/state/BUILD.bazel +++ b/beacon-chain/state/BUILD.bazel @@ -13,7 +13,6 @@ go_library( "//config/fieldparams:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", - "//math:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", diff --git a/beacon-chain/state/interfaces.go b/beacon-chain/state/interfaces.go index 2b32602cad14..7a6a5e83d9af 100644 --- a/beacon-chain/state/interfaces.go +++ b/beacon-chain/state/interfaces.go @@ -11,7 +11,6 @@ import ( 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/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" ) @@ -182,7 +181,7 @@ type ReadOnlyEth1Data interface { // ReadOnlyExits defines a struct which only has read access to Exit related methods. type ReadOnlyExits interface { - ExitBalanceToConsume() (math.Gwei, error) + ExitBalanceToConsume() (primitives.Gwei, error) EarliestExitEpoch() (primitives.Epoch, error) } @@ -219,13 +218,13 @@ type ReadOnlySyncCommittee interface { } type ReadOnlyDeposits interface { - DepositBalanceToConsume() (math.Gwei, error) + DepositBalanceToConsume() (primitives.Gwei, error) DepositReceiptsStartIndex() (uint64, error) PendingBalanceDeposits() ([]*ethpb.PendingBalanceDeposit, error) } type ReadOnlyConsolidations interface { - ConsolidationBalanceToConsume() (math.Gwei, error) + ConsolidationBalanceToConsume() (primitives.Gwei, error) EarliestConsolidationEpoch() (primitives.Epoch, error) PendingConsolidations() ([]*ethpb.PendingConsolidation, error) NumPendingConsolidations() (uint64, error) @@ -249,7 +248,7 @@ type WriteOnlyEth1Data interface { SetEth1DataVotes(val []*ethpb.Eth1Data) error AppendEth1DataVotes(val *ethpb.Eth1Data) error SetEth1DepositIndex(val uint64) error - ExitEpochAndUpdateChurn(exitBalance math.Gwei) (primitives.Epoch, error) + ExitEpochAndUpdateChurn(exitBalance primitives.Gwei) (primitives.Epoch, error) } // WriteOnlyValidators defines a struct which only has write access to validators methods. @@ -321,7 +320,7 @@ type WriteOnlyWithdrawals interface { type WriteOnlyConsolidations interface { AppendPendingConsolidation(val *ethpb.PendingConsolidation) error - SetConsolidationBalanceToConsume(math.Gwei) error + SetConsolidationBalanceToConsume(primitives.Gwei) error SetEarliestConsolidationEpoch(epoch primitives.Epoch) error SetPendingConsolidations(val []*ethpb.PendingConsolidation) error } @@ -330,5 +329,5 @@ type WriteOnlyDeposits interface { AppendPendingBalanceDeposit(index primitives.ValidatorIndex, amount uint64) error SetDepositReceiptsStartIndex(index uint64) error SetPendingBalanceDeposits(val []*ethpb.PendingBalanceDeposit) error - SetDepositBalanceToConsume(math.Gwei) error + SetDepositBalanceToConsume(primitives.Gwei) error } diff --git a/beacon-chain/state/state-native/BUILD.bazel b/beacon-chain/state/state-native/BUILD.bazel index 3f8760c2a411..91dd62d471a0 100644 --- a/beacon-chain/state/state-native/BUILD.bazel +++ b/beacon-chain/state/state-native/BUILD.bazel @@ -143,7 +143,6 @@ go_test( "//container/trie:go_default_library", "//crypto/rand:go_default_library", "//encoding/bytesutil:go_default_library", - "//math:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//runtime/interop:go_default_library", diff --git a/beacon-chain/state/state-native/beacon_state_mainnet.go b/beacon-chain/state/state-native/beacon_state_mainnet.go index 4ceb16a65518..8cdcda554e6a 100644 --- a/beacon-chain/state/state-native/beacon_state_mainnet.go +++ b/beacon-chain/state/state-native/beacon_state_mainnet.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/stateutil" "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" ) @@ -64,10 +63,10 @@ type BeaconState struct { // Electra fields depositReceiptsStartIndex uint64 - depositBalanceToConsume math.Gwei - exitBalanceToConsume math.Gwei + depositBalanceToConsume primitives.Gwei + exitBalanceToConsume primitives.Gwei earliestExitEpoch primitives.Epoch - consolidationBalanceToConsume math.Gwei + consolidationBalanceToConsume primitives.Gwei earliestConsolidationEpoch primitives.Epoch pendingBalanceDeposits []*ethpb.PendingBalanceDeposit // pending_balance_deposits: List[PendingBalanceDeposit, PENDING_BALANCE_DEPOSITS_LIMIT] pendingPartialWithdrawals []*ethpb.PendingPartialWithdrawal // pending_partial_withdrawals: List[PartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT] @@ -121,10 +120,10 @@ type beaconStateMarshalable struct { NextWithdrawalIndex uint64 `json:"next_withdrawal_index" yaml:"next_withdrawal_index"` NextWithdrawalValidatorIndex primitives.ValidatorIndex `json:"next_withdrawal_validator_index" yaml:"next_withdrawal_validator_index"` DepositReceiptsStartIndex uint64 `json:"deposit_receipts_start_index" yaml:"deposit_receipts_start_index"` - DepositBalanceToConsume math.Gwei `json:"deposit_balance_to_consume" yaml:"deposit_balance_to_consume"` - ExitBalanceToConsume math.Gwei `json:"exit_balance_to_consume" yaml:"exit_balance_to_consume"` + DepositBalanceToConsume primitives.Gwei `json:"deposit_balance_to_consume" yaml:"deposit_balance_to_consume"` + ExitBalanceToConsume primitives.Gwei `json:"exit_balance_to_consume" yaml:"exit_balance_to_consume"` EarliestExitEpoch primitives.Epoch `json:"earliest_exit_epoch" yaml:"earliest_exit_epoch"` - ConsolidationBalanceToConsume math.Gwei `json:"consolidation_balance_to_consume" yaml:"consolidation_balance_to_consume"` + ConsolidationBalanceToConsume primitives.Gwei `json:"consolidation_balance_to_consume" yaml:"consolidation_balance_to_consume"` EarliestConsolidationEpoch primitives.Epoch `json:"earliest_consolidation_epoch" yaml:"earliest_consolidation_epoch"` PendingBalanceDeposits []*ethpb.PendingBalanceDeposit `json:"pending_balance_deposits" yaml:"pending_balance_deposits"` PendingPartialWithdrawals []*ethpb.PendingPartialWithdrawal `json:"pending_partial_withdrawals" yaml:"pending_partial_withdrawals"` diff --git a/beacon-chain/state/state-native/beacon_state_minimal.go b/beacon-chain/state/state-native/beacon_state_minimal.go index 1a5631f9cc1f..886634a90832 100644 --- a/beacon-chain/state/state-native/beacon_state_minimal.go +++ b/beacon-chain/state/state-native/beacon_state_minimal.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/stateutil" "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" ) @@ -64,10 +63,10 @@ type BeaconState struct { // Electra fields depositReceiptsStartIndex uint64 - depositBalanceToConsume math.Gwei - exitBalanceToConsume math.Gwei + depositBalanceToConsume primitives.Gwei + exitBalanceToConsume primitives.Gwei earliestExitEpoch primitives.Epoch - consolidationBalanceToConsume math.Gwei + consolidationBalanceToConsume primitives.Gwei earliestConsolidationEpoch primitives.Epoch pendingBalanceDeposits []*ethpb.PendingBalanceDeposit // pending_balance_deposits: List[PendingBalanceDeposit, PENDING_BALANCE_DEPOSITS_LIMIT] pendingPartialWithdrawals []*ethpb.PendingPartialWithdrawal // pending_partial_withdrawals: List[PartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT] @@ -121,10 +120,10 @@ type beaconStateMarshalable struct { NextWithdrawalIndex uint64 `json:"next_withdrawal_index" yaml:"next_withdrawal_index"` NextWithdrawalValidatorIndex primitives.ValidatorIndex `json:"next_withdrawal_validator_index" yaml:"next_withdrawal_validator_index"` DepositReceiptsStartIndex uint64 `json:"deposit_receipts_start_index" yaml:"deposit_receipts_start_index"` - DepositBalanceToConsume math.Gwei `json:"deposit_balance_to_consume" yaml:"deposit_balance_to_consume"` - ExitBalanceToConsume math.Gwei `json:"exit_balance_to_consume" yaml:"exit_balance_to_consume"` + DepositBalanceToConsume primitives.Gwei `json:"deposit_balance_to_consume" yaml:"deposit_balance_to_consume"` + ExitBalanceToConsume primitives.Gwei `json:"exit_balance_to_consume" yaml:"exit_balance_to_consume"` EarliestExitEpoch primitives.Epoch `json:"earliest_exit_epoch" yaml:"earliest_exit_epoch"` - ConsolidationBalanceToConsume math.Gwei `json:"consolidation_balance_to_consume" yaml:"consolidation_balance_to_consume"` + ConsolidationBalanceToConsume primitives.Gwei `json:"consolidation_balance_to_consume" yaml:"consolidation_balance_to_consume"` EarliestConsolidationEpoch primitives.Epoch `json:"earliest_consolidation_epoch" yaml:"earliest_consolidation_epoch"` PendingBalanceDeposits []*ethpb.PendingBalanceDeposit `json:"pending_balance_deposits" yaml:"pending_balance_deposits"` PendingPartialWithdrawals []*ethpb.PendingPartialWithdrawal `json:"pending_partial_withdrawals" yaml:"pending_partial_withdrawals"` diff --git a/beacon-chain/state/state-native/getters_balance_deposits.go b/beacon-chain/state/state-native/getters_balance_deposits.go index 900a5ece2101..e7257dd0c270 100644 --- a/beacon-chain/state/state-native/getters_balance_deposits.go +++ b/beacon-chain/state/state-native/getters_balance_deposits.go @@ -1,7 +1,7 @@ package state_native import ( - "github.com/prysmaticlabs/prysm/v5/math" + "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/runtime/version" ) @@ -9,7 +9,7 @@ import ( // DepositBalanceToConsume is a non-mutating call to the beacon state which returns the value of the // deposit balance to consume field. This method requires access to the RLock on the state and only // applies in electra or later. -func (b *BeaconState) DepositBalanceToConsume() (math.Gwei, error) { +func (b *BeaconState) DepositBalanceToConsume() (primitives.Gwei, error) { if b.version < version.Electra { return 0, errNotSupported("DepositBalanceToConsume", b.version) } diff --git a/beacon-chain/state/state-native/getters_balance_deposits_test.go b/beacon-chain/state/state-native/getters_balance_deposits_test.go index 358681e52bad..ab1738e0b754 100644 --- a/beacon-chain/state/state-native/getters_balance_deposits_test.go +++ b/beacon-chain/state/state-native/getters_balance_deposits_test.go @@ -5,7 +5,6 @@ import ( state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" ) @@ -17,7 +16,7 @@ func TestDepositBalanceToConsume(t *testing.T) { require.NoError(t, err) dbtc, err := s.DepositBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(44), dbtc) + require.Equal(t, primitives.Gwei(44), dbtc) // Fails for older than electra state s, err = state_native.InitializeFromProtoDeneb(ð.BeaconStateDeneb{}) diff --git a/beacon-chain/state/state-native/getters_consolidation.go b/beacon-chain/state/state-native/getters_consolidation.go index 017dde5112a4..0ec07328f5a0 100644 --- a/beacon-chain/state/state-native/getters_consolidation.go +++ b/beacon-chain/state/state-native/getters_consolidation.go @@ -2,7 +2,6 @@ package state_native import ( "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" ) @@ -22,7 +21,7 @@ func (b *BeaconState) EarliestConsolidationEpoch() (primitives.Epoch, error) { // ConsolidationBalanceToConsume is a non-mutating call to the beacon state which returns the value // of the consolidation balance to consume field. This method requires access to the RLock on the // state and only applies in electra or later. -func (b *BeaconState) ConsolidationBalanceToConsume() (math.Gwei, error) { +func (b *BeaconState) ConsolidationBalanceToConsume() (primitives.Gwei, error) { if b.version < version.Electra { return 0, errNotSupported("ConsolidationBalanceToConsume", b.version) } diff --git a/beacon-chain/state/state-native/getters_consolidation_test.go b/beacon-chain/state/state-native/getters_consolidation_test.go index 6a4ec384a24b..a2e768642278 100644 --- a/beacon-chain/state/state-native/getters_consolidation_test.go +++ b/beacon-chain/state/state-native/getters_consolidation_test.go @@ -5,7 +5,6 @@ import ( state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" "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/testing/require" ) @@ -32,7 +31,7 @@ func TestEarliestConsolidationEpoch(t *testing.T) { func TestConsolidationBalanceToConsume(t *testing.T) { t.Run("electra returns expected value", func(t *testing.T) { - want := math.Gwei(10) + want := primitives.Gwei(10) st, err := state_native.InitializeFromProtoElectra(ðpb.BeaconStateElectra{ ConsolidationBalanceToConsume: want, }) diff --git a/beacon-chain/state/state-native/getters_exit.go b/beacon-chain/state/state-native/getters_exit.go index 12be6844e05c..c43ba8756b33 100644 --- a/beacon-chain/state/state-native/getters_exit.go +++ b/beacon-chain/state/state-native/getters_exit.go @@ -2,12 +2,11 @@ package state_native import ( "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" "github.com/prysmaticlabs/prysm/v5/runtime/version" ) // ExitBalanceToConsume is used for returning the ExitBalanceToConsume as part of eip 7251 -func (b *BeaconState) ExitBalanceToConsume() (math.Gwei, error) { +func (b *BeaconState) ExitBalanceToConsume() (primitives.Gwei, error) { if b.version < version.Electra { return 0, errNotSupported("ExitBalanceToConsume", b.version) } diff --git a/beacon-chain/state/state-native/getters_exit_test.go b/beacon-chain/state/state-native/getters_exit_test.go index 1e3287cd191d..cc3a0e479dcb 100644 --- a/beacon-chain/state/state-native/getters_exit_test.go +++ b/beacon-chain/state/state-native/getters_exit_test.go @@ -5,7 +5,6 @@ import ( state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" "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/testing/require" "github.com/prysmaticlabs/prysm/v5/testing/util" @@ -18,7 +17,7 @@ func TestExitBalanceToConsume(t *testing.T) { require.ErrorContains(t, "is not supported", err) }) t.Run("electra returns expected value", func(t *testing.T) { - want := math.Gwei(2) + want := primitives.Gwei(2) dState, err := state_native.InitializeFromProtoElectra(ðpb.BeaconStateElectra{ExitBalanceToConsume: want}) require.NoError(t, err) got, err := dState.ExitBalanceToConsume() diff --git a/beacon-chain/state/state-native/setters_balance_deposits.go b/beacon-chain/state/state-native/setters_balance_deposits.go index 9bb398b13e15..1be44219bc5a 100644 --- a/beacon-chain/state/state-native/setters_balance_deposits.go +++ b/beacon-chain/state/state-native/setters_balance_deposits.go @@ -4,7 +4,6 @@ import ( "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/primitives" - "github.com/prysmaticlabs/prysm/v5/math" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/runtime/version" ) @@ -52,7 +51,7 @@ func (b *BeaconState) SetPendingBalanceDeposits(val []*ethpb.PendingBalanceDepos // SetDepositBalanceToConsume is a mutating call to the beacon state which sets the deposit balance // to consume value to the given value. This method requires access to the Lock on the state and // only applies in electra or later. -func (b *BeaconState) SetDepositBalanceToConsume(dbtc math.Gwei) error { +func (b *BeaconState) SetDepositBalanceToConsume(dbtc primitives.Gwei) error { if b.version < version.Electra { return errNotSupported("SetDepositBalanceToConsume", b.version) } diff --git a/beacon-chain/state/state-native/setters_balance_deposits_test.go b/beacon-chain/state/state-native/setters_balance_deposits_test.go index 7c2b201230a3..594943b712a9 100644 --- a/beacon-chain/state/state-native/setters_balance_deposits_test.go +++ b/beacon-chain/state/state-native/setters_balance_deposits_test.go @@ -5,7 +5,6 @@ import ( state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" ) @@ -52,7 +51,7 @@ func TestSetDepositBalanceToConsume(t *testing.T) { require.NoError(t, s.SetDepositBalanceToConsume(10)) dbtc, err := s.DepositBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(10), dbtc) + require.Equal(t, primitives.Gwei(10), dbtc) // Fails for versions older than electra s, err = state_native.InitializeFromProtoDeneb(ð.BeaconStateDeneb{}) diff --git a/beacon-chain/state/state-native/setters_churn.go b/beacon-chain/state/state-native/setters_churn.go index bf7e67602a01..fdcf547fdcd1 100644 --- a/beacon-chain/state/state-native/setters_churn.go +++ b/beacon-chain/state/state-native/setters_churn.go @@ -4,7 +4,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native/types" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" "github.com/prysmaticlabs/prysm/v5/runtime/version" "github.com/prysmaticlabs/prysm/v5/time/slots" ) @@ -34,7 +33,7 @@ import ( // state.earliest_exit_epoch = earliest_exit_epoch // // return state.earliest_exit_epoch -func (b *BeaconState) ExitEpochAndUpdateChurn(exitBalance math.Gwei) (primitives.Epoch, error) { +func (b *BeaconState) ExitEpochAndUpdateChurn(exitBalance primitives.Gwei) (primitives.Epoch, error) { if b.version < version.Electra { return 0, errNotSupported("ExitEpochAndUpdateChurn", b.version) } @@ -49,10 +48,10 @@ func (b *BeaconState) ExitEpochAndUpdateChurn(exitBalance math.Gwei) (primitives defer b.lock.Unlock() earliestExitEpoch := max(b.earliestExitEpoch, helpers.ActivationExitEpoch(slots.ToEpoch(b.slot))) - perEpochChurn := helpers.ActivationExitChurnLimit(math.Gwei(activeBal)) // Guaranteed to be non-zero. + perEpochChurn := helpers.ActivationExitChurnLimit(primitives.Gwei(activeBal)) // Guaranteed to be non-zero. // New epoch for exits - var exitBalanceToConsume math.Gwei + var exitBalanceToConsume primitives.Gwei if b.earliestExitEpoch < earliestExitEpoch { exitBalanceToConsume = perEpochChurn } else { @@ -64,7 +63,7 @@ func (b *BeaconState) ExitEpochAndUpdateChurn(exitBalance math.Gwei) (primitives balanceToProcess := exitBalance - exitBalanceToConsume additionalEpochs := primitives.Epoch((balanceToProcess-1)/perEpochChurn + 1) earliestExitEpoch += additionalEpochs - exitBalanceToConsume += math.Gwei(additionalEpochs) * perEpochChurn + exitBalanceToConsume += primitives.Gwei(additionalEpochs) * perEpochChurn } // Consume the balance and update state variables. diff --git a/beacon-chain/state/state-native/setters_churn_test.go b/beacon-chain/state/state-native/setters_churn_test.go index 2aa98382c473..397932023d3b 100644 --- a/beacon-chain/state/state-native/setters_churn_test.go +++ b/beacon-chain/state/state-native/setters_churn_test.go @@ -8,7 +8,6 @@ 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" - "github.com/prysmaticlabs/prysm/v5/math" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/testing/util" @@ -30,7 +29,7 @@ func TestExitEpochAndUpdateChurn_SpectestCase(t *testing.T) { val, err := s.ValidatorAtIndex(0) require.NoError(t, err) - ee, err := s.ExitEpochAndUpdateChurn(math.Gwei(val.EffectiveBalance)) + ee, err := s.ExitEpochAndUpdateChurn(primitives.Gwei(val.EffectiveBalance)) require.NoError(t, err) require.Equal(t, primitives.Epoch(262), ee) @@ -39,7 +38,7 @@ func TestExitEpochAndUpdateChurn_SpectestCase(t *testing.T) { if !ok { t.Fatal("wrong proto") } - require.Equal(t, math.Gwei(127000000000), pb.ExitBalanceToConsume) + require.Equal(t, primitives.Gwei(127000000000), pb.ExitBalanceToConsume) require.Equal(t, primitives.Epoch(262), pb.EarliestExitEpoch) // Fails for versions older than electra @@ -62,15 +61,15 @@ func TestExitEpochAndUpdateChurn(t *testing.T) { }, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalanceElectra}, EarliestExitEpoch: epoch - params.BeaconConfig().MaxSeedLookahead*2, // Old, relative to slot. - ExitBalanceToConsume: math.Gwei(20_000_000), + ExitBalanceToConsume: primitives.Gwei(20_000_000), }) require.NoError(t, err) activeBal, err := helpers.TotalActiveBalance(st) require.NoError(t, err) - exitBal := math.Gwei(10_000_000) + exitBal := primitives.Gwei(10_000_000) - wantExitBalToConsume := helpers.ActivationExitChurnLimit(math.Gwei(activeBal)) - exitBal + wantExitBalToConsume := helpers.ActivationExitChurnLimit(primitives.Gwei(activeBal)) - exitBal ee, err := st.ExitEpochAndUpdateChurn(exitBal) require.NoError(t, err) @@ -97,16 +96,16 @@ func TestExitEpochAndUpdateChurn(t *testing.T) { }, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalanceElectra}, EarliestExitEpoch: epoch, - ExitBalanceToConsume: math.Gwei(20_000_000), + ExitBalanceToConsume: primitives.Gwei(20_000_000), }) require.NoError(t, err) activeBal, err := helpers.TotalActiveBalance(st) require.NoError(t, err) - activationExitChurnLimit := helpers.ActivationExitChurnLimit(math.Gwei(activeBal)) + activationExitChurnLimit := helpers.ActivationExitChurnLimit(primitives.Gwei(activeBal)) exitBal := activationExitChurnLimit * 2 - wantExitBalToConsume := math.Gwei(0) + wantExitBalToConsume := primitives.Gwei(0) ee, err := st.ExitEpochAndUpdateChurn(exitBal) require.NoError(t, err) @@ -133,13 +132,13 @@ func TestExitEpochAndUpdateChurn(t *testing.T) { }, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalanceElectra}, EarliestExitEpoch: epoch + 10_000, - ExitBalanceToConsume: math.Gwei(20_000_000), + ExitBalanceToConsume: primitives.Gwei(20_000_000), }) require.NoError(t, err) - exitBal := math.Gwei(10_000_000) + exitBal := primitives.Gwei(10_000_000) - wantExitBalToConsume := math.Gwei(20_000_000) - exitBal + wantExitBalToConsume := primitives.Gwei(20_000_000) - exitBal ee, err := st.ExitEpochAndUpdateChurn(exitBal) require.NoError(t, err) @@ -166,14 +165,14 @@ func TestExitEpochAndUpdateChurn(t *testing.T) { }, Balances: []uint64{params.BeaconConfig().MaxEffectiveBalanceElectra}, EarliestExitEpoch: epoch + 10_000, - ExitBalanceToConsume: math.Gwei(20_000_000), + ExitBalanceToConsume: primitives.Gwei(20_000_000), }) require.NoError(t, err) - exitBal := math.Gwei(40_000_000) + exitBal := primitives.Gwei(40_000_000) activeBal, err := helpers.TotalActiveBalance(st) require.NoError(t, err) - activationExitChurnLimit := helpers.ActivationExitChurnLimit(math.Gwei(activeBal)) + activationExitChurnLimit := helpers.ActivationExitChurnLimit(primitives.Gwei(activeBal)) wantExitBalToConsume := activationExitChurnLimit - 20_000_000 ee, err := st.ExitEpochAndUpdateChurn(exitBal) diff --git a/beacon-chain/state/state-native/setters_consolidation.go b/beacon-chain/state/state-native/setters_consolidation.go index c76e1ae5c091..525230578f0a 100644 --- a/beacon-chain/state/state-native/setters_consolidation.go +++ b/beacon-chain/state/state-native/setters_consolidation.go @@ -4,7 +4,6 @@ import ( "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/primitives" - "github.com/prysmaticlabs/prysm/v5/math" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/runtime/version" ) @@ -69,7 +68,7 @@ func (b *BeaconState) SetEarliestConsolidationEpoch(epoch primitives.Epoch) erro // SetConsolidationBalanceToConsume is a mutating call to the beacon state which sets the value of // the consolidation balance to consume to the provided value. This method requires access to the // Lock on the state and only applies in electra or later. -func (b *BeaconState) SetConsolidationBalanceToConsume(balance math.Gwei) error { +func (b *BeaconState) SetConsolidationBalanceToConsume(balance primitives.Gwei) error { if b.version < version.Electra { return errNotSupported("SetConsolidationBalanceToConsume", b.version) } diff --git a/beacon-chain/state/state-native/setters_consolidation_test.go b/beacon-chain/state/state-native/setters_consolidation_test.go index 1a2ee153cef4..af8ced0ea22b 100644 --- a/beacon-chain/state/state-native/setters_consolidation_test.go +++ b/beacon-chain/state/state-native/setters_consolidation_test.go @@ -5,7 +5,6 @@ import ( state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" ) @@ -67,7 +66,7 @@ func TestSetConsolidationBalanceToConsume(t *testing.T) { require.NoError(t, s.SetConsolidationBalanceToConsume(10)) cbtc, err := s.ConsolidationBalanceToConsume() require.NoError(t, err) - require.Equal(t, math.Gwei(10), cbtc) + require.Equal(t, primitives.Gwei(10), cbtc) // Fails for versions older than electra s, err = state_native.InitializeFromProtoDeneb(ð.BeaconStateDeneb{}) diff --git a/consensus-types/blocks/BUILD.bazel b/consensus-types/blocks/BUILD.bazel index feda65d199ba..d56c464ac30e 100644 --- a/consensus-types/blocks/BUILD.bazel +++ b/consensus-types/blocks/BUILD.bazel @@ -24,7 +24,6 @@ go_library( "//container/trie:go_default_library", "//encoding/bytesutil:go_default_library", "//encoding/ssz:go_default_library", - "//math:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", diff --git a/consensus-types/blocks/execution.go b/consensus-types/blocks/execution.go index 08cc5aeabf6d..13e3905e698b 100644 --- a/consensus-types/blocks/execution.go +++ b/consensus-types/blocks/execution.go @@ -9,9 +9,9 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" 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/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v5/encoding/ssz" - "github.com/prysmaticlabs/prysm/v5/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" "google.golang.org/protobuf/proto" ) @@ -24,7 +24,7 @@ type executionPayload struct { } // NewWrappedExecutionData creates an appropriate execution payload wrapper based on the incoming type. -func NewWrappedExecutionData(v proto.Message, weiValue math.Wei) (interfaces.ExecutionData, error) { +func NewWrappedExecutionData(v proto.Message, weiValue primitives.Wei) (interfaces.ExecutionData, error) { if weiValue == nil { weiValue = new(big.Int).SetInt64(0) } @@ -194,7 +194,7 @@ func (e executionPayload) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (executionPayload) ValueInWei() (math.Wei, error) { +func (executionPayload) ValueInWei() (primitives.Wei, error) { return nil, consensus_types.ErrUnsupportedField } @@ -362,7 +362,7 @@ func (e executionPayloadHeader) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (executionPayloadHeader) ValueInWei() (math.Wei, error) { +func (executionPayloadHeader) ValueInWei() (primitives.Wei, error) { return nil, consensus_types.ErrUnsupportedField } @@ -404,15 +404,15 @@ func PayloadToHeader(payload interfaces.ExecutionData) (*enginev1.ExecutionPaylo // blocks for future forks can also be applied across Prysm without issues. type executionPayloadCapella struct { p *enginev1.ExecutionPayloadCapella - weiValue math.Wei + weiValue primitives.Wei gweiValue uint64 } var _ interfaces.ExecutionData = &executionPayloadCapella{} // WrappedExecutionPayloadCapella is a constructor which wraps a protobuf execution payload into an interface. -func WrappedExecutionPayloadCapella(p *enginev1.ExecutionPayloadCapella, value math.Wei) (interfaces.ExecutionData, error) { - w := executionPayloadCapella{p: p, weiValue: value, gweiValue: uint64(math.WeiToGwei(value))} +func WrappedExecutionPayloadCapella(p *enginev1.ExecutionPayloadCapella, value primitives.Wei) (interfaces.ExecutionData, error) { + w := executionPayloadCapella{p: p, weiValue: value, gweiValue: uint64(primitives.WeiToGwei(value))} if w.IsNil() { return nil, consensus_types.ErrNilObjectWrapped } @@ -560,7 +560,7 @@ func (e executionPayloadCapella) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (e executionPayloadCapella) ValueInWei() (math.Wei, error) { +func (e executionPayloadCapella) ValueInWei() (primitives.Wei, error) { return e.weiValue, nil } @@ -574,15 +574,15 @@ func (e executionPayloadCapella) ValueInGwei() (uint64, error) { // blocks for future forks can also be applied across Prysm without issues. type executionPayloadHeaderCapella struct { p *enginev1.ExecutionPayloadHeaderCapella - weiValue math.Wei + weiValue primitives.Wei gweiValue uint64 } var _ interfaces.ExecutionData = &executionPayloadHeaderCapella{} // WrappedExecutionPayloadHeaderCapella is a constructor which wraps a protobuf execution header into an interface. -func WrappedExecutionPayloadHeaderCapella(p *enginev1.ExecutionPayloadHeaderCapella, value math.Wei) (interfaces.ExecutionData, error) { - w := executionPayloadHeaderCapella{p: p, weiValue: value, gweiValue: uint64(math.WeiToGwei(value))} +func WrappedExecutionPayloadHeaderCapella(p *enginev1.ExecutionPayloadHeaderCapella, value primitives.Wei) (interfaces.ExecutionData, error) { + w := executionPayloadHeaderCapella{p: p, weiValue: value, gweiValue: uint64(primitives.WeiToGwei(value))} if w.IsNil() { return nil, consensus_types.ErrNilObjectWrapped } @@ -730,7 +730,7 @@ func (e executionPayloadHeaderCapella) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (e executionPayloadHeaderCapella) ValueInWei() (math.Wei, error) { +func (e executionPayloadHeaderCapella) ValueInWei() (primitives.Wei, error) { return e.weiValue, nil } @@ -966,15 +966,15 @@ func IsEmptyExecutionData(data interfaces.ExecutionData) (bool, error) { // blocks for future forks can also be applied across Prysm without issues. type executionPayloadHeaderDeneb struct { p *enginev1.ExecutionPayloadHeaderDeneb - weiValue math.Wei + weiValue primitives.Wei gweiValue uint64 } var _ interfaces.ExecutionData = &executionPayloadHeaderDeneb{} // WrappedExecutionPayloadHeaderDeneb is a constructor which wraps a protobuf execution header into an interface. -func WrappedExecutionPayloadHeaderDeneb(p *enginev1.ExecutionPayloadHeaderDeneb, value math.Wei) (interfaces.ExecutionData, error) { - w := executionPayloadHeaderDeneb{p: p, weiValue: value, gweiValue: uint64(math.WeiToGwei(value))} +func WrappedExecutionPayloadHeaderDeneb(p *enginev1.ExecutionPayloadHeaderDeneb, value primitives.Wei) (interfaces.ExecutionData, error) { + w := executionPayloadHeaderDeneb{p: p, weiValue: value, gweiValue: uint64(primitives.WeiToGwei(value))} if w.IsNil() { return nil, consensus_types.ErrNilObjectWrapped } @@ -1117,7 +1117,7 @@ func (e executionPayloadHeaderDeneb) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (e executionPayloadHeaderDeneb) ValueInWei() (math.Wei, error) { +func (e executionPayloadHeaderDeneb) ValueInWei() (primitives.Wei, error) { return e.weiValue, nil } @@ -1136,15 +1136,15 @@ func (e executionPayloadHeaderDeneb) IsBlinded() bool { // blocks for future forks can also be applied across Prysm without issues. type executionPayloadDeneb struct { p *enginev1.ExecutionPayloadDeneb - weiValue math.Wei + weiValue primitives.Wei gweiValue uint64 } var _ interfaces.ExecutionData = &executionPayloadDeneb{} // WrappedExecutionPayloadDeneb is a constructor which wraps a protobuf execution payload into an interface. -func WrappedExecutionPayloadDeneb(p *enginev1.ExecutionPayloadDeneb, value math.Wei) (interfaces.ExecutionData, error) { - w := executionPayloadDeneb{p: p, weiValue: value, gweiValue: uint64(math.WeiToGwei(value))} +func WrappedExecutionPayloadDeneb(p *enginev1.ExecutionPayloadDeneb, value primitives.Wei) (interfaces.ExecutionData, error) { + w := executionPayloadDeneb{p: p, weiValue: value, gweiValue: uint64(primitives.WeiToGwei(value))} if w.IsNil() { return nil, consensus_types.ErrNilObjectWrapped } @@ -1285,7 +1285,7 @@ func (e executionPayloadDeneb) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (e executionPayloadDeneb) ValueInWei() (math.Wei, error) { +func (e executionPayloadDeneb) ValueInWei() (primitives.Wei, error) { return e.weiValue, nil } @@ -1304,7 +1304,7 @@ func (e executionPayloadDeneb) IsBlinded() bool { // blocks for future forks can also be applied across Prysm without issues. type executionPayloadHeaderElectra struct { p *enginev1.ExecutionPayloadHeaderElectra - weiValue math.Wei + weiValue primitives.Wei gweiValue uint64 } @@ -1312,8 +1312,8 @@ var _ interfaces.ExecutionData = &executionPayloadElectra{} var _ interfaces.ExecutionDataElectra = &executionPayloadElectra{} // WrappedExecutionPayloadHeaderElectra is a constructor which wraps a protobuf execution header into an interface. -func WrappedExecutionPayloadHeaderElectra(p *enginev1.ExecutionPayloadHeaderElectra, value math.Wei) (interfaces.ExecutionData, error) { - w := executionPayloadHeaderElectra{p: p, weiValue: value, gweiValue: uint64(math.WeiToGwei(value))} +func WrappedExecutionPayloadHeaderElectra(p *enginev1.ExecutionPayloadHeaderElectra, value primitives.Wei) (interfaces.ExecutionData, error) { + w := executionPayloadHeaderElectra{p: p, weiValue: value, gweiValue: uint64(primitives.WeiToGwei(value))} if w.IsNil() { return nil, consensus_types.ErrNilObjectWrapped } @@ -1456,7 +1456,7 @@ func (e executionPayloadHeaderElectra) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (e executionPayloadHeaderElectra) ValueInWei() (math.Wei, error) { +func (e executionPayloadHeaderElectra) ValueInWei() (primitives.Wei, error) { return e.weiValue, nil } @@ -1485,13 +1485,13 @@ func (e executionPayloadHeaderElectra) IsBlinded() bool { // blocks for future forks can also be applied across Prysm without issues. type executionPayloadElectra struct { p *enginev1.ExecutionPayloadElectra - weiValue math.Wei + weiValue primitives.Wei gweiValue uint64 } // WrappedExecutionPayloadElectra is a constructor which wraps a protobuf execution payload into an interface. -func WrappedExecutionPayloadElectra(p *enginev1.ExecutionPayloadElectra, value math.Wei) (interfaces.ExecutionData, error) { - w := executionPayloadElectra{p: p, weiValue: value, gweiValue: uint64(math.WeiToGwei(value))} +func WrappedExecutionPayloadElectra(p *enginev1.ExecutionPayloadElectra, value primitives.Wei) (interfaces.ExecutionData, error) { + w := executionPayloadElectra{p: p, weiValue: value, gweiValue: uint64(primitives.WeiToGwei(value))} if w.IsNil() { return nil, consensus_types.ErrNilObjectWrapped } @@ -1635,7 +1635,7 @@ func (e executionPayloadElectra) ExcessBlobGas() (uint64, error) { } // ValueInWei -- -func (e executionPayloadElectra) ValueInWei() (math.Wei, error) { +func (e executionPayloadElectra) ValueInWei() (primitives.Wei, error) { return e.weiValue, nil } @@ -1660,14 +1660,14 @@ func (e executionPayloadElectra) IsBlinded() bool { } // PayloadValueToWei returns a Wei value given the payload's value -func PayloadValueToWei(value []byte) math.Wei { +func PayloadValueToWei(value []byte) primitives.Wei { // We have to convert big endian to little endian because the value is coming from the execution layer. return big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(value)) } // PayloadValueToGwei returns a Gwei value given the payload's value -func PayloadValueToGwei(value []byte) math.Gwei { +func PayloadValueToGwei(value []byte) primitives.Gwei { // We have to convert big endian to little endian because the value is coming from the execution layer. v := big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(value)) - return math.WeiToGwei(v) + return primitives.WeiToGwei(v) } diff --git a/consensus-types/blocks/getters.go b/consensus-types/blocks/getters.go index 369f972d42ab..1c42187bd727 100644 --- a/consensus-types/blocks/getters.go +++ b/consensus-types/blocks/getters.go @@ -10,7 +10,6 @@ import ( 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/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/validator-client" @@ -329,7 +328,7 @@ func (b *SignedBeaconBlock) IsBlinded() bool { } // ValueInWei metadata on the payload value returned by the builder. -func (b *SignedBeaconBlock) ValueInWei() math.Wei { +func (b *SignedBeaconBlock) ValueInWei() primitives.Wei { exec, err := b.block.body.Execution() if err != nil { if !errors.Is(err, consensus_types.ErrUnsupportedField) { diff --git a/consensus-types/interfaces/BUILD.bazel b/consensus-types/interfaces/BUILD.bazel index 84e8be9f0d4b..3a20551c7d68 100644 --- a/consensus-types/interfaces/BUILD.bazel +++ b/consensus-types/interfaces/BUILD.bazel @@ -14,7 +14,6 @@ go_library( deps = [ "//config/fieldparams:go_default_library", "//consensus-types/primitives:go_default_library", - "//math:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", diff --git a/consensus-types/interfaces/beacon_block.go b/consensus-types/interfaces/beacon_block.go index 3eae02c6956f..a852c683e0b6 100644 --- a/consensus-types/interfaces/beacon_block.go +++ b/consensus-types/interfaces/beacon_block.go @@ -6,7 +6,6 @@ import ( "github.com/prysmaticlabs/go-bitfield" field_params "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/validator-client" @@ -29,7 +28,7 @@ type ReadOnlySignedBeaconBlock interface { ssz.Unmarshaler Version() int IsBlinded() bool - ValueInWei() math.Wei + ValueInWei() primitives.Wei ValueInGwei() uint64 Header() (*ethpb.SignedBeaconBlockHeader, error) } @@ -130,7 +129,7 @@ type ExecutionData interface { TransactionsRoot() ([]byte, error) Withdrawals() ([]*enginev1.Withdrawal, error) WithdrawalsRoot() ([]byte, error) - ValueInWei() (math.Wei, error) + ValueInWei() (primitives.Wei, error) ValueInGwei() (uint64, error) } diff --git a/consensus-types/mock/BUILD.bazel b/consensus-types/mock/BUILD.bazel index a76b14edad33..b37f4f30d51d 100644 --- a/consensus-types/mock/BUILD.bazel +++ b/consensus-types/mock/BUILD.bazel @@ -9,7 +9,6 @@ go_library( "//config/fieldparams: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", "//proto/prysm/v1alpha1/validator-client:go_default_library", "@com_github_prysmaticlabs_fastssz//:go_default_library", diff --git a/consensus-types/mock/block.go b/consensus-types/mock/block.go index 846eb42618bf..e13e09be20b2 100644 --- a/consensus-types/mock/block.go +++ b/consensus-types/mock/block.go @@ -5,7 +5,6 @@ import ( field_params "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/math" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" validatorpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/validator-client" "google.golang.org/protobuf/proto" @@ -75,7 +74,7 @@ func (SignedBeaconBlock) Header() (*eth.SignedBeaconBlockHeader, error) { panic("implement me") } -func (SignedBeaconBlock) ValueInWei() math.Wei { +func (SignedBeaconBlock) ValueInWei() primitives.Wei { panic("implement me") } diff --git a/consensus-types/primitives/BUILD.bazel b/consensus-types/primitives/BUILD.bazel index ff6752a194e9..10ddde9c7346 100644 --- a/consensus-types/primitives/BUILD.bazel +++ b/consensus-types/primitives/BUILD.bazel @@ -13,6 +13,7 @@ go_library( "sszbytes.go", "sszuint64.go", "validator.go", + "wei.go", ], importpath = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives", visibility = ["//visibility:public"], @@ -32,6 +33,7 @@ go_test( "sszbytes_test.go", "sszuint64_test.go", "validator_test.go", + "wei_test.go", ], embed = [":go_default_library"], deps = [ diff --git a/consensus-types/primitives/wei.go b/consensus-types/primitives/wei.go new file mode 100644 index 000000000000..8bcee0130899 --- /dev/null +++ b/consensus-types/primitives/wei.go @@ -0,0 +1,93 @@ +package primitives + +import ( + "fmt" + "math/big" + "slices" + + fssz "github.com/prysmaticlabs/fastssz" +) + +// ZeroWei is a non-nil zero value for primitives.Wei +var ZeroWei Wei = big.NewInt(0) + +// Wei is the smallest unit of Ether, represented as a pointer to a bigInt. +type Wei *big.Int + +// Gwei is a denomination of 1e9 Wei represented as an uint64. +type Gwei uint64 + +var _ fssz.HashRoot = (Gwei)(0) +var _ fssz.Marshaler = (*Gwei)(nil) +var _ fssz.Unmarshaler = (*Gwei)(nil) + +// HashTreeRoot -- +func (g Gwei) HashTreeRoot() ([32]byte, error) { + return fssz.HashWithDefaultHasher(g) +} + +// HashTreeRootWith -- +func (g Gwei) HashTreeRootWith(hh *fssz.Hasher) error { + hh.PutUint64(uint64(g)) + return nil +} + +// UnmarshalSSZ -- +func (g *Gwei) UnmarshalSSZ(buf []byte) error { + if len(buf) != g.SizeSSZ() { + return fmt.Errorf("expected buffer of length %d received %d", g.SizeSSZ(), len(buf)) + } + *g = Gwei(fssz.UnmarshallUint64(buf)) + return nil +} + +// MarshalSSZTo -- +func (g *Gwei) MarshalSSZTo(dst []byte) ([]byte, error) { + marshalled, err := g.MarshalSSZ() + if err != nil { + return nil, err + } + return append(dst, marshalled...), nil +} + +// MarshalSSZ -- +func (g *Gwei) MarshalSSZ() ([]byte, error) { + marshalled := fssz.MarshalUint64([]byte{}, uint64(*g)) + return marshalled, nil +} + +// SizeSSZ -- +func (g *Gwei) SizeSSZ() int { + return 8 +} + +// WeiToBigInt is a convenience method to cast a wei back to a big int +func WeiToBigInt(w Wei) *big.Int { + return w +} + +// Uint64ToWei creates a new Wei (aka big.Int) representing the given uint64 value. +func Uint64ToWei(v uint64) Wei { + return big.NewInt(0).SetUint64(v) +} + +// BigEndianBytesToWei returns a Wei value given a big-endian binary representation (eg engine api payload bids). +func BigEndianBytesToWei(value []byte) Wei { + v := make([]byte, len(value)) + copy(v, value) + slices.Reverse(v) + // We have to convert big endian to little endian because the value is coming from the execution layer. + return big.NewInt(0).SetBytes(v) +} + +// WeiToGwei converts big int wei to uint64 gwei. +// The input `v` is copied before being modified. +func WeiToGwei(v Wei) Gwei { + if v == nil { + return 0 + } + gweiPerEth := big.NewInt(1e9) + copied := big.NewInt(0).Set(v) + copied.Div(copied, gweiPerEth) + return Gwei(copied.Uint64()) +} diff --git a/consensus-types/primitives/wei_test.go b/consensus-types/primitives/wei_test.go new file mode 100644 index 000000000000..dd9ff308aeaf --- /dev/null +++ b/consensus-types/primitives/wei_test.go @@ -0,0 +1,41 @@ +package primitives_test + +import ( + "math" + "math/big" + "testing" + + "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" + "github.com/prysmaticlabs/prysm/v5/testing/require" +) + +func TestWeiStringer(t *testing.T) { + require.Equal(t, "0", primitives.WeiToBigInt(primitives.ZeroWei).String()) + require.Equal(t, "1234", primitives.WeiToBigInt(primitives.Uint64ToWei(1234)).String()) + require.Equal(t, "18446744073709551615", primitives.WeiToBigInt(primitives.Uint64ToWei(math.MaxUint64)).String()) +} + +func TestWeiToGwei(t *testing.T) { + tests := []struct { + v *big.Int + want primitives.Gwei + }{ + {big.NewInt(1e9 - 1), 0}, + {big.NewInt(1e9), 1}, + {big.NewInt(1e10), 10}, + {big.NewInt(239489233849348394), 239489233}, + } + for _, tt := range tests { + if got := primitives.WeiToGwei(tt.v); got != tt.want { + t.Errorf("WeiToGwei() = %v, want %v", got, tt.want) + } + } +} + +func TestWeiToGwei_CopyOk(t *testing.T) { + v := big.NewInt(1e9) + got := primitives.WeiToGwei(v) + + require.Equal(t, primitives.Gwei(1), got) + require.Equal(t, big.NewInt(1e9).Uint64(), v.Uint64()) +} diff --git a/encoding/ssz/equality/BUILD.bazel b/encoding/ssz/equality/BUILD.bazel index 0e023a0463ed..4c67be0035a1 100644 --- a/encoding/ssz/equality/BUILD.bazel +++ b/encoding/ssz/equality/BUILD.bazel @@ -7,7 +7,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//consensus-types/primitives:go_default_library", - "//math:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) diff --git a/encoding/ssz/equality/deep_equal.go b/encoding/ssz/equality/deep_equal.go index 9c52d8475a8f..e0216a11c54e 100644 --- a/encoding/ssz/equality/deep_equal.go +++ b/encoding/ssz/equality/deep_equal.go @@ -5,7 +5,6 @@ import ( "unsafe" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v5/math" "google.golang.org/protobuf/proto" ) @@ -232,7 +231,7 @@ func deepValueBaseTypeEqual(v1, v2 reflect.Value) bool { case "CommitteeIndex": return v1.Interface().(primitives.CommitteeIndex) == v2.Interface().(primitives.CommitteeIndex) case "Gwei": - return v1.Interface().(math.Gwei) == v2.Interface().(math.Gwei) + return v1.Interface().(primitives.Gwei) == v2.Interface().(primitives.Gwei) } return v1.Interface().(uint64) == v2.Interface().(uint64) case reflect.Uint32: diff --git a/math/BUILD.bazel b/math/BUILD.bazel index 39964b0712c7..fac6ee3ab7a0 100644 --- a/math/BUILD.bazel +++ b/math/BUILD.bazel @@ -5,10 +5,7 @@ go_library( srcs = ["math_helper.go"], importpath = "github.com/prysmaticlabs/prysm/v5/math", visibility = ["//visibility:public"], - deps = [ - "@com_github_prysmaticlabs_fastssz//:go_default_library", - "@com_github_thomaso_mirodin_intmath//u64:go_default_library", - ], + deps = ["@com_github_thomaso_mirodin_intmath//u64:go_default_library"], ) go_test( @@ -17,6 +14,7 @@ go_test( srcs = ["math_helper_test.go"], deps = [ ":go_default_library", + "//consensus-types/primitives:go_default_library", "//testing/require:go_default_library", ], ) diff --git a/math/math_helper.go b/math/math_helper.go index d926a3db750e..e4a59e21d6f0 100644 --- a/math/math_helper.go +++ b/math/math_helper.go @@ -3,13 +3,11 @@ package math import ( "errors" - "fmt" stdmath "math" "math/big" "math/bits" "sync" - fssz "github.com/prysmaticlabs/fastssz" "github.com/thomaso-mirodin/intmath/u64" ) @@ -215,68 +213,6 @@ func AddInt(i ...int) (int, error) { return sum, nil } -// Wei is the smallest unit of Ether, represented as a pointer to a bigInt. -type Wei *big.Int - -var _ fssz.HashRoot = (Gwei)(0) -var _ fssz.Marshaler = (*Gwei)(nil) -var _ fssz.Unmarshaler = (*Gwei)(nil) - -// Gwei is a denomination of 1e9 Wei represented as an uint64. -type Gwei uint64 - -// HashTreeRoot -- -func (g Gwei) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(g) -} - -// HashTreeRootWith -- -func (g Gwei) HashTreeRootWith(hh *fssz.Hasher) error { - hh.PutUint64(uint64(g)) - return nil -} - -// UnmarshalSSZ -- -func (g *Gwei) UnmarshalSSZ(buf []byte) error { - if len(buf) != g.SizeSSZ() { - return fmt.Errorf("expected buffer of length %d received %d", g.SizeSSZ(), len(buf)) - } - *g = Gwei(fssz.UnmarshallUint64(buf)) - return nil -} - -// MarshalSSZTo -- -func (g *Gwei) MarshalSSZTo(dst []byte) ([]byte, error) { - marshalled, err := g.MarshalSSZ() - if err != nil { - return nil, err - } - return append(dst, marshalled...), nil -} - -// MarshalSSZ -- -func (g *Gwei) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*g)) - return marshalled, nil -} - -// SizeSSZ -- -func (g *Gwei) SizeSSZ() int { - return 8 -} - -// WeiToGwei converts big int wei to uint64 gwei. -// The input `v` is copied before being modified. -func WeiToGwei(v Wei) Gwei { - if v == nil { - return 0 - } - gweiPerEth := big.NewInt(1e9) - copied := big.NewInt(0).Set(v) - copied.Div(copied, gweiPerEth) - return Gwei(copied.Uint64()) -} - // IsValidUint256 given a bigint checks if the value is a valid Uint256 func IsValidUint256(bi *big.Int) bool { return bi.Cmp(big.NewInt(0)) >= 0 && bi.BitLen() <= 256 diff --git a/math/math_helper_test.go b/math/math_helper_test.go index 6419ff503e35..64243a694724 100644 --- a/math/math_helper_test.go +++ b/math/math_helper_test.go @@ -6,6 +6,7 @@ import ( "math/big" "testing" + "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/math" "github.com/prysmaticlabs/prysm/v5/testing/require" ) @@ -554,7 +555,7 @@ func TestAddInt(t *testing.T) { func TestWeiToGwei(t *testing.T) { tests := []struct { v *big.Int - want math.Gwei + want primitives.Gwei }{ {big.NewInt(1e9 - 1), 0}, {big.NewInt(1e9), 1}, @@ -562,7 +563,7 @@ func TestWeiToGwei(t *testing.T) { {big.NewInt(239489233849348394), 239489233}, } for _, tt := range tests { - if got := math.WeiToGwei(tt.v); got != tt.want { + if got := primitives.WeiToGwei(tt.v); got != tt.want { t.Errorf("WeiToGwei() = %v, want %v", got, tt.want) } } @@ -570,8 +571,8 @@ func TestWeiToGwei(t *testing.T) { func TestWeiToGwei_CopyOk(t *testing.T) { v := big.NewInt(1e9) - got := math.WeiToGwei(v) + got := primitives.WeiToGwei(v) - require.Equal(t, math.Gwei(1), got) + require.Equal(t, primitives.Gwei(1), got) require.Equal(t, big.NewInt(1e9).Uint64(), v.Uint64()) } diff --git a/proto/eth/v1/generated.ssz.go b/proto/eth/v1/generated.ssz.go index 9e8cfc3999b7..01daabe6c0ab 100644 --- a/proto/eth/v1/generated.ssz.go +++ b/proto/eth/v1/generated.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: a13be0354388a9ab681c78ee577580c9aebbd6d3d17024084c06c839c5db58ee +// Hash: 2874e1dadeb47411763f48fe31e5daaa91ac663e796933d9a508c2e7be94fa5e package v1 import ( diff --git a/proto/eth/v2/generated.ssz.go b/proto/eth/v2/generated.ssz.go index b91d3b7aa5d5..29dcf6d09da2 100644 --- a/proto/eth/v2/generated.ssz.go +++ b/proto/eth/v2/generated.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: e1b3713d854395a4c86aa7a0bf0249d9f2764183a636fcc53badddeaf38990f2 +// Hash: 2755944d1f9b0e6e8b7e58d3cbba1d6028bbbb740ec05f5de43137d5b5459411 package eth import ( diff --git a/proto/prysm/v1alpha1/beacon_state.pb.go b/proto/prysm/v1alpha1/beacon_state.pb.go index aac6093e1d11..8a01977e8ee7 100755 --- a/proto/prysm/v1alpha1/beacon_state.pb.go +++ b/proto/prysm/v1alpha1/beacon_state.pb.go @@ -12,7 +12,6 @@ import ( github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield" github_com_prysmaticlabs_prysm_v5_consensus_types_primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - github_com_prysmaticlabs_prysm_v5_math "github.com/prysmaticlabs/prysm/v5/math" v1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" _ "github.com/prysmaticlabs/prysm/v5/proto/eth/ext" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -1869,10 +1868,10 @@ type BeaconStateElectra struct { NextWithdrawalValidatorIndex github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=next_withdrawal_validator_index,json=nextWithdrawalValidatorIndex,proto3" json:"next_withdrawal_validator_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"` HistoricalSummaries []*HistoricalSummary `protobuf:"bytes,11003,rep,name=historical_summaries,json=historicalSummaries,proto3" json:"historical_summaries,omitempty" ssz-max:"16777216"` DepositReceiptsStartIndex uint64 `protobuf:"varint,12001,opt,name=deposit_receipts_start_index,json=depositReceiptsStartIndex,proto3" json:"deposit_receipts_start_index,omitempty"` - DepositBalanceToConsume github_com_prysmaticlabs_prysm_v5_math.Gwei `protobuf:"varint,12002,opt,name=deposit_balance_to_consume,json=depositBalanceToConsume,proto3" json:"deposit_balance_to_consume,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/math.Gwei"` - ExitBalanceToConsume github_com_prysmaticlabs_prysm_v5_math.Gwei `protobuf:"varint,12003,opt,name=exit_balance_to_consume,json=exitBalanceToConsume,proto3" json:"exit_balance_to_consume,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/math.Gwei"` + DepositBalanceToConsume github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei `protobuf:"varint,12002,opt,name=deposit_balance_to_consume,json=depositBalanceToConsume,proto3" json:"deposit_balance_to_consume,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Gwei"` + ExitBalanceToConsume github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei `protobuf:"varint,12003,opt,name=exit_balance_to_consume,json=exitBalanceToConsume,proto3" json:"exit_balance_to_consume,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Gwei"` EarliestExitEpoch github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch `protobuf:"varint,12004,opt,name=earliest_exit_epoch,json=earliestExitEpoch,proto3" json:"earliest_exit_epoch,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"` - ConsolidationBalanceToConsume github_com_prysmaticlabs_prysm_v5_math.Gwei `protobuf:"varint,12005,opt,name=consolidation_balance_to_consume,json=consolidationBalanceToConsume,proto3" json:"consolidation_balance_to_consume,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/math.Gwei"` + ConsolidationBalanceToConsume github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei `protobuf:"varint,12005,opt,name=consolidation_balance_to_consume,json=consolidationBalanceToConsume,proto3" json:"consolidation_balance_to_consume,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Gwei"` EarliestConsolidationEpoch github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch `protobuf:"varint,12006,opt,name=earliest_consolidation_epoch,json=earliestConsolidationEpoch,proto3" json:"earliest_consolidation_epoch,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"` PendingBalanceDeposits []*PendingBalanceDeposit `protobuf:"bytes,12007,rep,name=pending_balance_deposits,json=pendingBalanceDeposits,proto3" json:"pending_balance_deposits,omitempty" ssz-max:"134217728"` PendingPartialWithdrawals []*PendingPartialWithdrawal `protobuf:"bytes,12008,rep,name=pending_partial_withdrawals,json=pendingPartialWithdrawals,proto3" json:"pending_partial_withdrawals,omitempty" ssz-max:"134217728"` @@ -2114,18 +2113,18 @@ func (x *BeaconStateElectra) GetDepositReceiptsStartIndex() uint64 { return 0 } -func (x *BeaconStateElectra) GetDepositBalanceToConsume() github_com_prysmaticlabs_prysm_v5_math.Gwei { +func (x *BeaconStateElectra) GetDepositBalanceToConsume() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei { if x != nil { return x.DepositBalanceToConsume } - return github_com_prysmaticlabs_prysm_v5_math.Gwei(0) + return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(0) } -func (x *BeaconStateElectra) GetExitBalanceToConsume() github_com_prysmaticlabs_prysm_v5_math.Gwei { +func (x *BeaconStateElectra) GetExitBalanceToConsume() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei { if x != nil { return x.ExitBalanceToConsume } - return github_com_prysmaticlabs_prysm_v5_math.Gwei(0) + return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(0) } func (x *BeaconStateElectra) GetEarliestExitEpoch() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch { @@ -2135,11 +2134,11 @@ func (x *BeaconStateElectra) GetEarliestExitEpoch() github_com_prysmaticlabs_pry return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch(0) } -func (x *BeaconStateElectra) GetConsolidationBalanceToConsume() github_com_prysmaticlabs_prysm_v5_math.Gwei { +func (x *BeaconStateElectra) GetConsolidationBalanceToConsume() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei { if x != nil { return x.ConsolidationBalanceToConsume } - return github_com_prysmaticlabs_prysm_v5_math.Gwei(0) + return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(0) } func (x *BeaconStateElectra) GetEarliestConsolidationEpoch() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch { @@ -3011,7 +3010,7 @@ var file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = []byte{ 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x42, 0x0c, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x13, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, - 0x72, 0x69, 0x65, 0x73, 0x22, 0x8d, 0x19, 0x0a, 0x12, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, + 0x72, 0x69, 0x65, 0x73, 0x22, 0xd1, 0x19, 0x0a, 0x12, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x61, 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, @@ -3152,94 +3151,98 @@ var file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = []byte{ 0x69, 0x70, 0x74, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xe1, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x19, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x64, - 0x65, 0x78, 0x12, 0x6d, 0x0a, 0x1a, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x62, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, - 0x18, 0xe2, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x2f, 0x82, 0xb5, 0x18, 0x2b, 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, 0x6d, - 0x61, 0x74, 0x68, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, 0x17, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, - 0x65, 0x12, 0x67, 0x0a, 0x17, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, - 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x18, 0xe3, 0x5d, 0x20, - 0x01, 0x28, 0x04, 0x42, 0x2f, 0x82, 0xb5, 0x18, 0x2b, 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, 0x6d, 0x61, 0x74, 0x68, 0x2e, - 0x47, 0x77, 0x65, 0x69, 0x52, 0x14, 0x65, 0x78, 0x69, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, - 0x65, 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x77, 0x0a, 0x13, 0x65, 0x61, - 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, - 0x68, 0x18, 0xe4, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, 0x67, 0x69, + 0x65, 0x78, 0x12, 0x83, 0x01, 0x0a, 0x1a, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x62, + 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, + 0x65, 0x18, 0xe2, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 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, - 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, - 0x52, 0x11, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x45, 0x78, 0x69, 0x74, 0x45, 0x70, - 0x6f, 0x63, 0x68, 0x12, 0x79, 0x0a, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, - 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x18, 0xe5, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x2f, - 0x82, 0xb5, 0x18, 0x2b, 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, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, - 0x1d, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x89, - 0x01, 0x0a, 0x1c, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x73, - 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, - 0xe6, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, 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, 0x70, 0x72, - 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x1a, - 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x76, 0x0a, 0x18, 0x70, 0x65, - 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x64, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0xe7, 0x5d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, - 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x61, 0x6c, - 0x61, 0x6e, 0x63, 0x65, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, 0x0d, 0x92, 0xb5, 0x18, - 0x09, 0x31, 0x33, 0x34, 0x32, 0x31, 0x37, 0x37, 0x32, 0x38, 0x52, 0x16, 0x70, 0x65, 0x6e, 0x64, - 0x69, 0x6e, 0x67, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x73, 0x12, 0x7f, 0x0a, 0x1b, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x61, - 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, - 0x73, 0x18, 0xe8, 0x5d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, + 0x17, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, + 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x7d, 0x0a, 0x17, 0x65, 0x78, 0x69, 0x74, + 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, + 0x75, 0x6d, 0x65, 0x18, 0xe3, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, + 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, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, + 0x69, 0x52, 0x14, 0x65, 0x78, 0x69, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, + 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x77, 0x0a, 0x13, 0x65, 0x61, 0x72, 0x6c, 0x69, + 0x65, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0xe4, + 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, 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, 0x70, 0x72, 0x69, + 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x11, 0x65, + 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x45, 0x78, 0x69, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, + 0x12, 0x8f, 0x01, 0x0a, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, + 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x18, 0xe5, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, + 0x18, 0x41, 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, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, + 0x77, 0x65, 0x69, 0x52, 0x1d, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, + 0x6d, 0x65, 0x12, 0x89, 0x01, 0x0a, 0x1c, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x5f, + 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x18, 0xe6, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, + 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, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, + 0x63, 0x68, 0x52, 0x1a, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x73, + 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x76, + 0x0a, 0x18, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, + 0x65, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0xe7, 0x5d, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x2c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, + 0x67, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, + 0x0d, 0x92, 0xb5, 0x18, 0x09, 0x31, 0x33, 0x34, 0x32, 0x31, 0x37, 0x37, 0x32, 0x38, 0x52, 0x16, + 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x44, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x12, 0x7f, 0x0a, 0x1b, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, + 0x67, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0xe8, 0x5d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x72, 0x74, + 0x69, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x42, 0x0d, 0x92, + 0xb5, 0x18, 0x09, 0x31, 0x33, 0x34, 0x32, 0x31, 0x37, 0x37, 0x32, 0x38, 0x52, 0x19, 0x70, 0x65, + 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, 0x6f, 0x0a, 0x16, 0x70, 0x65, 0x6e, 0x64, 0x69, + 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0xe9, 0x5d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x57, - 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x42, 0x0d, 0x92, 0xb5, 0x18, 0x09, 0x31, - 0x33, 0x34, 0x32, 0x31, 0x37, 0x37, 0x32, 0x38, 0x52, 0x19, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, - 0x67, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, - 0x61, 0x6c, 0x73, 0x12, 0x6f, 0x0a, 0x16, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, - 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe9, 0x5d, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, - 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, - 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x42, 0x0a, 0x92, 0xb5, 0x18, 0x06, 0x32, 0x36, 0x32, 0x31, 0x34, 0x34, 0x52, 0x15, 0x70, - 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x8d, 0x01, 0x0a, 0x08, 0x50, 0x6f, 0x77, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, - 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, - 0x68, 0x12, 0x31, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x69, - 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, - 0x02, 0x33, 0x32, 0x52, 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, - 0x75, 0x6c, 0x74, 0x79, 0x22, 0x7f, 0x0a, 0x11, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, - 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x34, 0x0a, 0x12, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x5f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x10, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x6f, 0x6f, 0x74, 0x12, - 0x34, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, - 0x02, 0x33, 0x32, 0x52, 0x10, 0x73, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, - 0x79, 0x52, 0x6f, 0x6f, 0x74, 0x42, 0x9b, 0x01, 0x0a, 0x19, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, - 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x42, 0x10, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 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, 0x3b, - 0x65, 0x74, 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, - 0x74, 0x68, 0x2e, 0x56, 0x31, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x15, 0x45, 0x74, - 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x92, 0xb5, 0x18, 0x06, 0x32, 0x36, 0x32, 0x31, 0x34, + 0x34, 0x52, 0x15, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x8d, 0x01, 0x0a, 0x08, 0x50, 0x6f, 0x77, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, + 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, + 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x27, 0x0a, 0x0b, + 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, + 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x31, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x64, + 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x44, 0x69, + 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x22, 0x7f, 0x0a, 0x11, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x34, 0x0a, + 0x12, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, + 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, + 0x32, 0x52, 0x10, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x34, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x10, 0x73, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, + 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x6f, 0x6f, 0x74, 0x42, 0x9b, 0x01, 0x0a, 0x19, 0x6f, 0x72, + 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x10, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 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, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x31, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, + 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/prysm/v1alpha1/beacon_state.proto b/proto/prysm/v1alpha1/beacon_state.proto index f4bc57e2ce1d..dd38eebd201a 100644 --- a/proto/prysm/v1alpha1/beacon_state.proto +++ b/proto/prysm/v1alpha1/beacon_state.proto @@ -397,10 +397,10 @@ message BeaconStateElectra { // Fields introduced in EIP-7251 fork [12001-13000] uint64 deposit_receipts_start_index = 12001; - uint64 deposit_balance_to_consume = 12002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/math.Gwei"]; - uint64 exit_balance_to_consume = 12003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/math.Gwei"]; + uint64 deposit_balance_to_consume = 12002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Gwei"]; + uint64 exit_balance_to_consume = 12003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Gwei"]; uint64 earliest_exit_epoch = 12004 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"]; - uint64 consolidation_balance_to_consume = 12005 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/math.Gwei"]; + uint64 consolidation_balance_to_consume = 12005 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Gwei"]; uint64 earliest_consolidation_epoch = 12006 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"]; repeated PendingBalanceDeposit pending_balance_deposits = 12007 [(ethereum.eth.ext.ssz_max) = "pending_balance_deposits_limit"]; repeated PendingPartialWithdrawal pending_partial_withdrawals = 12008 [(ethereum.eth.ext.ssz_max) = "pending_partial_withdrawals_limit"]; diff --git a/proto/prysm/v1alpha1/generated.ssz.go b/proto/prysm/v1alpha1/generated.ssz.go index 9d201ba3218e..50b0fb52dc8a 100644 --- a/proto/prysm/v1alpha1/generated.ssz.go +++ b/proto/prysm/v1alpha1/generated.ssz.go @@ -1,11 +1,10 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 5d2c5eb257aa9cd0f12fd74f707963c8e7f779fbef26d0031f6ae18e9b1ee124 +// Hash: 75d48d13b4efa7867468bae2df70b80e9606b9a44e621915d2093a4f20ae111f package eth import ( ssz "github.com/prysmaticlabs/fastssz" github_com_prysmaticlabs_prysm_v5_consensus_types_primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" - github_com_prysmaticlabs_prysm_v5_math "github.com/prysmaticlabs/prysm/v5/math" v1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ) @@ -17980,16 +17979,16 @@ func (b *BeaconStateElectra) UnmarshalSSZ(buf []byte) error { b.DepositReceiptsStartIndex = ssz.UnmarshallUint64(buf[2736653:2736661]) // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = github_com_prysmaticlabs_prysm_v5_math.Gwei(ssz.UnmarshallUint64(buf[2736661:2736669])) + b.DepositBalanceToConsume = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(ssz.UnmarshallUint64(buf[2736661:2736669])) // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = github_com_prysmaticlabs_prysm_v5_math.Gwei(ssz.UnmarshallUint64(buf[2736669:2736677])) + b.ExitBalanceToConsume = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(ssz.UnmarshallUint64(buf[2736669:2736677])) // Field (31) 'EarliestExitEpoch' b.EarliestExitEpoch = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch(ssz.UnmarshallUint64(buf[2736677:2736685])) // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = github_com_prysmaticlabs_prysm_v5_math.Gwei(ssz.UnmarshallUint64(buf[2736685:2736693])) + b.ConsolidationBalanceToConsume = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Gwei(ssz.UnmarshallUint64(buf[2736685:2736693])) // Field (33) 'EarliestConsolidationEpoch' b.EarliestConsolidationEpoch = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch(ssz.UnmarshallUint64(buf[2736693:2736701])) diff --git a/testing/spectest/shared/electra/epoch_processing/BUILD.bazel b/testing/spectest/shared/electra/epoch_processing/BUILD.bazel index 342cfae44b29..0f37ce9b7437 100644 --- a/testing/spectest/shared/electra/epoch_processing/BUILD.bazel +++ b/testing/spectest/shared/electra/epoch_processing/BUILD.bazel @@ -26,7 +26,7 @@ go_library( "//beacon-chain/state:go_default_library", "//beacon-chain/state/state-native:go_default_library", "//config/params:go_default_library", - "//math:go_default_library", + "//consensus-types/primitives:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/utils:go_default_library", diff --git a/testing/spectest/shared/electra/epoch_processing/pending_balance_updates.go b/testing/spectest/shared/electra/epoch_processing/pending_balance_updates.go index fbd3714cde54..89a734373199 100644 --- a/testing/spectest/shared/electra/epoch_processing/pending_balance_updates.go +++ b/testing/spectest/shared/electra/epoch_processing/pending_balance_updates.go @@ -8,7 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/electra" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" - "github.com/prysmaticlabs/prysm/v5/math" + "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/testing/spectest/utils" ) @@ -31,5 +31,5 @@ func processPendingBalanceDeposits(t *testing.T, st state.BeaconState) (state.Be // balance from the given state. tab, err := helpers.TotalActiveBalance(st) require.NoError(t, err) - return st, electra.ProcessPendingBalanceDeposits(context.TODO(), st, math.Gwei(tab)) + return st, electra.ProcessPendingBalanceDeposits(context.TODO(), st, primitives.Gwei(tab)) } diff --git a/testing/util/BUILD.bazel b/testing/util/BUILD.bazel index 921d39161c9d..675ea1fb6c33 100644 --- a/testing/util/BUILD.bazel +++ b/testing/util/BUILD.bazel @@ -49,7 +49,6 @@ go_library( "//crypto/hash:go_default_library", "//crypto/rand:go_default_library", "//encoding/bytesutil:go_default_library", - "//math:go_default_library", "//network/forks:go_default_library", "//proto/engine/v1:go_default_library", "//proto/eth/v1:go_default_library", diff --git a/testing/util/electra_state.go b/testing/util/electra_state.go index 9af5a78e10d9..947b096f2f7f 100644 --- a/testing/util/electra_state.go +++ b/testing/util/electra_state.go @@ -11,8 +11,8 @@ 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/primitives" "github.com/prysmaticlabs/prysm/v5/crypto/bls" - "github.com/prysmaticlabs/prysm/v5/math" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/time/slots" @@ -84,9 +84,9 @@ func emptyGenesisStateElectra() (state.BeaconState, error) { LatestExecutionPayloadHeader: &enginev1.ExecutionPayloadHeaderElectra{}, - DepositBalanceToConsume: math.Gwei(0), - ExitBalanceToConsume: math.Gwei(0), - ConsolidationBalanceToConsume: math.Gwei(0), + DepositBalanceToConsume: primitives.Gwei(0), + ExitBalanceToConsume: primitives.Gwei(0), + ConsolidationBalanceToConsume: primitives.Gwei(0), } return state_native.InitializeFromProtoElectra(st) } @@ -192,9 +192,9 @@ func buildGenesisBeaconStateElectra(genesisTime uint64, preState state.BeaconSta // Electra Data DepositReceiptsStartIndex: params.BeaconConfig().UnsetDepositReceiptsStartIndex, - ExitBalanceToConsume: helpers.ActivationExitChurnLimit(math.Gwei(tab)), + ExitBalanceToConsume: helpers.ActivationExitChurnLimit(primitives.Gwei(tab)), EarliestConsolidationEpoch: helpers.ActivationExitEpoch(slots.ToEpoch(preState.Slot())), - ConsolidationBalanceToConsume: helpers.ConsolidationChurnLimit(math.Gwei(tab)), + ConsolidationBalanceToConsume: helpers.ConsolidationChurnLimit(primitives.Gwei(tab)), PendingBalanceDeposits: make([]*ethpb.PendingBalanceDeposit, 0), PendingPartialWithdrawals: make([]*ethpb.PendingPartialWithdrawal, 0), PendingConsolidations: make([]*ethpb.PendingConsolidation, 0),