Skip to content

Conversation

@mgretzke
Copy link
Collaborator

@mgretzke mgretzke commented Nov 5, 2025

Added the UtilityLib:

  • Allows checking if the current chain supports eip-1153 (transient storage).
  • Adds settledBalanceOf to retrieve an ERC6909 balance from the compact. The function reverts in case the compacts reentrancy guard is active.

@mgretzke mgretzke requested review from 0age and ccashwell November 5, 2025 12:49
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.30%. Comparing base (ac25e50) to head (e2b0a3a).

Files with missing lines Patch % Lines
src/utility/UtilityLib.sol 86.66% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
- Coverage   98.39%   98.30%   -0.10%     
==========================================
  Files          41       42       +1     
  Lines        1809     1824      +15     
  Branches       99      102       +3     
==========================================
+ Hits         1780     1793      +13     
- Misses         29       31       +2     
Files with missing lines Coverage Δ
src/utility/UtilityLib.sol 86.66% <86.66%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac25e50...e2b0a3a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


/// @notice Returns the users balance only if reentrancy protection is not active on the Compact. This eliminates in flight balances before the ERC6909 tokens were burned.
/// @dev Only if eip-1153 (transient storage) is not available.
function settledBalanceOf_nonTransient(address owner, uint256 id) internal view returns (uint256 amount) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

for this one, if we want to go try-hard on it we could derive the balance slot and use the batch extsload function to get both values in one call

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like it! Not sure how much more efficient this will be though? it will at least lead to higher revert costs, since both values will be read from storage not knowing, if we even need the balance.

Copy link
Collaborator

@0age 0age left a comment

Choose a reason for hiding this comment

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

looking good! left some comments, the major thing i think this is still missing is a helper function for handling the case where tstore isn't supported yet but may become supported, and probably also a helper that makes it dead-simple for integrators (basically giving them a "settledBalanceOf" function that will select the appropriate function under the hood)

effectively, you'd have:

  • logic in the constructor to check if tstore is supported (which already has a helper implemented) and if so just assign the current settledBalanceOf as the balance check fn from the get-go
  • logic in the alternative balance check contract to handle cases where tstore got activated at a later point; I feel like the most straightforward move here is to just read both the tstore slot and the sstore slot and if either is set to revert (IMHO you'd be hard-pressed to find a chain that doesn't support tstore yet where execution isn't dirt-cheap)

@mgretzke mgretzke requested a review from 0age November 6, 2025 14:15
0age
0age previously approved these changes Nov 13, 2025
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.

4 participants