diff --git a/Cargo.lock b/Cargo.lock index bf780df19e..0d929a30ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,6 +78,7 @@ checksum = "35d744058a9daa51a8cf22a3009607498fcf82d3cf4c5444dd8056cdf651f471" dependencies = [ "alloy-primitives", "num_enum", + "serde", "strum", ] @@ -105,7 +106,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -141,7 +142,7 @@ dependencies = [ "futures", "futures-util", "serde_json", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -183,7 +184,7 @@ dependencies = [ "alloy-rlp", "crc", "serde", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -209,7 +210,7 @@ dependencies = [ "borsh", "k256", "serde", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -232,7 +233,7 @@ dependencies = [ "serde", "serde_with", "sha2 0.10.9", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -273,7 +274,7 @@ dependencies = [ "http", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", "tracing", ] @@ -300,7 +301,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -379,7 +380,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", "tokio", "tracing", "url", @@ -472,7 +473,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -498,7 +499,7 @@ dependencies = [ "either", "elliptic-curve", "k256", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -514,7 +515,7 @@ dependencies = [ "async-trait", "k256", "rand 0.8.5", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -605,7 +606,7 @@ dependencies = [ "parking_lot", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", "tokio", "tower", "tracing", @@ -699,9 +700,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anstyle-parse" @@ -1085,6 +1086,21 @@ dependencies = [ "syn 2.0.103", ] +[[package]] +name = "atomic" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "aurora-engine-modexp" version = "1.2.0" @@ -1261,6 +1277,31 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bon" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f47dbe92550676ee653353c310dfb9cf6ba17ee70396e1f7cf0a2020ad49b2fe" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519bd3116aeeb42d5372c29d982d16d0170d3d4a5ed85fc7dd91642ffff3c67c" +dependencies = [ + "darling 0.21.3", + "ident_case", + "prettyplease", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.103", +] + [[package]] name = "borsh" version = "1.6.0" @@ -1290,6 +1331,16 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36f64beae40a84da1b4b26ff2761a5b895c12adc41dc25aaee1c4f2bbfe97a6e" +[[package]] +name = "bstr" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bumpalo" version = "3.18.1" @@ -1302,6 +1353,12 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" +[[package]] +name = "bytemuck" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" + [[package]] name = "byteorder" version = "1.5.0" @@ -1718,71 +1775,70 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ - "darling_core 0.20.11", - "darling_macro 0.20.11", + "darling_core 0.21.3", + "darling_macro 0.21.3", ] [[package]] name = "darling" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ - "darling_core 0.21.3", - "darling_macro 0.21.3", + "darling_core 0.23.0", + "darling_macro 0.23.0", ] [[package]] name = "darling_core" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", + "serde", "strsim", "syn 2.0.103", ] [[package]] name = "darling_core" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" dependencies = [ - "fnv", "ident_case", "proc-macro2", "quote", - "serde", "strsim", "syn 2.0.103", ] [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ - "darling_core 0.20.11", + "darling_core 0.21.3", "quote", "syn 2.0.103", ] [[package]] name = "darling_macro" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ - "darling_core 0.21.3", + "darling_core 0.23.0", "quote", "syn 2.0.103", ] @@ -1813,12 +1869,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.4.0" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ "powerfmt", - "serde", + "serde_core", ] [[package]] @@ -2014,6 +2070,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + [[package]] name = "enum-ordinalize" version = "4.3.0" @@ -2040,6 +2105,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "erased-serde" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2add8a07dd6a8d93ff627029c51de145e12686fbc36ecb298ac22e74cf02dec" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + [[package]] name = "errno" version = "0.3.12" @@ -2059,7 +2135,7 @@ dependencies = [ "alloy-provider", "anyhow", "indicatif", - "revm", + "revm 29.0.0", "tokio", ] @@ -2068,7 +2144,7 @@ name = "example-cheatcode-inspector" version = "0.0.0" dependencies = [ "anyhow", - "revm", + "revm 29.0.0", ] [[package]] @@ -2076,14 +2152,14 @@ name = "example-contract-deployment" version = "0.0.0" dependencies = [ "anyhow", - "revm", + "revm 29.0.0", ] [[package]] name = "example-custom-opcodes" version = "0.0.0" dependencies = [ - "revm", + "revm 29.0.0", ] [[package]] @@ -2091,7 +2167,7 @@ name = "example-custom-precompile-journal" version = "0.1.0" dependencies = [ "anyhow", - "revm", + "revm 29.0.0", ] [[package]] @@ -2099,8 +2175,8 @@ name = "example-database-components" version = "0.0.0" dependencies = [ "auto_impl", - "revm", - "thiserror", + "revm 29.0.0", + "thiserror 2.0.17", ] [[package]] @@ -2110,7 +2186,7 @@ dependencies = [ "alloy-provider", "alloy-sol-types", "anyhow", - "revm", + "revm 29.0.0", "tokio", ] @@ -2118,7 +2194,7 @@ dependencies = [ name = "example-my-evm" version = "0.0.0" dependencies = [ - "revm", + "revm 29.0.0", ] [[package]] @@ -2129,7 +2205,7 @@ dependencies = [ "alloy-provider", "alloy-sol-types", "anyhow", - "revm", + "revm 29.0.0", "tokio", ] @@ -2141,10 +2217,20 @@ dependencies = [ "alloy-provider", "alloy-sol-types", "anyhow", - "revm", + "revm 29.0.0", "tokio", ] +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fastrand" version = "2.3.0" @@ -2200,6 +2286,20 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "figment" +version = "0.10.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3" +dependencies = [ + "atomic", + "pear", + "serde", + "toml 0.8.23", + "uncased", + "version_check", +] + [[package]] name = "find-msvc-tools" version = "0.1.5" @@ -2271,6 +2371,24 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "foundry-block-explorers" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff814624bb21bfe43b70fb736ab39527b405d04cdc94d90b7e182fba28b25ec7" +dependencies = [ + "alloy-chains", + "alloy-json-abi", + "alloy-primitives", + "foundry-compilers", + "reqwest", + "semver 1.0.26", + "serde", + "serde_json", + "thiserror 2.0.17", + "tracing", +] + [[package]] name = "foundry-compilers" version = "0.19.14" @@ -2290,9 +2408,11 @@ dependencies = [ "semver 1.0.26", "serde", "serde_json", + "sha2 0.10.9", "solar-compiler", "svm-rs", - "thiserror", + "svm-rs-builds", + "thiserror 2.0.17", "tracing", "winnow", "yansi", @@ -2324,7 +2444,7 @@ dependencies = [ "semver 1.0.26", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", "tracing", "yansi", ] @@ -2358,11 +2478,51 @@ dependencies = [ "semver 1.0.26", "serde", "serde_json", - "thiserror", + "svm-rs", + "thiserror 2.0.17", + "tokio", "walkdir", "xxhash-rust", ] +[[package]] +name = "foundry-config" +version = "1.4.1" +source = "git+https://github.com/foundry-rs/foundry.git?tag=v1.4.1#cf7746048646f2ecff48246dd61e265e49ab16f0" +dependencies = [ + "alloy-chains", + "alloy-primitives", + "clap", + "dirs", + "dunce", + "eyre", + "figment", + "foundry-block-explorers", + "foundry-compilers", + "glob", + "globset", + "heck", + "itertools 0.14.0", + "mesc", + "number_prefix", + "path-slash", + "rayon", + "regex", + "reqwest", + "revm 29.0.1", + "semver 1.0.26", + "serde", + "serde_json", + "solar-compiler", + "soldeer-core", + "thiserror 2.0.17", + "toml 0.9.11+spec-1.1.0", + "toml_edit 0.23.10+spec-1.0.0", + "tracing", + "walkdir", + "yansi", +] + [[package]] name = "funty" version = "2.0.0" @@ -2520,10 +2680,23 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +[[package]] +name = "globset" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + [[package]] name = "gmp-mpfr-sys" version = "1.6.8" -source = "git+ssh://git@github.com/Entropy-Foundation/bicycl-rs?rev=05f9c22eef4c30f55e9633640269e7c9296510f0#05f9c22eef4c30f55e9633640269e7c9296510f0" +source = "git+ssh://git@github.com/Entropy-Foundation/gmp-mpfr-sys?branch=master#6d5c91968d809b692df0abdcc3d93ce3588ff7ad" dependencies = [ "cc", "libc", @@ -2541,6 +2714,25 @@ dependencies = [ "subtle", ] +[[package]] +name = "h2" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.12.1", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.6.0" @@ -2630,6 +2822,15 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "http" version = "1.3.1" @@ -2679,6 +2880,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2", "http", "http-body", "httparse", @@ -2742,9 +2944,11 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2 0.5.10", + "system-configuration", "tokio", "tower-service", "tracing", + "windows-registry", ] [[package]] @@ -2884,6 +3088,22 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "ignore" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -2904,6 +3124,12 @@ dependencies = [ "syn 2.0.103", ] +[[package]] +name = "indenter" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" + [[package]] name = "index_vec" version = "0.1.4" @@ -2947,6 +3173,12 @@ dependencies = [ "web-time", ] +[[package]] +name = "inlinable_string" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" + [[package]] name = "inturn" version = "0.1.2" @@ -3037,10 +3269,12 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" dependencies = [ + "cfg-if", + "futures-util", "once_cell", "wasm-bindgen", ] @@ -3103,9 +3337,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.174" +version = "0.2.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" [[package]] name = "libm" @@ -3193,9 +3427,12 @@ dependencies = [ [[package]] name = "log" -version = "0.4.27" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +dependencies = [ + "value-bag", +] [[package]] name = "lru" @@ -3229,6 +3466,33 @@ version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +[[package]] +name = "mesc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d04b0347d2799ef17df4623dbcb03531031142105168e0c549e0bf1f980e9e7e" +dependencies = [ + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -3319,9 +3583,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" [[package]] name = "num-integer" @@ -3417,9 +3681,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "once_cell_polyfill" @@ -3452,7 +3716,7 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "auto_impl", - "revm", + "revm 29.0.0", "rstest", "serde", "serde_json", @@ -3717,6 +3981,29 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" +[[package]] +name = "pear" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi", +] + +[[package]] +name = "pear_codegen" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.103", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -3725,12 +4012,11 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.8.1" +version = "2.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" dependencies = [ "memchr", - "thiserror", "ucd-trie", ] @@ -3864,9 +4150,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.11.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "potential_utf" @@ -3892,6 +4178,16 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "prettyplease" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837b9e10d61f45f987d50808f83d1ee3d206c66acf650c3e4ae2e1f6ddedf55" +dependencies = [ + "proc-macro2", + "syn 2.0.103", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -3918,7 +4214,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ - "toml_edit", + "toml_edit 0.22.27", ] [[package]] @@ -3952,6 +4248,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.103", + "version_check", + "yansi", +] + [[package]] name = "proptest" version = "1.7.0" @@ -4003,7 +4312,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2 0.6.1", - "thiserror", + "thiserror 2.0.17", "tokio", "tracing", "web-time", @@ -4024,7 +4333,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.17", "tinyvec", "tracing", "web-time", @@ -4183,7 +4492,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -4208,9 +4517,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", @@ -4220,9 +4529,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -4249,7 +4558,11 @@ checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813" dependencies = [ "base64", "bytes", + "encoding_rs", + "futures-channel", "futures-core", + "futures-util", + "h2", "http", "http-body", "http-body-util", @@ -4259,6 +4572,8 @@ dependencies = [ "hyper-util", "js-sys", "log", + "mime", + "mime_guess", "native-tls", "percent-encoding", "pin-project-lite", @@ -4273,12 +4588,14 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls", + "tokio-util", "tower", "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "webpki-roots", ] @@ -4287,21 +4604,40 @@ dependencies = [ name = "revm" version = "29.0.0" dependencies = [ - "revm-bytecode", - "revm-context", - "revm-context-interface", - "revm-database", - "revm-database-interface", - "revm-handler", - "revm-inspector", - "revm-interpreter", - "revm-precompile", - "revm-primitives", - "revm-state", + "revm-bytecode 6.2.2", + "revm-context 9.0.2", + "revm-context-interface 10.1.0", + "revm-database 7.0.5", + "revm-database-interface 7.0.5", + "revm-handler 10.0.0", + "revm-inspector 10.0.0", + "revm-interpreter 25.0.2", + "revm-precompile 27.0.0", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "serde", "serde_json", ] +[[package]] +name = "revm" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "718d90dce5f07e115d0e66450b1b8aa29694c1cf3f89ebddaddccc2ccbd2f13e" +dependencies = [ + "revm-bytecode 6.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-context 9.1.0", + "revm-context-interface 10.2.0", + "revm-database 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-database-interface 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-handler 10.0.1", + "revm-inspector 10.0.1", + "revm-interpreter 25.0.3", + "revm-precompile 27.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-state 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-bytecode" version = "6.2.2" @@ -4309,10 +4645,20 @@ dependencies = [ "bitvec", "paste", "phf", - "revm-primitives", + "revm-primitives 20.2.1", "serde", ] +[[package]] +name = "revm-bytecode" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c52031b73cae95d84cd1b07725808b5fd1500da3e5e24574a3b2dc13d9f16d" +dependencies = [ + "bitvec", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-context" version = "9.0.2" @@ -4320,15 +4666,31 @@ dependencies = [ "bitvec", "cfg-if", "derive-where", - "revm-bytecode", - "revm-context-interface", - "revm-database", - "revm-database-interface", - "revm-primitives", - "revm-state", + "revm-bytecode 6.2.2", + "revm-context-interface 10.1.0", + "revm-database 7.0.5", + "revm-database-interface 7.0.5", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "serde", ] +[[package]] +name = "revm-context" +version = "9.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a20c98e7008591a6f012550c2a00aa36cba8c14cc88eb88dec32eb9102554b4" +dependencies = [ + "bitvec", + "cfg-if", + "derive-where", + "revm-bytecode 6.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-context-interface 10.2.0", + "revm-database-interface 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-state 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-context-interface" version = "10.1.0" @@ -4337,12 +4699,27 @@ dependencies = [ "alloy-eip7702", "auto_impl", "either", - "revm-database-interface", - "revm-primitives", - "revm-state", + "revm-database-interface 7.0.5", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "serde", ] +[[package]] +name = "revm-context-interface" +version = "10.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b50d241ed1ce647b94caf174fcd0239b7651318b2c4c06b825b59b973dfb8495" +dependencies = [ + "alloy-eip2930", + "alloy-eip7702", + "auto_impl", + "either", + "revm-database-interface 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-state 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-database" version = "7.0.5" @@ -4350,27 +4727,51 @@ dependencies = [ "alloy-eips", "alloy-provider", "alloy-transport", - "revm-bytecode", - "revm-database-interface", - "revm-primitives", - "revm-state", + "revm-bytecode 6.2.2", + "revm-database-interface 7.0.5", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "serde", "serde_json", "tokio", ] +[[package]] +name = "revm-database" +version = "7.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a276ed142b4718dcf64bc9624f474373ed82ef20611025045c3fb23edbef9c" +dependencies = [ + "revm-bytecode 6.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-database-interface 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-state 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-database-interface" version = "7.0.5" dependencies = [ "auto_impl", "either", - "revm-primitives", - "revm-state", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "serde", "tokio", ] +[[package]] +name = "revm-database-interface" +version = "7.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c523c77e74eeedbac5d6f7c092e3851dbe9c7fec6f418b85992bd79229db361" +dependencies = [ + "auto_impl", + "either", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-state 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-ee-tests" version = "0.1.0" @@ -4378,7 +4779,7 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "op-revm", - "revm", + "revm 29.0.0", "rstest", "serde", "serde_json", @@ -4395,46 +4796,91 @@ dependencies = [ "alloy-signer-local", "auto_impl", "derive-where", - "revm-bytecode", - "revm-context", - "revm-context-interface", - "revm-database", - "revm-database-interface", - "revm-interpreter", - "revm-precompile", - "revm-primitives", - "revm-state", + "revm-bytecode 6.2.2", + "revm-context 9.0.2", + "revm-context-interface 10.1.0", + "revm-database 7.0.5", + "revm-database-interface 7.0.5", + "revm-interpreter 25.0.2", + "revm-precompile 27.0.0", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "serde", ] +[[package]] +name = "revm-handler" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "550331ea85c1d257686e672081576172fe3d5a10526248b663bbf54f1bef226a" +dependencies = [ + "auto_impl", + "derive-where", + "revm-bytecode 6.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-context 9.1.0", + "revm-context-interface 10.2.0", + "revm-database-interface 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-interpreter 25.0.3", + "revm-precompile 27.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-state 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-inspector" version = "10.0.0" dependencies = [ "auto_impl", "either", - "revm-context", - "revm-database", - "revm-database-interface", - "revm-handler", - "revm-interpreter", - "revm-primitives", - "revm-state", + "revm-context 9.0.2", + "revm-database 7.0.5", + "revm-database-interface 7.0.5", + "revm-handler 10.0.0", + "revm-interpreter 25.0.2", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "serde", "serde_json", ] +[[package]] +name = "revm-inspector" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c0a6e9ccc2ae006f5bed8bd80cd6f8d3832cd55c5e861b9402fdd556098512f" +dependencies = [ + "auto_impl", + "either", + "revm-context 9.1.0", + "revm-database-interface 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-handler 10.0.1", + "revm-interpreter 25.0.3", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-state 7.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-interpreter" version = "25.0.2" dependencies = [ "bincode 2.0.1", - "revm-bytecode", - "revm-context-interface", - "revm-primitives", + "revm-bytecode 6.2.2", + "revm-context-interface 10.1.0", + "revm-primitives 20.2.1", "serde", ] +[[package]] +name = "revm-interpreter" +version = "25.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06575dc51b1d8f5091daa12a435733a90b4a132dca7ccee0666c7db3851bc30c" +dependencies = [ + "revm-bytecode 6.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-context-interface 10.2.0", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-precompile" version = "27.0.0" @@ -4456,7 +4902,7 @@ dependencies = [ "libsecp256k1", "p256", "rand 0.9.1", - "revm-primitives", + "revm-primitives 20.2.1", "ripemd", "rstest", "rug", @@ -4465,6 +4911,27 @@ dependencies = [ "substrate-bn", ] +[[package]] +name = "revm-precompile" +version = "27.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b57d4bd9e6b5fe469da5452a8a137bc2d030a3cd47c46908efc615bbc699da" +dependencies = [ + "ark-bls12-381", + "ark-bn254", + "ark-ec", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "arrayref", + "aurora-engine-modexp", + "cfg-if", + "k256", + "p256", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ripemd", + "sha2 0.10.9", +] + [[package]] name = "revm-primitives" version = "20.2.1" @@ -4475,25 +4942,47 @@ dependencies = [ "serde", ] +[[package]] +name = "revm-primitives" +version = "20.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa29d9da06fe03b249b6419b33968ecdf92ad6428e2f012dc57bcd619b5d94e" +dependencies = [ + "alloy-primitives", + "num_enum", + "once_cell", +] + [[package]] name = "revm-state" version = "7.0.5" dependencies = [ "bitflags", - "revm-bytecode", - "revm-primitives", + "revm-bytecode 6.2.2", + "revm-primitives 20.2.1", "serde", ] +[[package]] +name = "revm-state" +version = "7.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f64fbacb86008394aaebd3454f9643b7d5a782bd251135e17c5b33da592d84d" +dependencies = [ + "bitflags", + "revm-bytecode 6.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "revm-primitives 20.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "revm-statetest-types" version = "9.0.2" dependencies = [ "k256", - "revm", + "revm 29.0.0", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -4507,15 +4996,19 @@ dependencies = [ "alloy-serde", "alloy-sol-types", "anyhow", + "bincode 2.0.1", "derive-getters", "derive_more", "foundry-compilers", - "revm-context", - "revm-primitives", + "foundry-config", + "once_cell", + "revm-context 9.0.2", + "revm-primitives 20.2.1", "serde", "serde_json", - "thiserror", - "toml", + "serde_with", + "thiserror 2.0.17", + "toml 0.9.11+spec-1.1.0", ] [[package]] @@ -4531,19 +5024,19 @@ dependencies = [ "indicatif", "k256", "plain_hasher", - "revm", - "revm-bytecode", - "revm-context", - "revm-context-interface", - "revm-database", - "revm-database-interface", - "revm-inspector", - "revm-primitives", - "revm-state", + "revm 29.0.0", + "revm-bytecode 6.2.2", + "revm-context 9.0.2", + "revm-context-interface 10.1.0", + "revm-database 7.0.5", + "revm-database-interface 7.0.5", + "revm-inspector 10.0.0", + "revm-primitives 20.2.1", + "revm-state 7.0.5", "revm-statetest-types", "serde", "serde_json", - "thiserror", + "thiserror 2.0.17", "triehash", "walkdir", ] @@ -4793,6 +5286,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sanitize-filename" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc984f4f9ceb736a7bb755c3e3bd17dc56370af2600c9780dcc48c66453da34d" +dependencies = [ + "regex", +] + [[package]] name = "schannel" version = "0.1.27" @@ -4814,6 +5316,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "schemars" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -4984,6 +5498,15 @@ dependencies = [ "syn 2.0.103", ] +[[package]] +name = "serde_fmt" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e497af288b3b95d067a23a4f749f2861121ffcb2f6d8379310dcda040c345ed" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_json" version = "1.0.149" @@ -4998,6 +5521,15 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "serde_spanned" version = "1.0.4" @@ -5021,18 +5553,18 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.13.0" +version = "3.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf65a400f8f66fb7b0552869ad70157166676db75ed8181f8104ea91cf9d0b42" +checksum = "dd5414fad8e6907dbdd5bc441a50ae8d6e26151a03b1de04d89a5576de61d01f" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", "indexmap 2.12.1", - "schemars", - "serde", - "serde_derive", + "schemars 0.9.0", + "schemars 1.2.1", + "serde_core", "serde_json", "serde_with_macros", "time", @@ -5040,11 +5572,11 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.13.0" +version = "3.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81679d9ed988d5e9a5e6531dc3f2c28efbd639cbd1dfb628df08edea6004da77" +checksum = "d3db8978e608f1fe7357e211969fd9abdcae80bac1ba7a3369bb7eb6b404eb65" dependencies = [ - "darling 0.20.11", + "darling 0.23.0", "proc-macro2", "quote", "syn 2.0.103", @@ -5120,6 +5652,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + [[package]] name = "signature" version = "2.2.0" @@ -5258,7 +5800,7 @@ dependencies = [ "solar-config", "solar-data-structures", "solar-macros", - "thiserror", + "thiserror 2.0.17", "tracing", "unicode-width", ] @@ -5323,6 +5865,37 @@ dependencies = [ "tracing", ] +[[package]] +name = "soldeer-core" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6956940ce1436c00d50847e78c703375922d25130041a97f57508dee5f3952" +dependencies = [ + "bon", + "chrono", + "const-hex", + "derive_more", + "dunce", + "home", + "ignore", + "log", + "path-slash", + "rayon", + "regex", + "reqwest", + "sanitize-filename", + "semver 1.0.26", + "serde", + "serde_json", + "sha2 0.10.9", + "thiserror 2.0.17", + "tokio", + "toml_edit 0.23.10+spec-1.0.0", + "uuid", + "zip", + "zip-extract", +] + [[package]] name = "sp1-lib" version = "5.0.5" @@ -5444,6 +6017,84 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "sval" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb9318255ebd817902d7e279d8f8e39b35b1b9954decd5eb9ea0e30e5fd2b6a" + +[[package]] +name = "sval_buffer" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12571299185e653fdb0fbfe36cd7f6529d39d4e747a60b15a3f34574b7b97c61" +dependencies = [ + "sval", + "sval_ref", +] + +[[package]] +name = "sval_dynamic" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39526f24e997706c0de7f03fb7371f7f5638b66a504ded508e20ad173d0a3677" +dependencies = [ + "sval", +] + +[[package]] +name = "sval_fmt" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "933dd3bb26965d682280fcc49400ac2a05036f4ee1e6dbd61bf8402d5a5c3a54" +dependencies = [ + "itoa", + "ryu", + "sval", +] + +[[package]] +name = "sval_json" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0cda08f6d5c9948024a6551077557b1fdcc3880ff2f20ae839667d2ec2d87ed" +dependencies = [ + "itoa", + "ryu", + "sval", +] + +[[package]] +name = "sval_nested" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d49d5e6c1f9fd0e53515819b03a97ca4eb1bff5c8ee097c43391c09ecfb19f" +dependencies = [ + "sval", + "sval_buffer", + "sval_ref", +] + +[[package]] +name = "sval_ref" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14f876c5a78405375b4e19cbb9554407513b59c93dea12dc6a4af4e1d30899ca" +dependencies = [ + "sval", +] + +[[package]] +name = "sval_serde" +version = "2.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9ccd3b7f7200239a655e517dd3fd48d960b9111ad24bd6a5e055bef17607c7" +dependencies = [ + "serde_core", + "sval", + "sval_nested", +] + [[package]] name = "svm-rs" version = "0.5.23" @@ -5458,11 +6109,23 @@ dependencies = [ "serde_json", "sha2 0.10.9", "tempfile", - "thiserror", + "thiserror 2.0.17", "url", "zip", ] +[[package]] +name = "svm-rs-builds" +version = "0.5.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab96ac3275ad299c6e5455b69a2f72443c4d3afb4933d92a0f859d48432dea49" +dependencies = [ + "const-hex", + "semver 1.0.26", + "serde_json", + "svm-rs", +] + [[package]] name = "syn" version = "1.0.109" @@ -5517,6 +6180,27 @@ dependencies = [ "syn 2.0.103", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -5536,13 +6220,33 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.103", ] [[package]] @@ -5576,30 +6280,30 @@ dependencies = [ [[package]] name = "time" -version = "0.3.41" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" dependencies = [ "deranged", "itoa", "num-conv", "powerfmt", - "serde", + "serde_core", "time-core", "time-macros", ] [[package]] name = "time-core" -version = "0.1.4" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" -version = "0.2.22" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" dependencies = [ "num-conv", "time-core", @@ -5659,6 +6363,7 @@ dependencies = [ "libc", "mio", "pin-project-lite", + "signal-hook-registry", "socket2 0.6.1", "tokio-macros", "windows-sys 0.61.2", @@ -5720,6 +6425,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", + "toml_edit 0.22.27", +] + [[package]] name = "toml" version = "0.9.11+spec-1.1.0" @@ -5728,7 +6445,7 @@ checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" dependencies = [ "indexmap 2.12.1", "serde_core", - "serde_spanned", + "serde_spanned 1.0.4", "toml_datetime 0.7.5+spec-1.1.0", "toml_parser", "toml_writer", @@ -5740,6 +6457,9 @@ name = "toml_datetime" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] [[package]] name = "toml_datetime" @@ -5757,7 +6477,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap 2.12.1", + "serde", + "serde_spanned 0.6.9", "toml_datetime 0.6.11", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.23.10+spec-1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" +dependencies = [ + "indexmap 2.12.1", + "serde_core", + "serde_spanned 1.0.4", + "toml_datetime 0.7.5+spec-1.1.0", + "toml_parser", + "toml_writer", "winnow", ] @@ -5770,6 +6508,12 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "toml_writer" version = "1.0.6+spec-1.1.0" @@ -5878,6 +6622,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "typenum" version = "1.18.0" @@ -5908,6 +6658,21 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" +[[package]] +name = "uncased" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + [[package]] name = "unicode-ident" version = "1.0.18" @@ -5975,6 +6740,7 @@ checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ "getrandom 0.3.3", "js-sys", + "serde_core", "wasm-bindgen", ] @@ -5984,6 +6750,42 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "value-bag" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ba6f5989077681266825251a52748b8c1d8a4ad098cc37e440103d0ea717fc0" +dependencies = [ + "value-bag-serde1", + "value-bag-sval2", +] + +[[package]] +name = "value-bag-serde1" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16530907bfe2999a1773ca5900a65101e092c70f642f25cc23ca0c43573262c5" +dependencies = [ + "erased-serde", + "serde_core", + "serde_fmt", +] + +[[package]] +name = "value-bag-sval2" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d00ae130edd690eaa877e4f40605d534790d1cf1d651e7685bd6a144521b251f" +dependencies = [ + "sval", + "sval_buffer", + "sval_dynamic", + "sval_fmt", + "sval_json", + "sval_ref", + "sval_serde", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -6047,48 +6849,32 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn 2.0.103", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "f371d383f2fb139252e0bfac3b81b265689bf45b6874af544ffa4c975ac1ebf8" dependencies = [ - "cfg-if", "js-sys", - "once_cell", "wasm-bindgen", - "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6096,26 +6882,39 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn 2.0.103", - "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmtimer" version = "0.4.2" @@ -6132,9 +6931,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "4f2dfbb17949fa2088e5d39408c48368947b86f7834484e87b73de55bc14d97d" dependencies = [ "js-sys", "wasm-bindgen", @@ -6183,9 +6982,9 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.60.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", @@ -6194,9 +6993,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.59.1" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", @@ -6215,6 +7014,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-registry" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" +dependencies = [ + "windows-link 0.1.3", + "windows-result", + "windows-strings", +] + [[package]] name = "windows-result" version = "0.3.4" @@ -6442,6 +7252,9 @@ name = "yansi" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +dependencies = [ + "is-terminal", +] [[package]] name = "yoke" @@ -6575,6 +7388,17 @@ dependencies = [ "zopfli", ] +[[package]] +name = "zip-extract" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fa5b9958fd0b5b685af54f2c3fa21fca05fe295ebaf3e77b6d24d96c4174037" +dependencies = [ + "log", + "thiserror 2.0.17", + "zip", +] + [[package]] name = "zlib-rs" version = "0.5.5" diff --git a/Cargo.toml b/Cargo.toml index efa6ca54b4..b7f84befb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,11 +81,12 @@ alloy = { version = "1.0.19", features = ["sol-types", "contract"] } alloy-serde = { version = "1.0.19" } # libraries required to build supra-contract bindings -# For more detaisl see crates/supra-extension/build.rs +# For more details see crates/supra-extension/build.rs #forge = { git = "https://github.com/foundry-rs/foundry.git", tag="v1.4.1"} #alloy-chains = { version = "0.2.13" } #shlex = { version = "1.3.0" } foundry-compilers = "0.19.14" +foundry-config = { git = "https://github.com/foundry-rs/foundry.git", tag="v1.4.1"} toml = { version = "0.9.8"} # precompiles @@ -120,6 +121,7 @@ criterion = { package = "codspeed-criterion-compat", version = "2.10" } # serde serde = { version = "1.0", default-features = false } serde_json = { version = "1.0.149", default-features = false } +serde_with = "3.18.0" # misc auto_impl = "1.3.0" diff --git a/crates/handler/src/handler.rs b/crates/handler/src/handler.rs index 09f0c1eb5e..7b01935165 100644 --- a/crates/handler/src/handler.rs +++ b/crates/handler/src/handler.rs @@ -14,6 +14,8 @@ use interpreter::interpreter_action::FrameInit; use interpreter::{Gas, InitialAndFloorGas, SharedMemory}; use primitives::supra_constants::{is_supra_reserved, is_vm_signer}; use primitives::U256; +use std::format; +use std::string::String; /// Trait for errors that can occur during EVM execution. /// diff --git a/crates/supra-extension/Cargo.toml b/crates/supra-extension/Cargo.toml index 254c2b5133..66b3a9a806 100644 --- a/crates/supra-extension/Cargo.toml +++ b/crates/supra-extension/Cargo.toml @@ -29,6 +29,7 @@ foundry-compilers = { workspace = true } serde_json = { workspace = true } bincode = { workspace = true , features = ["serde"]} once_cell = { workspace = true } +serde_with = { workspace = true , features = ["hex"]} [lints] workspace = true @@ -39,6 +40,7 @@ workspace = true #clap = { workspace = true } #shlex = { workspace = true } foundry-compilers = { workspace = true } +foundry-config = { workspace = true } anyhow = { workspace = true } toml = { workspace = true } serde = {workspace = true } diff --git a/crates/supra-extension/build.rs b/crates/supra-extension/build.rs index 3c4eed76da..5a6b8f60ed 100644 --- a/crates/supra-extension/build.rs +++ b/crates/supra-extension/build.rs @@ -2,14 +2,14 @@ use anyhow::Result; use bincode; -use foundry_compilers::artifacts::Remapping; -use foundry_compilers::multi::MultiCompilerSettings; -use foundry_compilers::solc::SolcSettings; -use foundry_compilers::{utils, Project, ProjectPathsConfig}; +use foundry_compilers::utils; +use foundry_config::Config; use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; use std::env; use std::path::Path; use std::path::PathBuf; +use std::process::Command; const CURRENT_DIR: &str = env!("CARGO_MANIFEST_DIR"); @@ -58,10 +58,14 @@ fn rebuild_rust_bindings() { #[derive(Serialize, Deserialize, Debug)] struct CompileConfig { - dapp_relative_path: PathBuf, - solc_settings: SolcSettings, - #[serde(default)] - remappings: Vec<(String, String)>, + /// Supra contracts relative path + supra_dapp_path: PathBuf, + /// Supra nova dapp repository + supra_nova_repo: String, + /// Supra nova dapp tag to reference to + supra_nova_tag: String, + /// Supra nova dapp relative path in repo + supra_nova_dapp_path: String, } impl CompileConfig { @@ -72,45 +76,70 @@ impl CompileConfig { .inspect_err(|e| println!("Error: {}", e)) } - fn dapp_path(&self) -> PathBuf { - utils::canonicalize(Path::new(CURRENT_DIR).join(&self.dapp_relative_path)) + fn supra_contracts_dapp_path(&self) -> PathBuf { + utils::canonicalize(Path::new(CURRENT_DIR).join(&self.supra_dapp_path)) .expect("failed to canonicalize dapp path") } - fn remappings(&self) -> Vec { - self.remappings - .iter() - .map(|(name, rel_path)| Remapping { - context: None, - name: name.clone(), - path: self - .dapp_path() - .join(rel_path) - .to_string_lossy() - .into_owned(), - }) - .collect() + fn supra_nova_dapp_path(&self) -> Result { + self.checkout_supra_nova_repo() + .map(|path| path.join(self.supra_nova_dapp_path.clone())) } - fn to_multi_compiler_settings(self) -> MultiCompilerSettings { - let mut settings = MultiCompilerSettings::default(); - settings.solc = self.solc_settings; - settings - } -} + fn checkout_supra_nova_repo(&self) -> Result { + let out_dir = env::var("OUT_DIR")?; + let repo_dir = Path::new(&out_dir).join("supranova-contracts"); + + if repo_dir.exists() { + // Check whether the already-cloned repo is at the right tag. + let output = Command::new("git") + .args(["describe", "--tags", "--exact-match"]) + .current_dir(&repo_dir) + .output()?; + let current_tag = String::from_utf8_lossy(&output.stdout).trim().to_string(); + if current_tag == self.supra_nova_tag { + return Ok(repo_dir); + } + // Wrong tag – remove and re-clone. + std::fs::remove_dir_all(&repo_dir)?; + } + + let status = Command::new("git") + .env( + "GIT_SSH_COMMAND", + "ssh -o BatchMode=yes -o StrictHostKeyChecking=no", + ) + .args([ + "clone", + "--recurse-submodules", + "--branch", + self.supra_nova_tag.as_str(), + "--depth", + "1", + self.supra_nova_repo.as_str(), + repo_dir + .to_str() + .ok_or_else(|| anyhow::anyhow!("non-UTF-8 OUT_DIR path"))?, + ]) + .status()?; -fn compile_contracts() -> Result { - let config = CompileConfig::load()?; + if !status.success() { + return Err(anyhow::anyhow!( + "Failed to clone {} at tag {}", + self.supra_nova_repo, + self.supra_nova_tag + )); + } - let mut paths = ProjectPathsConfig::dapptools(&config.dapp_path())?; - for (idx, value) in config.remappings().into_iter().enumerate() { - paths.remappings.insert(idx, value) + Ok(repo_dir) } +} + +fn compile_contracts(path: &impl AsRef) -> Result { + let foundry_config = Config::load_with_root(path.as_ref())?.sanitized(); + let _ = foundry_config.install_lib_dir(); + let project = foundry_config.project()?; - let project = Project::builder() - .paths(paths) - .settings(config.to_multi_compiler_settings()) - .build(Default::default())?; let output = project.compile()?; let _ = output.succeeded(); // Tell Cargo that if a source file changes, to rerun this build script. @@ -126,24 +155,59 @@ fn compile_contracts() -> Result { Ok(artifacts_dir) } -fn combine_and_dump_contracts_bytecode(artifacts_path: &Path) -> Result<()> { +fn load_supra_contracts_bytecode( + artifacts_path: &Path, + bytecodes: &mut BTreeMap>, +) -> Result<()> { // Contract names to load - let contract_names = vec![ + let contract_names = [ "MultiSignatureWallet", "MultisigBeacon", "BeaconProxy", "ERC20Supra", + "ERC20SupraHandler", "BlockMeta", "ERC1967Proxy", - "AutomationCore", - "AutomationRegistry", - "AutomationController", + "DiamondCutFacet", + "Diamond", + "DiamondLoupeFacet", + "OwnershipFacet", + "ConfigFacet", + "RegistryFacet", + "CoreFacet", + "DiamondInit", ]; + load_contracts_bytecode(&contract_names, artifacts_path, bytecodes) +} - let mut bytecodes = std::collections::BTreeMap::new(); +fn load_supra_nova_contracts_bytecode( + artifacts_path: &Path, + bytecodes: &mut BTreeMap>, +) -> Result<()> { + // Contract names to load + let contract_names = [ + "WrappedToken", // Impl + "WrappedTokenFactory", // Beacon + "WrappedTokenFactoryProxy", // Beacon Proxy + "TokenVault", + "TokenVaultProxy", + "Hypernova", + "HypernovaProxy", + "FeeOperator", + "FeeOperatorProxy", + "TokenBridge", + "TokenBridgeProxy", + ]; + load_contracts_bytecode(&contract_names, artifacts_path, bytecodes) +} +fn load_contracts_bytecode( + contract_names: &[&'static str], + artifacts_path: &Path, + bytecodes: &mut BTreeMap>, +) -> Result<()> { // Load each contract's bytecode - for contract_name in &contract_names { + for contract_name in contract_names { let path = artifacts_path .join(format!("{contract_name}.sol")) .join(format!("{contract_name}.json")); @@ -169,12 +233,22 @@ fn combine_and_dump_contracts_bytecode(artifacts_path: &Path) -> Result<()> { anyhow::anyhow!("Failed to load bytecode for contract: {contract_name}") })?; - bytecodes.insert(contract_name.to_string(), bytecode); + let inserted = bytecodes.insert(contract_name.to_string(), bytecode); + if inserted.is_some() { + return Err(anyhow::anyhow!( + "Duplicate contract name: {contract_name} in {artifacts_path:?} path" + )); + } } + Ok(()) +} +fn dump_bytecodes(bytecodes: BTreeMap>, bin_file_name: &str) -> Result<()> { // Dump the combined contract bytecodes to be loaded at compile to by generator. let out_dir = env::var("OUT_DIR")?; - let out_path = Path::new(&out_dir).join("contract_bytecodes.bin"); + let out_path = Path::new(&out_dir) + .join(bin_file_name) + .with_extension("bin"); std::fs::write( &out_path, @@ -183,17 +257,27 @@ fn combine_and_dump_contracts_bytecode(artifacts_path: &Path) -> Result<()> { ) .expect("Failed to write bytecodes to file"); - println!("cargo:rustc-env=CONTRACTS_LOADED=1"); + println!("cargo:rustc-env=CONTRACTS_DUMPED=1"); Ok(()) } fn main() { rebuild_rust_bindings(); - let artifacts_dir = compile_contracts() - .inspect_err(|e| panic!("{e:?}")) - .unwrap(); - combine_and_dump_contracts_bytecode(&artifacts_dir) - .inspect_err(|e| panic!("Failed to combine and dump contract bytecodes: {e:?}")) - .unwrap() + let config = CompileConfig::load().expect("Config should always be valid"); + let supra_contracts_artifacts = compile_contracts(&config.supra_contracts_dapp_path()) + .expect("Successful supra contracts compilation"); + let supra_nova_artifacts = compile_contracts( + &config + .supra_nova_dapp_path() + .expect("Successful supra nova dapp path resolve"), + ) + .expect("Successful supra nova contracts compilation"); + let mut contracts_bytecode = BTreeMap::new(); + load_supra_contracts_bytecode(&supra_contracts_artifacts, &mut contracts_bytecode) + .expect("Supra contracts loaded successfully"); + load_supra_nova_contracts_bytecode(&supra_nova_artifacts, &mut contracts_bytecode) + .expect("Supra nova contracts loaded successfully"); + dump_bytecodes(contracts_bytecode, "supra_contracts_bytecode") + .expect("Bytecodes dumped successfully"); } diff --git a/crates/supra-extension/compile_config.toml b/crates/supra-extension/compile_config.toml index e43581cc69..d44c795ac1 100644 --- a/crates/supra-extension/compile_config.toml +++ b/crates/supra-extension/compile_config.toml @@ -1,14 +1,7 @@ -dapp_relative_path = "../../solidity/supra_contracts/" -remappings = [["@openzeppelin/contracts/", "lib/openzeppelin-contracts/contracts/"]] +supra_dapp_path = "../../solidity/supra_contracts/" -[solc_settings] -evmVersion = "prague" -viaIR = true +supra_nova_repo = "git@github.com:Entropy-Foundation/supranova-contracts-private.git" +supra_nova_tag = "supranova-evm-v2.0.0-beta.1" +supra_nova_dapp_path = "hypernova/evm" -[solc_settings.optimizer] -enabled = true -runs = 200 -[solc_settings.outputSelection."*"] -"" = ["ast"] -"*" = ["abi", "evm.bytecode.object"] diff --git a/crates/supra-extension/src/contracts/configs.rs b/crates/supra-extension/src/contracts/configs.rs index 58f6a4f5a6..5b3b2068ef 100644 --- a/crates/supra-extension/src/contracts/configs.rs +++ b/crates/supra-extension/src/contracts/configs.rs @@ -1,9 +1,10 @@ //! Configurations to generate genesis transactions -use primitives::Address; +use serde::{Deserialize, Serialize}; +use primitives::{address, Address}; /// Configuration parameters for Automation Registry contracts initialization -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct AutomationRegistryConfigV1 { /// Maximum allowable duration (in seconds) from the registration time that a user automation task can run. pub task_duration_cap_secs: u64, @@ -59,7 +60,7 @@ impl Default for AutomationRegistryConfigV1 { } /// Configuration parameters for Automation Registry contracts initialization -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub enum AutomationRegistryConfig { /// First version of the evm automation registry contract configurations V1(AutomationRegistryConfigV1), @@ -79,8 +80,62 @@ impl From for AutomationRegistryConfig { } } +/// Configuration to generate supra-nova contracts for genesis +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SupraNovaConfig { + /// Dora storage addressed utilized by fee operator. + pub dora_storage_address: Address, + /// WETH9 address utilized by token vault and token bridge. + pub weth9_address: Address, + /// Hypernova message index. + pub hypernova_msg_id: u64, + /// USDT pair index in Dora. + pub supra_usdt_pair_idx: u64, + /// Maximum stale oracle price limit. + pub max_stale_oracle_price_limit: u64, +} + +impl Default for SupraNovaConfig { + fn default() -> Self { + Self { + dora_storage_address: Self::DORA_STORAGE_TESTNET, + weth9_address: Self::WETH9_TESTNET, + hypernova_msg_id: 0, + supra_usdt_pair_idx: Self::SUPRA_USDT_PAIR_INDEX, + max_stale_oracle_price_limit: Self::MAX_STALE_ORACLE_PRICE_LIMIT, + } + } +} + + +impl SupraNovaConfig { + pub(crate) const WRAPPED_TOKEN_IMPL_SALT: &'static str = "supranova.WrappedToken.v1"; + pub(crate) const WRAPPED_TOKEN_FACTORY_IMPL_SALT:&'static str = "supranova.WrappedTokenFactory.v1"; + pub(crate) const WRAPPED_TOKEN_FACTORY_PROXY_SALT: &'static str = "supranova.WrappedTokenFactoryProxy.v1"; + + pub(crate) const HYPER_NOVA_IMPL_SALT: &'static str = "supranova.Hypernova.v2"; + pub(crate) const HYPER_NOVA_PROXY_SALT: &'static str = "supranova.HypernovaProxy.v2"; + + pub(crate) const FEE_OPERATOR_IMPL_SALT: &'static str = "supranova.FeeOperator.v2"; + pub(crate) const FEE_OPERATOR_PROXY_SALT: &'static str = "supranova.FeeOperatorProxy.v2"; + + pub(crate) const DORA_STORAGE_TESTNET: Address = address!("0x131918bC49Bb7de74aC7e19d61A01544242dAA80"); + pub(crate) const SUPRA_USDT_PAIR_INDEX: u64 = 500; + pub(crate) const MAX_STALE_ORACLE_PRICE_LIMIT:u64 = 86400; + + pub(crate) const TOKEN_BRIDGE_IMPL_SALT: &'static str = "supranova.TokenBridge.v2"; + pub(crate) const TOKEN_BRIDGE_PROXY_SALT: &'static str = "supranova.TokenBridgeProxy.v2"; + + pub(crate) const WETH9_TESTNET: Address = address!("0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"); + + + pub(crate) const TOKEN_VAULT_IMPL_SALT: &'static str = "supranova.TokenVault.v2"; + pub(crate) const TOKEN_VAULT_PROXY_SALT: &'static str = "supranova.TokenVaultProxy.v2"; + +} + /// Genesis Transaction generator configuration details -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct GenesisTransactionGeneratorConfig { /// List of EOAs to set up multisig foundation wallet. pub foundation_owners: Vec
, @@ -88,6 +143,12 @@ pub struct GenesisTransactionGeneratorConfig { pub foundation_threshold: u64, /// Flag indicating whether full set of genesis transaction should be generated or only mandatory once. pub full_set: bool, + #[serde(skip_serializing_if = "Option::is_none")] /// Automation configuration parameters (optional, uses defaults if None). pub automation_config: Option, + /// Initial native tokens to be minted to ERC20Supra handler contract + pub initial_native_token: u128, + #[serde(skip_serializing_if = "Option::is_none")] + /// Indicates whether the genesis transactions are generated for localnet. + pub supra_nova_config: Option, } diff --git a/crates/supra-extension/src/contracts/generator.rs b/crates/supra-extension/src/contracts/generator.rs index 9357384eda..1b5faaced6 100644 --- a/crates/supra-extension/src/contracts/generator.rs +++ b/crates/supra-extension/src/contracts/generator.rs @@ -1,19 +1,30 @@ //! Encloses transaction data generation logic based on the genesis contracts -use crate::contracts::configs::{AutomationRegistryConfig, GenesisTransactionGeneratorConfig}; -use crate::contracts::transaction::{GenesisTransaction, GenesisTransactionTags}; +use crate::contracts::configs::{ + AutomationRegistryConfig, GenesisTransactionGeneratorConfig, SupraNovaConfig, +}; +use crate::contracts::supra_nova_contracts::{ + FeeOperator, FeeOperatorProxy, Hypernova, HypernovaProxy, TokenBridge, TokenBridgeProxy, + TokenVault, TokenVaultProxy, WrappedTokenFactory, WrappedTokenFactoryProxy, FEE_OPERATOR, + FEE_OPERATOR_PROXY, HYPERNOVA, HYPERNOVA_PROXY, TOKEN_BRIDGE, TOKEN_BRIDGE_PROXY, TOKEN_VAULT, + TOKEN_VAULT_PROXY, WRAPPED_TOKEN, WRAPPED_TOKEN_FACTORY, WRAPPED_TOKEN_FACTORY_PROXY, +}; +use crate::contracts::transaction::{ + GenesisTransaction, GenesisTransactionTags, CREATE2_FACTORY_ADDRESS, CREATE2_FACTORY_CODE, + CREATE2_FACTORY_OWNER, +}; use alloy::primitives::Address; use alloy_sol_types::{sol, SolCall, SolConstructor}; use anyhow::{anyhow, Result}; use bincode::config; use once_cell::sync::Lazy; use primitives::supra_constants::VM_SIGNER; -use primitives::{Bytes, U256}; +use primitives::{Bytes, TxKind, U256}; use std::collections::BTreeMap; /// Load precompiled combined bytecode of contracts. const CONTRACT_BYTECODES_RAW: &[u8] = - include_bytes!(concat!(env!("OUT_DIR"), "/contract_bytecodes.bin")); + include_bytes!(concat!(env!("OUT_DIR"), "/supra_contracts_bytecode.bin")); const CONTRACT_BYTECODES: Lazy>> = Lazy::new(|| { // Deserialize the bytecodes from the raw bytes @@ -44,9 +55,14 @@ sol! { ///////////////////// ERC20Supra related contracts and init APIs ///////////////////////////// const ERC20_SUPRA: &str = "ERC20Supra"; +const ERC20_SUPRA_HANDLER: &str = "ERC20SupraHandler"; sol! { contract ERC20Supra { - constructor(address _initialOwner); + function initialize(address _initialOwner, address[] memory _authorizedAddresses); + } + + contract ERC20SupraHandler { + function initialize(address _initialOwner, address _erc20Supra); } } @@ -68,13 +84,19 @@ sol! { ///////////////////// Automation related contracts and init APIs ///////////////////////////// -const AUTOMATION_CORE: &str = "AutomationCore"; -const AUTOMATION_REGISTRY: &str = "AutomationRegistry"; -const AUTOMATION_CONTROLLER: &str = "AutomationController"; +const DIAMOND_CUT_FACET: &str = "DiamondCutFacet"; +const DIAMOND: &str = "Diamond"; +const DIAMOND_LOUPE_FACET: &str = "DiamondLoupeFacet"; +const OWNERSHIP_FACET: &str = "OwnershipFacet"; +const CONFIG_FACET: &str = "ConfigFacet"; +const REGISTRY_FACET: &str = "RegistryFacet"; +const CORE_FACET: &str = "CoreFacet"; +const DIAMOND_INIT: &str = "DiamondInit"; sol! { - /// Initialization parameters for AutomationCore contract. - struct InitializeParams { + + /// Initialization parameters for Automation Registry State. + struct InitParams { uint64 taskDurationCapSecs; uint128 registryMaxGasCap; uint128 automationBaseFeeWeiPerSec; @@ -87,33 +109,31 @@ sol! { uint64 sysTaskDurationCapSecs; uint128 sysRegistryMaxGasCap; uint16 sysTaskCapacity; - address vmSigner; - address erc20Supra; - address controller; - address registry; - address owner; + bool registrationEnabled; + bool automationEnabled; } - /// AutomationCore is a UUPS upgradeable contract - constructor has no parameters. - /// Deployed behind ERC1967Proxy. - contract AutomationCore { - constructor(); - function initialize(InitializeParams calldata params); + /// Addresses of the facets for diamond cut and diamond initializer contract + struct FacetsDeployment { + address diamondCutFacet; + address loupeFacet; + address ownershipFacet; + address configFacet; + address registryFacet; + address coreFacet; + address diamondInit; } - /// AutomationRegistry is a UUPS upgradeable contract - constructor has no parameters. - /// Deployed behind ERC1967Proxy. - contract AutomationRegistry { - constructor(); - function initialize(address _automationCore, address _automationController, address _owner); + contract Diamond { + constructor( + address _contractOwner, + FacetsDeployment memory _facets, + address _vmSigner, + address _erc20Supra, + InitParams memory _params + ); } - /// AutomationController is a UUPS upgradeable contract - constructor has no parameters. - /// Deployed behind ERC1967Proxy. - contract AutomationController { - constructor(); - function initialize(address _automationCore, address _registry, address _owner, bool _automationEnabled, uint64 _cycleDurationSecs); - } } /// Genesis Transaction generator using configured address as transaction owner. @@ -140,6 +160,18 @@ impl GenesisTransactionGenerator { Self { nonce, address } } + /// Generates Create2Factory contract deployment transaction. + fn generate_create2_factory_transaction() -> GenesisTransaction { + GenesisTransaction::new( + CREATE2_FACTORY_OWNER, + 0, + 0, + CREATE2_FACTORY_CODE.to_owned(), + TxKind::Create, + CREATE2_FACTORY_ADDRESS, + ) + } + /// Prepares genesis transactions based on the input configuration. pub fn prepare_genesis_transactions( &mut self, @@ -150,25 +182,49 @@ impl GenesisTransactionGenerator { foundation_threshold, full_set, automation_config, + initial_native_token, + supra_nova_config, } = config; - // First foundation multisig account setup should be done - let mut genesis_transactions = - self.setup_multisig_wallet(foundation_owners, foundation_threshold)?; + // First Create2 Factory contract deployment, which will allow later to utilize create2 API + // if required during genesis + let mut genesis_transactions = BTreeMap::from([( + GenesisTransactionTags::Create2Factory, + Self::generate_create2_factory_transaction(), + )]); + // Second multisig contract and foundation multisig account setup should be done + genesis_transactions + .extend(self.setup_multisig_wallet(foundation_owners, foundation_threshold)?); if full_set { let multisig_address = *genesis_transactions .get(&GenesisTransactionTags::FoundationWallet) .expect("Foundation Wallet deployment transaction") .deploy_address(); - let erc20_supra_txn = self.setup_erc20_supra(multisig_address)?; - let erc20_supra_address = *erc20_supra_txn.deploy_address(); - genesis_transactions.insert(GenesisTransactionTags::Erc20Supra, erc20_supra_txn); + + // Erc20 Supra contracts + let erc20_contracts = + self.setup_erc20_contracts(multisig_address, initial_native_token)?; + let erc20supra_address = *erc20_contracts + .get(&GenesisTransactionTags::Erc20Supra) + .expect("Erc20Supra deployment transaction exists") + .deploy_address(); + genesis_transactions.extend(erc20_contracts); + + // BlockMetadata contract genesis_transactions.extend(self.setup_block_metadata(multisig_address)?.into_iter()); + + // Automation registry contracts if let Some(config) = automation_config { genesis_transactions.extend( - self.setup_automation_registry(multisig_address, erc20_supra_address, config)? + self.setup_automation_registry(multisig_address, erc20supra_address, config)? .into_iter(), ); } + + // Supra Nova/Bridge contracts + if let Some(nova_conig) = supra_nova_config { + genesis_transactions + .extend(self.setup_supra_nova_contracts(nova_conig, multisig_address)?); + } }; Ok(genesis_transactions) @@ -202,7 +258,7 @@ impl GenesisTransactionGenerator { // 1. Deploy MultiSignatureWallet implementation (no constructor args) // ------------------------------------------------------------------------- let multisig_impl_create_data = Self::load_contract_bytecode(MULTISIG_WALLET)?; - let multisig_txn = GenesisTransaction::new( + let multisig_txn = GenesisTransaction::create( self.address.clone(), multisig_impl_create_data, self.nonce, @@ -222,7 +278,7 @@ impl GenesisTransactionGenerator { } .abi_encode(); let beacon_txn_data = [multisig_beacon_create_data, beacon_args].concat(); - let multisig_beacon_txn = GenesisTransaction::new( + let multisig_beacon_txn = GenesisTransaction::create( self.address.clone(), beacon_txn_data, self.nonce, @@ -250,7 +306,7 @@ impl GenesisTransactionGenerator { .abi_encode(); // Concatenate bytecode + constructor args for deployment let beacon_proxy_txn_data = [beacon_proxy_create_data, beacon_proxy_args].concat(); - let beacon_proxy_txn = GenesisTransaction::new( + let beacon_proxy_txn = GenesisTransaction::create( self.address.clone(), beacon_proxy_txn_data, self.nonce, @@ -265,42 +321,189 @@ impl GenesisTransactionGenerator { ])) } + /// Generates Erc20Supra and Erc20SupraHandler contracts deployment transactions. + /// Both are ERC1967Proxy upgradeable contracts, and are deployed in the same transaction + /// batch to ensure correct initial authorization setup. + fn setup_erc20_contracts( + &mut self, + owner: Address, + initial_native_tokens: u128, + ) -> Result> { + // Precomputed addresses + // nonce + 0: ERC20Supra Impl + // nonce + 1: ERC20Supra (Proxy) + // nonce + 2: ERC20SupraHandler Impl + // nonce + 3: ERC20SupraHandler (Proxy) + let erc20_supra_address = self.address.create(self.nonce + 1); + let erc20_handler_address = self.address.create(self.nonce + 3); + + // For now only erc20supra handler address is specified as authorized, the bridge one will be specified past deployment + let mut erc20_supra_txn = self.setup_erc20_supra(owner, vec![erc20_handler_address])?; + let gen_erc20_supra_address = *erc20_supra_txn + .get(&GenesisTransactionTags::Erc20Supra) + .expect("Erc20Supra should be deployed") + .deploy_address(); + assert_eq!( + erc20_supra_address, gen_erc20_supra_address, + "Address computed by tag and nonce should be the same" + ); + + let erc20_handler_txn = + self.setup_erc20_supra_handler(owner, gen_erc20_supra_address, initial_native_tokens)?; + let gen_erc20_handler_address = *erc20_handler_txn + .get(&GenesisTransactionTags::Erc20SupraHandler) + .expect("Erc20Supra should be deployed") + .deploy_address(); + assert_eq!( + erc20_handler_address, gen_erc20_handler_address, + "Address computed by tag and nonce should be the same" + ); + + erc20_supra_txn.extend(erc20_handler_txn); + Ok(erc20_supra_txn) + } + /// Generates genesis transaction for ERC20Supra token contract deployment. /// Deployment order follows GenesisTransactionTags: - /// 1. Erc20Supra (3) - ERC20 token contract with constructor(initialOwner) + /// 1. ERC20SupraImpl (nonce+0) - ERC20Supra implementation contract (UUPS upgradeable) + /// 2. ERC20Supra (nonce+1) - ERC1967Proxy with initialize(initialOwner, authorizedAddresses[]) /// - /// This is a non-upgradeable contract deployed directly (not behind a proxy). /// The initial owner (typically the foundation multisig wallet) receives /// administrative privileges over the token contract. - fn setup_erc20_supra(&mut self, initial_owner: Address) -> Result { + fn setup_erc20_supra( + &mut self, + initial_owner: Address, + authorized_addresses: Vec
, + ) -> Result> { // ------------------------------------------------------------------------- // Pre-compute deployment address // ------------------------------------------------------------------------- - let contract_address = self.address.create(self.nonce); + let erc20_supra_address_impl = self.address.create(self.nonce); + let erc20_supra_address = self.address.create(self.nonce + 1); // ------------------------------------------------------------------------- - // Deploy ERC20Supra - // Constructor args: initial owner address + // 1. Deploy ERC20Supra // ------------------------------------------------------------------------- let erc20_contract_create_data = Self::load_contract_bytecode(ERC20_SUPRA)?; - // Encode the constructor args - let erc20_constructor_args = ERC20Supra::constructorCall { + let erc20supra_impl = GenesisTransaction::create( + self.address, + erc20_contract_create_data, + self.nonce, + erc20_supra_address_impl, + ); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 2. Deploy ERC1967Proxy (ERC20Supra) + // Constructor args: implementation address, initialization data + // Initialization data: initialize(initialOwner, authorizedAddresses[]) + // ------------------------------------------------------------------------- + let proxy_impl_data = Self::load_contract_bytecode(ERC1967PROXY)?; + // Encode Erc20Supra initialize call + let erc20_init_args = ERC20Supra::initializeCall { + _initialOwner: initial_owner, + _authorizedAddresses: authorized_addresses, + } + .abi_encode(); + // Encode the ERC1967Proxy constructor args + let proxy_args = ERC1967Proxy::constructorCall { + _impl: erc20_supra_address_impl, + _data: erc20_init_args.into(), + } + .abi_encode(); + // Concatenate bytecode + constructor args for deployment + let proxy_txn_data = [proxy_impl_data, proxy_args].concat(); + let erc20supra = GenesisTransaction::create( + self.address, + proxy_txn_data, + self.nonce, + erc20_supra_address, + ); + self.nonce += 1; + + Ok(BTreeMap::from([ + (GenesisTransactionTags::Erc20SupraImpl, erc20supra_impl), + (GenesisTransactionTags::Erc20Supra, erc20supra), + ])) + } + + /// Generates genesis transaction for ERC20SupraHandler token conversion contract deployment. + /// Deployment order follows GenesisTransactionTags: + /// 1. ERC20SupraHandlerImpl (nonce+0) - ERC20SupraHandler implementation contract (UUPS upgradeable) + /// 2. ERC20SupraHandler (nonce+1) - ERC1967Proxy with initialize(initialOwner, erc20supra) + /// + /// The initial owner (typically the foundation multisig wallet) receives + /// administrative privileges over the token contract. + fn setup_erc20_supra_handler( + &mut self, + initial_owner: Address, + erc20supra: Address, + initial_native_tokens: u128, + ) -> Result> { + // ------------------------------------------------------------------------- + // Pre-compute deployment address + // ------------------------------------------------------------------------- + let erc20_handler_address_impl = self.address.create(self.nonce); + let erc20_handler_address = self.address.create(self.nonce + 1); + + // ------------------------------------------------------------------------- + // 1. Deploy ERC20SupraHandler + // ------------------------------------------------------------------------- + let erc20_contract_create_data = Self::load_contract_bytecode(ERC20_SUPRA_HANDLER)?; + let erc20supra_handler_impl = GenesisTransaction::create( + self.address, + erc20_contract_create_data, + self.nonce, + erc20_handler_address_impl, + ); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 2. Deploy ERC1967Proxy (ERC20SupraHandler) + // Constructor args: implementation address, initialization data + // Initialization data: initialize(initialOwner, erc20supra) + // ------------------------------------------------------------------------- + let proxy_impl_data = Self::load_contract_bytecode(ERC1967PROXY)?; + // Encode Erc20Supra initialize call + let erc20_handler_init_args = ERC20SupraHandler::initializeCall { _initialOwner: initial_owner, + _erc20Supra: erc20supra, + } + .abi_encode(); + // Encode the ERC1967Proxy constructor args + let proxy_args = ERC1967Proxy::constructorCall { + _impl: erc20_handler_address_impl, + _data: erc20_handler_init_args.into(), } .abi_encode(); // Concatenate bytecode + constructor args for deployment - let erc20_txn_data = [erc20_contract_create_data, erc20_constructor_args].concat(); - let txn = - GenesisTransaction::new(self.address, erc20_txn_data, self.nonce, contract_address); + let proxy_txn_data = [proxy_impl_data, proxy_args].concat(); + let erc20supra_handler = GenesisTransaction::new( + self.address, + self.nonce, + initial_native_tokens, + proxy_txn_data, + TxKind::Create, + erc20_handler_address, + ); self.nonce += 1; - Ok(txn) + Ok(BTreeMap::from([ + ( + GenesisTransactionTags::Erc20SupraHandlerImpl, + erc20supra_handler_impl, + ), + ( + GenesisTransactionTags::Erc20SupraHandler, + erc20supra_handler, + ), + ])) } /// Generates genesis transactions for BlockMeta contract deployment. /// Deployment order follows GenesisTransactionTags: - /// 1. BlockMetadataImpl (4) - BlockMeta implementation contract (UUPS upgradeable) - /// 2. BlockMetadata (5) - ERC1967Proxy with initialize(initialOwner) + /// 1. BlockMetadataImpl - BlockMeta implementation contract (UUPS upgradeable) + /// 2. BlockMetadata - ERC1967Proxy with initialize(initialOwner) /// /// BlockMeta is a UUPS upgradeable contract deployed behind an ERC1967Proxy. /// The proxy pattern allows future upgrades while maintaining the same address. @@ -320,7 +523,7 @@ impl GenesisTransactionGenerator { // 1. Deploy BlockMeta implementation (UUPS - no constructor args) // ------------------------------------------------------------------------- let block_metadata_impl = Self::load_contract_bytecode(BLOCK_META)?; - let block_metadata_impl_txn = GenesisTransaction::new( + let block_metadata_impl_txn = GenesisTransaction::create( self.address, block_metadata_impl, self.nonce, @@ -347,7 +550,7 @@ impl GenesisTransactionGenerator { .abi_encode(); // Concatenate bytecode + constructor args for deployment let proxy_txn_data = [proxy_impl_data, proxy_args].concat(); - let block_metadata_proxy_txn = GenesisTransaction::new( + let block_metadata_proxy_txn = GenesisTransaction::create( self.address, proxy_txn_data, self.nonce, @@ -369,14 +572,16 @@ impl GenesisTransactionGenerator { /// Generates genesis transactions for automation contracts deployment. /// Deployment order follows GenesisTransactionTags: - /// 1. AutomationControllerImpl - implementation contract - /// 2. AutomationController - ERC1967Proxy with initialize(automationCore, registry) - /// 3. AutomationCoreImpl - implementation contract - /// 4. AutomationCore - ERC1967Proxy with initialize(InitializeParams) - /// 5. AutomationRegistryImpl - implementation contract - /// 6. AutomationRegistry - ERC1967Proxy with initialize(automationCore, automationController) /// - /// All proxy addresses are pre-computed before deployment to handle circular dependencies. + /// 1. DiamondCutFacet, // Facet contract enabling APIs to extend facets and executed registered facet + /// 2. DiamondLoupeFacet, // Facet providing API to query registered facets + /// 3. OwnershipFacet, // Facet to manage ownership credential updates and checks + /// 4. ConfigFacet, // Facet to manage automation registry configuration + /// 5. RegistryFacet, // Facet providing API for task registration, cancellation and registry state query + /// 6. CoreFacet, // Facet providing API to monitor cycle and initiate bookkeeping on cycle transition + /// 7. DiamondInit, + /// 8. Diamond, // The wrapper contract of all the facets, main entry point of automation registry API + /// All contracts addresses are pre-computed before deployment to handle circular dependencies if any. fn setup_automation_registry( &mut self, owner: Address, @@ -387,37 +592,115 @@ impl GenesisTransactionGenerator { .v1() .ok_or_else(|| anyhow!("Unhandled configuration version"))?; // Pre-compute all deployment addresses - // nonce+0: AutomationCoreImpl - // nonce+1: AutomationCore (proxy) - // nonce+2: AutomationRegistryImpl - // nonce+3: AutomationRegistry (proxy) - // nonce+4: AutomationControllerImpl - // nonce+5: AutomationController (proxy) - let core_impl_address = self.address.create(self.nonce); - let core_proxy_address = self.address.create(self.nonce + 1); - let registry_impl_address = self.address.create(self.nonce + 2); - let registry_proxy_address = self.address.create(self.nonce + 3); - let controller_impl_address = self.address.create(self.nonce + 4); - let controller_proxy_address = self.address.create(self.nonce + 5); - - let proxy_bytecode = Self::load_contract_bytecode(ERC1967PROXY)?; - - // ------------------------------------------------------------------------- - // 1. Deploy AutomationCoreImpl (UUPS - no constructor args) - // ------------------------------------------------------------------------- - let core_impl_bytecode = Self::load_contract_bytecode(AUTOMATION_CORE)?; - let core_impl_txn = GenesisTransaction::new( + // nonce+0: DiamondCutFacet (implementation for Diamond proxy) + // nonce+1: DiamondLoupeFacet + // nonce+2: OwnershipFacet + // nonce+3: ConfigFacet + // nonce+4: RegistryFacet + // nonce+5: CoreFacet + // nonce+6: DiamondInit + // nonce+7: Diamond (proxy to all facets APIs) + + let diamond_cut_facet_addr = self.address.create(self.nonce); + let diamond_loupe_facet_addr = self.address.create(self.nonce + 1); + let ownership_facet_addr = self.address.create(self.nonce + 2); + let config_facet_addr = self.address.create(self.nonce + 3); + let registry_facet_addr = self.address.create(self.nonce + 4); + let core_facet_addr = self.address.create(self.nonce + 5); + let diamond_init_addr = self.address.create(self.nonce + 6); + let diamond_addr = self.address.create(self.nonce + 7); + + // ------------------------------------------------------------------------- + // 1. Deploy DiamondCutFacet (no constructor args) + // ------------------------------------------------------------------------- + let diamond_cut = Self::load_contract_bytecode(DIAMOND_CUT_FACET)?; + let diamond_cut_txn = GenesisTransaction::create( self.address, - core_impl_bytecode, + diamond_cut, self.nonce, - core_impl_address, + diamond_cut_facet_addr, ); self.nonce += 1; // ------------------------------------------------------------------------- - // 2. Deploy AutomationCore proxy + // 2. Deploy DiamondLoupeFacet // ------------------------------------------------------------------------- - let core_init_params = InitializeParams { + let diamond_loupe_data = Self::load_contract_bytecode(DIAMOND_LOUPE_FACET)?; + let diamond_loupe_txn = GenesisTransaction::create( + self.address, + diamond_loupe_data, + self.nonce, + diamond_loupe_facet_addr, + ); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 3. Deploy Ownership facet + // ------------------------------------------------------------------------- + let ownership_data = Self::load_contract_bytecode(OWNERSHIP_FACET)?; + let ownership_txn = GenesisTransaction::create( + self.address, + ownership_data, + self.nonce, + ownership_facet_addr, + ); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 4. Deploy Config Facet + // ------------------------------------------------------------------------- + let config_data = Self::load_contract_bytecode(CONFIG_FACET)?; + let config_txn = + GenesisTransaction::create(self.address, config_data, self.nonce, config_facet_addr); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 5. Deploy Register facet + // ------------------------------------------------------------------------- + let register_data = Self::load_contract_bytecode(REGISTRY_FACET)?; + let register_txn = GenesisTransaction::create( + self.address, + register_data, + self.nonce, + registry_facet_addr, + ); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 6. Deploy Core facet + // ------------------------------------------------------------------------- + let core_data = Self::load_contract_bytecode(CORE_FACET)?; + let core_txn = + GenesisTransaction::create(self.address, core_data, self.nonce, core_facet_addr); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 7. Deploy Core facet + // ------------------------------------------------------------------------- + let diamond_init_data = Self::load_contract_bytecode(DIAMOND_INIT)?; + let diamond_init_txn = GenesisTransaction::create( + self.address, + diamond_init_data, + self.nonce, + diamond_init_addr, + ); + self.nonce += 1; + + // ------------------------------------------------------------------------- + // 7. Deploy Diamond + // ------------------------------------------------------------------------- + let diamond_init_data = Self::load_contract_bytecode(DIAMOND)?; + let facets = FacetsDeployment { + diamondCutFacet: diamond_cut_facet_addr, + loupeFacet: diamond_loupe_facet_addr, + ownershipFacet: ownership_facet_addr, + configFacet: config_facet_addr, + registryFacet: registry_facet_addr, + coreFacet: core_facet_addr, + diamondInit: diamond_init_addr, + }; + + let init_params = InitParams { taskDurationCapSecs: config.task_duration_cap_secs, registryMaxGasCap: config.registry_max_gas_cap, automationBaseFeeWeiPerSec: config.automation_base_fee_wei_per_sec, @@ -430,120 +713,338 @@ impl GenesisTransactionGenerator { sysTaskDurationCapSecs: config.sys_task_duration_cap_secs, sysRegistryMaxGasCap: config.sys_registry_max_gas_cap, sysTaskCapacity: config.sys_task_capacity, - vmSigner: VM_SIGNER, - erc20Supra: erc20_supra_address, - controller: controller_proxy_address, - registry: registry_proxy_address, - owner, + registrationEnabled: true, + automationEnabled: config.enable_automation_feature, }; - let core_init_data = AutomationCore::initializeCall { - params: core_init_params, + + let diamond_constructor_data = Diamond::constructorCall { + _contractOwner: owner, + _facets: facets, + _vmSigner: VM_SIGNER, + _erc20Supra: erc20_supra_address, + _params: init_params, } .abi_encode(); - let core_proxy_args = ERC1967Proxy::constructorCall { - _impl: core_impl_address, - _data: Bytes::from(core_init_data), + let diamond_data = [diamond_init_data, diamond_constructor_data].concat(); + let diamond_txn = + GenesisTransaction::create(self.address, diamond_data, self.nonce, diamond_addr); + self.nonce += 1; + + Ok(BTreeMap::from([ + (GenesisTransactionTags::DiamondCutFacet, diamond_cut_txn), + (GenesisTransactionTags::Diamond, diamond_txn), + (GenesisTransactionTags::DiamondLoupeFacet, diamond_loupe_txn), + (GenesisTransactionTags::OwnershipFacet, ownership_txn), + (GenesisTransactionTags::ConfigFacet, config_txn), + (GenesisTransactionTags::RegistryFacet, register_txn), + (GenesisTransactionTags::CoreFacet, core_txn), + (GenesisTransactionTags::DiamondInit, diamond_init_txn), + ])) + } + + fn setup_supra_nova_contracts( + &mut self, + config: SupraNovaConfig, + owner: Address, + ) -> Result> { + // First setup all independent contracts + // 1. Wrapped token contracts + // 2. Hypernova contracts + // 3. Token Vault contracts + let wrapped_token_contracts = self.setup_wrapped_token_contracts(owner)?; + let hyper_nova_contracts = self.setup_hyper_nova_contracts(owner, &config)?; + let token_vault_contracts = self.setup_token_vault_contracts(owner, &config)?; + + // 4. Setup FeeOperator contracts which depends on hypernova deployment + let hyper_nova = *hyper_nova_contracts + .get(&GenesisTransactionTags::HypernovaProxy) + .expect("Hypernova contract should be deployed") + .deploy_address(); + + let fee_operator_contracts = + self.setup_fee_operator_contracts(owner, hyper_nova, &config)?; + + // 5. Setup Token Bridge contracts which depends on all above + let token_vault = *token_vault_contracts + .get(&GenesisTransactionTags::TokenVaultProxy) + .expect("TokenVault contract should be deployed") + .deploy_address(); + + let fee_operator = *fee_operator_contracts + .get(&GenesisTransactionTags::FeeOperatorProxy) + .expect("FeeOperator contract should be deployed") + .deploy_address(); + + let wrapped_token = *wrapped_token_contracts + .get(&GenesisTransactionTags::WrappedTokenFactoryProxy) + .expect("WrappedToken contract should be deployed") + .deploy_address(); + + let token_bridge_contracts = self.setup_token_bridge_contracts( + owner, + hyper_nova, + token_vault, + fee_operator, + wrapped_token, + &config, + )?; + + let mut contract_txns = wrapped_token_contracts; + contract_txns.extend(hyper_nova_contracts); + contract_txns.extend(token_vault_contracts); + contract_txns.extend(fee_operator_contracts); + contract_txns.extend(token_bridge_contracts); + + Ok(contract_txns) + } + + fn setup_wrapped_token_contracts( + &mut self, + owner: Address, + ) -> Result> { + let wrapped_token_init_data = Self::load_contract_bytecode(WRAPPED_TOKEN)?; + let wrapped_token_txn = GenesisTransaction::create2( + self.address, + SupraNovaConfig::WRAPPED_TOKEN_IMPL_SALT, + wrapped_token_init_data, + self.nonce, + ); + self.nonce += 1; + + let wrapped_token_fct_init_data = Self::load_contract_bytecode(WRAPPED_TOKEN_FACTORY)?; + let wrapped_token_fct_txn = GenesisTransaction::create2( + self.address, + SupraNovaConfig::WRAPPED_TOKEN_FACTORY_IMPL_SALT, + wrapped_token_fct_init_data, + self.nonce, + ); + self.nonce += 1; + + let wrapped_token_fct_init_call = WrappedTokenFactory::initializeCall { + owner, + token_impl: *wrapped_token_txn.deploy_address(), } .abi_encode(); - let core_proxy_txn_data = [proxy_bytecode.clone(), core_proxy_args].concat(); - let core_proxy_txn = GenesisTransaction::new( + + let wrapped_token_proxy_init_data = + Self::load_contract_bytecode(WRAPPED_TOKEN_FACTORY_PROXY)?; + let wrapped_token_proxy_cnstr_data = WrappedTokenFactoryProxy::constructorCall { + factory_impl: *wrapped_token_fct_txn.deploy_address(), + init_data: wrapped_token_fct_init_call.into(), + } + .abi_encode(); + let wrapped_token_proxy_txn_data = [ + wrapped_token_proxy_init_data, + wrapped_token_proxy_cnstr_data, + ] + .concat(); + let wrapped_token_proxy_txn = GenesisTransaction::create2( self.address, - core_proxy_txn_data, + SupraNovaConfig::WRAPPED_TOKEN_FACTORY_PROXY_SALT, + wrapped_token_proxy_txn_data, self.nonce, - core_proxy_address, ); self.nonce += 1; - // ------------------------------------------------------------------------- - // 3. Deploy AutomationRegistryImpl (UUPS - no constructor args) - // ------------------------------------------------------------------------- - let registry_impl_bytecode = Self::load_contract_bytecode(AUTOMATION_REGISTRY)?; - let registry_impl_txn = GenesisTransaction::new( + Ok(BTreeMap::from([ + (GenesisTransactionTags::WrappedToken, wrapped_token_txn), + ( + GenesisTransactionTags::WrappedTokenFactory, + wrapped_token_fct_txn, + ), + ( + GenesisTransactionTags::WrappedTokenFactoryProxy, + wrapped_token_proxy_txn, + ), + ])) + } + + fn setup_hyper_nova_contracts( + &mut self, + owner: Address, + config: &SupraNovaConfig, + ) -> Result> { + let hyper_nova_init_data = Self::load_contract_bytecode(HYPERNOVA)?; + let hyper_nova_txn = GenesisTransaction::create2( self.address, - registry_impl_bytecode, + SupraNovaConfig::HYPER_NOVA_IMPL_SALT, + hyper_nova_init_data, self.nonce, - registry_impl_address, ); self.nonce += 1; - // ------------------------------------------------------------------------- - // 4. Deploy AutomationRegistry proxy - // ------------------------------------------------------------------------- - let registry_init_data = AutomationRegistry::initializeCall { - _automationCore: core_proxy_address, - _automationController: controller_proxy_address, - _owner: owner, + let hyper_nova_init_call_data = Hypernova::initializeCall { + owner, + msgId: U256::from(config.hypernova_msg_id), } .abi_encode(); - let registry_proxy_args = ERC1967Proxy::constructorCall { - _impl: registry_impl_address, - _data: Bytes::from(registry_init_data), + + let hyper_nova_proxy_init_data = Self::load_contract_bytecode(HYPERNOVA_PROXY)?; + let hyper_nova_proxy_cnstr_data = HypernovaProxy::constructorCall { + hypernova_impl: *hyper_nova_txn.deploy_address(), + init_data: hyper_nova_init_call_data.into(), } .abi_encode(); - let registry_proxy_txn_data = [proxy_bytecode.clone(), registry_proxy_args].concat(); - let registry_proxy_txn = GenesisTransaction::new( + let hyper_nova_proxy_txn_data = + [hyper_nova_proxy_init_data, hyper_nova_proxy_cnstr_data].concat(); + let hyper_nova_proxy_txn = GenesisTransaction::create2( self.address, - registry_proxy_txn_data, + SupraNovaConfig::HYPER_NOVA_PROXY_SALT, + hyper_nova_proxy_txn_data, self.nonce, - registry_proxy_address, ); self.nonce += 1; - // ------------------------------------------------------------------------- - // 5. Deploy AutomationControllerImpl (UUPS - no constructor args) - // ------------------------------------------------------------------------- - let controller_impl_bytecode = Self::load_contract_bytecode(AUTOMATION_CONTROLLER)?; - let controller_impl_txn = GenesisTransaction::new( + Ok(BTreeMap::from([ + (GenesisTransactionTags::Hypernova, hyper_nova_txn), + (GenesisTransactionTags::HypernovaProxy, hyper_nova_proxy_txn), + ])) + } + + fn setup_token_vault_contracts( + &mut self, + owner: Address, + config: &SupraNovaConfig, + ) -> Result> { + let token_vault_init_data = Self::load_contract_bytecode(TOKEN_VAULT)?; + let token_vault_txn = GenesisTransaction::create2( self.address, - controller_impl_bytecode, + SupraNovaConfig::TOKEN_VAULT_IMPL_SALT, + token_vault_init_data, self.nonce, - controller_impl_address, ); self.nonce += 1; - // ------------------------------------------------------------------------- - // 6. Deploy AutomationController proxy - // ------------------------------------------------------------------------- - let controller_init_data = AutomationController::initializeCall { - _automationCore: core_proxy_address, - _registry: registry_proxy_address, - _owner: owner, - _automationEnabled: config.enable_automation_feature, - _cycleDurationSecs: config.cycle_duration_secs, + let token_vault_init_call_data = TokenVault::initializeCall { + owner, + nativeToken: config.weth9_address, + brigde: owner, } .abi_encode(); - let controller_proxy_args = ERC1967Proxy::constructorCall { - _impl: controller_impl_address, - _data: Bytes::from(controller_init_data), + + let token_vault_proxy_init_data = Self::load_contract_bytecode(TOKEN_VAULT_PROXY)?; + let token_vault_proxy_cnstr_data = TokenVaultProxy::constructorCall { + token_vault_impl: *token_vault_txn.deploy_address(), + init_data: token_vault_init_call_data.into(), } .abi_encode(); - let controller_proxy_txn_data = [proxy_bytecode, controller_proxy_args].concat(); - let controller_proxy_txn = GenesisTransaction::new( + let token_vault_proxy_txn_data = + [token_vault_proxy_init_data, token_vault_proxy_cnstr_data].concat(); + let token_vault_proxy_txn = GenesisTransaction::create2( self.address, - controller_proxy_txn_data, + SupraNovaConfig::TOKEN_VAULT_PROXY_SALT, + token_vault_proxy_txn_data, self.nonce, - controller_proxy_address, ); self.nonce += 1; Ok(BTreeMap::from([ + (GenesisTransactionTags::TokenVault, token_vault_txn), ( - GenesisTransactionTags::AutomationControllerImpl, - controller_impl_txn, - ), - ( - GenesisTransactionTags::AutomationController, - controller_proxy_txn, + GenesisTransactionTags::TokenVaultProxy, + token_vault_proxy_txn, ), - (GenesisTransactionTags::AutomationCoreImpl, core_impl_txn), - (GenesisTransactionTags::AutomationCore, core_proxy_txn), + ])) + } + + fn setup_fee_operator_contracts( + &mut self, + owner: Address, + hyper_nova: Address, + config: &SupraNovaConfig, + ) -> Result> { + let fee_operator_init_data = Self::load_contract_bytecode(FEE_OPERATOR)?; + let fee_operator_txn = GenesisTransaction::create2( + self.address, + SupraNovaConfig::FEE_OPERATOR_IMPL_SALT, + fee_operator_init_data, + self.nonce, + ); + self.nonce += 1; + + let fee_operator_init_call_data = FeeOperator::initializeCall { + owner, + hypernova: hyper_nova, + sValueFeed: config.dora_storage_address, + supraUsdtPairIndex: U256::from(config.supra_usdt_pair_idx), + maxStaleOraclePriceLimit: U256::from(config.max_stale_oracle_price_limit), + } + .abi_encode(); + + let fee_operator_proxy_init_data = Self::load_contract_bytecode(FEE_OPERATOR_PROXY)?; + let fee_operator_proxy_cnstr_data = FeeOperatorProxy::constructorCall { + fee_operator_impl: *fee_operator_txn.deploy_address(), + init_data: fee_operator_init_call_data.into(), + } + .abi_encode(); + let fee_operator_proxy_txn_data = + [fee_operator_proxy_init_data, fee_operator_proxy_cnstr_data].concat(); + let fee_operator_proxy_txn = GenesisTransaction::create2( + self.address, + SupraNovaConfig::FEE_OPERATOR_PROXY_SALT, + fee_operator_proxy_txn_data, + self.nonce, + ); + self.nonce += 1; + + Ok(BTreeMap::from([ + (GenesisTransactionTags::FeeOperator, fee_operator_txn), ( - GenesisTransactionTags::AutomationRegistryImpl, - registry_impl_txn, + GenesisTransactionTags::FeeOperatorProxy, + fee_operator_proxy_txn, ), + ])) + } + + fn setup_token_bridge_contracts( + &mut self, + owner: Address, + hyper_nova: Address, + fee_operator_address: Address, + token_vault_address: Address, + wrapped_token_proxy_address: Address, + config: &SupraNovaConfig, + ) -> Result> { + let token_bridge_init_data = Self::load_contract_bytecode(TOKEN_BRIDGE)?; + let token_bridge_txn = GenesisTransaction::create2( + self.address, + SupraNovaConfig::TOKEN_BRIDGE_IMPL_SALT, + token_bridge_init_data, + self.nonce, + ); + self.nonce += 1; + + let token_bridge_init_call_data = TokenBridge::initializeCall { + owner, + nativeToken: config.weth9_address, + hypernova: hyper_nova, + feeOperator: fee_operator_address, + vault: token_vault_address, + wrappedTokenFactory: wrapped_token_proxy_address, + } + .abi_encode(); + + let token_bridge_proxy_init_data = Self::load_contract_bytecode(TOKEN_BRIDGE_PROXY)?; + let token_bridge_proxy_cnstr_data = TokenBridgeProxy::constructorCall { + token_bridge_impl: *token_bridge_txn.deploy_address(), + init_data: token_bridge_init_call_data.into(), + } + .abi_encode(); + let token_bridge_proxy_txn_data = + [token_bridge_proxy_init_data, token_bridge_proxy_cnstr_data].concat(); + let token_bridge_proxy_txn = GenesisTransaction::create2( + self.address, + SupraNovaConfig::TOKEN_BRIDGE_PROXY_SALT, + token_bridge_proxy_txn_data, + self.nonce, + ); + self.nonce += 1; + + Ok(BTreeMap::from([ + (GenesisTransactionTags::TokenBridge, token_bridge_txn), ( - GenesisTransactionTags::AutomationRegistry, - registry_proxy_txn, + GenesisTransactionTags::TokenBridgeProxy, + token_bridge_proxy_txn, ), ])) } @@ -567,16 +1068,20 @@ mod tests { fn check_multisig_setup() { let mut generator = GenesisTransactionGenerator::default(); let owners = vec![u64_to_address(1), u64_to_address(2), u64_to_address(3)]; + let initial_native_token = 1000; let mut config = GenesisTransactionGeneratorConfig { foundation_owners: owners, foundation_threshold: 2, full_set: false, automation_config: None, + initial_native_token, + supra_nova_config: None, }; let result = generator .prepare_genesis_transactions(config.clone()) .unwrap(); - assert_eq!(result.len(), 3); + assert_eq!(result.len(), 4); + assert!(result.contains_key(&GenesisTransactionTags::Create2Factory)); assert!(result.contains_key(&GenesisTransactionTags::MultisigWalletImpl)); assert!(result.contains_key(&GenesisTransactionTags::MultisigBeacon)); assert!(result.contains_key(&GenesisTransactionTags::FoundationWallet)); @@ -586,16 +1091,27 @@ mod tests { let result = generator .prepare_genesis_transactions(config) .expect("Successful txn generation"); + assert!(result.contains_key(&GenesisTransactionTags::Create2Factory)); assert!(result.contains_key(&GenesisTransactionTags::FoundationWallet)); assert!(result.contains_key(&GenesisTransactionTags::BlockMetadata)); + assert!(result.contains_key(&GenesisTransactionTags::Erc20SupraImpl)); assert!(result.contains_key(&GenesisTransactionTags::Erc20Supra)); + assert!(result.contains_key(&GenesisTransactionTags::Erc20SupraHandlerImpl)); + assert!(result.contains_key(&GenesisTransactionTags::Erc20SupraHandler)); + let erc20_supra_handler = result + .get(&GenesisTransactionTags::Erc20SupraHandler) + .unwrap(); + assert_eq!(erc20_supra_handler.value(), &initial_native_token); + // Verify automation contracts are not deployed - assert!(!result.contains_key(&GenesisTransactionTags::AutomationControllerImpl)); - assert!(!result.contains_key(&GenesisTransactionTags::AutomationController)); - assert!(!result.contains_key(&GenesisTransactionTags::AutomationCoreImpl)); - assert!(!result.contains_key(&GenesisTransactionTags::AutomationCore)); - assert!(!result.contains_key(&GenesisTransactionTags::AutomationRegistryImpl)); - assert!(!result.contains_key(&GenesisTransactionTags::AutomationRegistry)); + assert!(!result.contains_key(&GenesisTransactionTags::DiamondCutFacet)); + assert!(!result.contains_key(&GenesisTransactionTags::Diamond)); + assert!(!result.contains_key(&GenesisTransactionTags::DiamondLoupeFacet)); + assert!(!result.contains_key(&GenesisTransactionTags::OwnershipFacet)); + assert!(!result.contains_key(&GenesisTransactionTags::ConfigFacet)); + assert!(!result.contains_key(&GenesisTransactionTags::RegistryFacet)); + assert!(!result.contains_key(&GenesisTransactionTags::CoreFacet)); + assert!(!result.contains_key(&GenesisTransactionTags::DiamondInit)); println!("{result:#?}"); } @@ -614,18 +1130,59 @@ mod tests { foundation_threshold: 2, full_set: true, automation_config: Some(custom_config.into()), + initial_native_token: 1000, + supra_nova_config: None, + }; + let result = generator + .prepare_genesis_transactions(config) + .expect("Successful txn generation"); + + // Verify all automation contracts are deployed + assert!(result.contains_key(&GenesisTransactionTags::DiamondCutFacet)); + assert!(result.contains_key(&GenesisTransactionTags::Diamond)); + assert!(result.contains_key(&GenesisTransactionTags::DiamondLoupeFacet)); + assert!(result.contains_key(&GenesisTransactionTags::OwnershipFacet)); + assert!(result.contains_key(&GenesisTransactionTags::ConfigFacet)); + assert!(result.contains_key(&GenesisTransactionTags::RegistryFacet)); + assert!(result.contains_key(&GenesisTransactionTags::CoreFacet)); + assert!(result.contains_key(&GenesisTransactionTags::DiamondInit)); + println!("{result:#?}"); + } + + #[test] + fn check_supra_nova_with_custom_config() { + let mut generator = GenesisTransactionGenerator::default(); + let owners = vec![u64_to_address(1), u64_to_address(2), u64_to_address(3)]; + let custom_config = AutomationRegistryConfigV1 { + task_duration_cap_secs: 7200, + registry_max_gas_cap: 20_000_000, + task_capacity: 1000, + ..Default::default() + }; + let config = GenesisTransactionGeneratorConfig { + foundation_owners: owners, + foundation_threshold: 2, + full_set: true, + automation_config: Some(custom_config.into()), + initial_native_token: 1000, + supra_nova_config: Some(SupraNovaConfig::default()), }; let result = generator .prepare_genesis_transactions(config) .expect("Successful txn generation"); // Verify all automation contracts are deployed - assert!(result.contains_key(&GenesisTransactionTags::AutomationControllerImpl)); - assert!(result.contains_key(&GenesisTransactionTags::AutomationController)); - assert!(result.contains_key(&GenesisTransactionTags::AutomationCoreImpl)); - assert!(result.contains_key(&GenesisTransactionTags::AutomationCore)); - assert!(result.contains_key(&GenesisTransactionTags::AutomationRegistryImpl)); - assert!(result.contains_key(&GenesisTransactionTags::AutomationRegistry)); + assert!(result.contains_key(&GenesisTransactionTags::WrappedToken)); + assert!(result.contains_key(&GenesisTransactionTags::WrappedTokenFactory)); + assert!(result.contains_key(&GenesisTransactionTags::WrappedTokenFactoryProxy)); + assert!(result.contains_key(&GenesisTransactionTags::Hypernova)); + assert!(result.contains_key(&GenesisTransactionTags::HypernovaProxy)); + assert!(result.contains_key(&GenesisTransactionTags::FeeOperator)); + assert!(result.contains_key(&GenesisTransactionTags::FeeOperatorProxy)); + assert!(result.contains_key(&GenesisTransactionTags::TokenVault)); + assert!(result.contains_key(&GenesisTransactionTags::TokenVaultProxy)); + assert!(result.contains_key(&GenesisTransactionTags::TokenBridge)); + assert!(result.contains_key(&GenesisTransactionTags::TokenBridgeProxy)); println!("{result:#?}"); } } diff --git a/crates/supra-extension/src/contracts/mod.rs b/crates/supra-extension/src/contracts/mod.rs index d6e3624b3c..4d0b2a65e3 100644 --- a/crates/supra-extension/src/contracts/mod.rs +++ b/crates/supra-extension/src/contracts/mod.rs @@ -3,3 +3,4 @@ pub mod configs; pub mod generator; pub mod transaction; +pub(crate) mod supra_nova_contracts; diff --git a/crates/supra-extension/src/contracts/supra_nova_contracts.rs b/crates/supra-extension/src/contracts/supra_nova_contracts.rs new file mode 100644 index 0000000000..6223d76812 --- /dev/null +++ b/crates/supra-extension/src/contracts/supra_nova_contracts.rs @@ -0,0 +1,67 @@ +use alloy_sol_types::sol; + +pub(crate) const WRAPPED_TOKEN: &str = "WrappedToken"; +pub(crate) const WRAPPED_TOKEN_FACTORY: &str = "WrappedTokenFactory"; +pub(crate) const WRAPPED_TOKEN_FACTORY_PROXY: &str = "WrappedTokenFactoryProxy"; +pub(crate) const HYPERNOVA: &str = "Hypernova"; +pub(crate) const HYPERNOVA_PROXY: &str = "HypernovaProxy"; +pub(crate) const TOKEN_VAULT: &str = "TokenVault"; +pub(crate) const TOKEN_VAULT_PROXY: &str = "TokenVaultProxy"; +pub(crate) const FEE_OPERATOR: &str = "FeeOperator"; +pub(crate) const FEE_OPERATOR_PROXY: &str = "FeeOperatorProxy"; +pub(crate) const TOKEN_BRIDGE: &str = "TokenBridge"; +pub(crate) const TOKEN_BRIDGE_PROXY: &str = "TokenBridgeProxy"; + +sol! { + contract WrappedTokenFactory { + function initialize(address owner, address token_impl); + } + contract WrappedTokenFactoryProxy { + constructor(address factory_impl, bytes init_data); + } + + contract Hypernova { + function initialize(address owner, uint256 msgId); + } + + contract HypernovaProxy { + constructor(address hypernova_impl, bytes init_data); + } + + contract TokenVault { + function initialize(address owner, address nativeToken, address brigde); + } + + contract TokenVaultProxy { + constructor(address token_vault_impl, bytes init_data); + } + + contract FeeOperator { + function initialize( + address owner, + address hypernova, + address sValueFeed, + uint256 supraUsdtPairIndex, + uint256 maxStaleOraclePriceLimit); + } + + contract FeeOperatorProxy { + constructor(address fee_operator_impl, bytes init_data); + } + + contract TokenBridge { + function initialize( + address owner, + address nativeToken, + address hypernova, + address feeOperator, + address vault, + address wrappedTokenFactory + ); + } + + contract TokenBridgeProxy { + constructor(address token_bridge_impl, bytes init_data); + } + +} diff --git a/crates/supra-extension/src/contracts/transaction.rs b/crates/supra-extension/src/contracts/transaction.rs index 9eb8111010..e23ceef690 100644 --- a/crates/supra-extension/src/contracts/transaction.rs +++ b/crates/supra-extension/src/contracts/transaction.rs @@ -2,43 +2,142 @@ use derive_getters::{Dissolve, Getters}; use derive_more::Constructor; -use primitives::Address; -use std::fmt::Debug; +use primitives::{keccak256, Address, TxKind, address, hex}; +use std::fmt::{Debug, Display}; +use serde::{Serialize, Deserialize}; +use serde_with::hex::Hex ; +use serde_with::serde_as; + + +/// The address that deploys the default CREATE2 deployer contract. +pub const CREATE2_FACTORY_OWNER: Address = + address!("0x3fAB184622Dc19b6109349B94811493BF2a45362"); + +/// The default CREATE2 FACTORY contract address. Assumed deployed by [CREATE2_FACTORY_OWNER] with nonce 0 +pub const CREATE2_FACTORY_ADDRESS: Address = + address!("0x4e59b44847b379578588920ca78fbf26c0b4956c"); + +/// The init-code of the default CREATE2 FACTORY widely used in community +/// Retrieved from https://github.com/Arachnid/deterministic-deployment-proxy +pub const CREATE2_FACTORY_CODE: &[u8] = &hex!( + "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" +); /// Represents data required to construct genesis contracts deployment transaction -#[derive(Clone, Getters, Dissolve, Constructor)] +#[serde_as] +#[derive(Clone, Getters, Dissolve, Constructor, Serialize, Deserialize)] pub struct GenesisTransaction { + /// Sender of the transaction sender: Address, - data: Vec, + /// Expected nonce of the sender account. nonce: u64, + /// Amount to mint to the contract address if the transaction deploys a contract. + value: u128, + /// Input data of the transaction. + #[serde_as(as = "Hex")] + data: Vec, + /// Kind of the transaction. + kind: TxKind, + /// Pre-computed deploy address of the contract if the transaction deploys a contract. deploy_address: Address, } +impl GenesisTransaction { + /// Creates a new genesis transaction with the given parameters to deploy a contract via standard create API. + pub fn create( + sender: Address, + data: Vec, + nonce: u64, + deploy_address: Address, + ) -> Self { + Self::new ( + sender, + nonce, + 0, + data, + TxKind::Create, + deploy_address, + ) + } + + /// Creates a new genesis transaction with the given parameters to deploy a contract via create2 API. + pub fn create2( + sender: Address, + salt: &str, + data: Vec, + nonce: u64, + ) -> Self { + let salt_hash = keccak256(salt); + let deploy_address = CREATE2_FACTORY_ADDRESS.create2_from_code(salt_hash, &data.as_slice()); + let call_data = [ salt_hash.to_vec(), data].concat(); + Self::new ( + sender, + nonce, + 0, + call_data, + TxKind::Call(CREATE2_FACTORY_ADDRESS), + deploy_address, + ) + } + +} + impl Debug for GenesisTransaction { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("GenesisTransaction") .field("sender", &self.sender) + .field("kind", &self.kind) .field("data", &self.data.len()) .field("nonce", &self.nonce) .field("deploy_address", &self.deploy_address) + .field("value", &self.value) .finish() } } /// Genesis transaction tags which also guide deployment/execution order -#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[allow(missing_docs)] +#[repr(u8)] pub enum GenesisTransactionTags { - MultisigWalletImpl = 0, - MultisigBeacon = 1, - FoundationWallet = 2, - Erc20Supra = 3, - BlockMetadataImpl = 4, - BlockMetadata = 5, - AutomationCoreImpl = 6, - AutomationCore = 7, - AutomationRegistryImpl = 8, - AutomationRegistry = 9, - AutomationControllerImpl = 10, - AutomationController = 11, + Create2Factory = 0, + // Main system and foundation contracts + MultisigWalletImpl = 1, + MultisigBeacon = 2, + FoundationWallet = 3, + Erc20SupraImpl = 4, + Erc20Supra = 5, + Erc20SupraHandlerImpl = 6, + Erc20SupraHandler = 7, + BlockMetadataImpl = 8, + BlockMetadata = 9, + + // Automation registry contracts + DiamondCutFacet = 10, + DiamondLoupeFacet = 11, + OwnershipFacet = 12, + ConfigFacet = 13, + RegistryFacet = 14, + CoreFacet = 15, + DiamondInit = 16, + Diamond = 17, + + // Supra Nova contracts + WrappedToken = 18, // Impl + WrappedTokenFactory = 19, // Beacon + WrappedTokenFactoryProxy = 20, // Beacon Proxy + Hypernova = 21, + HypernovaProxy = 22, + TokenVault = 23, + TokenVaultProxy = 24, + FeeOperator = 25, + FeeOperatorProxy = 26, + TokenBridge = 27, + TokenBridgeProxy = 28, +} + +impl Display for GenesisTransactionTags { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self) + } } diff --git a/crates/supra-extension/src/lib.rs b/crates/supra-extension/src/lib.rs index 8a6b3bdc9b..9c8c245dc7 100644 --- a/crates/supra-extension/src/lib.rs +++ b/crates/supra-extension/src/lib.rs @@ -5,5 +5,9 @@ pub mod contracts; pub mod errors; #[allow(missing_docs, missing_debug_implementations)] #[allow(elided_lifetimes_in_paths)] -pub mod supra_contract_bindings; +mod supra_contract_bindings; pub mod transactions; +pub use crate::supra_contract_bindings::supra_contracts_bindings::{ + LibCommon::{CycleDetails, CycleState, TaskState, TaskType}, + SupraContractsBindings::*, +}; diff --git a/crates/supra-extension/src/supra_contract_bindings/mod.rs b/crates/supra-extension/src/supra_contract_bindings/mod.rs index f95e49cc7a..f23401cf42 100644 --- a/crates/supra-extension/src/supra_contract_bindings/mod.rs +++ b/crates/supra-extension/src/supra_contract_bindings/mod.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports, unused_attributes, clippy::all, rustdoc::all)] +#![allow(unused_imports, unused_attributes, clippy::all, rustdoc::all, dead_code, unreachable_pub)] //! This module contains the sol! generated bindings for solidity contracts. //! This is autogenerated code. //! Do not manually edit these files. diff --git a/crates/supra-extension/src/supra_contract_bindings/supra_contracts_bindings.rs b/crates/supra-extension/src/supra_contract_bindings/supra_contracts_bindings.rs index 6d91a3276f..3a8a254237 100644 --- a/crates/supra-extension/src/supra_contract_bindings/supra_contracts_bindings.rs +++ b/crates/supra-extension/src/supra_contract_bindings/supra_contracts_bindings.rs @@ -2,12 +2,11 @@ /** ```solidity -library CommonUtils { +library LibCommon { type CycleState is uint8; type TaskState is uint8; type TaskType is uint8; struct CycleDetails { uint64 index; uint64 startTime; uint64 durationSecs; CycleState state; uint64 nextTaskIndexPosition; uint64[] expectedTasksToBeProcessed; } - struct TaskDetails { uint128 maxGasAmount; uint128 gasPriceCap; uint128 automationFeeCapForCycle; uint128 depositFee; bytes32 txHash; uint64 taskIndex; uint64 registrationTime; uint64 expiryTime; uint64 priority; TaskType taskType; TaskState state; address owner; bytes payloadTx; bytes[] auxData; } } ```*/ #[allow( @@ -17,7 +16,7 @@ library CommonUtils { clippy::style, clippy::empty_structs_with_brackets )] -pub mod CommonUtils { +pub mod LibCommon { use super::*; use alloy::sol_types as alloy_sol_types; #[derive(serde::Serialize, serde::Deserialize)] @@ -759,598 +758,92 @@ struct CycleDetails { uint64 index; uint64 startTime; uint64 durationSecs; Cycle } } }; - #[derive(serde::Serialize, serde::Deserialize)] - #[derive(Default, Debug, PartialEq, Eq, Hash)] - /**```solidity -struct TaskDetails { uint128 maxGasAmount; uint128 gasPriceCap; uint128 automationFeeCapForCycle; uint128 depositFee; bytes32 txHash; uint64 taskIndex; uint64 registrationTime; uint64 expiryTime; uint64 priority; TaskType taskType; TaskState state; address owner; bytes payloadTx; bytes[] auxData; } -```*/ - #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + use alloy::contract as alloy_contract; + /**Creates a new wrapper around an on-chain [`LibCommon`](self) contract instance. + +See the [wrapper's documentation](`LibCommonInstance`) for more details.*/ + #[inline] + pub const fn new< + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + >( + address: alloy_sol_types::private::Address, + __provider: P, + ) -> LibCommonInstance { + LibCommonInstance::::new(address, __provider) + } + /**A [`LibCommon`](self) instance. + +Contains type-safe methods for interacting with an on-chain instance of the +[`LibCommon`](self) contract located at a given `address`, using a given +provider `P`. + +If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) +documentation on how to provide it), the `deploy` and `deploy_builder` methods can +be used to deploy a new instance of the contract. + +See the [module-level documentation](self) for all the available methods.*/ #[derive(Clone)] - pub struct TaskDetails { - #[allow(missing_docs)] - pub maxGasAmount: u128, - #[allow(missing_docs)] - pub gasPriceCap: u128, - #[allow(missing_docs)] - pub automationFeeCapForCycle: u128, - #[allow(missing_docs)] - pub depositFee: u128, - #[allow(missing_docs)] - pub txHash: alloy::sol_types::private::FixedBytes<32>, - #[allow(missing_docs)] - pub taskIndex: u64, - #[allow(missing_docs)] - pub registrationTime: u64, - #[allow(missing_docs)] - pub expiryTime: u64, - #[allow(missing_docs)] - pub priority: u64, - #[allow(missing_docs)] - pub taskType: ::RustType, - #[allow(missing_docs)] - pub state: ::RustType, - #[allow(missing_docs)] - pub owner: alloy::sol_types::private::Address, - #[allow(missing_docs)] - pub payloadTx: alloy::sol_types::private::Bytes, - #[allow(missing_docs)] - pub auxData: alloy::sol_types::private::Vec, + pub struct LibCommonInstance { + address: alloy_sol_types::private::Address, + provider: P, + _network: ::core::marker::PhantomData, } - #[allow( - non_camel_case_types, - non_snake_case, - clippy::pub_underscore_fields, - clippy::style - )] - const _: () = { - use alloy::sol_types as alloy_sol_types; - #[doc(hidden)] - #[allow(dead_code)] - type UnderlyingSolTuple<'a> = ( - alloy::sol_types::sol_data::Uint<128>, - alloy::sol_types::sol_data::Uint<128>, - alloy::sol_types::sol_data::Uint<128>, - alloy::sol_types::sol_data::Uint<128>, - alloy::sol_types::sol_data::FixedBytes<32>, - alloy::sol_types::sol_data::Uint<64>, - alloy::sol_types::sol_data::Uint<64>, - alloy::sol_types::sol_data::Uint<64>, - alloy::sol_types::sol_data::Uint<64>, - TaskType, - TaskState, - alloy::sol_types::sol_data::Address, - alloy::sol_types::sol_data::Bytes, - alloy::sol_types::sol_data::Array, - ); - #[doc(hidden)] - type UnderlyingRustTuple<'a> = ( - u128, - u128, - u128, - u128, - alloy::sol_types::private::FixedBytes<32>, - u64, - u64, - u64, - u64, - ::RustType, - ::RustType, - alloy::sol_types::private::Address, - alloy::sol_types::private::Bytes, - alloy::sol_types::private::Vec, - ); - #[cfg(test)] - #[allow(dead_code, unreachable_patterns)] - fn _type_assertion( - _t: alloy_sol_types::private::AssertTypeEq, - ) { - match _t { - alloy_sol_types::private::AssertTypeEq::< - ::RustType, - >(_) => {} - } + #[automatically_derived] + impl ::core::fmt::Debug for LibCommonInstance { + #[inline] + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_tuple("LibCommonInstance").field(&self.address).finish() } - #[automatically_derived] - #[doc(hidden)] - impl ::core::convert::From for UnderlyingRustTuple<'_> { - fn from(value: TaskDetails) -> Self { - ( - value.maxGasAmount, - value.gasPriceCap, - value.automationFeeCapForCycle, - value.depositFee, - value.txHash, - value.taskIndex, - value.registrationTime, - value.expiryTime, - value.priority, - value.taskType, - value.state, - value.owner, - value.payloadTx, - value.auxData, - ) + } + /// Instantiation and getters/setters. + impl< + P: alloy_contract::private::Provider, + N: alloy_contract::private::Network, + > LibCommonInstance { + /**Creates a new wrapper around an on-chain [`LibCommon`](self) contract instance. + +See the [wrapper's documentation](`LibCommonInstance`) for more details.*/ + #[inline] + pub const fn new( + address: alloy_sol_types::private::Address, + __provider: P, + ) -> Self { + Self { + address, + provider: __provider, + _network: ::core::marker::PhantomData, } } - #[automatically_derived] - #[doc(hidden)] - impl ::core::convert::From> for TaskDetails { - fn from(tuple: UnderlyingRustTuple<'_>) -> Self { - Self { - maxGasAmount: tuple.0, - gasPriceCap: tuple.1, - automationFeeCapForCycle: tuple.2, - depositFee: tuple.3, - txHash: tuple.4, - taskIndex: tuple.5, - registrationTime: tuple.6, - expiryTime: tuple.7, - priority: tuple.8, - taskType: tuple.9, - state: tuple.10, - owner: tuple.11, - payloadTx: tuple.12, - auxData: tuple.13, - } - } + /// Returns a reference to the address. + #[inline] + pub const fn address(&self) -> &alloy_sol_types::private::Address { + &self.address } - #[automatically_derived] - impl alloy_sol_types::SolValue for TaskDetails { - type SolType = Self; + /// Sets the address. + #[inline] + pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { + self.address = address; } - #[automatically_derived] - impl alloy_sol_types::private::SolTypeValue for TaskDetails { - #[inline] - fn stv_to_tokens(&self) -> ::Token<'_> { - ( - as alloy_sol_types::SolType>::tokenize(&self.maxGasAmount), - as alloy_sol_types::SolType>::tokenize(&self.gasPriceCap), - as alloy_sol_types::SolType>::tokenize( - &self.automationFeeCapForCycle, - ), - as alloy_sol_types::SolType>::tokenize(&self.depositFee), - as alloy_sol_types::SolType>::tokenize(&self.txHash), - as alloy_sol_types::SolType>::tokenize(&self.taskIndex), - as alloy_sol_types::SolType>::tokenize(&self.registrationTime), - as alloy_sol_types::SolType>::tokenize(&self.expiryTime), - as alloy_sol_types::SolType>::tokenize(&self.priority), - ::tokenize(&self.taskType), - ::tokenize(&self.state), - ::tokenize( - &self.owner, - ), - ::tokenize( - &self.payloadTx, - ), - as alloy_sol_types::SolType>::tokenize(&self.auxData), - ) - } - #[inline] - fn stv_abi_encoded_size(&self) -> usize { - if let Some(size) = ::ENCODED_SIZE { - return size; - } - let tuple = as ::core::convert::From>::from(self.clone()); - as alloy_sol_types::SolType>::abi_encoded_size(&tuple) - } - #[inline] - fn stv_eip712_data_word(&self) -> alloy_sol_types::Word { - ::eip712_hash_struct(self) - } - #[inline] - fn stv_abi_encode_packed_to( - &self, - out: &mut alloy_sol_types::private::Vec, - ) { - let tuple = as ::core::convert::From>::from(self.clone()); - as alloy_sol_types::SolType>::abi_encode_packed_to(&tuple, out) - } - #[inline] - fn stv_abi_packed_encoded_size(&self) -> usize { - if let Some(size) = ::PACKED_ENCODED_SIZE { - return size; - } - let tuple = as ::core::convert::From>::from(self.clone()); - as alloy_sol_types::SolType>::abi_packed_encoded_size(&tuple) - } + /// Sets the address and returns `self`. + pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { + self.set_address(address); + self } - #[automatically_derived] - impl alloy_sol_types::SolType for TaskDetails { - type RustType = Self; - type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; - const SOL_NAME: &'static str = ::NAME; - const ENCODED_SIZE: Option = as alloy_sol_types::SolType>::ENCODED_SIZE; - const PACKED_ENCODED_SIZE: Option = as alloy_sol_types::SolType>::PACKED_ENCODED_SIZE; - #[inline] - fn valid_token(token: &Self::Token<'_>) -> bool { - as alloy_sol_types::SolType>::valid_token(token) - } - #[inline] - fn detokenize(token: Self::Token<'_>) -> Self::RustType { - let tuple = as alloy_sol_types::SolType>::detokenize(token); - >>::from(tuple) - } + /// Returns a reference to the provider. + #[inline] + pub const fn provider(&self) -> &P { + &self.provider } - #[automatically_derived] - impl alloy_sol_types::SolStruct for TaskDetails { - const NAME: &'static str = "TaskDetails"; - #[inline] - fn eip712_root_type() -> alloy_sol_types::private::Cow<'static, str> { - alloy_sol_types::private::Cow::Borrowed( - "TaskDetails(uint128 maxGasAmount,uint128 gasPriceCap,uint128 automationFeeCapForCycle,uint128 depositFee,bytes32 txHash,uint64 taskIndex,uint64 registrationTime,uint64 expiryTime,uint64 priority,uint8 taskType,uint8 state,address owner,bytes payloadTx,bytes[] auxData)", - ) - } - #[inline] - fn eip712_components() -> alloy_sol_types::private::Vec< - alloy_sol_types::private::Cow<'static, str>, - > { - alloy_sol_types::private::Vec::new() - } - #[inline] - fn eip712_encode_type() -> alloy_sol_types::private::Cow<'static, str> { - ::eip712_root_type() - } - #[inline] - fn eip712_encode_data(&self) -> alloy_sol_types::private::Vec { - [ - as alloy_sol_types::SolType>::eip712_data_word(&self.maxGasAmount) - .0, - as alloy_sol_types::SolType>::eip712_data_word(&self.gasPriceCap) - .0, - as alloy_sol_types::SolType>::eip712_data_word( - &self.automationFeeCapForCycle, - ) - .0, - as alloy_sol_types::SolType>::eip712_data_word(&self.depositFee) - .0, - as alloy_sol_types::SolType>::eip712_data_word(&self.txHash) - .0, - as alloy_sol_types::SolType>::eip712_data_word(&self.taskIndex) - .0, - as alloy_sol_types::SolType>::eip712_data_word( - &self.registrationTime, - ) - .0, - as alloy_sol_types::SolType>::eip712_data_word(&self.expiryTime) - .0, - as alloy_sol_types::SolType>::eip712_data_word(&self.priority) - .0, - ::eip712_data_word( - &self.taskType, - ) - .0, - ::eip712_data_word( - &self.state, - ) - .0, - ::eip712_data_word( - &self.owner, - ) - .0, - ::eip712_data_word( - &self.payloadTx, - ) - .0, - as alloy_sol_types::SolType>::eip712_data_word(&self.auxData) - .0, - ] - .concat() - } - } - #[automatically_derived] - impl alloy_sol_types::EventTopic for TaskDetails { - #[inline] - fn topic_preimage_length(rust: &Self::RustType) -> usize { - 0usize - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.maxGasAmount, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.gasPriceCap, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.automationFeeCapForCycle, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.depositFee, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.txHash, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.taskIndex, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.registrationTime, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.expiryTime, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.priority, - ) - + ::topic_preimage_length( - &rust.taskType, - ) - + ::topic_preimage_length( - &rust.state, - ) - + ::topic_preimage_length( - &rust.owner, - ) - + ::topic_preimage_length( - &rust.payloadTx, - ) - + as alloy_sol_types::EventTopic>::topic_preimage_length( - &rust.auxData, - ) - } - #[inline] - fn encode_topic_preimage( - rust: &Self::RustType, - out: &mut alloy_sol_types::private::Vec, - ) { - out.reserve( - ::topic_preimage_length(rust), - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.maxGasAmount, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.gasPriceCap, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.automationFeeCapForCycle, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.depositFee, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.txHash, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.taskIndex, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.registrationTime, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.expiryTime, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.priority, - out, - ); - ::encode_topic_preimage( - &rust.taskType, - out, - ); - ::encode_topic_preimage( - &rust.state, - out, - ); - ::encode_topic_preimage( - &rust.owner, - out, - ); - ::encode_topic_preimage( - &rust.payloadTx, - out, - ); - as alloy_sol_types::EventTopic>::encode_topic_preimage( - &rust.auxData, - out, - ); - } - #[inline] - fn encode_topic( - rust: &Self::RustType, - ) -> alloy_sol_types::abi::token::WordToken { - let mut out = alloy_sol_types::private::Vec::new(); - ::encode_topic_preimage( - rust, - &mut out, - ); - alloy_sol_types::abi::token::WordToken( - alloy_sol_types::private::keccak256(out), - ) - } - } - }; - use alloy::contract as alloy_contract; - /**Creates a new wrapper around an on-chain [`CommonUtils`](self) contract instance. - -See the [wrapper's documentation](`CommonUtilsInstance`) for more details.*/ - #[inline] - pub const fn new< - P: alloy_contract::private::Provider, - N: alloy_contract::private::Network, - >( - address: alloy_sol_types::private::Address, - __provider: P, - ) -> CommonUtilsInstance { - CommonUtilsInstance::::new(address, __provider) - } - /**A [`CommonUtils`](self) instance. - -Contains type-safe methods for interacting with an on-chain instance of the -[`CommonUtils`](self) contract located at a given `address`, using a given -provider `P`. - -If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) -documentation on how to provide it), the `deploy` and `deploy_builder` methods can -be used to deploy a new instance of the contract. - -See the [module-level documentation](self) for all the available methods.*/ - #[derive(Clone)] - pub struct CommonUtilsInstance { - address: alloy_sol_types::private::Address, - provider: P, - _network: ::core::marker::PhantomData, - } - #[automatically_derived] - impl ::core::fmt::Debug for CommonUtilsInstance { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple("CommonUtilsInstance").field(&self.address).finish() - } - } - /// Instantiation and getters/setters. - impl< - P: alloy_contract::private::Provider, - N: alloy_contract::private::Network, - > CommonUtilsInstance { - /**Creates a new wrapper around an on-chain [`CommonUtils`](self) contract instance. - -See the [wrapper's documentation](`CommonUtilsInstance`) for more details.*/ - #[inline] - pub const fn new( - address: alloy_sol_types::private::Address, - __provider: P, - ) -> Self { - Self { - address, - provider: __provider, - _network: ::core::marker::PhantomData, - } - } - /// Returns a reference to the address. - #[inline] - pub const fn address(&self) -> &alloy_sol_types::private::Address { - &self.address - } - /// Sets the address. - #[inline] - pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { - self.address = address; - } - /// Sets the address and returns `self`. - pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { - self.set_address(address); - self - } - /// Returns a reference to the provider. - #[inline] - pub const fn provider(&self) -> &P { - &self.provider - } - } - impl CommonUtilsInstance<&P, N> { - /// Clones the provider and returns a new instance with the cloned provider. - #[inline] - pub fn with_cloned_provider(self) -> CommonUtilsInstance { - CommonUtilsInstance { - address: self.address, - provider: ::core::clone::Clone::clone(&self.provider), - _network: ::core::marker::PhantomData, + } + impl LibCommonInstance<&P, N> { + /// Clones the provider and returns a new instance with the cloned provider. + #[inline] + pub fn with_cloned_provider(self) -> LibCommonInstance { + LibCommonInstance { + address: self.address, + provider: ::core::clone::Clone::clone(&self.provider), + _network: ::core::marker::PhantomData, } } } @@ -1358,7 +851,7 @@ See the [wrapper's documentation](`CommonUtilsInstance`) for more details.*/ impl< P: alloy_contract::private::Provider, N: alloy_contract::private::Network, - > CommonUtilsInstance { + > LibCommonInstance { /// Creates a new call builder using this contract instance's provider and address. /// /// Note that the call can be any function call, not just those defined in this @@ -1374,7 +867,7 @@ See the [wrapper's documentation](`CommonUtilsInstance`) for more details.*/ impl< P: alloy_contract::private::Provider, N: alloy_contract::private::Network, - > CommonUtilsInstance { + > LibCommonInstance { /// Creates a new event filter using this contract instance's provider and address. /// /// Note that the type can be any event, not just those defined in this contract. @@ -1390,7 +883,7 @@ See the [wrapper's documentation](`CommonUtilsInstance`) for more details.*/ Generated by the following Solidity interface... ```solidity -library CommonUtils { +library LibCommon { type CycleState is uint8; type TaskState is uint8; type TaskType is uint8; @@ -1402,7 +895,10 @@ library CommonUtils { uint64 nextTaskIndexPosition; uint64[] expectedTasksToBeProcessed; } - struct TaskDetails { +} + +interface SupraContractsBindings { + struct TaskMetadata { uint128 maxGasAmount; uint128 gasPriceCap; uint128 automationFeeCapForCycle; @@ -1412,25 +908,25 @@ library CommonUtils { uint64 registrationTime; uint64 expiryTime; uint64 priority; - TaskType taskType; - TaskState state; address owner; + LibCommon.TaskType taskType; + LibCommon.TaskState taskState; bytes payloadTx; + bytes predicate; bytes[] auxData; } -} -interface SupraContractsBindings { - event AutomationCycleEvent(uint64 indexed index, CommonUtils.CycleState indexed state, uint64 startTime, uint64 durationSecs, CommonUtils.CycleState indexed oldState); + event AutomationCycleEvent(uint64 indexed index, LibCommon.CycleState indexed state, uint64 startTime, uint64 durationSecs, LibCommon.CycleState indexed oldState); function blockPrologue() external; - function getAllActiveTaskIds() external view returns (uint256[] memory); - function getCycleStateDetails() external view returns (CommonUtils.CycleDetails memory details); - function getTaskDetails(uint64 _taskIndex) external view returns (CommonUtils.TaskDetails memory); - function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns (CommonUtils.TaskDetails[] memory); + function getActiveTaskIds() external view returns (uint256[] memory); + function getCycleStateDetails() external view returns (LibCommon.CycleDetails memory); + function getTaskDetails(uint64 _taskIndex) external view returns (TaskMetadata memory); + function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns (TaskMetadata[] memory); function getTaskIdList() external view returns (uint256[] memory); + function ifTaskExists(uint64 _taskIndex) external view returns (bool); function isAutomationEnabled() external view returns (bool); - function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external; + function processTasks(uint64 _cycleIndex, uint256[] memory _taskIndexes) external; } ``` @@ -1446,7 +942,7 @@ interface SupraContractsBindings { }, { "type": "function", - "name": "getAllActiveTaskIds", + "name": "getActiveTaskIds", "inputs": [], "outputs": [ { @@ -1463,9 +959,9 @@ interface SupraContractsBindings { "inputs": [], "outputs": [ { - "name": "details", + "name": "", "type": "tuple", - "internalType": "struct CommonUtils.CycleDetails", + "internalType": "struct LibCommon.CycleDetails", "components": [ { "name": "index", @@ -1485,7 +981,7 @@ interface SupraContractsBindings { { "name": "state", "type": "uint8", - "internalType": "enum CommonUtils.CycleState" + "internalType": "enum LibCommon.CycleState" }, { "name": "nextTaskIndexPosition", @@ -1516,7 +1012,7 @@ interface SupraContractsBindings { { "name": "", "type": "tuple", - "internalType": "struct CommonUtils.TaskDetails", + "internalType": "struct TaskMetadata", "components": [ { "name": "maxGasAmount", @@ -1563,23 +1059,28 @@ interface SupraContractsBindings { "type": "uint64", "internalType": "uint64" }, + { + "name": "owner", + "type": "address", + "internalType": "address" + }, { "name": "taskType", "type": "uint8", - "internalType": "enum CommonUtils.TaskType" + "internalType": "enum LibCommon.TaskType" }, { - "name": "state", + "name": "taskState", "type": "uint8", - "internalType": "enum CommonUtils.TaskState" + "internalType": "enum LibCommon.TaskState" }, { - "name": "owner", - "type": "address", - "internalType": "address" + "name": "payloadTx", + "type": "bytes", + "internalType": "bytes" }, { - "name": "payloadTx", + "name": "predicate", "type": "bytes", "internalType": "bytes" }, @@ -1607,7 +1108,7 @@ interface SupraContractsBindings { { "name": "", "type": "tuple[]", - "internalType": "struct CommonUtils.TaskDetails[]", + "internalType": "struct TaskMetadata[]", "components": [ { "name": "maxGasAmount", @@ -1654,23 +1155,28 @@ interface SupraContractsBindings { "type": "uint64", "internalType": "uint64" }, + { + "name": "owner", + "type": "address", + "internalType": "address" + }, { "name": "taskType", "type": "uint8", - "internalType": "enum CommonUtils.TaskType" + "internalType": "enum LibCommon.TaskType" }, { - "name": "state", + "name": "taskState", "type": "uint8", - "internalType": "enum CommonUtils.TaskState" + "internalType": "enum LibCommon.TaskState" }, { - "name": "owner", - "type": "address", - "internalType": "address" + "name": "payloadTx", + "type": "bytes", + "internalType": "bytes" }, { - "name": "payloadTx", + "name": "predicate", "type": "bytes", "internalType": "bytes" }, @@ -1697,6 +1203,25 @@ interface SupraContractsBindings { ], "stateMutability": "view" }, + { + "type": "function", + "name": "ifTaskExists", + "inputs": [ + { + "name": "_taskIndex", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, { "type": "function", "name": "isAutomationEnabled", @@ -1721,8 +1246,8 @@ interface SupraContractsBindings { }, { "name": "_taskIndexes", - "type": "uint64[]", - "internalType": "uint64[]" + "type": "uint256[]", + "internalType": "uint256[]" } ], "outputs": [], @@ -1742,7 +1267,7 @@ interface SupraContractsBindings { "name": "state", "type": "uint8", "indexed": true, - "internalType": "enum CommonUtils.CycleState" + "internalType": "enum LibCommon.CycleState" }, { "name": "startTime", @@ -1760,7 +1285,7 @@ interface SupraContractsBindings { "name": "oldState", "type": "uint8", "indexed": true, - "internalType": "enum CommonUtils.CycleState" + "internalType": "enum LibCommon.CycleState" } ], "anonymous": false @@ -1799,9 +1324,539 @@ pub mod SupraContractsBindings { ); #[derive(serde::Serialize, serde::Deserialize)] #[derive(Default, Debug, PartialEq, Eq, Hash)] + /**```solidity +struct TaskMetadata { uint128 maxGasAmount; uint128 gasPriceCap; uint128 automationFeeCapForCycle; uint128 depositFee; bytes32 txHash; uint64 taskIndex; uint64 registrationTime; uint64 expiryTime; uint64 priority; address owner; LibCommon.TaskType taskType; LibCommon.TaskState taskState; bytes payloadTx; bytes predicate; bytes[] auxData; } +```*/ + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct TaskMetadata { + #[allow(missing_docs)] + pub maxGasAmount: u128, + #[allow(missing_docs)] + pub gasPriceCap: u128, + #[allow(missing_docs)] + pub automationFeeCapForCycle: u128, + #[allow(missing_docs)] + pub depositFee: u128, + #[allow(missing_docs)] + pub txHash: alloy::sol_types::private::FixedBytes<32>, + #[allow(missing_docs)] + pub taskIndex: u64, + #[allow(missing_docs)] + pub registrationTime: u64, + #[allow(missing_docs)] + pub expiryTime: u64, + #[allow(missing_docs)] + pub priority: u64, + #[allow(missing_docs)] + pub owner: alloy::sol_types::private::Address, + #[allow(missing_docs)] + pub taskType: ::RustType, + #[allow(missing_docs)] + pub taskState: ::RustType, + #[allow(missing_docs)] + pub payloadTx: alloy::sol_types::private::Bytes, + #[allow(missing_docs)] + pub predicate: alloy::sol_types::private::Bytes, + #[allow(missing_docs)] + pub auxData: alloy::sol_types::private::Vec, + } + #[allow( + non_camel_case_types, + non_snake_case, + clippy::pub_underscore_fields, + clippy::style + )] + const _: () = { + use alloy::sol_types as alloy_sol_types; + #[doc(hidden)] + #[allow(dead_code)] + type UnderlyingSolTuple<'a> = ( + alloy::sol_types::sol_data::Uint<128>, + alloy::sol_types::sol_data::Uint<128>, + alloy::sol_types::sol_data::Uint<128>, + alloy::sol_types::sol_data::Uint<128>, + alloy::sol_types::sol_data::FixedBytes<32>, + alloy::sol_types::sol_data::Uint<64>, + alloy::sol_types::sol_data::Uint<64>, + alloy::sol_types::sol_data::Uint<64>, + alloy::sol_types::sol_data::Uint<64>, + alloy::sol_types::sol_data::Address, + LibCommon::TaskType, + LibCommon::TaskState, + alloy::sol_types::sol_data::Bytes, + alloy::sol_types::sol_data::Bytes, + alloy::sol_types::sol_data::Array, + ); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = ( + u128, + u128, + u128, + u128, + alloy::sol_types::private::FixedBytes<32>, + u64, + u64, + u64, + u64, + alloy::sol_types::private::Address, + ::RustType, + ::RustType, + alloy::sol_types::private::Bytes, + alloy::sol_types::private::Bytes, + alloy::sol_types::private::Vec, + ); + #[cfg(test)] + #[allow(dead_code, unreachable_patterns)] + fn _type_assertion( + _t: alloy_sol_types::private::AssertTypeEq, + ) { + match _t { + alloy_sol_types::private::AssertTypeEq::< + ::RustType, + >(_) => {} + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From for UnderlyingRustTuple<'_> { + fn from(value: TaskMetadata) -> Self { + ( + value.maxGasAmount, + value.gasPriceCap, + value.automationFeeCapForCycle, + value.depositFee, + value.txHash, + value.taskIndex, + value.registrationTime, + value.expiryTime, + value.priority, + value.owner, + value.taskType, + value.taskState, + value.payloadTx, + value.predicate, + value.auxData, + ) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for TaskMetadata { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { + maxGasAmount: tuple.0, + gasPriceCap: tuple.1, + automationFeeCapForCycle: tuple.2, + depositFee: tuple.3, + txHash: tuple.4, + taskIndex: tuple.5, + registrationTime: tuple.6, + expiryTime: tuple.7, + priority: tuple.8, + owner: tuple.9, + taskType: tuple.10, + taskState: tuple.11, + payloadTx: tuple.12, + predicate: tuple.13, + auxData: tuple.14, + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolValue for TaskMetadata { + type SolType = Self; + } + #[automatically_derived] + impl alloy_sol_types::private::SolTypeValue for TaskMetadata { + #[inline] + fn stv_to_tokens(&self) -> ::Token<'_> { + ( + as alloy_sol_types::SolType>::tokenize(&self.maxGasAmount), + as alloy_sol_types::SolType>::tokenize(&self.gasPriceCap), + as alloy_sol_types::SolType>::tokenize( + &self.automationFeeCapForCycle, + ), + as alloy_sol_types::SolType>::tokenize(&self.depositFee), + as alloy_sol_types::SolType>::tokenize(&self.txHash), + as alloy_sol_types::SolType>::tokenize(&self.taskIndex), + as alloy_sol_types::SolType>::tokenize(&self.registrationTime), + as alloy_sol_types::SolType>::tokenize(&self.expiryTime), + as alloy_sol_types::SolType>::tokenize(&self.priority), + ::tokenize( + &self.owner, + ), + ::tokenize( + &self.taskType, + ), + ::tokenize( + &self.taskState, + ), + ::tokenize( + &self.payloadTx, + ), + ::tokenize( + &self.predicate, + ), + as alloy_sol_types::SolType>::tokenize(&self.auxData), + ) + } + #[inline] + fn stv_abi_encoded_size(&self) -> usize { + if let Some(size) = ::ENCODED_SIZE { + return size; + } + let tuple = as ::core::convert::From>::from(self.clone()); + as alloy_sol_types::SolType>::abi_encoded_size(&tuple) + } + #[inline] + fn stv_eip712_data_word(&self) -> alloy_sol_types::Word { + ::eip712_hash_struct(self) + } + #[inline] + fn stv_abi_encode_packed_to( + &self, + out: &mut alloy_sol_types::private::Vec, + ) { + let tuple = as ::core::convert::From>::from(self.clone()); + as alloy_sol_types::SolType>::abi_encode_packed_to(&tuple, out) + } + #[inline] + fn stv_abi_packed_encoded_size(&self) -> usize { + if let Some(size) = ::PACKED_ENCODED_SIZE { + return size; + } + let tuple = as ::core::convert::From>::from(self.clone()); + as alloy_sol_types::SolType>::abi_packed_encoded_size(&tuple) + } + } + #[automatically_derived] + impl alloy_sol_types::SolType for TaskMetadata { + type RustType = Self; + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SOL_NAME: &'static str = ::NAME; + const ENCODED_SIZE: Option = as alloy_sol_types::SolType>::ENCODED_SIZE; + const PACKED_ENCODED_SIZE: Option = as alloy_sol_types::SolType>::PACKED_ENCODED_SIZE; + #[inline] + fn valid_token(token: &Self::Token<'_>) -> bool { + as alloy_sol_types::SolType>::valid_token(token) + } + #[inline] + fn detokenize(token: Self::Token<'_>) -> Self::RustType { + let tuple = as alloy_sol_types::SolType>::detokenize(token); + >>::from(tuple) + } + } + #[automatically_derived] + impl alloy_sol_types::SolStruct for TaskMetadata { + const NAME: &'static str = "TaskMetadata"; + #[inline] + fn eip712_root_type() -> alloy_sol_types::private::Cow<'static, str> { + alloy_sol_types::private::Cow::Borrowed( + "TaskMetadata(uint128 maxGasAmount,uint128 gasPriceCap,uint128 automationFeeCapForCycle,uint128 depositFee,bytes32 txHash,uint64 taskIndex,uint64 registrationTime,uint64 expiryTime,uint64 priority,address owner,uint8 taskType,uint8 taskState,bytes payloadTx,bytes predicate,bytes[] auxData)", + ) + } + #[inline] + fn eip712_components() -> alloy_sol_types::private::Vec< + alloy_sol_types::private::Cow<'static, str>, + > { + alloy_sol_types::private::Vec::new() + } + #[inline] + fn eip712_encode_type() -> alloy_sol_types::private::Cow<'static, str> { + ::eip712_root_type() + } + #[inline] + fn eip712_encode_data(&self) -> alloy_sol_types::private::Vec { + [ + as alloy_sol_types::SolType>::eip712_data_word(&self.maxGasAmount) + .0, + as alloy_sol_types::SolType>::eip712_data_word(&self.gasPriceCap) + .0, + as alloy_sol_types::SolType>::eip712_data_word( + &self.automationFeeCapForCycle, + ) + .0, + as alloy_sol_types::SolType>::eip712_data_word(&self.depositFee) + .0, + as alloy_sol_types::SolType>::eip712_data_word(&self.txHash) + .0, + as alloy_sol_types::SolType>::eip712_data_word(&self.taskIndex) + .0, + as alloy_sol_types::SolType>::eip712_data_word( + &self.registrationTime, + ) + .0, + as alloy_sol_types::SolType>::eip712_data_word(&self.expiryTime) + .0, + as alloy_sol_types::SolType>::eip712_data_word(&self.priority) + .0, + ::eip712_data_word( + &self.owner, + ) + .0, + ::eip712_data_word( + &self.taskType, + ) + .0, + ::eip712_data_word( + &self.taskState, + ) + .0, + ::eip712_data_word( + &self.payloadTx, + ) + .0, + ::eip712_data_word( + &self.predicate, + ) + .0, + as alloy_sol_types::SolType>::eip712_data_word(&self.auxData) + .0, + ] + .concat() + } + } + #[automatically_derived] + impl alloy_sol_types::EventTopic for TaskMetadata { + #[inline] + fn topic_preimage_length(rust: &Self::RustType) -> usize { + 0usize + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.maxGasAmount, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.gasPriceCap, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.automationFeeCapForCycle, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.depositFee, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.txHash, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.taskIndex, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.registrationTime, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.expiryTime, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.priority, + ) + + ::topic_preimage_length( + &rust.owner, + ) + + ::topic_preimage_length( + &rust.taskType, + ) + + ::topic_preimage_length( + &rust.taskState, + ) + + ::topic_preimage_length( + &rust.payloadTx, + ) + + ::topic_preimage_length( + &rust.predicate, + ) + + as alloy_sol_types::EventTopic>::topic_preimage_length( + &rust.auxData, + ) + } + #[inline] + fn encode_topic_preimage( + rust: &Self::RustType, + out: &mut alloy_sol_types::private::Vec, + ) { + out.reserve( + ::topic_preimage_length(rust), + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.maxGasAmount, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.gasPriceCap, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.automationFeeCapForCycle, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.depositFee, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.txHash, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.taskIndex, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.registrationTime, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.expiryTime, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.priority, + out, + ); + ::encode_topic_preimage( + &rust.owner, + out, + ); + ::encode_topic_preimage( + &rust.taskType, + out, + ); + ::encode_topic_preimage( + &rust.taskState, + out, + ); + ::encode_topic_preimage( + &rust.payloadTx, + out, + ); + ::encode_topic_preimage( + &rust.predicate, + out, + ); + as alloy_sol_types::EventTopic>::encode_topic_preimage( + &rust.auxData, + out, + ); + } + #[inline] + fn encode_topic( + rust: &Self::RustType, + ) -> alloy_sol_types::abi::token::WordToken { + let mut out = alloy_sol_types::private::Vec::new(); + ::encode_topic_preimage( + rust, + &mut out, + ); + alloy_sol_types::abi::token::WordToken( + alloy_sol_types::private::keccak256(out), + ) + } + } + }; + #[derive(serde::Serialize, serde::Deserialize)] + #[derive(Default, Debug, PartialEq, Eq, Hash)] /**Event with signature `AutomationCycleEvent(uint64,uint8,uint64,uint64,uint8)` and selector `0xe3a609ff9d35dde784f4ecc5c5988b3a4ad5ebeabb27e7ad22a76570128e51df`. ```solidity -event AutomationCycleEvent(uint64 indexed index, CommonUtils.CycleState indexed state, uint64 startTime, uint64 durationSecs, CommonUtils.CycleState indexed oldState); +event AutomationCycleEvent(uint64 indexed index, LibCommon.CycleState indexed state, uint64 startTime, uint64 durationSecs, LibCommon.CycleState indexed oldState); ```*/ #[allow( non_camel_case_types, @@ -1814,13 +1869,13 @@ event AutomationCycleEvent(uint64 indexed index, CommonUtils.CycleState indexed #[allow(missing_docs)] pub index: u64, #[allow(missing_docs)] - pub state: ::RustType, + pub state: ::RustType, #[allow(missing_docs)] pub startTime: u64, #[allow(missing_docs)] pub durationSecs: u64, #[allow(missing_docs)] - pub oldState: ::RustType, + pub oldState: ::RustType, } #[allow( non_camel_case_types, @@ -1842,8 +1897,8 @@ event AutomationCycleEvent(uint64 indexed index, CommonUtils.CycleState indexed type TopicList = ( alloy_sol_types::sol_data::FixedBytes<32>, alloy::sol_types::sol_data::Uint<64>, - CommonUtils::CycleState, - CommonUtils::CycleState, + LibCommon::CycleState, + LibCommon::CycleState, ); const SIGNATURE: &'static str = "AutomationCycleEvent(uint64,uint8,uint64,uint64,uint8)"; const SIGNATURE_HASH: alloy_sol_types::private::B256 = alloy_sol_types::private::B256::new([ @@ -1915,10 +1970,10 @@ event AutomationCycleEvent(uint64 indexed index, CommonUtils.CycleState indexed out[1usize] = as alloy_sol_types::EventTopic>::encode_topic(&self.index); - out[2usize] = ::encode_topic( + out[2usize] = ::encode_topic( &self.state, ); - out[3usize] = ::encode_topic( + out[3usize] = ::encode_topic( &self.oldState, ); Ok(()) @@ -2080,19 +2135,19 @@ function blockPrologue() external; }; #[derive(serde::Serialize, serde::Deserialize)] #[derive(Default, Debug, PartialEq, Eq, Hash)] - /**Function with signature `getAllActiveTaskIds()` and selector `0xc5dcf6ac`. + /**Function with signature `getActiveTaskIds()` and selector `0x2321cca3`. ```solidity -function getAllActiveTaskIds() external view returns (uint256[] memory); +function getActiveTaskIds() external view returns (uint256[] memory); ```*/ #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] - pub struct getAllActiveTaskIdsCall; + pub struct getActiveTaskIdsCall; #[derive(serde::Serialize, serde::Deserialize)] #[derive(Default, Debug, PartialEq, Eq, Hash)] - ///Container type for the return parameters of the [`getAllActiveTaskIds()`](getAllActiveTaskIdsCall) function. + ///Container type for the return parameters of the [`getActiveTaskIds()`](getActiveTaskIdsCall) function. #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] - pub struct getAllActiveTaskIdsReturn { + pub struct getActiveTaskIdsReturn { #[allow(missing_docs)] pub _0: alloy::sol_types::private::Vec< alloy::sol_types::private::primitives::aliases::U256, @@ -2125,16 +2180,16 @@ function getAllActiveTaskIds() external view returns (uint256[] memory); } #[automatically_derived] #[doc(hidden)] - impl ::core::convert::From + impl ::core::convert::From for UnderlyingRustTuple<'_> { - fn from(value: getAllActiveTaskIdsCall) -> Self { + fn from(value: getActiveTaskIdsCall) -> Self { () } } #[automatically_derived] #[doc(hidden)] impl ::core::convert::From> - for getAllActiveTaskIdsCall { + for getActiveTaskIdsCall { fn from(tuple: UnderlyingRustTuple<'_>) -> Self { Self } @@ -2165,23 +2220,23 @@ function getAllActiveTaskIds() external view returns (uint256[] memory); } #[automatically_derived] #[doc(hidden)] - impl ::core::convert::From + impl ::core::convert::From for UnderlyingRustTuple<'_> { - fn from(value: getAllActiveTaskIdsReturn) -> Self { + fn from(value: getActiveTaskIdsReturn) -> Self { (value._0,) } } #[automatically_derived] #[doc(hidden)] impl ::core::convert::From> - for getAllActiveTaskIdsReturn { + for getActiveTaskIdsReturn { fn from(tuple: UnderlyingRustTuple<'_>) -> Self { Self { _0: tuple.0 } } } } #[automatically_derived] - impl alloy_sol_types::SolCall for getAllActiveTaskIdsCall { + impl alloy_sol_types::SolCall for getActiveTaskIdsCall { type Parameters<'a> = (); type Token<'a> = = as alloy_sol_types::SolType>::Token<'a>; - const SIGNATURE: &'static str = "getAllActiveTaskIds()"; - const SELECTOR: [u8; 4] = [197u8, 220u8, 246u8, 172u8]; + const SIGNATURE: &'static str = "getActiveTaskIds()"; + const SELECTOR: [u8; 4] = [35u8, 33u8, 204u8, 163u8]; #[inline] fn new<'a>( tuple: as alloy_sol_types::SolType>::RustType, @@ -2221,7 +2276,7 @@ function getAllActiveTaskIds() external view returns (uint256[] memory); '_, > as alloy_sol_types::SolType>::abi_decode_sequence(data) .map(|r| { - let r: getAllActiveTaskIdsReturn = r.into(); + let r: getActiveTaskIdsReturn = r.into(); r._0 }) } @@ -2233,7 +2288,7 @@ function getAllActiveTaskIds() external view returns (uint256[] memory); '_, > as alloy_sol_types::SolType>::abi_decode_sequence_validate(data) .map(|r| { - let r: getAllActiveTaskIdsReturn = r.into(); + let r: getActiveTaskIdsReturn = r.into(); r._0 }) } @@ -2243,7 +2298,7 @@ function getAllActiveTaskIds() external view returns (uint256[] memory); #[derive(Default, Debug, PartialEq, Eq, Hash)] /**Function with signature `getCycleStateDetails()` and selector `0x6b5d8c56`. ```solidity -function getCycleStateDetails() external view returns (CommonUtils.CycleDetails memory details); +function getCycleStateDetails() external view returns (LibCommon.CycleDetails memory); ```*/ #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] @@ -2255,7 +2310,7 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails #[derive(Clone)] pub struct getCycleStateDetailsReturn { #[allow(missing_docs)] - pub details: ::RustType, + pub _0: ::RustType, } #[allow( non_camel_case_types, @@ -2302,10 +2357,10 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails { #[doc(hidden)] #[allow(dead_code)] - type UnderlyingSolTuple<'a> = (CommonUtils::CycleDetails,); + type UnderlyingSolTuple<'a> = (LibCommon::CycleDetails,); #[doc(hidden)] type UnderlyingRustTuple<'a> = ( - ::RustType, + ::RustType, ); #[cfg(test)] #[allow(dead_code, unreachable_patterns)] @@ -2323,7 +2378,7 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails impl ::core::convert::From for UnderlyingRustTuple<'_> { fn from(value: getCycleStateDetailsReturn) -> Self { - (value.details,) + (value._0,) } } #[automatically_derived] @@ -2331,7 +2386,7 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails impl ::core::convert::From> for getCycleStateDetailsReturn { fn from(tuple: UnderlyingRustTuple<'_>) -> Self { - Self { details: tuple.0 } + Self { _0: tuple.0 } } } } @@ -2341,8 +2396,8 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; - type Return = ::RustType; - type ReturnTuple<'a> = (CommonUtils::CycleDetails,); + type Return = ::RustType; + type ReturnTuple<'a> = (LibCommon::CycleDetails,); type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; @@ -2360,7 +2415,7 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails } #[inline] fn tokenize_returns(ret: &Self::Return) -> Self::ReturnToken<'_> { - (::tokenize(ret),) + (::tokenize(ret),) } #[inline] fn abi_decode_returns(data: &[u8]) -> alloy_sol_types::Result { @@ -2369,7 +2424,7 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails > as alloy_sol_types::SolType>::abi_decode_sequence(data) .map(|r| { let r: getCycleStateDetailsReturn = r.into(); - r.details + r._0 }) } #[inline] @@ -2381,7 +2436,7 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails > as alloy_sol_types::SolType>::abi_decode_sequence_validate(data) .map(|r| { let r: getCycleStateDetailsReturn = r.into(); - r.details + r._0 }) } } @@ -2390,7 +2445,7 @@ function getCycleStateDetails() external view returns (CommonUtils.CycleDetails #[derive(Default, Debug, PartialEq, Eq, Hash)] /**Function with signature `getTaskDetails(uint64)` and selector `0xb2ef6896`. ```solidity -function getTaskDetails(uint64 _taskIndex) external view returns (CommonUtils.TaskDetails memory); +function getTaskDetails(uint64 _taskIndex) external view returns (TaskMetadata memory); ```*/ #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] @@ -2399,13 +2454,13 @@ function getTaskDetails(uint64 _taskIndex) external view returns (CommonUtils.Ta pub _taskIndex: u64, } #[derive(serde::Serialize, serde::Deserialize)] - #[derive()] + #[derive(Default, Debug, PartialEq, Eq, Hash)] ///Container type for the return parameters of the [`getTaskDetails(uint64)`](getTaskDetailsCall) function. #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] pub struct getTaskDetailsReturn { #[allow(missing_docs)] - pub _0: ::RustType, + pub _0: ::RustType, } #[allow( non_camel_case_types, @@ -2450,10 +2505,10 @@ function getTaskDetails(uint64 _taskIndex) external view returns (CommonUtils.Ta { #[doc(hidden)] #[allow(dead_code)] - type UnderlyingSolTuple<'a> = (CommonUtils::TaskDetails,); + type UnderlyingSolTuple<'a> = (TaskMetadata,); #[doc(hidden)] type UnderlyingRustTuple<'a> = ( - ::RustType, + ::RustType, ); #[cfg(test)] #[allow(dead_code, unreachable_patterns)] @@ -2489,8 +2544,8 @@ function getTaskDetails(uint64 _taskIndex) external view returns (CommonUtils.Ta type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; - type Return = ::RustType; - type ReturnTuple<'a> = (CommonUtils::TaskDetails,); + type Return = ::RustType; + type ReturnTuple<'a> = (TaskMetadata,); type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; @@ -2512,7 +2567,7 @@ function getTaskDetails(uint64 _taskIndex) external view returns (CommonUtils.Ta } #[inline] fn tokenize_returns(ret: &Self::Return) -> Self::ReturnToken<'_> { - (::tokenize(ret),) + (::tokenize(ret),) } #[inline] fn abi_decode_returns(data: &[u8]) -> alloy_sol_types::Result { @@ -2542,7 +2597,7 @@ function getTaskDetails(uint64 _taskIndex) external view returns (CommonUtils.Ta #[derive(Default, Debug, PartialEq, Eq, Hash)] /**Function with signature `getTaskDetailsBulk(uint64[])` and selector `0x12f72cf4`. ```solidity -function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns (CommonUtils.TaskDetails[] memory); +function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns (TaskMetadata[] memory); ```*/ #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] @@ -2551,14 +2606,14 @@ function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns pub _taskIndexes: alloy::sol_types::private::Vec, } #[derive(serde::Serialize, serde::Deserialize)] - #[derive()] + #[derive(Default, Debug, PartialEq, Eq, Hash)] ///Container type for the return parameters of the [`getTaskDetailsBulk(uint64[])`](getTaskDetailsBulkCall) function. #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] pub struct getTaskDetailsBulkReturn { #[allow(missing_docs)] pub _0: alloy::sol_types::private::Vec< - ::RustType, + ::RustType, >, } #[allow( @@ -2609,12 +2664,12 @@ function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns #[doc(hidden)] #[allow(dead_code)] type UnderlyingSolTuple<'a> = ( - alloy::sol_types::sol_data::Array, + alloy::sol_types::sol_data::Array, ); #[doc(hidden)] type UnderlyingRustTuple<'a> = ( alloy::sol_types::private::Vec< - ::RustType, + ::RustType, >, ); #[cfg(test)] @@ -2654,11 +2709,9 @@ function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns 'a, > as alloy_sol_types::SolType>::Token<'a>; type Return = alloy::sol_types::private::Vec< - ::RustType, + ::RustType, >; - type ReturnTuple<'a> = ( - alloy::sol_types::sol_data::Array, - ); + type ReturnTuple<'a> = (alloy::sol_types::sol_data::Array,); type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; @@ -2682,7 +2735,7 @@ function getTaskDetailsBulk(uint64[] memory _taskIndexes) external view returns fn tokenize_returns(ret: &Self::Return) -> Self::ReturnToken<'_> { ( as alloy_sol_types::SolType>::tokenize(ret), ) } @@ -2869,6 +2922,158 @@ function getTaskIdList() external view returns (uint256[] memory); }; #[derive(serde::Serialize, serde::Deserialize)] #[derive(Default, Debug, PartialEq, Eq, Hash)] + /**Function with signature `ifTaskExists(uint64)` and selector `0x8aaa404e`. +```solidity +function ifTaskExists(uint64 _taskIndex) external view returns (bool); +```*/ + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct ifTaskExistsCall { + #[allow(missing_docs)] + pub _taskIndex: u64, + } + #[derive(serde::Serialize, serde::Deserialize)] + #[derive(Default, Debug, PartialEq, Eq, Hash)] + ///Container type for the return parameters of the [`ifTaskExists(uint64)`](ifTaskExistsCall) function. + #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] + #[derive(Clone)] + pub struct ifTaskExistsReturn { + #[allow(missing_docs)] + pub _0: bool, + } + #[allow( + non_camel_case_types, + non_snake_case, + clippy::pub_underscore_fields, + clippy::style + )] + const _: () = { + use alloy::sol_types as alloy_sol_types; + { + #[doc(hidden)] + #[allow(dead_code)] + type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Uint<64>,); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (u64,); + #[cfg(test)] + #[allow(dead_code, unreachable_patterns)] + fn _type_assertion( + _t: alloy_sol_types::private::AssertTypeEq, + ) { + match _t { + alloy_sol_types::private::AssertTypeEq::< + ::RustType, + >(_) => {} + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From for UnderlyingRustTuple<'_> { + fn from(value: ifTaskExistsCall) -> Self { + (value._taskIndex,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for ifTaskExistsCall { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { _taskIndex: tuple.0 } + } + } + } + { + #[doc(hidden)] + #[allow(dead_code)] + type UnderlyingSolTuple<'a> = (alloy::sol_types::sol_data::Bool,); + #[doc(hidden)] + type UnderlyingRustTuple<'a> = (bool,); + #[cfg(test)] + #[allow(dead_code, unreachable_patterns)] + fn _type_assertion( + _t: alloy_sol_types::private::AssertTypeEq, + ) { + match _t { + alloy_sol_types::private::AssertTypeEq::< + ::RustType, + >(_) => {} + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From for UnderlyingRustTuple<'_> { + fn from(value: ifTaskExistsReturn) -> Self { + (value._0,) + } + } + #[automatically_derived] + #[doc(hidden)] + impl ::core::convert::From> for ifTaskExistsReturn { + fn from(tuple: UnderlyingRustTuple<'_>) -> Self { + Self { _0: tuple.0 } + } + } + } + #[automatically_derived] + impl alloy_sol_types::SolCall for ifTaskExistsCall { + type Parameters<'a> = (alloy::sol_types::sol_data::Uint<64>,); + type Token<'a> = as alloy_sol_types::SolType>::Token<'a>; + type Return = bool; + type ReturnTuple<'a> = (alloy::sol_types::sol_data::Bool,); + type ReturnToken<'a> = as alloy_sol_types::SolType>::Token<'a>; + const SIGNATURE: &'static str = "ifTaskExists(uint64)"; + const SELECTOR: [u8; 4] = [138u8, 170u8, 64u8, 78u8]; + #[inline] + fn new<'a>( + tuple: as alloy_sol_types::SolType>::RustType, + ) -> Self { + tuple.into() + } + #[inline] + fn tokenize(&self) -> Self::Token<'_> { + ( + as alloy_sol_types::SolType>::tokenize(&self._taskIndex), + ) + } + #[inline] + fn tokenize_returns(ret: &Self::Return) -> Self::ReturnToken<'_> { + ( + ::tokenize( + ret, + ), + ) + } + #[inline] + fn abi_decode_returns(data: &[u8]) -> alloy_sol_types::Result { + as alloy_sol_types::SolType>::abi_decode_sequence(data) + .map(|r| { + let r: ifTaskExistsReturn = r.into(); + r._0 + }) + } + #[inline] + fn abi_decode_returns_validate( + data: &[u8], + ) -> alloy_sol_types::Result { + as alloy_sol_types::SolType>::abi_decode_sequence_validate(data) + .map(|r| { + let r: ifTaskExistsReturn = r.into(); + r._0 + }) + } + } + }; + #[derive(serde::Serialize, serde::Deserialize)] + #[derive(Default, Debug, PartialEq, Eq, Hash)] /**Function with signature `isAutomationEnabled()` and selector `0xe48e0e98`. ```solidity function isAutomationEnabled() external view returns (bool); @@ -3018,9 +3223,9 @@ function isAutomationEnabled() external view returns (bool); }; #[derive(serde::Serialize, serde::Deserialize)] #[derive(Default, Debug, PartialEq, Eq, Hash)] - /**Function with signature `processTasks(uint64,uint64[])` and selector `0x7f69c35c`. + /**Function with signature `processTasks(uint64,uint256[])` and selector `0x40b7cbc6`. ```solidity -function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external; +function processTasks(uint64 _cycleIndex, uint256[] memory _taskIndexes) external; ```*/ #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] @@ -3028,9 +3233,11 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external #[allow(missing_docs)] pub _cycleIndex: u64, #[allow(missing_docs)] - pub _taskIndexes: alloy::sol_types::private::Vec, + pub _taskIndexes: alloy::sol_types::private::Vec< + alloy::sol_types::private::primitives::aliases::U256, + >, } - ///Container type for the return parameters of the [`processTasks(uint64,uint64[])`](processTasksCall) function. + ///Container type for the return parameters of the [`processTasks(uint64,uint256[])`](processTasksCall) function. #[allow(non_camel_case_types, non_snake_case, clippy::pub_underscore_fields)] #[derive(Clone)] pub struct processTasksReturn {} @@ -3047,10 +3254,15 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external #[allow(dead_code)] type UnderlyingSolTuple<'a> = ( alloy::sol_types::sol_data::Uint<64>, - alloy::sol_types::sol_data::Array>, + alloy::sol_types::sol_data::Array>, ); #[doc(hidden)] - type UnderlyingRustTuple<'a> = (u64, alloy::sol_types::private::Vec); + type UnderlyingRustTuple<'a> = ( + u64, + alloy::sol_types::private::Vec< + alloy::sol_types::private::primitives::aliases::U256, + >, + ); #[cfg(test)] #[allow(dead_code, unreachable_patterns)] fn _type_assertion( @@ -3123,7 +3335,7 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external impl alloy_sol_types::SolCall for processTasksCall { type Parameters<'a> = ( alloy::sol_types::sol_data::Uint<64>, - alloy::sol_types::sol_data::Array>, + alloy::sol_types::sol_data::Array>, ); type Token<'a> = = as alloy_sol_types::SolType>::Token<'a>; - const SIGNATURE: &'static str = "processTasks(uint64,uint64[])"; - const SELECTOR: [u8; 4] = [127u8, 105u8, 195u8, 92u8]; + const SIGNATURE: &'static str = "processTasks(uint64,uint256[])"; + const SELECTOR: [u8; 4] = [64u8, 183u8, 203u8, 198u8]; #[inline] fn new<'a>( tuple: as alloy_sol_types::SolType>::RustType, @@ -3148,7 +3360,7 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external 64, > as alloy_sol_types::SolType>::tokenize(&self._cycleIndex), , + alloy::sol_types::sol_data::Uint<256>, > as alloy_sol_types::SolType>::tokenize(&self._taskIndexes), ) } @@ -3182,7 +3394,7 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external #[allow(missing_docs)] blockPrologue(blockPrologueCall), #[allow(missing_docs)] - getAllActiveTaskIds(getAllActiveTaskIdsCall), + getActiveTaskIds(getActiveTaskIdsCall), #[allow(missing_docs)] getCycleStateDetails(getCycleStateDetailsCall), #[allow(missing_docs)] @@ -3192,6 +3404,8 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external #[allow(missing_docs)] getTaskIdList(getTaskIdListCall), #[allow(missing_docs)] + ifTaskExists(ifTaskExistsCall), + #[allow(missing_docs)] isAutomationEnabled(isAutomationEnabledCall), #[allow(missing_docs)] processTasks(processTasksCall), @@ -3205,33 +3419,36 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external /// Prefer using `SolInterface` methods instead. pub const SELECTORS: &'static [[u8; 4usize]] = &[ [18u8, 247u8, 44u8, 244u8], + [35u8, 33u8, 204u8, 163u8], + [64u8, 183u8, 203u8, 198u8], [107u8, 93u8, 140u8, 86u8], [125u8, 237u8, 9u8, 27u8], - [127u8, 105u8, 195u8, 92u8], + [138u8, 170u8, 64u8, 78u8], [178u8, 239u8, 104u8, 150u8], - [197u8, 220u8, 246u8, 172u8], [228u8, 142u8, 14u8, 152u8], [236u8, 130u8, 180u8, 41u8], ]; /// The names of the variants in the same order as `SELECTORS`. pub const VARIANT_NAMES: &'static [&'static str] = &[ ::core::stringify!(getTaskDetailsBulk), + ::core::stringify!(getActiveTaskIds), + ::core::stringify!(processTasks), ::core::stringify!(getCycleStateDetails), ::core::stringify!(blockPrologue), - ::core::stringify!(processTasks), + ::core::stringify!(ifTaskExists), ::core::stringify!(getTaskDetails), - ::core::stringify!(getAllActiveTaskIds), ::core::stringify!(isAutomationEnabled), ::core::stringify!(getTaskIdList), ]; /// The signatures in the same order as `SELECTORS`. pub const SIGNATURES: &'static [&'static str] = &[ ::SIGNATURE, + ::SIGNATURE, + ::SIGNATURE, ::SIGNATURE, ::SIGNATURE, - ::SIGNATURE, + ::SIGNATURE, ::SIGNATURE, - ::SIGNATURE, ::SIGNATURE, ::SIGNATURE, ]; @@ -3260,15 +3477,15 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external impl alloy_sol_types::SolInterface for SupraContractsBindingsCalls { const NAME: &'static str = "SupraContractsBindingsCalls"; const MIN_DATA_LENGTH: usize = 0usize; - const COUNT: usize = 8usize; + const COUNT: usize = 9usize; #[inline] fn selector(&self) -> [u8; 4] { match self { Self::blockPrologue(_) => { ::SELECTOR } - Self::getAllActiveTaskIds(_) => { - ::SELECTOR + Self::getActiveTaskIds(_) => { + ::SELECTOR } Self::getCycleStateDetails(_) => { ::SELECTOR @@ -3282,6 +3499,9 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external Self::getTaskIdList(_) => { ::SELECTOR } + Self::ifTaskExists(_) => { + ::SELECTOR + } Self::isAutomationEnabled(_) => { ::SELECTOR } @@ -3318,6 +3538,28 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external } getTaskDetailsBulk }, + { + fn getActiveTaskIds( + data: &[u8], + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + ) + .map(SupraContractsBindingsCalls::getActiveTaskIds) + } + getActiveTaskIds + }, + { + fn processTasks( + data: &[u8], + ) -> alloy_sol_types::Result { + ::abi_decode_raw( + data, + ) + .map(SupraContractsBindingsCalls::processTasks) + } + processTasks + }, { fn getCycleStateDetails( data: &[u8], @@ -3341,15 +3583,15 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external blockPrologue }, { - fn processTasks( + fn ifTaskExists( data: &[u8], ) -> alloy_sol_types::Result { - ::abi_decode_raw( + ::abi_decode_raw( data, ) - .map(SupraContractsBindingsCalls::processTasks) + .map(SupraContractsBindingsCalls::ifTaskExists) } - processTasks + ifTaskExists }, { fn getTaskDetails( @@ -3362,17 +3604,6 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external } getTaskDetails }, - { - fn getAllActiveTaskIds( - data: &[u8], - ) -> alloy_sol_types::Result { - ::abi_decode_raw( - data, - ) - .map(SupraContractsBindingsCalls::getAllActiveTaskIds) - } - getAllActiveTaskIds - }, { fn isAutomationEnabled( data: &[u8], @@ -3426,6 +3657,28 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external } getTaskDetailsBulk }, + { + fn getActiveTaskIds( + data: &[u8], + ) -> alloy_sol_types::Result { + ::abi_decode_raw_validate( + data, + ) + .map(SupraContractsBindingsCalls::getActiveTaskIds) + } + getActiveTaskIds + }, + { + fn processTasks( + data: &[u8], + ) -> alloy_sol_types::Result { + ::abi_decode_raw_validate( + data, + ) + .map(SupraContractsBindingsCalls::processTasks) + } + processTasks + }, { fn getCycleStateDetails( data: &[u8], @@ -3449,15 +3702,15 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external blockPrologue }, { - fn processTasks( + fn ifTaskExists( data: &[u8], ) -> alloy_sol_types::Result { - ::abi_decode_raw_validate( + ::abi_decode_raw_validate( data, ) - .map(SupraContractsBindingsCalls::processTasks) + .map(SupraContractsBindingsCalls::ifTaskExists) } - processTasks + ifTaskExists }, { fn getTaskDetails( @@ -3470,17 +3723,6 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external } getTaskDetails }, - { - fn getAllActiveTaskIds( - data: &[u8], - ) -> alloy_sol_types::Result { - ::abi_decode_raw_validate( - data, - ) - .map(SupraContractsBindingsCalls::getAllActiveTaskIds) - } - getAllActiveTaskIds - }, { fn isAutomationEnabled( data: &[u8], @@ -3522,8 +3764,8 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external inner, ) } - Self::getAllActiveTaskIds(inner) => { - ::abi_encoded_size( + Self::getActiveTaskIds(inner) => { + ::abi_encoded_size( inner, ) } @@ -3547,6 +3789,11 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external inner, ) } + Self::ifTaskExists(inner) => { + ::abi_encoded_size( + inner, + ) + } Self::isAutomationEnabled(inner) => { ::abi_encoded_size( inner, @@ -3568,8 +3815,8 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external out, ) } - Self::getAllActiveTaskIds(inner) => { - ::abi_encode_raw( + Self::getActiveTaskIds(inner) => { + ::abi_encode_raw( inner, out, ) @@ -3598,6 +3845,12 @@ function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external out, ) } + Self::ifTaskExists(inner) => { + ::abi_encode_raw( + inner, + out, + ) + } Self::isAutomationEnabled(inner) => { ::abi_encode_raw( inner, @@ -3876,11 +4129,11 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/ ) -> alloy_contract::SolCallBuilder<&P, blockPrologueCall, N> { self.call_builder(&blockPrologueCall) } - ///Creates a new call builder for the [`getAllActiveTaskIds`] function. - pub fn getAllActiveTaskIds( + ///Creates a new call builder for the [`getActiveTaskIds`] function. + pub fn getActiveTaskIds( &self, - ) -> alloy_contract::SolCallBuilder<&P, getAllActiveTaskIdsCall, N> { - self.call_builder(&getAllActiveTaskIdsCall) + ) -> alloy_contract::SolCallBuilder<&P, getActiveTaskIdsCall, N> { + self.call_builder(&getActiveTaskIdsCall) } ///Creates a new call builder for the [`getCycleStateDetails`] function. pub fn getCycleStateDetails( @@ -3912,6 +4165,13 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/ ) -> alloy_contract::SolCallBuilder<&P, getTaskIdListCall, N> { self.call_builder(&getTaskIdListCall) } + ///Creates a new call builder for the [`ifTaskExists`] function. + pub fn ifTaskExists( + &self, + _taskIndex: u64, + ) -> alloy_contract::SolCallBuilder<&P, ifTaskExistsCall, N> { + self.call_builder(&ifTaskExistsCall { _taskIndex }) + } ///Creates a new call builder for the [`isAutomationEnabled`] function. pub fn isAutomationEnabled( &self, @@ -3922,7 +4182,9 @@ the bytecode concatenated with the constructor's ABI-encoded arguments.*/ pub fn processTasks( &self, _cycleIndex: u64, - _taskIndexes: alloy::sol_types::private::Vec, + _taskIndexes: alloy::sol_types::private::Vec< + alloy::sol_types::private::primitives::aliases::U256, + >, ) -> alloy_contract::SolCallBuilder<&P, processTasksCall, N> { self.call_builder( &processTasksCall { diff --git a/crates/supra-extension/src/transactions/automated_transaction.rs b/crates/supra-extension/src/transactions/automated_transaction.rs index 541557c9f0..4c313a5f9e 100644 --- a/crates/supra-extension/src/transactions/automated_transaction.rs +++ b/crates/supra-extension/src/transactions/automated_transaction.rs @@ -1,8 +1,8 @@ //! AutomatedTransaction generated based on the registered active automation task. use crate::errors::SupraExtensionError; -use crate::supra_contract_bindings::supra_contracts_bindings::CommonUtils::TaskDetails; use crate::value_or_error; +use crate::TaskMetadata; use alloy::eips::eip2930::AccessList; use alloy::primitives::{Address, Bytes, ChainId, B256, U256}; use alloy_consensus::transaction::Transaction; @@ -243,7 +243,19 @@ type ExpandedPayloadTy = ( ); /// Evm automation task execution payload. -#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize, Getters, Dissolve, Constructor)] +#[derive( + Clone, + Debug, + Default, + PartialEq, + Eq, + Hash, + Serialize, + Deserialize, + Getters, + Dissolve, + Constructor, +)] pub struct TaskPayload { to: Address, value: U256, @@ -252,7 +264,6 @@ pub struct TaskPayload { } impl TaskPayload { - /// Generates random [`TaskPayload`] for testing propose only. pub fn random() -> Self { TaskPayload { @@ -262,7 +273,6 @@ impl TaskPayload { access_list: AccessList::default(), } } - } impl TryFrom<&[u8]> for TaskPayload { @@ -503,11 +513,11 @@ impl AutomatedTransactionBuilder { /// Fails if: /// - inner payload cannot be deserialized based on the [`ExpandedPayloadTy`] schema /// - Loaded task is not in active state (Active | Cancelled) -impl TryFrom for AutomatedTransactionBuilder { +impl TryFrom for AutomatedTransactionBuilder { type Error = SupraExtensionError; - fn try_from(value: TaskDetails) -> Result { - let TaskDetails { + fn try_from(value: TaskMetadata) -> Result { + let TaskMetadata { maxGasAmount, gasPriceCap, automationFeeCapForCycle: _, @@ -519,12 +529,14 @@ impl TryFrom for AutomatedTransactionBuilder { priority, taskType, owner, - state, + taskState, payloadTx, + // TODO: handle predicate + predicate: _, auxData: _, } = value; - if AutomationTaskState::try_from(state)? == AutomationTaskState::Pending { + if AutomationTaskState::try_from(taskState)? == AutomationTaskState::Pending { return Err(SupraExtensionError::InvalidAutomationTaskStateForBuilder); } let typ = AutomatedTransactionType::try_from(taskType)?; diff --git a/crates/supra-extension/src/transactions/automation_record.rs b/crates/supra-extension/src/transactions/automation_record.rs index 309bb37728..9485fc64a9 100644 --- a/crates/supra-extension/src/transactions/automation_record.rs +++ b/crates/supra-extension/src/transactions/automation_record.rs @@ -1,6 +1,6 @@ //! Automation registry transaction record definition to assist automation bookkeeping. use crate::errors::SupraExtensionError; -use crate::supra_contract_bindings::supra_contracts_bindings::SupraContractsBindings::processTasksCall; +use crate::processTasksCall; use crate::value_or_error; use alloy::eips::eip2930::AccessList; use alloy::primitives::{Address, Bytes, ChainId, TxKind, B256, U256}; @@ -227,7 +227,7 @@ impl AutomationRecordBuilder { pub fn get_process_tasks_payload(_cycle_index: u64, _task_indexes: Vec) -> Bytes { let process_task_call = processTasksCall { _cycleIndex: _cycle_index, - _taskIndexes: _task_indexes, + _taskIndexes: _task_indexes.into_iter().map(U256::from).collect(), }; Bytes::from(process_task_call.abi_encode()) } diff --git a/crates/supra-extension/src/transactions/block_metadata.rs b/crates/supra-extension/src/transactions/block_metadata.rs index 77b7f7fa53..ac72b2fdbd 100644 --- a/crates/supra-extension/src/transactions/block_metadata.rs +++ b/crates/supra-extension/src/transactions/block_metadata.rs @@ -2,7 +2,7 @@ //! to aid block based checks to assist chain regular operations use crate::errors::SupraExtensionError; -use crate::supra_contract_bindings::supra_contracts_bindings::SupraContractsBindings::blockPrologueCall; +use crate::blockPrologueCall; use crate::value_or_error; use alloy::primitives::{Address, Bytes, ChainId, B256, U256}; use alloy_consensus::transaction::Transaction; diff --git a/solidity/supra_contracts/foundry.toml b/solidity/supra_contracts/foundry.toml index b1b1fa7da9..4994e0fd18 100644 --- a/solidity/supra_contracts/foundry.toml +++ b/solidity/supra_contracts/foundry.toml @@ -4,9 +4,12 @@ out = "out" libs = ["lib"] via_ir = true optimizer = true +evm_version = "prague" # Uncomment when running agains supra chain -# eth_rpc_url = "http://localhost:27000/rpc/v1/eth/wallet_integration" +#eth_rpc_url = "http://localhost:27000/rpc/v1/eth/wallet_integration" + +remappings = ["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/"] # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/solidity/supra_contracts/script/DeployDiamond.s.sol b/solidity/supra_contracts/script/DeployDiamond.s.sol index f46549e1aa..463347146e 100644 --- a/solidity/supra_contracts/script/DeployDiamond.s.sol +++ b/solidity/supra_contracts/script/DeployDiamond.s.sol @@ -39,21 +39,18 @@ contract DeployDiamond is Script { function run() external { vm.startBroadcast(); - // Deploy the Diamond, its facets and the DiamondInit - Deployment memory deployment = LibDiamondUtils.deploy(multiSig); - - // Execute the diamond cut to initialize the Diamond state - LibDiamondUtils.executeCut(vmSigner, erc20Supra, initParams, deployment); + // Deploy the Diamond, its facets and the DiamondInit and initialize the Diamond in a single transaction + Deployment memory deployment = LibDiamondUtils.deploy(multiSig, vmSigner, erc20Supra, initParams); console.log("Diamond owner:", OwnershipFacet(address(deployment.diamond)).owner()); console.log("Diamond deployed at:", address(deployment.diamond)); - console.log("DiamondCutFacet deployed at:", address(deployment.diamondCutFacet)); - console.log("DiamondLoupeFacet deployed at:", address(deployment.loupeFacet)); - console.log("OwnershipFacet deployed at:", address(deployment.ownershipFacet)); - console.log("ConfigFacet deployed at:", address(deployment.configFacet)); - console.log("RegistryFacet deployed at:", address(deployment.registryFacet)); - console.log("CoreFacet deployed at:", address(deployment.coreFacet)); - console.log("DiamondInit deployed at:", address(deployment.diamondInit)); + console.log("DiamondCutFacet deployed at:", address(deployment.facets.diamondCutFacet)); + console.log("DiamondLoupeFacet deployed at:", address(deployment.facets.loupeFacet)); + console.log("OwnershipFacet deployed at:", address(deployment.facets.ownershipFacet)); + console.log("ConfigFacet deployed at:", address(deployment.facets.configFacet)); + console.log("RegistryFacet deployed at:", address(deployment.facets.registryFacet)); + console.log("CoreFacet deployed at:", address(deployment.facets.coreFacet)); + console.log("DiamondInit deployed at:", address(deployment.facets.diamondInit)); vm.stopBroadcast(); } diff --git a/solidity/supra_contracts/script/GovActions.s.sol b/solidity/supra_contracts/script/GovActions.s.sol index 630482ca6c..a4df43311c 100644 --- a/solidity/supra_contracts/script/GovActions.s.sol +++ b/solidity/supra_contracts/script/GovActions.s.sol @@ -8,14 +8,14 @@ import {BlockMeta} from "../src/BlockMeta.sol"; contract InitializeCycleMonitoring is Script { address payable multisigWalletAddr; address blockMetadata; - address automationController; + address registry; bytes4 selector; uint64 timeout; function setUp() public { multisigWalletAddr = payable(vm.envAddress("MULTISIG_WALLET_ADDRESS")); blockMetadata = vm.envAddress("BLOCK_METADATA_ADDRESS"); - automationController = vm.envAddress("AUTOMATION_CONTROLLER"); + registry = vm.envAddress("REGISTRY"); selector = bytes4(keccak256("monitorCycleEnd()")); timeout = uint64(vm.envUint("TIMEOUT")); } @@ -28,9 +28,9 @@ contract InitializeCycleMonitoring is Script { uint256 nextTxnIndex = wallet.getNextTransactionIndex(); console.log("TxnIndex: ", nextTxnIndex); - // Submit a foundation/gov action to register automationController::monitor_cycle_event + // Submit a foundation/gov action to register registry::monitor_cycle_event // to be executed for each block - bytes memory data = abi.encodeCall(BlockMeta.register, (automationController, selector)); + bytes memory data = abi.encodeCall(BlockMeta.register, (registry, selector)); wallet.submitTransaction(blockMetadata, 0, timeout, data); vm.stopBroadcast(); diff --git a/solidity/supra_contracts/script/MintErc20Supra.s.sol b/solidity/supra_contracts/script/MintErc20Supra.s.sol index 00b16db152..19e360b2b2 100644 --- a/solidity/supra_contracts/script/MintErc20Supra.s.sol +++ b/solidity/supra_contracts/script/MintErc20Supra.s.sol @@ -18,7 +18,7 @@ contract MintErc20Supra is Script { allowance = uint64(vm.envUint("ALLOWANCE")); erc20SupraAddr = vm.envAddress("ERC20SUPRA"); erc20SupraHandlerAddr = payable(vm.envAddress("ERC20SUPRA_HANDLER")); - authority = vm.envAddress("AUTOMATION_REGISTRY"); + authority = vm.envAddress("REGISTRY"); } function run() public { @@ -35,8 +35,9 @@ contract MintErc20Supra is Script { // Then do the conversion erc20SupraHandler.deposit{value: value}(); + uint256 conf_all = erc20Supra.allowance(msg.sender, authority); - console.log("Sender: ", msg.sender); + console.log("Sender: ", msg.sender, conf_all, authority); console.log("Token balance after: ", erc20Supra.balanceOf(msg.sender)); vm.stopBroadcast(); diff --git a/solidity/supra_contracts/script/RegisterAutomationTask.s.sol b/solidity/supra_contracts/script/RegisterAutomationTask.s.sol index bb35889e0e..1474e70a52 100644 --- a/solidity/supra_contracts/script/RegisterAutomationTask.s.sol +++ b/solidity/supra_contracts/script/RegisterAutomationTask.s.sol @@ -13,7 +13,7 @@ contract RegisterAutomationTask is Script { uint64 automationFeeCap; uint128 taskMaxGas; uint128 taskGasPriceCap; - address diamond; + address registry; address erc20supra; address target; @@ -23,7 +23,7 @@ contract RegisterAutomationTask is Script { taskDurationSecs = uint64(vm.envUint("TASK_DURATION_SEC")); taskMaxGas = uint128(vm.envUint("TASK_MAX_GAS")); taskGasPriceCap = uint128(vm.envUint("TASK_GAS_PRICE_CAP")); - diamond = vm.envAddress("DIAMOND"); + registry = vm.envAddress("REGISTRY"); erc20supra = vm.envAddress("ERC20SUPRA"); target = vm.envAddress("TARGET"); automationFeeCap = uint64(vm.envUint("TASK_AUTOMATION_FEE_CAP")); @@ -36,13 +36,14 @@ contract RegisterAutomationTask is Script { function run() public { vm.startBroadcast(); - IRegistryFacet registryFacet = IRegistryFacet(diamond); + IRegistryFacet registryFacet = IRegistryFacet(registry); + IConfigFacet configFacet = IConfigFacet(registry); bytes[] memory auxData; uint64 taskIdx = registryFacet.getNextTaskIndex(); console.log("Next task index ", taskIdx); bytes memory payload = createPayload(0, target, erc20supra); - bytes memory predicate = createPredicate(diamond); + bytes memory predicate = createPredicate(registry); registryFacet.register( payload, diff --git a/solidity/supra_contracts/src/Diamond.sol b/solidity/supra_contracts/src/Diamond.sol index 59bdd96247..97e0302822 100644 --- a/solidity/supra_contracts/src/Diamond.sol +++ b/solidity/supra_contracts/src/Diamond.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity 0.8.27; /******************************************************************************\ * Author: Nick Mudge (https://twitter.com/mudgen) @@ -8,24 +8,92 @@ pragma solidity ^0.8.0; * Implementation of a diamond. /******************************************************************************/ -import { LibDiamond } from "./libraries/LibDiamond.sol"; -import { IDiamondCut } from "./interfaces/IDiamondCut.sol"; +import {LibDiamond} from "./libraries/LibDiamond.sol"; +import {LibUtils} from "./libraries/LibUtils.sol"; +import {LibAppStorage} from "./libraries/LibAppStorage.sol"; +import {IDiamondCut} from "./interfaces/IDiamondCut.sol"; +import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol"; +import {IFacetSelectors} from "./interfaces/IFacetSelectors.sol"; +import {DiamondInit} from "./upgradeInitializers/DiamondInit.sol"; +import {FacetsDeployment, InitParams} from "./libraries/DiamondTypes.sol"; +import { IERC173 } from "./interfaces/IERC173.sol"; +import { IERC165 } from "./interfaces/IERC165.sol"; -contract Diamond { +contract Diamond { + using LibUtils for address; - constructor(address _contractOwner, address _diamondCutFacet) { + /// @notice Deploy and fully initialize the Diamond in a single transaction. + /// @param _contractOwner Address that will own the diamond. + /// @param _d Addresses of all deployed facets and DiamondInit. + /// `_d.diamond` is ignored (this contract is the diamond). + /// @param _vmSigner VM signer address passed to DiamondInit. + /// @param _erc20Supra ERC20Supra contract address passed to DiamondInit. + /// @param _params Registry configuration passed to DiamondInit. + constructor( + address _contractOwner, + FacetsDeployment memory _d, + address _vmSigner, + address _erc20Supra, + InitParams memory _params + ) { LibDiamond.setContractOwner(_contractOwner); - // Add the diamondCut external function from the diamondCutFacet - IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1); - bytes4[] memory functionSelectors = new bytes4[](1); - functionSelectors[0] = IDiamondCut.diamondCut.selector; + _d.configFacet.validateContractAddress(); + _d.coreFacet.validateContractAddress(); + _d.diamondCutFacet.validateContractAddress(); + _d.registryFacet.validateContractAddress(); + _d.ownershipFacet.validateContractAddress(); + _d.diamondInit.validateContractAddress(); + + // ------------------------------------------------------------------ + // Build the full cut array: + // slot 0 — diamondCut function (from DiamondCutFacet) + // slots 1-5 — remaining facets, each self-reporting their selectors + // ------------------------------------------------------------------ + IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](6); + + bytes4[] memory cutSelectors = new bytes4[](1); + cutSelectors[0] = IDiamondCut.diamondCut.selector; cut[0] = IDiamondCut.FacetCut({ - facetAddress: _diamondCutFacet, - action: IDiamondCut.FacetCutAction.Add, - functionSelectors: functionSelectors + facetAddress: _d.diamondCutFacet, + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: cutSelectors }); - LibDiamond.diamondCut(cut, address(0), ""); + + address[5] memory facets = [ + _d.loupeFacet, + _d.ownershipFacet, + _d.configFacet, + _d.registryFacet, + _d.coreFacet + ]; + for (uint256 i = 0; i < 5; i++) { + cut[i + 1] = IDiamondCut.FacetCut({ + facetAddress: facets[i], + action: IDiamondCut.FacetCutAction.Add, + functionSelectors: IFacetSelectors(facets[i]).getSelectors() + }); + } + + // ------------------------------------------------------------------ + // Encode DiamondInit.init calldata and apply all cuts atomically + // ------------------------------------------------------------------ + bytes memory initCalldata = abi.encodeCall( + DiamondInit.init, + (_params, _vmSigner, _erc20Supra) + ); + + LibDiamond.diamondCut(cut, _d.diamondInit, initCalldata); + } + + /// @notice Returns true if the automation feature is enabled and the diamond has been initialized. + function is_feature_enabled_and_initialized() external view returns (bool) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + bool initialized = ds.supportedInterfaces[type(IERC165).interfaceId] && + ds.supportedInterfaces[type(IDiamondCut).interfaceId] && + ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] && + ds.supportedInterfaces[type(IERC173).interfaceId]; + return initialized && LibAppStorage.appStorage().automationEnabled; } // Find facet for function that is called and execute the @@ -50,12 +118,8 @@ contract Diamond { returndatacopy(0, 0, returndatasize()) // return any return value or error back to the caller switch result - case 0 { - revert(0, returndatasize()) - } - default { - return(0, returndatasize()) - } + case 0 { revert(0, returndatasize()) } + default { return(0, returndatasize()) } } } -} +} \ No newline at end of file diff --git a/solidity/supra_contracts/src/SupraContractsBindings.sol b/solidity/supra_contracts/src/SupraContractsBindings.sol index c2ab613946..8b5df3987c 100644 --- a/solidity/supra_contracts/src/SupraContractsBindings.sol +++ b/solidity/supra_contracts/src/SupraContractsBindings.sol @@ -15,11 +15,10 @@ interface SupraContractsBindings { // View functions of CoreFacet function isAutomationEnabled() external view returns (bool); - function getCycleInfo() external view returns (uint64, uint64, uint64, LibCommon.CycleState); - function getTransitionInfo() external view returns (uint64, uint128); + function getCycleStateDetails() external view returns (LibCommon.CycleDetails memory); // Entry function to be called by node runtime for bookkeeping - function processTasks(uint64 _cycleIndex, uint64[] memory _taskIndexes) external; + function processTasks(uint64 _cycleIndex, uint256[] memory _taskIndexes) external; // Entry function of the BlockMeta for block metadata transaction function blockPrologue() external; diff --git a/solidity/supra_contracts/src/facets/ConfigFacet.sol b/solidity/supra_contracts/src/facets/ConfigFacet.sol index f9cc25a694..476988ecee 100644 --- a/solidity/supra_contracts/src/facets/ConfigFacet.sol +++ b/solidity/supra_contracts/src/facets/ConfigFacet.sol @@ -5,14 +5,15 @@ import {AppStorage, Config, RegistryState, LibAppStorage} from "../libraries/Lib import {LibCommon} from "../libraries/LibCommon.sol"; import {LibUtils} from "../libraries/LibUtils.sol"; import {IConfigFacet} from "../interfaces/IConfigFacet.sol"; +import {IFacetSelectors} from "../interfaces/IFacetSelectors.sol"; import {LibDiamond} from "../libraries/LibDiamond.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; -contract ConfigFacet is IConfigFacet { +contract ConfigFacet is IConfigFacet, IFacetSelectors { using EnumerableSet for *; - /// @dev State variables + /// @dev State variables AppStorage internal s; // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ADMIN FUNCTIONS ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -159,4 +160,19 @@ contract ConfigFacet is IConfigFacet { function getConfigBuffer() external view returns (Config memory) { return LibAppStorage.bufferConfig(); } + + function getSelectors() external pure override returns (bytes4[] memory selectors) { + selectors = new bytes4[](11); + selectors[0] = ConfigFacet.grantAuthorization.selector; + selectors[1] = ConfigFacet.revokeAuthorization.selector; + selectors[2] = ConfigFacet.enableRegistration.selector; + selectors[3] = ConfigFacet.disableRegistration.selector; + selectors[4] = ConfigFacet.withdrawFees.selector; + selectors[5] = ConfigFacet.updateConfigBuffer.selector; + selectors[6] = ConfigFacet.getVmSigner.selector; + selectors[7] = ConfigFacet.erc20Supra.selector; + selectors[8] = ConfigFacet.isRegistrationEnabled.selector; + selectors[9] = ConfigFacet.getConfig.selector; + selectors[10] = ConfigFacet.getConfigBuffer.selector; + } } \ No newline at end of file diff --git a/solidity/supra_contracts/src/facets/CoreFacet.sol b/solidity/supra_contracts/src/facets/CoreFacet.sol index fbe7abdd55..861964c922 100644 --- a/solidity/supra_contracts/src/facets/CoreFacet.sol +++ b/solidity/supra_contracts/src/facets/CoreFacet.sol @@ -6,10 +6,11 @@ import {LibCommon} from "../libraries/LibCommon.sol"; import {LibCore} from "../libraries/LibCore.sol"; import {LibUtils} from "../libraries/LibUtils.sol"; import {ICoreFacet} from "../interfaces/ICoreFacet.sol"; +import {IFacetSelectors} from "../interfaces/IFacetSelectors.sol"; import {LibDiamond} from "../libraries/LibDiamond.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; -contract CoreFacet is ICoreFacet { +contract CoreFacet is ICoreFacet, IFacetSelectors { using LibUtils for address; using EnumerableSet for EnumerableSet.UintSet; @@ -83,19 +84,7 @@ contract CoreFacet is ICoreFacet { return (s.index, s.startTime, s.durationSecs, s.cycleState); } - /// @notice Returns the index, start time, duration, state, transition details if any of the current cycle. - function getCycleStateDetails() external view returns (LibCommon.CycleDetails memory details) { - TransitionState storage transitionState = LibAppStorage.transitionState(); - - details.index = s.index; - details.startTime = s.startTime; - details.durationSecs = s.durationSecs; - details.state = s.cycleState; - details.nextTaskIndexPosition = transitionState.nextTaskIndexPosition; - details.expectedTasksToBeProcessed = transitionState.expectedTasksToBeProcessed.values(); - } - - /// @notice Returns the duration of the current cycle. + /// @notice Returns the duration of the current cycle. function getCycleDuration() external view returns (uint64) { return s.durationSecs; } @@ -108,6 +97,17 @@ contract CoreFacet is ICoreFacet { return (transitionState.refundDuration, transitionState.automationFeePerSec); } + /// @notice Returns the index, start time, duration, state, transition details if any of the current cycle. + function getCycleStateDetails() external view returns (LibCommon.CycleDetails memory details) { + details.index = s.index; + details.startTime = s.startTime; + details.durationSecs = s.durationSecs; + details.state = s.cycleState; + TransitionState storage transitionState = LibAppStorage.transitionState(); + details.nextTaskIndexPosition = transitionState.nextTaskIndexPosition; + details.expectedTasksToBeProcessed = LibUtils.uintSetToUint64Array(transitionState.expectedTasksToBeProcessed); + } + /// @notice Returns if automation is enabled. function isAutomationEnabled() external view returns (bool) { return s.automationEnabled; @@ -119,7 +119,21 @@ contract CoreFacet is ICoreFacet { function removeRegisteredTask(uint64 _taskIndex, string memory _reason) external { // Check caller is VM Signer msg.sender.enforceIsVmSigner(s.vmSigner); - + LibCore.handleTaskRemoval(_taskIndex, _reason); } + + function getSelectors() external pure override returns (bytes4[] memory selectors) { + selectors = new bytes4[](10); + selectors[0] = CoreFacet.processTasks.selector; + selectors[1] = CoreFacet.monitorCycleEnd.selector; + selectors[2] = CoreFacet.enableAutomation.selector; + selectors[3] = CoreFacet.disableAutomation.selector; + selectors[4] = CoreFacet.removeRegisteredTask.selector; + selectors[5] = CoreFacet.getCycleInfo.selector; + selectors[6] = CoreFacet.getCycleDuration.selector; + selectors[7] = CoreFacet.getTransitionInfo.selector; + selectors[8] = CoreFacet.isAutomationEnabled.selector; + selectors[9] = CoreFacet.getCycleStateDetails.selector; + } } diff --git a/solidity/supra_contracts/src/facets/DiamondLoupeFacet.sol b/solidity/supra_contracts/src/facets/DiamondLoupeFacet.sol index 538516f91a..079a8727f1 100644 --- a/solidity/supra_contracts/src/facets/DiamondLoupeFacet.sol +++ b/solidity/supra_contracts/src/facets/DiamondLoupeFacet.sol @@ -8,11 +8,13 @@ pragma solidity ^0.8.0; import { LibDiamond } from "../libraries/LibDiamond.sol"; import { IDiamondLoupe } from "../interfaces/IDiamondLoupe.sol"; import { IERC165 } from "../interfaces/IERC165.sol"; +import { IFacetSelectors } from "../interfaces/IFacetSelectors.sol"; // The functions in DiamondLoupeFacet MUST be added to a diamond. // The EIP-2535 Diamond standard requires these functions. -contract DiamondLoupeFacet is IDiamondLoupe, IERC165 { +contract DiamondLoupeFacet is IDiamondLoupe, IERC165, IFacetSelectors { + // Diamond Loupe Functions //////////////////////////////////////////////////////////////////// /// These functions are expected to be called frequently by tools. @@ -64,4 +66,13 @@ contract DiamondLoupeFacet is IDiamondLoupe, IERC165 { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); return ds.supportedInterfaces[_interfaceId]; } + + function getSelectors() external pure override returns (bytes4[] memory s) { + s = new bytes4[](5); + s[0] = DiamondLoupeFacet.facets.selector; + s[1] = DiamondLoupeFacet.facetFunctionSelectors.selector; + s[2] = DiamondLoupeFacet.facetAddresses.selector; + s[3] = DiamondLoupeFacet.facetAddress.selector; + s[4] = DiamondLoupeFacet.supportsInterface.selector; + } } diff --git a/solidity/supra_contracts/src/facets/OwnershipFacet.sol b/solidity/supra_contracts/src/facets/OwnershipFacet.sol index 45cba09baa..a68d0ded76 100644 --- a/solidity/supra_contracts/src/facets/OwnershipFacet.sol +++ b/solidity/supra_contracts/src/facets/OwnershipFacet.sol @@ -3,8 +3,10 @@ pragma solidity ^0.8.0; import { LibDiamond } from "../libraries/LibDiamond.sol"; import { IERC173 } from "../interfaces/IERC173.sol"; +import { IFacetSelectors } from "../interfaces/IFacetSelectors.sol"; + +contract OwnershipFacet is IERC173, IFacetSelectors { -contract OwnershipFacet is IERC173 { function transferOwnership(address _newOwner) external override { LibDiamond.enforceIsContractOwner(); LibDiamond.setContractOwner(_newOwner); @@ -13,4 +15,10 @@ contract OwnershipFacet is IERC173 { function owner() external override view returns (address owner_) { owner_ = LibDiamond.contractOwner(); } + + function getSelectors() external pure override returns (bytes4[] memory s) { + s = new bytes4[](2); + s[0] = OwnershipFacet.owner.selector; + s[1] = OwnershipFacet.transferOwnership.selector; + } } diff --git a/solidity/supra_contracts/src/facets/RegistryFacet.sol b/solidity/supra_contracts/src/facets/RegistryFacet.sol index 9bc687eca6..5ecf87d35c 100644 --- a/solidity/supra_contracts/src/facets/RegistryFacet.sol +++ b/solidity/supra_contracts/src/facets/RegistryFacet.sol @@ -6,10 +6,11 @@ import {LibAccounting} from "../libraries/LibAccounting.sol"; import {LibCommon} from "../libraries/LibCommon.sol"; import {LibRegistry} from "../libraries/LibRegistry.sol"; import {IRegistryFacet} from "../interfaces/IRegistryFacet.sol"; +import {IFacetSelectors} from "../interfaces/IFacetSelectors.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; -contract RegistryFacet is IRegistryFacet { +contract RegistryFacet is IRegistryFacet, IFacetSelectors { using EnumerableSet for *; /// @dev State variables @@ -408,4 +409,44 @@ contract RegistryFacet is IRegistryFacet { _committedOccupancy ); } + + function getSelectors() external pure override returns (bytes4[] memory selectors) { + selectors = new bytes4[](36); + selectors[0] = RegistryFacet.register.selector; + selectors[1] = RegistryFacet.registerSystemTask.selector; + selectors[2] = RegistryFacet.cancelTasks.selector; + selectors[3] = RegistryFacet.cancelSystemTasks.selector; + selectors[4] = RegistryFacet.stopTasks.selector; + selectors[5] = RegistryFacet.stopSystemTasks.selector; + selectors[6] = RegistryFacet.getTaskIdList.selector; + selectors[7] = RegistryFacet.getSystemTaskIds.selector; + selectors[8] = RegistryFacet.getTaskOwner.selector; + selectors[9] = RegistryFacet.getNextTaskIndex.selector; + selectors[10] = RegistryFacet.totalTasks.selector; + selectors[11] = RegistryFacet.totalSystemTasks.selector; + selectors[12] = RegistryFacet.getTaskDetails.selector; + selectors[13] = RegistryFacet.getTaskDetailsBulk.selector; + selectors[14] = this.isAuthorizedSubmitter.selector; + selectors[15] = RegistryFacet.getTotalActiveTasks.selector; + selectors[16] = RegistryFacet.getActiveTaskIds.selector; + selectors[17] = this.hasActiveUserTask.selector; + selectors[18] = this.hasActiveSystemTask.selector; + selectors[19] = this.hasActiveTaskOfType.selector; + selectors[20] = RegistryFacet.getGasCommittedForNextCycle.selector; + selectors[21] = RegistryFacet.getGasCommittedForCurrentCycle.selector; + selectors[22] = RegistryFacet.getSystemGasCommittedForNextCycle.selector; + selectors[23] = RegistryFacet.getSystemGasCommittedForCurrentCycle.selector; + selectors[24] = RegistryFacet.getNextCycleRegistryMaxGasCap.selector; + selectors[25] = RegistryFacet.getNextCycleSysRegistryMaxGasCap.selector; + selectors[26] = RegistryFacet.getCycleLockedFees.selector; + selectors[27] = RegistryFacet.getTotalDepositedAutomationFees.selector; + selectors[28] = RegistryFacet.getTotalLockedBalance.selector; + selectors[29] = RegistryFacet.calculateAutomationFeeMultiplierForCommittedOccupancy.selector; + selectors[30] = RegistryFacet.calculateAutomationFeeMultiplierForCurrentCycle.selector; + selectors[31] = RegistryFacet.estimateAutomationFee.selector; + selectors[32] = RegistryFacet.estimateAutomationFeeWithCommittedOccupancy.selector; + selectors[33] = RegistryFacet.ifTaskExists.selector; + selectors[34] = RegistryFacet.ifSysTaskExists.selector; + selectors[35] = RegistryFacet.getTasksByAddress.selector; + } } diff --git a/solidity/supra_contracts/src/interfaces/IFacetSelectors.sol b/solidity/supra_contracts/src/interfaces/IFacetSelectors.sol new file mode 100644 index 0000000000..418b2e17d9 --- /dev/null +++ b/solidity/supra_contracts/src/interfaces/IFacetSelectors.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +/// @notice Implemented by every facet so the Diamond constructor can +/// retrieve its function selectors without a central registry. +interface IFacetSelectors { + function getSelectors() external pure returns (bytes4[] memory); +} \ No newline at end of file diff --git a/solidity/supra_contracts/src/libraries/DiamondTypes.sol b/solidity/supra_contracts/src/libraries/DiamondTypes.sol new file mode 100644 index 0000000000..f9bab03c46 --- /dev/null +++ b/solidity/supra_contracts/src/libraries/DiamondTypes.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.27; + +struct FacetsDeployment { + address diamondCutFacet; + address loupeFacet; + address ownershipFacet; + address configFacet; + address registryFacet; + address coreFacet; + address diamondInit; +} + +struct InitParams { + uint64 taskDurationCapSecs; + uint128 registryMaxGasCap; + uint128 automationBaseFeeWeiPerSec; + uint128 flatRegistrationFeeWei; + uint8 congestionThresholdPercentage; + uint128 congestionBaseFeeWeiPerSec; + uint8 congestionExponent; + uint16 taskCapacity; + uint64 cycleDurationSecs; + uint64 sysTaskDurationCapSecs; + uint128 sysRegistryMaxGasCap; + uint16 sysTaskCapacity; + bool automationEnabled; + bool registrationEnabled; +} diff --git a/solidity/supra_contracts/src/libraries/LibCommon.sol b/solidity/supra_contracts/src/libraries/LibCommon.sol index 52b2b091b3..cdc161f828 100644 --- a/solidity/supra_contracts/src/libraries/LibCommon.sol +++ b/solidity/supra_contracts/src/libraries/LibCommon.sol @@ -6,7 +6,16 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet library LibCommon { using EnumerableSet for EnumerableSet.UintSet; - + + struct CycleDetails { + uint64 index; + uint64 startTime; + uint64 durationSecs; + LibCommon.CycleState state; + uint64 nextTaskIndexPosition; + uint64[] expectedTasksToBeProcessed; + } + /// @notice Enum describing state of the cycle. enum CycleState { READY, @@ -28,16 +37,6 @@ library LibCommon { GST } - /// @notice Struct to hold cycle details. - struct CycleDetails { - uint64 index; - uint64 startTime; - uint64 durationSecs; - CycleState state; - uint64 nextTaskIndexPosition; - uint256[] expectedTasksToBeProcessed; - } - /// @notice Represents intermediate state of the registry on cycle change. struct IntermediateStateOfCycleChange { uint256 cycleLockedFees; diff --git a/solidity/supra_contracts/src/libraries/LibDiamondUtils.sol b/solidity/supra_contracts/src/libraries/LibDiamondUtils.sol index 03b5c6e2c1..01d49d4c42 100644 --- a/solidity/supra_contracts/src/libraries/LibDiamondUtils.sol +++ b/solidity/supra_contracts/src/libraries/LibDiamondUtils.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.27; +pragma solidity ^0.8.27; import {Diamond} from "../Diamond.sol"; import {DiamondCutFacet} from "../facets/DiamondCutFacet.sol"; @@ -9,40 +9,13 @@ import {ConfigFacet} from "../facets/ConfigFacet.sol"; import {RegistryFacet} from "../facets/RegistryFacet.sol"; import {CoreFacet} from "../facets/CoreFacet.sol"; import {DiamondInit} from "../upgradeInitializers/DiamondInit.sol"; -import {IDiamondCut} from "../interfaces/IDiamondCut.sol"; - -// ============================================================= -// STRUCTS -// ============================================================= +import {FacetsDeployment, InitParams} from "../libraries/DiamondTypes.sol"; struct Deployment { - address diamondCutFacet; + FacetsDeployment facets; address diamond; - address loupeFacet; - address ownershipFacet; - address configFacet; - address registryFacet; - address coreFacet; - address diamondInit; } -struct InitParams { - uint64 taskDurationCapSecs; - uint128 registryMaxGasCap; - uint128 automationBaseFeeWeiPerSec; - uint128 flatRegistrationFeeWei; - uint8 congestionThresholdPercentage; - uint128 congestionBaseFeeWeiPerSec; - uint8 congestionExponent; - uint16 taskCapacity; - uint64 cycleDurationSecs; - uint64 sysTaskDurationCapSecs; - uint128 sysRegistryMaxGasCap; - uint16 sysTaskCapacity; - bool automationEnabled; - bool registrationEnabled; -} - library LibDiamondUtils { // ============================================================= @@ -72,215 +45,33 @@ library LibDiamondUtils { // DEPLOY FUNCTION // ============================================================= - function deploy(address _owner) internal returns (Deployment memory d) { - - // 1) Deploy DiamondCutFacet - DiamondCutFacet cutFacet = new DiamondCutFacet(); - d.diamondCutFacet = address(cutFacet); - - // 2) Deploy Diamond - Diamond diamond = new Diamond(_owner, address(cutFacet)); - d.diamond = address(diamond); - - // 3. Deploy other facets - DiamondLoupeFacet loupeFacet = new DiamondLoupeFacet(); - OwnershipFacet ownershipFacet = new OwnershipFacet(); - ConfigFacet configFacet = new ConfigFacet(); - RegistryFacet registryFacet = new RegistryFacet(); - CoreFacet coreFacet = new CoreFacet(); - - d.loupeFacet = address(loupeFacet); - d.ownershipFacet = address(ownershipFacet); - d.configFacet = address(configFacet); - d.registryFacet = address(registryFacet); - d.coreFacet = address(coreFacet); - - // 4) Deploy DiamondInit - DiamondInit diamondInit = new DiamondInit(); - d.diamondInit = address(diamondInit); - } - - // ============================================================= - // EXECUTE DIAMOND CUT - // ============================================================= - - function executeCut( + /// @notice Deploys all facets, DiamondInit, and a fully-initialized Diamond + /// in a single call. The Diamond constructor applies all facet cuts + /// and runs DiamondInit atomically. + function deploy( + address _owner, address _vmSigner, address _erc20Supra, - InitParams memory _params, - Deployment memory _deployment - ) internal { - - // 1) Build the facet cuts - IDiamondCut.FacetCut[] memory cut = buildFacetCuts( - _deployment.loupeFacet, - _deployment.ownershipFacet, - _deployment.configFacet, - _deployment.registryFacet, - _deployment.coreFacet - ); - - // 2) Prepare init calldata for DiamondInit - bytes memory initCalldata = abi.encodeCall( - DiamondInit.init, - ( - _params, - _vmSigner, - _erc20Supra - ) - ); - - // 3) Execute diamondCut to add all the facets and initialize the state - IDiamondCut(_deployment.diamond).diamondCut( - cut, - _deployment.diamondInit, - initCalldata - ); + InitParams memory _params + ) internal returns (Deployment memory d) { + d.facets = deploy_facets(); + d.diamond = address (new Diamond(_owner, d.facets, _vmSigner, _erc20Supra, _params)); } + /// @notice Deploys all facets, DiamondInit. + function deploy_facets() internal returns (FacetsDeployment memory d) { - // ============================================================= - // FACET CUT BUILDER - // ============================================================= - - function buildFacetCuts( - address loupeFacet, - address ownershipFacet, - address configFacet, - address registryFacet, - address coreFacet - ) internal pure returns (IDiamondCut.FacetCut[] memory cut) { - cut = new IDiamondCut.FacetCut[](5); - - // ------------------------------------------------------------ - // DiamondLoupeFacet - // ------------------------------------------------------------ - { - bytes4[] memory selectors = new bytes4[](5); - selectors[0] = DiamondLoupeFacet.facets.selector; - selectors[1] = DiamondLoupeFacet.facetFunctionSelectors.selector; - selectors[2] = DiamondLoupeFacet.facetAddresses.selector; - selectors[3] = DiamondLoupeFacet.facetAddress.selector; - selectors[4] = DiamondLoupeFacet.supportsInterface.selector; - - cut[0] = IDiamondCut.FacetCut({ - facetAddress: loupeFacet, - action: IDiamondCut.FacetCutAction.Add, - functionSelectors: selectors - }); - } - - // ------------------------------------------------------------ - // OwnershipFacet - // ------------------------------------------------------------ - { - bytes4[] memory selectors = new bytes4[](2); - selectors[0] = OwnershipFacet.owner.selector; - selectors[1] = OwnershipFacet.transferOwnership.selector; - - cut[1] = IDiamondCut.FacetCut({ - facetAddress: ownershipFacet, - action: IDiamondCut.FacetCutAction.Add, - functionSelectors: selectors - }); - } - - // ------------------------------------------------------------ - // ConfigFacet - // ------------------------------------------------------------ - { - bytes4[] memory selectors = new bytes4[](11); - selectors[0] = ConfigFacet.grantAuthorization.selector; - selectors[1] = ConfigFacet.revokeAuthorization.selector; - selectors[2] = ConfigFacet.enableRegistration.selector; - selectors[3] = ConfigFacet.disableRegistration.selector; - selectors[4] = ConfigFacet.withdrawFees.selector; - selectors[5] = ConfigFacet.updateConfigBuffer.selector; - - selectors[6] = ConfigFacet.getVmSigner.selector; - selectors[7] = ConfigFacet.erc20Supra.selector; - selectors[8] = ConfigFacet.isRegistrationEnabled.selector; - selectors[9] = ConfigFacet.getConfig.selector; - selectors[10] = ConfigFacet.getConfigBuffer.selector; - - cut[2] = IDiamondCut.FacetCut({ - facetAddress: configFacet, - action: IDiamondCut.FacetCutAction.Add, - functionSelectors: selectors - }); - } - - // ------------------------------------------------------------ - // RegistryFacet - // ------------------------------------------------------------ - { - bytes4[] memory selectors = new bytes4[](36); - selectors[0] = RegistryFacet.register.selector; - selectors[1] = RegistryFacet.registerSystemTask.selector; - selectors[2] = RegistryFacet.cancelTasks.selector; - selectors[3] = RegistryFacet.cancelSystemTasks.selector; - selectors[4] = RegistryFacet.stopTasks.selector; - selectors[5] = RegistryFacet.stopSystemTasks.selector; + // 1) Deploy DiamondCutFacet + d.diamondCutFacet = address(new DiamondCutFacet()); - selectors[6] = RegistryFacet.getTaskIdList.selector; - selectors[7] = RegistryFacet.getSystemTaskIds.selector; - selectors[8] = RegistryFacet.getTaskOwner.selector; - selectors[9] = RegistryFacet.getNextTaskIndex.selector; - selectors[10] = RegistryFacet.totalTasks.selector; - selectors[11] = RegistryFacet.totalSystemTasks.selector; - selectors[12] = RegistryFacet.getTaskDetails.selector; - selectors[13] = RegistryFacet.getTaskDetailsBulk.selector; - selectors[14] = RegistryFacet.isAuthorizedSubmitter.selector; - selectors[15] = RegistryFacet.getTotalActiveTasks.selector; - selectors[16] = RegistryFacet.getActiveTaskIds.selector; - selectors[17] = RegistryFacet.hasActiveUserTask.selector; - selectors[18] = RegistryFacet.hasActiveSystemTask.selector; - selectors[19] = RegistryFacet.hasActiveTaskOfType.selector; - selectors[20] = RegistryFacet.getGasCommittedForNextCycle.selector; - selectors[21] = RegistryFacet.getGasCommittedForCurrentCycle.selector; - selectors[22] = RegistryFacet.getSystemGasCommittedForNextCycle.selector; - selectors[23] = RegistryFacet.getSystemGasCommittedForCurrentCycle.selector; - selectors[24] = RegistryFacet.getNextCycleRegistryMaxGasCap.selector; - selectors[25] = RegistryFacet.getNextCycleSysRegistryMaxGasCap.selector; - selectors[26] = RegistryFacet.getCycleLockedFees.selector; - selectors[27] = RegistryFacet.getTotalDepositedAutomationFees.selector; - selectors[28] = RegistryFacet.getTotalLockedBalance.selector; - selectors[29] = RegistryFacet.calculateAutomationFeeMultiplierForCommittedOccupancy.selector; - selectors[30] = RegistryFacet.calculateAutomationFeeMultiplierForCurrentCycle.selector; - selectors[31] = RegistryFacet.estimateAutomationFee.selector; - selectors[32] = RegistryFacet.estimateAutomationFeeWithCommittedOccupancy.selector; - selectors[33] = RegistryFacet.ifTaskExists.selector; - selectors[34] = RegistryFacet.ifSysTaskExists.selector; - selectors[35] = RegistryFacet.getTasksByAddress.selector; + // 2) Deploy remaining facets + d.loupeFacet = address(new DiamondLoupeFacet()); + d.ownershipFacet = address(new OwnershipFacet()); + d.configFacet = address(new ConfigFacet()); + d.registryFacet = address(new RegistryFacet()); + d.coreFacet = address(new CoreFacet()); - cut[3] = IDiamondCut.FacetCut({ - facetAddress: registryFacet, - action: IDiamondCut.FacetCutAction.Add, - functionSelectors: selectors - }); - } - - // ------------------------------------------------------------ - // CoreFacet - // ------------------------------------------------------------ - { - bytes4[] memory selectors = new bytes4[](10); - selectors[0] = CoreFacet.processTasks.selector; - selectors[1] = CoreFacet.monitorCycleEnd.selector; - selectors[2] = CoreFacet.enableAutomation.selector; - selectors[3] = CoreFacet.disableAutomation.selector; - selectors[4] = CoreFacet.removeRegisteredTask.selector; - selectors[5] = CoreFacet.getCycleInfo.selector; - selectors[6] = CoreFacet.getCycleDuration.selector; - selectors[7] = CoreFacet.getTransitionInfo.selector; - selectors[8] = CoreFacet.isAutomationEnabled.selector; - selectors[9] = CoreFacet.getCycleStateDetails.selector; - - cut[4] = IDiamondCut.FacetCut({ - facetAddress: coreFacet, - action: IDiamondCut.FacetCutAction.Add, - functionSelectors: selectors - }); - } + // 3) Deploy DiamondInit + d.diamondInit = address(new DiamondInit()); } -} +} \ No newline at end of file diff --git a/solidity/supra_contracts/src/libraries/LibUtils.sol b/solidity/supra_contracts/src/libraries/LibUtils.sol index b7f9ceb30b..6a6f757e57 100644 --- a/solidity/supra_contracts/src/libraries/LibUtils.sol +++ b/solidity/supra_contracts/src/libraries/LibUtils.sol @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.27; +import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; // Helper library used by Supra contracts library LibUtils { @@ -55,4 +56,15 @@ library LibUtils { uint160 addr = uint160(_addr); return addr >= uint160(VM_SIGNER) && addr <= uint160(0x535550FF); } + + /// @notice Converts an EnumerableSet.UintSet to a uint64 array. + /// @param set The UintSet to convert. + /// @return result The values as a uint64 array. + function uintSetToUint64Array(EnumerableSet.UintSet storage set) internal view returns (uint64[] memory result) { + uint256 length = EnumerableSet.length(set); + result = new uint64[](length); + for (uint256 i = 0; i < length; i++) { + result[i] = uint64(EnumerableSet.at(set, i)); + } + } } diff --git a/solidity/supra_contracts/src/upgradeInitializers/DiamondInit.sol b/solidity/supra_contracts/src/upgradeInitializers/DiamondInit.sol index c3b5f2e37e..6f2a05d997 100644 --- a/solidity/supra_contracts/src/upgradeInitializers/DiamondInit.sol +++ b/solidity/supra_contracts/src/upgradeInitializers/DiamondInit.sol @@ -117,4 +117,5 @@ contract DiamondInit { registryState.nextCycleRegistryMaxGasCap = _params.registryMaxGasCap; registryState.nextCycleSysRegistryMaxGasCap = _params.sysRegistryMaxGasCap; } + } diff --git a/solidity/supra_contracts/test/BaseDiamondTest.t.sol b/solidity/supra_contracts/test/BaseDiamondTest.t.sol index b19bd783f6..0a69a888be 100644 --- a/solidity/supra_contracts/test/BaseDiamondTest.t.sol +++ b/solidity/supra_contracts/test/BaseDiamondTest.t.sol @@ -44,8 +44,7 @@ abstract contract BaseDiamondTest is Test { erc20SupraHandler = ERC20SupraHandler(payable(address(proxy))); defaultParams = LibDiamondUtils.defaultInitParams(); - deployment = LibDiamondUtils.deploy(admin); - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), defaultParams, deployment); + deployment = LibDiamondUtils.deploy(admin, LibUtils.VM_SIGNER, address(erc20Supra), defaultParams); diamondAddr = deployment.diamond; IConfigFacet(diamondAddr).grantAuthorization(bob); diff --git a/solidity/supra_contracts/test/CoreFacet.t.sol b/solidity/supra_contracts/test/CoreFacet.t.sol index 64d454fbef..fe7bf95b71 100644 --- a/solidity/supra_contracts/test/CoreFacet.t.sol +++ b/solidity/supra_contracts/test/CoreFacet.t.sol @@ -55,8 +55,7 @@ contract CoreFacetTest is BaseDiamondTest { automationEnabled: false }); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + Deployment memory deployment = LibDiamondUtils.deploy(admin, LibUtils.VM_SIGNER, address(erc20Supra), initParams); address diamondAddr = deployment.diamond; vm.stopPrank(); diff --git a/solidity/supra_contracts/test/DiamondInit.t.sol b/solidity/supra_contracts/test/DiamondInit.t.sol index fc3699034c..0a4b929c1e 100644 --- a/solidity/supra_contracts/test/DiamondInit.t.sol +++ b/solidity/supra_contracts/test/DiamondInit.t.sol @@ -6,7 +6,7 @@ import {OwnershipFacet} from "../src/facets/OwnershipFacet.sol"; import {LibCommon} from "../src/libraries/LibCommon.sol"; import {LibUtils} from "../src/libraries/LibUtils.sol"; import {Config} from "../src/libraries/LibAppStorage.sol"; -import {Deployment, InitParams, LibDiamondUtils} from "../src/libraries/LibDiamondUtils.sol"; +import {FacetsDeployment, Deployment, InitParams, LibDiamondUtils} from "../src/libraries/LibDiamondUtils.sol"; import {IConfigFacet} from "../src/interfaces/IConfigFacet.sol"; import {IRegistryFacet} from "../src/interfaces/IRegistryFacet.sol"; import {ICoreFacet} from "../src/interfaces/ICoreFacet.sol"; @@ -15,6 +15,7 @@ import {IDiamondLoupe} from "../src/interfaces/IDiamondLoupe.sol"; import {IERC173} from "../src/interfaces/IERC173.sol"; import {IERC165} from "../src/interfaces/IERC165.sol"; import {DiamondInit} from "../src/upgradeInitializers/DiamondInit.sol"; +import {Diamond} from "../src//Diamond.sol"; contract DiamondInitTest is BaseDiamondTest { @@ -105,11 +106,11 @@ contract DiamondInitTest is BaseDiamondTest { bool coreExists; for (uint i; i < facets.length; i++) { - if (facets[i] == deployment.diamondCutFacet) diamondCutExists = true; - if (facets[i] == deployment.loupeFacet) loupeExists = true; - if (facets[i] == deployment.ownershipFacet) ownershipExists = true; - if (facets[i] == deployment.registryFacet) registryExists = true; - if (facets[i] == deployment.coreFacet) coreExists = true; + if (facets[i] == deployment.facets.diamondCutFacet) diamondCutExists = true; + if (facets[i] == deployment.facets.loupeFacet) loupeExists = true; + if (facets[i] == deployment.facets.ownershipFacet) ownershipExists = true; + if (facets[i] == deployment.facets.registryFacet) registryExists = true; + if (facets[i] == deployment.facets.coreFacet) coreExists = true; } assertTrue(diamondCutExists); @@ -123,17 +124,17 @@ contract DiamondInitTest is BaseDiamondTest { function testSelectorRouting() public view { assertEq( IDiamondLoupe(diamondAddr).facetAddress(IRegistryFacet.register.selector), - deployment.registryFacet + deployment.facets.registryFacet ); assertEq( IDiamondLoupe(diamondAddr).facetAddress(ICoreFacet.enableAutomation.selector), - deployment.coreFacet + deployment.facets.coreFacet ); assertEq( IDiamondLoupe(diamondAddr).facetAddress(OwnershipFacet.transferOwnership.selector), - deployment.ownershipFacet + deployment.facets.ownershipFacet ); } @@ -229,7 +230,7 @@ contract DiamondInitTest is BaseDiamondTest { IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1); cut[0] = IDiamondCut.FacetCut({ - facetAddress: deployment.registryFacet, + facetAddress: deployment.facets.registryFacet, action: IDiamondCut.FacetCutAction.Add, functionSelectors: selectors }); @@ -260,7 +261,7 @@ contract DiamondInitTest is BaseDiamondTest { /// @dev Test to ensure removing a selector works correclty. function testRemoveSelector() public { - uint256 numSelectorsBefore = IDiamondLoupe(diamondAddr).facetFunctionSelectors(deployment.registryFacet).length; + uint256 numSelectorsBefore = IDiamondLoupe(diamondAddr).facetFunctionSelectors(deployment.facets.registryFacet).length; bytes4[] memory selectors = new bytes4[](1); selectors[0] = IRegistryFacet.cancelTasks.selector; @@ -279,7 +280,7 @@ contract DiamondInitTest is BaseDiamondTest { address facet = IDiamondLoupe(diamondAddr).facetAddress(IRegistryFacet.cancelTasks.selector); assertEq(facet, address(0)); - uint256 numSelectorsAfter = IDiamondLoupe(diamondAddr).facetFunctionSelectors(deployment.registryFacet).length; + uint256 numSelectorsAfter = IDiamondLoupe(diamondAddr).facetFunctionSelectors(deployment.facets.registryFacet).length; assertEq(numSelectorsAfter, numSelectorsBefore - 1); uint64[] memory taskIndexes = new uint64[](1); @@ -341,7 +342,7 @@ contract DiamondInitTest is BaseDiamondTest { IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1); cut[0] = IDiamondCut.FacetCut({ - facetAddress: deployment.configFacet, + facetAddress: deployment.facets.configFacet, action: IDiamondCut.FacetCutAction.Replace, functionSelectors: selectors }); @@ -355,43 +356,38 @@ contract DiamondInitTest is BaseDiamondTest { /// @dev Test to ensure initialization fails if zero address is passed as VM Signer. function testInitializeRevertsIfVmSignerZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); vm.expectRevert(LibUtils.AddressCannotBeZero.selector); - // address(0) as VM signer - LibDiamondUtils.executeCut(address(0), address(erc20Supra), defaultParams, deployment); + new Diamond(admin, facets, + address(0), address(erc20Supra), defaultParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if ERC20Supra address is zero. function testInitializeRevertsIfErc20SupraIsZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); vm.expectRevert(LibUtils.AddressCannotBeZero.selector); - // address(0) as ERC20Supra - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(0), defaultParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(0), defaultParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if EOA is passed as ERC20Supra address. function testInitializeRevertsIfErc20SupraIsEoa() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); vm.expectRevert(LibUtils.AddressCannotBeEOA.selector); - // EOA address as ERC20Supra - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, admin, defaultParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, admin, defaultParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if task duration is <= cycle duration. function testInitializeRevertsIfInvalidTaskDuration() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); InitParams memory initParams = InitParams({ taskDurationCapSecs: 1200, @@ -409,18 +405,17 @@ contract DiamondInitTest is BaseDiamondTest { registrationEnabled: true, automationEnabled: true }); - - vm.expectRevert(LibCommon.InvalidTaskDuration.selector); - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + vm.expectRevert(LibCommon.InvalidTaskDuration.selector); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if registry max gas cap is zero. function testInitializeRevertsIfRegistryMaxGasCapZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); + InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, registryMaxGasCap: 0, @@ -436,19 +431,18 @@ contract DiamondInitTest is BaseDiamondTest { sysTaskCapacity: 100, registrationEnabled: true, automationEnabled: true - }); + }); vm.expectRevert(LibCommon.InvalidRegistryMaxGasCap.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if congestion threshold percentage is > 100. function testInitializeRevertsIfInvalidCongestionThreshold() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); + InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, registryMaxGasCap: 20_000_000, @@ -464,18 +458,17 @@ contract DiamondInitTest is BaseDiamondTest { sysTaskCapacity: 100, registrationEnabled: true, automationEnabled: true - }); + }); vm.expectRevert(LibCommon.InvalidCongestionThreshold.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if congestion exponent is 0. function testInitializeRevertsIfCongestionExponentZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, @@ -495,16 +488,15 @@ contract DiamondInitTest is BaseDiamondTest { }); vm.expectRevert(LibCommon.InvalidCongestionExponent.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); - vm.stopPrank(); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); + vm.stopPrank(); } /// @dev Test to ensure initialization fails if task capacity is 0. function testInitializeRevertsIfTaskCapacityZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); + InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, registryMaxGasCap: 20_000_000, @@ -523,16 +515,14 @@ contract DiamondInitTest is BaseDiamondTest { }); vm.expectRevert(LibCommon.InvalidTaskCapacity.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); - vm.stopPrank(); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); + vm.stopPrank(); } /// @dev Test to ensure initialization fails if cycle duration is 0. function testInitializeRevertsIfCycleDurationZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, registryMaxGasCap: 20_000_000, @@ -551,16 +541,14 @@ contract DiamondInitTest is BaseDiamondTest { }); vm.expectRevert(LibCommon.InvalidCycleDuration.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if system task duration is <= cycle duration. function testInitializeRevertsIfInvalidSysTaskDuration() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, registryMaxGasCap: 20_000_000, @@ -579,16 +567,14 @@ contract DiamondInitTest is BaseDiamondTest { }); vm.expectRevert(LibCommon.InvalidSysTaskDuration.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if system registry max gas cap is 0. function testInitializeRevertsIfSysRegistryMaxGasCapZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, registryMaxGasCap: 20_000_000, @@ -607,16 +593,14 @@ contract DiamondInitTest is BaseDiamondTest { }); vm.expectRevert(LibCommon.InvalidSysRegistryMaxGasCap.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); vm.stopPrank(); } /// @dev Test to ensure initialization fails if system task capacity is 0. function testInitializeRevertsIfSysTaskCapacityZero() public { vm.startPrank(admin); - Deployment memory deployment = LibDiamondUtils.deploy(admin); - + FacetsDeployment memory facets = LibDiamondUtils.deploy_facets(); InitParams memory initParams = InitParams({ taskDurationCapSecs: 3600 * 24 * 7, registryMaxGasCap: 20_000_000, @@ -635,8 +619,7 @@ contract DiamondInitTest is BaseDiamondTest { }); vm.expectRevert(LibCommon.InvalidSysTaskCapacity.selector); - - LibDiamondUtils.executeCut(LibUtils.VM_SIGNER, address(erc20Supra), initParams, deployment); + new Diamond(admin, facets, LibUtils.VM_SIGNER, address(erc20Supra), initParams); vm.stopPrank(); } }