Skip to content

chore(precompiles): cleanup#3107

Merged
0xrusowsky merged 13 commits intomainfrom
rus/precompiles-cleanup
Mar 30, 2026
Merged

chore(precompiles): cleanup#3107
0xrusowsky merged 13 commits intomainfrom
rus/precompiles-cleanup

Conversation

@0xrusowsky
Copy link
Copy Markdown
Contributor

@0xrusowsky 0xrusowsky commented Mar 12, 2026

this PR:

  • drops encode_to_slot / decode_from_slot in favor of typed patterns leveraging StorageCtx
  • remove dead dispatch code and unused helpers
  • exposes precompile constants from tempo-contracts so alloy consumers don't need tempo-precompiles deps
  • clean up stale TODOs and comments

NOTE: no behavioral change

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 12, 2026

📊 Tempo Precompiles Coverage

📦 Download full HTML report

Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019ce295-a43d-731f-a20d-dbfd6beae083
…orage (#3351)

Upstream compound-policy tests in `tempo_pool.rs` used stale
`PolicyData::encode_to_slot()` / manual slot encoding that #3107
deletes. Migrates all 5 call sites to `setup_storage` + typed
`TIP403Registry` writes.

Co-Authored-By: 0xrusowsky
<90208954+0xrusowsky@users.noreply.github.com>

Prompted by: rusowsky

---------

Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

⚠️ Changelog not found.

A changelog entry is required before merging. We've generated a suggested changelog based on your changes:

Preview
---
tempo-contracts: minor
tempo-precompiles: major
tempo-transaction-pool: minor
---

Removed `encode_to_slot`/`decode_from_slot` helpers from `AuthorizedKey` and `PolicyData`, and removed the `validator_tokens` public method from `TipFeeManager` in favor of the existing `get_validator_token`. Exported shared constants (`DECIMALS`, `MIN_TICK`, `MAX_TICK`, `PRICE_SCALE`) from `tempo-contracts` and refactored the transaction pool's AMM liquidity cache to use a read-only storage context instead of raw slot decoding.

Add changelog to commit this to your branch.

Comment on lines +769 to +774
///
/// NOTE: Maker transfer policy authorization is intentionally NOT checked here.
/// Fills must never fail due to unexecutable orders from blacklisted makers, as that
/// would force takers to pay gas eating through stale liquidity. Instead, anyone can
/// call [`cancel_stale_order`](Self::cancel_stale_order) to remove orders from
/// blacklisted makers before they are filled.
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.

nit: The reason that Maker transfer policy auth is not checked is to ensure that swaps can complete, rather than for gas efficiency. Consider updating the comment to something like the following:

    /// NOTE: Maker transfer policy is not enforced here to not block swaps on the pair. 
    /// Note that TIP403 checks on order placement and withdraws are enforced.
    /// [`cancel_stale_order`](Self::cancel_stale_order) can be used to remove orders. 

Comment thread tips/ref-impls/src/StablecoinDEX.sol Outdated
Comment on lines +554 to +557
/// @dev Maker transfer policy authorization is intentionally NOT checked here.
/// Fills must never fail due to unexecutable orders from blacklisted makers, as that
/// would force takers to pay gas eating through stale liquidity. Instead, anyone can
/// call `cancelStaleOrder` to remove orders from blacklisted makers before they are filled.
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.

nit: same thing here, it is important to not fail on 403 policies during swaps to ensure swap execution rather than this being a gas optimization.

}
TipFeeManagerCall::FeeManager(IFeeManagerCalls::validatorTokens(call)) => {
view(call, |c| self.validator_tokens(c))
view(call, |c| self.get_validator_token(c.validator))
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.

I think this should be fine, but lets make sure re-execution passes. Previously self.validator_tokens returned a Vec.

Copy link
Copy Markdown
Contributor Author

@0xrusowsky 0xrusowsky Mar 30, 2026

Choose a reason for hiding this comment

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

i dropped it cause it returned an Address, so it's identical:

    /// Reads the stored fee token preference for a validator, defaulting to [`DEFAULT_FEE_TOKEN`].
    pub fn validator_tokens(&self, call: IFeeManager::validatorTokensCall) -> Result<Address> {
        let token = self.validator_tokens[call.validator].read()?;

        if token.is_zero() {
            Ok(DEFAULT_FEE_TOKEN)
        } else {
            Ok(token)
        }
    }
    /// Returns the validator's preferred fee token, falling back to [`DEFAULT_FEE_TOKEN`].
    pub fn get_validator_token(&self, beneficiary: Address) -> Result<Address> {
        let token = self.validator_tokens[beneficiary].read()?;

        if token.is_zero() {
            Ok(DEFAULT_FEE_TOKEN)
        } else {
            Ok(token)
        }
    }

Clarify that maker transfer policy is not enforced to avoid blocking
swaps, not for gas efficiency.

Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d3dd9-3244-706d-a2f6-f865f61c998c
@0xrusowsky 0xrusowsky enabled auto-merge March 30, 2026 08:34
@0xrusowsky 0xrusowsky added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit fe55ae0 Mar 30, 2026
33 checks passed
@0xrusowsky 0xrusowsky deleted the rus/precompiles-cleanup branch March 30, 2026 08:49
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