mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-02 01:36:06 +00:00
check that process_slots() succeeds
This commit is contained in:
parent
6c941b1ff7
commit
f4d38611ef
@ -168,7 +168,8 @@ proc runProcessSlots*(dir, preState: string, numSlots: uint64) =
|
|||||||
)
|
)
|
||||||
state.root = hash_tree_root(state.data)
|
state.root = hash_tree_root(state.data)
|
||||||
|
|
||||||
process_slots(state[], state.data.slot + numSlots)
|
# Shouldn't necessarily assert, because nbench can run test suite
|
||||||
|
discard process_slots(state[], state.data.slot + numSlots)
|
||||||
|
|
||||||
template processEpochScenarioImpl(
|
template processEpochScenarioImpl(
|
||||||
dir, preState: string,
|
dir, preState: string,
|
||||||
|
@ -127,7 +127,7 @@ proc add*(state: var HashedBeaconState, attestation: Attestation, slot: Slot) =
|
|||||||
var signedBlock = mockBlockForNextSlot(state.data)
|
var signedBlock = mockBlockForNextSlot(state.data)
|
||||||
signedBlock.message.slot = slot
|
signedBlock.message.slot = slot
|
||||||
signedBlock.message.body.attestations.add attestation
|
signedBlock.message.body.attestations.add attestation
|
||||||
discard process_slots(state, slot)
|
doAssert process_slots(state, slot)
|
||||||
signMockBlock(state.data, signedBlock)
|
signMockBlock(state.data, signedBlock)
|
||||||
|
|
||||||
doAssert state_transition(
|
doAssert state_transition(
|
||||||
|
@ -18,8 +18,8 @@ proc nextEpoch*(state: var HashedBeaconState) =
|
|||||||
## Transition to the start of the next epoch
|
## Transition to the start of the next epoch
|
||||||
let slot =
|
let slot =
|
||||||
state.data.slot + SLOTS_PER_EPOCH - (state.data.slot mod SLOTS_PER_EPOCH)
|
state.data.slot + SLOTS_PER_EPOCH - (state.data.slot mod SLOTS_PER_EPOCH)
|
||||||
discard process_slots(state, slot)
|
doAssert process_slots(state, slot)
|
||||||
|
|
||||||
proc nextSlot*(state: var HashedBeaconState) =
|
proc nextSlot*(state: var HashedBeaconState) =
|
||||||
## Transition to the next slot
|
## Transition to the next slot
|
||||||
discard process_slots(state, state.data.slot + 1)
|
doAssert process_slots(state, state.data.slot + 1)
|
||||||
|
@ -37,10 +37,11 @@ proc runTest(identifier: string) =
|
|||||||
data: preState[], root: hash_tree_root(preState[]))
|
data: preState[], root: hash_tree_root(preState[]))
|
||||||
let postState = newClone(parseTest(testDir/"post.ssz", SSZ, BeaconState))
|
let postState = newClone(parseTest(testDir/"post.ssz", SSZ, BeaconState))
|
||||||
|
|
||||||
discard process_slots(
|
check:
|
||||||
hashedPreState, hashedPreState.data.slot + num_slots)
|
process_slots(
|
||||||
|
hashedPreState, hashedPreState.data.slot + num_slots)
|
||||||
|
|
||||||
check: hashedPreState.root == postState[].hash_tree_root()
|
hashedPreState.root == postState[].hash_tree_root()
|
||||||
let newPreState = newClone(hashedPreState.data)
|
let newPreState = newClone(hashedPreState.data)
|
||||||
reportDiff(newPreState, postState)
|
reportDiff(newPreState, postState)
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ suiteReport "Attestation pool processing" & preset():
|
|||||||
pool = AttestationPool.init(blockPool)
|
pool = AttestationPool.init(blockPool)
|
||||||
state = newClone(loadTailState(blockPool))
|
state = newClone(loadTailState(blockPool))
|
||||||
# Slot 0 is a finalized slot - won't be making attestations for it..
|
# Slot 0 is a finalized slot - won't be making attestations for it..
|
||||||
discard process_slots(state.data, state.data.data.slot + 1)
|
check:
|
||||||
|
process_slots(state.data, state.data.data.slot + 1)
|
||||||
|
|
||||||
timedTest "Can add and retrieve simple attestation" & preset():
|
timedTest "Can add and retrieve simple attestation" & preset():
|
||||||
var cache = get_empty_per_epoch_cache()
|
var cache = get_empty_per_epoch_cache()
|
||||||
@ -39,7 +40,8 @@ suiteReport "Attestation pool processing" & preset():
|
|||||||
|
|
||||||
pool.add(attestation)
|
pool.add(attestation)
|
||||||
|
|
||||||
discard process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
check:
|
||||||
|
process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
||||||
|
|
||||||
let attestations = pool.getAttestationsForBlock(state.data.data)
|
let attestations = pool.getAttestationsForBlock(state.data.data)
|
||||||
|
|
||||||
@ -55,7 +57,8 @@ suiteReport "Attestation pool processing" & preset():
|
|||||||
attestation0 = makeAttestation(
|
attestation0 = makeAttestation(
|
||||||
state.data.data, state.blck.root, bc0[0], cache)
|
state.data.data, state.blck.root, bc0[0], cache)
|
||||||
|
|
||||||
discard process_slots(state.data, state.data.data.slot + 1)
|
check:
|
||||||
|
process_slots(state.data, state.data.data.slot + 1)
|
||||||
|
|
||||||
let
|
let
|
||||||
bc1 = get_beacon_committee(state.data.data,
|
bc1 = get_beacon_committee(state.data.data,
|
||||||
@ -88,7 +91,8 @@ suiteReport "Attestation pool processing" & preset():
|
|||||||
pool.add(attestation0)
|
pool.add(attestation0)
|
||||||
pool.add(attestation1)
|
pool.add(attestation1)
|
||||||
|
|
||||||
discard process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
check:
|
||||||
|
process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
||||||
|
|
||||||
let attestations = pool.getAttestationsForBlock(state.data.data)
|
let attestations = pool.getAttestationsForBlock(state.data.data)
|
||||||
|
|
||||||
@ -112,7 +116,8 @@ suiteReport "Attestation pool processing" & preset():
|
|||||||
pool.add(attestation0)
|
pool.add(attestation0)
|
||||||
pool.add(attestation1)
|
pool.add(attestation1)
|
||||||
|
|
||||||
discard process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
check:
|
||||||
|
process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
||||||
|
|
||||||
let attestations = pool.getAttestationsForBlock(state.data.data)
|
let attestations = pool.getAttestationsForBlock(state.data.data)
|
||||||
|
|
||||||
@ -135,7 +140,8 @@ suiteReport "Attestation pool processing" & preset():
|
|||||||
pool.add(attestation1)
|
pool.add(attestation1)
|
||||||
pool.add(attestation0)
|
pool.add(attestation0)
|
||||||
|
|
||||||
discard process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
check:
|
||||||
|
process_slots(state.data, MIN_ATTESTATION_INCLUSION_DELAY.Slot + 1)
|
||||||
|
|
||||||
let attestations = pool.getAttestationsForBlock(state.data.data)
|
let attestations = pool.getAttestationsForBlock(state.data.data)
|
||||||
|
|
||||||
|
@ -132,7 +132,8 @@ suiteReport "Block pool processing" & preset():
|
|||||||
pool.heads[0].blck == b2Add
|
pool.heads[0].blck == b2Add
|
||||||
|
|
||||||
# Skip one slot to get a gap
|
# Skip one slot to get a gap
|
||||||
discard process_slots(stateData.data, stateData.data.data.slot + 1)
|
check:
|
||||||
|
process_slots(stateData.data, stateData.data.data.slot + 1)
|
||||||
|
|
||||||
let
|
let
|
||||||
b4 = addTestBlock(stateData.data.data, b2Root)
|
b4 = addTestBlock(stateData.data.data, b2Root)
|
||||||
@ -345,8 +346,9 @@ when const_preset == "minimal": # These require some minutes in mainnet
|
|||||||
pool.updateHead(added)
|
pool.updateHead(added)
|
||||||
|
|
||||||
# Advance past epoch so that the epoch transition is gapped
|
# Advance past epoch so that the epoch transition is gapped
|
||||||
discard process_slots(
|
check:
|
||||||
pool.headState.data, Slot(SLOTS_PER_EPOCH * 6 + 2) )
|
process_slots(
|
||||||
|
pool.headState.data, Slot(SLOTS_PER_EPOCH * 6 + 2) )
|
||||||
|
|
||||||
var blck = makeTestBlock(
|
var blck = makeTestBlock(
|
||||||
pool.headState.data.data, pool.head.blck.root,
|
pool.headState.data.data, pool.head.blck.root,
|
||||||
|
@ -29,8 +29,8 @@ suiteReport "Block processing" & preset():
|
|||||||
var state = newClone(genesisState)
|
var state = newClone(genesisState)
|
||||||
|
|
||||||
timedTest "Passes from genesis state, no block" & preset():
|
timedTest "Passes from genesis state, no block" & preset():
|
||||||
discard process_slots(state[], state.data.slot + 1)
|
|
||||||
check:
|
check:
|
||||||
|
process_slots(state[], state.data.slot + 1)
|
||||||
state.data.slot == genesisState.data.slot + 1
|
state.data.slot == genesisState.data.slot + 1
|
||||||
|
|
||||||
timedTest "Passes from genesis state, empty block" & preset():
|
timedTest "Passes from genesis state, empty block" & preset():
|
||||||
@ -46,9 +46,8 @@ suiteReport "Block processing" & preset():
|
|||||||
state.data.slot == genesisState.data.slot + 1
|
state.data.slot == genesisState.data.slot + 1
|
||||||
|
|
||||||
timedTest "Passes through epoch update, no block" & preset():
|
timedTest "Passes through epoch update, no block" & preset():
|
||||||
discard process_slots(state[], Slot(SLOTS_PER_EPOCH))
|
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
process_slots(state[], Slot(SLOTS_PER_EPOCH))
|
||||||
state.data.slot == genesisState.data.slot + SLOTS_PER_EPOCH
|
state.data.slot == genesisState.data.slot + SLOTS_PER_EPOCH
|
||||||
|
|
||||||
timedTest "Passes through epoch update, empty block" & preset():
|
timedTest "Passes through epoch update, empty block" & preset():
|
||||||
@ -74,7 +73,8 @@ suiteReport "Block processing" & preset():
|
|||||||
cache = get_empty_per_epoch_cache()
|
cache = get_empty_per_epoch_cache()
|
||||||
|
|
||||||
# Slot 0 is a finalized slot - won't be making attestations for it..
|
# Slot 0 is a finalized slot - won't be making attestations for it..
|
||||||
discard process_slots(state[], state.data.slot + 1)
|
check:
|
||||||
|
process_slots(state[], state.data.slot + 1)
|
||||||
|
|
||||||
let
|
let
|
||||||
# Create an attestation for slot 1 signed by the only attester we have!
|
# Create an attestation for slot 1 signed by the only attester we have!
|
||||||
@ -85,8 +85,9 @@ suiteReport "Block processing" & preset():
|
|||||||
|
|
||||||
# Some time needs to pass before attestations are included - this is
|
# Some time needs to pass before attestations are included - this is
|
||||||
# to let the attestation propagate properly to interested participants
|
# to let the attestation propagate properly to interested participants
|
||||||
discard process_slots(
|
check:
|
||||||
state[], GENESIS_SLOT + MIN_ATTESTATION_INCLUSION_DELAY + 1)
|
process_slots(
|
||||||
|
state[], GENESIS_SLOT + MIN_ATTESTATION_INCLUSION_DELAY + 1)
|
||||||
|
|
||||||
let
|
let
|
||||||
new_block = makeTestBlock(state.data, previous_block_root,
|
new_block = makeTestBlock(state.data, previous_block_root,
|
||||||
@ -101,7 +102,8 @@ suiteReport "Block processing" & preset():
|
|||||||
|
|
||||||
when const_preset=="minimal":
|
when const_preset=="minimal":
|
||||||
# Can take several minutes with mainnet settings
|
# Can take several minutes with mainnet settings
|
||||||
discard process_slots(state[], Slot(191))
|
check:
|
||||||
|
process_slots(state[], Slot(191))
|
||||||
|
|
||||||
# Would need to process more epochs for the attestation to be removed from
|
# Would need to process more epochs for the attestation to be removed from
|
||||||
# the state! (per above bug)
|
# the state! (per above bug)
|
||||||
|
@ -97,7 +97,7 @@ proc addTestBlock*(
|
|||||||
|
|
||||||
# TODO workaround, disable when this works directly
|
# TODO workaround, disable when this works directly
|
||||||
var hashedState = HashedBeaconState(data: state, root: hash_tree_root(state))
|
var hashedState = HashedBeaconState(data: state, root: hash_tree_root(state))
|
||||||
discard process_slots(hashedState, hashedState.data.slot + 1)
|
doAssert process_slots(hashedState, hashedState.data.slot + 1)
|
||||||
state = hashedState.data
|
state = hashedState.data
|
||||||
|
|
||||||
var cache = get_empty_per_epoch_cache()
|
var cache = get_empty_per_epoch_cache()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user