From 60b12bdc62179d1cfcd806340b45ca03617958c7 Mon Sep 17 00:00:00 2001 From: garyschulte Date: Thu, 19 May 2022 13:45:31 -0700 Subject: [PATCH] ropsten TTD config (#3871) * ropsten TTD config Signed-off-by: garyschulte --- CHANGELOG.md | 1 + .../besu/config/GenesisConfigFile.java | 20 +++++++----------- config/src/main/resources/ropsten.json | 1 + .../besu/config/GenesisConfigFileTest.java | 21 +++++++++++++++++++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c866caeeb80..c2e3a2c6756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - GraphQL - allow null log topics in queries which match any topic [#3662](https://github.com/hyperledger/besu/pull/3662) - multi-arch docker builds for amd64 and arm64 [#2954](https://github.com/hyperledger/besu/pull/2954) - Filter Netty native lib errors likewise the pure Java implementation [#3807](https://github.com/hyperledger/besu/pull/3807) +- Add ropsten terminal total difficulty config [#3871](https://github.com/hyperledger/besu/pull/3871) ### Bug Fixes - Stop the BlockPropagationManager when it receives the TTD reached event [#3809](https://github.com/hyperledger/besu/pull/3809) diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java index fa7fb0ab3e9..4c0b63391e3 100644 --- a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java +++ b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java @@ -45,12 +45,7 @@ private GenesisConfigFile(final ObjectNode config) { } public static GenesisConfigFile mainnet() { - try { - return fromConfig( - Resources.toString(GenesisConfigFile.class.getResource("/mainnet.json"), UTF_8)); - } catch (final IOException e) { - throw new IllegalStateException(e); - } + return genesisFileFromResources("/mainnet.json"); } public static ObjectNode mainnetJsonNode() { @@ -64,18 +59,17 @@ public static ObjectNode mainnetJsonNode() { } public static GenesisConfigFile development() { - try { - return fromConfig( - Resources.toString(GenesisConfigFile.class.getResource("/dev.json"), UTF_8)); - } catch (final IOException e) { - throw new IllegalStateException(e); - } + return genesisFileFromResources("/dev.json"); } public static GenesisConfigFile ecip1049dev() { + return genesisFileFromResources("/ecip1049_dev.json"); + } + + public static GenesisConfigFile genesisFileFromResources(final String resourceName) { try { return fromConfig( - Resources.toString(GenesisConfigFile.class.getResource("/ecip1049_dev.json"), UTF_8)); + Resources.toString(GenesisConfigFile.class.getResource(resourceName), UTF_8)); } catch (final IOException e) { throw new IllegalStateException(e); } diff --git a/config/src/main/resources/ropsten.json b/config/src/main/resources/ropsten.json index 939e0a3b0e1..6c1a369bb46 100644 --- a/config/src/main/resources/ropsten.json +++ b/config/src/main/resources/ropsten.json @@ -10,6 +10,7 @@ "muirGlacierBlock": 7117117, "berlinBlock": 9812189, "londonBlock": 10499401, + "terminalTotalDifficulty": 43531756765713534, "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 30e6beb4216..47d29dc3866 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java @@ -198,6 +198,27 @@ public void shouldGetEmptyTerminalTotalDifficultyAtGenesis() { assertThat(EMPTY_CONFIG.getConfigOptions().getTerminalTotalDifficulty()).isNotPresent(); } + @Test + public void assertRopstenTerminalTotalDifficulty() { + GenesisConfigOptions ropstenOptions = + GenesisConfigFile.genesisFileFromResources("/ropsten.json").getConfigOptions(); + + assertThat(ropstenOptions.getTerminalTotalDifficulty()).isPresent(); + assertThat(ropstenOptions.getTerminalTotalDifficulty().get()) + .isEqualTo(UInt256.valueOf(43531756765713534L)); + } + + @Test + public void assertTerminalTotalDifficultyOverride() { + GenesisConfigOptions ropstenOverrideOptions = + GenesisConfigFile.genesisFileFromResources("/ropsten.json") + .getConfigOptions(Map.of("terminalTotalDifficulty", String.valueOf(Long.MAX_VALUE))); + + assertThat(ropstenOverrideOptions.getTerminalTotalDifficulty()).isPresent(); + assertThat(ropstenOverrideOptions.getTerminalTotalDifficulty().get()) + .isEqualTo(UInt256.valueOf(Long.MAX_VALUE)); + } + @Test public void shouldFindParisForkAndAlias() { GenesisConfigFile parisGenesis =