Skip to content

Commit 0f0ab13

Browse files
authored
Deprecate native state flag (OffchainLabs#11268)
1 parent a27feb4 commit 0f0ab13

File tree

152 files changed

+890
-5499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+890
-5499
lines changed

beacon-chain/core/altair/reward_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
8+
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
89
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
910
"github.com/prysmaticlabs/prysm/v3/config/params"
1011
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
@@ -13,6 +14,7 @@ import (
1314
)
1415

1516
func Test_BaseReward(t *testing.T) {
17+
helpers.ClearCache()
1618
genState := func(valCount uint64) state.ReadOnlyBeaconState {
1719
s, _ := util.DeterministicGenesisStateAltair(t, valCount)
1820
return s
@@ -66,6 +68,7 @@ func Test_BaseReward(t *testing.T) {
6668
}
6769

6870
func Test_BaseRewardWithTotalBalance(t *testing.T) {
71+
helpers.ClearCache()
6972
s, _ := util.DeterministicGenesisStateAltair(t, 1)
7073
tests := []struct {
7174
name string
@@ -137,6 +140,7 @@ func Test_BaseRewardWithTotalBalance(t *testing.T) {
137140
}
138141

139142
func Test_BaseRewardPerIncrement(t *testing.T) {
143+
helpers.ClearCache()
140144
tests := []struct {
141145
name string
142146
activeBalance uint64

beacon-chain/core/validators/validator_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func TestSlashValidator_OK(t *testing.T) {
132132
state, err := v1.InitializeFromProto(base)
133133
require.NoError(t, err)
134134

135-
slashedIdx := types.ValidatorIndex(2)
135+
slashedIdx := types.ValidatorIndex(3)
136136

137137
proposer, err := helpers.BeaconProposerIndex(context.Background(), state)
138138
require.NoError(t, err, "Could not get proposer")

beacon-chain/db/kv/state.go

+3-21
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,7 @@ func (s *Store) saveStatesEfficientInternal(ctx context.Context, tx *bolt.Tx, bl
233233
// look at issue https://github.com/prysmaticlabs/prysm/issues/9262.
234234
switch rawType := states[i].InnerStateUnsafe().(type) {
235235
case *ethpb.BeaconState:
236-
var pbState *ethpb.BeaconState
237-
var err error
238-
if features.Get().EnableNativeState {
239-
pbState, err = statenative.ProtobufBeaconStatePhase0(rawType)
240-
} else {
241-
pbState, err = v1.ProtobufBeaconState(rawType)
242-
}
236+
pbState, err := statenative.ProtobufBeaconStatePhase0(rawType)
243237
if err != nil {
244238
return err
245239
}
@@ -260,13 +254,7 @@ func (s *Store) saveStatesEfficientInternal(ctx context.Context, tx *bolt.Tx, bl
260254
return err
261255
}
262256
case *ethpb.BeaconStateAltair:
263-
var pbState *ethpb.BeaconStateAltair
264-
var err error
265-
if features.Get().EnableNativeState {
266-
pbState, err = statenative.ProtobufBeaconStateAltair(rawType)
267-
} else {
268-
pbState, err = v2.ProtobufBeaconState(rawType)
269-
}
257+
pbState, err := statenative.ProtobufBeaconStateAltair(rawType)
270258
if err != nil {
271259
return err
272260
}
@@ -288,13 +276,7 @@ func (s *Store) saveStatesEfficientInternal(ctx context.Context, tx *bolt.Tx, bl
288276
return err
289277
}
290278
case *ethpb.BeaconStateBellatrix:
291-
var pbState *ethpb.BeaconStateBellatrix
292-
var err error
293-
if features.Get().EnableNativeState {
294-
pbState, err = statenative.ProtobufBeaconStateBellatrix(rawType)
295-
} else {
296-
pbState, err = v3.ProtobufBeaconState(rawType)
297-
}
279+
pbState, err := statenative.ProtobufBeaconStateBellatrix(rawType)
298280
if err != nil {
299281
return err
300282
}

beacon-chain/execution/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ go_library(
3838
"//beacon-chain/state/state-native:go_default_library",
3939
"//beacon-chain/state/stategen:go_default_library",
4040
"//beacon-chain/state/v1:go_default_library",
41-
"//config/features:go_default_library",
4241
"//config/fieldparams:go_default_library",
4342
"//config/params:go_default_library",
4443
"//consensus-types/blocks:go_default_library",

beacon-chain/execution/log_processing.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
1919
coreState "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
2020
statenative "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
21-
v1 "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/v1"
22-
"github.com/prysmaticlabs/prysm/v3/config/features"
2321
"github.com/prysmaticlabs/prysm/v3/config/params"
2422
contracts "github.com/prysmaticlabs/prysm/v3/contracts/deposit"
2523
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
@@ -552,13 +550,7 @@ func (s *Service) processChainStartIfReady(ctx context.Context, blockHash [32]by
552550

553551
// savePowchainData saves all powchain related metadata to disk.
554552
func (s *Service) savePowchainData(ctx context.Context) error {
555-
var pbState *ethpb.BeaconState
556-
var err error
557-
if features.Get().EnableNativeState {
558-
pbState, err = statenative.ProtobufBeaconStatePhase0(s.preGenesisState.InnerStateUnsafe())
559-
} else {
560-
pbState, err = v1.ProtobufBeaconState(s.preGenesisState.InnerStateUnsafe())
561-
}
553+
pbState, err := statenative.ProtobufBeaconStatePhase0(s.preGenesisState.InnerStateUnsafe())
562554
if err != nil {
563555
return err
564556
}

beacon-chain/execution/service.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
3232
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stategen"
3333
v1 "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/v1"
34-
"github.com/prysmaticlabs/prysm/v3/config/features"
3534
"github.com/prysmaticlabs/prysm/v3/config/params"
3635
"github.com/prysmaticlabs/prysm/v3/container/trie"
3736
contracts "github.com/prysmaticlabs/prysm/v3/contracts/deposit"
@@ -262,11 +261,7 @@ func (s *Service) Stop() error {
262261
// ClearPreGenesisData clears out the stored chainstart deposits and beacon state.
263262
func (s *Service) ClearPreGenesisData() {
264263
s.chainStartData.ChainstartDeposits = []*ethpb.Deposit{}
265-
if features.Get().EnableNativeState {
266-
s.preGenesisState = &native.BeaconState{}
267-
} else {
268-
s.preGenesisState = &v1.BeaconState{}
269-
}
264+
s.preGenesisState = &native.BeaconState{}
270265
}
271266

272267
// ChainStartEth1Data returns the eth1 data at chainstart.
@@ -784,13 +779,7 @@ func (s *Service) ensureValidPowchainData(ctx context.Context) error {
784779
return errors.Wrap(err, "unable to retrieve eth1 data")
785780
}
786781
if eth1Data == nil || !eth1Data.ChainstartData.Chainstarted || !validateDepositContainers(eth1Data.DepositContainers) {
787-
var pbState *ethpb.BeaconState
788-
var err error
789-
if features.Get().EnableNativeState {
790-
pbState, err = native.ProtobufBeaconStatePhase0(s.preGenesisState.InnerStateUnsafe())
791-
} else {
792-
pbState, err = v1.ProtobufBeaconState(s.preGenesisState.InnerStateUnsafe())
793-
}
782+
pbState, err := native.ProtobufBeaconStatePhase0(s.preGenesisState.InnerStateUnsafe())
794783
if err != nil {
795784
return err
796785
}

beacon-chain/node/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ go_test(
8585
"//beacon-chain/execution/testing:go_default_library",
8686
"//cmd:go_default_library",
8787
"//cmd/beacon-chain/flags:go_default_library",
88-
"//config/features:go_default_library",
8988
"//config/fieldparams:go_default_library",
9089
"//config/params:go_default_library",
9190
"//consensus-types/primitives:go_default_library",

beacon-chain/node/node_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
mockExecution "github.com/prysmaticlabs/prysm/v3/beacon-chain/execution/testing"
1818
"github.com/prysmaticlabs/prysm/v3/cmd"
1919
"github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags"
20-
"github.com/prysmaticlabs/prysm/v3/config/features"
2120
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
2221
"github.com/prysmaticlabs/prysm/v3/config/params"
2322
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
@@ -34,7 +33,6 @@ var _ statefeed.Notifier = (*BeaconNode)(nil)
3433
// Test that beacon chain node can close.
3534
func TestNodeClose_OK(t *testing.T) {
3635
hook := logTest.NewGlobal()
37-
features.Init(&features.Flags{EnableNativeState: true})
3836
tmp := fmt.Sprintf("%s/datadirtest2", t.TempDir())
3937

4038
app := cli.App{}
@@ -54,7 +52,6 @@ func TestNodeClose_OK(t *testing.T) {
5452
node.Close()
5553

5654
require.LogsContain(t, hook, "Stopping beacon node")
57-
features.Init(&features.Flags{EnableNativeState: false})
5855
}
5956

6057
func TestNodeStart_Ok(t *testing.T) {
@@ -63,7 +60,6 @@ func TestNodeStart_Ok(t *testing.T) {
6360
tmp := fmt.Sprintf("%s/datadirtest2", t.TempDir())
6461
set := flag.NewFlagSet("test", 0)
6562
set.String("datadir", tmp, "node data directory")
66-
features.Init(&features.Flags{EnableNativeState: true})
6763
ctx := cli.NewContext(&app, set, nil)
6864
node, err := New(ctx, WithBlockchainFlagOptions([]blockchain.Option{}),
6965
WithBuilderFlagOptions([]builder.Option{}),
@@ -80,7 +76,6 @@ func TestNodeStart_Ok(t *testing.T) {
8076
}
8177

8278
func TestNodeStart_Ok_registerDeterministicGenesisService(t *testing.T) {
83-
features.Init(&features.Flags{EnableNativeState: true})
8479
numValidators := uint64(1)
8580
hook := logTest.NewGlobal()
8681
app := cli.App{}
@@ -124,7 +119,6 @@ func TestNodeStart_Ok_registerDeterministicGenesisService(t *testing.T) {
124119
node.Close()
125120
require.LogsContain(t, hook, "Starting beacon node")
126121
require.NoError(t, os.Remove("genesis_ssz.json"))
127-
features.Init(&features.Flags{EnableNativeState: false})
128122
}
129123

130124
// TestClearDB tests clearing the database

beacon-chain/rpc/eth/beacon/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ go_library(
3535
"//beacon-chain/rpc/prysm/v1alpha1/validator:go_default_library",
3636
"//beacon-chain/rpc/statefetcher:go_default_library",
3737
"//beacon-chain/state:go_default_library",
38+
"//beacon-chain/state/state-native:go_default_library",
3839
"//beacon-chain/state/stategen:go_default_library",
3940
"//beacon-chain/state/v1:go_default_library",
4041
"//beacon-chain/sync:go_default_library",

beacon-chain/rpc/eth/beacon/validator.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
corehelpers "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
99
"github.com/prysmaticlabs/prysm/v3/beacon-chain/rpc/eth/helpers"
1010
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
11+
statenative "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
1112
v1 "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/v1"
1213
"github.com/prysmaticlabs/prysm/v3/config/params"
1314
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
@@ -255,7 +256,7 @@ func valContainersByRequestIds(state state.BeaconState, validatorIds [][]byte) (
255256
valIndex = types.ValidatorIndex(index)
256257
}
257258
validator, err := state.ValidatorAtIndex(valIndex)
258-
if _, ok := err.(*v1.ValidatorIndexOutOfRangeError); ok {
259+
if _, ok := err.(*statenative.ValidatorIndexOutOfRangeError); ok {
259260
// Ignore well-formed yet unknown indexes.
260261
continue
261262
}

beacon-chain/rpc/prysm/v1alpha1/beacon/BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ go_test(
8181
"validators_test.go",
8282
],
8383
embed = [":go_default_library"],
84+
eth_network = "minimal",
8485
shard_count = 4,
86+
tags = ["minimal"],
8587
deps = [
8688
"//beacon-chain/blockchain/testing:go_default_library",
8789
"//beacon-chain/core/altair:go_default_library",

beacon-chain/rpc/prysm/v1alpha1/beacon/attestations_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ func TestServer_mapAttestationToTargetRoot(t *testing.T) {
497497

498498
func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
499499
params.SetupTestConfigCleanup(t)
500-
params.OverrideBeaconConfig(params.MainnetConfig())
500+
params.OverrideBeaconConfig(params.BeaconConfig())
501501
db := dbTest.SetupDB(t)
502502
helpers.ClearCache()
503503
ctx := context.Background()
@@ -542,8 +542,8 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
542542

543543
}
544544

545-
// We setup 128 validators.
546-
numValidators := uint64(128)
545+
// We setup 512 validators so that committee size matches the length of attestations' aggregation bits.
546+
numValidators := uint64(512)
547547
state, _ := util.DeterministicGenesisState(t, numValidators)
548548

549549
// Next up we convert the test attestations to indexed form:
@@ -605,7 +605,7 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
605605

606606
func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) {
607607
params.SetupTestConfigCleanup(t)
608-
params.OverrideBeaconConfig(params.MainnetConfig())
608+
params.OverrideBeaconConfig(params.BeaconConfig())
609609
db := dbTest.SetupDB(t)
610610
helpers.ClearCache()
611611
ctx := context.Background()
@@ -852,7 +852,7 @@ func TestServer_StreamIndexedAttestations_ContextCanceled(t *testing.T) {
852852

853853
func TestServer_StreamIndexedAttestations_OK(t *testing.T) {
854854
params.SetupTestConfigCleanup(t)
855-
params.OverrideBeaconConfig(params.MainnetConfig())
855+
params.OverrideBeaconConfig(params.BeaconConfig())
856856
db := dbTest.SetupDB(t)
857857
exitRoutine := make(chan bool)
858858
ctrl := gomock.NewController(t)

beacon-chain/rpc/prysm/v1alpha1/beacon/blocks_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ func TestServer_StreamBlocks_ContextCanceled(t *testing.T) {
382382

383383
func TestServer_StreamBlocks_OnHeadUpdated(t *testing.T) {
384384
params.SetupTestConfigCleanup(t)
385-
params.OverrideBeaconConfig(params.MainnetConfig())
385+
params.OverrideBeaconConfig(params.BeaconConfig())
386386

387387
ctx := context.Background()
388388
beaconState, privs := util.DeterministicGenesisState(t, 32)
@@ -421,7 +421,7 @@ func TestServer_StreamBlocks_OnHeadUpdated(t *testing.T) {
421421

422422
func TestServer_StreamBlocksVerified_OnHeadUpdated(t *testing.T) {
423423
params.SetupTestConfigCleanup(t)
424-
params.OverrideBeaconConfig(params.MainnetConfig())
424+
params.OverrideBeaconConfig(params.BeaconConfig())
425425

426426
db := dbTest.SetupDB(t)
427427
ctx := context.Background()

beacon-chain/rpc/prysm/v1alpha1/beacon/committees_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func addDefaultReplayerBuilder(s *Server, h stategen.HistoryAccessor) {
8282

8383
func TestServer_ListBeaconCommittees_PreviousEpoch(t *testing.T) {
8484
params.SetupTestConfigCleanup(t)
85-
params.OverrideBeaconConfig(params.MainnetConfig())
85+
params.OverrideBeaconConfig(params.BeaconConfig())
8686
ctx := context.Background()
8787

8888
db := dbTest.SetupDB(t)

beacon-chain/rpc/prysm/v1alpha1/beacon/validators_stream_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestInfostream_EpochToTimestamp(t *testing.T) {
5151

5252
func TestInfostream_HandleSetValidatorKeys(t *testing.T) {
5353
params.SetupTestConfigCleanup(t)
54-
params.OverrideBeaconConfig(params.MainnetConfig())
54+
params.OverrideBeaconConfig(params.BeaconConfig())
5555
tests := []struct {
5656
name string
5757
reqPubKeys [][]byte
@@ -89,7 +89,7 @@ func TestInfostream_HandleSetValidatorKeys(t *testing.T) {
8989

9090
func TestInfostream_HandleAddValidatorKeys(t *testing.T) {
9191
params.SetupTestConfigCleanup(t)
92-
params.OverrideBeaconConfig(params.MainnetConfig())
92+
params.OverrideBeaconConfig(params.BeaconConfig())
9393
tests := []struct {
9494
name string
9595
initialPubKeys [][]byte
@@ -137,7 +137,7 @@ func TestInfostream_HandleAddValidatorKeys(t *testing.T) {
137137

138138
func TestInfostream_HandleRemoveValidatorKeys(t *testing.T) {
139139
params.SetupTestConfigCleanup(t)
140-
params.OverrideBeaconConfig(params.MainnetConfig())
140+
params.OverrideBeaconConfig(params.BeaconConfig())
141141
tests := []struct {
142142
name string
143143
initialPubKeys [][]byte

0 commit comments

Comments
 (0)