feat(cketh): configure and expose the sweeper contract address - #11145
Open
gregorydemay wants to merge 3 commits into
Open
feat(cketh): configure and expose the sweeper contract address#11145gregorydemay wants to merge 3 commits into
gregorydemay wants to merge 3 commits into
Conversation
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>
|
✅ No security or compliance issues detected. Reviewed everything up to 88530b6. Security Overview
Detected Code Changes
|
Contributor
There was a problem hiding this comment.
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_addressto init/upgrade args and persist it inStateassweeper_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
MinterInfoand 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
ethereum_sweeper_contract_addressfield 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
InvalidStateErrorvariants collapse into a singleInvalidContractAddress, and both address rules now live invalidate_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 andLogScrapingStateErrorcould go away.Finally, the address is surfaced in
get_minter_infoand 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