Merge pull request #539 from status-im/prepare_berlin

Preparation for Berlin HF
This commit is contained in:
andri lim 2020-11-19 13:03:20 +07:00 committed by GitHub
commit cd98ddbbd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 13 deletions

4
.gitmodules vendored
View File

@ -74,8 +74,8 @@
ignore = dirty
branch = master
[submodule "vendor/nim-blscurve"]
path = vendor/nim-blscurve
url = https://github.com/status-im/nim-blscurve
path = vendor/nim-blscurve
url = https://github.com/status-im/nim-blscurve
ignore = dirty
branch = master
[submodule "vendor/nim-chronos"]

View File

@ -144,6 +144,7 @@ type
petersburgBlock*: BlockNumber
istanbulBlock*: BlockNumber
muirGlacierBlock*: BlockNumber
berlinBlock*: BlockNumber
NimbusConfiguration* = ref object
## Main Nimbus configuration object
@ -174,6 +175,7 @@ type
petersburgBlock*: BlockNumber
istanbulBlock*: BlockNumber
muirGlacierBlock*: BlockNumber
berlinBlock*: BlockNumber
nonce*: BlockNonce
extraData*: seq[byte]
gasLimit*: int64
@ -194,7 +196,8 @@ var nimbusConfig {.threadvar.}: NimbusConfiguration
proc getConfiguration*(): NimbusConfiguration {.gcsafe.}
proc toFork*(c: ChainConfig, number: BlockNumber): Fork =
if number >= c.istanbulBlock: FkIstanbul
if number >= c.berlinBlock: FkBerlin
elif number >= c.istanbulBlock: FkIstanbul
elif number >= c.petersburgBlock: FkPetersburg
elif number >= c.constantinopleBlock: FkConstantinople
elif number >= c.byzantiumBlock: FkByzantium
@ -218,7 +221,8 @@ proc privateChainConfig*(): ChainConfig =
constantinopleBlock: config.customGenesis.constantinopleBlock,
petersburgBlock: config.customGenesis.petersburgBlock,
istanbulBlock: config.customGenesis.istanbulBlock,
muirGlacierBlock: config.customGenesis.muirGlacierBlock
muirGlacierBlock: config.customGenesis.muirGlacierBlock,
berlinBlock: config.customGenesis.berlinBlock
)
trace "Custom genesis block configuration loaded", configuration=result
@ -238,7 +242,8 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
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
muirGlacierBlock: 9_200_000.toBlockNumber, # 02/01/2020 08:30:49
berlinBlock: high(BlockNumber).toBlockNumber
)
of RopstenNet:
ChainConfig(
@ -253,7 +258,8 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
constantinopleBlock: 4_230_000.toBlockNumber,
petersburgBlock:4_939_394.toBlockNumber,
istanbulBlock: 6_485_846.toBlockNumber,
muirGlacierBlock: 7_117_117.toBlockNumber
muirGlacierBlock: 7_117_117.toBlockNumber,
berlinBlock: high(BlockNumber).toBlockNumber
)
of RinkebyNet:
ChainConfig(
@ -268,7 +274,8 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
constantinopleBlock: 3_660_663.toBlockNumber,
petersburgBlock:4_321_234.toBlockNumber,
istanbulBlock: 5_435_345.toBlockNumber,
muirGlacierBlock: high(BlockNumber).toBlockNumber
muirGlacierBlock: high(BlockNumber).toBlockNumber,
berlinBlock: high(BlockNumber).toBlockNumber
)
of GoerliNet:
ChainConfig(
@ -283,7 +290,8 @@ proc publicChainConfig*(id: PublicNetwork): ChainConfig =
constantinopleBlock: 0.toBlockNumber,
petersburgBlock: 0.toBlockNumber,
istanbulBlock: 1_561_651.toBlockNumber,
muirGlacierBlock: high(BlockNumber).toBlockNumber
muirGlacierBlock: high(BlockNumber).toBlockNumber,
berlinBlock: high(BlockNumber).toBlockNumber
)
of CustomNet:
privateChainConfig()
@ -351,7 +359,7 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
var
chainId = 0.uint
homesteadBlock, daoForkblock, eip150Block, eip155Block, eip158Block, byzantiumBlock, constantinopleBlock = 0.toBlockNumber
petersburgBlock, istanbulBlock, muirGlacierBlock = 0.toBlockNumber
petersburgBlock, istanbulBlock, muirGlacierBlock, berlinBlock = 0.toBlockNumber
eip150Hash, mixHash : MDigest[256]
daoForkSupport = false
nonce = 66.toBlockNonce
@ -382,6 +390,7 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
checkForFork(forkDetails, petersburgBlock, constantinopleBlock)
checkForFork(forkDetails, istanbulBlock, petersburgBlock)
checkForFork(forkDetails, muirGlacierBlock, istanbulBlock)
checkForFork(forkDetails, istanbulBlock, berlinBlock)
else:
error "No chain configuration found."
quit(1)
@ -409,6 +418,7 @@ proc processCustomGenesisConfig(customGenesis: JsonNode): ConfigStatus =
petersburgBlock: petersburgBlock,
istanbulBlock: istanbulBlock,
muirGlacierBlock: muirGlacierBlock,
berlinBlock: berlinBlock,
nonce: nonce,
extraData: extraData,
gasLimit: gasLimit,

View File

@ -18,7 +18,8 @@ type
Constantinople,
Petersburg,
Istanbul,
MuirGlacier
MuirGlacier,
Berlin
Chain* = ref object of AbstractChainDB
db: BaseChainDB
@ -26,7 +27,8 @@ type
blockZeroHash: KeccakHash
func toChainFork(c: ChainConfig, number: BlockNumber): ChainFork =
if number >= c.muirGlacierBlock: MuirGlacier
if number >= c.berlinBlock: Berlin
elif number >= c.muirGlacierBlock: MuirGlacier
elif number >= c.istanbulBlock: Istanbul
elif number >= c.petersburgBlock: Petersburg
elif number >= c.constantinopleBlock: Constantinople
@ -55,6 +57,7 @@ func getNextFork(c: ChainConfig, fork: ChainFork): uint64 =
toNextFork(c.petersburgBlock),
toNextFork(c.istanbulBlock),
toNextFork(c.muirGlacierBlock),
toNextFork(c.berlinBlock),
]
if fork == high(ChainFork):

View File

@ -92,7 +92,8 @@ const
eth3, # FkByzantium
eth2, # FkConstantinople
eth2, # FkPetersburg
eth2 # FkIstanbul
eth2, # FkIstanbul
eth2 # FkBerlin
]
proc calculateReward(fork: Fork, header: BlockHeader, body: BlockBody, vmState: BaseVMState) =

View File

@ -710,7 +710,8 @@ const
FkByzantium: SpuriousGasFees,
FkConstantinople: SpuriousGasFees,
FkPetersburg: SpuriousGasFees,
FkIstanbul: IstanbulGasFees
FkIstanbul: IstanbulGasFees,
FkBerlin: IstanbulGasFees
]

View File

@ -17,3 +17,4 @@ type
FkConstantinople = "constantinople"
FkPetersburg = "petersburg"
FkIstanbul = "istanbul"
FkBerlin = "berlin"

1
vendor/nim-blscurve vendored Submodule

@ -0,0 +1 @@
Subproject commit 3878b9bf324fd895f07f2c3a07622fac7c939e21