clean up hashed rollback proc declarations (#3333)

* clean up hashed rollback proc declarations

* use generic hashed rollback proc type
This commit is contained in:
tersec 2022-01-28 14:24:37 +00:00 committed by GitHub
parent 1287a20b13
commit 95fee10328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View File

@ -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

View File

@ -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)