diff --git a/CHANGELOG.md b/CHANGELOG.md index fa99e9abd5a..7a125cb2501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Introduce a cap to reputation score increase [#4230](https://github.com/hyperledger/besu/pull/4230) - Add experimental CLI option for `--Xp2p-peer-lower-bound` [#4200](https://github.com/hyperledger/besu/pull/4200) - Improve pending blocks retrieval mechanism [#4227](https://github.com/hyperledger/besu/pull/4227) +- set mainnet terminal total difficulty [#4260](https://github.com/hyperledger/besu/pull/4260) ### Bug Fixes - Fixes off-by-one error for mainnet TTD fallback [#4223](https://github.com/hyperledger/besu/pull/4223) diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java index d9221d0f472..5510419614f 100644 --- a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java +++ b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java @@ -403,6 +403,8 @@ private GenesisConfigFile getFastSyncGenesis() { (node) -> { // Clear DAO block so that inability to validate DAO block won't interfere with fast sync node.remove("daoForkBlock"); + // remove merge terminal difficulty for fast sync in the absence of a CL mock + node.remove("terminalTotalDifficulty"); }); return GenesisConfigFile.fromConfig(jsonNode); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 984b412354e..1b64a1cdb65 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -3670,6 +3670,8 @@ public void blockProducingOptionsWarnsMinerShouldBeEnabled() { final Address requestedCoinbase = Address.fromHexString("0000011111222223333344444"); parseCommand( + "--network", + "dev", "--miner-coinbase", requestedCoinbase.toString(), "--min-gas-price", @@ -3692,7 +3694,8 @@ public void blockProducingOptionsWarnsMinerShouldBeEnabledToml() throws IOExcept final Path toml = createTempFile( "toml", - "miner-coinbase=\"" + "network=\"dev\"\n" + + "miner-coinbase=\"" + requestedCoinbase + "\"\n" + "min-gas-price=42\n" @@ -3735,7 +3738,7 @@ public void blockProducingOptionsDoNotWarnWhenMergeEnabled() { @Test public void minGasPriceRequiresMainOption() { - parseCommand("--min-gas-price", "0"); + parseCommand("--min-gas-price", "0", "--network", "dev"); verifyOptionsConstraintLoggerCall("--miner-enabled", "--min-gas-price"); @@ -3745,7 +3748,7 @@ public void minGasPriceRequiresMainOption() { @Test public void minGasPriceRequiresMainOptionToml() throws IOException { - final Path toml = createTempFile("toml", "min-gas-price=0\n"); + final Path toml = createTempFile("toml", "min-gas-price=0\nnetwork=\"dev\"\n"); parseCommand("--config-file", toml.toString()); diff --git a/config/src/main/resources/mainnet.json b/config/src/main/resources/mainnet.json index 805a668c762..57273c6436f 100644 --- a/config/src/main/resources/mainnet.json +++ b/config/src/main/resources/mainnet.json @@ -13,6 +13,7 @@ "londonBlock": 12965000, "arrowGlacierBlock": 13773000, "grayGlacierBlock": 15050000, + "terminalTotalDifficulty": 58750000000000000000000, "ethash": { }, "discovery": { diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java index 3112f908377..55efdcb1635 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java @@ -228,6 +228,17 @@ public void assertGoerliTerminalTotalDifficulty() { .isEqualTo(UInt256.valueOf(new BigInteger("10790000"))); } + @Test + public void assertMainnetTerminalTotalDifficulty() { + GenesisConfigOptions mainnetOptions = + GenesisConfigFile.genesisFileFromResources("/mainnet.json").getConfigOptions(); + + assertThat(mainnetOptions.getTerminalTotalDifficulty()).isPresent(); + // tentative as of 2022-08-11: + assertThat(mainnetOptions.getTerminalTotalDifficulty().get()) + .isEqualTo(UInt256.valueOf(new BigInteger("58750000000000000000000"))); + } + @Test public void assertTerminalTotalDifficultyOverride() { GenesisConfigOptions ropstenOverrideOptions =