Skip to content

Commit

Permalink
implement tentative mainnet TTD (hyperledger#4260)
Browse files Browse the repository at this point in the history
* implement tentative mainnet TTD
* fix unit test breakage
* add to change log

Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte authored and jflo committed Aug 18, 2022
1 parent df3d9fd commit e2c0168
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions besu/src/test/java/org/hyperledger/besu/RunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3670,6 +3670,8 @@ public void blockProducingOptionsWarnsMinerShouldBeEnabled() {

final Address requestedCoinbase = Address.fromHexString("0000011111222223333344444");
parseCommand(
"--network",
"dev",
"--miner-coinbase",
requestedCoinbase.toString(),
"--min-gas-price",
Expand All @@ -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"
Expand Down Expand Up @@ -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");

Expand All @@ -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());

Expand Down
1 change: 1 addition & 0 deletions config/src/main/resources/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"londonBlock": 12965000,
"arrowGlacierBlock": 13773000,
"grayGlacierBlock": 15050000,
"terminalTotalDifficulty": 58750000000000000000000,
"ethash": {
},
"discovery": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit e2c0168

Please sign in to comment.