From 2cfa22c7b941f58af44d1ab4b34562c703e39a91 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Mon, 22 Sep 2025 16:43:01 +0200 Subject: [PATCH 1/2] fix: use sourcify for selector lookups --- Cargo.lock | 215 ++++++++++-------- crates/cast/src/opts.rs | 18 +- crates/cast/tests/cli/selectors.rs | 6 +- crates/common/src/selectors.rs | 102 ++++----- .../evm/traces/src/identifier/signatures.rs | 12 +- crates/forge/tests/cli/test_cmd.rs | 6 +- 6 files changed, 192 insertions(+), 167 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb9157a4d6025..beb4c89fbabff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,7 +91,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -128,7 +128,7 @@ dependencies = [ "futures", "futures-util", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -160,7 +160,7 @@ dependencies = [ "alloy-rlp", "crc", "serde", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -196,7 +196,7 @@ dependencies = [ "alloy-rlp", "k256", "serde", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -218,7 +218,7 @@ dependencies = [ "serde", "serde_with", "sha2 0.10.9", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -232,7 +232,7 @@ dependencies = [ "alloy-provider", "alloy-sol-types", "async-trait", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -252,7 +252,7 @@ dependencies = [ "op-alloy-consensus", "op-revm", "revm", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -304,7 +304,7 @@ dependencies = [ "http 1.3.1", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -331,7 +331,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -444,7 +444,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "url", @@ -572,7 +572,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -623,7 +623,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -637,7 +637,7 @@ dependencies = [ "alloy-serde", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -677,7 +677,7 @@ dependencies = [ "either", "elliptic-curve", "k256", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -695,7 +695,7 @@ dependencies = [ "aws-sdk-kms", "k256", "spki", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -713,7 +713,7 @@ dependencies = [ "gcloud-sdk", "k256", "spki", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -733,7 +733,7 @@ dependencies = [ "coins-ledger", "futures-util", "semver 1.0.27", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -753,7 +753,7 @@ dependencies = [ "eth-keystore", "k256", "rand 0.8.5", - "thiserror 2.0.16", + "thiserror 2.0.17", "zeroize", ] @@ -769,7 +769,7 @@ dependencies = [ "alloy-signer", "async-trait", "semver 1.0.27", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "trezor-client", ] @@ -863,7 +863,7 @@ dependencies = [ "parking_lot", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tower", "tracing", @@ -919,7 +919,7 @@ dependencies = [ "rustls", "serde_json", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.26.2", "tracing", "ws_stream_wasm", ] @@ -1013,9 +1013,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" [[package]] name = "anstyle-lossy" @@ -1128,7 +1128,7 @@ dependencies = [ "serde", "serde_json", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "tracing-subscriber 0.3.20", @@ -1157,7 +1157,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -1183,7 +1183,7 @@ dependencies = [ "pin-project 1.1.10", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio-util", "tower-http", "tracing", @@ -2005,9 +2005,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" +checksum = "98e529aee37b5c8206bb4bf4c44797127566d72f76952c970bd3d1e85de8f4e2" dependencies = [ "axum-core", "base64 0.22.1", @@ -2025,15 +2025,14 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rustversion", - "serde", + "serde_core", "serde_json", "serde_path_to_error", "serde_urlencoded", "sha1", "sync_wrapper", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.28.0", "tower", "tower-layer", "tower-service", @@ -2042,9 +2041,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" +checksum = "0ac7a6beb1182c7e30253ee75c3e918080bfb83f5a3023bcdf7209d85fd147e6" dependencies = [ "bytes", "futures-core", @@ -2053,7 +2052,6 @@ dependencies = [ "http-body-util", "mime", "pin-project-lite", - "rustversion", "sync_wrapper", "tower-layer", "tower-service", @@ -2292,7 +2290,7 @@ dependencies = [ "static_assertions", "tap", "thin-vec", - "thiserror 2.0.16", + "thiserror 2.0.17", "time", ] @@ -2501,9 +2499,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1de8bc0aa9e9385ceb3bf0c152e3a9b9544f6c4a912c8ae504e80c1f0368603" +checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609" dependencies = [ "serde_core", ] @@ -2821,7 +2819,7 @@ checksum = "85a8ab73a1c02b0c15597b22e09c7dc36e63b2f601f9d1e83ac0c3decd38b1ae" dependencies = [ "nix 0.29.0", "terminfo", - "thiserror 2.0.16", + "thiserror 2.0.17", "which", "windows-sys 0.59.0", ] @@ -2943,7 +2941,7 @@ dependencies = [ "eyre", "indenter", "once_cell", - "owo-colors 4.2.2", + "owo-colors 4.2.3", "tracing-error", ] @@ -2954,7 +2952,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427" dependencies = [ "once_cell", - "owo-colors 4.2.2", + "owo-colors 4.2.3", "tracing-core", "tracing-error", ] @@ -4107,7 +4105,7 @@ dependencies = [ "strum 0.27.2", "svm-rs", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "toml_edit 0.23.6", "tower-http", @@ -4137,7 +4135,7 @@ dependencies = [ "serde", "serde_json", "solar-compiler", - "thiserror 2.0.16", + "thiserror 2.0.17", "toml 0.9.7", "tracing", ] @@ -4169,7 +4167,7 @@ dependencies = [ "heck", "rayon", "solar-compiler", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -4324,7 +4322,7 @@ dependencies = [ "semver 1.0.27", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -4373,7 +4371,7 @@ dependencies = [ "semver 1.0.27", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "toml 0.9.7", "tracing", "walkdir", @@ -4483,7 +4481,7 @@ dependencies = [ "serde", "serde_json", "solar-compiler", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tower", "tracing", @@ -4539,7 +4537,7 @@ dependencies = [ "svm-rs", "svm-rs-builds", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "winnow", "yansi", @@ -4571,7 +4569,7 @@ dependencies = [ "semver 1.0.27", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "yansi", ] @@ -4608,7 +4606,7 @@ dependencies = [ "serde_json", "svm-rs", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "walkdir", "xxhash-rust", @@ -4646,7 +4644,7 @@ dependencies = [ "solar-compiler", "soldeer-core", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", "toml 0.9.7", "toml_edit 0.23.6", "tracing", @@ -4699,7 +4697,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "uuid 1.18.1", ] @@ -4750,7 +4748,7 @@ dependencies = [ "revm-inspectors", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "url", @@ -4792,7 +4790,7 @@ dependencies = [ "rand 0.9.2", "revm", "serde", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", ] @@ -4856,7 +4854,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "url", @@ -4870,7 +4868,7 @@ dependencies = [ "foundry-compilers", "rayon", "semver 1.0.27", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -4893,7 +4891,7 @@ dependencies = [ "lalrpop", "lalrpop-util", "phf", - "thiserror 2.0.16", + "thiserror 2.0.17", "unicode-xid", ] @@ -4948,7 +4946,7 @@ dependencies = [ "foundry-config", "rpassword", "serde", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", ] @@ -5253,7 +5251,7 @@ dependencies = [ "pest_derive", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -6841,9 +6839,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nybbles" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa11e84403164a9f12982ab728f3c67c6fd4ab5b5f0254ffc217bdbd3b28ab0" +checksum = "2c4b5ecbd0beec843101bffe848217f770e8b8da81d8355b7d6e226f2199b3dc" dependencies = [ "alloy-rlp", "cfg-if", @@ -6901,7 +6899,7 @@ dependencies = [ "alloy-serde", "derive_more", "serde", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -6926,7 +6924,7 @@ dependencies = [ "op-alloy-consensus", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -6983,9 +6981,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "owo-colors" -version = "4.2.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" +checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" [[package]] name = "p256" @@ -7151,7 +7149,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21e0a3a33733faeaf8651dfee72dd0f388f0c8e5ad496a3478fa5a922f49cfa8" dependencies = [ "memchr", - "thiserror 2.0.16", + "thiserror 2.0.17", "ucd-trie", ] @@ -7654,7 +7652,7 @@ dependencies = [ "newtype-uuid", "quick-xml 0.37.5", "strip-ansi-escapes", - "thiserror 2.0.16", + "thiserror 2.0.17", "uuid 1.18.1", ] @@ -7690,7 +7688,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2 0.6.0", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "web-time", @@ -7711,7 +7709,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.16", + "thiserror 2.0.17", "tinyvec", "tracing", "web-time", @@ -7733,9 +7731,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -7897,23 +7895,23 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] name = "ref-cast" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", @@ -8158,7 +8156,7 @@ dependencies = [ "revm", "serde", "serde_json", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -8232,7 +8230,7 @@ dependencies = [ "nix 0.30.1", "regex", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -8712,9 +8710,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.5.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc198e42d9b7510827939c9a15f5062a0c913f3371d765977e586d2fe6c16f4a" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ "bitflags 2.9.4", "core-foundation 0.10.1", @@ -9064,7 +9062,7 @@ checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" dependencies = [ "num-bigint", "num-traits", - "thiserror 2.0.16", + "thiserror 2.0.17", "time", ] @@ -9222,7 +9220,7 @@ dependencies = [ "solar-config", "solar-data-structures", "solar-macros", - "thiserror 2.0.16", + "thiserror 2.0.17", "tracing", "unicode-width 0.2.0", ] @@ -9329,7 +9327,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.9", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "toml_edit 0.23.6", "uuid 1.18.1", @@ -9563,7 +9561,7 @@ dependencies = [ "serde_json", "sha2 0.10.9", "tempfile", - "thiserror 2.0.16", + "thiserror 2.0.17", "url", "zip", ] @@ -9750,11 +9748,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl 2.0.16", + "thiserror-impl 2.0.17", ] [[package]] @@ -9770,9 +9768,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", @@ -9950,10 +9948,22 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls", - "tungstenite", + "tungstenite 0.26.2", "webpki-roots 0.26.11", ] +[[package]] +name = "tokio-tungstenite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25a406cddcc431a75d3d9afc6a7c0f7428d4891dd973e4d54c56b46127bf857" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.28.0", +] + [[package]] name = "tokio-util" version = "0.7.16" @@ -10328,7 +10338,24 @@ dependencies = [ "rustls", "rustls-pki-types", "sha1", - "thiserror 2.0.16", + "thiserror 2.0.17", + "utf-8", +] + +[[package]] +name = "tungstenite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8628dcc84e5a09eb3d8423d6cb682965dea9133204e8fb3efee74c2a0c259442" +dependencies = [ + "bytes", + "data-encoding", + "http 1.3.1", + "httparse", + "log", + "rand 0.9.2", + "sha1", + "thiserror 2.0.17", "utf-8", ] @@ -10803,7 +10830,7 @@ dependencies = [ "miette", "normalize-path", "notify", - "thiserror 2.0.16", + "thiserror 2.0.17", "tokio", "tracing", "watchexec-events", @@ -10829,7 +10856,7 @@ checksum = "377729679262964c27e6a28f360a84b7aedb172b59841301c1c77922305dfd83" dependencies = [ "miette", "nix 0.30.1", - "thiserror 2.0.16", + "thiserror 2.0.17", ] [[package]] @@ -11314,7 +11341,7 @@ dependencies = [ "pharos", "rustc_version 0.4.1", "send_wrapper", - "thiserror 2.0.16", + "thiserror 2.0.17", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -11478,7 +11505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fa5b9958fd0b5b685af54f2c3fa21fca05fe295ebaf3e77b6d24d96c4174037" dependencies = [ "log", - "thiserror 2.0.16", + "thiserror 2.0.17", "zip", ] diff --git a/crates/cast/src/opts.rs b/crates/cast/src/opts.rs index 7da7c6105bf01..f9b50643fa0de 100644 --- a/crates/cast/src/opts.rs +++ b/crates/cast/src/opts.rs @@ -595,7 +595,7 @@ pub enum CastSubcommand { /// Decode event data. #[command(visible_aliases = &["event-decode", "--event-decode", "ed"])] DecodeEvent { - /// The event signature. If none provided then tries to decode from local cache or . + /// The event signature. If none provided then tries to decode from local cache or . #[arg(long, visible_alias = "event-sig")] sig: Option, /// The event data to decode. @@ -605,7 +605,7 @@ pub enum CastSubcommand { /// Decode custom error data. #[command(visible_aliases = &["error-decode", "--error-decode", "erd"])] DecodeError { - /// The error signature. If none provided then tries to decode from local cache or . + /// The error signature. If none provided then tries to decode from local cache or . #[arg(long, visible_alias = "error-sig")] sig: Option, /// The error data to decode. @@ -720,21 +720,21 @@ pub enum CastSubcommand { rpc: RpcOpts, }, - /// Get the function signatures for the given selector from . + /// Get the function signatures for the given selector from . #[command(name = "4byte", visible_aliases = &["4", "4b"])] FourByte { /// The function selector. selector: Option, }, - /// Decode ABI-encoded calldata using . + /// Decode ABI-encoded calldata using . #[command(name = "4byte-calldata", aliases = &["4byte-decode", "4d", "4bd"], visible_aliases = &["4c", "4bc"])] FourByteCalldata { /// The ABI-encoded calldata. calldata: Option, }, - /// Get the event signature for a given topic 0 from . + /// Get the event signature for a given topic 0 from . #[command(name = "4byte-event", visible_aliases = &["4e", "4be", "topic0-event", "t0e"])] FourByteEvent { /// Topic 0 @@ -742,7 +742,7 @@ pub enum CastSubcommand { topic: Option, }, - /// Upload the given signatures to . + /// Upload the given signatures to . /// /// Example inputs: /// - "transfer(address,uint256)" @@ -760,13 +760,13 @@ pub enum CastSubcommand { /// Pretty print calldata. /// - /// Tries to decode the calldata using unless --offline is passed. + /// Tries to decode the calldata using unless --offline is passed. #[command(visible_alias = "pc")] PrettyCalldata { /// The calldata. calldata: Option, - /// Skip the lookup. + /// Skip the lookup. #[arg(long, short)] offline: bool, }, @@ -1126,7 +1126,7 @@ pub enum CastSubcommand { /// The hex-encoded bytecode. bytecode: Option, - /// Resolve the function signatures for the extracted selectors using + /// Resolve the function signatures for the extracted selectors using #[arg(long, short)] resolve: bool, }, diff --git a/crates/cast/tests/cli/selectors.rs b/crates/cast/tests/cli/selectors.rs index cb17abf47d7d9..909f34b6144a1 100644 --- a/crates/cast/tests/cli/selectors.rs +++ b/crates/cast/tests/cli/selectors.rs @@ -1,7 +1,7 @@ use foundry_test_utils::util::OutputExt; use std::path::Path; -casttest!(error_decode_with_openchain, |prj, cmd| { +casttest!(error_decode_with_sourcify, |prj, cmd| { prj.clear_cache(); cmd.args(["decode-error", "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"]).assert_success().stdout_eq(str![[r#" ValueTooHigh(uint256,uint256) @@ -147,8 +147,8 @@ casttest!(event_decode_with_sig, |_prj, cmd| { "#]]); }); -// tests cast can decode event with Openchain API -casttest!(event_decode_with_openchain, |prj, cmd| { +// tests cast can decode event with Sourcify API +casttest!(event_decode_with_sourcify, |prj, cmd| { prj.clear_cache(); cmd.args(["decode-event", "0xe27c4c1372396a3d15a9922f74f9dfc7c72b1ad6d63868470787249c356454c1000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]).assert_success().stdout_eq(str![[r#" BaseCurrencySet(address,uint256) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 3bc41bc41111d..884a733b82299 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -17,9 +17,9 @@ use std::{ time::Duration, }; -const BASE_URL: &str = "https://api.openchain.xyz"; -const SELECTOR_LOOKUP_URL: &str = "https://api.openchain.xyz/signature-database/v1/lookup"; -const SELECTOR_IMPORT_URL: &str = "https://api.openchain.xyz/signature-database/v1/import"; +const BASE_URL: &str = "https://sourcify.dev/server"; +const SELECTOR_LOOKUP_URL: &str = "https://sourcify.dev/server/signature-database/v1/lookup"; +const SELECTOR_IMPORT_URL: &str = "https://sourcify.dev/server/signature-database/v1/import"; /// The standard request timeout for API requests. const REQ_TIMEOUT: Duration = Duration::from_secs(15); @@ -28,11 +28,11 @@ const REQ_TIMEOUT: Duration = Duration::from_secs(15); const MAX_TIMEDOUT_REQ: usize = 4usize; /// List of signatures for a given [`SelectorKind`]. -pub type OpenChainSignatures = Vec; +pub type SourcifySignatures = Vec; -/// A client that can request API data from OpenChain. +/// A client that can request API data from Sourcify. #[derive(Clone, Debug)] -pub struct OpenChainClient { +pub struct SourcifyClient { inner: reqwest::Client, /// Whether the connection is spurious, or API is down spurious_connection: Arc, @@ -42,14 +42,14 @@ pub struct OpenChainClient { max_timedout_requests: usize, } -impl OpenChainClient { +impl SourcifyClient { /// Creates a new client with default settings. pub fn new() -> eyre::Result { let inner = RuntimeTransportBuilder::new(BASE_URL.parse().unwrap()) .with_timeout(REQ_TIMEOUT) .build() .reqwest_client() - .wrap_err("failed to build OpenChain client")?; + .wrap_err("failed to build Sourcify client")?; Ok(Self { inner, spurious_connection: Default::default(), @@ -104,7 +104,7 @@ impl OpenChainClient { } if is_connectivity_err(err) { - warn!("spurious network detected for OpenChain"); + warn!("spurious network detected for Sourcify"); let previous = self.timedout_requests.fetch_add(1, Ordering::SeqCst); if previous >= self.max_timedout_requests { self.set_spurious(); @@ -129,19 +129,19 @@ impl OpenChainClient { Ok(()) } - /// Decodes the given function or event selector using OpenChain + /// Decodes the given function or event selector using Sourcify pub async fn decode_selector( &self, selector: SelectorKind, - ) -> eyre::Result { + ) -> eyre::Result { Ok(self.decode_selectors(&[selector]).await?.pop().unwrap()) } - /// Decodes the given function, error or event selectors using OpenChain. + /// Decodes the given function, error or event selectors using Sourcify. pub async fn decode_selectors( &self, selectors: &[SelectorKind], - ) -> eyre::Result> { + ) -> eyre::Result> { if selectors.is_empty() { return Ok(vec![]); } @@ -176,7 +176,7 @@ impl OpenChainClient { Err(err) => eyre::bail!("could not decode response: {err}: {text}"), }; if !ok { - eyre::bail!("OpenChain returned an error: {text}"); + eyre::bail!("Sourcify returned an error: {text}"); } Ok(selectors @@ -199,16 +199,16 @@ impl OpenChainClient { .collect()) } - /// Fetches a function signature given the selector using OpenChain + /// Fetches a function signature given the selector using Sourcify pub async fn decode_function_selector( &self, selector: Selector, - ) -> eyre::Result { + ) -> eyre::Result { self.decode_selector(SelectorKind::Function(selector)).await } /// Fetches all possible signatures and attempts to abi decode the calldata - pub async fn decode_calldata(&self, calldata: &str) -> eyre::Result { + pub async fn decode_calldata(&self, calldata: &str) -> eyre::Result { let calldata = calldata.strip_prefix("0x").unwrap_or(calldata); if calldata.len() < 8 { eyre::bail!( @@ -223,18 +223,18 @@ impl OpenChainClient { Ok(sigs) } - /// Fetches an event signature given the 32 byte topic using OpenChain. - pub async fn decode_event_topic(&self, topic: B256) -> eyre::Result { + /// Fetches an event signature given the 32 byte topic using Sourcify. + pub async fn decode_event_topic(&self, topic: B256) -> eyre::Result { self.decode_selector(SelectorKind::Event(topic)).await } /// Pretty print calldata and if available, fetch possible function signatures /// /// ```no_run - /// use foundry_common::selectors::OpenChainClient; + /// use foundry_common::selectors::SourcifyClient; /// /// # async fn foo() -> eyre::Result<()> { - /// let pretty_data = OpenChainClient::new()? + /// let pretty_data = SourcifyClient::new()? /// .pretty_calldata( /// "0x70a08231000000000000000000000000d0074f4e6490ae3f888d1d4f7e3e43326bd3f0f5" /// .to_string(), @@ -281,7 +281,7 @@ impl OpenChainClient { Ok(possible_info) } - /// uploads selectors to OpenChain using the given data + /// uploads selectors to Sourcify using the given data pub async fn import_selectors( &self, data: SelectorImportData, @@ -290,7 +290,7 @@ impl OpenChainClient { let request = match data { SelectorImportData::Abi(abis) => { - let functions_and_errors: OpenChainSignatures = abis + let functions_and_errors: SourcifySignatures = abis .iter() .flat_map(|abi| { abi.functions() @@ -320,12 +320,12 @@ impl OpenChainClient { pub enum SelectorOrSig { Selector(String), - Sig(OpenChainSignatures), + Sig(SourcifySignatures), } pub struct PossibleSigs { method: SelectorOrSig, - data: OpenChainSignatures, + data: SourcifySignatures, } impl PossibleSigs { @@ -358,7 +358,7 @@ impl fmt::Display for PossibleSigs { } } -/// The kind of selector to fetch from OpenChain. +/// The kind of selector to fetch from Sourcify. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum SelectorKind { /// A function selector. @@ -387,31 +387,29 @@ impl SelectorKind { } } -/// Decodes the given function or event selector using OpenChain. -pub async fn decode_selector(selector: SelectorKind) -> eyre::Result { - OpenChainClient::new()?.decode_selector(selector).await +/// Decodes the given function or event selector using Sourcify. +pub async fn decode_selector(selector: SelectorKind) -> eyre::Result { + SourcifyClient::new()?.decode_selector(selector).await } -/// Decodes the given function or event selectors using OpenChain. -pub async fn decode_selectors( - selectors: &[SelectorKind], -) -> eyre::Result> { - OpenChainClient::new()?.decode_selectors(selectors).await +/// Decodes the given function or event selectors using Sourcify. +pub async fn decode_selectors(selectors: &[SelectorKind]) -> eyre::Result> { + SourcifyClient::new()?.decode_selectors(selectors).await } -/// Fetches a function signature given the selector using OpenChain. -pub async fn decode_function_selector(selector: Selector) -> eyre::Result { - OpenChainClient::new()?.decode_function_selector(selector).await +/// Fetches a function signature given the selector using Sourcify. +pub async fn decode_function_selector(selector: Selector) -> eyre::Result { + SourcifyClient::new()?.decode_function_selector(selector).await } -/// Fetches all possible signatures and attempts to abi decode the calldata using OpenChain. -pub async fn decode_calldata(calldata: &str) -> eyre::Result { - OpenChainClient::new()?.decode_calldata(calldata).await +/// Fetches all possible signatures and attempts to abi decode the calldata using Sourcify. +pub async fn decode_calldata(calldata: &str) -> eyre::Result { + SourcifyClient::new()?.decode_calldata(calldata).await } -/// Fetches an event signature given the 32 byte topic using OpenChain. -pub async fn decode_event_topic(topic: B256) -> eyre::Result { - OpenChainClient::new()?.decode_event_topic(topic).await +/// Fetches an event signature given the 32 byte topic using Sourcify. +pub async fn decode_event_topic(topic: B256) -> eyre::Result { + SourcifyClient::new()?.decode_event_topic(topic).await } /// Pretty print calldata and if available, fetch possible function signatures. @@ -433,14 +431,14 @@ pub async fn pretty_calldata( calldata: impl AsRef, offline: bool, ) -> eyre::Result { - OpenChainClient::new()?.pretty_calldata(calldata, offline).await + SourcifyClient::new()?.pretty_calldata(calldata, offline).await } #[derive(Debug, Default, PartialEq, Eq, Serialize)] pub struct RawSelectorImportData { - pub function: OpenChainSignatures, - pub event: OpenChainSignatures, - pub error: OpenChainSignatures, + pub function: SourcifySignatures, + pub event: SourcifySignatures, + pub error: SourcifySignatures, } impl RawSelectorImportData { @@ -458,8 +456,8 @@ pub enum SelectorImportData { #[derive(Debug, Default, Serialize)] struct SelectorImportRequest { - function: OpenChainSignatures, - event: OpenChainSignatures, + function: SourcifySignatures, + event: SourcifySignatures, } #[derive(Debug, Deserialize)] @@ -495,13 +493,13 @@ impl SelectorImportResponse { let _ = sh_println!("Duplicated: Event {k}: {v}"); }); - let _ = sh_println!("Selectors successfully uploaded to OpenChain"); + let _ = sh_println!("Selectors successfully uploaded to Sourcify"); } } -/// uploads selectors to OpenChain using the given data +/// uploads selectors to Sourcify using the given data pub async fn import_selectors(data: SelectorImportData) -> eyre::Result { - OpenChainClient::new()?.import_selectors(data).await + SourcifyClient::new()?.import_selectors(data).await } #[derive(Debug, Default, PartialEq, Eq)] diff --git a/crates/evm/traces/src/identifier/signatures.rs b/crates/evm/traces/src/identifier/signatures.rs index 5c4765a851fc7..f25b4f0bd55b3 100644 --- a/crates/evm/traces/src/identifier/signatures.rs +++ b/crates/evm/traces/src/identifier/signatures.rs @@ -4,7 +4,7 @@ use eyre::Result; use foundry_common::{ abi::{get_error, get_event, get_func}, fs, - selectors::{OpenChainClient, SelectorKind}, + selectors::{SelectorKind, SourcifyClient}, }; use foundry_config::Config; use serde::{Deserialize, Serialize}; @@ -147,7 +147,7 @@ impl SignaturesCache { } /// An identifier that tries to identify functions and events using signatures found at -/// `https://openchain.xyz` or a local cache. +/// `https://sourcify.dev` or a local cache. #[derive(Clone, Debug)] pub struct SignaturesIdentifier(Arc); @@ -157,8 +157,8 @@ struct SignaturesIdentifierInner { cache: RwLock, /// Location where to save the signature cache. cache_path: Option, - /// The OpenChain client to fetch signatures from. `None` if disabled on construction. - client: Option, + /// The Sourcify client to fetch signatures from. `None` if disabled on construction. + client: Option, } impl SignaturesIdentifier { @@ -175,9 +175,9 @@ impl SignaturesIdentifier { /// Creates a new `SignaturesIdentifier`. /// /// - `cache_dir` is the cache directory to store the signatures. - /// - `offline` disables the OpenChain client. + /// - `offline` disables the Sourcify client. pub fn new_with(cache_dir: Option<&Path>, offline: bool) -> Result { - let client = if !offline { Some(OpenChainClient::new()?) } else { None }; + let client = if !offline { Some(SourcifyClient::new()?) } else { None }; let (cache, cache_path) = if let Some(cache_dir) = cache_dir { let path = cache_dir.join("signatures"); let cache = SignaturesCache::load(&path); diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index a263b8e0c3693..a8e15bcc75675 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -3301,7 +3301,7 @@ Error: No contract name provided. ... Uploading selectors for CounterV2... ... -Selectors successfully uploaded to OpenChain +Selectors successfully uploaded to Sourcify ... "# @@ -3315,7 +3315,7 @@ Selectors successfully uploaded to OpenChain ... Uploading selectors for Counter... ... -Selectors successfully uploaded to OpenChain +Selectors successfully uploaded to Sourcify ... "#]]); @@ -3328,7 +3328,7 @@ Selectors successfully uploaded to OpenChain ... Uploading selectors for Counter... ... -Selectors successfully uploaded to OpenChain +Selectors successfully uploaded to Sourcify ... "#]]); From 797a2773e972d25b9ddbfa7866fbcf3f9e9cf5f6 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Mon, 29 Sep 2025 21:36:45 +0200 Subject: [PATCH 2/2] chore: deprecate signature uploading --- crates/cast/src/args.rs | 19 ++- crates/cast/src/opts.rs | 2 +- crates/cast/tests/cli/main.rs | 16 +-- crates/cast/tests/cli/selectors.rs | 118 +++++-------------- crates/common/src/selectors.rs | 112 +----------------- crates/forge/src/cmd/selectors.rs | 83 ++----------- crates/forge/tests/cli/failure_assertions.rs | 2 +- crates/forge/tests/cli/test_cmd.rs | 93 --------------- 8 files changed, 58 insertions(+), 387 deletions(-) diff --git a/crates/cast/src/args.rs b/crates/cast/src/args.rs index e9534ceccd656..a44b45aa6377d 100644 --- a/crates/cast/src/args.rs +++ b/crates/cast/src/args.rs @@ -19,9 +19,8 @@ use foundry_common::{ fmt::{format_tokens, format_uint_exp, serialize_value_as_json}, fs, selectors::{ - ParsedSignatures, SelectorImportData, SelectorKind, decode_calldata, decode_event_topic, - decode_function_selector, decode_selectors, import_selectors, parse_signatures, - pretty_calldata, + SelectorKind, decode_calldata, decode_event_topic, decode_function_selector, + decode_selectors, pretty_calldata, }, shell, stdin, }; @@ -594,15 +593,11 @@ pub async fn run_command(args: CastArgs) -> Result<()> { sh_println!("{sig}")? } } - CastSubcommand::UploadSignature { signatures } => { - let signatures = stdin::unwrap_vec(signatures)?; - let ParsedSignatures { signatures, abis } = parse_signatures(signatures); - if !abis.is_empty() { - import_selectors(SelectorImportData::Abi(abis)).await?.describe(); - } - if !signatures.is_empty() { - import_selectors(SelectorImportData::Raw(signatures)).await?.describe(); - } + CastSubcommand::UploadSignature { .. } => { + sh_warn!( + "Selector uploading is deprecated and is currently a no-op, as the upstream API has been removed." + )?; + sh_warn!("To upload selectors in the future, verify your contracts with Sourcify.")?; } // ENS diff --git a/crates/cast/src/opts.rs b/crates/cast/src/opts.rs index f9b50643fa0de..a2875ff901fd5 100644 --- a/crates/cast/src/opts.rs +++ b/crates/cast/src/opts.rs @@ -742,7 +742,7 @@ pub enum CastSubcommand { topic: Option, }, - /// Upload the given signatures to . + /// DEPRECATED: Upload the given signatures to . /// /// Example inputs: /// - "transfer(address,uint256)" diff --git a/crates/cast/tests/cli/main.rs b/crates/cast/tests/cli/main.rs index cc7276bd2b952..7ac1f76925cec 100644 --- a/crates/cast/tests/cli/main.rs +++ b/crates/cast/tests/cli/main.rs @@ -1686,7 +1686,7 @@ casttest!(mktx_raw_unsigned_no_from_missing_nonce, |_prj, cmd| { "--chain", "1", "--gas-limit", - "21000", + "21000", "--gas-price", "20000000000", "0x742d35Cc6634C0532925a3b8D6Ac6F67C9c2b7FD", @@ -3384,7 +3384,7 @@ Traces: │ ├─ [2553] 0x2Ce6311ddAE708829bc0784C967b7d77D19FD779::balanceOf(0xA12384c5E52fD646E7BC7F6B3b33A605651F566E) [delegatecall] │ │ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000000000f3b9 │ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000000000f3b9 - ├─ [65442] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::00000000(00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a12384c5e52fd646e7bc7f6b3b33a605651f566e000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f0000000000000000000000000000000000000000000000000000000000036cd000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000327a25ad5cfe5c4d4339c1a4267d4a83e8c93312000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000b55b053230e4effb6609de652fca73fd1c2980400000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000221000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) + ├─ [65442] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::fulfillBasicOrder_efficient_6GL6yc() │ ├─ [25070] 0xA12384c5E52fD646E7BC7F6B3b33A605651F566E::unwrapAndValidateSignature(0x290a4c4039f102eceba2147e1fcc46f994a46d1229faf43ffff26a058e7378ff, 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b00) [staticcall] │ │ ├─ [22067] 0x0B55b053230E4EFFb6609de652fCa73Fd1C29804::unwrapAndValidateSignature(0x290a4c4039f102eceba2147e1fcc46f994a46d1229faf43ffff26a058e7378ff, 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b00) [delegatecall] │ │ │ ├─ [2369] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::pauseFlag() [staticcall] @@ -3418,7 +3418,7 @@ Traces: │ │ ├─ [553] 0x2Ce6311ddAE708829bc0784C967b7d77D19FD779::balanceOf(0x327a25aD5Cfe5c4D4339C1A4267D4a83E8c93312) [delegatecall] │ │ │ └─ ← [Return] 0x0000000000000000000000000000000000000000000000000000000000009c9a │ │ └─ ← [Return] 0x0000000000000000000000000000000000000000000000000000000000009c9a - │ ├─ [5675] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::00000001(00000000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b290a4c4039f102eceba2147e1fcc46f994a46d1229faf43ffff26a058e7378ff0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a12384c5e52fd646e7bc7f6b3b33a605651f566e000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f0000000000000000000000000000000000000000000000000000000000036cd000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000000000000000000000000000000000000000060f000000000000000000000000327a25ad5cfe5c4d4339c1a4267d4a83e8c93312000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000b55b053230e4effb6609de652fca73fd1c2980400000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000221000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006cdd519280ec730727f07aa36550bde31a1d5f3097818f3425c2f083ed33a91f080fa2afac0071f6e1af9a0e9c09b851bf01e68bc8a1c1f89f686c48205762f92500000000000000000000000000000000000000000000000000000000000000244242424242424242424242424242424242424242424242424242424242424242010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000827b226368616c6c656e6765223a224b51704d51446e7841757a726f68522d483878472d5a536b625249702d76515f5f5f4a714259357a655038222c2263726f73734f726967696e223a66616c73652c226f726967696e223a2268747470732f2f6974686163612e78797a222c2274797065223a22776562617574686e2e676574227d0000000000000000000000000000000000000000000000000000000000001bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) + │ ├─ [5675] 0xc2FF493F28e894742b968A7DB5D3F21F0aD80C6c::multicallN2M_001Taw5z() │ │ ├─ [4148] 0xA12384c5E52fD646E7BC7F6B3b33A605651F566E::execute(0x0100000000007821000100000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000201bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b) │ │ │ ├─ [3693] 0x0B55b053230E4EFFb6609de652fCa73Fd1C29804::execute(0x0100000000007821000100000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000201bde17b8de18819c9eb86cefc3920ddb5d3d4254de276e3d6e18dd2b399f732b) [delegatecall] │ │ │ │ ├─ [435] 0xA12384c5E52fD646E7BC7F6B3b33A605651F566E::fallback() @@ -3586,12 +3586,12 @@ forgetest_async!(cast_send_create_with_constructor_args, |prj, cmd| { contract ConstructorContract { uint256 public value; string public name; - + constructor(uint256 _value, string memory _name) { value = _value; name = _name; } - + function getValue() public view returns (uint256) { return value; } @@ -3665,7 +3665,7 @@ casttest!(cast_estimate_create_with_constructor_args, |prj, cmd| { contract EstimateContract { uint256 public value; string public name; - + constructor(uint256 _value, string memory _name) { value = _value; name = _name; @@ -3767,13 +3767,13 @@ contract ComplexContract { address public owner; uint256[] public values; bool public active; - + constructor(address _owner, uint256[] memory _values, bool _active) { owner = _owner; values = _values; active = _active; } - + function getValuesLength() public view returns (uint256) { return values.length; } diff --git a/crates/cast/tests/cli/selectors.rs b/crates/cast/tests/cli/selectors.rs index 909f34b6144a1..087c3861e77bb 100644 --- a/crates/cast/tests/cli/selectors.rs +++ b/crates/cast/tests/cli/selectors.rs @@ -1,19 +1,22 @@ -use foundry_test_utils::util::OutputExt; -use std::path::Path; - -casttest!(error_decode_with_sourcify, |prj, cmd| { - prj.clear_cache(); - cmd.args(["decode-error", "0x7a0e198500000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000064"]).assert_success().stdout_eq(str![[r#" -ValueTooHigh(uint256,uint256) -101 -100 +casttest!( + #[ignore = "selector missing upstream"] + error_decode_with_sourcify, + |prj, cmd| { + prj.clear_cache(); + cmd.args(["decode-error", + "0xcf47918100000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000100000000" + ]).assert_success().stdout_eq(str![[r#" InsufficientBalance(uint256,uint256) +256 +4294967296 [4.294e9] "#]]); -}); + } +); casttest!(fourbyte, |_prj, cmd| { cmd.args(["4byte", "0xa9059cbb"]).assert_success().stdout_eq(str![[r#" transfer(address,uint256) +_____$_$__$___$$$___$$___$__$$(address,uint256) "#]]); }); @@ -27,109 +30,50 @@ For more information, try '--help'. "#]]); }); -casttest!(fourbyte_calldata, |_prj, cmd| { - cmd.args(["4byte-calldata", "0xa9059cbb0000000000000000000000000a2ac0c368dc8ec680a0c98c907656bd970675950000000000000000000000000000000000000000000000000000000767954a79"]).assert_success().stdout_eq(str![[r#" +casttest!( + #[ignore = "selector missing upstream"] + fourbyte_calldata, + |_prj, cmd| { + cmd.args(["4byte-calldata", + "0xa9059cbb0000000000000000000000000a2ac0c368dc8ec680a0c98c907656bd970675950000000000000000000000000000000000000000000000000000000767954a79" + ]).assert_success().stdout_eq(str![[r#" 1) "transfer(address,uint256)" 0x0A2AC0c368Dc8eC680a0c98C907656BD97067595 31802608249 [3.18e10] "#]]); -}); + } +); casttest!(fourbyte_calldata_only_selector, |_prj, cmd| { cmd.args(["4byte-calldata", "0xa9059cbb"]).assert_success().stdout_eq(str![[r#" transfer(address,uint256) +_____$_$__$___$$$___$$___$__$$(address,uint256) "#]]); }); casttest!(fourbyte_calldata_alias, |_prj, cmd| { - cmd.args(["4byte-decode", "0xa9059cbb0000000000000000000000000a2ac0c368dc8ec680a0c98c907656bd970675950000000000000000000000000000000000000000000000000000000767954a79"]).assert_success().stdout_eq(str![[r#" + cmd + .stdin(b"1\n") + .args(["4byte-decode", "0xa9059cbb0000000000000000000000000a2ac0c368dc8ec680a0c98c907656bd970675950000000000000000000000000000000000000000000000000000000767954a79"]).assert_success().stdout_eq(str![[r#" 1) "transfer(address,uint256)" -0x0A2AC0c368Dc8eC680a0c98C907656BD97067595 +2) "_____$_$__$___$$$___$$___$__$$(address,uint256)" +Select a function signature by number: 0x0A2AC0c368Dc8eC680a0c98C907656BD97067595 31802608249 [3.18e10] "#]]); }); casttest!(fourbyte_event, |_prj, cmd| { - cmd.args(["4byte-event", "0x7e1db2a1cd12f0506ecd806dba508035b290666b84b096a87af2fd2a1516ede6"]) - .assert_success() - .stdout_eq(str![[r#" -updateAuthority(address,uint8) - -"#]]); -}); - -casttest!(fourbyte_event_2, |_prj, cmd| { - cmd.args(["4byte-event", "0xb7009613e63fb13fd59a2fa4c206a992c1f090a44e5d530be255aa17fed0b3dd"]) + cmd.args(["4byte-event", "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]) .assert_success() .stdout_eq(str![[r#" -canCall(address,address,bytes4) +Transfer(address,address,uint256) "#]]); }); -casttest!(upload_signatures, |_prj, cmd| { - // test no prefix is accepted as function - let output = cmd - .args(["upload-signature", "transfer(address,uint256)"]) - .assert_success() - .get_output() - .stdout_lossy(); - assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); - - // test event prefix - cmd.args(["upload-signature", "event Transfer(address,uint256)"]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); - - // test error prefix - cmd.args(["upload-signature", "error ERC20InsufficientBalance(address,uint256,uint256)"]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!( - output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), - "{}", - output - ); // Custom error is interpreted as function - - // test multiple sigs - cmd.args([ - "upload-signature", - "event Transfer(address,uint256)", - "transfer(address,uint256)", - "approve(address,uint256)", - ]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); - assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); - assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); - - // test abi - cmd.args([ - "upload-signature", - "event Transfer(address,uint256)", - "transfer(address,uint256)", - "error ERC20InsufficientBalance(address,uint256,uint256)", - Path::new(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/ERC20Artifact.json") - .as_os_str() - .to_str() - .unwrap(), - ]); - let output = cmd.assert_success().get_output().stdout_lossy(); - assert!(output.contains("Event Transfer(address,uint256): 0x69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2"), "{}", output); - assert!(output.contains("Function transfer(address,uint256): 0xa9059cbb"), "{}", output); - assert!(output.contains("Function approve(address,uint256): 0x095ea7b3"), "{}", output); - assert!(output.contains("Function decimals(): 0x313ce567"), "{}", output); - assert!(output.contains("Function allowance(address,address): 0xdd62ed3e"), "{}", output); - assert!( - output.contains("Function ERC20InsufficientBalance(address,uint256,uint256): 0xe450d38c"), - "{}", - output - ); -}); - // tests cast can decode event with provided signature casttest!(event_decode_with_sig, |_prj, cmd| { cmd.args(["decode-event", "--sig", "MyEvent(uint256,address)", "0x000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000d0004f"]).assert_success().stdout_eq(str![[r#" @@ -148,7 +92,7 @@ casttest!(event_decode_with_sig, |_prj, cmd| { }); // tests cast can decode event with Sourcify API -casttest!(event_decode_with_sourcify, |prj, cmd| { +casttest!(event_decode, |prj, cmd| { prj.clear_cache(); cmd.args(["decode-event", "0xe27c4c1372396a3d15a9922f74f9dfc7c72b1ad6d63868470787249c356454c1000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e"]).assert_success().stdout_eq(str![[r#" BaseCurrencySet(address,uint256) diff --git a/crates/common/src/selectors.rs b/crates/common/src/selectors.rs index 884a733b82299..7b640545a0cb1 100644 --- a/crates/common/src/selectors.rs +++ b/crates/common/src/selectors.rs @@ -7,7 +7,7 @@ use alloy_json_abi::JsonAbi; use alloy_primitives::{B256, Selector, map::HashMap}; use eyre::Context; use itertools::Itertools; -use serde::{Deserialize, Serialize, de::DeserializeOwned}; +use serde::{Deserialize, Serialize}; use std::{ fmt, sync::{ @@ -19,7 +19,6 @@ use std::{ const BASE_URL: &str = "https://sourcify.dev/server"; const SELECTOR_LOOKUP_URL: &str = "https://sourcify.dev/server/signature-database/v1/lookup"; -const SELECTOR_IMPORT_URL: &str = "https://sourcify.dev/server/signature-database/v1/import"; /// The standard request timeout for API requests. const REQ_TIMEOUT: Duration = Duration::from_secs(15); @@ -70,24 +69,6 @@ impl SourcifyClient { .inspect_err(|err| self.on_reqwest_err(err)) } - /// Sends a new post request - async fn post_json( - &self, - url: &str, - body: &T, - ) -> reqwest::Result { - trace!(%url, body=?serde_json::to_string(body), "POST"); - self.inner - .post(url) - .json(body) - .send() - .await - .inspect_err(|err| self.on_reqwest_err(err))? - .json() - .await - .inspect_err(|err| self.on_reqwest_err(err)) - } - fn on_reqwest_err(&self, err: &reqwest::Error) { fn is_connectivity_err(err: &reqwest::Error) -> bool { if err.is_timeout() || err.is_connect() { @@ -280,42 +261,6 @@ impl SourcifyClient { } Ok(possible_info) } - - /// uploads selectors to Sourcify using the given data - pub async fn import_selectors( - &self, - data: SelectorImportData, - ) -> eyre::Result { - self.ensure_not_spurious()?; - - let request = match data { - SelectorImportData::Abi(abis) => { - let functions_and_errors: SourcifySignatures = abis - .iter() - .flat_map(|abi| { - abi.functions() - .map(|func| func.signature()) - .chain(abi.errors().map(|error| error.signature())) - .collect::>() - }) - .collect(); - - let events = abis - .iter() - .flat_map(|abi| abi.events().map(|event| event.signature())) - .collect::>(); - - SelectorImportRequest { function: functions_and_errors, event: events } - } - SelectorImportData::Raw(raw) => { - let function_and_error = - raw.function.iter().chain(raw.error.iter()).cloned().collect::>(); - SelectorImportRequest { function: function_and_error, event: raw.event } - } - }; - - Ok(self.post_json(SELECTOR_IMPORT_URL, &request).await?) - } } pub enum SelectorOrSig { @@ -447,61 +392,6 @@ impl RawSelectorImportData { } } -#[derive(Serialize)] -#[serde(untagged)] -pub enum SelectorImportData { - Abi(Vec), - Raw(RawSelectorImportData), -} - -#[derive(Debug, Default, Serialize)] -struct SelectorImportRequest { - function: SourcifySignatures, - event: SourcifySignatures, -} - -#[derive(Debug, Deserialize)] -struct SelectorImportEffect { - imported: HashMap, - duplicated: HashMap, -} - -#[derive(Debug, Deserialize)] -struct SelectorImportResult { - function: SelectorImportEffect, - event: SelectorImportEffect, -} - -#[derive(Debug, Deserialize)] -pub struct SelectorImportResponse { - result: SelectorImportResult, -} - -impl SelectorImportResponse { - /// Print info about the functions which were uploaded or already known - pub fn describe(&self) { - self.result.function.imported.iter().for_each(|(k, v)| { - let _ = sh_println!("Imported: Function {k}: {v}"); - }); - self.result.event.imported.iter().for_each(|(k, v)| { - let _ = sh_println!("Imported: Event {k}: {v}"); - }); - self.result.function.duplicated.iter().for_each(|(k, v)| { - let _ = sh_println!("Duplicated: Function {k}: {v}"); - }); - self.result.event.duplicated.iter().for_each(|(k, v)| { - let _ = sh_println!("Duplicated: Event {k}: {v}"); - }); - - let _ = sh_println!("Selectors successfully uploaded to Sourcify"); - } -} - -/// uploads selectors to Sourcify using the given data -pub async fn import_selectors(data: SelectorImportData) -> eyre::Result { - SourcifyClient::new()?.import_selectors(data).await -} - #[derive(Debug, Default, PartialEq, Eq)] pub struct ParsedSignatures { pub signatures: RawSelectorImportData, diff --git a/crates/forge/src/cmd/selectors.rs b/crates/forge/src/cmd/selectors.rs index ecbea1aac8d56..d4e600f61ccdd 100644 --- a/crates/forge/src/cmd/selectors.rs +++ b/crates/forge/src/cmd/selectors.rs @@ -7,8 +7,7 @@ use foundry_cli::{ utils::{FoundryPathExt, cache_local_signatures}, }; use foundry_common::{ - compile::{PathOrContractInfo, ProjectCompiler, compile_target}, - selectors::{SelectorImportData, import_selectors}, + compile::{PathOrContractInfo, ProjectCompiler}, shell, }; use foundry_compilers::{artifacts::output_selection::ContractOutputSelection, info::ContractInfo}; @@ -32,7 +31,7 @@ pub enum SelectorsSubcommands { build: Box, }, - /// Upload selectors to registry + /// DEPRECATED: Upload selectors to registry #[command(visible_alias = "up")] Upload { /// The name of the contract to upload selectors for. @@ -100,77 +99,13 @@ impl SelectorsSubcommands { let outcome = ProjectCompiler::new().quiet(true).compile(&project)?; cache_local_signatures(&outcome)?; } - Self::Upload { contract, all, project_paths } => { - let build_args = BuildOpts { - project_paths: project_paths.clone(), - compiler: CompilerOpts { - extra_output: vec![ContractOutputSelection::Abi], - ..Default::default() - }, - ..Default::default() - }; - - let project = build_args.project()?; - let output = if let Some(contract_info) = &contract { - let Some(contract_name) = contract_info.name() else { - eyre::bail!("No contract name provided.") - }; - - let target_path = contract_info - .path() - .map(Ok) - .unwrap_or_else(|| project.find_contract_path(contract_name))?; - compile_target(&target_path, &project, false)? - } else { - ProjectCompiler::new().compile(&project)? - }; - let artifacts = if all { - output - .into_artifacts_with_files() - .filter(|(file, _, _)| { - let is_sources_path = file.starts_with(&project.paths.sources); - let is_test = file.is_sol_test(); - - is_sources_path && !is_test - }) - .map(|(_, contract, artifact)| (contract, artifact)) - .collect() - } else { - let contract_info = contract.unwrap(); - let contract = contract_info.name().unwrap().to_string(); - - let found_artifact = if let Some(path) = contract_info.path() { - output.find(project.root().join(path).as_path(), &contract) - } else { - output.find_first(&contract) - }; - - let artifact = found_artifact - .ok_or_else(|| { - eyre::eyre!( - "Could not find artifact `{contract}` in the compiled artifacts" - ) - })? - .clone(); - vec![(contract, artifact)] - }; - - let mut artifacts = artifacts.into_iter().peekable(); - while let Some((contract, artifact)) = artifacts.next() { - let abi = artifact.abi.ok_or_else(|| eyre::eyre!("Unable to fetch abi"))?; - if abi.functions.is_empty() && abi.events.is_empty() && abi.errors.is_empty() { - continue; - } - - sh_println!("Uploading selectors for {contract}...")?; - - // upload abi to selector database - import_selectors(SelectorImportData::Abi(vec![abi])).await?.describe(); - - if artifacts.peek().is_some() { - sh_println!()? - } - } + Self::Upload { .. } => { + sh_warn!( + "Selector uploading is deprecated and is currently a no-op, as the upstream API has been removed." + )?; + sh_warn!( + "To upload selectors in the future, verify your contracts with Sourcify." + )?; } Self::Collision { mut first_contract, mut second_contract, build } => { // Compile the project with the two contracts included diff --git a/crates/forge/tests/cli/failure_assertions.rs b/crates/forge/tests/cli/failure_assertions.rs index 7032b3a34ba85..6174880e8eb5b 100644 --- a/crates/forge/tests/cli/failure_assertions.rs +++ b/crates/forge/tests/cli/failure_assertions.rs @@ -418,7 +418,7 @@ forgetest!(multiple_setups, |prj, cmd| { prj.add_source( "MultipleSetupsTest.t.sol", r#" - + import "./test.sol"; contract MultipleSetup is DSTest { diff --git a/crates/forge/tests/cli/test_cmd.rs b/crates/forge/tests/cli/test_cmd.rs index a8e15bcc75675..922cf2448a6cf 100644 --- a/crates/forge/tests/cli/test_cmd.rs +++ b/crates/forge/tests/cli/test_cmd.rs @@ -3241,99 +3241,6 @@ Traces: "#]]); }); -// -forgetest_init!(can_upload_selectors_with_path, |prj, cmd| { - prj.add_source( - "CounterV1.sol", - r#" -contract Counter { - uint256 public number; - - function setNumberV1(uint256 newNumber) public { - number = newNumber; - } - - function incrementV1() public { - number++; - } -} - "#, - ); - - prj.add_source( - "CounterV2.sol", - r#" -contract CounterV2 { - uint256 public number; - - function setNumberV2(uint256 newNumber) public { - number = newNumber; - } - - function incrementV2() public { - number++; - } -} - "#, - ); - - // Upload Counter without path fails as there are multiple contracts with same name. - cmd.args(["selectors", "upload", "Counter"]).assert_failure().stderr_eq(str![[r#" -... -Error: Multiple contracts found with the name `Counter` -... - -"#]]); - - // Upload without contract name should fail. - cmd.forge_fuse().args(["selectors", "upload", "src/Counter.sol"]).assert_failure().stderr_eq( - str![[r#" -... -Error: No contract name provided. -... - -"#]], - ); - - // Upload single CounterV2. - cmd.forge_fuse().args(["selectors", "upload", "CounterV2"]).assert_success().stdout_eq(str![[ - r#" -... -Uploading selectors for CounterV2... -... -Selectors successfully uploaded to Sourcify -... - -"# - ]]); - - // Upload CounterV1 with path. - cmd.forge_fuse() - .args(["selectors", "upload", "src/CounterV1.sol:Counter"]) - .assert_success() - .stdout_eq(str![[r#" -... -Uploading selectors for Counter... -... -Selectors successfully uploaded to Sourcify -... - -"#]]); - - // Upload Counter with path. - cmd.forge_fuse() - .args(["selectors", "upload", "src/Counter.sol:Counter"]) - .assert_success() - .stdout_eq(str![[r#" -... -Uploading selectors for Counter... -... -Selectors successfully uploaded to Sourcify -... - -"#]]); -}); - forgetest_init!(selectors_list_cmd, |prj, cmd| { prj.add_source( "Counter.sol",