more to update chain config [skip ci]

This commit is contained in:
andri lim 2020-04-11 16:59:46 +07:00
parent 6591893158
commit a864967c4f
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 60 additions and 10 deletions

View File

@ -136,6 +136,9 @@ type
constantinopleBlock*: BlockNumber
petersburgBlock*: BlockNumber
istanbulBlock*: BlockNumber
muirGlacierBlock*: BlockNumber
toForkImpl*: proc(c: ChainConfig, blockNumber: BlockNumber): Fork
NimbusConfiguration* = ref object
## Main Nimbus configuration object
@ -180,6 +183,19 @@ var nimbusConfig {.threadvar.}: NimbusConfiguration
proc getConfiguration*(): NimbusConfiguration {.gcsafe.}
template toFork*(c: ChainConfig, blockNumber: BlockNumber): Fork =
c.toForkImpl(c, blockNumber)
proc defaultToForkImpl(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.constantinopleBlock: FkByzantium
elif blockNumber < c.petersburgBlock: FkConstantinople
elif blockNumber < c.istanbulBlock: FkPetersburg
else: FkIstanbul
proc privateChainConfig*(): ChainConfig =
let config = getConfiguration()
result = ChainConfig(
@ -194,7 +210,8 @@ proc privateChainConfig*(): ChainConfig =
byzantiumBlock: config.customGenesis.byzantiumBlock,
constantinopleBlock: config.customGenesis.constantinopleBlock,
petersburgBlock: config.customGenesis.petersburgBlock,
istanbulBlock: config.customGenesis.istanbulBlock
istanbulBlock: config.customGenesis.istanbulBlock,
toForkImpl: defaultToForkImpl
)
trace "Custom genesis block configuration loaded", configuration=result
@ -203,14 +220,26 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
of MainNet:
ChainConfig(
chainId: MainNet.uint,
homesteadBlock: forkBlocks[FkHomestead],
daoForkBlock: forkBlocks[FkDao],
homesteadBlock: 1_150_000.toBlockNumber, # 14/03/2016 20:49:53
daoForkBlock: 1_920_000.toBlockNumber,
daoForkSupport: true,
eip150Block: forkBlocks[FkTangerine],
eip150Block: 2_463_000.toBlockNumber, # 18/10/2016 17:19:31
eip150Hash: toDigest("2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
eip155Block: forkBlocks[FkSpurious],
eip158Block: forkBlocks[FkSpurious],
byzantiumBlock: forkBlocks[FkByzantium]
eip155Block: 2_675_000.toBlockNumber, # 22/11/2016 18:15:44
eip158Block: 2_675_000.toBlockNumber,
byzantiumBlock: 4_370_000.toBlockNumber, # 16/10/2017 09:22:11
constantinopleBlock: 7_280_000.toBlockNumber, # Never Occured in MainNet
petersburgBlock:7_280_000.toBlockNumber, # 28/02/2019 07:52:04
istanbulBlock: 9_069_000.toBlockNumber, # 08/12/2019 12:25:09
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:
ChainConfig(
@ -221,7 +250,17 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
eip150Hash: toDigest("41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
eip155Block: 10.toBlockNumber,
eip158Block: 10.toBlockNumber,
byzantiumBlock: 1700000.toBlockNumber
byzantiumBlock: 1_700_000.toBlockNumber,
constantinopleBlock: 4_230_000.toBlockNumber,
petersburgBlock:4_939_394.toBlockNumber,
istanbulBlock: 6_485_846.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:
ChainConfig(
@ -232,7 +271,12 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
eip150Hash: toDigest("9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
eip155Block: 3.toBlockNumber,
eip158Block: 3.toBlockNumber,
byzantiumBlock: 1035301.toBlockNumber
byzantiumBlock: 1_035_301.toBlockNumber,
constantinopleBlock: 3_660_663.toBlockNumber,
petersburgBlock:4_321_234.toBlockNumber,
istanbulBlock: 5_435_345.toBlockNumber,
muirGlacierBlock: high(BlockNumber).toBlockNumber,
toForkImpl: defaultToForkImpl
)
of GoerliNet:
ChainConfig(
@ -244,7 +288,13 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
eip155Block: 0.toBlockNumber,
eip158Block: 0.toBlockNumber,
byzantiumBlock: 0.toBlockNumber,
istanbulBlock: 1561651.toBlockNumber
constantinopleBlock: 0.toBlockNumber,
petersburgBlock: 0.toBlockNumber,
istanbulBlock: 1_561_651.toBlockNumber,
muirGlacierBlock: high(BlockNumber).toBlockNumber,
toForkImpl: proc(c: ChainConfig, blockNumber: BlockNumber): Fork =
if blockNumber < c.istanbulBlock: FkPetersburg
else: FkIstanbul
)
of CustomNet:
privateChainConfig()