fix `mockBlock` for current slot (#2915)

In #2867 a regression was introduced that broke `mockBlock` when used to
compute a block for the current state. This patch fixes the regression.
This commit is contained in:
Etan Kissling 2021-09-28 18:27:44 +02:00 committed by GitHub
parent ca4c6b4c5c
commit a0e7463732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -52,10 +52,12 @@ proc mockBlock*(
## TODO don't do this gradual construction, for exception safety
## Mock a BeaconBlock for the specific slot
var cache = StateCache()
var rewards = RewardInfo()
var tmpState = assignClone(state)
doAssert process_slots(cfg, tmpState[], slot, cache, rewards, flags = {})
var
cache = StateCache()
tmpState = assignClone(state)
if getStateField(state, slot) != slot:
var rewards = RewardInfo()
doAssert process_slots(cfg, tmpState[], slot, cache, rewards, flags = {})
var previous_block_header = getStateField(tmpState[], latest_block_header)
if previous_block_header.state_root == ZERO_HASH: