Skip to content

Commit

Permalink
handle 0x
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Feb 26, 2025
1 parent 031e85b commit b17f702
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions beacon_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,18 +918,20 @@ pub fn get_config<E: EthSpec>(
.map_err(|e| format!("Failed to read invalid-block-roots file {}", e))?;
let invalid_block_roots: HashSet<Hash256> = contents
.split(',')
.filter_map(|s| match Hash256::from_str(s.trim()) {
Ok(block_root) => Some(block_root),
Err(e) => {
warn!(
log,
"Unable to parse invalid block root";
"block_root" => s,
"error" => ?e,
);
None
}
})
.filter_map(
|s| match Hash256::from_str(s.strip_prefix("0x").unwrap_or(s).trim()) {
Ok(block_root) => Some(block_root),
Err(e) => {
warn!(
log,
"Unable to parse invalid block root";
"block_root" => s,
"error" => ?e,
);
None
}
},
)
.collect();
client_config.chain.invalid_block_roots = invalid_block_roots;
}
Expand Down
2 changes: 1 addition & 1 deletion lighthouse/tests/beacon_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ fn invalid_block_root_flag() {
let dir = TempDir::new().expect("Unable to create temporary directory");
let mut file =
File::create(dir.path().join("invalid-block-roots")).expect("Unable to create file");
file.write_all(b"2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f359, 2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f358")
file.write_all(b"2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f359, 2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f358, 0x2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f359")
.expect("Unable to write to file");
CommandLineTest::new()
.flag(
Expand Down

0 comments on commit b17f702

Please sign in to comment.