Skip to content

Commit

Permalink
Add terminal block hash and number to Ropsten genesis file (#4026)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* If terminal block is present in the genesis, then peers must have it

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update unit test

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* address review comments

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 authored Jul 5, 2022
1 parent 3dce6a9 commit 27fc468
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,19 @@ protected List<PeerValidator> createPeerValidators(final ProtocolSchedule protoc
protocolSchedule, metricsSystem, requiredBlock.getKey(), requiredBlock.getValue()));
}

final Optional<Hash> 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())
Expand Down
4 changes: 2 additions & 2 deletions besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static Collection<Object[]> parameters() {
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,
Expand Down
2 changes: 2 additions & 0 deletions config/src/main/resources/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"berlinBlock": 9812189,
"londonBlock": 10499401,
"terminalTotalDifficulty": 50000000000000000,
"terminalBlockHash": "0x5010949c3acdf1d076c9e4ee8aedbb539aca48ebe19638330bc02c5b1bfb953d",
"terminalBlockNumber": 12350712,
"ethash": {
},
"discovery": {
Expand Down

0 comments on commit 27fc468

Please sign in to comment.