update 10 modules from using merge to bellatrix (#3257)

This commit is contained in:
tersec 2022-01-07 17:10:40 +00:00 committed by GitHub
parent ba99c8fe4f
commit bac0eaa92e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 52 deletions

View File

@ -1,5 +1,5 @@
# beacon_chain # beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -14,7 +14,7 @@ import
eth/db/[kvstore, kvstore_sqlite3], eth/db/[kvstore, kvstore_sqlite3],
./networking/network_metadata, ./beacon_chain_db_immutable, ./networking/network_metadata, ./beacon_chain_db_immutable,
./spec/[eth2_ssz_serialization, eth2_merkleization, forks, state_transition], ./spec/[eth2_ssz_serialization, eth2_merkleization, forks, state_transition],
./spec/datatypes/[phase0, altair, merge], ./spec/datatypes/[phase0, altair, bellatrix],
./filepath ./filepath
export export
@ -91,7 +91,7 @@ type
keyValues: KvStoreRef # Random stuff using DbKeyKind - suitable for small values mainly! keyValues: KvStoreRef # Random stuff using DbKeyKind - suitable for small values mainly!
blocks: KvStoreRef # BlockRoot -> phase0.TrustedBeaconBlock blocks: KvStoreRef # BlockRoot -> phase0.TrustedBeaconBlock
altairBlocks: KvStoreRef # BlockRoot -> altair.TrustedBeaconBlock altairBlocks: KvStoreRef # BlockRoot -> altair.TrustedBeaconBlock
mergeBlocks: KvStoreRef # BlockRoot -> merge.TrustedBeaconBlock mergeBlocks: KvStoreRef # BlockRoot -> bellatrix.TrustedBeaconBlock
stateRoots: KvStoreRef # (Slot, BlockRoot) -> StateRoot stateRoots: KvStoreRef # (Slot, BlockRoot) -> StateRoot
statesNoVal: KvStoreRef # StateRoot -> Phase0BeaconStateNoImmutableValidators statesNoVal: KvStoreRef # StateRoot -> Phase0BeaconStateNoImmutableValidators
altairStatesNoVal: KvStoreRef # StateRoot -> AltairBeaconStateNoImmutableValidators altairStatesNoVal: KvStoreRef # StateRoot -> AltairBeaconStateNoImmutableValidators
@ -494,7 +494,7 @@ proc putBlock*(db: BeaconChainDB, value: altair.TrustedSignedBeaconBlock) =
db.altairBlocks.putSnappySSZ(value.root.data, value) db.altairBlocks.putSnappySSZ(value.root.data, value)
db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary()) db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary())
proc putBlock*(db: BeaconChainDB, value: merge.TrustedSignedBeaconBlock) = proc putBlock*(db: BeaconChainDB, value: bellatrix.TrustedSignedBeaconBlock) =
db.mergeBlocks.putSnappySSZ(value.root.data, value) db.mergeBlocks.putSnappySSZ(value.root.data, value)
db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary()) db.putBeaconBlockSummary(value.root, value.message.toBeaconBlockSummary())
@ -519,7 +519,7 @@ template toBeaconStateNoImmutableValidators(state: altair.BeaconState):
AltairBeaconStateNoImmutableValidators = AltairBeaconStateNoImmutableValidators =
isomorphicCast[AltairBeaconStateNoImmutableValidators](state) isomorphicCast[AltairBeaconStateNoImmutableValidators](state)
template toBeaconStateNoImmutableValidators(state: merge.BeaconState): template toBeaconStateNoImmutableValidators(state: bellatrix.BeaconState):
MergeBeaconStateNoImmutableValidators = MergeBeaconStateNoImmutableValidators =
isomorphicCast[MergeBeaconStateNoImmutableValidators](state) isomorphicCast[MergeBeaconStateNoImmutableValidators](state)
@ -533,7 +533,7 @@ proc putState*(db: BeaconChainDB, key: Eth2Digest, value: altair.BeaconState) =
db.altairStatesNoVal.putSnappySSZ( db.altairStatesNoVal.putSnappySSZ(
key.data, toBeaconStateNoImmutableValidators(value)) key.data, toBeaconStateNoImmutableValidators(value))
proc putState*(db: BeaconChainDB, key: Eth2Digest, value: merge.BeaconState) = proc putState*(db: BeaconChainDB, key: Eth2Digest, value: bellatrix.BeaconState) =
db.updateImmutableValidators(value.validators.asSeq()) db.updateImmutableValidators(value.validators.asSeq())
db.mergeStatesNoVal.putSnappySSZ( db.mergeStatesNoVal.putSnappySSZ(
key.data, toBeaconStateNoImmutableValidators(value)) key.data, toBeaconStateNoImmutableValidators(value))
@ -624,9 +624,9 @@ proc getAltairBlock*(db: BeaconChainDB, key: Eth2Digest):
result.err() result.err()
proc getMergeBlock*(db: BeaconChainDB, key: Eth2Digest): proc getMergeBlock*(db: BeaconChainDB, key: Eth2Digest):
Opt[merge.TrustedSignedBeaconBlock] = Opt[bellatrix.TrustedSignedBeaconBlock] =
# We only store blocks that we trust in the database # We only store blocks that we trust in the database
result.ok(default(merge.TrustedSignedBeaconBlock)) result.ok(default(bellatrix.TrustedSignedBeaconBlock))
if db.mergeBlocks.getSnappySSZ(key.data, result.get) == GetResult.found: if db.mergeBlocks.getSnappySSZ(key.data, result.get) == GetResult.found:
# set root after deserializing (so it doesn't get zeroed) # set root after deserializing (so it doesn't get zeroed)
result.get().root = key result.get().root = key
@ -773,7 +773,7 @@ proc getState*(
db.immutableValidators, db.altairStatesNoVal, key.data, output, rollback) db.immutableValidators, db.altairStatesNoVal, key.data, output, rollback)
proc getState*( proc getState*(
db: BeaconChainDB, key: Eth2Digest, output: var merge.BeaconState, db: BeaconChainDB, key: Eth2Digest, output: var bellatrix.BeaconState,
rollback: RollbackProc): bool = rollback: RollbackProc): bool =
## Load state into `output` - BeaconState is large so we want to avoid ## Load state into `output` - BeaconState is large so we want to avoid
## re-allocating it if possible ## re-allocating it if possible

