move toFork to config.nim
This commit is contained in:
parent
a864967c4f
commit
e324a7342d
|
@ -138,8 +138,6 @@ type
|
||||||
istanbulBlock*: BlockNumber
|
istanbulBlock*: BlockNumber
|
||||||
muirGlacierBlock*: BlockNumber
|
muirGlacierBlock*: BlockNumber
|
||||||
|
|
||||||
toForkImpl*: proc(c: ChainConfig, blockNumber: BlockNumber): Fork
|
|
||||||
|
|
||||||
NimbusConfiguration* = ref object
|
NimbusConfiguration* = ref object
|
||||||
## Main Nimbus configuration object
|
## Main Nimbus configuration object
|
||||||
dataDir*: string
|
dataDir*: string
|
||||||
|
@ -164,6 +162,7 @@ type
|
||||||
constantinopleBlock*: BlockNumber
|
constantinopleBlock*: BlockNumber
|
||||||
petersburgBlock*: BlockNumber
|
petersburgBlock*: BlockNumber
|
||||||
istanbulBlock*: BlockNumber
|
istanbulBlock*: BlockNumber
|
||||||
|
muirGlacierBlock*: BlockNumber
|
||||||
nonce*: BlockNonce
|
nonce*: BlockNonce
|
||||||
extraData*: seq[byte]
|
extraData*: seq[byte]
|
||||||
gasLimit*: int64
|
gasLimit*: int64
|
||||||
|
@ -183,18 +182,15 @@ var nimbusConfig {.threadvar.}: NimbusConfiguration
|
||||||
|
|
||||||
proc getConfiguration*(): NimbusConfiguration {.gcsafe.}
|
proc getConfiguration*(): NimbusConfiguration {.gcsafe.}
|
||||||
|
|
||||||
template toFork*(c: ChainConfig, blockNumber: BlockNumber): Fork =
|
proc toFork*(c: ChainConfig, number: BlockNumber): Fork =
|
||||||
c.toForkImpl(c, blockNumber)
|
if number >= c.istanbulBlock: FkIstanbul
|
||||||
|
elif number >= c.petersburgBlock: FkPetersburg
|
||||||
proc defaultToForkImpl(c: ChainConfig, blockNumber: BlockNumber): Fork =
|
elif number >= c.constantinopleBlock: FkConstantinople
|
||||||
if blockNumber < c.homesteadBlock: FkFrontier
|
elif number >= c.byzantiumBlock: FkByzantium
|
||||||
elif blockNumber < c.eip150Block: FkHomestead
|
elif number >= c.eip158Block: FkSpurious
|
||||||
elif blockNumber < c.eip158Block: FkTangerine
|
elif number >= c.eip150Block: FkTangerine
|
||||||
elif blockNumber < c.byzantiumBlock: FkSpurious
|
elif number >= c.homesteadBlock: FkHomestead
|
||||||
elif blockNumber < c.constantinopleBlock: FkByzantium
|
else: FkFrontier
|
||||||
elif blockNumber < c.petersburgBlock: FkConstantinople
|
|
||||||
elif blockNumber < c.istanbulBlock: FkPetersburg
|
|
||||||
else: FkIstanbul
|
|
||||||
|
|
||||||
proc privateChainConfig*(): ChainConfig =
|
proc privateChainConfig*(): ChainConfig =
|
||||||
let config = getConfiguration()
|
let config = getConfiguration()
|
||||||
|
@ -211,7 +207,7 @@ proc privateChainConfig*(): ChainConfig =
|
||||||
constantinopleBlock: config.customGenesis.constantinopleBlock,
|
constantinopleBlock: config.customGenesis.constantinopleBlock,
|
||||||
petersburgBlock: config.customGenesis.petersburgBlock,
|
petersburgBlock: config.customGenesis.petersburgBlock,
|
||||||
istanbulBlock: config.customGenesis.istanbulBlock,
|
istanbulBlock: config.customGenesis.istanbulBlock,
|
||||||
toForkImpl: defaultToForkImpl
|
muirGlacierBlock: config.customGenesis.muirGlacierBlock
|
||||||
)
|
)
|
||||||
trace "Custom genesis block configuration loaded", configuration=result
|
trace "Custom genesis block configuration loaded", configuration=result
|
||||||
|
|
||||||
|
@ -231,15 +227,7 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
|
||||||
constantinopleBlock: 7_280_000.toBlockNumber, # Never Occured in MainNet
|
constantinopleBlock: 7_280_000.toBlockNumber, # Never Occured in MainNet
|
||||||
petersburgBlock:7_280_000.toBlockNumber, # 28/02/2019 07:52:04
|
petersburgBlock:7_280_000.toBlockNumber, # 28/02/2019 07:52:04
|
||||||
istanbulBlock: 9_069_000.toBlockNumber, # 08/12/2019 12:25:09
|
istanbulBlock: 9_069_000.toBlockNumber, # 08/12/2019 12:25:09
|
||||||
muirGlacierBlock: 9_200_000.toBlockNumber, # 02/01/2020 08:30:49
|
muirGlacierBlock: 9_200_000.toBlockNumber # 02/01/2020 08:30:49
|
||||||
toForkImpl: proc(c: ChainConfig, blockNumber: BlockNumber): Fork =
|
|
||||||
if blockNumber < c.homesteadBlock: FkFrontier
|
|
||||||
elif blockNumber < c.eip150Block: FkHomestead
|
|
||||||
elif blockNumber < c.eip158Block: FkTangerine
|
|
||||||
elif blockNumber < c.byzantiumBlock: FkSpurious
|
|
||||||
elif blockNumber < c.petersburgBlock: FkByzantium
|
|
||||||
elif blockNumber < c.istanbulBlock: FkPetersburg
|
|
||||||
else: FkIstanbul
|
|
||||||
)
|
)
|
||||||
of RopstenNet:
|
of RopstenNet:
|
||||||
ChainConfig(
|
ChainConfig(
|
||||||
|
@ -254,13 +242,7 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
|
||||||
constantinopleBlock: 4_230_000.toBlockNumber,
|
constantinopleBlock: 4_230_000.toBlockNumber,
|
||||||
petersburgBlock:4_939_394.toBlockNumber,
|
petersburgBlock:4_939_394.toBlockNumber,
|
||||||
istanbulBlock: 6_485_846.toBlockNumber,
|
istanbulBlock: 6_485_846.toBlockNumber,
|
||||||
muirGlacierBlock: 7_117_117.toBlockNumber,
|
muirGlacierBlock: 7_117_117.toBlockNumber
|
||||||
toForkImpl: proc(c: ChainConfig, blockNumber: BlockNumber): Fork =
|
|
||||||
if blockNumber < c.eip158Block: FkTangerine
|
|
||||||
elif blockNumber < c.byzantiumBlock: FkSpurious
|
|
||||||
elif blockNumber < c.petersburgBlock: FkByzantium
|
|
||||||
elif blockNumber < c.istanbulBlock: FkPetersburg
|
|
||||||
else: FkIstanbul
|
|
||||||
)
|
)
|
||||||
of RinkebyNet:
|
of RinkebyNet:
|
||||||
ChainConfig(
|
ChainConfig(
|
||||||
|
@ -275,8 +257,7 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
|
||||||
constantinopleBlock: 3_660_663.toBlockNumber,
|
constantinopleBlock: 3_660_663.toBlockNumber,
|
||||||
petersburgBlock:4_321_234.toBlockNumber,
|
petersburgBlock:4_321_234.toBlockNumber,
|
||||||
istanbulBlock: 5_435_345.toBlockNumber,
|
istanbulBlock: 5_435_345.toBlockNumber,
|
||||||
muirGlacierBlock: high(BlockNumber).toBlockNumber,
|
muirGlacierBlock: high(BlockNumber).toBlockNumber
|
||||||
toForkImpl: defaultToForkImpl
|
|
||||||
)
|
)
|
||||||
of GoerliNet:
|
of GoerliNet:
|
||||||
ChainConfig(
|
ChainConfig(
|
||||||
|
@ -291,10 +272,7 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
|
||||||
constantinopleBlock: 0.toBlockNumber,
|
constantinopleBlock: 0.toBlockNumber,
|
||||||
petersburgBlock: 0.toBlockNumber,
|
petersburgBlock: 0.toBlockNumber,
|
||||||
istanbulBlock: 1_561_651.toBlockNumber,
|
istanbulBlock: 1_561_651.toBlockNumber,
|
||||||
muirGlacierBlock: high(BlockNumber).toBlockNumber,
|
muirGlacierBlock: high(BlockNumber).toBlockNumber
|
||||||
toForkImpl: proc(c: ChainConfig, blockNumber: BlockNumber): Fork =
|
|
||||||
if blockNumber < c.istanbulBlock: FkPetersburg
|
|
||||||
else: FkIstanbul
|
|
||||||
)
|
)
|
||||||
of CustomNet:
|
of CustomNet:
|
||||||
privateChainConfig()
|
privateChainConfig()
|
||||||
|
@ -362,7 +340,7 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
|
||||||
var
|
var
|
||||||
chainId = 0.uint
|
chainId = 0.uint
|
||||||
homesteadBlock, daoForkblock, eip150Block, eip155Block, eip158Block, byzantiumBlock, constantinopleBlock = 0.toBlockNumber
|
homesteadBlock, daoForkblock, eip150Block, eip155Block, eip158Block, byzantiumBlock, constantinopleBlock = 0.toBlockNumber
|
||||||
petersburgBlock, istanbulBlock = 0.toBlockNumber
|
petersburgBlock, istanbulBlock, muirGlacierBlock = 0.toBlockNumber
|
||||||
eip150Hash, mixHash : MDigest[256]
|
eip150Hash, mixHash : MDigest[256]
|
||||||
daoForkSupport = false
|
daoForkSupport = false
|
||||||
nonce = 66.toBlockNonce
|
nonce = 66.toBlockNonce
|
||||||
|
@ -392,6 +370,7 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
|
||||||
checkForFork(forkDetails, constantinopleBlock, byzantiumBlock)
|
checkForFork(forkDetails, constantinopleBlock, byzantiumBlock)
|
||||||
checkForFork(forkDetails, petersburgBlock, constantinopleBlock)
|
checkForFork(forkDetails, petersburgBlock, constantinopleBlock)
|
||||||
checkForFork(forkDetails, istanbulBlock, petersburgBlock)
|
checkForFork(forkDetails, istanbulBlock, petersburgBlock)
|
||||||
|
checkForFork(forkDetails, muirGlacierBlock, istanbulBlock)
|
||||||
else:
|
else:
|
||||||
error "No chain configuration found."
|
error "No chain configuration found."
|
||||||
quit(1)
|
quit(1)
|
||||||
|
@ -418,6 +397,7 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
|
||||||
constantinopleBlock: constantinopleBlock,
|
constantinopleBlock: constantinopleBlock,
|
||||||
petersburgBlock: petersburgBlock,
|
petersburgBlock: petersburgBlock,
|
||||||
istanbulBlock: istanbulBlock,
|
istanbulBlock: istanbulBlock,
|
||||||
|
muirGlacierBlock: muirGlacierBlock,
|
||||||
nonce: nonce,
|
nonce: nonce,
|
||||||
extraData: extraData,
|
extraData: extraData,
|
||||||
gasLimit: gasLimit,
|
gasLimit: gasLimit,
|
||||||
|
|
Loading…
Reference in New Issue