Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: lightclient stops working during integration test #181

Open
smuu opened this issue Dec 18, 2024 · 3 comments · May be fixed by #193
Open

bug: lightclient stops working during integration test #181

smuu opened this issue Dec 18, 2024 · 3 comments · May be fixed by #193
Assignees
Labels
bug Something isn't working

Comments

@smuu
Copy link
Contributor

smuu commented Dec 18, 2024

When running the integration test, the client stops working when it finds the first epoch in a block.
The light client can verify the signatures, but when trying to read the previous commitment from the public values, the light client stops working. I could not identify if the functions never returned or if the light client crashed without an error.
The light client never continues to look at the next height.

if let Some(pubkey) = &self.prover_pubkey {
    match finalized_epoch.verify_signature(*pubkey) {
        Ok(_) => trace!("valid signature for epoch {}", finalized_epoch.height),
        Err(e) => panic!("invalid signature in epoch {}: {:?}", i, e),
    }
}

debug!("verifying commitment for epoch {}", finalized_epoch.height);

// Commitment verification
let prev_commitment = &finalized_epoch.prev_commitment;
debug!("prev_commitment: {:?}", prev_commitment);
let current_commitment = &finalized_epoch.current_commitment;
debug!("current_commitment: {:?}", current_commitment);
let mut public_values = finalized_epoch.proof.public_values.clone();
debug!("public_values: {:?}", public_values);                // <-- This debug message is the last one present in the terminal
let proof_prev_commitment: Digest = public_values.read();
debug!("proof_prev_commitment: {:?}", proof_prev_commitment);                // <-- This debug mesage is never shown
let proof_current_commitment: Digest = public_values.read();
debug!("proof_current_commitment: {:?}", proof_current_commitment);

if prev_commitment != &proof_prev_commitment
    || current_commitment != &proof_current_commitment
{
    error!(
        "Commitment mismatch:
        prev_commitment: {:?}, proof_prev_commitment: {:?},
        current_commitment: {:?}, proof_current_commitment: {:?}",
        prev_commitment, proof_prev_commitment,
        current_commitment, proof_current_commitment
    );
    continue;
}

debug!("verifying zkSNARK for epoch {}", finalized_epoch.height);

// SNARK verification
match self.client.verify(&finalized_epoch.proof, &self.verifying_key) {
    Ok(_) => info!("zkSNARK for epoch {} was validated successfully", finalized_epoch.height),
    Err(err) => panic!("failed to validate epoch at height {}: {:?}", finalized_epoch.height, err),
}

Please let me know if you need more context.

@distractedm1nd distractedm1nd added the bug Something isn't working label Dec 18, 2024
@distractedm1nd distractedm1nd self-assigned this Dec 18, 2024
@smuu
Copy link
Contributor Author

smuu commented Dec 18, 2024

When replacing

let proof_prev_commitment: Digest = public_values.read();
let proof_current_commitment: Digest = public_values.read();

with

let mut slice = [0u8; 32];
slice.copy_from_slice(&public_values.as_slice()[..32]);
let proof_prev_commitment: Digest = Digest::from(slice);
let mut slice = [0u8; 32];
slice.copy_from_slice(&public_values.to_vec()[32..64]);
let proof_current_commitment: Digest = Digest::from(slice);

The code stops when calling self.client.verify.

@smuu
Copy link
Contributor Author

smuu commented Dec 19, 2024

Not sure if this error is related:

Caused by:
    initializing service: task 15 panicked with message "failed to deserialize: Io(Custom { kind: UnexpectedEof, error: \"\" })"
Failed to validate and queue update: Account not found for id: 4@gmail.com
Failed to validate and queue update: Account not found for id: 4@gmail.com
Failed to validate and queue update: Account not found for id: 2@gmail.com
Failed to validate and queue update: Account not found for id: 2@gmail.com
Failed to validate and queue update: Account not found for id: 5@gmail.com
Failed to validate and queue update: Account not found for id: 3@gmail.com
Failed to validate and queue update: Account not found for id: 4@gmail.com
Failed to validate and queue update: Account not found for id: 5@gmail.com
Failed to validate and queue update: Account not found for id: 3@gmail.com
Failed to validate and queue update: Account not found for id: 1@gmail.com
Failed to validate and queue update: Account not found for id: 10@gmail.com
...
Failed to validate and queue update: Nonce does not match. 4 != 3
Failed to validate and queue update: Nonce does not match. 5 != 3
...
thread 'test_light_client_prover_talking_all_curves' panicked at /Users/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pretty_env_logger-0.5.0/src/lib.rs:63:16:
called `Result::unwrap()` on an `Err` value: SetLoggerError(())

@distractedm1nd
Copy link
Contributor

distractedm1nd commented Jan 8, 2025

This bug is happening because the mock_prover feature is not being activated for the lightclient package.

Opening a PR today to work around this, but we will need to add an integration test that actually generates the proof, meaning we need to set up the infra for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants