Skip to content

Commit

Permalink
simulators/ethereum/engine: Remove PoW config from withdrawals (ether…
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz authored and Rjected committed Feb 7, 2023
1 parent fcc1572 commit 2e6cc03
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
24 changes: 16 additions & 8 deletions simulators/ethereum/engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,24 @@ func addTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests []test
}

testFiles := hivesim.Params{}
if currentTest.GetChainFile() != "" {
// We are using a Proof of Work chain file, remove all clique-related settings
// TODO: Nethermind still requires HIVE_MINER for the Engine API
// delete(newParams, "HIVE_MINER")
if genesis.Difficulty.Cmp(big.NewInt(ttd)) < 0 {

if currentTest.GetChainFile() != "" {
// We are using a Proof of Work chain file, remove all clique-related settings
// TODO: Nethermind still requires HIVE_MINER for the Engine API
// delete(newParams, "HIVE_MINER")
delete(newParams, "HIVE_CLIQUE_PRIVATEKEY")
delete(newParams, "HIVE_CLIQUE_PERIOD")
// Add the new file to be loaded as chain.rlp
testFiles = testFiles.Set("/chain.rlp", "./chains/"+currentTest.GetChainFile())
}
if currentTest.IsMiningDisabled() {
delete(newParams, "HIVE_MINER")
}
} else {
// This is a post-merge test
delete(newParams, "HIVE_CLIQUE_PRIVATEKEY")
delete(newParams, "HIVE_CLIQUE_PERIOD")
// Add the new file to be loaded as chain.rlp
testFiles = testFiles.Set("/chain.rlp", "./chains/"+currentTest.GetChainFile())
}
if currentTest.IsMiningDisabled() {
delete(newParams, "HIVE_MINER")
}

Expand Down
7 changes: 7 additions & 0 deletions simulators/ethereum/engine/suites/withdrawals/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,13 @@ func AddUnconditionalBytecode(g *core.Genesis, start *big.Int, end *big.Int) {
// bytecode for testing purposes.
func (ws *WithdrawalsBaseSpec) GetGenesis() *core.Genesis {
genesis := ws.Spec.GetGenesis()

// Remove PoW altogether
genesis.Difficulty = common.Big0
genesis.Config.TerminalTotalDifficulty = common.Big0
genesis.Config.Clique = nil
genesis.ExtraData = []byte{}

startAccount := big.NewInt(0x1000)
endAccount := big.NewInt(0x1000 + int64(ws.GetWithdrawableAccountCount()) - 1)
AddUnconditionalBytecode(genesis, startAccount, endAccount)
Expand Down

0 comments on commit 2e6cc03

Please sign in to comment.