Skip to content

fix: skip irrelevant helios errors on circuit#13

Merged
vlopes11 merged 1 commit into
mainfrom
vlopes11/fix/apply-circuit-must-filter
Sep 26, 2025
Merged

fix: skip irrelevant helios errors on circuit#13
vlopes11 merged 1 commit into
mainfrom
vlopes11/fix/apply-circuit-must-filter

Conversation

@vlopes11

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @vlopes11, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the light client's resilience and efficiency by introducing a sophisticated error handling strategy for Helios consensus updates. It allows the system to gracefully ignore certain non-critical errors, ensuring smoother operation. Alongside this, a comprehensive update of project dependencies brings in the latest features and fixes, while a new build optimization streamlines the development and CI process for the light client controller.

Highlights

  • Helios Error Filtering: Implemented a mechanism to filter and skip specific 'irrelevant' Helios consensus errors (InvalidTimestamp, InvalidPeriod, NotRelevant, CheckpointTooOld) during light client update verification, preventing unnecessary failures.
  • Dependency Updates: Updated numerous Rust dependencies across the project, including core crates like anyhow, rustls, tokio-rustls, and clap, as well as project-specific valence-coprocessor components, to their latest versions.
  • Code Refactoring and Optimization: Refactored the light client service to centralize error handling within the State struct and removed redundant update verification logic from the main service loop. Additionally, a build-time optimization was introduced to conditionally skip the valence-coprocessor-ethereum-controller WASM build using an environment variable.
  • Binary Artifact Updates: Updated several binary artifacts (inner-vkh32.bin, wrapper-bytes32, wrapper-vkh32.bin), indicating re-compilation or updates to underlying cryptographic components related to the valence-coprocessor.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request aims to skip irrelevant Helios errors during circuit execution by updating dependencies, adding eyre for error handling, and refactoring the light client state update logic. The changes introduce a new error filtering mechanism which is a good step towards making the process more robust. However, I've identified two critical bugs in the new update logic where updates are applied regardless of their verification status, which could lead to state corruption. I've also found a minor issue with a misleading error message. Please see the detailed comments for suggestions on how to fix these issues.

Comment on lines 93 to 101
for u in updates.iter() {
verify_update(u, *expected_current_slot, &self.store, genesis_root, &forks)
.map_err(|e| anyhow::anyhow!("failed to verify update: {e}"))?;
if let Err(e) =
verify_update(u, *expected_current_slot, &self.store, genesis_root, &forks)
{
Self::filter_error(&e)?;
}

apply_update(&mut self.store, u);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

There's a critical bug in this loop. apply_update is called for every update, even if verify_update fails. The if let Err(e) block might swallow the error via filter_error, but execution proceeds to line 100, where apply_update is called with a potentially invalid update. This could corrupt the store state. The update should only be applied if verification succeeds.

        for u in updates.iter() {
            match verify_update(u, *expected_current_slot, &self.store, genesis_root, &forks) {
                Ok(_) => apply_update(&mut self.store, u),
                Err(e) => Self::filter_error(&e)?,
            }
        }

Comment on lines +103 to 113
if let Err(e) = verify_finality_update(
finality_update,
*expected_current_slot,
&self.store,
genesis_root,
&forks,
)
.map_err(|e| anyhow::anyhow!("failed to verify finality update: {e}"))?;
) {
Self::filter_error(&e)?;
}

apply_finality_update(&mut self.store, finality_update);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Similar to the loop for updates, there's a critical bug here. apply_finality_update is called unconditionally, even if verify_finality_update returns an error that is subsequently filtered. Applying an unverified finality update can lead to a corrupt or invalid light client state. The finality update should only be applied upon successful verification.

        match verify_finality_update(
            finality_update,
            *expected_current_slot,
            &self.store,
            genesis_root,
            &forks,
        ) {
            Ok(_) => apply_finality_update(&mut self.store, finality_update),
            Err(e) => Self::filter_error(&e)?,
        }

Comment on lines 115 to 118
anyhow::ensure!(
self.store.finalized_header.beacon().slot > prev_head,
self.store.finalized_header.beacon().slot >= prev_head,
"New head is not greater than previous head."
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The check was changed from > to >=, but the error message "New head is not greater than previous head." was not updated. This is now misleading. If the new head slot is equal to the previous head, the check will pass, but the error message would technically be a true statement about the situation, which is confusing. The message should be updated to reflect that the new head cannot be older than the previous one.

        anyhow::ensure!(
            self.store.finalized_header.beacon().slot >= prev_head,
            "New head is older than previous head."
        );

@vlopes11 vlopes11 force-pushed the vlopes11/fix/apply-circuit-must-filter branch from 04ce352 to b533ea0 Compare September 26, 2025 15:11
@vlopes11 vlopes11 force-pushed the vlopes11/fix/apply-circuit-must-filter branch from b533ea0 to 26cb942 Compare September 26, 2025 18:00
@vlopes11 vlopes11 merged commit 20a61bb into main Sep 26, 2025
10 checks passed
@vlopes11 vlopes11 deleted the vlopes11/fix/apply-circuit-must-filter branch September 26, 2025 18:18
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.

1 participant