Dont sign when advancing blockchain - #646
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
63bc088 to
e9ae098
Compare
757e8d9 to
20e0c7d
Compare
d150f84 to
d4f5b1e
Compare
8a6b781 to
d6ffdc2
Compare
d6ffdc2 to
ff76700
Compare
ff76700 to
0120e3e
Compare
| logger.error(message, e); | ||
| } catch (HSMClientException | SignerMessageBuilderException | ReleaseRequirementsEnforcerException e) { | ||
| } catch (ReleaseRequirementsEnforcerException e) { | ||
| logger.info("[signRelease] {}", e.getMessage()); |
There was a problem hiding this comment.
differentiating RRE from log level (info instead of error)
1526687 to
a76b4fb
Compare
a76b4fb to
73aa655
Compare
There was a problem hiding this comment.
Pull request overview
This PR tightens PowHSM release-signing behavior by enforcing “ancestor in position” requirements directly in ReleaseRequirementsEnforcer, and preventing signing when the HSM is busy updating its blockchain bookkeeping state (advance/update in progress). It also simplifies the requirements enforcement flow by removing the separate AncestorBlockUpdater component and renaming the HSM bookkeeping state getter for clarity.
Changes:
- Refactor release requirements enforcement to use
BlockStore+HSMBookkeepingClientdirectly, including explicit validation for “HSM in progress” and “target block not yet informed”. - Update BTC release signing to resolve and cache signer/HSM version during
setup(), and to skip signing when requirements enforcement indicates the HSM is busy. - Rename
HSMBookkeepingClient.getHSMPointer()togetPowHSMState()and update call sites and tests; removeAncestorBlockUpdaterand its tests, replacing coverage with expandedReleaseRequirementsEnforcerTest.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/co/rsk/federate/signing/hsm/requirements/ReleaseRequirementsEnforcer.java | Moves ancestor-update logic and validations into the enforcer; now interacts with BlockStore + HSMBookkeepingClient directly. |
| src/main/java/co/rsk/federate/signing/hsm/requirements/AncestorBlockUpdater.java | Deleted; functionality absorbed into ReleaseRequirementsEnforcer. |
| src/main/java/co/rsk/federate/signing/hsm/client/HSMBookkeepingClient.java | Renames bookkeeping state getter to getPowHSMState(). |
| src/main/java/co/rsk/federate/signing/hsm/advanceblockchain/HsmBookkeepingClientImpl.java | Implements getPowHSMState() and updates internal validation to use it. |
| src/main/java/co/rsk/federate/signing/hsm/advanceblockchain/HSMBookkeepingService.java | Switches bookkeeping state reads to getPowHSMState(). |
| src/main/java/co/rsk/federate/signing/hsm/HSMClientException.java | Narrows constructor visibility to protected for controlled subclassing. |
| src/main/java/co/rsk/federate/FedNodeRunner.java | Updates wiring to construct ReleaseRequirementsEnforcer without AncestorBlockUpdater. |
| src/main/java/co/rsk/federate/btcreleaseclient/BtcReleaseClient.java | Caches signer version during setup; skips signing when enforcer blocks due to HSM state; renames pegout readiness helper for inverted logic. |
| src/test/java/co/rsk/federate/signing/hsm/requirements/ReleaseRequirementsEnforcerTest.java | Adds comprehensive tests for multiple PowHSM enforcement scenarios and ancestor update payload behavior. |
| src/test/java/co/rsk/federate/signing/hsm/requirements/AncestorBlockUpdaterTest.java | Deleted along with AncestorBlockUpdater. |
| src/test/java/co/rsk/federate/signing/hsm/advanceblockchain/HSMBookkeepingServiceTest.java | Updates tests to use getPowHSMState(). |
| src/test/java/co/rsk/federate/signing/hsm/advanceblockchain/HsmBookkeepingClientImplTest.java | Updates tests to use getPowHSMState(). |
| src/test/java/co/rsk/federate/btcreleaseclient/BtcReleaseClientTest.java | Adjusts setup stubbing to account for version resolution during BtcReleaseClient.setup(). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
73aa655 to
b648847
Compare
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/main/java/co/rsk/federate/signing/hsm/requirements/ReleaseRequirementsEnforcer.java:130
getHeadersToUpdateAncestortreats “starting point is current best block” asstartingBlockNumber == targetBlockNumber, but that ignores forks at the same height. If the HSM best block is on a different branch with the same height, this will incorrectly send only the target header instead of failing fast (or building a verifiable path), potentially resulting in a bad update attempt and misleading logs.
Consider also requiring startingPoint.getHash().equals(targetBlock.getHash()) for this fast path; otherwise throw an HSMBlockchainBookkeepingRelatedException (chain mismatch) before calling updateAncestorBlock.
if (startingBlockNumber == targetBlockNumber) {
logger.trace(
"[getHeadersToUpdateAncestor] Target block is current best block. " +
"Will update ancestor with target block header only"
);



No description provided.