Conversation
…dir` Resolution Errors
### Description
This pull request resolves medium- and low-severity CLI panic vectors in `chain` identified during the Quantus workspace security audit (**FM-13, FM-14**).
Previously, invoking the `revert` subcommand triggered an `unimplemented!()` panic when executing consensus auxiliary data revert logic (leftover from Grandpa's removal)[cite: 49]. Additionally, resolving a relative path passed via `--node-key-file` relied on an unhandled `std::env::current_dir().unwrap()`, which panicked if the working directory was invalid or deleted[cite: 49].
### Key Changes & Remediations
#### 1. Safe No-Op Consensus Revert Hook (FM-13 - `node/src/command.rs`)
* **Eliminated `unimplemented!()` Panic:** Replaced the unimplemented Grandpa consensus revert closure with a deliberate no-op closure returning `Ok(())`:
```rust
let aux_revert = Box::new(
|_client, _, _blocks| -> Result<(), sc_cli::Error> { Ok(()) },
);
Upstream Type Alignment: Conforms strictly to upstream sc_cli::AuxRevertHandler (Box<dyn FnOnce(...) -> Result<(), sc_cli::Error>>), allowing chain reverts to complete cleanly without crashing the node process[cite: 49].2. Graceful Relative Node Key Resolution (FM-14 - node/src/command.rs)Eliminated current_dir().unwrap(): Replaced .unwrap() with explicit error mapping via .map_err(...). Descriptive Input Error: Maps working directory lookup failures to sc_cli::Error::Input with an informative error message instead of an unhandled panic[cite: 49, 61].How to ReviewInspect node/src/command.rs under Some(Subcommand::Revert(cmd)) to verify the no-op aux_revert closure. Inspect the relative path resolution branch for --node-key-file to verify the error mapping around std::env::current_dir().
n13
requested changes
Sep 19, 2026
n13
left a comment
Collaborator
There was a problem hiding this comment.
Question on the first item
Second item is good, and agree with that
| let aux_revert = Box::new(|_client, _, _blocks| { | ||
| unimplemented!("TODO - g*randpa was removed."); | ||
| }); | ||
| // Grandpa was removed from this chain, so there is no consensus |
Collaborator
There was a problem hiding this comment.
General policy is to fail early vs hide bugs
I think it's better to throw, which is why we're throwing.
Why did you make this change?
Collaborator
There was a problem hiding this comment.
If anything, a nice error message would be better, we don't want to ignore this
| } else { | ||
| // This is a valid assumption because the node is run from the shell | ||
| std::env::current_dir().unwrap().join(path) | ||
| // This is a valid assumption because the node is run from the shell; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request resolves medium- and low-severity CLI panic vectors in
chainidentified during the Quantus workspace security audit (FM-13, FM-14).Previously, invoking the
revertsubcommand triggered anunimplemented!()panic when executing consensus auxiliary data revert logic (leftover from Grandpa's removal)[cite: 49]. Additionally, resolving a relative path passed via--node-key-filerelied on an unhandledstd::env::current_dir().unwrap(), which panicked if the working directory was invalid or deleted[cite: 49].Key Changes & Remediations
1. Safe No-Op Consensus Revert Hook (FM-13 -
node/src/command.rs)unimplemented!()Panic: Replaced the unimplemented Grandpa consensus revert closure with a deliberate no-op closure returningOk(()): ```rust let aux_revert = Box::new( |_client, _, _blocks| -> Result<(), sc_cli::Error> { Ok(()) }, );Upstream Type Alignment: Conforms strictly to upstream sc_cli::AuxRevertHandler (Box<dyn FnOnce(...) -> Result<(), sc_cli::Error>>), allowing chain reverts to complete cleanly without crashing the node process[cite: 49].
2. Graceful Relative Node Key Resolution
(FM-14 - node/src/command.rs)Eliminated current_dir().unwrap(): Replaced .unwrap() with explicit error mapping via .map_err(...). Descriptive Input Error: Maps working directory lookup failures to sc_cli::Error::Input with an informative error message instead of an unhandled panic[cite: 49, 61].
How to Review
Inspect node/src/command.rs under Some(Subcommand::Revert(cmd)) to verify the no-op aux_revert closure. Inspect the relative path resolution branch for --node-key-file to verify the error mapping around std::env::current_dir().