From d0526233817d4bb9d1a284514c24f8abbc3e2c8c Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 3 Aug 2020 00:19:25 +0300 Subject: [PATCH] Fix a trivial issue with 'make medalla' and add more logging --- beacon_chain/beacon_node.nim | 2 +- beacon_chain/mainchain_monitor.nim | 16 ++++++++++++++-- vendor/eth2-testnets | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 518b0d793..1b81ccf23 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -1079,7 +1079,7 @@ programMain: for node in metadata.bootstrapNodes: config.bootstrapNodes.add node - if config.stateSnapshot.isNone: + if config.stateSnapshot.isNone and metadata.genesisData.len > 0: config.stateSnapshotContents = newClone metadata.genesisData template checkForIncompatibleOption(flagName, fieldName) = diff --git a/beacon_chain/mainchain_monitor.nim b/beacon_chain/mainchain_monitor.nim index 72565c746..6df690b39 100644 --- a/beacon_chain/mainchain_monitor.nim +++ b/beacon_chain/mainchain_monitor.nim @@ -544,7 +544,7 @@ proc findGenesisBlockInRange(m: MainchainMonitor, secondsPerBlock = float(endBlock.timestamp - startBlock.timestamp) / float(endBlock.number - startBlock.number) blocksToJump = max(float(MIN_GENESIS_TIME - startBlockTime) / secondsPerBlock, 1.0) - candidateNumber = min(endBlock.number - 1, startBlock.number + blocksToJump.uint64) + candidateNumber = min(endBlock.number - 1, startBlock.number + 1) # blocksToJump.uint64) candidateBlock = await dataProvider.getBlockByNumber(candidateNumber) var candidateAsEth1Block = Eth1Block(number: candidateBlock.number.uint64, @@ -564,6 +564,11 @@ proc findGenesisBlockInRange(m: MainchainMonitor, else: endBlock = candidateAsEth1Block + info "Genesis block selected", + blockNum = endBlock.number, + blockHash = endBlock.voteData.block_hash, + blockTime = endBlock.timestamp + return endBlock proc checkForGenesisLoop(m: MainchainMonitor) {.async.} = @@ -577,6 +582,13 @@ proc checkForGenesisLoop(m: MainchainMonitor) {.async.} = let genesisCandidateIdx = genesisCandidateIdx.get genesisCandidate = m.eth1Chain.blocks[genesisCandidateIdx] + + info "Generating state for candidate block for genesis", + blockNum = genesisCandidate.number, + blockHash = genesisCandidate.voteData.block_hash, + potentialDeposits = genesisCandidate.voteData.deposit_count + + let candidateState = m.createBeaconState(genesisCandidate) if genesisCandidate.knownGoodDepositsCount.get >= m.preset.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: @@ -755,7 +767,7 @@ proc run(m: MainchainMonitor, delayBeforeStart: Duration) {.async.} = url = m.dataProviderFactory.desc await dataProvider.onBlockHeaders do (blk: Eth1BlockHeader) - {.raises: [Defect], gcsafe}: + {.raises: [Defect], gcsafe.}: try: m.depositQueue.addLastNoWait(blk) except AsyncQueueFullError: diff --git a/vendor/eth2-testnets b/vendor/eth2-testnets index e558ef88b..d057d1e5a 160000 --- a/vendor/eth2-testnets +++ b/vendor/eth2-testnets @@ -1 +1 @@ -Subproject commit e558ef88bafb4dd8367aaec01ba89eeec715b761 +Subproject commit d057d1e5a42c4d14c39e7e3211398ed65bb8aa6c