This commit is contained in:
Jacek Sieka 2020-10-22 20:53:40 +02:00 committed by zah
parent 7c0b4d28d2
commit b246d51ac1
3 changed files with 18 additions and 17 deletions

View File

@ -15,7 +15,8 @@ import
datatypes, crypto, helpers, beaconstate, helpers,
state_transition_block, state_transition_epoch, state_transition],
../beacon_chain/extras,
../beacon_chain/ssz/[merkleization, ssz_serialization]
../beacon_chain/ssz/[merkleization, ssz_serialization],
../tests/official/fixtures_utils
# Nimbus Bench - Scenario configuration
# --------------------------------------------------
@ -253,7 +254,7 @@ template genProcessBlockScenario(name, transitionFn,
genProcessEpochScenario(runProcessJustificationFinalization,
process_justification_and_finalization,
needCache = true)
needCache = false)
genProcessEpochScenario(runProcessRegistryUpdates,
process_registry_updates,
@ -261,7 +262,7 @@ genProcessEpochScenario(runProcessRegistryUpdates,
genProcessEpochScenario(runProcessSlashings,
process_slashings,
needCache = true)
needCache = false)
genProcessEpochScenario(runProcessFinalUpdates,
process_final_updates,

View File

@ -10,7 +10,7 @@ import
os, strutils, typetraits,
# Internals
../../beacon_chain/ssz,
../../beacon_chain/spec/[datatypes, crypto],
../../beacon_chain/spec/[datatypes, crypto, state_transition_epoch],
# Status libs
stew/byteutils,
serialization, json_serialization
@ -64,3 +64,16 @@ proc sszDecodeEntireInput*(input: openarray[byte], Decoded: type): Decoded =
if stream.readable:
raise newException(UnconsumedInput, "Remaining bytes in the input")
proc process_justification_and_finalization*(state: var BeaconState) =
var cache = StateCache()
var validator_statuses = ValidatorStatuses.init(state)
validator_statuses.process_attestations(state, cache)
process_justification_and_finalization(state, validator_statuses.total_balances)
proc process_slashings*(state: var BeaconState) =
var cache = StateCache()
var validator_statuses = ValidatorStatuses.init(state)
validator_statuses.process_attestations(state, cache)
process_slashings(state, validator_statuses.total_balances.current_epoch)

View File

@ -27,19 +27,6 @@ from ../../beacon_chain/spec/beaconstate import process_registry_updates
#
# We store the state on the heap to avoid that
proc process_justification_and_finalization(state: var BeaconState) =
var cache = StateCache()
var validator_statuses = ValidatorStatuses.init(state)
validator_statuses.process_attestations(state, cache)
process_justification_and_finalization(state, validator_statuses.total_balances)
proc process_slashings(state: var BeaconState) =
var cache = StateCache()
var validator_statuses = ValidatorStatuses.init(state)
validator_statuses.process_attestations(state, cache)
process_slashings(state, validator_statuses.total_balances.current_epoch)
template runSuite(suiteDir, testName: string, transitionProc: untyped{ident}, useCache: static bool): untyped =
# We wrap the tests in a proc to avoid running out of globals
# in the future: Nim supports up to 3500 globals