Skip to content

[Certora] OfferTree Soundness - #816

Merged
QGarchery merged 167 commits into
mainfrom
certora/offer-tree
Sep 21, 2026
Merged

QGarchery merged 167 commits into
mainfrom
certora/offer-tree

Conversation

@bhargavbh

@bhargavbh bhargavbh commented May 7, 2026

Copy link
Copy Markdown
Contributor

Objective is to show that a successful take can only settle an offer that was genuinely committed in the signed tree.
We reason about OfferTree, a model of the tree built only through the newLeaf and newInternalNode primitives. Leaves are keyed by HashLib.hashOffer(offer) and store a fixed-size pre-image of the offer, so isWellFormed re-hashes a leaf with a single bounded keccak instead of looping over the offer's dynamic members, which keeps the proofs bounded regardless of offer size.

  • OfferTreeWellFormed.spec checks that the primitives only ever build well-formed trees: every node is empty, a leaf carrying a genuine hashOffer, or an internal node correctly hashing its two children.
  • OfferTreeMembership.spec checks the main soundness result: for any well-formed tree, if a Merkle proof verifies an offer's hash against the root via isLeaf, then the offer is registered as a leaf. Equivalently, no valid proof can be forged for an offer that is not in the tree.

The verification setup and technique is inspired from the Merkle Tree Membership soundness spec in Universal Rewards Distributor

corresponding thread
motivation

@MathisGD MathisGD changed the title added rules inspired form URD [Certora] added rules inspired form URD May 11, 2026
@bhargavbh bhargavbh self-assigned this May 19, 2026
@bhargavbh bhargavbh changed the title [Certora] added rules inspired form URD [Certora] OfferTree soundness and completeness May 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0e2d9281b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread certora/confs/OfferTreeMembership.conf
Comment thread certora/specs/OfferTreeMembership.spec Outdated

@jhoenicke jhoenicke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. I also tried it with a broken hash function that allows collision of node and leaf and at least that found a counterexample.

Comment thread certora/confs/OfferTreeMembership.conf Outdated
Comment thread certora/confs/OfferTreeWellFormed.conf Outdated
Comment thread certora/specs/OfferTreeWellFormed.spec
Comment thread certora/helpers/GenerateRoot.sol Outdated
Comment thread certora/helpers/GenerateRoot.sol Outdated
Comment thread certora/helpers/GenerateRoot.sol
Comment thread certora/helpers/OfferTree.sol Outdated
Comment thread certora/helpers/GenerateRoot.sol
Comment thread certora/helpers/GenerateRoot.sol Outdated
Comment thread certora/helpers/GenerateRoot.sol
@bhargavbh

Copy link
Copy Markdown
Contributor Author

All good suggestions. Incorporated the following changes which simplifies the model quite a bit without impacting the claim:

  • Hash IDs: Internal-node IDs equal their hashes.
  • Idempotent creation: Constructors return hash IDs and reuse existing nodes.
  • Simpler membership: Use root directly; remove the separate node variable and getHash.
  • Generator does not inherit OfferTree: Compute roots in memory, independently of OfferTree.
  • Cleaner configs: Remove explicit sanity and timeout settings.
  • Regression tests: Cover root agreement, idempotency, missing children, duplicates, membership proofs, and storage isolation.
    cc @QGarchery

Comment thread certora/confs/OfferTreeWellFormed.conf

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b669c0ade

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread certora/specs/OfferTreeMembership.spec
Comment thread test/OfferTreeTest.sol Outdated
Comment thread certora/helpers/OfferTree.sol Outdated
Comment thread certora/helpers/OfferTree.sol Outdated
Comment thread certora/specs/OfferTreeMembership.spec Outdated
Comment thread certora/specs/OfferTreeMembership.spec Outdated
Comment thread test/OfferTreeTest.sol Outdated
@QGarchery
QGarchery merged commit 4d2621b into main Sep 21, 2026
64 checks passed
@QGarchery
QGarchery deleted the certora/offer-tree branch September 21, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants