Skip to content

chore: migrate rust/evm_block_explorer to icp-cli - #1435

Merged
marc0olo merged 10 commits into
masterfrom
chore/migrate-rust-evm-block-explorer-to-icp-cli
Jul 9, 2026
Merged

marc0olo merged 10 commits into
masterfrom
chore/migrate-rust-evm-block-explorer-to-icp-cli

Conversation

@marc0olo

@marc0olo marc0olo commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Deleted: dfx.json, BUILD.md, .devcontainer/ (dfx artifacts)
  • icp.yaml: @dfinity/rust@v3.3.0, @dfinity/asset-canister@v2.2.1; pre-built evm_rpc canister at v2.8.0 with nodesInSubnet = 28; environments block with local (deploys all three canisters) and ic (deploys only backend + frontend, injects PUBLIC_CANISTER_ID:evm_rpc = 7hfb6-caaaa-aaaar-qadga-cai)
  • Backend rewrite: replaced evm-rpc-canister-types + raw ic0 syscalls with evm_rpc_client 0.4.0 + evm_rpc_types 3.1.1 (builder pattern); ic_cdk::api::env_var_value for runtime canister ID resolution; get_evm_block now returns Result<Block, String> instead of panicking; uses EthMainnetService::PublicNode by default (no API key required)
  • Dropped signing functions: get_ecdsa_public_key, get_schnorr_public_key, sign_message_with_ecdsa, sign_message_with_schnorr — isolated primitives with no EVM context; refer to basic_ethereum for the full signing + submission flow
  • Moved backend/lib.rs → backend/src/lib.rs; updated Cargo.toml to edition = "2024", ic-cdk = "0.20"; removed hex, sha2, ic-cdk-management-canister (no longer needed)
  • Frontend: rewrote vite.config.js and actor.js to icp-cli only (no dfx fallback); removed ECDSASigning and SchnorrSigning components; Block.jsx handles the Result variant and requires a valid block number before enabling the fetch button
  • test.sh: fetches Ethereum mainnet block 1 and asserts its deterministic hash and miner address
  • CI workflow: rust-evm_block_explorer job using ghcr.io/dfinity/icp-dev-env-rust:1.0.1

Test plan

  • icp network start -d && icp deploy && bash test.sh passes locally
  • Frontend builds and block fetch works: npm run dev --prefix frontend
  • icp deploy -e ic deploys only backend + frontend on ICP mainnet

🤖 Generated with Claude Code

marc0olo and others added 10 commits July 9, 2026 14:55
- Delete dfx.json, BUILD.md, .devcontainer/ (dfx artifacts)
- Rewrite icp.yaml: rust@v3.3.0, asset-canister@v2.2.1, evm_rpc pre-built
  at v2.8.0; add environments block so production sets
  PUBLIC_CANISTER_ID:evm_rpc to the shared mainnet canister
- Update backend/Cargo.toml: edition 2024, ic-cdk 0.20, replace
  evm-rpc-canister-types + ic0 with evm_rpc_client 0.4.0,
  evm_rpc_types 3.1.1, ic-canister-runtime 0.2.0, and
  ic-cdk-management-canister 0.1.1 for ECDSA/Schnorr APIs
- Move backend/lib.rs → backend/src/lib.rs; update to new API:
  EvmRpcClient builder pattern for get_evm_block, ic_cdk::api::env_var_value
  for runtime canister ID resolution, ic-cdk-management-canister types
  for ECDSA/Schnorr (EcdsaPublicKeyArgs, SignWithEcdsaArgs, etc.)
- Rewrite frontend/vite.config.js: icp-cli only (no dfx fallback),
  uses icp network status for proxy target and root key
- Rewrite frontend/src/actor.js: icp-cli only via safeGetCanisterEnv()
- Add test.sh covering ECDSA/Schnorr public key and signing endpoints
- Add .github/workflows/evm_block_explorer.yml CI workflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…m ic deploy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…om get_evm_block

Using only Llama caused 521 failures when that provider is down. Now uses
Llama + Cloudflare + PublicNode for redundancy. Changed return type to
Result<Block, String> so provider errors surface as a Candid Err variant
instead of an IC trap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…0 default

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sistent

When some providers are down and others succeed, MultiRpcResult::Inconsistent
previously caused an error. Now falls back to the first successful response
so transient provider outages don't block the request entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ance

- Use only PublicNode (no API key, reliable) instead of multiple providers
  with unreliable Llama/Cloudflare; comment explains how to switch to
  RpcServices::EthMainnet(None) for production consensus
