Skip to content

[Certora] lib/bundler assets/debts reachability#916

Open
lilCertora wants to merge 26 commits into
mainfrom
certora/bundlerAndTakeAmountLib
Open

[Certora] lib/bundler assets/debts reachability#916
lilCertora wants to merge 26 commits into
mainfrom
certora/bundlerAndTakeAmountLib

Conversation

@lilCertora

@lilCertora lilCertora commented May 22, 2026

Copy link
Copy Markdown
Collaborator

@lilCertora lilCertora self-assigned this May 22, 2026
@lilCertora lilCertora marked this pull request as ready for review May 25, 2026 16:01
@lilCertora lilCertora mentioned this pull request May 26, 2026
72 tasks

@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: cb5264a55a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated

@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: eabec97f3b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Comment thread certora/specs/TakeAmountsLibInvertibility.spec

@bhargavbh bhargavbh left a comment

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.

very nice roundtrip properties to have for bundler's liveness guarantees.

Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
@lilCertora lilCertora requested a review from bhargavbh June 2, 2026 12:25

@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: 6ed13dd96a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread certora/specs/TakeAmountsLibInvertibility.spec

@bhargavbh bhargavbh left a comment

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.

LGTM. Please update the README with the rules description.

lilCertora and others added 4 commits June 2, 2026 22:55
Comment thread certora/helpers/TakeAmountsLibHarness.sol Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
commit some suggestions

Co-authored-by: Quentin Garchery <garchery.quentin@gmail.com>
Signed-off-by: lilCertora <lilian@certora.com>

@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: 7bd9544bf7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread certora/specs/TakeAmountsLibInvertibility.spec
Comment thread certora/specs/TakeAmountsLibInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
}

// a*b <= max_uint256 and d >= 1 => a*b/d <= a*b <= max_uint256, so the cast never truncates.
return require_uint256(a * b / d);

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.

Can we use an assert_uint256 here?

Suggested change
return require_uint256(a * b / d);
return assert_uint256(a * b / d);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

can't access this link, but I also had problems in this run. Any idea what that might be ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

looks like an internal bug before reaching the assert_uint256 :

ERROR COMMON - Had an exception while getting object to verify for rule
repayAndWithdrawCollateralRepaysTargetUnits,
java.lang.IllegalArgumentException: Failed requirement.
    at verifier.PatchingProgramWrapper.updateAssertSnippetsOf(PatchingProgramWrapper.kt:149)

Comment thread certora/specs/BundlerRepayInvertibility.spec Outdated
Co-authored-by: Jochen Hoenicke <hoenicke@gmail.com>
Signed-off-by: lilCertora <lilian@certora.com>
rule buyerAssetsReachable(env e, Midnight.Offer offer, uint256 targetBuyerAssets, address taker, address takerCallback, bytes takerCallbackData, address receiverIfTakerIsSeller, bytes ratifierData) {
bytes32 id = summaryToId(offer.market);

uint256 units = TakeAmountsLibHarness.buyerAssetsToUnits(e, currentContract, id, offer, targetBuyerAssets);

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.

the fact that revert cases are ignored hides the fact that actually not all buyerAssets are reachable all the time. maybe at least:

Suggested change
uint256 units = TakeAmountsLibHarness.buyerAssetsToUnits(e, currentContract, id, offer, targetBuyerAssets);
// reverts if the offer's price is above one (in that case not all buyerAssets are reachable.
uint256 units = TakeAmountsLibHarness.buyerAssetsToUnits(e, currentContract, id, offer, targetBuyerAssets);

or a more advanced verification with @withrevert

Comment thread certora/specs/BundlerRepayInvertibility.spec
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.

5 participants