From 27fc468624d4a19067b076567ea9e1578217d34e Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Tue, 5 Jul 2022 17:32:07 +0200 Subject: [PATCH] Add terminal block hash and number to Ropsten genesis file (#4026) Signed-off-by: Fabio Di Fabio * If terminal block is present in the genesis, then peers must have it Signed-off-by: Fabio Di Fabio * Update unit test Signed-off-by: Fabio Di Fabio * address review comments Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + .../besu/controller/BesuControllerBuilder.java | 13 +++++++++++++ .../test/java/org/hyperledger/besu/ForkIdsTest.java | 4 ++-- config/src/main/resources/ropsten.json | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ee805a7bc..6abe1cd342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - When on PoS the head can be only be updated by ForkchoiceUpdate [#3994](https://github.com/hyperledger/besu/pull/3994) - Version information available in metrics [#3997](https://github.com/hyperledger/besu/pull/3997) - Add TTD and DNS to Sepolia config [#4024](https://github.com/hyperledger/besu/pull/4024) +- Add terminal block hash and number to Ropsten genesis file [#4026](https://github.com/hyperledger/besu/pull/4026) - Return `type` with value `0x0` when serializing legacy transactions [#4027](https://github.com/hyperledger/besu/pull/4027) ### Bug Fixes diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index 496f0f2abf..2ba399ed82 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -630,6 +630,19 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides protocolSchedule, metricsSystem, requiredBlock.getKey(), requiredBlock.getValue())); } + final Optional terminalBlockHash = configOptionsSupplier.get().getTerminalBlockHash(); + if (terminalBlockHash.isPresent() && !terminalBlockHash.get().equals(Hash.ZERO)) { + final OptionalLong terminalBlockNumber = configOptionsSupplier.get().getTerminalBlockNumber(); + if (terminalBlockNumber.isPresent()) { + validators.add( + new RequiredBlocksPeerValidator( + protocolSchedule, + metricsSystem, + terminalBlockNumber.getAsLong(), + terminalBlockHash.get())); + } + } + final CheckpointConfigOptions checkpointConfigOptions = genesisConfig.getConfigOptions(genesisConfigOverrides).getCheckpointOptions(); if (SyncMode.X_CHECKPOINT.equals(syncConfig.getSyncMode()) diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java index 98940b4981..cef9a121a7 100644 --- a/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java @@ -67,8 +67,8 @@ public class ForkIdsTest { new ForkId(Bytes.ofUnsignedInt(0x4bc66396L), 7117117L), new ForkId(Bytes.ofUnsignedInt(0x6727ef90L), 9812189L), new ForkId(Bytes.ofUnsignedInt(0xa157d377L), 10499401L), - new ForkId(Bytes.ofUnsignedInt(0x7119b6b3L), 0L), - new ForkId(Bytes.ofUnsignedInt(0x7119b6b3L), 0L)) + new ForkId(Bytes.ofUnsignedInt(0x7119b6b3L), 12350712L), + new ForkId(Bytes.ofUnsignedInt(0xaae42f33L), 0L)) }, new Object[] { NetworkName.RINKEBY, diff --git a/config/src/main/resources/ropsten.json b/config/src/main/resources/ropsten.json index 3912705c18..3e67901012 100644 --- a/config/src/main/resources/ropsten.json +++ b/config/src/main/resources/ropsten.json @@ -11,6 +11,8 @@ "berlinBlock": 9812189, "londonBlock": 10499401, "terminalTotalDifficulty": 50000000000000000, + "terminalBlockHash": "0x5010949c3acdf1d076c9e4ee8aedbb539aca48ebe19638330bc02c5b1bfb953d", + "terminalBlockNumber": 12350712, "ethash": { }, "discovery": {