mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-08 12:44:34 +00:00
clean up hashed rollback proc declarations (#3333)
* clean up hashed rollback proc declarations * use generic hashed rollback proc type
This commit is contained in:
parent
1287a20b13
commit
95fee10328
@ -86,16 +86,14 @@ func verifyStateRoot(
|
|||||||
ok()
|
ok()
|
||||||
|
|
||||||
type
|
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*() =
|
func noRollback*() =
|
||||||
trace "Skipping rollback of broken state"
|
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
|
# Hashed-state transition functions
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
@ -236,10 +234,6 @@ proc state_transition_block_aux(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
type
|
|
||||||
RollbackForkedHashedProc* =
|
|
||||||
proc(state: var ForkedHashedBeaconState) {.gcsafe, raises: [Defect].}
|
|
||||||
|
|
||||||
func noRollback*(state: var ForkedHashedBeaconState) =
|
func noRollback*(state: var ForkedHashedBeaconState) =
|
||||||
trace "Skipping rollback of broken state"
|
trace "Skipping rollback of broken state"
|
||||||
|
|
||||||
@ -334,7 +328,7 @@ proc makeBeaconBlock*(
|
|||||||
exits: BeaconBlockExits,
|
exits: BeaconBlockExits,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
execution_payload: ExecutionPayload,
|
execution_payload: ExecutionPayload,
|
||||||
rollback: RollbackHashedProc,
|
rollback: RollbackHashedProc[phase0.HashedBeaconState],
|
||||||
cache: var StateCache): Result[phase0.BeaconBlock, cstring] =
|
cache: var StateCache): Result[phase0.BeaconBlock, cstring] =
|
||||||
## Create a block for the given state. The latest block applied to it will
|
## 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
|
## be used for the parent_root value, and the slot will be take from
|
||||||
@ -399,7 +393,7 @@ proc makeBeaconBlock*(
|
|||||||
exits: BeaconBlockExits,
|
exits: BeaconBlockExits,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
execution_payload: ExecutionPayload,
|
execution_payload: ExecutionPayload,
|
||||||
rollback: RollbackAltairHashedProc,
|
rollback: RollbackHashedProc[altair.HashedBeaconState],
|
||||||
cache: var StateCache): Result[altair.BeaconBlock, cstring] =
|
cache: var StateCache): Result[altair.BeaconBlock, cstring] =
|
||||||
## Create a block for the given state. The latest block applied to it will
|
## 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
|
## be used for the parent_root value, and the slot will be take from
|
||||||
@ -465,7 +459,7 @@ proc makeBeaconBlock*(
|
|||||||
exits: BeaconBlockExits,
|
exits: BeaconBlockExits,
|
||||||
sync_aggregate: SyncAggregate,
|
sync_aggregate: SyncAggregate,
|
||||||
execution_payload: ExecutionPayload,
|
execution_payload: ExecutionPayload,
|
||||||
rollback: RollbackBellatrixHashedProc,
|
rollback: RollbackHashedProc[bellatrix.HashedBeaconState],
|
||||||
cache: var StateCache): Result[bellatrix.BeaconBlock, cstring] =
|
cache: var StateCache): Result[bellatrix.BeaconBlock, cstring] =
|
||||||
## Create a block for the given state. The latest block applied to it will
|
## 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
|
## be used for the parent_root value, and the slot will be take from
|
||||||
|
@ -223,7 +223,7 @@ func makeAttestation*(
|
|||||||
flags: UpdateFlags = {}): Attestation =
|
flags: UpdateFlags = {}): Attestation =
|
||||||
# Avoids state_sim silliness; as it's responsible for all validators,
|
# Avoids state_sim silliness; as it's responsible for all validators,
|
||||||
# transforming, from monotonic enumerable index -> committee index ->
|
# 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.
|
# want ValidatorIndex, so that's supported too.
|
||||||
let
|
let
|
||||||
sac_index = committee.find(validator_index)
|
sac_index = committee.find(validator_index)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user