From 24f40c60d0ad592b0f05f3fb116dfc45d2240148 Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:38:18 +0200 Subject: [PATCH] Migration from ethers to alloy types (#1693) * Migration from ethers to alloy types * some fixes * try snake case rename * fix tests * fix rust version * fix conflicts * some fixes * modify clippy script * fix clippy * some fixes * some fixes * remove unused dep * Update scripts/clippy.sh * some fixes * serde feature * fmt --------- Co-authored-by: Tarrence van As --- .github/workflows/ci.yml | 2 +- Cargo.lock | 1056 +++++++---------- Cargo.toml | 18 + bin/katana/Cargo.toml | 1 + bin/katana/src/args.rs | 3 +- crates/katana/core/Cargo.toml | 29 +- crates/katana/core/src/backend/config.rs | 2 +- .../core/src/service/messaging/ethereum.rs | 170 ++- .../katana/core/src/service/messaging/mod.rs | 8 +- crates/katana/core/tests/sequencer.rs | 2 +- crates/katana/executor/Cargo.toml | 2 + crates/katana/executor/tests/fixtures/mod.rs | 3 +- crates/katana/primitives/Cargo.toml | 3 +- .../primitives/src/genesis/allocation.rs | 4 +- crates/katana/primitives/src/genesis/json.rs | 10 +- crates/katana/primitives/src/genesis/mod.rs | 8 +- crates/katana/primitives/src/receipt.rs | 4 +- crates/katana/primitives/src/transaction.rs | 4 +- crates/katana/primitives/src/utils/mod.rs | 6 +- .../primitives/src/utils/transaction.rs | 6 +- crates/katana/rpc/rpc-types/Cargo.toml | 3 +- crates/katana/rpc/rpc-types/src/account.rs | 2 +- crates/katana/rpc/rpc-types/src/receipt.rs | 2 +- crates/katana/storage/provider/Cargo.toml | 2 +- crates/saya/core/src/lib.rs | 2 +- crates/saya/core/src/prover/serializer.rs | 10 +- crates/saya/core/src/prover/state_diff.rs | 2 +- crates/saya/core/src/prover/vec252.rs | 2 +- crates/saya/provider/Cargo.toml | 2 +- crates/saya/provider/src/rpc/state.rs | 10 +- crates/saya/provider/src/rpc/state_diff.rs | 3 - 31 files changed, 590 insertions(+), 791 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4421507c96..b6d31b7a7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - - run: | + - run: | cargo llvm-cov nextest --no-report --all-features --workspace --exclude katana --build-jobs 10 cargo llvm-cov nextest --no-report -p katana cargo llvm-cov nextest --no-report -p katana --no-default-features --features sir diff --git a/Cargo.lock b/Cargo.lock index 6a42dac365..cc3809f29c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,16 +116,339 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-eips", + "alloy-primitives", + "alloy-rlp", +] + +[[package]] +name = "alloy-contract" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-network", + "alloy-primitives", + "alloy-provider", + "alloy-rpc-types", + "alloy-sol-types", + "alloy-transport", + "futures", + "futures-util", + "thiserror", +] + +[[package]] +name = "alloy-dyn-abi" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-type-parser", + "alloy-sol-types", + "const-hex", + "itoa", + "serde", + "serde_json", + "winnow 0.6.1", +] + +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "serde", +] + +[[package]] +name = "alloy-json-abi" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-json-rpc" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-network" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-json-rpc", + "alloy-primitives", + "alloy-rpc-types", + "alloy-signer", + "async-trait", + "futures-utils-wasm", + "serde", + "thiserror", +] + +[[package]] +name = "alloy-primitives" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if", + "const-hex", + "derive_more", + "hex-literal", + "itoa", + "k256", + "keccak-asm", + "proptest", + "rand", + "ruint", + "serde", + "tiny-keccak", +] + +[[package]] +name = "alloy-provider" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-json-rpc", + "alloy-network", + "alloy-primitives", + "alloy-rpc-client", + "alloy-rpc-trace-types", + "alloy-rpc-types", + "alloy-transport", + "alloy-transport-http", + "async-stream", + "async-trait", + "auto_impl", + "dashmap", + "futures", + "lru 0.12.2", + "reqwest", + "serde_json", + "tokio", + "tracing", +] + [[package]] name = "alloy-rlp" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" dependencies = [ + "alloy-rlp-derive", "arrayvec", "bytes", ] +[[package]] +name = "alloy-rlp-derive" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.55", +] + +[[package]] +name = "alloy-rpc-client" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "alloy-transport-http", + "futures", + "pin-project", + "reqwest", + "serde", + "serde_json", + "tokio", + "tokio-stream", + "tower", + "tracing", + "url", +] + +[[package]] +name = "alloy-rpc-trace-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types", + "alloy-serde", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-serde", + "itertools 0.12.1", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-serde" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-signer" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-primitives", + "async-trait", + "auto_impl", + "elliptic-curve", + "k256", + "thiserror", +] + +[[package]] +name = "alloy-signer-wallet" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", + "k256", + "rand", + "thiserror", +] + +[[package]] +name = "alloy-sol-macro" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "alloy-json-abi", + "alloy-sol-macro-input", + "const-hex", + "heck 0.4.1", + "indexmap 2.2.5", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.55", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-macro-input" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "alloy-json-abi", + "const-hex", + "dunce", + "heck 0.5.0", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.55", + "syn-solidity", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "winnow 0.6.1", +] + +[[package]] +name = "alloy-sol-types" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-macro", + "const-hex", + "serde", +] + +[[package]] +name = "alloy-transport" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-json-rpc", + "base64 0.22.0", + "futures-util", + "futures-utils-wasm", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "url", + "wasm-bindgen-futures", +] + +[[package]] +name = "alloy-transport-http" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=98e9012c95a12d67b012dfee6f0d928797426e79#98e9012c95a12d67b012dfee6f0d928797426e79" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "reqwest", + "serde_json", + "tower", + "url", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -594,7 +917,7 @@ dependencies = [ "Inflector", "async-graphql-parser", "darling 0.20.6", - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "strum 0.25.0", @@ -773,17 +1096,6 @@ dependencies = [ "syn 2.0.55", ] -[[package]] -name = "async_io_stream" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" -dependencies = [ - "futures", - "pharos", - "rustc_version 0.4.0", -] - [[package]] name = "asynchronous-codec" version = "0.7.0" @@ -835,9 +1147,9 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", @@ -934,6 +1246,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + [[package]] name = "base64ct" version = "1.6.0" @@ -1200,7 +1518,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ - "sha2 0.10.8", "tinyvec", ] @@ -2464,58 +2781,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" -[[package]] -name = "coins-bip32" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" -dependencies = [ - "bs58", - "coins-core", - "digest 0.10.7", - "hmac", - "k256", - "serde", - "sha2 0.10.8", - "thiserror", -] - -[[package]] -name = "coins-bip39" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" -dependencies = [ - "bitvec", - "coins-bip32", - "hmac", - "once_cell", - "pbkdf2 0.12.2", - "rand", - "sha2 0.10.8", - "thiserror", -] - -[[package]] -name = "coins-core" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" -dependencies = [ - "base64 0.21.7", - "bech32", - "bs58", - "digest 0.10.7", - "generic-array", - "hex", - "ripemd", - "serde", - "serde_derive", - "sha2 0.10.8", - "sha3", - "thiserror", -] - [[package]] name = "colorchoice" version = "1.0.0" @@ -3624,24 +3889,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" -[[package]] -name = "enr" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" -dependencies = [ - "base64 0.21.7", - "bytes", - "hex", - "k256", - "log", - "rand", - "rlp", - "serde", - "sha3", - "zeroize", -] - [[package]] name = "enum-as-inner" version = "0.6.0" @@ -3726,7 +3973,7 @@ dependencies = [ "digest 0.10.7", "hex", "hmac", - "pbkdf2 0.11.0", + "pbkdf2", "rand", "scrypt", "serde", @@ -3737,23 +3984,6 @@ dependencies = [ "uuid 0.8.2", ] -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - [[package]] name = "ethbloom" version = "0.13.0" @@ -3762,10 +3992,8 @@ checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", "fixed-hash", - "impl-codec", "impl-rlp", "impl-serde", - "scale-info", "tiny-keccak", ] @@ -3777,260 +4005,10 @@ checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", "fixed-hash", - "impl-codec", "impl-rlp", "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c7cd562832e2ff584fa844cd2f6e5d4f35bbe11b28c7c9b8df957b2e1d0c701" -dependencies = [ - "ethers-addressbook", - "ethers-contract", - "ethers-core", - "ethers-etherscan", - "ethers-middleware", - "ethers-providers", - "ethers-signers", - "ethers-solc", -] - -[[package]] -name = "ethers-addressbook" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35dc9a249c066d17e8947ff52a4116406163cf92c7f0763cb8c001760b26403f" -dependencies = [ - "ethers-core", - "once_cell", - "serde", - "serde_json", -] - -[[package]] -name = "ethers-contract" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43304317c7f776876e47f2f637859f6d0701c1ec7930a150f169d5fbe7d76f5a" -dependencies = [ - "const-hex", - "ethers-contract-abigen", - "ethers-contract-derive", - "ethers-core", - "ethers-providers", - "futures-util", - "once_cell", - "pin-project", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "ethers-contract-abigen" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f96502317bf34f6d71a3e3d270defaa9485d754d789e15a8e04a84161c95eb" -dependencies = [ - "Inflector", - "const-hex", - "dunce", - "ethers-core", - "ethers-etherscan", - "eyre", - "prettyplease 0.2.16", - "proc-macro2", - "quote", - "regex", - "reqwest", - "serde", - "serde_json", - "syn 2.0.55", - "toml 0.8.10", - "walkdir", -] - -[[package]] -name = "ethers-contract-derive" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "452ff6b0a64507ce8d67ffd48b1da3b42f03680dcf5382244e9c93822cbbf5de" -dependencies = [ - "Inflector", - "const-hex", - "ethers-contract-abigen", - "ethers-core", - "proc-macro2", - "quote", - "serde_json", - "syn 2.0.55", -] - -[[package]] -name = "ethers-core" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aab3cef6cc1c9fd7f787043c81ad3052eff2b96a3878ef1526aa446311bdbfc9" -dependencies = [ - "arrayvec", - "bytes", - "cargo_metadata", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "once_cell", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum 0.25.0", - "syn 2.0.55", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", -] - -[[package]] -name = "ethers-etherscan" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d45b981f5fa769e1d0343ebc2a44cfa88c9bc312eb681b676318b40cef6fb1" -dependencies = [ - "chrono", - "ethers-core", - "reqwest", - "semver 1.0.22", - "serde", - "serde_json", - "thiserror", - "tracing", -] - -[[package]] -name = "ethers-middleware" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145211f34342487ef83a597c1e69f0d3e01512217a7c72cc8a25931854c7dca0" -dependencies = [ - "async-trait", - "auto_impl", - "ethers-contract", - "ethers-core", - "ethers-etherscan", - "ethers-providers", - "ethers-signers", - "futures-channel", - "futures-locks", - "futures-util", - "instant", - "reqwest", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", - "tracing-futures", - "url", -] - -[[package]] -name = "ethers-providers" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb6b15393996e3b8a78ef1332d6483c11d839042c17be58decc92fa8b1c3508a" -dependencies = [ - "async-trait", - "auto_impl", - "base64 0.21.7", - "bytes", - "const-hex", - "enr", - "ethers-core", - "futures-core", - "futures-timer", - "futures-util", - "hashers", - "http", - "instant", - "jsonwebtoken", - "once_cell", - "pin-project", - "reqwest", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite", - "tracing", - "tracing-futures", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "ws_stream_wasm", -] - -[[package]] -name = "ethers-signers" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3b125a103b56aef008af5d5fb48191984aa326b50bfd2557d231dc499833de3" -dependencies = [ - "async-trait", - "coins-bip32", - "coins-bip39", - "const-hex", - "elliptic-curve", - "eth-keystore", - "ethers-core", - "rand", - "sha2 0.10.8", - "thiserror", - "tracing", -] - -[[package]] -name = "ethers-solc" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d21df08582e0a43005018a858cc9b465c5fff9cf4056651be64f844e57d1f55f" -dependencies = [ - "cfg-if", - "const-hex", - "dirs 5.0.1", - "dunce", - "ethers-core", - "glob", - "home", - "md-5", - "num_cpus", - "once_cell", - "path-slash", - "rayon", - "regex", - "semver 1.0.22", - "serde", - "serde_json", - "solang-parser", - "svm-rs", - "thiserror", - "tiny-keccak", - "tokio", - "tracing", - "walkdir", - "yansi", + "primitive-types", + "uint", ] [[package]] @@ -4248,16 +4226,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "fs4" version = "0.7.0" @@ -4388,16 +4356,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "futures-locks" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" -dependencies = [ - "futures-channel", - "futures-task", -] - [[package]] name = "futures-macro" version = "0.3.30" @@ -4471,13 +4429,10 @@ dependencies = [ ] [[package]] -name = "fxhash" -version = "0.2.1" +name = "futures-utils-wasm" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] +checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" [[package]] name = "genco" @@ -5507,15 +5462,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hashers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" -dependencies = [ - "fxhash", -] - [[package]] name = "hashlink" version = "0.8.4" @@ -5577,6 +5523,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.6" @@ -5588,6 +5540,15 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "hex_fmt" @@ -6520,7 +6481,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" dependencies = [ "heck 0.4.1", - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -6533,7 +6494,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29110019693a4fa2dbda04876499d098fa16d70eba06b1e6e2b3f1b251419515" dependencies = [ "heck 0.4.1", - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -6625,20 +6586,6 @@ dependencies = [ "url", ] -[[package]] -name = "jsonwebtoken" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" -dependencies = [ - "base64 0.21.7", - "pem 1.1.1", - "ring 0.16.20", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "jwalk" version = "0.8.1" @@ -6667,6 +6614,7 @@ dependencies = [ name = "katana" version = "0.6.0-alpha.12" dependencies = [ + "alloy-primitives", "anyhow", "assert_matches", "cfg-if", @@ -6711,6 +6659,15 @@ dependencies = [ name = "katana-core" version = "0.6.0-alpha.12" dependencies = [ + "alloy-contract", + "alloy-network", + "alloy-primitives", + "alloy-provider", + "alloy-rpc-types", + "alloy-signer", + "alloy-signer-wallet", + "alloy-sol-types", + "alloy-transport", "anyhow", "assert_matches", "async-trait", @@ -6719,10 +6676,10 @@ dependencies = [ "cairo-vm 0.9.2", "convert_case 0.6.0", "derive_more", - "ethers", "flate2", "futures", "hex", + "k256", "katana-db", "katana-executor", "katana-primitives", @@ -6730,8 +6687,8 @@ dependencies = [ "katana-tasks", "lazy_static", "parking_lot 0.12.1", - "primitive-types", "rand", + "reqwest", "serde", "serde_json", "serde_with", @@ -6769,6 +6726,7 @@ dependencies = [ name = "katana-executor" version = "0.6.0-alpha.12" dependencies = [ + "alloy-primitives", "anyhow", "blockifier", "cairo-lang-sierra", @@ -6796,13 +6754,13 @@ dependencies = [ name = "katana-primitives" version = "0.6.0-alpha.12" dependencies = [ + "alloy-primitives", "anyhow", "base64 0.21.7", "cairo-lang-sierra", "cairo-lang-starknet", "cairo-vm 0.9.2", "derive_more", - "ethers", "flate2", "lazy_static", "rand", @@ -6894,9 +6852,9 @@ dependencies = [ name = "katana-rpc-types" version = "0.6.0-alpha.12" dependencies = [ + "alloy-primitives", "anyhow", "derive_more", - "ethers", "futures", "jsonrpsee 0.16.3", "katana-core", @@ -6961,6 +6919,16 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "keccak-asm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb8515fff80ed850aea4a1595f2e519c003e2a00a82fe168ebf5269196caf444" +dependencies = [ + "digest 0.10.7", + "sha3-asm", +] + [[package]] name = "kqueue" version = "1.0.8" @@ -8073,7 +8041,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", @@ -8471,27 +8439,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" -dependencies = [ - "proc-macro-crate 3.1.0", - "proc-macro2", - "quote", - "syn 2.0.55", -] - [[package]] name = "num_threads" version = "0.1.7" @@ -8552,31 +8499,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "openssl" version = "0.10.63" @@ -8715,7 +8637,7 @@ version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -8807,12 +8729,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "path-slash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" - [[package]] name = "pathdiff" version = "0.2.1" @@ -8834,31 +8750,12 @@ dependencies = [ "sha2 0.10.8", ] -[[package]] -name = "pbkdf2" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" -dependencies = [ - "digest 0.10.7", - "hmac", -] - [[package]] name = "peeking_take_while" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - [[package]] name = "pem" version = "3.0.3" @@ -8939,16 +8836,6 @@ dependencies = [ "indexmap 2.2.5", ] -[[package]] -name = "pharos" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" -dependencies = [ - "futures", - "rustc_version 0.4.0", -] - [[package]] name = "phf" version = "0.11.2" @@ -9274,7 +9161,6 @@ dependencies = [ "impl-codec", "impl-rlp", "impl-serde", - "scale-info", "uint", ] @@ -9288,15 +9174,6 @@ dependencies = [ "toml 0.5.11", ] -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -9729,7 +9606,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52c4f3084aa3bc7dfbba4eff4fab2a54db4324965d8872ab933565e6fbd83bc6" dependencies = [ - "pem 3.0.3", + "pem", "ring 0.16.20", "time", "x509-parser", @@ -9965,15 +9842,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "rlimit" version = "0.10.1" @@ -9990,21 +9858,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "rsa" version = "0.9.6" @@ -10421,11 +10277,11 @@ dependencies = [ name = "saya-provider" version = "0.6.0-alpha.12" dependencies = [ + "alloy-primitives", "anyhow", "async-trait", "auto_impl", "convert_case 0.6.0", - "ethers", "flate2", "futures", "jsonrpsee 0.16.3", @@ -10447,30 +10303,6 @@ dependencies = [ "url", ] -[[package]] -name = "scale-info" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" -dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "scarb" version = "2.5.4" @@ -10656,7 +10488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" dependencies = [ "hmac", - "pbkdf2 0.11.0", + "pbkdf2", "salsa20", "sha2 0.10.8", ] @@ -11004,6 +10836,16 @@ dependencies = [ "keccak", ] +[[package]] +name = "sha3-asm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac61da6b35ad76b195eb4771210f947734321a8d81d7738e1580d953bc7a15e" +dependencies = [ + "cc", + "cfg-if", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -11083,18 +10925,6 @@ dependencies = [ "similar", ] -[[package]] -name = "simple_asn1" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" -dependencies = [ - "num-bigint", - "num-traits 0.2.18", - "thiserror", - "time", -] - [[package]] name = "siphasher" version = "0.3.11" @@ -11206,20 +11036,6 @@ dependencies = [ "sha-1", ] -[[package]] -name = "solang-parser" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" -dependencies = [ - "itertools 0.11.0", - "lalrpop", - "lalrpop-util", - "phf", - "thiserror", - "unicode-xid", -] - [[package]] name = "sozo" version = "0.6.0-alpha.12" @@ -12183,26 +11999,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" -[[package]] -name = "svm-rs" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" -dependencies = [ - "dirs 5.0.1", - "fs2", - "hex", - "once_cell", - "reqwest", - "semver 1.0.22", - "serde", - "serde_json", - "sha2 0.10.8", - "thiserror", - "url", - "zip", -] - [[package]] name = "syn" version = "1.0.109" @@ -12225,6 +12021,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn-solidity" +version = "0.6.4" +source = "git+https://github.com/alloy-rs/core?rev=ff339696fa9b490698cb3edec3d4647fae0bd332#ff339696fa9b490698cb3edec3d4647fae0bd332" +dependencies = [ + "paste", + "proc-macro2", + "quote", + "syn 2.0.55", +] + [[package]] name = "sync_wrapper" version = "0.1.2" @@ -12537,6 +12344,7 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", + "tokio-util", ] [[package]] @@ -12547,11 +12355,8 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls 0.21.10", "tokio", - "tokio-rustls 0.24.1", "tungstenite", - "webpki-roots", ] [[package]] @@ -12624,17 +12429,6 @@ dependencies = [ "winnow 0.5.40", ] -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.5", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.6" @@ -13177,16 +12971,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-log" version = "0.1.4" @@ -13270,7 +13054,6 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.21.10", "sha1", "thiserror", "url", @@ -13810,7 +13593,7 @@ dependencies = [ "interceptor", "lazy_static", "log", - "pem 3.0.3", + "pem", "rand", "rcgen", "regex", @@ -13873,7 +13656,7 @@ dependencies = [ "log", "p256", "p384", - "pem 3.0.3", + "pem", "rand", "rand_core", "rcgen", @@ -14334,25 +14117,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "ws_stream_wasm" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" -dependencies = [ - "async_io_stream", - "futures", - "js-sys", - "log", - "pharos", - "rustc_version 0.4.0", - "send_wrapper 0.6.0", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wyz" version = "0.5.1" @@ -14539,7 +14303,7 @@ dependencies = [ "crossbeam-utils", "flate2", "hmac", - "pbkdf2 0.11.0", + "pbkdf2", "sha1", "time", "zstd 0.11.2+zstd.1.5.2", diff --git a/Cargo.toml b/Cargo.toml index 0cef8b37fd..cae357b075 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -190,6 +190,24 @@ wasm-prost = { version = "0.11.9", package = "prost" } wasm-tonic = { version = "0.9.2", default-features = false, features = [ "codegen", "gzip", "prost" ], package = "tonic" } wasm-tonic-build = { version = "0.9.2", default-features = false, features = [ "prost" ], package = "tonic-build" } +alloy-primitives = { version = "0.6.4", default-features = false } + + [patch.crates-io] cairo-felt = { git = "https://github.com/dojoengine/cairo-rs.git", rev = "1031381" } cairo-vm = { git = "https://github.com/dojoengine/cairo-rs.git", rev = "1031381" } + +alloy-sol-macro = { git = "https://github.com/alloy-rs/core", rev = "ff339696fa9b490698cb3edec3d4647fae0bd332" } +alloy-primitives = { git = "https://github.com/alloy-rs/core", rev = "ff339696fa9b490698cb3edec3d4647fae0bd332" } +alloy-sol-types = { git = "https://github.com/alloy-rs/core", rev = "ff339696fa9b490698cb3edec3d4647fae0bd332" } +alloy-json-abi = { git = "https://github.com/alloy-rs/core", rev = "ff339696fa9b490698cb3edec3d4647fae0bd332" } +alloy-dyn-abi = { git = "https://github.com/alloy-rs/core", rev = "ff339696fa9b490698cb3edec3d4647fae0bd332" } +syn-solidity = { git = "https://github.com/alloy-rs/core", rev = "ff339696fa9b490698cb3edec3d4647fae0bd332" } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } +alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "98e9012c95a12d67b012dfee6f0d928797426e79" } diff --git a/bin/katana/Cargo.toml b/bin/katana/Cargo.toml index e268ad2f02..8edb17a859 100644 --- a/bin/katana/Cargo.toml +++ b/bin/katana/Cargo.toml @@ -26,6 +26,7 @@ tokio.workspace = true tracing-subscriber.workspace = true tracing.workspace = true url.workspace = true +alloy-primitives.workspace = true [dev-dependencies] assert_matches = "1.5.0" diff --git a/bin/katana/src/args.rs b/bin/katana/src/args.rs index bd89f80488..eac8a32599 100644 --- a/bin/katana/src/args.rs +++ b/bin/katana/src/args.rs @@ -13,6 +13,7 @@ use std::net::SocketAddr; use std::path::PathBuf; +use alloy_primitives::U256; use clap::{Args, Parser, Subcommand}; use clap_complete::Shell; use common::parse::parse_socket_address; @@ -253,7 +254,7 @@ impl KatanaArgs { let accounts = DevAllocationsGenerator::new(self.starknet.total_accounts) .with_seed(parse_seed(&self.starknet.seed)) - .with_balance(DEFAULT_PREFUNDED_ACCOUNT_BALANCE) + .with_balance(U256::from(DEFAULT_PREFUNDED_ACCOUNT_BALANCE)) .generate(); let mut genesis = Genesis { diff --git a/crates/katana/core/Cargo.toml b/crates/katana/core/Cargo.toml index 2669286bdc..d23fe3b517 100644 --- a/crates/katana/core/Cargo.toml +++ b/crates/katana/core/Cargo.toml @@ -19,13 +19,13 @@ cairo-lang-casm = "2.3.1" cairo-lang-starknet = "2.3.1" cairo-vm.workspace = true convert_case.workspace = true +k256 = { version = "0.13", default-features = false, features = ["ecdsa", "std"] } +reqwest = { version = "0.11.22", features = [ "blocking", "rustls-tls" ], default-features = false } derive_more.workspace = true -ethers = { version = "2.0.11", optional = true } flate2.workspace = true futures.workspace = true lazy_static = "1.4.0" parking_lot.workspace = true -primitive-types = "0.12.2" rand = { version = "0.8.5", features = [ "small_rng" ] } serde.workspace = true serde_json.workspace = true @@ -37,11 +37,32 @@ tokio.workspace = true tracing.workspace = true url.workspace = true +alloy-primitives = { workspace = true, features = ["serde"] } + +alloy-sol-types = { version = "0.6.4", default-features = false, features = ["json"], optional = true } + +alloy-transport = { version = "0.1.0", default-features = false, optional = true } +alloy-provider = { version = "0.1.0", default-features = false, optional = true } +alloy-signer = { version = "0.1.0", default-features = false, optional = true } +alloy-network = { version = "0.1.0", default-features = false, optional = true } +alloy-rpc-types = { version = "0.1.0", default-features = false, optional = true } +alloy-signer-wallet = { version = "0.1.0", default-features = false, optional = true } +alloy-contract = { version = "0.1.0", default-features = false, optional = true } + [dev-dependencies] assert_matches.workspace = true hex = "0.4.3" tempfile = "3.8.1" [features] -messaging = [ "ethers" ] -starknet-messaging = [ ] +messaging = [ + "alloy-sol-types", + "alloy-transport", + "alloy-provider", + "alloy-signer", + "alloy-network", + "alloy-rpc-types", + "alloy-signer-wallet", + "alloy-contract" +] +starknet-messaging = [ ] diff --git a/crates/katana/core/src/backend/config.rs b/crates/katana/core/src/backend/config.rs index b7b25c3799..e1c4773c1f 100644 --- a/crates/katana/core/src/backend/config.rs +++ b/crates/katana/core/src/backend/config.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use ::primitive_types::U256; +use alloy_primitives::U256; use katana_primitives::chain::ChainId; use katana_primitives::genesis::allocation::DevAllocationsGenerator; use katana_primitives::genesis::constant::DEFAULT_PREFUNDED_ACCOUNT_BALANCE; diff --git a/crates/katana/core/src/service/messaging/ethereum.rs b/crates/katana/core/src/service/messaging/ethereum.rs index fd85994724..3268293f6d 100644 --- a/crates/katana/core/src/service/messaging/ethereum.rs +++ b/crates/katana/core/src/service/messaging/ethereum.rs @@ -2,62 +2,56 @@ use std::collections::HashMap; use std::str::FromStr; use std::sync::Arc; +use alloy_network::Ethereum; +use alloy_primitives::{Address, LogData, U256}; +use alloy_provider::{HttpProvider, Provider}; +use alloy_rpc_types::{BlockNumberOrTag, Filter, FilterBlockOption, FilterSet, Log, Topic}; +use alloy_sol_types::{sol, SolEvent}; use anyhow::Result; use async_trait::async_trait; -use ethers::prelude::*; -use ethers::providers::{Http, Provider}; -use ethers::types::{Address, BlockNumber, Log}; -use k256::ecdsa::SigningKey; use katana_primitives::chain::ChainId; use katana_primitives::receipt::MessageToL1; use katana_primitives::transaction::L1HandlerTx; use katana_primitives::utils::transaction::compute_l1_message_hash; use katana_primitives::FieldElement; -use tracing::{debug, error, trace, warn}; +use tracing::{debug, trace, warn}; use super::{Error, MessagingConfig, Messenger, MessengerResult, LOG_TARGET}; -abigen!( +sol! { + #[sol(rpc, rename_all = "snakecase")] + #[derive(serde::Serialize, serde::Deserialize)] StarknetMessagingLocal, - "../primitives/contracts/messaging/solidity/IStarknetMessagingLocal_ABI.json", - event_derives(serde::Serialize, serde::Deserialize) -); - -#[derive(Debug, PartialEq, Eq, EthEvent)] -pub struct LogMessageToL2 { - #[ethevent(indexed)] - from_address: Address, - #[ethevent(indexed)] - to_address: U256, - #[ethevent(indexed)] - selector: U256, - payload: Vec, - nonce: U256, - fee: U256, + "../primitives/contracts/messaging/solidity/IStarknetMessagingLocal_ABI.json" +} + +sol! { + #[sol(rpc)] + contract LogMessageToL2 { + #[derive(Debug, PartialEq)] + event LogMessageToL2Event( + address indexed from_address, + uint256 indexed to_address, + uint256 indexed selector, + uint256[] payload, + uint256 nonce, + uint256 fee + ); + } } pub struct EthereumMessaging { - provider: Arc>, - provider_signer: Arc, Wallet>>, + provider: Arc>, messaging_contract_address: Address, } impl EthereumMessaging { pub async fn new(config: MessagingConfig) -> Result { - let provider = Provider::::try_from(&config.rpc_url)?; - - let chain_id = provider.get_chainid().await?; - - let wallet: LocalWallet = - config.private_key.parse::()?.with_chain_id(chain_id.as_u32()); - - let provider_signer = SignerMiddleware::new(provider.clone(), wallet); - let messaging_contract_address = Address::from_str(&config.contract_address)?; - Ok(EthereumMessaging { - provider: Arc::new(provider), - provider_signer: Arc::new(provider_signer), - messaging_contract_address, + provider: Arc::new(HttpProvider::::new_http(reqwest::Url::parse( + &config.rpc_url, + )?)), + messaging_contract_address: config.contract_address.parse::
()?, }) } @@ -81,17 +75,22 @@ impl EthereumMessaging { let mut block_to_logs: HashMap> = HashMap::new(); - let log_msg_to_l2_topic = - H256::from_str("0xdb80dd488acf86d17c747445b0eabb5d57c541d3bd7b6b87af987858e5066b2b") - .unwrap(); - let filters = Filter { block_option: FilterBlockOption::Range { - from_block: Some(BlockNumber::Number(from_block.into())), - to_block: Some(BlockNumber::Number(to_block.into())), + from_block: Some(BlockNumberOrTag::Number(from_block)), + to_block: Some(BlockNumberOrTag::Number(to_block)), }, - address: Some(ValueOrArray::Value(self.messaging_contract_address)), - topics: [Some(ValueOrArray::Value(Some(log_msg_to_l2_topic))), None, None, None], + address: FilterSet::
::from(self.messaging_contract_address), + topics: [ + Topic::from( + "0xdb80dd488acf86d17c747445b0eabb5d57c541d3bd7b6b87af987858e5066b2b" + .parse::() + .unwrap(), + ), + Default::default(), + Default::default(), + Default::default(), + ], }; self.provider @@ -130,12 +129,7 @@ impl Messenger for EthereumMessaging { max_blocks: u64, chain_id: ChainId, ) -> MessengerResult<(u64, Vec)> { - let chain_latest_block: u64 = self - .provider - .get_block_number() - .await? - .try_into() - .expect("Can't convert latest block number into u64."); + let chain_latest_block: u64 = self.provider.get_block_number().await?; // +1 as the from_block counts as 1 block fetched. let to_block = if from_block + max_blocks + 1 < chain_latest_block { @@ -174,45 +168,42 @@ impl Messenger for EthereumMessaging { return Ok(vec![]); } - let starknet_messaging = StarknetMessagingLocal::new( - self.messaging_contract_address, - self.provider_signer.clone(), - ); + let starknet_messaging = + StarknetMessagingLocal::new(self.messaging_contract_address, self.provider.clone()); let hashes = parse_messages(messages); - debug!(target: LOG_TARGET, "Sending transaction on L1 to register messages."); - match starknet_messaging - .add_message_hashes_from_l2(hashes.clone()) + debug!("Sending transaction on L1 to register messages..."); + + let receipt = starknet_messaging + .addMessageHashesFromL2(hashes.clone()) .send() .await .map_err(|_| Error::SendError)? - // wait for the tx to be mined - .await? - { - Some(receipt) => { - trace!( - target: LOG_TARGET, - num_messages = %hashes.len(), - transaction_hash = %format!("{:#x}", receipt.transaction_hash), - "Transaction sent on L1 to register messages." - ); - - Ok(hashes) - } - None => { + .get_receipt() + .await + .map_err(|_| { warn!(target: LOG_TARGET, "No receipt for L1 transaction."); - Err(Error::SendError) - } - } + Error::SendError + })?; + + trace!( + target: LOG_TARGET, + "Transaction sent on L1 to register {} messages: {:#x}", + hashes.len(), + receipt.transaction_hash, + ); + + Ok(hashes) } } fn l1_handler_tx_from_log(log: Log, chain_id: ChainId) -> MessengerResult { - let parsed_log = ::decode_log(&log.into()).map_err(|e| { - error!(target: LOG_TARGET, error = %e, "Log parsing."); - Error::GatherError - })?; + let parsed_log = LogMessageToL2::LogMessageToL2Event::decode_log( + &alloy_primitives::Log::::new(log.address, log.topics, log.data).unwrap(), + false, + ) + .unwrap(); let from_address = felt_from_address(parsed_log.from_address); let contract_address = felt_from_u256(parsed_log.to_address); @@ -221,7 +212,7 @@ fn l1_handler_tx_from_log(log: Log, chain_id: ChainId) -> MessengerResult Vec { messages .iter() .map(|msg| { - let hash = - compute_l1_message_hash(msg.from_address.into(), msg.to_address, &msg.payload); - - U256::from_big_endian(hash.as_bytes()) + U256::from_be_bytes( + compute_l1_message_hash(msg.from_address.into(), msg.to_address, &msg.payload) + .into(), + ) }) .collect() } @@ -261,6 +252,7 @@ fn felt_from_address(v: Address) -> FieldElement { #[cfg(test)] mod tests { + use alloy_primitives::{Address, B256, U256}; use katana_primitives::chain::{ChainId, NamedChainId}; use starknet::macros::{felt, selector}; @@ -287,15 +279,15 @@ mod tests { felt!("0x6182c63599a9638272f1ce5b5cadabece9c81c2d2b8f88ab7a294472b8fce8b"); let log = Log { - address: H160::from_str("0xde29d060D45901Fb19ED6C6e959EB22d8626708e").unwrap(), + address: Address::from_str("0xde29d060D45901Fb19ED6C6e959EB22d8626708e").unwrap(), topics: vec![ - H256::from_str( + B256::from_str( "0xdb80dd488acf86d17c747445b0eabb5d57c541d3bd7b6b87af987858e5066b2b", ) .unwrap(), - H256::from_str(from_address).unwrap(), - H256::from_str(to_address).unwrap(), - H256::from_str(selector).unwrap(), + B256::from_str(from_address).unwrap(), + B256::from_str(to_address).unwrap(), + B256::from_str(selector).unwrap(), ], data: payload_buf.into(), ..Default::default() @@ -339,7 +331,7 @@ mod tests { assert_eq!( hashes[0], U256::from_str_radix( - "0x5ba1d2e131360f15e26dd4f6ff10550685611cc25f75e7950b704adb04b36162", + "5ba1d2e131360f15e26dd4f6ff10550685611cc25f75e7950b704adb04b36162", 16 ) .unwrap() diff --git a/crates/katana/core/src/service/messaging/mod.rs b/crates/katana/core/src/service/messaging/mod.rs index 466db6d43d..f07b353e8c 100644 --- a/crates/katana/core/src/service/messaging/mod.rs +++ b/crates/katana/core/src/service/messaging/mod.rs @@ -40,10 +40,10 @@ mod starknet; use std::path::Path; use ::starknet::providers::ProviderError as StarknetProviderError; +use alloy_transport::TransportError; use anyhow::Result; use async_trait::async_trait; use ethereum::EthereumMessaging; -use ethers::providers::ProviderError as EthereumProviderError; use katana_primitives::chain::ChainId; use katana_primitives::receipt::MessageToL1; use serde::Deserialize; @@ -77,13 +77,13 @@ pub enum Error { #[derive(Debug, thiserror::Error)] pub enum ProviderError { #[error("Ethereum provider error: {0}")] - Ethereum(EthereumProviderError), + Ethereum(TransportError), #[error("Starknet provider error: {0}")] Starknet(StarknetProviderError), } -impl From for Error { - fn from(e: EthereumProviderError) -> Self { +impl From for Error { + fn from(e: TransportError) -> Self { Self::Provider(ProviderError::Ethereum(e)) } } diff --git a/crates/katana/core/tests/sequencer.rs b/crates/katana/core/tests/sequencer.rs index fa49b94faf..b87e0c9f8d 100644 --- a/crates/katana/core/tests/sequencer.rs +++ b/crates/katana/core/tests/sequencer.rs @@ -1,3 +1,4 @@ +use alloy_primitives::U256; use katana_core::backend::config::{Environment, StarknetConfig}; use katana_core::sequencer::{KatanaSequencer, SequencerConfig}; use katana_executor::implementation::noop::NoopExecutorFactory; @@ -6,7 +7,6 @@ use katana_primitives::genesis::constant::DEFAULT_PREFUNDED_ACCOUNT_BALANCE; use katana_primitives::genesis::Genesis; use katana_provider::traits::block::{BlockNumberProvider, BlockProvider}; use katana_provider::traits::env::BlockEnvProvider; -use primitive_types::U256; fn create_test_sequencer_config() -> (SequencerConfig, StarknetConfig) { let accounts = DevAllocationsGenerator::new(2) diff --git a/crates/katana/executor/Cargo.toml b/crates/katana/executor/Cargo.toml index 22830c4933..dca77a1056 100644 --- a/crates/katana/executor/Cargo.toml +++ b/crates/katana/executor/Cargo.toml @@ -19,6 +19,8 @@ starknet_api.workspace = true thiserror.workspace = true tracing.workspace = true +alloy-primitives.workspace = true + # blockifier deps blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "d38b979", optional = true } cairo-vm = { workspace = true, optional = true } diff --git a/crates/katana/executor/tests/fixtures/mod.rs b/crates/katana/executor/tests/fixtures/mod.rs index 9a7f04ca8d..d11bf0e1ff 100644 --- a/crates/katana/executor/tests/fixtures/mod.rs +++ b/crates/katana/executor/tests/fixtures/mod.rs @@ -2,6 +2,7 @@ pub mod transaction; use std::collections::HashMap; +use alloy_primitives::U256; use cairo_vm::vm::runners::builtin_runner::{ BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, @@ -59,7 +60,7 @@ pub fn genesis() -> Genesis { let accounts = DevAllocationsGenerator::new(10) .with_seed(seed) - .with_balance(DEFAULT_PREFUNDED_ACCOUNT_BALANCE) + .with_balance(U256::from(DEFAULT_PREFUNDED_ACCOUNT_BALANCE)) .generate(); let mut genesis = Genesis::default(); diff --git a/crates/katana/primitives/Cargo.toml b/crates/katana/primitives/Cargo.toml index a2ec69ca12..ac4c654b75 100644 --- a/crates/katana/primitives/Cargo.toml +++ b/crates/katana/primitives/Cargo.toml @@ -27,8 +27,7 @@ cairo-lang-sierra.workspace = true cairo-lang-starknet.workspace = true flate2.workspace = true starknet_api.workspace = true - -ethers = "2.0.11" +alloy-primitives.workspace = true [features] default = [ "serde" ] diff --git a/crates/katana/primitives/src/genesis/allocation.rs b/crates/katana/primitives/src/genesis/allocation.rs index fa5fd2a07c..5ae6f11cba 100644 --- a/crates/katana/primitives/src/genesis/allocation.rs +++ b/crates/katana/primitives/src/genesis/allocation.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use std::fmt::Debug; +use alloy_primitives::U256; use derive_more::{Deref, DerefMut}; -use ethers::types::U256; use rand::rngs::SmallRng; use rand::{RngCore, SeedableRng}; use serde::{Deserialize, Serialize}; @@ -239,7 +239,7 @@ impl DevAllocationsGenerator { Self { total, seed: [0u8; 32], - balance: U256::zero(), + balance: U256::ZERO, class_hash: DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH, } } diff --git a/crates/katana/primitives/src/genesis/json.rs b/crates/katana/primitives/src/genesis/json.rs index 3efc140fa2..ffa9f59a9e 100644 --- a/crates/katana/primitives/src/genesis/json.rs +++ b/crates/katana/primitives/src/genesis/json.rs @@ -10,10 +10,10 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::Arc; +use alloy_primitives::U256; use base64::prelude::*; use cairo_lang_starknet::casm_contract_class::StarknetSierraCompilationError; use cairo_vm::types::errors::program_errors::ProgramError; -use ethers::types::U256; use rayon::prelude::*; use serde::de::value::MapAccessDeserializer; use serde::de::Visitor; @@ -318,7 +318,7 @@ impl TryFrom for Genesis { let mut fee_token = FeeTokenConfig { name: value.fee_token.name, symbol: value.fee_token.symbol, - total_supply: U256::zero(), + total_supply: U256::ZERO, decimals: value.fee_token.decimals, address: value.fee_token.address.unwrap_or(DEFAULT_FEE_TOKEN_ADDRESS), class_hash: value.fee_token.class.unwrap_or(DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH), @@ -552,7 +552,7 @@ mod tests { use std::path::PathBuf; use std::str::FromStr; - use ethers::types::U256; + use alloy_primitives::U256; use starknet::macros::felt; use super::{from_base64, GenesisClassJson, GenesisJson}; @@ -801,7 +801,9 @@ mod tests { address: ContractAddress::from(felt!("0x55")), name: String::from("ETHER"), symbol: String::from("ETH"), - total_supply: U256::from_str("0xD3C21BCECCEDA1000000").unwrap() * 5, + total_supply: U256::from_str("0xD3C21BCECCEDA1000000") + .unwrap() + .wrapping_mul(U256::from(5)), decimals: 18, class_hash: felt!("0x8"), storage: Some(HashMap::from([ diff --git a/crates/katana/primitives/src/genesis/mod.rs b/crates/katana/primitives/src/genesis/mod.rs index 5b072d196e..c1574f660d 100644 --- a/crates/katana/primitives/src/genesis/mod.rs +++ b/crates/katana/primitives/src/genesis/mod.rs @@ -6,7 +6,7 @@ use std::collections::{BTreeMap, HashMap}; use std::fmt::Debug; use std::sync::Arc; -use ethers::types::U256; +use alloy_primitives::U256; use serde::{Deserialize, Serialize}; use starknet::core::serde::unsigned_field_element::UfeHex; use starknet::core::utils::cairo_short_string_to_felt; @@ -246,7 +246,7 @@ impl Default for Genesis { decimals: 18, name: "Ether".into(), symbol: "ETH".into(), - total_supply: 0.into(), + total_supply: U256::ZERO, address: DEFAULT_FEE_TOKEN_ADDRESS, class_hash: DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH, storage: None, @@ -393,7 +393,7 @@ mod tests { ContractAddress::from(felt!("0x2")), GenesisAllocation::Account(GenesisAccountAlloc::Account(GenesisAccount { public_key: felt!("0x2"), - balance: Some(U256::zero()), + balance: Some(U256::ZERO), class_hash: DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH, nonce: None, storage: None, @@ -649,7 +649,7 @@ mod tests { assert_eq!(fee_token_storage.get(&felt!("0x111")), Some(&felt!("0x1"))); assert_eq!(fee_token_storage.get(&felt!("0x222")), Some(&felt!("0x2"))); - let mut actual_total_supply = U256::zero(); + let mut actual_total_supply = U256::ZERO; // check for balance for (address, alloc) in &allocations { diff --git a/crates/katana/primitives/src/receipt.rs b/crates/katana/primitives/src/receipt.rs index 2223115e61..b9f5bb5e9f 100644 --- a/crates/katana/primitives/src/receipt.rs +++ b/crates/katana/primitives/src/receipt.rs @@ -1,4 +1,4 @@ -use ethers::types::H256; +use alloy_primitives::B256; use crate::contract::ContractAddress; use crate::FieldElement; @@ -67,7 +67,7 @@ pub struct L1HandlerTxReceipt { /// Events emitted by contracts. pub events: Vec, /// The hash of the L1 message - pub message_hash: H256, + pub message_hash: B256, /// Messages sent to L1. pub messages_sent: Vec, /// Revert error message if the transaction execution failed. diff --git a/crates/katana/primitives/src/transaction.rs b/crates/katana/primitives/src/transaction.rs index 90a8d7c9be..f2f7cb54e3 100644 --- a/crates/katana/primitives/src/transaction.rs +++ b/crates/katana/primitives/src/transaction.rs @@ -1,5 +1,5 @@ +use alloy_primitives::B256; use derive_more::{AsRef, Deref, From}; -use ethers::types::H256; use starknet::core::types::{DataAvailabilityMode, ResourceBoundsMapping}; use crate::chain::ChainId; @@ -355,7 +355,7 @@ pub struct L1HandlerTx { pub chain_id: ChainId, pub paid_fee_on_l1: u128, pub version: FieldElement, - pub message_hash: H256, + pub message_hash: B256, pub calldata: Vec, pub contract_address: ContractAddress, pub entry_point_selector: FieldElement, diff --git a/crates/katana/primitives/src/utils/mod.rs b/crates/katana/primitives/src/utils/mod.rs index 1a16289a6e..3a1684749f 100644 --- a/crates/katana/primitives/src/utils/mod.rs +++ b/crates/katana/primitives/src/utils/mod.rs @@ -1,4 +1,4 @@ -use ethers::types::U256; +use alloy_primitives::U256; use crate::FieldElement; @@ -9,7 +9,7 @@ pub mod transaction; /// The first element in the returned tuple is the low part, and the second element is the high /// part. pub fn split_u256(value: U256) -> (FieldElement, FieldElement) { - let low_u128: u128 = value.low_u128(); - let high_u128: u128 = (value >> 128).low_u128(); + let low_u128: u128 = value.to::(); + let high_u128: u128 = U256::from(value >> 128).to::(); (FieldElement::from(low_u128), FieldElement::from(high_u128)) } diff --git a/crates/katana/primitives/src/utils/transaction.rs b/crates/katana/primitives/src/utils/transaction.rs index f9922f268d..d2dc99d26a 100644 --- a/crates/katana/primitives/src/utils/transaction.rs +++ b/crates/katana/primitives/src/utils/transaction.rs @@ -1,4 +1,4 @@ -use ethers::types::H256; +use alloy_primitives::B256; use starknet::core::crypto::compute_hash_on_elements; use starknet::core::types::{DataAvailabilityMode, MsgToL1, ResourceBounds}; use starknet_crypto::poseidon_hash_many; @@ -268,10 +268,10 @@ pub fn compute_l1_message_hash( from_address: FieldElement, to_address: FieldElement, payload: &[FieldElement], -) -> H256 { +) -> B256 { let msg = MsgToL1 { from_address, to_address, payload: payload.to_vec() }; - H256::from_slice(msg.hash().as_bytes()) + B256::from_slice(msg.hash().as_bytes()) } fn encode_gas_bound(name: &[u8], bound: &ResourceBounds) -> FieldElement { diff --git a/crates/katana/rpc/rpc-types/Cargo.toml b/crates/katana/rpc/rpc-types/Cargo.toml index d2bfaae88a..2ec1d5f101 100644 --- a/crates/katana/rpc/rpc-types/Cargo.toml +++ b/crates/katana/rpc/rpc-types/Cargo.toml @@ -14,7 +14,6 @@ katana-provider = { path = "../../storage/provider" } anyhow.workspace = true derive_more.workspace = true -ethers = "2.0.11" futures.workspace = true jsonrpsee = { workspace = true, features = [ "macros", "server" ] } serde.workspace = true @@ -23,5 +22,7 @@ serde_with.workspace = true starknet.workspace = true thiserror.workspace = true +alloy-primitives.workspace = true + [dev-dependencies] rstest.workspace = true diff --git a/crates/katana/rpc/rpc-types/src/account.rs b/crates/katana/rpc/rpc-types/src/account.rs index d73eb48f3c..47fc8b225f 100644 --- a/crates/katana/rpc/rpc-types/src/account.rs +++ b/crates/katana/rpc/rpc-types/src/account.rs @@ -1,4 +1,4 @@ -use ethers::types::U256; +use alloy_primitives::U256; use katana_primitives::class::ClassHash; use katana_primitives::contract::ContractAddress; use katana_primitives::genesis::allocation::GenesisAccountAlloc; diff --git a/crates/katana/rpc/rpc-types/src/receipt.rs b/crates/katana/rpc/rpc-types/src/receipt.rs index 42112be1c3..a6ff5692e6 100644 --- a/crates/katana/rpc/rpc-types/src/receipt.rs +++ b/crates/katana/rpc/rpc-types/src/receipt.rs @@ -86,7 +86,7 @@ impl TxReceipt { transaction_hash, actual_fee: FeePayment { amount: rct.actual_fee.into(), unit: PriceUnit::Wei }, execution_resources: ExecutionResources::from(rct.execution_resources).0, - message_hash: Hash256::from_bytes(rct.message_hash.to_fixed_bytes()), + message_hash: Hash256::from_bytes(*rct.message_hash), execution_result: if let Some(reason) = rct.revert_error { ExecutionResult::Reverted { reason } } else { diff --git a/crates/katana/storage/provider/Cargo.toml b/crates/katana/storage/provider/Cargo.toml index 39b0345385..1b40d42c40 100644 --- a/crates/katana/storage/provider/Cargo.toml +++ b/crates/katana/storage/provider/Cargo.toml @@ -11,7 +11,7 @@ katana-db = { path = "../db", features = [ "test-utils" ] } katana-primitives = { path = "../../primitives", features = [ "rpc" ] } anyhow.workspace = true -auto_impl = "1.1.0" +auto_impl = "1.2.0" parking_lot.workspace = true thiserror.workspace = true tracing.workspace = true diff --git a/crates/saya/core/src/lib.rs b/crates/saya/core/src/lib.rs index fc18b5208b..b36261df73 100644 --- a/crates/saya/core/src/lib.rs +++ b/crates/saya/core/src/lib.rs @@ -166,7 +166,7 @@ impl Saya { let exec_infos = self.provider.fetch_transactions_executions(block_number).await?; - if exec_infos.len() == 0 { + if exec_infos.is_empty() { trace!(target: "saya_core", block_number, "Skipping empty block."); return Ok(()); } diff --git a/crates/saya/core/src/prover/serializer.rs b/crates/saya/core/src/prover/serializer.rs index 8c5564cc32..b026e6ca6b 100644 --- a/crates/saya/core/src/prover/serializer.rs +++ b/crates/saya/core/src/prover/serializer.rs @@ -14,11 +14,11 @@ pub fn parse_proof(proof: String) -> anyhow::Result> { let witness: VecFelt252 = serde_json::from_str(&parsed.witness.to_string()).unwrap(); let serialized = config - .to_vec() - .into_iter() - .chain(public_input.to_vec().into_iter()) - .chain(unsent_commitment.to_vec().into_iter()) - .chain(witness.to_vec().into_iter()) + .iter() + .cloned() + .chain(public_input.to_vec()) + .chain(unsent_commitment.iter().cloned()) + .chain(witness.iter().cloned()) .map(|x| FieldElement::from_dec_str(&x.to_string())) .map(Result::unwrap) .collect(); diff --git a/crates/saya/core/src/prover/state_diff.rs b/crates/saya/core/src/prover/state_diff.rs index c6e039b2e0..d87c9090da 100644 --- a/crates/saya/core/src/prover/state_diff.rs +++ b/crates/saya/core/src/prover/state_diff.rs @@ -109,7 +109,7 @@ impl ProvedStateDiff { .join(","); result.push_str(&format!("{}{}", declared_classes, "}")); - result.push_str(&format!("{}", "}")); + result.push('}'); result } diff --git a/crates/saya/core/src/prover/vec252.rs b/crates/saya/core/src/prover/vec252.rs index 09457b7ff5..2d6c0f979b 100644 --- a/crates/saya/core/src/prover/vec252.rs +++ b/crates/saya/core/src/prover/vec252.rs @@ -89,7 +89,7 @@ impl VecFelt252 { impl<'de> Visitor<'de> for VecFelt252 { type Value = VecFelt252; - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { formatter.write_str("a list of arguments") } fn visit_seq(self, mut seq: A) -> Result diff --git a/crates/saya/provider/Cargo.toml b/crates/saya/provider/Cargo.toml index 13e9108e4a..884164ed1b 100644 --- a/crates/saya/provider/Cargo.toml +++ b/crates/saya/provider/Cargo.toml @@ -18,7 +18,7 @@ anyhow.workspace = true auto_impl = "1.1.0" async-trait.workspace = true convert_case.workspace = true -ethers = "2.0.11" +alloy-primitives.workspace = true flate2.workspace = true futures.workspace = true jsonrpsee = { workspace = true, features = ["client"] } diff --git a/crates/saya/provider/src/rpc/state.rs b/crates/saya/provider/src/rpc/state.rs index 890a88dd52..072b30c939 100644 --- a/crates/saya/provider/src/rpc/state.rs +++ b/crates/saya/provider/src/rpc/state.rs @@ -3,7 +3,7 @@ //! For data availability format, all the specification is available here: //! . //! -//! We use `U256` from ethers for easier computation (than working with felts). +//! We use `U256` from alloy for easier computation (than working with felts). //! //! Optims: //! Currently, the serialize functions are using `iter().find()` on arrays @@ -12,7 +12,7 @@ //! arrays to then have O(1) search. use std::collections::{HashMap, HashSet}; -use ethers::types::U256; +use alloy_primitives::U256; use katana_primitives::contract::ContractAddress; use katana_primitives::state::StateUpdates; use starknet::core::types::{ @@ -23,7 +23,7 @@ use starknet::core::types::{ use crate::ProviderResult; // 2 ^ 128 -const CLASS_INFO_FLAG_TRUE: &str = "0x100000000000000000000000000000000"; +const CLASS_INFO_FLAG_TRUE: &str = "100000000000000000000000000000000"; /// Converts the [`StateUpdate`] RPC type into [`StateUpdate`] Katana primitive. /// @@ -230,10 +230,10 @@ fn compute_update_meta_info( if let Some(nonce) = new_nonce { // At the moment, v0.11 and forward are packing the nonce into 64 bits. let nonce_u64: u64 = nonce.try_into().expect("Nonce too large for DA serialization"); - meta += ((nonce_u64 as u128) << 64).into() + meta += U256::from((nonce_u64 as u128) << 64) } - meta += (n_storage_updates as u128).into(); + meta += U256::from(n_storage_updates); FieldElement::from_hex_be(format!("0x{:064x}", meta).as_str()).unwrap() } diff --git a/crates/saya/provider/src/rpc/state_diff.rs b/crates/saya/provider/src/rpc/state_diff.rs index 959eb414a1..aee6e87b70 100644 --- a/crates/saya/provider/src/rpc/state_diff.rs +++ b/crates/saya/provider/src/rpc/state_diff.rs @@ -1,7 +1,5 @@ - use std::collections::HashSet; -use ethers::types::U256; use starknet::core::types::{ ContractStorageDiffItem, DeclaredClassItem, DeployedContractItem, FieldElement, NonceUpdate, StateDiff, @@ -9,4 +7,3 @@ use starknet::core::types::{ // 2 ^ 128 const CLASS_INFO_FLAG_TRUE: &str = "0x100000000000000000000000000000000"; -