Skip to content

Conversation

@nsannn
Copy link
Collaborator

@nsannn nsannn commented Jan 25, 2026

  • Removed duplicated code.
  • Removed not used devnet-2 feature flag.
  • Moved unit tests from lib.rs to separate file.

… in validator/lib.rs and moved the unit_tests to separate folder and file
@nsannn nsannn marked this pull request as ready for review January 25, 2026 01:14
.verify_aggregated_payload(
&validator_ids
.iter()
.map(|vid| validators.get(*vid).expect("validator must exist"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't panic here, throw proper error

&attestation_data_root,
aggregated_attestation.data.slot.0 as u32,
)
.expect("Attestation aggregated signature verification failed");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before, don't panic

if let Some(votes) = justifications.get(&target_root) {
let num_validators = self.validators.len_u64() as usize;
let count = votes.iter().filter(|&&v| v).count();
let threshold = (2 * num_validators + 2) / 3; // ceil(2/3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use .div_ceil instead

tracing::info!(
target_slot = target_slot.0,
target_root = %format!("0x{:x}", target_root.0),
"JUSTIFICATION THRESHOLD REACHED!"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONT SCREAM PLEASE! thank you :)

Comment on lines +25 to +26
leansig = { git = "https://github.com/leanEthereum/leanSig", rev = "73bedc26ed961b110df7ac2e234dc11361a4bf25" }
lean-multisig = { git = "https://github.com/leanEthereum/leanMultisig", rev = "e4474138487eeb1ed7c2e1013674fe80ac9f3165" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! wanted to do the same thing 👍

Comment on lines +28 to +35
fn validate_attestation_data(store: &Store, data: &AttestationData) -> Result<(), String> {
// Cannot count a vote if we haven't seen the blocks involved
if !store.blocks.contains_key(&data.source.root) {
return Err(format!(
"Unknown source block: {:?}",
&data.source.root.0.as_bytes()[..8]
));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use anyhow error instead of string, and immediately get lots of benefits:

  1. builtin backtraces
  2. builtin conversions from any type, implementing std::error::Error
  3. various nice helpers, like:
    • custom error messages with anyhow! macro;
    • assert-like non-panicking macro ensure!;
    • nice wrapper bail! for simplifying return Err(anyhow!(...)).

The only shortcoming of anyhow is that you can't do pattern matching on error types. For those cases, thiserror exist.

So when using anyhow, your code can look a lot nicer:

Suggested change
fn validate_attestation_data(store: &Store, data: &AttestationData) -> Result<(), String> {
// Cannot count a vote if we haven't seen the blocks involved
if !store.blocks.contains_key(&data.source.root) {
return Err(format!(
"Unknown source block: {:?}",
&data.source.root.0.as_bytes()[..8]
));
}
fn validate_attestation_data(store: &Store, data: &AttestationData) -> Result<()> {
// Cannot count a vote if we haven't seen the blocks involved
ensure!(store.blocks.contains_key(&data.source.root), "Unknown source block: {:?}", &data.source.root.0.as_bytes()[..8]);

Don't want to repeat this comment everywhere, but I think you got the idea, that all places, where you use String or Box<dyn std::error::Error> or something else as error type, must be changed to use anyhow's errors.

Comment on lines +588 to +591
let err_str = format!("{:?}", err);
if !err_str.contains("Duplicate") {
warn!(slot = slot, ?err, "Publish block with attestation failed");
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if duplicate errors are expected, then don't throw them at all. However, how do you distinguish between duplicate where you've received your own block, and duplicate where someone else attests twice? I think this place just doesn't make sense, and you've missed something during implementation, and warning is justified here.

Comment on lines +81 to +86
# docker-local: ./target/x86_64-unknown-linux-gnu/release/lean_client ./target/aarch64-unknown-linux-gnu/release/lean_client
docker-local: ./target/x86_64-unknown-linux-gnu/release/lean_client
@mkdir -p ./bin/amd64
@cp ./target/x86_64-unknown-linux-gnu/release/lean_client ./bin/amd64/lean_client
@mkdir -p ./bin/arm64
@cp ./target/aarch64-unknown-linux-gnu/release/lean_client ./bin/arm64/lean_client
# @mkdir -p ./bin/arm64
# @cp ./target/aarch64-unknown-linux-gnu/release/lean_client ./bin/arm64/lean_client
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented lines

@ArtiomTr
Copy link
Collaborator

do this PR fix some test vectors? because that would be primary goal to achieve, apart from refactoring some parts

@ArtiomTr
Copy link
Collaborator

let's merge it now, and fix all nitpicks later

@ArtiomTr ArtiomTr merged commit c525df2 into devnet-2 Jan 26, 2026
0 of 3 checks passed
nsannn added a commit that referenced this pull request Jan 26, 2026
ArtiomTr pushed a commit that referenced this pull request Jan 27, 2026
LiudasBaronas1 pushed a commit that referenced this pull request Jan 27, 2026
* feat: use ssz encoded validator key generation

* fix: export validator keys to both ssz and json format for compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants