Finalization experiements

* Switched to FloodSub
* Testnet0 switched to the minimal preset. All validators deployed on the master node.
This commit is contained in:
Zahary Karadjov 2019-11-05 00:41:12 +00:00
parent 21223d2627
commit 14374504cf
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
7 changed files with 40 additions and 27 deletions

View File

@ -343,7 +343,7 @@ proc proposeBlock(node: BeaconNode,
(e1d, newSeq[Deposit]()) (e1d, newSeq[Deposit]())
else: else:
let e1d = await node.mainchainMonitor.getBeaconBlockRef() let e1d = node.mainchainMonitor.eth1Data
(e1d, node.mainchainMonitor.getPendingDeposits()) (e1d, node.mainchainMonitor.getPendingDeposits())

View File

@ -207,12 +207,12 @@ else:
keyFile, bootstrapNodes keyFile, bootstrapNodes
var daemonFut = if bootstrapNodes.len == 0: var daemonFut = if bootstrapNodes.len == 0:
newDaemonApi({PSNoSign, DHTFull, PSGossipSub}, newDaemonApi({PSNoSign, DHTFull, PSFloodSub},
id = keyFile, id = keyFile,
hostAddresses = @[hostAddress], hostAddresses = @[hostAddress],
announcedAddresses = announcedAddresses) announcedAddresses = announcedAddresses)
else: else:
newDaemonApi({PSNoSign, DHTFull, PSGossipSub, WaitBootstrap}, newDaemonApi({PSNoSign, DHTFull, PSFloodSub, WaitBootstrap},
id = keyFile, id = keyFile,
hostAddresses = @[hostAddress], hostAddresses = @[hostAddress],
announcedAddresses = announcedAddresses, announcedAddresses = announcedAddresses,

View File

@ -19,6 +19,7 @@ type
depositQueue: AsyncQueue[QueueElement] depositQueue: AsyncQueue[QueueElement]
eth1Block: BlockHash eth1Block: BlockHash
eth1Data*: Eth1Data
QueueElement = (BlockHash, DepositData) QueueElement = (BlockHash, DepositData)
@ -38,6 +39,16 @@ contract(DepositContract):
const MIN_GENESIS_TIME = 0 const MIN_GENESIS_TIME = 0
proc updateEth1Data*(m: MainchainMonitor) {.async.} =
let ns = m.web3.contractSender(DepositContract, m.depositContractAddress)
# TODO: use m.eth1Block for web3 calls
let cnt = await ns.get_deposit_count().call()
let htr = await ns.get_deposit_root().call()
m.eth1Data.deposit_count = bytes_to_int(array[8, byte](cnt))
m.eth1Data.deposit_root.data = array[32, byte](htr)
m.eth1Data.block_hash.data = array[32, byte](m.eth1Block)
proc processDeposits(m: MainchainMonitor) {.async.} = proc processDeposits(m: MainchainMonitor) {.async.} =
while true: while true:
let (blkHash, data) = await m.depositQueue.popFirst() let (blkHash, data) = await m.depositQueue.popFirst()
@ -66,6 +77,10 @@ proc processDeposits(m: MainchainMonitor) {.async.} =
m.genesisStateFut.complete() m.genesisStateFut.complete()
m.genesisStateFut = nil m.genesisStateFut = nil
# TODO: Set curBlock to blk number # TODO: Set curBlock to blk number
# TODO: This should be progressing in more independent way.
# The Eth1 cross-link can advance even when there are no new deposits.
await m.updateEth1Data
proc isRunning*(m: MainchainMonitor): bool = proc isRunning*(m: MainchainMonitor): bool =
not m.web3.isNil not m.web3.isNil
@ -105,16 +120,6 @@ proc run(m: MainchainMonitor) {.async.} =
proc start*(m: MainchainMonitor) = proc start*(m: MainchainMonitor) =
asyncCheck m.run() asyncCheck m.run()
proc getBeaconBlockRef*(m: MainchainMonitor): Future[Eth1Data] {.async.} =
let ns = m.web3.contractSender(DepositContract, m.depositContractAddress)
# TODO: use m.eth1Block for web3 calls
let cnt = await ns.get_deposit_count().call()
let htr = await ns.get_deposit_root().call()
result.deposit_count = bytes_to_int(array[8, byte](cnt))
result.deposit_root.data = array[32, byte](htr)
result.block_hash.data = array[32, byte](m.eth1Block)
proc getPendingDeposits*(m: MainchainMonitor): seq[Deposit] = proc getPendingDeposits*(m: MainchainMonitor): seq[Deposit] =
# This should be a simple accessor for the reference kept above # This should be a simple accessor for the reference kept above
m.pendingDeposits m.pendingDeposits

View File

@ -41,8 +41,16 @@ iterator nodes: tuple[server, container: string, firstValidator, lastValidator:
server = &"{nodeName}.do-ams3.nimbus.test.statusim.net" server = &"{nodeName}.do-ams3.nimbus.test.statusim.net"
for j in 0 ..< instancesCount: for j in 0 ..< instancesCount:
let firstIdx = baseIdx + j * validatorsPerNode var firstIdx, lastIdx: int
let lastIdx = firstIdx + validatorsPerNode - 1 if conf.network == "testnet0" and i == 0 and j == 0:
firstIdx = conf.totalUserValidators
lastIdx = conf.totalValidators
elif true:
firstIdx = 0
lastIdx = 0
else:
firstIdx = baseIdx + j * validatorsPerNode
lastIdx = firstIdx + validatorsPerNode
yield (server, &"beacon-node-{conf.network}-{j+1}", firstIdx, lastIdx) yield (server, &"beacon-node-{conf.network}-{j+1}", firstIdx, lastIdx)
case conf.cmd case conf.cmd
@ -56,18 +64,18 @@ of redist_validators:
keysList = "" keysList = ""
networkDataFiles = conf.networkDataDir & "/{genesis.ssz,bootstrap_nodes.txt}" networkDataFiles = conf.networkDataDir & "/{genesis.ssz,bootstrap_nodes.txt}"
for i in n.firstValidator..n.lastValidator: for i in n.firstValidator ..< n.lastValidator:
let validatorKey = fmt"v{i:07}.privkey" let validatorKey = fmt"v{i:07}.privkey"
keysList.add " " keysList.add " "
keysList.add conf.depositsDir / validatorKey keysList.add conf.depositsDir / validatorKey
let dockerPath = &"/docker/{n.container}/data/BeaconNode" let dockerPath = &"/docker/{n.container}/data/BeaconNode"
echo &"echo Distributing keys {n.firstValidator}..{n.lastValidator} to container {n.container}@{n.server} ... && \\" echo &"echo Syncing {n.lastValidator - n.firstValidator} keys starting from {n.firstValidator} to container {n.container}@{n.server} ... && \\"
echo &" ssh {n.server} 'sudo rm -rf /tmp/nimbus && mkdir -p /tmp/nimbus' && \\" echo &" ssh {n.server} 'sudo rm -rf /tmp/nimbus && mkdir -p /tmp/nimbus/' && \\"
echo &" rsync {networkDataFiles} {n.server}:/tmp/nimbus/net-data/ && \\" echo &" rsync {networkDataFiles} {n.server}:/tmp/nimbus/net-data/ && \\"
echo &" rsync {keysList} {n.server}:/tmp/nimbus/keys/ && \\" if keysList.len > 0: echo &" rsync {keysList} {n.server}:/tmp/nimbus/keys/ && \\"
echo &" ssh {n.server} 'sudo mkdir -p {dockerPath}/validators && sudo rm -f {dockerPath}/validators/* && " & echo &" ssh {n.server} 'sudo mkdir -p {dockerPath}/validators && sudo rm -f {dockerPath}/validators/* && " &
&"sudo mv /tmp/nimbus/keys/* {dockerPath}/validators/ && " & (if keysList.len > 0: &"sudo mv /tmp/nimbus/keys/* {dockerPath}/validators/ && " else: "") &
&"sudo mv /tmp/nimbus/net-data/* {dockerPath}/ && " & &"sudo mv /tmp/nimbus/net-data/* {dockerPath}/ && " &
&"sudo chown dockremap:docker -R {dockerPath}'" &"sudo chown dockremap:docker -R {dockerPath}'"

View File

@ -1,9 +1,9 @@
CONST_PRESET=minimal CONST_PRESET=minimal
NETWORK_TYPE=libp2p_daemon NETWORK_TYPE=libp2p_daemon
SHARD_COUNT=16 SHARD_COUNT=8
SLOTS_PER_EPOCH=16 SLOTS_PER_EPOCH=8
SECONDS_PER_SLOT=30 SECONDS_PER_SLOT=6
QUICKSTART_VALIDATORS=32 QUICKSTART_VALIDATORS=8
RANDOM_VALIDATORS=160 RANDOM_VALIDATORS=120
BOOTSTRAP_PORT=9000 BOOTSTRAP_PORT=9000
WEB3_URL=wss://goerli.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a WEB3_URL=wss://goerli.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a

@ -1 +1 @@
Subproject commit 173c7b4a86e6d75a69577166526b0f5840c45003 Subproject commit 88b79e230005d8301c3ae950abdbf8ad55e37f19

@ -1 +1 @@
Subproject commit 448a03ed4bd5837e18a3c50e10c6e31d25a6c9e5 Subproject commit ae60eef4e8413e49fb0dbcae9a343fb479509fa0