View File

@ -1,5 +1,5 @@
# beacon_chain # beacon_chain
# Copyright (c) 2021 Status Research & Development GmbH # Copyright (c) 2021-2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -11,7 +11,7 @@ import
stew/[assign2, results], stew/[assign2, results],
serialization, serialization,
eth/db/kvstore, eth/db/kvstore,
./spec/datatypes/[base, altair, merge], ./spec/datatypes/[base, altair, bellatrix],
./spec/[eth2_ssz_serialization, eth2_merkleization] ./spec/[eth2_ssz_serialization, eth2_merkleization]
type type

View File

@ -1,5 +1,5 @@
# beacon_chain # beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -15,12 +15,12 @@ import
chronicles, stew/byteutils, chronicles, stew/byteutils,
# Internal # Internal
../spec/[beaconstate, eth2_merkleization, forks, helpers, validator], ../spec/[beaconstate, eth2_merkleization, forks, helpers, validator],
../spec/datatypes/[phase0, altair, merge], ../spec/datatypes/[phase0, altair, bellatrix],
"."/[spec_cache, blockchain_dag, block_quarantine], "."/[spec_cache, blockchain_dag, block_quarantine],
../fork_choice/fork_choice, ../fork_choice/fork_choice,
../beacon_clock ../beacon_clock
export options, tables, phase0, altair, merge, blockchain_dag, fork_choice export options, tables, phase0, altair, bellatrix, blockchain_dag, fork_choice
const const
ATTESTATION_LOOKBACK* = ATTESTATION_LOOKBACK* =
@ -450,7 +450,7 @@ func init(T: type AttestationCache, state: phase0.HashedBeaconState): T =
func init( func init(
T: type AttestationCache, T: type AttestationCache,
state: altair.HashedBeaconState | merge.HashedBeaconState, state: altair.HashedBeaconState | bellatrix.HashedBeaconState,
cache: var StateCache): T = cache: var StateCache): T =
# Load attestations that are scheduled for being given rewards for # Load attestations that are scheduled for being given rewards for
let let
@ -533,7 +533,7 @@ proc getAttestationsForBlock*(pool: var AttestationPool,
attCache = attCache =
when state is phase0.HashedBeaconState: when state is phase0.HashedBeaconState:
AttestationCache.init(state) AttestationCache.init(state)
elif state is altair.HashedBeaconState or state is merge.HashedBeaconState: elif state is altair.HashedBeaconState or state is bellatrix.HashedBeaconState:
AttestationCache.init(state, cache) AttestationCache.init(state, cache)
else: else:
static: doAssert false static: doAssert false
@ -588,7 +588,7 @@ proc getAttestationsForBlock*(pool: var AttestationPool,
var var
prevEpoch = state.data.get_previous_epoch() prevEpoch = state.data.get_previous_epoch()
prevEpochSpace = prevEpochSpace =
when state is altair.HashedBeaconState or state is merge.HashedBeaconState: when state is altair.HashedBeaconState or state is bellatrix.HashedBeaconState:
MAX_ATTESTATIONS MAX_ATTESTATIONS
elif state is phase0.HashedBeaconState: elif state is phase0.HashedBeaconState:
state.data.previous_epoch_attestations.maxLen - state.data.previous_epoch_attestations.maxLen -

View File

@ -1,5 +1,5 @@
# beacon_chain # beacon_chain
# Copyright (c) 2018-2021 Status Research & Development GmbH # Copyright (c) 2018-2022 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -14,7 +14,7 @@ import
stew/endians2, chronicles, stew/endians2, chronicles,
# Internals # Internals
../spec/[signatures_batch, forks, helpers], ../spec/[signatures_batch, forks, helpers],
../spec/datatypes/[phase0, altair, merge], ../spec/datatypes/[phase0, altair, bellatrix],
".."/beacon_chain_db, ".."/beacon_chain_db,
../validators/validator_monitor, ../validators/validator_monitor,
./block_dag ./block_dag
@ -226,7 +226,7 @@ type
OnMergeBlockAdded* = proc( OnMergeBlockAdded* = proc(
blckRef: BlockRef, blckRef: BlockRef,
blck: merge.TrustedSignedBeaconBlock, blck: bellatrix.TrustedSignedBeaconBlock,
epochRef: EpochRef) {.gcsafe, raises: [Defect].} epochRef: EpochRef) {.gcsafe, raises: [Defect].}
HeadChangeInfoObject* = object HeadChangeInfoObject* = object

View File

@ -15,7 +15,7 @@ import
# Internal # Internal
../beacon_clock, ../beacon_clock,
../spec/[beaconstate, helpers], ../spec/[beaconstate, helpers],
../spec/datatypes/[phase0, altair, merge], ../spec/datatypes/[phase0, altair, bellatrix],
# Fork choice # Fork choice
./fork_choice_types, ./proto_array, ./fork_choice_types, ./proto_array,
../consensus_object_pools/[spec_cache, blockchain_dag] ../consensus_object_pools/[spec_cache, blockchain_dag]
@ -337,9 +337,9 @@ func process_block*(self: var ForkChoiceBackend,
# blck: SomeSomeBeaconBlock # blck: SomeSomeBeaconBlock
# as comes up. Other types can be added as needed. # as comes up. Other types can be added as needed.
type ReallyAnyBeaconBlock = type ReallyAnyBeaconBlock =
phase0.BeaconBlock | altair.BeaconBlock | merge.BeaconBlock | phase0.BeaconBlock | altair.BeaconBlock | bellatrix.BeaconBlock |
phase0.TrustedBeaconBlock | altair.TrustedBeaconBlock | phase0.TrustedBeaconBlock | altair.TrustedBeaconBlock |
merge.TrustedBeaconBlock bellatrix.TrustedBeaconBlock
proc process_block*(self: var ForkChoice, proc process_block*(self: var ForkChoice,
dag: ChainDAGRef, dag: ChainDAGRef,
epochRef: EpochRef, epochRef: EpochRef,

View File

@ -12,7 +12,7 @@ import
os, os,
# Beacon chain internals # Beacon chain internals
../../../beacon_chain/spec/[beaconstate, helpers], ../../../beacon_chain/spec/[beaconstate, helpers],
../../../beacon_chain/spec/datatypes/[altair, merge], ../../../beacon_chain/spec/datatypes/[altair, bellatrix],
# Test utilities # Test utilities
../../testutil, ../../testutil,
../fixtures_utils, ../fixtures_utils,
@ -29,7 +29,7 @@ proc runTest(identifier: string) =
preState = newClone( preState = newClone(
parseTest(testDir/"pre.ssz_snappy", SSZ, altair.BeaconState)) parseTest(testDir/"pre.ssz_snappy", SSZ, altair.BeaconState))
postState = newClone( postState = newClone(
parseTest(testDir/"post.ssz_snappy", SSZ, merge.BeaconState)) parseTest(testDir/"post.ssz_snappy", SSZ, bellatrix.BeaconState))
var cfg = defaultRuntimeConfig var cfg = defaultRuntimeConfig

View File

@ -16,7 +16,7 @@ import
stew/results, stew/results,
# Beacon chain internals # Beacon chain internals
../../../beacon_chain/spec/[beaconstate, state_transition_block], ../../../beacon_chain/spec/[beaconstate, state_transition_block],
../../../beacon_chain/spec/datatypes/merge, ../../../beacon_chain/spec/datatypes/bellatrix,
# Test utilities # Test utilities
../../testutil, ../../testutil,
../fixtures_utils, ../fixtures_utils,
@ -55,13 +55,14 @@ proc runTest[T, U](
test prefix & baseDescription & testSuiteName & " - " & identifier: test prefix & baseDescription & testSuiteName & " - " & identifier:
var preState = newClone( var preState = newClone(
parseTest(testDir/"pre.ssz_snappy", SSZ, merge.BeaconState)) parseTest(testDir/"pre.ssz_snappy", SSZ, bellatrix.BeaconState))
let done = applyProc( let done = applyProc(
preState[], parseTest(testDir/(applyFile & ".ssz_snappy"), SSZ, T)) preState[], parseTest(testDir/(applyFile & ".ssz_snappy"), SSZ, T))
if existsFile(testDir/"post.ssz_snappy"): if existsFile(testDir/"post.ssz_snappy"):
let postState = let postState =
newClone(parseTest(testDir/"post.ssz_snappy", SSZ, merge.BeaconState)) newClone(parseTest(
testDir/"post.ssz_snappy", SSZ, bellatrix.BeaconState))
check: check:
done.isOk() done.isOk()
@ -74,7 +75,7 @@ proc runTest[T, U](
suite baseDescription & "Attestation " & preset(): suite baseDescription & "Attestation " & preset():
proc applyAttestation( proc applyAttestation(
preState: var merge.BeaconState, attestation: Attestation): preState: var bellatrix.BeaconState, attestation: Attestation):
Result[void, cstring] = Result[void, cstring] =
var cache = StateCache() var cache = StateCache()
let let
@ -91,7 +92,7 @@ suite baseDescription & "Attestation " & preset():
suite baseDescription & "Attester Slashing " & preset(): suite baseDescription & "Attester Slashing " & preset():
proc applyAttesterSlashing( proc applyAttesterSlashing(
preState: var merge.BeaconState, attesterSlashing: AttesterSlashing): preState: var bellatrix.BeaconState, attesterSlashing: AttesterSlashing):
Result[void, cstring] = Result[void, cstring] =
var cache = StateCache() var cache = StateCache()
process_attester_slashing( process_attester_slashing(
@ -104,18 +105,18 @@ suite baseDescription & "Attester Slashing " & preset():
suite baseDescription & "Block Header " & preset(): suite baseDescription & "Block Header " & preset():
func applyBlockHeader( func applyBlockHeader(
preState: var merge.BeaconState, blck: merge.BeaconBlock): preState: var bellatrix.BeaconState, blck: bellatrix.BeaconBlock):
Result[void, cstring] = Result[void, cstring] =
var cache = StateCache() var cache = StateCache()
process_block_header(preState, blck, {}, cache) process_block_header(preState, blck, {}, cache)
for path in walkTests(OpBlockHeaderDir): for path in walkTests(OpBlockHeaderDir):
runTest[merge.BeaconBlock, typeof applyBlockHeader]( runTest[bellatrix.BeaconBlock, typeof applyBlockHeader](
OpBlockHeaderDir, "Block Header", "block", applyBlockHeader, path) OpBlockHeaderDir, "Block Header", "block", applyBlockHeader, path)
suite baseDescription & "Deposit " & preset(): suite baseDescription & "Deposit " & preset():
proc applyDeposit( proc applyDeposit(
preState: var merge.BeaconState, deposit: Deposit): preState: var bellatrix.BeaconState, deposit: Deposit):
Result[void, cstring] = Result[void, cstring] =
process_deposit(defaultRuntimeConfig, preState, deposit, {}) process_deposit(defaultRuntimeConfig, preState, deposit, {})
@ -126,7 +127,8 @@ suite baseDescription & "Deposit " & preset():
suite baseDescription & "Execution Payload " & preset(): suite baseDescription & "Execution Payload " & preset():
for path in walkTests(OpExecutionPayloadDir): for path in walkTests(OpExecutionPayloadDir):
proc applyExecutionPayload( proc applyExecutionPayload(
preState: var merge.BeaconState, executionPayload: ExecutionPayload): preState: var bellatrix.BeaconState,
executionPayload: ExecutionPayload):
Result[void, cstring] = Result[void, cstring] =
let payloadValid = let payloadValid =
readFile(OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml"). readFile(OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml").
@ -141,7 +143,7 @@ suite baseDescription & "Execution Payload " & preset():
suite baseDescription & "Proposer Slashing " & preset(): suite baseDescription & "Proposer Slashing " & preset():
proc applyProposerSlashing( proc applyProposerSlashing(
preState: var merge.BeaconState, proposerSlashing: ProposerSlashing): preState: var bellatrix.BeaconState, proposerSlashing: ProposerSlashing):
Result[void, cstring] = Result[void, cstring] =
var cache = StateCache() var cache = StateCache()
process_proposer_slashing( process_proposer_slashing(
@ -154,7 +156,7 @@ suite baseDescription & "Proposer Slashing " & preset():
suite baseDescription & "Sync Aggregate " & preset(): suite baseDescription & "Sync Aggregate " & preset():
proc applySyncAggregate( proc applySyncAggregate(
preState: var merge.BeaconState, syncAggregate: SyncAggregate): preState: var bellatrix.BeaconState, syncAggregate: SyncAggregate):
Result[void, cstring] = Result[void, cstring] =
var cache = StateCache() var cache = StateCache()
process_sync_aggregate( process_sync_aggregate(
@ -167,7 +169,7 @@ suite baseDescription & "Sync Aggregate " & preset():
suite baseDescription & "Voluntary Exit " & preset(): suite baseDescription & "Voluntary Exit " & preset():
proc applyVoluntaryExit( proc applyVoluntaryExit(
preState: var merge.BeaconState, voluntaryExit: SignedVoluntaryExit): preState: var bellatrix.BeaconState, voluntaryExit: SignedVoluntaryExit):
Result[void, cstring] = Result[void, cstring] =
var cache = StateCache() var cache = StateCache()
process_voluntary_exit( process_voluntary_exit(

View File

@ -14,7 +14,7 @@ import
chronicles, chronicles,
# Beacon chain internals # Beacon chain internals
../../../beacon_chain/spec/[forks, state_transition], ../../../beacon_chain/spec/[forks, state_transition],
../../../beacon_chain/spec/datatypes/merge, ../../../beacon_chain/spec/datatypes/bellatrix,
# Test utilities # Test utilities
../../testutil, ../../testutil,
../../helpers/debug_state, ../../helpers/debug_state,
@ -34,8 +34,9 @@ proc runTest(testName, testDir, unitTestName: string) =
test prefix & testName & " - " & unitTestName & preset(): test prefix & testName & " - " & unitTestName & preset():
var var
preState = newClone(parseTest(testPath/"pre.ssz_snappy", SSZ, merge.BeaconState)) preState = newClone(parseTest(
fhPreState = (ref ForkedHashedBeaconState)(mergeData: merge.HashedBeaconState( testPath/"pre.ssz_snappy", SSZ, bellatrix.BeaconState))
fhPreState = (ref ForkedHashedBeaconState)(mergeData: bellatrix.HashedBeaconState(
data: preState[], root: hash_tree_root(preState[])), data: preState[], root: hash_tree_root(preState[])),
kind: BeaconStateFork.Bellatrix) kind: BeaconStateFork.Bellatrix)
cache = StateCache() cache = StateCache()
@ -47,7 +48,9 @@ proc runTest(testName, testDir, unitTestName: string) =
if numBlocks > 1: if numBlocks > 1:
return return
for i in 0 ..< numBlocks: for i in 0 ..< numBlocks:
let blck = parseTest(testPath/"blocks_" & $i & ".ssz_snappy", SSZ, merge.SignedBeaconBlock) let blck = parseTest(
testPath/"blocks_" & $i & ".ssz_snappy", SSZ,
bellatrix.SignedBeaconBlock)
if hasPostState: if hasPostState:
let success = state_transition( let success = state_transition(
@ -62,7 +65,8 @@ proc runTest(testName, testDir, unitTestName: string) =
"We didn't expect these invalid blocks to be processed" "We didn't expect these invalid blocks to be processed"
if hasPostState: if hasPostState:
let postState = newClone(parseTest(testPath/"post.ssz_snappy", SSZ, merge.BeaconState)) let postState = newClone(parseTest(
testPath/"post.ssz_snappy", SSZ, bellatrix.BeaconState))
when false: when false:
reportDiff(fhPreState.mergeData.data, postState) reportDiff(fhPreState.mergeData.data, postState)
doAssert getStateRoot(fhPreState[]) == postState[].hash_tree_root() doAssert getStateRoot(fhPreState[]) == postState[].hash_tree_root()

View File

@ -12,7 +12,7 @@ import
os, strutils, os, strutils,
# Beacon chain internals # Beacon chain internals
../../../beacon_chain/spec/[forks, state_transition], ../../../beacon_chain/spec/[forks, state_transition],
../../../beacon_chain/spec/datatypes/merge, ../../../beacon_chain/spec/datatypes/bellatrix,
# Test utilities # Test utilities
../../testutil, ../../testutil,
../fixtures_utils, ../fixtures_utils,
@ -28,14 +28,16 @@ proc runTest(identifier: string) =
proc `testImpl _ slots _ identifier`() = proc `testImpl _ slots _ identifier`() =
test "Slots - " & identifier: test "Slots - " & identifier:
var var
preState = newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, merge.BeaconState)) preState = newClone(parseTest(
testDir/"pre.ssz_snappy", SSZ, bellatrix.BeaconState))
fhPreState = (ref ForkedHashedBeaconState)( fhPreState = (ref ForkedHashedBeaconState)(
mergeData: merge.HashedBeaconState( mergeData: bellatrix.HashedBeaconState(
data: preState[], root: hash_tree_root(preState[])), data: preState[], root: hash_tree_root(preState[])),
kind: BeaconStateFork.Bellatrix) kind: BeaconStateFork.Bellatrix)
cache = StateCache() cache = StateCache()
info = ForkedEpochInfo() info = ForkedEpochInfo()
let postState = newClone(parseTest(testDir/"post.ssz_snappy", SSZ, merge.BeaconState)) let postState = newClone(parseTest(
testDir/"post.ssz_snappy", SSZ, bellatrix.BeaconState))
check: check:
process_slots( process_slots(

View File

@ -14,7 +14,7 @@ import
# Third-party # Third-party
yaml, yaml,
# Beacon chain internals # Beacon chain internals
../../beacon_chain/spec/datatypes/merge, ../../beacon_chain/spec/datatypes/bellatrix,
# Status libraries # Status libraries
snappy, snappy,
# Test utilities # Test utilities
@ -39,7 +39,7 @@ type
# Note this only tracks HashTreeRoot # Note this only tracks HashTreeRoot
# Checking the values against the yaml file is TODO (require more flexible Yaml parser) # Checking the values against the yaml file is TODO (require more flexible Yaml parser)
proc checkSSZ(T: type merge.SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) = proc checkSSZ(T: type bellatrix.SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) =
# Deserialize into a ref object to not fill Nim stack # Deserialize into a ref object to not fill Nim stack
let encoded = snappy.decode( let encoded = snappy.decode(
readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize)
@ -99,10 +99,10 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset():
of "Attestation": checkSSZ(Attestation, path, hash) of "Attestation": checkSSZ(Attestation, path, hash)
of "AttestationData": checkSSZ(AttestationData, path, hash) of "AttestationData": checkSSZ(AttestationData, path, hash)
of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash) of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash)
of "BeaconBlock": checkSSZ(merge.BeaconBlock, path, hash) of "BeaconBlock": checkSSZ(bellatrix.BeaconBlock, path, hash)
of "BeaconBlockBody": checkSSZ(merge.BeaconBlockBody, path, hash) of "BeaconBlockBody": checkSSZ(bellatrix.BeaconBlockBody, path, hash)
of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash) of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash)
of "BeaconState": checkSSZ(merge.BeaconState, path, hash) of "BeaconState": checkSSZ(bellatrix.BeaconState, path, hash)
of "Checkpoint": checkSSZ(Checkpoint, path, hash) of "Checkpoint": checkSSZ(Checkpoint, path, hash)
of "ContributionAndProof": checkSSZ(ContributionAndProof, path, hash) of "ContributionAndProof": checkSSZ(ContributionAndProof, path, hash)
of "Deposit": checkSSZ(Deposit, path, hash) of "Deposit": checkSSZ(Deposit, path, hash)
@ -123,7 +123,8 @@ suite "EF - Bellatrix - SSZ consensus objects " & preset():
of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash) of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash)
of "SignedAggregateAndProof": of "SignedAggregateAndProof":
checkSSZ(SignedAggregateAndProof, path, hash) checkSSZ(SignedAggregateAndProof, path, hash)
of "SignedBeaconBlock": checkSSZ(merge.SignedBeaconBlock, path, hash) of "SignedBeaconBlock":
checkSSZ(bellatrix.SignedBeaconBlock, path, hash)
of "SignedBeaconBlockHeader": of "SignedBeaconBlockHeader":
checkSSZ(SignedBeaconBlockHeader, path, hash) checkSSZ(SignedBeaconBlockHeader, path, hash)
of "SignedContributionAndProof": of "SignedContributionAndProof":