Skip to content

Commit

Permalink
clients: add 'glacier' forks in mapper (#941)
Browse files Browse the repository at this point in the history
* clients/go-ethereum: remove 'yolo' fork blocks

* clients/ethereumjs: remove 'yolo' forks in mapper

* clients: add missing 'glacier' forks in mapper

* cmd/hivechain: put back difficulty-only forks

This reverts commit f01b2d3.

* simulators/smoke: add 'glacier' forks

* cmd/hivechain: improve uncle generation
  • Loading branch information
fjl authored Nov 8, 2023
1 parent 431557d commit e4d92c4
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 15 deletions.
2 changes: 2 additions & 0 deletions clients/besu/mapper.jq
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def to_int:
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int,
"londonBlock": env.HIVE_FORK_LONDON|to_int,
"arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int,
"grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int,
"parisBlock": env.HIVE_MERGE_BLOCK_ID|to_int,
"terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int,
"shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int,
Expand Down
2 changes: 2 additions & 0 deletions clients/erigon/mapper.jq
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def to_bool:
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int,
"londonBlock": env.HIVE_FORK_LONDON|to_int,
"arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int,
"grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int,
"mergeNetsplitBlock": env.HIVE_MERGE_BLOCK_ID|to_int,
"terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int,
"terminalTotalDifficultyPassed": true,
Expand Down
4 changes: 2 additions & 2 deletions clients/ethereumjs/mapper.jq
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def to_bool:
"istanbulBlock": env.HIVE_FORK_ISTANBUL|to_int,
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int,
"yolov2Block": env.HIVE_FORK_BERLIN|to_int,
"yolov3Block": env.HIVE_FORK_BERLIN|to_int,
"londonBlock": env.HIVE_FORK_LONDON|to_int,
"arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int,
"grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int,
"mergeForkBlock": env.HIVE_MERGE_BLOCK_ID|to_int,
"terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int,
"shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int,
Expand Down
4 changes: 2 additions & 2 deletions clients/go-ethereum/mapper.jq
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def to_bool:
"istanbulBlock": env.HIVE_FORK_ISTANBUL|to_int,
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int,
"yolov2Block": env.HIVE_FORK_BERLIN|to_int,
"yolov3Block": env.HIVE_FORK_BERLIN|to_int,
"londonBlock": env.HIVE_FORK_LONDON|to_int,
"arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int,
"grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int,
"mergeNetsplitBlock": env.HIVE_MERGE_BLOCK_ID|to_int,
"terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int,
"shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int,
Expand Down
2 changes: 2 additions & 0 deletions clients/nethermind/mapper.jq
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def ethash_engine:
(env.HIVE_FORK_CONSTANTINOPLE|to_hex//""): 2000000,
(env.HIVE_FORK_MUIR_GLACIER|to_hex//""): 4000000,
(env.HIVE_FORK_LONDON|to_hex//""): 700000,
(env.HIVE_FORK_ARROW_GLACIER|to_hex//""): 1000000,
(env.HIVE_FORK_GRAY_GLACIER|to_hex//""): 700000,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions clients/nimbus-el/mapper.jq
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def to_bool:
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int,
"londonBlock": env.HIVE_FORK_LONDON|to_int,
"arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int,
"grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int,
"mergeForkBlock": env.HIVE_MERGE_BLOCK_ID|to_int,
"terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int,
"shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int,
Expand Down
8 changes: 6 additions & 2 deletions cmd/hivechain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ var (
"muirglacier",
"berlin",
"london",
// "arrowglacier", "grayglacier" forks were difficulty bomb changes. They are not
// available here because hive doesn't support configuring them on clients.
"arrowglacier",
"grayglacier",
"merge",
}

Expand Down Expand Up @@ -98,6 +98,10 @@ func (cfg *generatorConfig) createChainConfig() *params.ChainConfig {
chaincfg.BerlinBlock = new(big.Int).SetUint64(b)
case "london":
chaincfg.LondonBlock = new(big.Int).SetUint64(b)
case "arrowglacier":
chaincfg.ArrowGlacierBlock = new(big.Int).SetUint64(b)
case "grayglacier":
chaincfg.GrayGlacierBlock = new(big.Int).SetUint64(b)
case "merge":
chaincfg.MergeNetsplitBlock = new(big.Int).SetUint64(b)
chaincfg.TerminalTotalDifficultyPassed = true
Expand Down
18 changes: 12 additions & 6 deletions cmd/hivechain/mod_uncles.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,33 @@ type unclesInfo struct {
}

func (m *modUncles) apply(ctx *genBlockContext) bool {
merge := ctx.ChainConfig().MergeNetsplitBlock
if merge != nil && merge.Cmp(ctx.Number()) <= 0 {
return false // no uncles after merge
}
if ctx.NumberU64() < 3 {
cfg := ctx.ChainConfig()
merged := cfg.MergeNetsplitBlock != nil && cfg.MergeNetsplitBlock.Cmp(ctx.Number()) <= 0
if merged || cfg.Ethash == nil || ctx.NumberU64() < 3 {
return false
}

info := m.info[ctx.NumberU64()]
if len(info.Hashes) >= 2 {
return false
return false // block has enough uncles already
}

parent := ctx.ParentBlock()
time := parent.Time() + 1
uncle := &types.Header{
Number: parent.Number(),
ParentHash: parent.ParentHash(),
Time: time,
Extra: []byte(fmt.Sprintf("hivechain uncle %d", m.counter)),
}
// Initialize the remaining remaining header fields by converting to a full block.
ub := types.NewBlock(uncle, nil, nil, nil, trie.NewStackTrie(nil))
uncle = ub.Header()

// Add the uncle to the generated block.
// Note that AddUncle computes the difficulty and gas limit for us.
ctx.block.AddUncle(uncle)

info.Hashes = append(info.Hashes, uncle.Hash())
m.info[ctx.NumberU64()] = info
m.counter++
Expand Down
2 changes: 2 additions & 0 deletions cmd/hivechain/output_forkenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func (g *generator) writeForkEnv() error {
setNum("HIVE_FORK_PETERSBURG", cfg.PetersburgBlock)
setNum("HIVE_FORK_ISTANBUL", cfg.IstanbulBlock)
setNum("HIVE_FORK_MUIR_GLACIER", cfg.MuirGlacierBlock)
setNum("HIVE_FORK_ARROW_GLACIER", cfg.ArrowGlacierBlock)
setNum("HIVE_FORK_GRAY_GLACIER", cfg.GrayGlacierBlock)
setNum("HIVE_FORK_BERLIN", cfg.BerlinBlock)
setNum("HIVE_FORK_LONDON", cfg.LondonBlock)
setNum("HIVE_MERGE_BLOCK_ID", cfg.MergeNetsplitBlock)
Expand Down
8 changes: 5 additions & 3 deletions simulators/smoke/genesis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ func main() {
"HIVE_FORK_MUIR_GLACIER": "19",
"HIVE_FORK_BERLIN": "20",
"HIVE_FORK_LONDON": "21",
"HIVE_TERMINAL_TOTAL_DIFFICULTY": "22",
"HIVE_SHANGHAI_TIMESTAMP": "23",
"HIVE_CANCUN_TIMESTAMP": "24",
"HIVE_FORK_ARROW_GLACIER": "22",
"HIVE_FORK_GRAY_GLACIER": "23",
"HIVE_TERMINAL_TOTAL_DIFFICULTY": "24",
"HIVE_SHANGHAI_TIMESTAMP": "25",
"HIVE_CANCUN_TIMESTAMP": "26",
},
Run: genesisTest{"0x433d0b859a77a29753d2a6df477c971dcc6300af33f9d64d821a1d490b4148b1"}.test,
})
Expand Down

0 comments on commit e4d92c4

Please sign in to comment.