Skip to content

perf(cketh): reuse the delegation authorization a deposit address signed - #11337

Closed
gregorydemay wants to merge 2 commits into
greg/DEFI-2926-enqueue-batched-sweepfrom
greg/DEFI-2926-reuse-signed-authorizations
Closed

perf(cketh): reuse the delegation authorization a deposit address signed#11337
gregorydemay wants to merge 2 commits into
greg/DEFI-2926-enqueue-batched-sweepfrom
greg/DEFI-2926-reuse-signed-authorizations

Conversation

@gregorydemay

@gregorydemay gregorydemay commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Why

  • Every sweep signed a fresh EIP-7702 authorization for each deposit address it touched, paying a threshold-ECDSA signature for a tuple that never changes: nonce 0, one chain, one delegate.

What

  • The minter remembers the authorization a deposit address signed and reuses it on every later sweep of that address; only addresses without a usable stored tuple cost a signature.
  • A stored tuple is checked against the configuration before reuse — one naming a retired sweeper contract or another chain misses and is simply re-signed.
  • The store lives on the heap alone: losing it costs one signature per address, never a sweep, so an upgrade may empty it rather than the event log carrying an entry per address forever.
  • A gauge reports the store's size, so growth is visible before it needs bounding.

Copilot AI 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.

Pull request overview

Caches EIP-7702 deposit-address authorizations to reduce threshold-ECDSA signing costs during repeated ckERC20 sweeps.

Changes:

  • Stores and reuses configuration-compatible authorizations in heap state.
  • Adds validation and reuse tests.
  • Exposes cache size as a metric.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sweep/tests.rs Tests stored-authorization selection.
sweep/mod.rs Reuses cached authorizations during sweep preparation.
state/tests.rs Tests authorization configuration validation.
state/automatic_deposits/mod.rs Adds the heap-only authorization cache.
state.rs Provides cache access and validation.
main.rs Exposes cache size as a gauge.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +647 to +651
/// The authorizations the minter already holds for these addresses, keyed by account.
///
/// Only the ones still usable: [`State::authorization`] checks a stored tuple against the chain and
/// the delegate the minter runs against, so an address delegated by a retired sweeper contract falls
/// through to a fresh signature rather than being swept through the wrong delegate.
/// every upgrade, to save a cost that is bounded by the addresses in flight. Nothing prunes it
/// within a canister version — [`Self::authorizations_len`] is exported as a metric so its
/// growth is visible before it needs bounding.
authorizations: BTreeMap<DepositAddress, SignedAuthorization>,
@github-actions github-actions Bot added the perf label Aug 26, 2026
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-reuse-signed-authorizations branch from b808126 to 135e448 Compare August 26, 2026 17:38
The tuple never expires — nonce 0, one chain, one delegate — so it is
kept on the heap, checked against the configuration before reuse, and
only addresses without a usable one cost a threshold-ECDSA signature.
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-reuse-signed-authorizations branch from 135e448 to d2cba5a Compare August 27, 2026 07:56
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from e6e7cf3 to 8311a24 Compare August 27, 2026 07:56

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

rs/ethereum/cketh/minter/src/state/automatic_deposits/mod.rs:85

  • This heap-only cache is still included in AutomaticDeposits' derived PartialEq, while State::is_equivalent_to compares the entire automatic_deposits value. After the first authorization is cached, check_audit_log replays an empty cache and then traps because the states are considered different. Exclude authorizations from upgrade-equivalence checks while retaining normal equality coverage for the persistent fields.
    authorizations: BTreeMap<DepositAddress, SignedAuthorization>,

@gregorydemay

Copy link
Copy Markdown
Contributor Author

🤖 Closing: superseded by the restructured stack #11353 (PRs #11359#11360#11362#11363#11342).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants