diff --git a/beacon_chain/spec/state_transition.nim b/beacon_chain/spec/state_transition.nim index e298fad83..3511d166d 100644 --- a/beacon_chain/spec/state_transition.nim +++ b/beacon_chain/spec/state_transition.nim @@ -86,16 +86,14 @@ func verifyStateRoot( ok() type - RollbackProc* = proc() {.gcsafe, raises: [Defect].} + RollbackProc* = proc() {.gcsafe, noSideEffect, raises: [Defect].} + RollbackHashedProc[T] = + proc(state: var T) {.gcsafe, noSideEffect, raises: [Defect].} + RollbackForkedHashedProc* = RollbackHashedProc[ForkedHashedBeaconState] 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].} - RollbackBellatrixHashedProc* = proc(state: var bellatrix.HashedBeaconState) {.gcsafe, raises: [Defect].} - # Hashed-state transition functions # --------------------------------------------------------------- @@ -236,10 +234,6 @@ proc state_transition_block_aux( ok() -type - RollbackForkedHashedProc* = - proc(state: var ForkedHashedBeaconState) {.gcsafe, raises: [Defect].} - func noRollback*(state: var ForkedHashedBeaconState) = trace "Skipping rollback of broken state" @@ -334,7 +328,7 @@ proc makeBeaconBlock*( exits: BeaconBlockExits, sync_aggregate: SyncAggregate, execution_payload: ExecutionPayload, - rollback: RollbackHashedProc, + rollback: RollbackHashedProc[phase0.HashedBeaconState], cache: var StateCache): Result[phase0.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 @@ -399,7 +393,7 @@ proc makeBeaconBlock*( exits: BeaconBlockExits, sync_aggregate: SyncAggregate, execution_payload: ExecutionPayload, - rollback: RollbackAltairHashedProc, + rollback: RollbackHashedProc[altair.HashedBeaconState], cache: var StateCache): Result[altair.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 @@ -465,7 +459,7 @@ proc makeBeaconBlock*( exits: BeaconBlockExits, sync_aggregate: SyncAggregate, execution_payload: ExecutionPayload, - rollback: RollbackBellatrixHashedProc, + rollback: RollbackHashedProc[bellatrix.HashedBeaconState], 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 diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index 1536c7c77..6c8553530 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -223,7 +223,7 @@ func makeAttestation*( flags: UpdateFlags = {}): Attestation = # Avoids state_sim silliness; as it's responsible for all validators, # transforming, from monotonic enumerable index -> committee index -> - # montonoic enumerable index, is wasteful and slow. Most test callers + # monotonic enumerable index, is wasteful and slow. Most test callers # want ValidatorIndex, so that's supported too. let sac_index = committee.find(validator_index)