diff --git a/beacon-chain/blockchain/chain_info_test.go b/beacon-chain/blockchain/chain_info_test.go index ed22b29395..53f9577a50 100644 --- a/beacon-chain/blockchain/chain_info_test.go +++ b/beacon-chain/blockchain/chain_info_test.go @@ -47,9 +47,14 @@ func prepareForkchoiceState( BlockHash: payloadHash[:], } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } + base := ðpb.BeaconStateBellatrix{ Slot: slot, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, BlockRoots: make([][]byte, 1), CurrentJustifiedCheckpoint: justified, FinalizedCheckpoint: finalized, diff --git a/beacon-chain/cache/active_balance_test.go b/beacon-chain/cache/active_balance_test.go index d0e6101a23..df67f113ab 100644 --- a/beacon-chain/cache/active_balance_test.go +++ b/beacon-chain/cache/active_balance_test.go @@ -17,7 +17,7 @@ import ( func TestBalanceCache_AddGetBalance(t *testing.T) { blockRoots := make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot) for i := 0; i < len(blockRoots); i++ { - b := make([]byte, 8) + b := make([]byte, 32) binary.LittleEndian.PutUint64(b, uint64(i)) blockRoots[i] = b } diff --git a/beacon-chain/core/blocks/attestation_test.go b/beacon-chain/core/blocks/attestation_test.go index d61fc01ab7..c3c905ee9b 100644 --- a/beacon-chain/core/blocks/attestation_test.go +++ b/beacon-chain/core/blocks/attestation_test.go @@ -191,11 +191,15 @@ func TestConvertToIndexed_OK(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{ Slot: 5, Validators: validators, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, }) require.NoError(t, err) tests := []struct { @@ -249,6 +253,10 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) { WithdrawalCredentials: make([]byte, 32), } } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{ Slot: 5, @@ -258,7 +266,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) { CurrentVersion: params.BeaconConfig().GenesisForkVersion, PreviousVersion: params.BeaconConfig().GenesisForkVersion, }, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, }) require.NoError(t, err) tests := []struct { diff --git a/beacon-chain/core/epoch/precompute/BUILD.bazel b/beacon-chain/core/epoch/precompute/BUILD.bazel index 3d31608023..aa49836f92 100644 --- a/beacon-chain/core/epoch/precompute/BUILD.bazel +++ b/beacon-chain/core/epoch/precompute/BUILD.bazel @@ -54,6 +54,7 @@ go_test( "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", + "//encoding/bytesutil:go_default_library", "//math:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/attestation:go_default_library", diff --git a/beacon-chain/core/epoch/precompute/justification_finalization_test.go b/beacon-chain/core/epoch/precompute/justification_finalization_test.go index 6553088c52..ea55723a86 100644 --- a/beacon-chain/core/epoch/precompute/justification_finalization_test.go +++ b/beacon-chain/core/epoch/precompute/justification_finalization_test.go @@ -11,6 +11,7 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v4/testing/assert" "github.com/prysmaticlabs/prysm/v4/testing/require" @@ -19,9 +20,9 @@ import ( func TestProcessJustificationAndFinalizationPreCompute_ConsecutiveEpochs(t *testing.T) { e := params.BeaconConfig().FarFutureEpoch a := params.BeaconConfig().MaxEffectiveBalance - blockRoots := make([][]byte, params.BeaconConfig().SlotsPerEpoch*2+1) + blockRoots := make([][]byte, fieldparams.BlockRootsLength) for i := 0; i < len(blockRoots); i++ { - blockRoots[i] = []byte{byte(i)} + blockRoots[i] = bytesutil.PadTo([]byte{byte(i)}, 32) } base := ðpb.BeaconState{ Slot: params.BeaconConfig().SlotsPerEpoch*2 + 1, diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index 38173f0f88..71b950dda1 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -8,8 +8,10 @@ import ( "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v4/testing/assert" "github.com/prysmaticlabs/prysm/v4/testing/require" @@ -58,13 +60,25 @@ func TestAttestation_ComputeSubnetForAttestation(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } + bRoots := make([][]byte, fieldparams.BlockRootsLength) + for i := range bRoots { + bRoots[i] = bytesutil.PadTo([]byte{}, 32) + } + sRoots := make([][]byte, fieldparams.StateRootsLength) + for i := range sRoots { + sRoots[i] = bytesutil.PadTo([]byte{}, 32) + } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{ Validators: validators, Slot: 200, - BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + BlockRoots: bRoots, + StateRoots: sRoots, + RandaoMixes: mixes, }) require.NoError(t, err) att := ðpb.Attestation{ diff --git a/beacon-chain/core/helpers/beacon_committee_test.go b/beacon-chain/core/helpers/beacon_committee_test.go index c281150638..4b6d4eaed2 100644 --- a/beacon-chain/core/helpers/beacon_committee_test.go +++ b/beacon-chain/core/helpers/beacon_committee_test.go @@ -9,6 +9,7 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time" state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/container/slice" @@ -35,13 +36,25 @@ func TestComputeCommittee_WithoutCache(t *testing.T) { ExitEpoch: params.BeaconConfig().FarFutureEpoch, } } + bRoots := make([][]byte, fieldparams.BlockRootsLength) + for i := range bRoots { + bRoots[i] = bytesutil.PadTo([]byte{}, 32) + } + sRoots := make([][]byte, fieldparams.StateRootsLength) + for i := range sRoots { + sRoots[i] = bytesutil.PadTo([]byte{}, 32) + } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } state, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{ Validators: validators, Slot: 200, - BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + BlockRoots: bRoots, + StateRoots: sRoots, + RandaoMixes: mixes, }) require.NoError(t, err) diff --git a/beacon-chain/core/transition/transition_test.go b/beacon-chain/core/transition/transition_test.go index 3a8e5f380e..70d62ecead 100644 --- a/beacon-chain/core/transition/transition_test.go +++ b/beacon-chain/core/transition/transition_test.go @@ -149,7 +149,7 @@ func TestProcessBlock_IncorrectProcessExits(t *testing.T) { } var blockRoots [][]byte for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ { - blockRoots = append(blockRoots, []byte{byte(i)}) + blockRoots = append(blockRoots, bytesutil.PadTo([]byte{byte(i)}, 32)) } require.NoError(t, beaconState.SetBlockRoots(blockRoots)) blockAtt := util.HydrateAttestation(ðpb.Attestation{ @@ -295,7 +295,7 @@ func createFullBlockWithOperations(t *testing.T) (state.BeaconState, var blockRoots [][]byte for i := uint64(0); i < uint64(params.BeaconConfig().SlotsPerHistoricalRoot); i++ { - blockRoots = append(blockRoots, []byte{byte(i)}) + blockRoots = append(blockRoots, bytesutil.PadTo([]byte{byte(i)}, 32)) } require.NoError(t, beaconState.SetBlockRoots(blockRoots)) diff --git a/beacon-chain/core/validators/BUILD.bazel b/beacon-chain/core/validators/BUILD.bazel index 21bf85257e..44fde8120f 100644 --- a/beacon-chain/core/validators/BUILD.bazel +++ b/beacon-chain/core/validators/BUILD.bazel @@ -31,8 +31,10 @@ go_test( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/time:go_default_library", "//beacon-chain/state/state-native:go_default_library", + "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", + "//encoding/bytesutil: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_test.go b/beacon-chain/core/validators/validator_test.go index fcbbeb5b8c..66494b3b5a 100644 --- a/beacon-chain/core/validators/validator_test.go +++ b/beacon-chain/core/validators/validator_test.go @@ -7,8 +7,10 @@ import ( "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/time" state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v4/runtime/version" "github.com/prysmaticlabs/prysm/v4/testing/assert" @@ -122,11 +124,15 @@ func TestSlashValidator_OK(t *testing.T) { }) balances = append(balances, params.BeaconConfig().MaxEffectiveBalance) } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } base := ðpb.BeaconState{ Validators: registry, Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, Balances: balances, } state, err := state_native.InitializeFromProtoPhase0(base) diff --git a/beacon-chain/forkchoice/doubly-linked-tree/BUILD.bazel b/beacon-chain/forkchoice/doubly-linked-tree/BUILD.bazel index 0f8be212f1..55349c8261 100644 --- a/beacon-chain/forkchoice/doubly-linked-tree/BUILD.bazel +++ b/beacon-chain/forkchoice/doubly-linked-tree/BUILD.bazel @@ -65,6 +65,7 @@ go_test( "//beacon-chain/forkchoice/types:go_default_library", "//beacon-chain/state:go_default_library", "//beacon-chain/state/state-native:go_default_library", + "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types/blocks:go_default_library", "//consensus-types/primitives:go_default_library", diff --git a/beacon-chain/forkchoice/doubly-linked-tree/forkchoice_test.go b/beacon-chain/forkchoice/doubly-linked-tree/forkchoice_test.go index 1ebcc4fab8..256033c573 100644 --- a/beacon-chain/forkchoice/doubly-linked-tree/forkchoice_test.go +++ b/beacon-chain/forkchoice/doubly-linked-tree/forkchoice_test.go @@ -10,10 +10,12 @@ import ( forkchoicetypes "github.com/prysmaticlabs/prysm/v4/beacon-chain/forkchoice/types" "github.com/prysmaticlabs/prysm/v4/beacon-chain/state" state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/crypto/hash" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v4/testing/assert" @@ -48,9 +50,14 @@ func prepareForkchoiceState( Epoch: finalizedEpoch, } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } + base := ðpb.BeaconStateBellatrix{ Slot: slot, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, CurrentJustifiedCheckpoint: justifiedCheckpoint, FinalizedCheckpoint: finalizedCheckpoint, LatestExecutionPayloadHeader: executionHeader, diff --git a/beacon-chain/rpc/eth/beacon/state_test.go b/beacon-chain/rpc/eth/beacon/state_test.go index a557428f5a..5916d1bb79 100644 --- a/beacon-chain/rpc/eth/beacon/state_test.go +++ b/beacon-chain/rpc/eth/beacon/state_test.go @@ -400,17 +400,17 @@ func TestGetRandao(t *testing.T) { t.Run("no epoch requested", func(t *testing.T) { resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head")}) require.NoError(t, err) - assert.DeepEqual(t, mixCurrent, resp.Data.Randao) + assert.DeepEqual(t, mixCurrent[:], resp.Data.Randao) }) t.Run("current epoch requested", func(t *testing.T) { resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head"), Epoch: &epochCurrent}) require.NoError(t, err) - assert.DeepEqual(t, mixCurrent, resp.Data.Randao) + assert.DeepEqual(t, mixCurrent[:], resp.Data.Randao) }) t.Run("old epoch requested", func(t *testing.T) { resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head"), Epoch: &epochOld}) require.NoError(t, err) - assert.DeepEqual(t, mixOld, resp.Data.Randao) + assert.DeepEqual(t, mixOld[:], resp.Data.Randao) }) t.Run("head state below `EpochsPerHistoricalVector`", func(t *testing.T) { server.Stater = &testutil.MockStater{ @@ -418,7 +418,7 @@ func TestGetRandao(t *testing.T) { } resp, err := server.GetRandao(ctx, ð2.RandaoRequest{StateId: []byte("head")}) require.NoError(t, err) - assert.DeepEqual(t, headRandao, resp.Data.Randao) + assert.DeepEqual(t, headRandao[:], resp.Data.Randao) }) t.Run("epoch too old", func(t *testing.T) { epochTooOld := primitives.Epoch(100000 - st.RandaoMixesLength()) diff --git a/beacon-chain/rpc/eth/helpers/sync_test.go b/beacon-chain/rpc/eth/helpers/sync_test.go index 5590ccd13f..179d0c361c 100644 --- a/beacon-chain/rpc/eth/helpers/sync_test.go +++ b/beacon-chain/rpc/eth/helpers/sync_test.go @@ -16,7 +16,6 @@ import ( state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" syncmock "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" - "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" @@ -313,11 +312,19 @@ func prepareForkchoiceState( executionHeader := &enginev1.ExecutionPayloadHeader{ BlockHash: payloadHash[:], } + bRoots := make([][]byte, fieldparams.BlockRootsLength) + for i := range bRoots { + bRoots[i] = bytesutil.PadTo([]byte{}, 32) + } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } base := ð.BeaconStateBellatrix{ Slot: slot, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), - BlockRoots: make([][]byte, 1), + RandaoMixes: mixes, + BlockRoots: bRoots, CurrentJustifiedCheckpoint: justified, FinalizedCheckpoint: finalized, LatestExecutionPayloadHeader: executionHeader, diff --git a/beacon-chain/rpc/eth/rewards/handlers_test.go b/beacon-chain/rpc/eth/rewards/handlers_test.go index 25a0464aa0..d3fd349951 100644 --- a/beacon-chain/rpc/eth/rewards/handlers_test.go +++ b/beacon-chain/rpc/eth/rewards/handlers_test.go @@ -58,6 +58,9 @@ func TestBlockRewards(t *testing.T) { require.NoError(t, st.SetCurrentSyncCommittee(syncCommittee)) slot0bRoot := bytesutil.PadTo([]byte("slot0root"), 32) bRoots := make([][]byte, fieldparams.BlockRootsLength) + for i := range bRoots { + bRoots[i] = bytesutil.PadTo([]byte{}, 32) + } bRoots[0] = slot0bRoot require.NoError(t, st.SetBlockRoots(bRoots)) diff --git a/beacon-chain/rpc/eth/validator/validator_test.go b/beacon-chain/rpc/eth/validator/validator_test.go index 7a8682dafb..7818a583ac 100644 --- a/beacon-chain/rpc/eth/validator/validator_test.go +++ b/beacon-chain/rpc/eth/validator/validator_test.go @@ -54,6 +54,9 @@ func TestGetAttesterDuties(t *testing.T) { genesisRoot, err := genesis.Block.HashTreeRoot() require.NoError(t, err, "Could not get signing root") roots := make([][]byte, fieldparams.BlockRootsLength) + for i := range roots { + roots[i] = bytesutil.PadTo([]byte{}, 32) + } roots[0] = genesisRoot[:] require.NoError(t, bs.SetBlockRoots(roots)) db := dbutil.SetupDB(t) diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go index d79e4ff83d..242787de93 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/aggregator_test.go @@ -47,8 +47,12 @@ func TestSubmitAggregateAndProof_Syncing(t *testing.T) { func TestSubmitAggregateAndProof_CantFindValidatorIndex(t *testing.T) { ctx := context.Background() + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } s, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{ - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, }) require.NoError(t, err) diff --git a/beacon-chain/state/state-native/custom-types/block_roots_test.go b/beacon-chain/state/state-native/custom-types/block_roots_test.go index 51ff6174fa..37ed99df24 100644 --- a/beacon-chain/state/state-native/custom-types/block_roots_test.go +++ b/beacon-chain/state/state-native/custom-types/block_roots_test.go @@ -8,14 +8,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/testing/assert" ) -func TestBlockRoots_Casting(t *testing.T) { - var b [][32]byte - d := BlockRoots(b) - if !reflect.DeepEqual([fieldparams.BlockRootsLength][32]byte(d), b) { - t.Errorf("Unequal: %v = %v", d, b) - } -} - func TestBlockRoots_UnmarshalSSZ(t *testing.T) { t.Run("Ok", func(t *testing.T) { d := BlockRoots{} diff --git a/beacon-chain/state/state-native/field_trie_test.go b/beacon-chain/state/state-native/field_trie_test.go index 926ab71b9c..7eb674d054 100644 --- a/beacon-chain/state/state-native/field_trie_test.go +++ b/beacon-chain/state/state-native/field_trie_test.go @@ -40,7 +40,7 @@ func TestFieldTrie_RecomputeTrie(t *testing.T) { st, ok := newState.(*state_native.BeaconState) require.Equal(t, true, ok) // 10 represents the enum value of validators - trie, err := state_native.NewFieldTrie(st, types.FieldIndex(11), types.FieldInfo{ArrayType: types.CompositeArray, ValueType: types.SingleValue}, newState.Validators(), params.BeaconConfig().ValidatorRegistryLimit) + trie, err := state_native.NewFieldTrie(st, types.FieldIndex(11), types.FieldInfo{ArrayType: types.CompositeArray, ValueType: types.MultiValue}, state_native.NewMultiValueValidators(newState.Validators()), params.BeaconConfig().ValidatorRegistryLimit) require.NoError(t, err) oldroot, err := trie.TrieRoot() @@ -64,7 +64,7 @@ func TestFieldTrie_RecomputeTrie(t *testing.T) { expectedRoot, err := stateutil.ValidatorRegistryRoot(newState.Validators()) require.NoError(t, err) - root, err := trie.RecomputeTrie(st, changedIdx, newState.Validators()) + root, err := trie.RecomputeTrie(st, changedIdx, state_native.NewMultiValueValidators(newState.Validators())) require.NoError(t, err) assert.Equal(t, expectedRoot, root) } diff --git a/beacon-chain/state/state-native/getters_participation_test.go b/beacon-chain/state/state-native/getters_participation_test.go index 732b4ccb65..53d7a79d56 100644 --- a/beacon-chain/state/state-native/getters_participation_test.go +++ b/beacon-chain/state/state-native/getters_participation_test.go @@ -3,7 +3,9 @@ package state_native import ( "testing" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v4/testing/require" ) @@ -18,9 +20,13 @@ func TestState_UnrealizedCheckpointBalances(t *testing.T) { } balances[i] = params.BeaconConfig().MaxEffectiveBalance } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } base := ðpb.BeaconStateAltair{ Slot: 2, - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, Validators: validators, CurrentEpochParticipation: make([]byte, params.BeaconConfig().MinGenesisActiveValidatorCount), diff --git a/beacon-chain/sync/validate_proposer_slashing_test.go b/beacon-chain/sync/validate_proposer_slashing_test.go index 3aac4a4a8e..2bbf09c9dc 100644 --- a/beacon-chain/sync/validate_proposer_slashing_test.go +++ b/beacon-chain/sync/validate_proposer_slashing_test.go @@ -21,9 +21,11 @@ import ( state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native" mockSync "github.com/prysmaticlabs/prysm/v4/beacon-chain/sync/initial-sync/testing" lruwrpr "github.com/prysmaticlabs/prysm/v4/cache/lru" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/crypto/bls" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v4/testing/assert" "github.com/prysmaticlabs/prysm/v4/testing/require" @@ -44,6 +46,18 @@ func setupValidProposerSlashing(t *testing.T) (*ethpb.ProposerSlashing, state.Be for i := 0; i < len(validatorBalances); i++ { validatorBalances[i] = params.BeaconConfig().MaxEffectiveBalance } + bRoots := make([][]byte, fieldparams.BlockRootsLength) + for i := range bRoots { + bRoots[i] = bytesutil.PadTo([]byte{}, 32) + } + sRoots := make([][]byte, fieldparams.StateRootsLength) + for i := range sRoots { + sRoots[i] = bytesutil.PadTo([]byte{}, 32) + } + mixes := make([][]byte, fieldparams.RandaoMixesLength) + for i := range mixes { + mixes[i] = bytesutil.PadTo([]byte{}, 32) + } currentSlot := primitives.Slot(0) st, err := state_native.InitializeFromProtoPhase0(ðpb.BeaconState{ @@ -56,10 +70,10 @@ func setupValidProposerSlashing(t *testing.T) (*ethpb.ProposerSlashing, state.Be Epoch: 0, }, Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector), - RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector), + RandaoMixes: mixes, - StateRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), - BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot), + StateRoots: sRoots, + BlockRoots: bRoots, LatestBlockHeader: ðpb.BeaconBlockHeader{}, }) require.NoError(t, err)