2020-05-01 15:51:24 +00:00
|
|
|
# beacon_chain
|
2021-02-08 07:27:30 +00:00
|
|
|
# Copyright (c) 2019-2021 Status Research & Development GmbH
|
2020-05-01 15:51:24 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
# `block_sim` is a block and attestation simulator similar to `state_sim` whose
|
|
|
|
# task is to run the beacon chain without considering the network or the
|
|
|
|
# wall clock. Functionally, it achieves the same as the distributed beacon chain
|
|
|
|
# by producing blocks and attestations as if they were created by separate
|
|
|
|
# nodes, just like a set of `beacon_node` instances would.
|
|
|
|
#
|
|
|
|
# Similar to `state_sim`, but uses the block and attestation pools along with
|
|
|
|
# a database, as if a real node was running.
|
|
|
|
|
|
|
|
import
|
2020-12-03 04:30:35 +00:00
|
|
|
math, stats, times, strformat,
|
2020-10-12 01:07:20 +00:00
|
|
|
options, random, tables, os,
|
2020-12-03 04:30:35 +00:00
|
|
|
confutils, chronicles, eth/db/kvstore_sqlite3,
|
2021-01-25 18:45:48 +00:00
|
|
|
eth/keys,
|
2021-06-11 17:51:46 +00:00
|
|
|
../tests/testblockutil,
|
2021-06-23 14:43:18 +00:00
|
|
|
../beacon_chain/spec/[beaconstate, crypto, digest,
|
2021-06-11 17:51:46 +00:00
|
|
|
forkedbeaconstate_helpers, presets,
|
|
|
|
helpers, signatures, state_transition],
|
2021-06-23 14:43:18 +00:00
|
|
|
../beacon_chain/spec/datatypes/[phase0, altair],
|
2021-03-04 09:13:44 +00:00
|
|
|
../beacon_chain/[beacon_node_types, beacon_chain_db, extras],
|
2021-03-03 06:23:05 +00:00
|
|
|
../beacon_chain/eth1/eth1_monitor,
|
2021-03-02 10:27:45 +00:00
|
|
|
../beacon_chain/validators/validator_pool,
|
2021-05-21 09:23:28 +00:00
|
|
|
../beacon_chain/consensus_object_pools/[blockchain_dag, block_quarantine,
|
2021-06-11 17:51:46 +00:00
|
|
|
block_clearance, attestation_pool],
|
2020-06-03 13:52:02 +00:00
|
|
|
../beacon_chain/ssz/[merkleization, ssz_serialization],
|
2020-05-01 15:51:24 +00:00
|
|
|
./simutils
|
|
|
|
|
|
|
|
type Timers = enum
|
|
|
|
tBlock = "Process non-epoch slot with block"
|
|
|
|
tEpoch = "Process epoch slot with block"
|
|
|
|
tHashBlock = "Tree-hash block"
|
|
|
|
tSignBlock = "Sign block"
|
2020-05-03 17:44:04 +00:00
|
|
|
tAttest = "Have committee attest to block"
|
|
|
|
tReplay = "Replay all produced blocks"
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2020-12-03 04:30:35 +00:00
|
|
|
proc gauss(r: var Rand; mu = 0.0; sigma = 1.0): float =
|
|
|
|
# TODO This is present in Nim 1.4
|
|
|
|
const K = sqrt(2 / E)
|
|
|
|
var
|
|
|
|
a = 0.0
|
|
|
|
b = 0.0
|
|
|
|
while true:
|
|
|
|
a = rand(r, 1.0)
|
|
|
|
b = (2.0 * rand(r, 1.0) - 1.0) * K
|
|
|
|
if b * b <= -4.0 * a * a * ln(a): break
|
|
|
|
result = mu + sigma * (b / a)
|
|
|
|
|
2020-05-01 15:51:24 +00:00
|
|
|
# TODO confutils is an impenetrable black box. how can a help text be added here?
|
2021-06-23 14:43:18 +00:00
|
|
|
cli do(slots = SLOTS_PER_EPOCH * 6,
|
2021-03-17 13:35:59 +00:00
|
|
|
validators = SLOTS_PER_EPOCH * 400, # One per shard is minimum
|
2020-10-13 17:21:25 +00:00
|
|
|
attesterRatio {.desc: "ratio of validators that attest in each round"} = 0.82,
|
2020-05-03 17:44:04 +00:00
|
|
|
blockRatio {.desc: "ratio of slots with blocks"} = 1.0,
|
|
|
|
replay = true):
|
2020-05-01 15:51:24 +00:00
|
|
|
let
|
2020-12-03 04:30:35 +00:00
|
|
|
(state, depositContractSnapshot) = loadGenesis(validators, false)
|
2020-05-22 14:21:22 +00:00
|
|
|
genesisBlock = get_initial_beacon_block(state[].data)
|
2020-12-03 04:30:35 +00:00
|
|
|
genesisTime = float state[].data.genesis_time
|
2020-05-01 15:51:24 +00:00
|
|
|
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
var runtimePreset = defaultRuntimeConfig
|
|
|
|
|
|
|
|
runtimePreset.ALTAIR_FORK_EPOCH = 96.Slot.epoch
|
2021-06-23 14:43:18 +00:00
|
|
|
|
2020-05-01 15:51:24 +00:00
|
|
|
echo "Starting simulation..."
|
|
|
|
|
2021-04-06 18:56:45 +00:00
|
|
|
let db = BeaconChainDB.new(runtimePreset, "block_sim_db")
|
2020-09-16 07:16:23 +00:00
|
|
|
defer: db.close()
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2020-09-22 20:42:42 +00:00
|
|
|
ChainDAGRef.preInit(db, state[].data, state[].data, genesisBlock)
|
2020-12-03 04:30:35 +00:00
|
|
|
putInitialDepositContractSnapshot(db, depositContractSnapshot)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
|
|
|
var
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
dag = ChainDAGRef.init(runtimePreset, db, {})
|
2020-12-03 04:30:35 +00:00
|
|
|
eth1Chain = Eth1Chain.init(runtimePreset, db)
|
|
|
|
merkleizer = depositContractSnapshot.createMerkleizer
|
2021-01-25 18:45:48 +00:00
|
|
|
quarantine = QuarantineRef.init(keys.newRng())
|
2021-06-01 11:13:40 +00:00
|
|
|
attPool = AttestationPool.init(dag, quarantine)
|
2020-05-01 15:51:24 +00:00
|
|
|
timers: array[Timers, RunningStat]
|
|
|
|
attesters: RunningStat
|
2020-05-03 17:44:04 +00:00
|
|
|
r = initRand(1)
|
2021-06-01 11:13:40 +00:00
|
|
|
tmpState = assignClone(dag.headState)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2020-12-03 04:30:35 +00:00
|
|
|
eth1Chain.addBlock Eth1Block(
|
|
|
|
number: Eth1BlockNumber 1,
|
|
|
|
timestamp: Eth1BlockTimestamp genesisTime,
|
|
|
|
voteData: Eth1Data(
|
|
|
|
deposit_root: merkleizer.getDepositsRoot,
|
|
|
|
deposit_count: merkleizer.getChunkCount))
|
|
|
|
|
2021-06-01 11:13:40 +00:00
|
|
|
let replayState = assignClone(dag.headState)
|
2020-05-03 17:44:04 +00:00
|
|
|
|
|
|
|
proc handleAttestations(slot: Slot) =
|
2020-05-01 15:51:24 +00:00
|
|
|
let
|
2021-06-01 11:13:40 +00:00
|
|
|
attestationHead = dag.head.atSlot(slot)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2021-06-01 11:13:40 +00:00
|
|
|
dag.withState(tmpState[], attestationHead):
|
2020-07-27 10:59:57 +00:00
|
|
|
let committees_per_slot =
|
2021-06-11 17:51:46 +00:00
|
|
|
get_committee_count_per_slot(stateData.data, slot.epoch, cache)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
|
|
|
for committee_index in 0'u64..<committees_per_slot:
|
|
|
|
let committee = get_beacon_committee(
|
2021-06-11 17:51:46 +00:00
|
|
|
stateData.data, slot, committee_index.CommitteeIndex, cache)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
|
|
|
for index_in_committee, validatorIdx in committee:
|
2020-05-03 17:44:04 +00:00
|
|
|
if rand(r, 1.0) <= attesterRatio:
|
2020-05-01 15:51:24 +00:00
|
|
|
let
|
2020-11-04 21:52:47 +00:00
|
|
|
data = makeAttestationData(
|
2021-06-11 17:51:46 +00:00
|
|
|
stateData.data, slot, committee_index.CommitteeIndex, blck.root)
|
2020-05-01 15:51:24 +00:00
|
|
|
sig =
|
2021-06-11 17:51:46 +00:00
|
|
|
get_attestation_signature(getStateField(stateData.data, fork),
|
|
|
|
getStateField(stateData.data, genesis_validators_root),
|
2021-05-21 09:23:28 +00:00
|
|
|
data, hackPrivKey(
|
2021-06-11 17:51:46 +00:00
|
|
|
getStateField(stateData.data, validators)[validatorIdx]))
|
2020-05-01 15:51:24 +00:00
|
|
|
var aggregation_bits = CommitteeValidatorsBits.init(committee.len)
|
|
|
|
aggregation_bits.setBit index_in_committee
|
|
|
|
|
2020-07-09 09:29:32 +00:00
|
|
|
attPool.addAttestation(
|
2020-05-01 15:51:24 +00:00
|
|
|
Attestation(
|
|
|
|
data: data,
|
|
|
|
aggregation_bits: aggregation_bits,
|
2021-04-26 20:39:44 +00:00
|
|
|
signature: sig.toValidatorSig()
|
|
|
|
), [validatorIdx], sig, data.slot)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2021-06-23 14:43:18 +00:00
|
|
|
proc getNewBlock[T](
|
|
|
|
stateData: var StateData, slot: Slot, cache: var StateCache): T =
|
|
|
|
let
|
|
|
|
finalizedEpochRef = dag.getFinalizedEpochRef()
|
|
|
|
proposerIdx = get_beacon_proposer_index(
|
|
|
|
stateData.data, cache, getStateField(stateData.data, slot)).get()
|
|
|
|
privKey = hackPrivKey(
|
|
|
|
getStateField(stateData.data, validators)[proposerIdx])
|
|
|
|
eth1ProposalData = eth1Chain.getBlockProposalData(
|
|
|
|
stateData.data,
|
|
|
|
finalizedEpochRef.eth1_data,
|
|
|
|
finalizedEpochRef.eth1_deposit_index)
|
|
|
|
hashedState =
|
|
|
|
when T is phase0.SignedBeaconBlock:
|
|
|
|
addr stateData.data.hbsPhase0
|
|
|
|
elif T is altair.SignedBeaconBlock:
|
|
|
|
addr stateData.data.hbsAltair
|
|
|
|
else:
|
|
|
|
static: doAssert false
|
|
|
|
message = makeBeaconBlock(
|
|
|
|
runtimePreset,
|
|
|
|
hashedState[],
|
|
|
|
proposerIdx,
|
|
|
|
dag.head.root,
|
|
|
|
privKey.genRandaoReveal(
|
|
|
|
getStateField(stateData.data, fork),
|
|
|
|
getStateField(stateData.data, genesis_validators_root),
|
|
|
|
slot).toValidatorSig(),
|
|
|
|
eth1ProposalData.vote,
|
|
|
|
default(GraffitiBytes),
|
|
|
|
attPool.getAttestationsForTestBlock(stateData, cache),
|
|
|
|
eth1ProposalData.deposits,
|
|
|
|
@[],
|
|
|
|
@[],
|
|
|
|
@[],
|
|
|
|
ExecutionPayload(),
|
|
|
|
noRollback,
|
|
|
|
cache)
|
|
|
|
|
|
|
|
var
|
|
|
|
newBlock = T(
|
|
|
|
message: message.get()
|
|
|
|
)
|
|
|
|
|
|
|
|
let blockRoot = withTimerRet(timers[tHashBlock]):
|
|
|
|
hash_tree_root(newBlock.message)
|
|
|
|
newBlock.root = blockRoot
|
|
|
|
# Careful, state no longer valid after here because of the await..
|
|
|
|
newBlock.signature = withTimerRet(timers[tSignBlock]):
|
|
|
|
get_block_signature(
|
|
|
|
getStateField(stateData.data, fork),
|
|
|
|
getStateField(stateData.data, genesis_validators_root),
|
|
|
|
newBlock.message.slot,
|
|
|
|
blockRoot, privKey).toValidatorSig()
|
|
|
|
|
|
|
|
newBlock
|
|
|
|
|
|
|
|
proc proposePhase0Block(slot: Slot) =
|
2020-05-03 17:44:04 +00:00
|
|
|
if rand(r, 1.0) > blockRatio:
|
|
|
|
return
|
|
|
|
|
2021-06-23 14:43:18 +00:00
|
|
|
dag.withState(tmpState[], dag.head.atSlot(slot)):
|
2020-05-01 15:51:24 +00:00
|
|
|
let
|
2021-06-23 14:43:18 +00:00
|
|
|
newBlock = getNewBlock[phase0.SignedBeaconBlock](stateData, slot, cache)
|
|
|
|
added = dag.addRawBlock(quarantine, newBlock) do (
|
|
|
|
blckRef: BlockRef, signedBlock: phase0.TrustedSignedBeaconBlock,
|
|
|
|
epochRef: EpochRef):
|
|
|
|
# Callback add to fork choice if valid
|
|
|
|
attPool.addForkChoice(
|
|
|
|
epochRef, blckRef, signedBlock.message, blckRef.slot)
|
|
|
|
|
|
|
|
blck() = added[]
|
|
|
|
dag.updateHead(added[], quarantine)
|
|
|
|
if dag.needStateCachesAndForkChoicePruning():
|
|
|
|
dag.pruneStateCachesDAG()
|
|
|
|
attPool.prune()
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2021-06-23 14:43:18 +00:00
|
|
|
proc proposeAltairBlock(slot: Slot) =
|
|
|
|
if rand(r, 1.0) > blockRatio:
|
|
|
|
return
|
|
|
|
|
|
|
|
dag.withState(tmpState[], dag.head.atSlot(slot)):
|
|
|
|
let
|
|
|
|
newBlock = getNewBlock[altair.SignedBeaconBlock](stateData, slot, cache)
|
|
|
|
added = dag.addRawBlock(quarantine, newBlock) do (
|
|
|
|
blckRef: BlockRef, signedBlock: altair.TrustedSignedBeaconBlock,
|
|
|
|
epochRef: EpochRef):
|
|
|
|
# Callback add to fork choice if valid
|
|
|
|
attPool.addForkChoice(
|
|
|
|
epochRef, blckRef, signedBlock.message, blckRef.slot)
|
2020-07-22 09:42:55 +00:00
|
|
|
|
2020-07-09 09:29:32 +00:00
|
|
|
blck() = added[]
|
2021-06-01 11:13:40 +00:00
|
|
|
dag.updateHead(added[], quarantine)
|
|
|
|
if dag.needStateCachesAndForkChoicePruning():
|
|
|
|
dag.pruneStateCachesDAG()
|
2021-03-09 14:36:17 +00:00
|
|
|
attPool.prune()
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2020-12-03 04:30:35 +00:00
|
|
|
var
|
|
|
|
lastEth1BlockAt = genesisTime
|
|
|
|
eth1BlockNum = 1000
|
|
|
|
|
2020-05-01 15:51:24 +00:00
|
|
|
for i in 0..<slots:
|
|
|
|
let
|
2020-05-03 17:44:04 +00:00
|
|
|
slot = Slot(i + 1)
|
2020-05-01 15:51:24 +00:00
|
|
|
t =
|
2020-05-03 17:44:04 +00:00
|
|
|
if slot.isEpoch: tEpoch
|
2020-05-01 15:51:24 +00:00
|
|
|
else: tBlock
|
2020-12-03 04:30:35 +00:00
|
|
|
now = genesisTime + float(slot * SECONDS_PER_SLOT)
|
|
|
|
|
|
|
|
while true:
|
|
|
|
let nextBlockTime = lastEth1BlockAt +
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
max(1.0, gauss(r, float defaultRuntimeConfig.SECONDS_PER_ETH1_BLOCK, 3.0))
|
2020-12-03 04:30:35 +00:00
|
|
|
if nextBlockTime > now:
|
|
|
|
break
|
|
|
|
|
|
|
|
inc eth1BlockNum
|
|
|
|
var eth1Block = Eth1Block(
|
|
|
|
number: Eth1BlockNumber eth1BlockNum,
|
|
|
|
timestamp: Eth1BlockTimestamp nextBlockTime,
|
|
|
|
voteData: Eth1Data(
|
|
|
|
block_hash: makeFakeHash(eth1BlockNum)))
|
|
|
|
|
|
|
|
let newDeposits = int clamp(gauss(r, 5.0, 8.0), 0.0, 1000.0)
|
|
|
|
for i in 0 ..< newDeposits:
|
|
|
|
let d = makeDeposit(merkleizer.getChunkCount.int, {skipBLSValidation})
|
|
|
|
eth1Block.deposits.add d
|
|
|
|
merkleizer.addChunk hash_tree_root(d).data
|
|
|
|
|
|
|
|
eth1Block.voteData.deposit_root = merkleizer.getDepositsRoot
|
|
|
|
eth1Block.voteData.deposit_count = merkleizer.getChunkCount
|
|
|
|
|
|
|
|
eth1Chain.addBlock eth1Block
|
|
|
|
lastEth1BlockAt = nextBlockTime
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2020-05-03 17:44:04 +00:00
|
|
|
if blockRatio > 0.0:
|
|
|
|
withTimer(timers[t]):
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
if slot.epoch < dag.cfg.ALTAIR_FORK_EPOCH:
|
2021-06-23 14:43:18 +00:00
|
|
|
proposePhase0Block(slot)
|
|
|
|
else:
|
|
|
|
proposeAltairBlock(slot)
|
2020-05-01 15:51:24 +00:00
|
|
|
if attesterRatio > 0.0:
|
|
|
|
withTimer(timers[tAttest]):
|
2020-05-03 17:44:04 +00:00
|
|
|
handleAttestations(slot)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
2020-05-03 17:44:04 +00:00
|
|
|
# TODO if attestation pool was smarter, it would include older attestations
|
|
|
|
# too!
|
2021-06-11 17:51:46 +00:00
|
|
|
verifyConsensus(dag.headState.data, attesterRatio * blockRatio)
|
2020-05-01 15:51:24 +00:00
|
|
|
|
|
|
|
if t == tEpoch:
|
|
|
|
echo &". slot: {shortLog(slot)} ",
|
|
|
|
&"epoch: {shortLog(slot.compute_epoch_at_slot)}"
|
|
|
|
else:
|
|
|
|
write(stdout, ".")
|
|
|
|
flushFile(stdout)
|
|
|
|
|
2020-05-03 17:44:04 +00:00
|
|
|
if replay:
|
|
|
|
withTimer(timers[tReplay]):
|
2020-08-18 20:29:33 +00:00
|
|
|
var cache = StateCache()
|
2021-06-01 11:13:40 +00:00
|
|
|
dag.updateStateData(
|
|
|
|
replayState[], dag.head.atSlot(Slot(slots)), false, cache)
|
2020-05-03 17:44:04 +00:00
|
|
|
|
2020-05-01 15:51:24 +00:00
|
|
|
echo "Done!"
|
|
|
|
|
2021-06-11 17:51:46 +00:00
|
|
|
printTimers(dag.headState.data, attesters, true, timers)
|