Skip to content

Commit 24c5c2a

Browse files
gregorydemayclaudeIDX GitHub Automation
authored
test: end-to-end deposit-from-CEX EIP-7702 sweep demo against a local Ethereum node (#10670)
A hermetic, monorepo-native integration test that validates the "deposit from CEX" sweep (design in `rs/ethereum/cketh/docs/deposit_from_cex.md`) end-to-end against a local `anvil` node, through the minter's productive EIP-7702 transaction layer (#10671). It sweeps unfunded deposit addresses to the minter in minter-paid EIP-7702 transactions, checks each emits the canonical deposit event with the right IC principal, measures gas across batch sizes (1/10/20), and covers both sweeper designs — caller-gated and permissionless-with-minter-attestation — including rejection of unauthorized sweeps. foundry and solc are vendored via Bazel (no docker, IC replica, or alloy). --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>
1 parent dc7e68f commit 24c5c2a

9 files changed

Lines changed: 1617 additions & 1 deletion

File tree

BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,30 @@ alias(
100100
}),
101101
)
102102

103+
### foundry (anvil) & solc, used by //rs/ethereum/cketh/minter:deposit_from_cex_demo_test
104+
105+
alias(
106+
name = "anvil",
107+
actual = select({
108+
"@bazel_tools//src/conditions:darwin_arm64": "@foundry_bin_darwin_arm64//:anvil",
109+
"@bazel_tools//src/conditions:darwin_x86_64": "@foundry_bin_darwin_amd64//:anvil",
110+
"@bazel_tools//src/conditions:linux_aarch64": "@foundry_bin_linux_arm64//:anvil",
111+
"@bazel_tools//src/conditions:linux_x86_64": "@foundry_bin_linux_amd64//:anvil",
112+
}),
113+
)
114+
115+
# The macOS solc download is a universal (x86_64 + arm64) binary, so it serves
116+
# both Intel and Apple Silicon Macs natively.
117+
alias(
118+
name = "solc",
119+
actual = select({
120+
"@bazel_tools//src/conditions:darwin_arm64": "@solc_0_8_35_macosx_amd64//file",
121+
"@bazel_tools//src/conditions:darwin_x86_64": "@solc_0_8_35_macosx_amd64//file",
122+
"@bazel_tools//src/conditions:linux_aarch64": "@solc_0_8_35_linux_arm64//file",
123+
"@bazel_tools//src/conditions:linux_x86_64": "@solc_0_8_35_linux_amd64//file",
124+
}),
125+
)
126+
103127
genrule(
104128
name = "dogecoind_stub",
105129
outs = ["dogecoind_stub.txt"],

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MODULE.bazel

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,71 @@ http_file(
442442
url = "https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.8.18+commit.87f61d96",
443443
)
444444

445+
# Latest stable solc, used by //rs/ethereum/cketh/minter:deposit_from_cex_demo_test
446+
# to compile the demo contracts (pinned exactly for reproducible bytecode/gas).
447+
# One binary per host platform; the consuming target selects the right one.
448+
# The macosx-amd64 download is a universal (x86_64 + arm64) Mach-O, so it runs
449+
# natively on both Intel and Apple Silicon Macs.
450+
http_file(
451+
name = "solc_0_8_35_linux_amd64",
452+
downloaded_file_path = "solc",
453+
executable = True,
454+
sha256 = "fa8ac9a32d301ad023a36ee5a29f8e291fe3200c60244e43c142539e82a617f4",
455+
url = "https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.8.35+commit.47b9dedd",
456+
)
457+
458+
http_file(
459+
name = "solc_0_8_35_linux_arm64",
460+
downloaded_file_path = "solc",
461+
executable = True,
462+
sha256 = "4218d2936d2b582bc5751dac548f97b36a8652b21ded52b60a1c1259143ee0e4",
463+
url = "https://binaries.soliditylang.org/linux-arm64/solc-linux-arm64-v0.8.35+commit.47b9dedd",
464+
)
465+
466+
http_file(
467+
name = "solc_0_8_35_macosx_amd64",
468+
downloaded_file_path = "solc",
469+
executable = True,
470+
sha256 = "6e432580d973cae74c869ef4f737529e73fec5b200dce3c08d5e76c4a6b19159",
471+
url = "https://binaries.soliditylang.org/macosx-amd64/solc-macosx-amd64-v0.8.35+commit.47b9dedd",
472+
)
473+
474+
# foundry release binaries (anvil/cast/forge/chisel) used to run a local
475+
# EIP-7702-capable Ethereum node hermetically from a rust_test, without docker.
476+
# This release (>= v1.0) supports EIP-7702, unlike the v0.3.0 `@foundry` oci
477+
# image used by //rs/tests/cross_chain:ic_xc_cketh_test. One archive per host
478+
# platform; the consuming target selects the right one (see
479+
# //rs/ethereum/cketh/deposit_from_cex_demo:BUILD.bazel).
480+
FOUNDRY_BUILD_FILE = 'exports_files(["anvil", "cast", "forge", "chisel"])'
481+
482+
http_archive(
483+
name = "foundry_bin_linux_amd64",
484+
build_file_content = FOUNDRY_BUILD_FILE,
485+
sha256 = "cf7e688ed0c4c48adffca788b496076e31060b67ac5afe1e43dbb5499c20c88b",
486+
url = "https://github.com/foundry-rs/foundry/releases/download/v1.7.1/foundry_v1.7.1_linux_amd64.tar.gz",
487+
)
488+
489+
http_archive(
490+
name = "foundry_bin_linux_arm64",
491+
build_file_content = FOUNDRY_BUILD_FILE,
492+
sha256 = "c8fe8fa09ae3aba2c81b510c6f9da3a9d468029b9580e690b245b3f0aea687ae",
493+
url = "https://github.com/foundry-rs/foundry/releases/download/v1.7.1/foundry_v1.7.1_linux_arm64.tar.gz",
494+
)
495+
496+
http_archive(
497+
name = "foundry_bin_darwin_amd64",
498+
build_file_content = FOUNDRY_BUILD_FILE,
499+
sha256 = "c7fd1f5c9bf718d30b5cb6fc94eac605039de2aa50afc4c545a4dddc1e411acb",
500+
url = "https://github.com/foundry-rs/foundry/releases/download/v1.7.1/foundry_v1.7.1_darwin_amd64.tar.gz",
501+
)
502+
503+
http_archive(
504+
name = "foundry_bin_darwin_arm64",
505+
build_file_content = FOUNDRY_BUILD_FILE,
506+
sha256 = "eacdc67718fac857cad9e19c7f6729dd80de731d09df81856391d093cfcab547",
507+
url = "https://github.com/foundry-rs/foundry/releases/download/v1.7.1/foundry_v1.7.1_darwin_arm64.tar.gz",
508+
)
509+
445510
# Bitcoin Adapter Mainnet Data for Integration Test
446511

447512
# The files have been generated by syncing bitcoind client, followed

rs/ethereum/cketh/minter/BUILD.bazel

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,11 @@ rust_ic_test_suite(
200200
timeout = "long",
201201
srcs = glob(
202202
["tests/**/*.rs"],
203-
exclude = ["tests/dump_stable_memory.rs"],
203+
exclude = [
204+
"tests/dump_stable_memory.rs",
205+
# Runs against a local foundry anvil node, not the IC test suite.
206+
"tests/deposit_from_cex_demo.rs",
207+
],
204208
),
205209
data = [
206210
":cketh_minter_debug.wasm.gz",
@@ -243,6 +247,43 @@ rust_ic_test_suite(
243247
],
244248
)
245249

250+
rust_test(
251+
name = "deposit_from_cex_demo_test",
252+
size = "small",
253+
srcs = ["tests/deposit_from_cex_demo.rs"],
254+
data = [
255+
"//:anvil",
256+
"//:solc",
257+
# Contract sources compiled at test time by the vendored solc.
258+
"DepositHelperWithSubaccount.sol",
259+
"tests/deposit_from_cex_demo/CkSweeperAttested.sol",
260+
"tests/deposit_from_cex_demo/CkSweeperViaHelper.sol",
261+
"tests/deposit_from_cex_demo/MockUSDT.sol",
262+
],
263+
edition = "2021",
264+
env = {
265+
"ANVIL_BIN": "$(rootpath //:anvil)",
266+
"CKDEPOSIT_SOL": "$(rootpath DepositHelperWithSubaccount.sol)",
267+
"CKSWEEPER_ATTESTED_SOL": "$(rootpath tests/deposit_from_cex_demo/CkSweeperAttested.sol)",
268+
"CKSWEEPER_VIA_HELPER_SOL": "$(rootpath tests/deposit_from_cex_demo/CkSweeperViaHelper.sol)",
269+
"MOCKUSDT_SOL": "$(rootpath tests/deposit_from_cex_demo/MockUSDT.sol)",
270+
"SOLC_BIN": "$(rootpath //:solc)",
271+
},
272+
deps = [
273+
# Keep sorted.
274+
":minter",
275+
"//packages/ic-ethereum-types",
276+
"//packages/ic-secp256k1",
277+
"@crate_index//:candid",
278+
"@crate_index//:ethers-core",
279+
"@crate_index//:ethnum",
280+
"@crate_index//:hex",
281+
"@crate_index//:ic-sha3",
282+
"@crate_index//:reqwest",
283+
"@crate_index//:serde_json",
284+
],
285+
)
286+
246287
rust_binary(
247288
name = "cketh_minter_dump_stable_memory",
248289
testonly = True,

rs/ethereum/cketh/minter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ ic-state-machine-tests = { path = "../../../state_machine_tests" }
7070
maplit = "1"
7171
proptest = { workspace = true }
7272
rand = { workspace = true }
73+
reqwest = { workspace = true }
7374
scraper = "0.17.1"
7475
tempfile = { workspace = true }
7576
tokio = { workspace = true }

0 commit comments

Comments
 (0)