Skip to content

feat(cketh): configure and expose the sweeper contract address - #11145

Open
gregorydemay wants to merge 3 commits into
masterfrom
gdemay/DEFI-2925-sweeper-contract
Open

feat(cketh): configure and expose the sweeper contract address#11145
gregorydemay wants to merge 3 commits into
masterfrom
gdemay/DEFI-2925-sweeper-contract

Conversation

@gregorydemay

Copy link
Copy Markdown
Contributor

Adds an optional ethereum_sweeper_contract_address field to the ckETH minter's init and upgrade arguments, holding the address of the sweeper smart contract deployed on Ethereum (DEFI-2925). It can be set at install time and changed on upgrade, exactly like the existing deposit helper contract addresses. Nothing consumes it yet — this is the configuration plumbing the sweeper will build on.

Along the way, the per-contract InvalidStateError variants collapse into a single InvalidContractAddress, and both address rules now live in validate_config: no configured contract address may be zero, and no two contracts may share an address. Since the zero check no longer sits in the log scraping state, setting a contract address became infallible and LogScrapingStateError could go away.

Finally, the address is surfaced in get_minter_info and in the Metadata section of the minter dashboard, so it can be inspected like the minter address and the helper contracts. The dashboard row is omitted when no sweeper contract is configured.

Note: the distinctness rule is a new constraint on existing configurations. Mainnet's three helper contracts are distinct, so nothing currently deployed trips it.

🤖 Generated with Claude Code

gregorydemay and others added 3 commits August 14, 2026 13:42
Add an optional `ethereum_sweeper_contract_address` field to the ckETH
minter's `InitArg` and `UpgradeArg`, holding the address of the sweeper
smart contract deployed on Ethereum. The address is parsed into the
minter's state at install time and can be changed on upgrade, mirroring
how `ethereum_contract_address` is handled. Nothing consumes it yet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Collapse the per-contract `InvalidStateError` variants into a single
`InvalidContractAddress`, and move both address rules into
`validate_config`: no configured contract address may be zero, and no
two contracts may share an address.

Since the zero check no longer lives in the log scraping state, setting
a contract address becomes infallible and `LogScrapingStateError` goes
away, removing the error mapping at every call site.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Surface the configured sweeper smart contract address in the
`get_minter_info` endpoint and in the Metadata section of the minter
dashboard, so it can be inspected the same way as the minter address and
the deposit helper contracts. The dashboard row is omitted when no
sweeper contract is configured.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gregorydemay
gregorydemay requested a lite review from Copilot August 14, 2026 12:08
@github-actions github-actions Bot added the feat label Aug 14, 2026
@gregorydemay
gregorydemay marked this pull request as ready for review August 14, 2026 12:09
@gregorydemay
gregorydemay requested a review from a team as a code owner August 14, 2026 12:09
@github-actions github-actions Bot added the @defi label Aug 14, 2026
@zeropath-ai

zeropath-ai Bot commented Aug 14, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 88530b6.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/ethereum/cketh/minter/src/dashboard.rs
    Add sweeper_contract_address field to DashboardTemplate
Enhancement ► rs/ethereum/cketh/minter/src/dashboard.rs
    Include sweeper_contract_address in DashboardTemplate state rendering
Enhancement ► rs/ethereum/cketh/minter/src/dashboard/tests.rs
    Add tests for sweeper_contract_address in dashboard state
Enhancement ► rs/ethereum/cketh/minter/src/endpoints.rs
    Add sweeper_contract_address to MinterInfo
Enhancement ► rs/ethereum/cketh/minter/src/eth_logs/tests.rs
    Adjust test state to include sweeper_contract_address where applicable
Enhancement ► rs/ethereum/cketh/minter/src/lifecycle/init.rs
    Introduce ethereum_sweeper_contract_address in InitArg and State construction
Enhancement ► rs/ethereum/cketh/minter/src/lifecycle/init.rs
    Validate sweeper_contract_address during InitArg -> State conversion
Enhancement ► rs/ethereum/cketh/minter/src/lifecycle/upgrade.rs
    Add ethereum_sweeper_contract_address to UpgradeArg
Enhancement ► rs/ethereum/cketh/minter/src/state.rs
    Add sweeper_contract_address: Option to State
Enhancement ► rs/ethereum/cketh/minter/src/state.rs
    Update state validation to include sweeper_contract_address and uniqueness checks
Enhancement ► rs/ethereum/cketh/minter/templates/dashboard.html
    Render Sweeper contract address row when present
Enhancement ► rs/ethereum/cketh/minter/tests/ckerc20.rs
    Update test fixture to include sweeper_contract_address field
