Skip to content

test(cketh): teach the live harness to deploy and drive the sweep contracts - #11259

Closed
gregorydemay wants to merge 2 commits into
greg/DEFI-2926-reuse-signed-authorizationsfrom
greg/DEFI-2926-anvil-sweep-harness
Closed

test(cketh): teach the live harness to deploy and drive the sweep contracts#11259
gregorydemay wants to merge 2 commits into
greg/DEFI-2926-reuse-signed-authorizationsfrom
greg/DEFI-2926-anvil-sweep-harness

Conversation

@gregorydemay

@gregorydemay gregorydemay commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Why

  • The live harness could scan balances on anvil, but nothing test-side could run a sweep against a real chain: no sweep contracts on the node, and no way to read what a sweep did.

What

  • LiveSetup::new_sweep deploys the real deposit helper and the attested sweeper delegate on the harness' anvil before installing the minter, so the minter starts knowing both, and pre-funds the sweeper address with ETH (a shortcut for the funding pipeline, which has its own end-to-end test).
  • The anvil client learns to read what a sweep did: an address' code (for delegation designators), the transactions an address sent with their type, status, and gas, and to set an ETH balance.
  • anvil now mines on an interval, so block-based scan backoffs and the finalized tag advance on their own instead of freezing whenever no test transaction lands.

