diff --git a/nbench/scenarios.nim b/nbench/scenarios.nim index 6d2edce24..16839c285 100644 --- a/nbench/scenarios.nim +++ b/nbench/scenarios.nim @@ -145,6 +145,7 @@ proc parseSSZ(path: string, T: typedesc): T = proc runFullTransition*(dir, preState, blocksPrefix: string, blocksQty: int, skipBLS: bool) = let prePath = dir / preState & ".ssz" + var cache = StateCache() echo "Running: ", prePath let state = (ref HashedBeaconState)( @@ -160,7 +161,7 @@ proc runFullTransition*(dir, preState, blocksPrefix: string, blocksQty: int, ski let flags = if skipBLS: {skipBlsValidation} else: {} let success = state_transition( - defaultRuntimePreset, state[], signedBlock, flags, noRollback) + defaultRuntimePreset, state[], signedBlock, cache, flags, noRollback) echo "State transition status: ", if success: "SUCCESS ✓" else: "FAILURE ⚠️" proc runProcessSlots*(dir, preState: string, numSlots: uint64) = diff --git a/ncli/ncli.nim b/ncli/ncli.nim index 9b6b5fb66..05cd2c35b 100644 --- a/ncli/ncli.nim +++ b/ncli/ncli.nim @@ -83,8 +83,9 @@ proc doTransition(conf: NcliConf) = stateY.root = hash_tree_root(stateY.data) + var cache = StateCache() if not state_transition(getRuntimePresetForNetwork(conf.eth2Network), - stateY[], blckX, flags, noRollback): + stateY[], blckX, cache, flags, noRollback): error "State transition failed" quit 1 else: diff --git a/ncli/ncli_db.nim b/ncli/ncli_db.nim index 61900870d..febbed1f8 100644 --- a/ncli/ncli_db.nim +++ b/ncli/ncli_db.nim @@ -127,7 +127,8 @@ proc cmdBench(conf: DbConf, runtimePreset: RuntimePreset) = isEpoch = state[].data.get_current_epoch() != b.message.slot.compute_epoch_at_slot withTimer(timers[if isEpoch: tApplyEpochBlock else: tApplyBlock]): - if not state_transition(runtimePreset, state[], b, {}, noRollback): + var cache = StateCache() + if not state_transition(runtimePreset, state[], b, cache, {}, noRollback): dump("./", b) echo "State transition failed (!)" quit 1 diff --git a/nfuzz/libnfuzz.nim b/nfuzz/libnfuzz.nim index e98f0b5d9..1970a828e 100644 --- a/nfuzz/libnfuzz.nim +++ b/nfuzz/libnfuzz.nim @@ -112,9 +112,12 @@ proc nfuzz_block(input: openArray[byte], xoutput: ptr byte, proc state_transition( preset: RuntimePreset, data: auto, blck: auto, flags: auto, rollback: RollbackHashedProc): auto = - var hashedState = - HashedBeaconState(data: data.state, root: hash_tree_root(data.state)) - result = state_transition(preset, hashedState, blck, flags, rollback) + var + hashedState = + HashedBeaconState(data: data.state, root: hash_tree_root(data.state)) + cache = StateCache() + result = + state_transition(preset, hashedState, blck, cache, flags, rollback) data.state = hashedState.data decodeAndProcess(BlockInput):