add goerli testnet genesis data[skip ci]

This commit is contained in:
andri lim 2020-04-09 17:06:08 +07:00 committed by zah
parent 03eb7a3c2a
commit d69ede6060
4 changed files with 63 additions and 6 deletions

View File

@ -74,6 +74,7 @@ type
MordenNet = 2
RopstenNet = 3
RinkebyNet = 4
GoerliNet = 5
KovanNet = 42
NetworkFlags* = enum
@ -133,6 +134,8 @@ type
byzantiumBlock*: BlockNumber
constantinopleBlock*: BlockNumber
petersburgBlock*: BlockNumber
istanbulBlock*: BlockNumber
NimbusConfiguration* = ref object
## Main Nimbus configuration object
@ -156,6 +159,8 @@ type
eip158Block*: BlockNumber
byzantiumBlock*: BlockNumber
constantinopleBlock*: BlockNumber
petersburgBlock*: BlockNumber
istanbulBlock*: BlockNumber
nonce*: BlockNonce
extraData*: seq[byte]
gasLimit*: int64
@ -188,6 +193,8 @@ proc privateChainConfig*(): ChainConfig =
eip158Block: config.customGenesis.eip158Block,
byzantiumBlock: config.customGenesis.byzantiumBlock,
constantinopleBlock: config.customGenesis.constantinopleBlock,
petersburgBlock: config.customGenesis.petersburgBlock,
istanbulBlock: config.customGenesis.istanbulBlock
)
trace "Custom genesis block configuration loaded", configuration=result
@ -227,6 +234,18 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
eip158Block: 3.toBlockNumber,
byzantiumBlock: 1035301.toBlockNumber
)
of GoerliNet:
ChainConfig(
chainId: GoerliNet.uint,
homesteadBlock: 0.toBlockNumber,
daoForkSupport: false,
eip150Block: 0.toBlockNumber,
eip150Hash: toDigest("0000000000000000000000000000000000000000000000000000000000000000"),
eip155Block: 0.toBlockNumber,
eip158Block: 0.toBlockNumber,
byzantiumBlock: 0.toBlockNumber,
istanbulBlock: 1561651.toBlockNumber
)
of CustomNet:
privateChainConfig()
else:
@ -293,6 +312,7 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
var
chainId = 0.uint
homesteadBlock, daoForkblock, eip150Block, eip155Block, eip158Block, byzantiumBlock, constantinopleBlock = 0.toBlockNumber
petersburgBlock, istanbulBlock = 0.toBlockNumber
eip150Hash, mixHash : MDigest[256]
daoForkSupport = false
nonce = 66.toBlockNonce
@ -320,6 +340,8 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
checkForFork(forkDetails, eip158Block, eip155Block)
checkForFork(forkDetails, byzantiumBlock, eip158Block)
checkForFork(forkDetails, constantinopleBlock, byzantiumBlock)
checkForFork(forkDetails, petersburgBlock, constantinopleBlock)
checkForFork(forkDetails, istanbulBlock, petersburgBlock)
else:
error "No chain configuration found."
quit(1)
@ -344,6 +366,8 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
daoForkSupport: daoForkSupport,
byzantiumBlock: byzantiumBlock,
constantinopleBlock: constantinopleBlock,
petersburgBlock: petersburgBlock,
istanbulBlock: istanbulBlock,
nonce: nonce,
extraData: extraData,
gasLimit: gasLimit,
@ -559,6 +583,8 @@ proc setNetwork(conf: var NetConfiguration, id: PublicNetwork) =
conf.bootNodes.setBootnodes(RopstenBootnodes)
of RinkebyNet:
conf.bootNodes.setBootnodes(RinkebyBootnodes)
of GoerliNet:
conf.bootNodes.setBootnodes(GoerliBootnodes)
of KovanNet:
conf.bootNodes.setBootnodes(KovanBootnodes)
of CustomNet:
@ -593,6 +619,8 @@ proc processNetArguments(key, value: string): ConfigStatus =
config.net.setNetwork(RopstenNet)
elif skey == "rinkeby":
config.net.setNetwork(RinkebyNet)
elif skey == "goerli":
config.net.setNetwork(GoerliNet)
elif skey == "kovan":
config.net.setNetwork(KovanNet)
elif skey == "customnetwork":

View File

@ -1,5 +1,5 @@
import
tables, json, strutils,
tables, json, strutils, times,
eth/[common, rlp, trie], stint, stew/[byteutils, ranges],
chronicles, eth/trie/db,
db/[db_chain, state_db], genesis_alloc, config, constants
@ -32,7 +32,7 @@ func decodePrealloc(data: seq[byte]): GenesisAlloc =
for tup in rlp.decode(data.toRange, seq[(UInt256, UInt256)]):
result[toAddress(tup[0])] = GenesisAccount(balance: tup[1])
proc customNetPrealloc(genesisBlock: JsonNode): GenesisAlloc =
proc customNetPrealloc(genesisBlock: JsonNode): GenesisAlloc =
result = newTable[EthAddress, GenesisAccount]()
for address, balance in genesisBlock.pairs():
let balance = fromHex(UInt256,balance["balance"].getStr())
@ -58,12 +58,22 @@ proc defaultGenesisBlockForNetwork*(id: PublicNetwork): Genesis =
)
of RinkebyNet:
Genesis(
nonce: 66.toBlockNonce,
extraData: hexToSeqByte("0x3535353535353535353535353535353535353535353535353535353535353535"),
gasLimit: 16777216,
difficulty: 1048576.u256,
nonce: 0.toBlockNonce,
timestamp: initTime(0x58ee40ba, 0),
extraData: hexToSeqByte("0x52657370656374206d7920617574686f7269746168207e452e436172746d616e42eb768f2244c8811c63729a21a3569731535f067ffc57839b00206d1ad20c69a1981b489f772031b279182d99e65703f0076e4812653aab85fca0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
gasLimit: 4700000,
difficulty: 1.u256,
alloc: decodePrealloc(rinkebyAllocData)
)
of GoerliNet:
Genesis(
nonce: 0.toBlockNonce,
timestamp: initTime(0x5c51a607, 0),
extraData: hexToSeqByte("0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
gasLimit: 0xa00000,
difficulty: 1.u256,
alloc: decodePrealloc(goerliAllocData)
)
of CustomNet:
let genesis = getConfiguration().customGenesis
var alloc = new GenesisAlloc

File diff suppressed because one or more lines are too long

View File

@ -6,3 +6,21 @@ proc genesisMain*() =
let g = defaultGenesisBlockForNetwork(MainNet)
let b = g.toBlock
check(b.blockHash == "D4E56740F876AEF8C010B86A40D5F56745A118D0906A34E69AEC8C0DB1CB8FA3".toDigest)
test "Correct ropstennet hash":
let g = defaultGenesisBlockForNetwork(RopstenNet)
let b = g.toBlock
check(b.blockHash == "41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d".toDigest)
test "Correct rinkebynet hash":
let g = defaultGenesisBlockForNetwork(RinkebyNet)
let b = g.toBlock
check(b.blockHash == "6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177".toDigest)
test "Correct goerlinet hash":
let g = defaultGenesisBlockForNetwork(GoerliNet)
let b = g.toBlock
check(b.blockHash == "bf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a".toDigest)
when isMainModule:
genesisMain()