drop PublicNetwork enum usage and replace it with NetworkId
we cannot limit the `--networkid` switch to values available in `PublicNetwork` enum. it should able to accept very wide range of custom NetworkId.
This commit is contained in:
parent
d12e7d22bf
commit
a0d10f5728
|
@ -27,7 +27,7 @@ proc processNode(genesisFile, chainFile,
|
||||||
conf = getConfiguration()
|
conf = getConfiguration()
|
||||||
chainDB = newBaseChainDB(newMemoryDb(),
|
chainDB = newBaseChainDB(newMemoryDb(),
|
||||||
pruneTrie = false,
|
pruneTrie = false,
|
||||||
id = toPublicNetwork(conf.net.networkId)
|
conf.net.networkId
|
||||||
)
|
)
|
||||||
|
|
||||||
initializeEmptyDb(chainDB)
|
initializeEmptyDb(chainDB)
|
||||||
|
|
|
@ -78,11 +78,11 @@ proc main() =
|
||||||
ethNode = setupEthNode(eth)
|
ethNode = setupEthNode(eth)
|
||||||
chainDB = newBaseChainDB(newMemoryDb(),
|
chainDB = newBaseChainDB(newMemoryDb(),
|
||||||
pruneTrie = false,
|
pruneTrie = false,
|
||||||
id = toPublicNetwork(conf.net.networkId)
|
conf.net.networkId
|
||||||
)
|
)
|
||||||
|
|
||||||
initializeEmptyDb(chainDB)
|
initializeEmptyDb(chainDB)
|
||||||
importRlpBlock(blocksFile, chainDB)
|
discard importRlpBlock(blocksFile, chainDB)
|
||||||
let ctx = setupGraphqlContext(chainDB, ethNode)
|
let ctx = setupGraphqlContext(chainDB, ethNode)
|
||||||
|
|
||||||
runTest("GraphQL", caseFolder):
|
runTest("GraphQL", caseFolder):
|
||||||
|
|
|
@ -53,6 +53,10 @@ type
|
||||||
muirGlacierBlock* : BlockNumber
|
muirGlacierBlock* : BlockNumber
|
||||||
berlinBlock* : BlockNumber
|
berlinBlock* : BlockNumber
|
||||||
|
|
||||||
|
# TODO: this need to be fixed somehow
|
||||||
|
# using `real` engine configuration
|
||||||
|
poaEngine* : bool
|
||||||
|
|
||||||
Genesis* = object
|
Genesis* = object
|
||||||
nonce* : BlockNonce
|
nonce* : BlockNonce
|
||||||
timestamp* : EthTime
|
timestamp* : EthTime
|
||||||
|
@ -156,6 +160,10 @@ proc loadCustomGenesis*(fileName: string, cg: var CustomGenesis): bool =
|
||||||
cg.config.daoForkSupport = cc.config.daoForkSupport
|
cg.config.daoForkSupport = cc.config.daoForkSupport
|
||||||
cg.config.eip150Hash = cc.config.eip150Hash
|
cg.config.eip150Hash = cc.config.eip150Hash
|
||||||
|
|
||||||
|
# TODO: this need to be fixed somehow
|
||||||
|
# using `real` engine configuration
|
||||||
|
cg.config.poaEngine = false
|
||||||
|
|
||||||
template validateFork(forkName: untyped, nextBlock: BlockNumber) =
|
template validateFork(forkName: untyped, nextBlock: BlockNumber) =
|
||||||
let fork = astToStr(forkName)
|
let fork = astToStr(forkName)
|
||||||
if cc.config.forkName.isSome:
|
if cc.config.forkName.isSome:
|
||||||
|
|
|
@ -75,19 +75,11 @@ type
|
||||||
enabled*: bool
|
enabled*: bool
|
||||||
address*: TransportAddress
|
address*: TransportAddress
|
||||||
|
|
||||||
PublicNetwork* = enum
|
|
||||||
CustomNet = 0
|
|
||||||
MainNet = 1
|
|
||||||
# No longer used: MordenNet = 2
|
|
||||||
RopstenNet = 3
|
|
||||||
RinkebyNet = 4
|
|
||||||
GoerliNet = 5
|
|
||||||
KovanNet = 42
|
|
||||||
|
|
||||||
NetworkFlags* = enum
|
NetworkFlags* = enum
|
||||||
## Ethereum network flags
|
## Ethereum network flags
|
||||||
NoDiscover, ## Peer discovery disabled
|
NoDiscover ## Peer discovery disabled
|
||||||
V5Discover, ## Dicovery V5 enabled
|
V5Discover ## Dicovery V5 enabled
|
||||||
|
NetworkIdSet ## prevent CustomNetwork replacement
|
||||||
|
|
||||||
DebugFlags* {.pure.} = enum
|
DebugFlags* {.pure.} = enum
|
||||||
## Debug selection flags
|
## Debug selection flags
|
||||||
|
@ -148,6 +140,16 @@ type
|
||||||
accounts*: Table[EthAddress, NimbusAccount]
|
accounts*: Table[EthAddress, NimbusAccount]
|
||||||
importFile*: string
|
importFile*: string
|
||||||
|
|
||||||
|
const
|
||||||
|
# these are public network id
|
||||||
|
CustomNet* = 0.NetworkId
|
||||||
|
MainNet* = 1.NetworkId
|
||||||
|
# No longer used: MordenNet = 2
|
||||||
|
RopstenNet* = 3.NetworkId
|
||||||
|
RinkebyNet* = 4.NetworkId
|
||||||
|
GoerliNet* = 5.NetworkId
|
||||||
|
KovanNet* = 42.NetworkId
|
||||||
|
|
||||||
const
|
const
|
||||||
defaultRpcApi = {RpcFlags.Eth, RpcFlags.Shh}
|
defaultRpcApi = {RpcFlags.Eth, RpcFlags.Shh}
|
||||||
defaultProtocols = {ProtocolFlags.Eth, ProtocolFlags.Shh}
|
defaultProtocols = {ProtocolFlags.Eth, ProtocolFlags.Shh}
|
||||||
|
@ -172,7 +174,7 @@ proc toFork*(c: ChainConfig, number: BlockNumber): Fork =
|
||||||
elif number >= c.homesteadBlock: FkHomestead
|
elif number >= c.homesteadBlock: FkHomestead
|
||||||
else: FkFrontier
|
else: FkFrontier
|
||||||
|
|
||||||
proc publicChainConfig*(id: PublicNetwork): ChainConfig =
|
proc chainConfig*(id: NetworkId): ChainConfig =
|
||||||
# For some public networks, NetworkId and ChainId value are identical
|
# For some public networks, NetworkId and ChainId value are identical
|
||||||
# but that is not always the case
|
# but that is not always the case
|
||||||
|
|
||||||
|
@ -242,14 +244,11 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
|
||||||
muirGlacierBlock: 4_460_644.toBlockNumber, # never occured in goerli network
|
muirGlacierBlock: 4_460_644.toBlockNumber, # never occured in goerli network
|
||||||
berlinBlock: 4_460_644.toBlockNumber
|
berlinBlock: 4_460_644.toBlockNumber
|
||||||
)
|
)
|
||||||
of CustomNet:
|
else:
|
||||||
|
# everything else will use CustomNet config
|
||||||
let conf = getConfiguration()
|
let conf = getConfiguration()
|
||||||
trace "Custom genesis block configuration loaded", conf=conf.customGenesis.config
|
trace "Custom genesis block configuration loaded", conf=conf.customGenesis.config
|
||||||
conf.customGenesis.config
|
conf.customGenesis.config
|
||||||
else:
|
|
||||||
error "No chain config for public network", networkId = id
|
|
||||||
doAssert(false, "No chain config for " & $id)
|
|
||||||
ChainConfig()
|
|
||||||
|
|
||||||
proc processList(v: string, o: var seq[string]) =
|
proc processList(v: string, o: var seq[string]) =
|
||||||
## Process comma-separated list of strings.
|
## Process comma-separated list of strings.
|
||||||
|
@ -418,18 +417,9 @@ proc setBootnodes(onodes: var seq[ENode], nodeUris: openarray[string]) =
|
||||||
doAssert(processENode(item, node) == Success)
|
doAssert(processENode(item, node) == Success)
|
||||||
onodes.add(node)
|
onodes.add(node)
|
||||||
|
|
||||||
macro availableEnumValues(T: type enum): untyped =
|
proc setNetwork(conf: var NetConfiguration, id: NetworkId) =
|
||||||
let impl = getTypeImpl(T)[1].getTypeImpl()
|
|
||||||
result = newNimNode(nnkBracket)
|
|
||||||
for i in 1 ..< impl.len: result.add(newCall("NetworkId", copyNimTree(impl[i])))
|
|
||||||
|
|
||||||
proc toPublicNetwork*(id: NetworkId): PublicNetwork {.inline.} =
|
|
||||||
if id in availableEnumValues(PublicNetwork):
|
|
||||||
result = PublicNetwork(id)
|
|
||||||
|
|
||||||
proc setNetwork(conf: var NetConfiguration, id: PublicNetwork) =
|
|
||||||
## Set network id and default network bootnodes
|
## Set network id and default network bootnodes
|
||||||
conf.networkId = NetworkId(id)
|
conf.networkId = id
|
||||||
case id
|
case id
|
||||||
of MainNet:
|
of MainNet:
|
||||||
conf.bootNodes.setBootnodes(MainnetBootnodes)
|
conf.bootNodes.setBootnodes(MainnetBootnodes)
|
||||||
|
@ -441,16 +431,10 @@ proc setNetwork(conf: var NetConfiguration, id: PublicNetwork) =
|
||||||
conf.bootNodes.setBootnodes(GoerliBootnodes)
|
conf.bootNodes.setBootnodes(GoerliBootnodes)
|
||||||
of KovanNet:
|
of KovanNet:
|
||||||
conf.bootNodes.setBootnodes(KovanBootnodes)
|
conf.bootNodes.setBootnodes(KovanBootnodes)
|
||||||
of CustomNet:
|
|
||||||
discard
|
|
||||||
|
|
||||||
proc setNetwork(conf: var NetConfiguration, id: NetworkId) =
|
|
||||||
## Set network id and default network bootnodes
|
|
||||||
let pubNet = toPublicNetwork(id)
|
|
||||||
if pubNet == CustomNet:
|
|
||||||
conf.networkId = id
|
|
||||||
else:
|
else:
|
||||||
conf.setNetwork(pubNet)
|
# everything else will use bootnodes
|
||||||
|
# from --bootnodes switch
|
||||||
|
discard
|
||||||
|
|
||||||
proc processNetArguments(key, value: string): ConfigStatus =
|
proc processNetArguments(key, value: string): ConfigStatus =
|
||||||
## Processes only `Networking` related command line options
|
## Processes only `Networking` related command line options
|
||||||
|
@ -480,12 +464,18 @@ proc processNetArguments(key, value: string): ConfigStatus =
|
||||||
elif skey == "customnetwork":
|
elif skey == "customnetwork":
|
||||||
if not loadCustomGenesis(value, config.customGenesis):
|
if not loadCustomGenesis(value, config.customGenesis):
|
||||||
result = Error
|
result = Error
|
||||||
config.net.networkId = NetworkId(CustomNet)
|
if NetworkIdSet notin config.net.flags:
|
||||||
|
# prevent clash with --networkid if it already set
|
||||||
|
# because any --networkid value that is not
|
||||||
|
# in the public network will also translated as
|
||||||
|
# CustomNetwork
|
||||||
|
config.net.networkId = CustomNet
|
||||||
elif skey == "networkid":
|
elif skey == "networkid":
|
||||||
var res = 0
|
var res = 0
|
||||||
result = processInteger(value, res)
|
result = processInteger(value, res)
|
||||||
if result == Success:
|
if result == Success:
|
||||||
config.net.setNetwork(NetworkId(result))
|
config.net.setNetwork(NetworkId(result))
|
||||||
|
config.net.flags.incl NetworkIdSet
|
||||||
elif skey == "nodiscover":
|
elif skey == "nodiscover":
|
||||||
config.net.flags.incl(NoDiscover)
|
config.net.flags.incl(NoDiscover)
|
||||||
elif skey == "v5discover":
|
elif skey == "v5discover":
|
||||||
|
@ -655,7 +645,7 @@ proc initConfiguration(): NimbusConfiguration =
|
||||||
result.rpc.binds = @[initTAddress("127.0.0.1:8545")]
|
result.rpc.binds = @[initTAddress("127.0.0.1:8545")]
|
||||||
|
|
||||||
## Network defaults
|
## Network defaults
|
||||||
result.net.setNetwork(defaultNetwork.NetworkId)
|
result.net.setNetwork(defaultNetwork)
|
||||||
result.net.maxPeers = 25
|
result.net.maxPeers = 25
|
||||||
result.net.maxPendingPeers = 0
|
result.net.maxPendingPeers = 0
|
||||||
result.net.bindPort = 30303'u16
|
result.net.bindPort = 30303'u16
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import
|
import
|
||||||
sequtils, algorithm,
|
sequtils, algorithm,
|
||||||
stew/[byteutils], eth/trie/[hexary, db],
|
stew/[byteutils], eth/trie/[hexary, db],
|
||||||
eth/[common, rlp], chronicles,
|
eth/[common, rlp, p2p], chronicles,
|
||||||
../errors, ../constants, ./storage_types,
|
../errors, ../constants, ./storage_types,
|
||||||
../utils, ../config, ../chain_config
|
../utils, ../config, ../chain_config
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ type
|
||||||
db* : TrieDatabaseRef
|
db* : TrieDatabaseRef
|
||||||
pruneTrie*: bool
|
pruneTrie*: bool
|
||||||
config* : ChainConfig
|
config* : ChainConfig
|
||||||
networkId*: PublicNetwork
|
networkId*: NetworkId
|
||||||
|
|
||||||
# startingBlock, currentBlock, and highestBlock
|
# startingBlock, currentBlock, and highestBlock
|
||||||
# are progress indicator
|
# are progress indicator
|
||||||
|
@ -29,11 +29,11 @@ type
|
||||||
blockNumber: BlockNumber
|
blockNumber: BlockNumber
|
||||||
index: int
|
index: int
|
||||||
|
|
||||||
proc newBaseChainDB*(db: TrieDatabaseRef, pruneTrie: bool = true, id: PublicNetwork = MainNet): BaseChainDB =
|
proc newBaseChainDB*(db: TrieDatabaseRef, pruneTrie: bool = true, id: NetworkId = MainNet): BaseChainDB =
|
||||||
new(result)
|
new(result)
|
||||||
result.db = db
|
result.db = db
|
||||||
result.pruneTrie = pruneTrie
|
result.pruneTrie = pruneTrie
|
||||||
result.config = publicChainConfig(id)
|
result.config = chainConfig(id)
|
||||||
result.networkId = id
|
result.networkId = id
|
||||||
|
|
||||||
proc `$`*(db: BaseChainDB): string =
|
proc `$`*(db: BaseChainDB): string =
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import
|
import
|
||||||
std/[json, strutils, times, tables],
|
std/[json, strutils, times, tables],
|
||||||
eth/[common, rlp, trie], stew/[byteutils],
|
eth/[common, rlp, trie, p2p], stew/[byteutils],
|
||||||
chronicles, eth/trie/db,
|
chronicles, eth/trie/db,
|
||||||
./db/[db_chain, state_db],
|
./db/[db_chain, state_db],
|
||||||
./genesis_alloc, ./config, ./constants,
|
./genesis_alloc, ./config, ./constants,
|
||||||
./chain_config
|
./chain_config
|
||||||
|
|
||||||
proc defaultGenesisBlockForNetwork*(id: PublicNetwork): Genesis =
|
proc defaultGenesisBlockForNetwork*(id: NetworkId): Genesis =
|
||||||
result = case id
|
result = case id
|
||||||
of MainNet:
|
of MainNet:
|
||||||
Genesis(
|
Genesis(
|
||||||
|
@ -42,14 +42,10 @@ proc defaultGenesisBlockForNetwork*(id: PublicNetwork): Genesis =
|
||||||
difficulty: 1.u256,
|
difficulty: 1.u256,
|
||||||
alloc: decodePrealloc(goerliAllocData)
|
alloc: decodePrealloc(goerliAllocData)
|
||||||
)
|
)
|
||||||
of CustomNet:
|
else:
|
||||||
|
# everything else will use custom genesis
|
||||||
let customGenesis = getConfiguration().customGenesis
|
let customGenesis = getConfiguration().customGenesis
|
||||||
customGenesis.genesis
|
customGenesis.genesis
|
||||||
else:
|
|
||||||
# TODO: Fill out the rest
|
|
||||||
error "No default genesis for network", id
|
|
||||||
doAssert(false, "No default genesis for " & $id)
|
|
||||||
Genesis()
|
|
||||||
|
|
||||||
proc toBlock*(g: Genesis, db: BaseChainDB = nil): BlockHeader =
|
proc toBlock*(g: Genesis, db: BaseChainDB = nil): BlockHeader =
|
||||||
let (tdb, pruneTrie) = if db.isNil: (newMemoryDB(), true)
|
let (tdb, pruneTrie) = if db.isNil: (newMemoryDB(), true)
|
||||||
|
@ -91,5 +87,5 @@ proc commit*(g: Genesis, db: BaseChainDB) =
|
||||||
|
|
||||||
proc initializeEmptyDb*(db: BaseChainDB) =
|
proc initializeEmptyDb*(db: BaseChainDB) =
|
||||||
trace "Writing genesis to DB"
|
trace "Writing genesis to DB"
|
||||||
let networkId = getConfiguration().net.networkId.toPublicNetwork()
|
let networkId = getConfiguration().net.networkId
|
||||||
defaultGenesisBlockForNetwork(networkId).commit(db)
|
defaultGenesisBlockForNetwork(networkId).commit(db)
|
||||||
|
|
|
@ -52,7 +52,8 @@ proc start(nimbus: NimbusNode) =
|
||||||
let trieDB = trieDB newChainDb(conf.dataDir)
|
let trieDB = trieDB newChainDb(conf.dataDir)
|
||||||
var chainDB = newBaseChainDB(trieDB,
|
var chainDB = newBaseChainDB(trieDB,
|
||||||
conf.prune == PruneMode.Full,
|
conf.prune == PruneMode.Full,
|
||||||
conf.net.networkId.toPublicNetwork())
|
conf.net.networkId
|
||||||
|
)
|
||||||
chainDB.populateProgress()
|
chainDB.populateProgress()
|
||||||
|
|
||||||
if canonicalHeadHashKey().toOpenArray notin trieDB:
|
if canonicalHeadHashKey().toOpenArray notin trieDB:
|
||||||
|
|
|
@ -69,9 +69,10 @@ proc setupTxContext*(vmState: BaseVMState, origin: EthAddress, gasPrice: GasInt,
|
||||||
vmState.gasCosts = vmState.fork.forkToSchedule
|
vmState.gasCosts = vmState.fork.forkToSchedule
|
||||||
|
|
||||||
proc consensusEnginePoA*(vmState: BaseVMState): bool =
|
proc consensusEnginePoA*(vmState: BaseVMState): bool =
|
||||||
let networkId = vmState.chainDB.networkId
|
|
||||||
# PoA consensus engine have no reward for miner
|
# PoA consensus engine have no reward for miner
|
||||||
result = networkId in {GoerliNet, RinkebyNet, KovanNet}
|
# TODO: this need to be fixed somehow
|
||||||
|
# using `real` engine configuration
|
||||||
|
vmState.chainDB.config.poaEngine
|
||||||
|
|
||||||
proc getSignature(bytes: openArray[byte], output: var Signature): bool =
|
proc getSignature(bytes: openArray[byte], output: var Signature): bool =
|
||||||
let sig = Signature.fromRaw(bytes)
|
let sig = Signature.fromRaw(bytes)
|
||||||
|
|
|
@ -57,9 +57,10 @@ proc newBaseVMState*(prevStateRoot: Hash256,
|
||||||
result.init(prevStateRoot, header, chainDB, tracerFlags)
|
result.init(prevStateRoot, header, chainDB, tracerFlags)
|
||||||
|
|
||||||
proc consensusEnginePoA*(vmState: BaseVMState): bool =
|
proc consensusEnginePoA*(vmState: BaseVMState): bool =
|
||||||
let networkId = vmState.chainDB.networkId
|
|
||||||
# PoA consensus engine have no reward for miner
|
# PoA consensus engine have no reward for miner
|
||||||
result = networkId in {GoerliNet, RinkebyNet, KovanNet}
|
# TODO: this need to be fixed somehow
|
||||||
|
# using `real` engine configuration
|
||||||
|
vmState.chainDB.config.poaEngine
|
||||||
|
|
||||||
proc getSignature(bytes: openArray[byte], output: var Signature): bool =
|
proc getSignature(bytes: openArray[byte], output: var Signature): bool =
|
||||||
let sig = Signature.fromRaw(bytes)
|
let sig = Signature.fromRaw(bytes)
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
import stint, os, parseopt, strutils
|
import
|
||||||
from ../nimbus/config import getDefaultDataDir, ConfigStatus, processInteger, PublicNetwork
|
std/[os, parseopt, strutils],
|
||||||
|
eth/p2p, stint
|
||||||
|
|
||||||
|
from ../nimbus/config import
|
||||||
|
getDefaultDataDir,
|
||||||
|
ConfigStatus,
|
||||||
|
processInteger,
|
||||||
|
MainNet,
|
||||||
|
RopstenNet,
|
||||||
|
RinkebyNet,
|
||||||
|
GoerliNet,
|
||||||
|
KovanNet
|
||||||
|
|
||||||
export ConfigStatus
|
export ConfigStatus
|
||||||
|
|
||||||
|
@ -9,7 +20,7 @@ type
|
||||||
head*: Uint256
|
head*: Uint256
|
||||||
maxBlocks*: int
|
maxBlocks*: int
|
||||||
numCommits*: int
|
numCommits*: int
|
||||||
netId*: PublicNetwork
|
netId*: NetworkId
|
||||||
|
|
||||||
var premixConfig {.threadvar.}: PremixConfiguration
|
var premixConfig {.threadvar.}: PremixConfiguration
|
||||||
|
|
||||||
|
@ -38,7 +49,7 @@ proc processU256(val: string, o: var Uint256): ConfigStatus =
|
||||||
o = parse(val, Uint256)
|
o = parse(val, Uint256)
|
||||||
result = Success
|
result = Success
|
||||||
|
|
||||||
proc processNetId(val: string, o: var PublicNetwork): ConfigStatus =
|
proc processNetId(val: string, o: var NetworkId): ConfigStatus =
|
||||||
case val.toLowerAscii()
|
case val.toLowerAscii()
|
||||||
of "main": o = MainNet
|
of "main": o = MainNet
|
||||||
of "ropsten": o = RopstenNet
|
of "ropsten": o = RopstenNet
|
||||||
|
@ -46,9 +57,9 @@ proc processNetId(val: string, o: var PublicNetwork): ConfigStatus =
|
||||||
of "goerli": o = GoerliNet
|
of "goerli": o = GoerliNet
|
||||||
of "kovan": o = KovanNet
|
of "kovan": o = KovanNet
|
||||||
|
|
||||||
template checkArgument(fun, o: untyped) =
|
template checkArgument(fun, o, value: untyped) =
|
||||||
## Checks if arguments got processed successfully
|
## Checks if arguments got processed successfully
|
||||||
var res = (fun)(value, o)
|
let res = fun(value, o)
|
||||||
if res == Success:
|
if res == Success:
|
||||||
continue
|
continue
|
||||||
elif res == ErrorParseOption:
|
elif res == ErrorParseOption:
|
||||||
|
@ -76,14 +87,14 @@ proc processArguments*(msg: var string): ConfigStatus =
|
||||||
case key.toLowerAscii()
|
case key.toLowerAscii()
|
||||||
of "datadir": config.dataDir = value
|
of "datadir": config.dataDir = value
|
||||||
of "maxblocks":
|
of "maxblocks":
|
||||||
checkArgument processInteger, config.maxBlocks
|
checkArgument(processInteger, config.maxBlocks, value)
|
||||||
of "head":
|
of "head":
|
||||||
checkArgument processU256, config.head
|
checkArgument(processU256, config.head, value)
|
||||||
of "numcommits":
|
of "numcommits":
|
||||||
checkArgument processInteger, config.numCommits
|
checkArgument(processInteger, config.numCommits, value)
|
||||||
config.numCommits = max(config.numCommits, 512)
|
config.numCommits = max(config.numCommits, 512)
|
||||||
of "netid":
|
of "netid":
|
||||||
checkArgument processNetId, config.netId
|
checkArgument(processNetId, config.netId, value)
|
||||||
else:
|
else:
|
||||||
msg = "Unknown option " & key
|
msg = "Unknown option " & key
|
||||||
if value.len > 0: msg = msg & " : " & value
|
if value.len > 0: msg = msg & " : " & value
|
||||||
|
|
|
@ -61,11 +61,11 @@ template runTests(name: string, hex: bool, calculator: typed) =
|
||||||
check diff == t.currentDifficulty
|
check diff == t.currentDifficulty
|
||||||
|
|
||||||
proc difficultyMain*() =
|
proc difficultyMain*() =
|
||||||
let mainnetConfig = publicChainConfig(MainNet)
|
let mainnetConfig = chainConfig(MainNet)
|
||||||
func calcDifficultyMainNetWork(timeStamp: EthTime, parent: BlockHeader): DifficultyInt =
|
func calcDifficultyMainNetWork(timeStamp: EthTime, parent: BlockHeader): DifficultyInt =
|
||||||
mainnetConfig.calcDifficulty(timeStamp, parent)
|
mainnetConfig.calcDifficulty(timeStamp, parent)
|
||||||
|
|
||||||
let ropstenConfig = publicChainConfig(RopstenNet)
|
let ropstenConfig = chainConfig(RopstenNet)
|
||||||
func calcDifficultyRopsten(timeStamp: EthTime, parent: BlockHeader): DifficultyInt =
|
func calcDifficultyRopsten(timeStamp: EthTime, parent: BlockHeader): DifficultyInt =
|
||||||
ropstenConfig.calcDifficulty(timeStamp, parent)
|
ropstenConfig.calcDifficulty(timeStamp, parent)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import
|
import
|
||||||
unittest2, eth/common, eth/trie/db,
|
unittest2, eth/[common, p2p], eth/trie/db,
|
||||||
../nimbus/db/db_chain, ../nimbus/p2p/chain,
|
../nimbus/db/db_chain, ../nimbus/p2p/chain,
|
||||||
../nimbus/config
|
../nimbus/config
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ const
|
||||||
(blockNumber: 5000000'u64, id: (crc: 0x757a1c47'u32, nextFork: 0'u64)), # Future Berlin block
|
(blockNumber: 5000000'u64, id: (crc: 0x757a1c47'u32, nextFork: 0'u64)), # Future Berlin block
|
||||||
]
|
]
|
||||||
|
|
||||||
template runTest(network: PublicNetwork) =
|
template runTest(network: untyped) =
|
||||||
test network.astToStr:
|
test network.astToStr:
|
||||||
var
|
var
|
||||||
memDB = newMemoryDB()
|
memDB = newMemoryDB()
|
||||||
|
|
|
@ -49,7 +49,7 @@ proc setupChain(chainDB: BaseChainDB) =
|
||||||
conf.customGenesis.genesis.timestamp = genesis.header.timestamp
|
conf.customGenesis.genesis.timestamp = genesis.header.timestamp
|
||||||
if not parseGenesisAlloc($(jn["pre"]), conf.customGenesis.genesis.alloc):
|
if not parseGenesisAlloc($(jn["pre"]), conf.customGenesis.genesis.alloc):
|
||||||
quit(QuitFailure)
|
quit(QuitFailure)
|
||||||
|
|
||||||
chainDB.initializeEmptyDb()
|
chainDB.initializeEmptyDb()
|
||||||
|
|
||||||
let blocks = jn["blocks"]
|
let blocks = jn["blocks"]
|
||||||
|
@ -69,7 +69,7 @@ proc setupChain(chainDB: BaseChainDB) =
|
||||||
|
|
||||||
proc graphqlMain*() =
|
proc graphqlMain*() =
|
||||||
let conf = getConfiguration()
|
let conf = getConfiguration()
|
||||||
conf.net.networkId = NetworkId(CustomNet)
|
conf.net.networkId = CustomNet
|
||||||
conf.customGenesis.config = ChainConfig(
|
conf.customGenesis.config = ChainConfig(
|
||||||
chainId : MainNet.ChainId,
|
chainId : MainNet.ChainId,
|
||||||
byzantiumBlock : 0.toBlockNumber,
|
byzantiumBlock : 0.toBlockNumber,
|
||||||
|
@ -84,7 +84,7 @@ proc graphqlMain*() =
|
||||||
ethNode = setupEthNode(eth)
|
ethNode = setupEthNode(eth)
|
||||||
chainDB = newBaseChainDB(newMemoryDb(),
|
chainDB = newBaseChainDB(newMemoryDb(),
|
||||||
pruneTrie = false,
|
pruneTrie = false,
|
||||||
id = toPublicNetwork(conf.net.networkId)
|
conf.net.networkId
|
||||||
)
|
)
|
||||||
|
|
||||||
chainDB.setupChain()
|
chainDB.setupChain()
|
||||||
|
|
|
@ -142,7 +142,7 @@ proc doTests {.async.} =
|
||||||
debugEcho unlock.error
|
debugEcho unlock.error
|
||||||
doAssert(unlock.isOk)
|
doAssert(unlock.isOk)
|
||||||
|
|
||||||
defaultGenesisBlockForNetwork(conf.net.networkId.toPublicNetwork()).commit(chain)
|
defaultGenesisBlockForNetwork(conf.net.networkId).commit(chain)
|
||||||
doAssert(canonicalHeadHashKey().toOpenArray in chain.db)
|
doAssert(canonicalHeadHashKey().toOpenArray in chain.db)
|
||||||
let env = setupEnv(chain, signer, ks2, conf)
|
let env = setupEnv(chain, signer, ks2, conf)
|
||||||
|
|
||||||
|
|
|
@ -19,4 +19,7 @@ import
|
||||||
../premix/hunter,
|
../premix/hunter,
|
||||||
../premix/regress,
|
../premix/regress,
|
||||||
./tracerTestGen,
|
./tracerTestGen,
|
||||||
./persistBlockTestGen
|
./persistBlockTestGen,
|
||||||
|
../hive_integration/nodocker/consensus/extract_consensus_data,
|
||||||
|
../hive_integration/nodocker/consensus/consensus_sim,
|
||||||
|
../hive_integration/nodocker/graphql/graphql_sim
|
||||||
|
|
Loading…
Reference in New Issue