Skip to content

Commit

Permalink
Update checkpoint sync for merge (hyperledger#4085)
Browse files Browse the repository at this point in the history
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
  • Loading branch information
matkt authored Jul 15, 2022
1 parent 45ce87e commit f885c46
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions config/src/main/resources/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
]
},
"checkpoint": {
"hash": "0x2ae30061bdfc7f6dad5b07361dce436502eb0fde68645de12bae4929be619188",
"number": 6720000,
"totalDifficulty": "0x967F81",
"hash": "0x50e55c39a725f062af438c5332a5c5bec9a36d02c829ee6ac2cc27d1db719446",
"number": 4350000,
"totalDifficulty": "0x61DBBF",
"_comment": "must be the beginning of an epoch"
}
},
Expand Down
6 changes: 3 additions & 3 deletions config/src/main/resources/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
]
},
"checkpoint": {
"hash": "0x844d581cb00058d19f0584fb582fa2de208876ee56bbae27446a679baf4633f4",
"number": 14700000,
"totalDifficulty": "0xA2539264C62BF98CFC6"
"hash": "0x44bca881b07a6a09f83b130798072441705d9a665c5ac8bdf2f39a3cdf3bee29",
"number": 11052984,
"totalDifficulty": "0x3D103014E5C74E5E196"
}
},
"nonce": "0x42",
Expand Down
6 changes: 3 additions & 3 deletions config/src/main/resources/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
]
},
"checkpoint": {
"hash": "0x43de216f876d897e59b9757dd24186e5b53be28bc425ca6a966335b48daaa50c",
"number": 12200000,
"totalDifficulty": "0x928D05243C1CF4"
"hash": "0xeefb1f70bf7bed6394ed7d6f812f422aa37bf7680e1b75fa551d40e849f10a87",
"number": 12269949,
"totalDifficulty": "0x94730AAE0106DC"
}
},
"nonce": "0x0000000000000042",
Expand Down
5 changes: 5 additions & 0 deletions config/src/main/resources/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"enode://9246d00bc8fd1742e5ad2428b80fc4dc45d786283e05ef6edbd9002cbc335d40998444732fbe921cb88e1d2c73d1b1de53bae6a2237996e9bfe14f871baf7066@18.168.182.86:30303",
"enode://ec66ddcf1a974950bd4c782789a7e04f8aa7110a72569b6e65fcd51e937e74eed303b1ea734e4d19cfaec9fbff9b6ee65bf31dcb50ba79acce9dd63a6aca61c7@52.14.151.177:30303"
]
},
"checkpoint": {
"hash": "0x491ebac1b7f9c0eb426047a495dc577140cb3e09036cd3f7266eda86b635d9fa",
"number": 1273020,
"totalDifficulty": "0x13DE1653E7D280"
}
},
"alloc":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.BlockAddedEvent;
import org.hyperledger.besu.ethereum.chain.BlockAddedObserver;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeader;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -46,16 +46,16 @@ public NewBlockHeadersSubscriptionService(
@Override
public void onBlockAdded(final BlockAddedEvent event) {
if (event.isNewCanonicalHead()) {
final List<Block> blocks = new ArrayList<>();
Block blockPtr = event.getBlock();
final List<BlockHeader> blocks = new ArrayList<>();
BlockHeader blockPtr = event.getBlock().getHeader();

while (!blockPtr.getHash().equals(event.getCommonAncestorHash())) {
blocks.add(blockPtr);

blockPtr =
blockchainQueries
.getBlockchain()
.getBlockByHash(blockPtr.getHeader().getParentHash())
.getBlockHeader(blockPtr.getParentHash())
.orElseThrow(() -> new IllegalStateException("The block was on a orphaned chain."));
}

Expand Down

0 comments on commit f885c46

Please sign in to comment.