- icp.yaml: add nodesInSubnet=28 to validate cycle costs locally, restore
  local environment entry, add explanatory comments matching basic_ethereum
- README: fix deploy command (ic environment, not production), add RPC
  providers section documenting the PublicNode default and production upgrade path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t, clean workflow

- Restore '// Use "key_1" for production' comment on KEY_NAME (present in the
  original, carries important production guidance)
- Add test 5: fetch Ethereum mainnet block 1 and assert its deterministic hash
  and miner address (both are immutable historical facts)
- Remove redundant npm install step from workflow — icp deploy already runs
  the build steps defined in icp.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ning panels

ECDSASigning and SchnorrSigning both declared function Block() internally
and had an error state that was set but never rendered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ck data

The ECDSA/Schnorr signing functions were isolated primitives with no
connection to EVM concepts — no address derivation, no transaction
construction. Developers wanting signing + EVM interaction should use
basic_ethereum instead.

Removes: get_ecdsa_public_key, get_schnorr_public_key,
sign_message_with_ecdsa, sign_message_with_schnorr from backend and DID;
ECDSASigning and SchnorrSigning components; hex, sha2,
ic-cdk-management-canister dependencies; signing tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Migrates the rust/evm_block_explorer example from dfx artifacts to the canonical icp-cli workflow, modernizing the Rust backend to use evm_rpc_client and updating the frontend/dev tooling accordingly.

Changes:

  • Replaced legacy dfx/ic0-syscall based backend logic with evm_rpc_client + runtime canister ID resolution via ic_cdk::api::env_var_value, and changed the API to return Result<Block, String>.
  • Updated project configuration for icp-cli (icp.yaml + new CI workflow) including local-only deployment of a pre-built evm_rpc canister and an ic environment mapping to the shared mainnet EVM RPC canister.
  • Simplified the frontend to focus on block fetching (removed signing UI) and aligned dev server configuration with the established ic_env cookie pattern used in other examples.

Reviewed changes

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

Show a summary per file
File Description
rust/evm_block_explorer/test.sh Adds a deterministic end-to-end CLI test asserting block-1 hash/miner via get_evm_block.
rust/evm_block_explorer/README.md Updates docs for icp-cli, mainnet deployment mode, and RPC provider guidance; refreshes security link.
rust/evm_block_explorer/icp.yaml Switches to updated recipes, adds local pre-built evm_rpc, and introduces local/ic environments with env var injection.
rust/evm_block_explorer/frontend/vite.config.js Removes dfx fallback and uses the standard ic_env cookie + icp network status proxy setup for dev.
rust/evm_block_explorer/frontend/src/main.jsx Removes signing components from the rendered UI.
rust/evm_block_explorer/frontend/src/Block.jsx Handles Result return type and disables fetch until the block number is valid.
rust/evm_block_explorer/frontend/src/actor.js Removes dfx env-var fallback; relies on ic_env cookie (consistent with rust/hello_world).
rust/evm_block_explorer/backend/src/lib.rs New backend implementation using evm_rpc_client and returning Result instead of panicking.
rust/evm_block_explorer/backend/Cargo.toml Updates edition/dependencies and aligns crate layout with src/lib.rs.
rust/evm_block_explorer/backend/backend.did Updates the public interface to only expose get_evm_block returning a Result.
rust/evm_block_explorer/frontend/src/ECDSASigning.jsx Removes signing UI component (dropped backend signing APIs).
rust/evm_block_explorer/frontend/src/SchnorrSigning.jsx Removes signing UI component (dropped backend signing APIs).
rust/evm_block_explorer/dfx.json Deletes legacy dfx project config.
rust/evm_block_explorer/BUILD.md Deletes ICP Ninja follow-up instructions tied to removed dfx artifacts.
rust/evm_block_explorer/.devcontainer/devcontainer.json Deletes per-example devcontainer (repo uses the root devcontainer).
.github/workflows/evm_block_explorer.yml Adds CI workflow using the pinned Rust dev-env container and icp network start/deploy/test.sh.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marc0olo
marc0olo marked this pull request as ready for review July 9, 2026 15:10
@marc0olo
marc0olo requested review from a team as code owners July 9, 2026 15:10
@marc0olo
marc0olo merged commit d624165 into master Jul 9, 2026
7 checks passed
@marc0olo
marc0olo deleted the chore/migrate-rust-evm-block-explorer-to-icp-cli branch July 9, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants