Headers informing logic integration - #651
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR updates the PowPeg node’s BTC-header synchronization logic so the federator informs the Bridge only about BTC block headers that the Bridge does not already have, and refactors/extends the test suite to validate the new behavior (including fork/deep-fork cases and updateBridge flow behavior).
Changes:
- Update
BtcToRskClient.updateBridgeBtcBlockchain()to skip already-known headers by querying the Bridge (isBlockHashInformedToBridge) and sending only the remaining unknown suffix (with a binary search helper). - Add mock support for
isBlockHashInformedToBridgeinSimpleFederatorSupportto model “known to Bridge” headers across both the Bridge-registered chain and previouslysendReceiveHeaders-informed headers. - Restructure and expand
BtcToRskClientTestto reflect the new header-informing behavior and to better isolate updateBridge sub-behaviors (blockchain/coinbase/txs/collections).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/co/rsk/federate/BtcToRskClient.java | Changes header sync to send only headers not already known by the Bridge; adds binary-search helper; removes duplicate config assignment and unused import. |
| src/test/java/co/rsk/federate/mock/SimpleFederatorSupport.java | Implements isBlockHashInformedToBridge for test scenarios by checking Bridge chain hashes and previously informed headers. |
| src/test/java/co/rsk/federate/BtcToRskClientTest.java | Updates expectations for deep-fork header informing, refactors nested tests, and adds/adjusts coverage for updateBridge control-flow and storage failure behavior. |
d150f84 to
d4f5b1e
Compare
d4f5b1e to
94e53c5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/test/java/co/rsk/federate/BtcToRskClientTest.java:4055
- This helper also uses height/array indexes (
blocks[depth]) rather than blockchain depth. Renaming parameters/locals tofromHeight/toHeightandheightimproves readability and prevents mixing up "height" vs "depth" in later test edits.
private void markHeadersAsInformed(int fromDepth, int toDepth) {
for (int depth = fromDepth; depth <= toDepth; depth++) {
Sha256Hash blockHash = blocks[depth].getHeader().getHash();
when(federatorSupport.isBlockHashInformedToBridge(blockHash)).thenReturn(true);
}
052106e to
36be0fe
Compare
36be0fe to
9ab366b
Compare
|



Federators inform the RSK Bridge of new BTC block headers via
updateBridgeBtcBlockchain(). The old logic always started from the common ancestor and re-sent the firstNheaders, so it could keep re-submitting headers the Bridge already had and never advance.Changes:
findFirstUnknownHeader()— binary search overisBlockHashInformedToBridge— and inform only headers from that index onward.isUpdateBridgeTimerEnabledassignment, drop unusedIOExceptionfrom the signature, logging tweaks.Testing:
BtcToRskClientTest(nestedUpdateBridgeclasses), including successive-informing and fork scenarios.