Skip to content

Commit 1670a45

Browse files
committed
fix: eliminate panic/unwrap crash risks in apos consensus engine
Replace 1 panic!() and 30+ unwrap() calls in apos.rs with proper Result error propagation and graceful error handling to prevent node crashes from lock poisoning, cache misses, or missing header fields. Also replace println!() with tracing::info!() in chainspec/spec.rs and remove unused imports in network-api/block.rs.
1 parent d8638e9 commit 1670a45

File tree

5 files changed

+168
-63
lines changed

5 files changed

+168
-63
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/chainspec/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ alloy-consensus.workspace = true
2929
auto_impl.workspace = true
3030
serde_json.workspace = true
3131
derive_more.workspace = true
32+
tracing.workspace = true
3233

3334
[dev-dependencies]
3435
# eth

crates/chainspec/src/spec.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ fn make_chain_spec(
164164
};
165165
spec.genesis.config.dao_fork_support = true;
166166
let state_root = state_root_ref_unhashed(&spec.genesis.alloc);
167-
println!(
168-
"Computed state_root from genesis alloc: state_root={}",
169-
state_root
170-
);
167+
tracing::info!(target: "chainspec", %state_root, "Computed state_root from genesis alloc");
171168
spec.into()
172169
}
173170

0 commit comments

Comments
 (0)