Enhancement ► rs/ethereum/cketh/minter/tests/cketh.rs
    Include sweeper_contract_address in minter info expectations
Enhancement ► rs/ethereum/cketh/minter/tests/cketh.rs
    Add test for retrieving sweeper contract address after upgrade
Enhancement ► rs/ethereum/cketh/minter/tests/ckerc20.rs
    Update should_retrieve_minter_info to include sweeper_contract_address
Enhancement ► rs/ethereum/cketh/minter/src/test_fixtures.rs
    Set valid_init_arg to include default sweeper_contract_address
Enhancement ► rs/ethereum/cketh/minter/src/main.rs
    Expose sweeper_contract_address in get_minter_info
Enhancement ► rs/ethereum/cketh/minter/src/state.rs
    Adjust is_equivalent_to to consider sweeper_contract_address
Enhancement ► rs/ethereum/cketh/minter/src/state/eth_logs_scraping/mod.rs
    Relax set_contract_address signature to match new usage
Enhancement ► rs/ethereum/cketh/minter/src/state/eth_logs_scraping/mod.rs
    Remove deprecated LogScrapingStateError and related error handling for addresses
Enhancement ► rs/tests/cross_chain/ic_xc_cketh_test.rs
    Add sweeper_contract_address to minter_init_args fixture

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

This PR extends the ckETH minter’s configuration plumbing to support an optional Ethereum sweeper contract address, exposes it via the public get_minter_info endpoint and the minter dashboard, and centralizes contract-address validation.

Changes:

  • Add ethereum_sweeper_contract_address to init/upgrade args and persist it in State as sweeper_contract_address.
  • Consolidate contract-address validation into State::validate_config (non-zero + all configured contract addresses must be distinct) and simplify error variants.
  • Surface the sweeper address in MinterInfo and the dashboard UI (row omitted when unset), updating tests/utilities accordingly.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rs/tests/cross_chain/ic_xc_cketh_test.rs Extend test init args with the new optional sweeper address field.
rs/ethereum/cketh/test_utils/src/live_scan.rs Provide the new init field when installing the minter in live-scan utilities.
rs/ethereum/cketh/test_utils/src/lib.rs Provide the new init field when installing the minter in test utilities.
rs/ethereum/cketh/minter/tests/cketh.rs Update MinterInfo expectations and add upgrade test for sweeper address.
rs/ethereum/cketh/minter/tests/ckerc20.rs Update MinterInfo expectations to include sweeper field.
rs/ethereum/cketh/minter/templates/dashboard.html Conditionally render a “Sweeper contract address” metadata row.
rs/ethereum/cketh/minter/src/test_fixtures.rs Add default ethereum_sweeper_contract_address: None in fixtures.
rs/ethereum/cketh/minter/src/state/tests.rs Add validation/state-equivalence coverage for sweeper + unified invalid address errors.
rs/ethereum/cketh/minter/src/state/eth_logs_scraping/tests.rs Update tests for infallible set_contract_address.
rs/ethereum/cketh/minter/src/state/eth_logs_scraping/mod.rs Make set_contract_address infallible and remove LogScrapingStateError.
rs/ethereum/cketh/minter/src/state.rs Add sweeper_contract_address to state, unify invalid address error, and enforce distinctness/zero checks in validate_config.
rs/ethereum/cketh/minter/src/main.rs Include sweeper address in get_minter_info output.
rs/ethereum/cketh/minter/src/lifecycle/upgrade.rs Add ethereum_sweeper_contract_address to upgrade args (CBOR field 10).
rs/ethereum/cketh/minter/src/lifecycle/tests.rs Add init validation/success coverage for sweeper address and unified error variant.
rs/ethereum/cketh/minter/src/lifecycle/init.rs Parse/store sweeper address during init and rely on validate_config for invariants.
rs/ethereum/cketh/minter/src/eth_logs/tests.rs Update tests for infallible set_contract_address.
rs/ethereum/cketh/minter/src/endpoints.rs Add sweeper_contract_address field to MinterInfo.
rs/ethereum/cketh/minter/src/dashboard/tests.rs Assert dashboard omits row when unset and renders row when set.
rs/ethereum/cketh/minter/src/dashboard.rs Add sweeper address to dashboard template context from state.
rs/ethereum/cketh/minter/cketh_minter.did Update Candid interface to include sweeper address in init/upgrade args and MinterInfo.

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

Comment on lines +560 to 564
let address = Address::from_str(&address)
.map_err(|e| InvalidStateError::InvalidContractAddress(format!("ERROR: {e}")))?;
self.sweeper_contract_address = Some(address);
}
self.validate_config()
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.

2 participants