rename On{Merge,Bellatrix}BlockAdded and Rollback{Merge,Bellatrix}HashedProc (#3321)
This commit is contained in:
parent
f70aceef37
commit
2b4a960270
|
@ -29,10 +29,10 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
|
|||
+ sanity check Altair blocks [Preset: mainnet] OK
|
||||
+ sanity check Altair states [Preset: mainnet] OK
|
||||
+ sanity check Altair states, reusing buffers [Preset: mainnet] OK
|
||||
+ sanity check Merge and cross-fork getState rollback [Preset: mainnet] OK
|
||||
+ sanity check Merge blocks [Preset: mainnet] OK
|
||||
+ sanity check Merge states [Preset: mainnet] OK
|
||||
+ sanity check Merge states, reusing buffers [Preset: mainnet] OK
|
||||
+ sanity check Bellatrix and cross-fork getState rollback [Preset: mainnet] OK
|
||||
+ sanity check Bellatrix blocks [Preset: mainnet] OK
|
||||
+ sanity check Bellatrix states [Preset: mainnet] OK
|
||||
+ sanity check Bellatrix states, reusing buffers [Preset: mainnet] OK
|
||||
+ sanity check genesis roundtrip [Preset: mainnet] OK
|
||||
+ sanity check phase 0 blocks [Preset: mainnet] OK
|
||||
+ sanity check phase 0 getState rollback [Preset: mainnet] OK
|
||||
|
@ -171,8 +171,8 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
|||
```diff
|
||||
+ load altair block OK
|
||||
+ load altair state OK
|
||||
+ load merge block OK
|
||||
+ load merge state OK
|
||||
+ load bellatrix block OK
|
||||
+ load bellatrix state OK
|
||||
+ load phase0 block OK
|
||||
+ load phase0 state OK
|
||||
+ should raise on unknown data OK
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# beacon_chain
|
||||
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
||||
# Copyright (c) 2018-2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * 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).
|
||||
|
@ -30,7 +30,7 @@ proc addResolvedHeadBlock(
|
|||
state: var StateData,
|
||||
trustedBlock: ForkyTrustedSignedBeaconBlock,
|
||||
parent: BlockRef, cache: var StateCache,
|
||||
onBlockAdded: OnPhase0BlockAdded | OnAltairBlockAdded | OnMergeBlockAdded,
|
||||
onBlockAdded: OnPhase0BlockAdded | OnAltairBlockAdded | OnBellatrixBlockAdded,
|
||||
stateDataDur, sigVerifyDur, stateVerifyDur: Duration
|
||||
): BlockRef =
|
||||
doAssert getStateField(state.data, slot) == trustedBlock.message.slot,
|
||||
|
@ -142,12 +142,14 @@ proc advanceClearanceState*(dag: ChainDAGRef) =
|
|||
proc addHeadBlock*(
|
||||
dag: ChainDAGRef, verifier: var BatchVerifier,
|
||||
signedBlock: ForkySignedBeaconBlock,
|
||||
onBlockAdded: OnPhase0BlockAdded | OnAltairBlockAdded | OnMergeBlockAdded
|
||||
onBlockAdded: OnPhase0BlockAdded | OnAltairBlockAdded |
|
||||
OnBellatrixBlockAdded
|
||||
): Result[BlockRef, BlockError] =
|
||||
## Try adding a block to the chain, verifying first that it passes the state
|
||||
## transition function and contains correct cryptographic signature.
|
||||
##
|
||||
## Cryptographic checks can be skipped by adding skipBLSValidation to dag.updateFlags
|
||||
## Cryptographic checks can be skipped by adding skipBLSValidation to
|
||||
## dag.updateFlags
|
||||
logScope:
|
||||
blockRoot = shortLog(signedBlock.root)
|
||||
blck = shortLog(signedBlock.message)
|
||||
|
|
|
@ -13,7 +13,7 @@ import
|
|||
../spec/datatypes/[phase0, altair],
|
||||
../spec/[helpers]
|
||||
|
||||
export chronicles, phase0, altair, merge, helpers
|
||||
export chronicles, phase0, altair, helpers
|
||||
|
||||
type
|
||||
BlockId* = object
|
||||
|
|
|
@ -216,7 +216,7 @@ type
|
|||
blck: altair.TrustedSignedBeaconBlock,
|
||||
epochRef: EpochRef) {.gcsafe, raises: [Defect].}
|
||||
|
||||
OnMergeBlockAdded* = proc(
|
||||
OnBellatrixBlockAdded* = proc(
|
||||
blckRef: BlockRef,
|
||||
blck: bellatrix.TrustedSignedBeaconBlock,
|
||||
epochRef: EpochRef) {.gcsafe, raises: [Defect].}
|
||||
|
|
|
@ -92,9 +92,9 @@ func noRollback*() =
|
|||
trace "Skipping rollback of broken state"
|
||||
|
||||
type
|
||||
RollbackHashedProc* = proc(state: var phase0.HashedBeaconState) {.gcsafe, raises: [Defect].}
|
||||
RollbackAltairHashedProc* = proc(state: var altair.HashedBeaconState) {.gcsafe, raises: [Defect].}
|
||||
RollbackMergeHashedProc* = proc(state: var bellatrix.HashedBeaconState) {.gcsafe, raises: [Defect].}
|
||||
RollbackHashedProc* = proc(state: var phase0.HashedBeaconState) {.gcsafe, raises: [Defect].}
|
||||
RollbackAltairHashedProc* = proc(state: var altair.HashedBeaconState) {.gcsafe, raises: [Defect].}
|
||||
RollbackBellatrixHashedProc* = proc(state: var bellatrix.HashedBeaconState) {.gcsafe, raises: [Defect].}
|
||||
|
||||
# Hashed-state transition functions
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -465,7 +465,7 @@ proc makeBeaconBlock*(
|
|||
exits: BeaconBlockExits,
|
||||
sync_aggregate: SyncAggregate,
|
||||
execution_payload: ExecutionPayload,
|
||||
rollback: RollbackMergeHashedProc,
|
||||
rollback: RollbackBellatrixHashedProc,
|
||||
cache: var StateCache): Result[bellatrix.BeaconBlock, cstring] =
|
||||
## Create a block for the given state. The latest block applied to it will
|
||||
## be used for the parent_root value, and the slot will be take from
|
||||
|
|
|
@ -364,7 +364,7 @@ MIN_GENESIS_TIME: 0
|
|||
GENESIS_DELAY: 10
|
||||
DEPOSIT_CONTRACT_ADDRESS: ${DEPOSIT_CONTRACT_ADDRESS}
|
||||
ETH1_FOLLOW_DISTANCE: 1
|
||||
ALTAIR_FORK_EPOCH: 2
|
||||
ALTAIR_FORK_EPOCH: 1
|
||||
EOF
|
||||
|
||||
dump_logs() {
|
||||
|
|
|
@ -169,7 +169,7 @@ suite "Beacon chain DB" & preset():
|
|||
|
||||
db.close()
|
||||
|
||||
test "sanity check Merge blocks" & preset():
|
||||
test "sanity check Bellatrix blocks" & preset():
|
||||
var db = BeaconChainDB.new("", inMemory = true)
|
||||
|
||||
let
|
||||
|
@ -244,7 +244,7 @@ suite "Beacon chain DB" & preset():
|
|||
|
||||
db.close()
|
||||
|
||||
test "sanity check Merge states" & preset():
|
||||
test "sanity check Bellatrix states" & preset():
|
||||
var db = makeTestDB(SLOTS_PER_EPOCH)
|
||||
|
||||
for state in testStatesBellatrix:
|
||||
|
@ -302,7 +302,7 @@ suite "Beacon chain DB" & preset():
|
|||
|
||||
db.close()
|
||||
|
||||
test "sanity check Merge states, reusing buffers" & preset():
|
||||
test "sanity check Bellatrix states, reusing buffers" & preset():
|
||||
var db = makeTestDB(SLOTS_PER_EPOCH)
|
||||
let stateBuffer = (bellatrix.BeaconStateRef)()
|
||||
|
||||
|
@ -371,7 +371,7 @@ suite "Beacon chain DB" & preset():
|
|||
state[].kind == BeaconStateFork.Phase0
|
||||
state[].phase0Data.data.slot != 10.Slot
|
||||
|
||||
test "sanity check Merge and cross-fork getState rollback" & preset():
|
||||
test "sanity check Bellatrix and cross-fork getState rollback" & preset():
|
||||
var
|
||||
db = makeTestDB(SLOTS_PER_EPOCH)
|
||||
validatorMonitor = newClone(ValidatorMonitor.init())
|
||||
|
|
|
@ -57,7 +57,7 @@ suite "Forked SSZ readers":
|
|||
expect(SszError):
|
||||
testHashedBeaconState(bellatrix.BeaconState, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||
|
||||
test "load merge state":
|
||||
test "load bellatrix state":
|
||||
testHashedBeaconState(bellatrix.BeaconState, cfg.MERGE_FORK_EPOCH.start_slot)
|
||||
|
||||
expect(SszError):
|
||||
|
@ -88,7 +88,7 @@ suite "Forked SSZ readers":
|
|||
testTrustedSignedBeaconBlock(
|
||||
bellatrix.TrustedSignedBeaconBlock, cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||
|
||||
test "load merge block":
|
||||
test "load bellatrix block":
|
||||
testTrustedSignedBeaconBlock(
|
||||
bellatrix.TrustedSignedBeaconBlock, cfg.MERGE_FORK_EPOCH.start_slot)
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ suite "Gossip validation - Extra": # Not based on preset config
|
|||
const nilCallback = OnAltairBlockAdded(nil)
|
||||
dag.addHeadBlock(verifier, blck.altairData, nilCallback)
|
||||
of BeaconBlockFork.Bellatrix:
|
||||
const nilCallback = OnMergeBlockAdded(nil)
|
||||
const nilCallback = OnBellatrixBlockAdded(nil)
|
||||
dag.addHeadBlock(verifier, blck.bellatrixData, nilCallback)
|
||||
check: added.isOk()
|
||||
dag.updateHead(added[], quarantine[])
|
||||
|
|
Loading…
Reference in New Issue