mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Remove SSZ tags from beacon state (#11613)
* Remove SSZ tags from beacon state * tests Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
872021f10d
commit
8ade8afb73
@ -90,10 +90,7 @@ go_test(
|
||||
"state_test.go",
|
||||
"state_trie_test.go",
|
||||
"types_test.go",
|
||||
] + select({
|
||||
"//config:mainnet": ["beacon_state_mainnet_test.go"],
|
||||
"//config:minimal": ["beacon_state_minimal_test.go"],
|
||||
}),
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//beacon-chain/core/transition:go_default_library",
|
||||
|
@ -19,36 +19,36 @@ import (
|
||||
// getters and setters for its respective values and helpful functions such as HashTreeRoot().
|
||||
type BeaconState struct {
|
||||
version int
|
||||
genesisTime uint64 `ssz-gen:"true"`
|
||||
genesisValidatorsRoot [32]byte `ssz-gen:"true" ssz-size:"32"`
|
||||
slot eth2types.Slot `ssz-gen:"true"`
|
||||
fork *ethpb.Fork `ssz-gen:"true"`
|
||||
latestBlockHeader *ethpb.BeaconBlockHeader `ssz-gen:"true"`
|
||||
blockRoots *customtypes.BlockRoots `ssz-gen:"true" ssz-size:"8192,32"`
|
||||
stateRoots *customtypes.StateRoots `ssz-gen:"true" ssz-size:"8192,32"`
|
||||
historicalRoots customtypes.HistoricalRoots `ssz-gen:"true" ssz-size:"?,32" ssz-max:"16777216"`
|
||||
eth1Data *ethpb.Eth1Data `ssz-gen:"true"`
|
||||
eth1DataVotes []*ethpb.Eth1Data `ssz-gen:"true" ssz-max:"2048"`
|
||||
eth1DepositIndex uint64 `ssz-gen:"true"`
|
||||
validators []*ethpb.Validator `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
balances []uint64 `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
randaoMixes *customtypes.RandaoMixes `ssz-gen:"true" ssz-size:"65536,32"`
|
||||
slashings []uint64 `ssz-gen:"true" ssz-size:"8192"`
|
||||
previousEpochAttestations []*ethpb.PendingAttestation `ssz-gen:"true" ssz-max:"4096"`
|
||||
currentEpochAttestations []*ethpb.PendingAttestation `ssz-gen:"true" ssz-max:"4096"`
|
||||
previousEpochParticipation []byte `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
currentEpochParticipation []byte `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
justificationBits bitfield.Bitvector4 `ssz-gen:"true" ssz-size:"1"`
|
||||
previousJustifiedCheckpoint *ethpb.Checkpoint `ssz-gen:"true"`
|
||||
currentJustifiedCheckpoint *ethpb.Checkpoint `ssz-gen:"true"`
|
||||
finalizedCheckpoint *ethpb.Checkpoint `ssz-gen:"true"`
|
||||
inactivityScores []uint64 `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
currentSyncCommittee *ethpb.SyncCommittee `ssz-gen:"true"`
|
||||
nextSyncCommittee *ethpb.SyncCommittee `ssz-gen:"true"`
|
||||
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader `ssz-gen:"true"`
|
||||
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella `ssz-gen:"true"`
|
||||
nextWithdrawalIndex uint64 `ssz-gen:"true"`
|
||||
lastWithdrawalValidatorIndex eth2types.ValidatorIndex `ssz-gen:"true"`
|
||||
genesisTime uint64
|
||||
genesisValidatorsRoot [32]byte
|
||||
slot eth2types.Slot
|
||||
fork *ethpb.Fork
|
||||
latestBlockHeader *ethpb.BeaconBlockHeader
|
||||
blockRoots *customtypes.BlockRoots
|
||||
stateRoots *customtypes.StateRoots
|
||||
historicalRoots customtypes.HistoricalRoots
|
||||
eth1Data *ethpb.Eth1Data
|
||||
eth1DataVotes []*ethpb.Eth1Data
|
||||
eth1DepositIndex uint64
|
||||
validators []*ethpb.Validator
|
||||
balances []uint64
|
||||
randaoMixes *customtypes.RandaoMixes
|
||||
slashings []uint64
|
||||
previousEpochAttestations []*ethpb.PendingAttestation
|
||||
currentEpochAttestations []*ethpb.PendingAttestation
|
||||
previousEpochParticipation []byte
|
||||
currentEpochParticipation []byte
|
||||
justificationBits bitfield.Bitvector4
|
||||
previousJustifiedCheckpoint *ethpb.Checkpoint
|
||||
currentJustifiedCheckpoint *ethpb.Checkpoint
|
||||
finalizedCheckpoint *ethpb.Checkpoint
|
||||
inactivityScores []uint64
|
||||
currentSyncCommittee *ethpb.SyncCommittee
|
||||
nextSyncCommittee *ethpb.SyncCommittee
|
||||
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader
|
||||
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
|
||||
nextWithdrawalIndex uint64
|
||||
lastWithdrawalValidatorIndex eth2types.ValidatorIndex
|
||||
|
||||
lock sync.RWMutex
|
||||
dirtyFields map[nativetypes.FieldIndex]bool
|
||||
|
@ -1,87 +0,0 @@
|
||||
//go:build !minimal
|
||||
|
||||
package state_native
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
)
|
||||
|
||||
func TestMainnetSszValuesAgainstFieldParams(t *testing.T) {
|
||||
// Casting needed to avoid lock copy analyzer issue.
|
||||
bs := (interface{})(BeaconState{})
|
||||
bsType := reflect.TypeOf(bs)
|
||||
|
||||
f, ok := bsType.FieldByName("genesisValidatorsRoot")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v := f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("blockRoots")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.BlockRootsLength)+","+strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("stateRoots")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.StateRootsLength)+","+strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("historicalRoots")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, "?,"+strconv.Itoa(fieldparams.RootLength), v)
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.HistoricalRootsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("eth1DataVotes")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.Eth1DataVotesLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("validators")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.ValidatorRegistryLimit), v)
|
||||
|
||||
f, ok = bsType.FieldByName("balances")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.ValidatorRegistryLimit), v)
|
||||
|
||||
f, ok = bsType.FieldByName("randaoMixes")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.RandaoMixesLength)+","+strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("slashings")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.SlashingsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("previousEpochAttestations")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.PreviousEpochAttestationsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("currentEpochAttestations")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.CurrentEpochAttestationsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("justificationBits")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, "1", v)
|
||||
|
||||
f, ok = bsType.FieldByName("inactivityScores")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.ValidatorRegistryLimit), v)
|
||||
}
|
@ -19,36 +19,36 @@ import (
|
||||
// getters and setters for its respective values and helpful functions such as HashTreeRoot().
|
||||
type BeaconState struct {
|
||||
version int
|
||||
genesisTime uint64 `ssz-gen:"true"`
|
||||
genesisValidatorsRoot [32]byte `ssz-gen:"true" ssz-size:"32"`
|
||||
slot eth2types.Slot `ssz-gen:"true"`
|
||||
fork *ethpb.Fork `ssz-gen:"true"`
|
||||
latestBlockHeader *ethpb.BeaconBlockHeader `ssz-gen:"true"`
|
||||
blockRoots *customtypes.BlockRoots `ssz-gen:"true" ssz-size:"64,32"`
|
||||
stateRoots *customtypes.StateRoots `ssz-gen:"true" ssz-size:"64,32"`
|
||||
historicalRoots customtypes.HistoricalRoots `ssz-gen:"true" ssz-size:"?,32" ssz-max:"16777216"`
|
||||
eth1Data *ethpb.Eth1Data `ssz-gen:"true"`
|
||||
eth1DataVotes []*ethpb.Eth1Data `ssz-gen:"true" ssz-max:"32"`
|
||||
eth1DepositIndex uint64 `ssz-gen:"true"`
|
||||
validators []*ethpb.Validator `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
balances []uint64 `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
randaoMixes *customtypes.RandaoMixes `ssz-gen:"true" ssz-size:"64,32"`
|
||||
slashings []uint64 `ssz-gen:"true" ssz-size:"64"`
|
||||
previousEpochAttestations []*ethpb.PendingAttestation `ssz-gen:"true" ssz-max:"1024"`
|
||||
currentEpochAttestations []*ethpb.PendingAttestation `ssz-gen:"true" ssz-max:"1024"`
|
||||
previousEpochParticipation []byte `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
currentEpochParticipation []byte `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
justificationBits bitfield.Bitvector4 `ssz-gen:"true" ssz-size:"1"`
|
||||
previousJustifiedCheckpoint *ethpb.Checkpoint `ssz-gen:"true"`
|
||||
currentJustifiedCheckpoint *ethpb.Checkpoint `ssz-gen:"true"`
|
||||
finalizedCheckpoint *ethpb.Checkpoint `ssz-gen:"true"`
|
||||
inactivityScores []uint64 `ssz-gen:"true" ssz-max:"1099511627776"`
|
||||
currentSyncCommittee *ethpb.SyncCommittee `ssz-gen:"true"`
|
||||
nextSyncCommittee *ethpb.SyncCommittee `ssz-gen:"true"`
|
||||
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader `ssz-gen:"true"`
|
||||
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella `ssz-gen:"true"`
|
||||
nextWithdrawalIndex uint64 `ssz-gen:"true"`
|
||||
lastWithdrawalValidatorIndex eth2types.ValidatorIndex `ssz-gen:"true"`
|
||||
genesisTime uint64
|
||||
genesisValidatorsRoot [32]byte
|
||||
slot eth2types.Slot
|
||||
fork *ethpb.Fork
|
||||
latestBlockHeader *ethpb.BeaconBlockHeader
|
||||
blockRoots *customtypes.BlockRoots
|
||||
stateRoots *customtypes.StateRoots
|
||||
historicalRoots customtypes.HistoricalRoots
|
||||
eth1Data *ethpb.Eth1Data
|
||||
eth1DataVotes []*ethpb.Eth1Data
|
||||
eth1DepositIndex uint64
|
||||
validators []*ethpb.Validator
|
||||
balances []uint64
|
||||
randaoMixes *customtypes.RandaoMixes
|
||||
slashings []uint64
|
||||
previousEpochAttestations []*ethpb.PendingAttestation
|
||||
currentEpochAttestations []*ethpb.PendingAttestation
|
||||
previousEpochParticipation []byte
|
||||
currentEpochParticipation []byte
|
||||
justificationBits bitfield.Bitvector4
|
||||
previousJustifiedCheckpoint *ethpb.Checkpoint
|
||||
currentJustifiedCheckpoint *ethpb.Checkpoint
|
||||
finalizedCheckpoint *ethpb.Checkpoint
|
||||
inactivityScores []uint64
|
||||
currentSyncCommittee *ethpb.SyncCommittee
|
||||
nextSyncCommittee *ethpb.SyncCommittee
|
||||
latestExecutionPayloadHeader *enginev1.ExecutionPayloadHeader
|
||||
latestExecutionPayloadHeaderCapella *enginev1.ExecutionPayloadHeaderCapella
|
||||
nextWithdrawalIndex uint64
|
||||
lastWithdrawalValidatorIndex eth2types.ValidatorIndex
|
||||
|
||||
lock sync.RWMutex
|
||||
dirtyFields map[nativetypes.FieldIndex]bool
|
||||
|
@ -1,86 +0,0 @@
|
||||
//go:build minimal
|
||||
|
||||
package state_native
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
)
|
||||
|
||||
func TestMinimalSszValuesAgainstFieldParams(t *testing.T) {
|
||||
// Casting needed to avoid lock copy analyzer issue.
|
||||
bs := (interface{})(BeaconState{})
|
||||
bsType := reflect.TypeOf(bs)
|
||||
|
||||
f, ok := bsType.FieldByName("genesisValidatorsRoot")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v := f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("blockRoots")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.BlockRootsLength)+","+strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("stateRoots")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.StateRootsLength)+","+strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("historicalRoots")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, "?,"+strconv.Itoa(fieldparams.RootLength), v)
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.HistoricalRootsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("eth1DataVotes")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.Eth1DataVotesLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("validators")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.ValidatorRegistryLimit), v)
|
||||
|
||||
f, ok = bsType.FieldByName("balances")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.ValidatorRegistryLimit), v)
|
||||
|
||||
f, ok = bsType.FieldByName("randaoMixes")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.RandaoMixesLength)+","+strconv.Itoa(fieldparams.RootLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("slashings")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.SlashingsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("previousEpochAttestations")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.PreviousEpochAttestationsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("currentEpochAttestations")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.CurrentEpochAttestationsLength), v)
|
||||
|
||||
f, ok = bsType.FieldByName("justificationBits")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-size")
|
||||
assert.Equal(t, "1", v)
|
||||
|
||||
f, ok = bsType.FieldByName("inactivityScores")
|
||||
require.Equal(t, true, ok, "Required field not found")
|
||||
v = f.Tag.Get("ssz-max")
|
||||
assert.Equal(t, strconv.Itoa(fieldparams.ValidatorRegistryLimit), v)
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
# Script to copy ssz.go files from bazel build folder to appropriate location.
|
||||
# Bazel builds to bazel-bin/... folder, script copies them back to original folder where target is.
|
||||
|
||||
bazel query 'kind(ssz_gen_marshal, //proto/...) union kind(ssz_gen_marshal, //beacon-chain/state/...)' | xargs bazel build
|
||||
bazel query 'kind(ssz_gen_marshal, //proto/...)' | xargs bazel build
|
||||
|
||||
# Get locations of proto ssz.go files.
|
||||
file_list=()
|
||||
|
Loading…
Reference in New Issue
Block a user