@github-actions github-actions Bot added the test label Aug 21, 2026
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 6344a8d to ce8f921 Compare August 21, 2026 14:46
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from f136aca to d741cac Compare August 21, 2026 14:46
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from ce8f921 to 21711b3 Compare August 25, 2026 07:16
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from d741cac to 4d0133d Compare August 25, 2026 07:16
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 21711b3 to 4f2146b Compare August 25, 2026 10:05
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 4d0133d to 461eaba Compare August 25, 2026 10:05
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 4f2146b to 32aeffc Compare August 25, 2026 11:21
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 461eaba to 954ac72 Compare August 25, 2026 11:21
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 32aeffc to e4933e1 Compare August 25, 2026 12:53
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 954ac72 to cd56d0a Compare August 25, 2026 12:55
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from e4933e1 to 68aa462 Compare August 25, 2026 13:05
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from cd56d0a to a988856 Compare August 25, 2026 13:05
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 68aa462 to bb73432 Compare August 25, 2026 13:17
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from a988856 to b02f84d Compare August 25, 2026 13:17
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch 2 times, most recently from 54fa93a to 1d54656 Compare August 25, 2026 14:23
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from b02f84d to 741e33a Compare August 25, 2026 14:27
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 1d54656 to 56569ec Compare August 25, 2026 14:32
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 741e33a to bf87e2e Compare August 25, 2026 14:32
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch 2 times, most recently from fca3bc8 to 4ee7b66 Compare August 25, 2026 15:44
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from bf87e2e to 80c65bb Compare August 25, 2026 15:45
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 4ee7b66 to f2c5e04 Compare August 25, 2026 15:50
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 80c65bb to 6814d95 Compare August 25, 2026 15:50
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from f2c5e04 to 2624c58 Compare August 26, 2026 05:55
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch 2 times, most recently from 104b780 to f16ec5a Compare August 26, 2026 06:00
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from 2624c58 to a383003 Compare August 26, 2026 06:00
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 6a777e9 to 3da307d Compare August 26, 2026 07:10
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from f348965 to f57f592 Compare August 26, 2026 08:56
Comment thread rs/ethereum/cketh/minter/src/sweep.rs Outdated
/// authorizations can advance it.
pub async fn enqueue_batched_sweep() {
let _guard = match TimerGuard::new(TaskType::SweeperSend) {
let _guard = match TimerGuard::new(TaskType::SweeperEnqueue) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

why does this change? Why is SweeperEnqueue added?

@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from f57f592 to 330569e Compare August 26, 2026 11:51
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 2295f0b to 2bb495f Compare August 26, 2026 11:51
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch 6 times, most recently from b56bfeb to ece8797 Compare August 26, 2026 16:38
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 2bb495f to 7dbcf5e Compare August 26, 2026 16:38
@gregorydemay gregorydemay changed the title test(cketh): deploy the sweep contracts on the harness' anvil test(cketh): teach the live harness to deploy and drive the sweep contracts Aug 26, 2026
@gregorydemay
gregorydemay requested a balanced review from Copilot August 26, 2026 16:41

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

Extends the ckETH live test harness to deploy and inspect real sweep contracts on Anvil.

Changes:

  • Adds sweep-specific fixture setup and minter configuration.
  • Adds Anvil transaction, balance, code, and contract deployment utilities.
  • Enables interval mining for block progression.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
test_utils/src/live.rs Adds the live sweep fixture and inspection APIs.
test_utils/src/lib.rs Wires sweep contracts into minter initialization.
test_utils/src/ckerc20.rs Supports custom subaccount helpers.
test_utils/src/anvil.rs Adds sweep deployment and chain inspection utilities.

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

let delegate = anvil.deploy(
&deployer,
&deploy_code(
&compile("CKSWEEPER_ATTESTED_SOL", "CkSweeperAttested"),
let Some(transactions) = block["transactions"].as_array() else {
continue;
};
for transaction in transactions {
///
/// Funding the sweeper directly is a shortcut: in production its gas comes from a ckETH burn
/// out of the minter's fee account, which is a separate pipeline from sweeping.
pub fn new_sweep(sweeper: &Address, sweeper_gas_wei: u128) -> Self {
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-enqueue-batched-sweep branch from ece8797 to 3991927 Compare August 26, 2026 17:03
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 7dbcf5e to 76e5ad9 Compare August 26, 2026 17:03
@gregorydemay
gregorydemay changed the base branch from greg/DEFI-2926-enqueue-batched-sweep to greg/DEFI-2926-reuse-signed-authorizations August 26, 2026 17:04
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-reuse-signed-authorizations branch from b808126 to 135e448 Compare August 26, 2026 17:38
@gregorydemay
gregorydemay force-pushed the greg/DEFI-2926-anvil-sweep-harness branch from 76e5ad9 to 56379f6 Compare August 26, 2026 17:38
@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-anvil-sweep-harness branch from 56379f6 to 4ba45e6 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 4 out of 4 changed files in this pull request and generated 2 comments.

Suppressed comments (2)

rs/ethereum/cketh/test_utils/src/anvil.rs:316

  • last_transaction_of searches block heights newest-first, but transactions within the selected block oldest-first. Interval mining explicitly allows several transactions in one block, so this can return an earlier transaction rather than the most recent one and make failure/gas assertions inspect the wrong sweep.
            for transaction in transactions {

rs/ethereum/cketh/test_utils/src/anvil.rs:599

  • This new compilation path requires CKSWEEPER_ATTESTED_SOL, but the live-harness Bazel target //rs/ethereum/cketh/minter:deposit_from_cex neither includes CkSweeperAttested.sol in data nor defines that environment variable (its BUILD target currently provides only CKDEPOSIT_SOL). Calling LiveSetup::new_sweep from the harness therefore panics with contract source env var not set by Bazel; add the source and env entry to that target.
            &compile("CKSWEEPER_ATTESTED_SOL", "CkSweeperAttested"),

Comment on lines +164 to +166
/// Like [`Self::new_balance_scan`], but with the real deposit helper and the attested sweeper
/// delegate deployed on the node first, so the minter is installed knowing both, and with the
/// minter's dedicated sweeper address pre-funded with `sweeper_gas_wei` of ETH.
Comment on lines +263 to +271
pub fn balance(&self, address: &Address) -> u128 {
let balance = self.rpc(
"eth_getBalance",
serde_json::json!([to_hex(address.as_ref()), "latest"]),
);
let balance = balance.as_str().unwrap();
u128::from_str_radix(balance.trim_start_matches("0x"), 16)
.unwrap_or_else(|e| panic!("not a u128 balance {balance}: {e}"))
}
@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