Skip to content

feat!(ethexe): transition of value claims to merkle root#5415

Draft
StackOverflowExcept1on wants to merge 3 commits intomasterfrom
av/ethexe-value-claims-merkle-root
Draft

feat!(ethexe): transition of value claims to merkle root#5415
StackOverflowExcept1on wants to merge 3 commits intomasterfrom
av/ethexe-value-claims-merkle-root

Conversation

@StackOverflowExcept1on
Copy link
Copy Markdown
Member

@StackOverflowExcept1on StackOverflowExcept1on commented May 8, 2026

Related to #5406

Summary

Transition to merkle roots, but only for value claims for now

TODO

  • add support for RPC and client methods for generating merkle proofs
  • fix node-loader and test with it that we don't have any economics problems

How to test

See tests that use merkle proofs to claim value

Notes

This will break state of programs on Ethereum, but will not break them in database

Checklist

  • PR title follows Conventional Commits (type(scope): description)
  • Single logical change
  • Tests added or updated (if logic changed)
  • Docs updated (if needed)

@StackOverflowExcept1on StackOverflowExcept1on self-assigned this May 8, 2026
@StackOverflowExcept1on StackOverflowExcept1on added scope: vara.eth Vara Ethereum application layer (L2) ci: full Run full CI matrix (all platforms and profiles) labels May 8, 2026
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented May 8, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  ethexe/ethereum/abi/WrappedVara.json  100% smaller
  ethexe/ethereum/abi/BatchMulticall.json  100% smaller
  ethexe/ethereum/abi/POAMiddleware.json  99% smaller
  ethexe/ethereum/abi/DemoCaller.json  97% smaller
  ethexe/ethereum/abi/Gear.json  95% smaller
  ethexe/ethereum/src/abi/mod.rs  50% smaller
  ethexe/node-loader/src/batch.rs  46% smaller
  ethexe/service/src/tests/mod.rs  24% smaller
  ethexe/ethereum/src/abi/gear.rs  10% smaller
  Cargo.lock Unsupported file format
  ethexe/common/Cargo.toml Unsupported file format
  ethexe/common/src/gear.rs  0% smaller
  ethexe/contracts/src/IMirror.sol Unsupported file format
  ethexe/contracts/src/Mirror.sol Unsupported file format
  ethexe/contracts/src/libraries/BinaryMerkleTree.sol Unsupported file format
  ethexe/contracts/src/libraries/Gear.sol Unsupported file format
  ethexe/contracts/test/Base.t.sol Unsupported file format
  ethexe/contracts/test/POC.t.sol Unsupported file format
  ethexe/ethereum/Cargo.toml Unsupported file format
  ethexe/ethereum/abi/Middleware.json Unsupported file format
  ethexe/ethereum/abi/Mirror.json Unsupported file format
  ethexe/ethereum/abi/Router.json Unsupported file format
  ethexe/ethereum/src/mirror/mod.rs  0% smaller
  ethexe/sdk/src/mirror.rs  0% smaller
  utils/gear-workspace-hack/Cargo.toml Unsupported file format

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 transitions the value claim mechanism in the ethexe system from using arrays to Merkle roots. This change optimizes the data structure for value claims, allowing for more efficient verification via Merkle proofs. Please note that this update introduces a breaking change for existing program states on Ethereum, though it does not affect the underlying database state.

Highlights

  • Merkle Root Transition: Transitioned value claims from arrays to Merkle roots to improve verification efficiency and scalability.
  • Smart Contract Updates: Implemented the claimValue function in the Mirror contract, enabling users to claim values using Merkle proofs.
  • Dependency Integration: Integrated the binary-merkle-tree library to handle the generation and verification of Merkle proofs across the codebase.
Ignored Files
  • Ignored by pattern: ethexe/ethereum/abi/*.json (8)
    • ethexe/ethereum/abi/BatchMulticall.json
    • ethexe/ethereum/abi/DemoCaller.json
    • ethexe/ethereum/abi/Gear.json
    • ethexe/ethereum/abi/Middleware.json
    • ethexe/ethereum/abi/Mirror.json
    • ethexe/ethereum/abi/POAMiddleware.json
    • ethexe/ethereum/abi/Router.json
    • ethexe/ethereum/abi/WrappedVara.json
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 the 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 counterproductive. 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.

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.

@StackOverflowExcept1on StackOverflowExcept1on marked this pull request as draft May 8, 2026 07:36
Copy link
Copy Markdown
Contributor

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

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 transitions the ethexe value claim mechanism from a push-based model to a pull-based model using Merkle proofs. It introduces a BinaryMerkleTree Solidity library, updates the Mirror contract to store Merkle roots of claims, and adds a claimValue function for users to claim funds individually. Feedback was provided to ensure that failed Ether transfers in claimValue revert the transaction to allow for retries and prevent permanent fund locking. Additionally, a comment in the BinaryMerkleTree library was flagged as misleading, noting that commutative hashing would break compatibility with the Rust-side root calculation.

Comment on lines +404 to +411
_processedValueClaims[_claim.messageId] = true;

bool success = _transferEther(_claim.destination, _claim.value);
if (success) {
emit ValueClaimed(_claim.messageId, _claim.value);
} else {
emit ValueClaimFailed(_claim.messageId, _claim.value);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In the new pull-based claimValue function, the claim is marked as processed (_processedValueClaims[_claim.messageId] = true) even if the ether transfer fails. Since the user initiates this call, they should be able to retry if the transfer fails (e.g., if the destination is a contract that temporarily reverts or runs out of gas). Marking it as processed on failure permanently locks the funds in the contract. It is recommended to use require(success, ...) to revert the transaction on failure, which ensures the state is not updated and allows for retries.

        _processedValueClaims[_claim.messageId] = true;

        bool success = _transferEther(_claim.destination, _claim.value);
        require(success, "Transfer failed");

        emit ValueClaimed(_claim.messageId, _claim.value);

Comment thread ethexe/contracts/src/libraries/BinaryMerkleTree.sol
@StackOverflowExcept1on StackOverflowExcept1on changed the title feat(ethexe): transition of value claims to merkle root feat!(ethexe): transition of value claims to merkle root May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: full Run full CI matrix (all platforms and profiles) scope: vara.eth Vara Ethereum application layer (L2)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant