Back merge 9.0.4.0 changes into master - #676
Conversation
…ight Consider work instead of height when informing BTC headers to the Bridge
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
🟡 Changes recommended
Bridge-chain traversal is unbounded, and the equal-work boundary lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Back-merges 9.0.4 Bitcoin header synchronization changes into master.
Changes:
- Compares cumulative Bitcoin chain work instead of height.
- Adds Bridge header retrieval APIs and tests.
- Updates naming, mocks, logging, and dependency verification.
File summaries
| File | Description |
|---|---|
gradle/verification-metadata.xml |
Updates RSKj 9.0.4 checksums. |
src/main/java/co/rsk/federate/BtcToRskClient.java |
Implements work-based chain selection. |
src/main/java/co/rsk/federate/FederatorSupport.java |
Adds Bridge header queries. |
src/main/java/co/rsk/federate/log/FederateLogger.java |
Uses renamed height API. |
src/test/java/co/rsk/federate/BtcToRskClientTest.java |
Tests work-based synchronization. |
src/test/java/co/rsk/federate/FederatorSupportTest.java |
Tests header query methods. |
src/test/java/co/rsk/federate/log/FederateLoggerTest.java |
Updates renamed API usage. |
src/test/java/co/rsk/federate/mock/SimpleFederatorSupport.java |
Simplifies the test support implementation. |
Review details
Suppressed comments (1)
src/main/java/co/rsk/federate/BtcToRskClient.java:431
- This branch also runs when cumulative work is equal, so the warning incorrectly reports that the Bridge has more work. Describe it as having “at least as much work” to keep diagnostics accurate for tie cases.
logger.warn("[updateBridgeBtcBlockchain] Bridge has more work than Federator, so we won't update it.");
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| BigInteger bridgeBitcoinChainWork = calculateBridgeBitcoinChainWork(commonAncestor); | ||
| BigInteger bitcoinBestChainWork = bitcoinChainHead.getChainWork(); | ||
| // Compare total cumulative work | ||
| boolean shouldUpdateBridge = bitcoinBestChainWork.compareTo(bridgeBitcoinChainWork) > 0; |
| while (!currentHeader.getHash().equals(ancestorHash)) { | ||
| BigInteger currentBlockWork = currentHeader.getWork(); | ||
| cumulativeWorkAboveAncestor = cumulativeWorkAboveAncestor.add(currentBlockWork); | ||
|
|
||
| byte[] parentPayloadBytes = federatorSupport.getBridgeBtcBlockchainParentBlockHeaderByHash(currentHeader.getHash()); | ||
| currentHeader = new Block(params, parentPayloadBytes); |
There was a problem hiding this comment.
🟡 Changes recommended
The unbounded per-block Bridge traversal and equal-work boundary coverage remain unresolved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Balanced
|



Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: