Skip to content

Commit e7ce3ca

Browse files
authored
Add support for the Ropsten beacon chain (#3648)
1 parent 68fb396 commit e7ce3ca

File tree

11 files changed

+71
-5
lines changed

11 files changed

+71
-5
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,7 @@
223223
url = https://github.com/status-im/nim-toml-serialization.git
224224
ignore = untracked
225225
branch = master
226+
[submodule "vendor/merge-testnets"]
227+
path = vendor/merge-testnets
228+
url = https://github.com/eth-clients/merge-testnets.git
229+
branch = main

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ BASE_PORT := 9000
2626
BASE_REST_PORT := 5052
2727
BASE_METRICS_PORT := 8008
2828

29+
ROPSTEN_WEB3_URL := "--web3-url=wss://ropsten.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a"
2930
GOERLI_WEB3_URL := "--web3-url=wss://goerli.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a"
3031
GNOSIS_WEB3_URLS := "--web3-url=wss://rpc.gnosischain.com/wss --web3-url=wss://xdai.poanetwork.dev/wss"
3132

@@ -399,6 +400,32 @@ prater-dev-deposit: | prater-build deposit_contract
399400
clean-prater:
400401
$(call CLEAN_NETWORK,prater)
401402

403+
###
404+
### Ropsten
405+
###
406+
ropsten-build: | nimbus_beacon_node nimbus_signing_node
407+
408+
# https://www.gnu.org/software/make/manual/html_node/Call-Function.html#Call-Function
409+
ropsten: | ropsten-build
410+
$(call CONNECT_TO_NETWORK,ropsten,nimbus_beacon_node,$(ROPSTEN_WEB3_URL))
411+
412+
ropsten-vc: | ropsten-build nimbus_validator_client
413+
$(call CONNECT_TO_NETWORK_WITH_VALIDATOR_CLIENT,ropsten,nimbus_beacon_node,$(ROPSTEN_WEB3_URL))
414+
415+
ifneq ($(LOG_LEVEL), TRACE)
416+
ropsten-dev:
417+
+ "$(MAKE)" LOG_LEVEL=TRACE $@
418+
else
419+
ropsten-dev: | ropsten-build
420+
$(call CONNECT_TO_NETWORK_IN_DEV_MODE,ropsten,nimbus_beacon_node,$(ROPSTEN_WEB3_URL))
421+
endif
422+
423+
ropsten-dev-deposit: | ropsten-build deposit_contract
424+
$(call MAKE_DEPOSIT,ropsten,$(ROPSTEN_WEB3_URL))
425+
426+
clean-ropsten:
427+
$(call CLEAN_NETWORK,ropsten)
428+
402429
###
403430
### Gnosis chain binary
404431
###

beacon_chain/eth1/eth1_monitor.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,7 @@ proc startEth1Syncing(m: Eth1Monitor, delayBeforeStart: Duration) {.async.} =
12921292
providerNetwork = awaitWithRetries m.dataProvider.web3.provider.net_version()
12931293
expectedNetwork = case m.eth1Network.get
12941294
of mainnet: "1"
1295+
of ropsten: "3"
12951296
of rinkeby: "4"
12961297
of goerli: "5"
12971298
if expectedNetwork != providerNetwork:

beacon_chain/networking/network_metadata.nim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type
3737

3838
Eth1Network* = enum
3939
mainnet
40+
ropsten
4041
rinkeby
4142
goerli
4243

@@ -86,6 +87,7 @@ type
8687

8788
const
8889
eth2NetworksDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor/eth2-networks"
90+
mergeTestnetsDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor/merge-testnets"
8991

9092
proc readBootstrapNodes*(path: string): seq[string] {.raises: [IOError, Defect].} =
9193
# Read a list of ENR values from a YAML file containing a flat list of entries
@@ -115,6 +117,7 @@ proc loadEth2NetworkMetadata*(path: string, eth1Network = none(Eth1Network)): Et
115117
genesisPath = path & "/genesis.ssz"
116118
genesisDepositsSnapshotPath = path & "/genesis_deposit_contract_snapshot.ssz"
117119
configPath = path & "/config.yaml"
120+
deployBlockPath = path & "/deploy_block.txt"
118121
depositContractBlockPath = path & "/deposit_contract_block.txt"
119122
bootstrapNodesPath = path & "/bootstrap_nodes.txt"
120123
bootEnrPath = path & "/boot_enr.yaml"
@@ -134,8 +137,16 @@ proc loadEth2NetworkMetadata*(path: string, eth1Network = none(Eth1Network)): Et
134137
readFile(depositContractBlockPath).strip
135138
else:
136139
""
140+
141+
deployBlock = if fileExists(deployBlockPath):
142+
readFile(deployBlockPath).strip
143+
else:
144+
""
145+
137146
depositContractDeployedAt = if depositContractBlock.len > 0:
138147
BlockHashOrNumber.init(depositContractBlock)
148+
elif deployBlock.len > 0:
149+
BlockHashOrNumber.init(deployBlock)
139150
else:
140151
BlockHashOrNumber(isHash: false, number: 1)
141152

@@ -217,11 +228,16 @@ template eth2Network(path: string, eth1Network: Eth1Network): Eth2NetworkMetadat
217228
loadCompileTimeNetworkMetadata(eth2NetworksDir & "/" & path,
218229
some eth1Network)
219230

231+
template mergeTestnet(path: string, eth1Network: Eth1Network): Eth2NetworkMetadata =
232+
loadCompileTimeNetworkMetadata(mergeTestnetsDir & "/" & path,
233+
some eth1Network)
234+
220235
when not defined(gnosisChainBinary):
221236
when const_preset == "mainnet":
222237
const
223238
mainnetMetadata* = eth2Network("shared/mainnet", mainnet)
224239
praterMetadata* = eth2Network("shared/prater", goerli)
240+
ropstenMetadata = mergeTestnet("ropsten-beacon-chain", ropsten)
225241

226242
proc getMetadataForNetwork*(networkName: string): Eth2NetworkMetadata {.raises: [Defect, IOError].} =
227243
template loadRuntimeMetadata: auto =
@@ -242,6 +258,8 @@ when not defined(gnosisChainBinary):
242258
mainnetMetadata
243259
of "prater":
244260
praterMetadata
261+
of "ropsten":
262+
ropstenMetadata
245263
else:
246264
loadRuntimeMetadata()
247265
else:

beacon_chain/nimbus_beacon_node.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ proc init*(T: type BeaconNode,
429429
if snapshotRes.isErr:
430430
fatal "Failed to locate the deposit contract deployment block",
431431
depositContract = cfg.DEPOSIT_CONTRACT_ADDRESS,
432-
deploymentBlock = $depositContractDeployedAt
432+
deploymentBlock = $depositContractDeployedAt,
433+
err = snapshotRes.error
433434
quit 1
434435
else:
435436
some snapshotRes.get

beacon_chain/spec/presets.nim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ when const_preset == "mainnet":
169169
# canonical network names include:
170170
# * 'mainnet' - there can be only one
171171
# * 'prater' - testnet
172+
# * 'ropsten' - testnet
172173
# Must match the regex: [a-z0-9\-]
173174
CONFIG_NAME: "mainnet",
174175

@@ -271,6 +272,7 @@ elif const_preset == "minimal":
271272
# canonical network names include:
272273
# * 'mainnet' - there can be only one
273274
# * 'prater' - testnet
275+
# * 'ropsten' - testnet
274276
# Must match the regex: [a-z0-9\-]
275277
CONFIG_NAME: "minimal",
276278

docker/dist/README.md.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ The `prater` testnet runs on
6767

6868
```bash
6969
# using a local Goerli instance
70-
WEB3_URL="ws://localhost:8545" ./run-mainnet-node.sh --max-peers=150
70+
WEB3_URL="ws://localhost:8545" ./run-prater-node.sh --max-peers=150
7171
```

docs/e2store.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Each era is identified by when it ends. Thus, the genesis era is era `0`, follow
178178

179179
`.era` file names follow a simple convention: `<config-name>-<era-number>-<era-count>-<short-historical-root>.era`:
180180

181-
* `config-name` is the `CONFIG_NAME` field of the runtime configation (`mainnet`, `prater`, etc)
181+
* `config-name` is the `CONFIG_NAME` field of the runtime configation (`mainnet`, `prater`, `ropsten`, etc)
182182
* `era-number` is the number of the _first_ era stored in the file - for example, the genesis era file has number 0 - as a 5-digit 0-filled decimal integer
183183
* `short-era-root` is the first 4 bytes of the last historical root in the _last_ state in the era file, lower-case hex-encoded (8 characters), except the genesis era which instead uses the `genesis_validators_root` field from the genesis state.
184184
* The root is available as `state.historical_roots[era - 1]` except for genesis, which is `state.genesis_validators_root`

docs/the_nimbus_book/src/attestation-performance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ The following options are available:
3232

3333
Where:
3434

35-
- The `network` can either be `mainnet` or `prater`
35+
- The `network` can either be `mainnet`, `prater` or `ropsten`
3636

37-
- The default location of the `db` is either `build/data/shared_mainnet_0/db` or `build/data/shared_prater_0/db`
37+
- The default location of the `db` is either `build/data/shared_mainnet_0/db`, `build/data/shared_prater_0/db` or `build/data/shared_ropsten_0/db`
3838

3939

4040
Near the bottom, you should see

run-ropsten-beacon-node.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2020-2021 Status Research & Development GmbH. Licensed under
4+
# either of:
5+
# - Apache License, version 2.0
6+
# - MIT license
7+
# at your option. This file may not be copied, modified, or distributed except
8+
# according to those terms.
9+
10+
cd "$(dirname $0)"
11+
# Allow the binary to receive signals directly.
12+
exec scripts/run-beacon-node.sh nimbus_beacon_node ropsten $@

0 commit comments

Comments
 (0)