From 5d5b1481bd18fd34a80d23dd1a285ef7362af6d5 Mon Sep 17 00:00:00 2001 From: fborello-lambda Date: Wed, 11 Sep 2024 17:35:56 -0300 Subject: [PATCH 1/9] feat: deploy with eip-712 --- Cargo.lock | 563 ++++++++++++++++-------------- Cargo.toml | 2 +- abi/ContractDeployer.json | 411 ++++++++++++++++++++++ rust-toolchain.toml | 2 + src/eip712/meta.rs | 14 +- src/eip712/paymaster_params.rs | 20 +- src/eip712/transaction.rs | 9 +- src/eip712/transaction_request.rs | 63 ++-- src/lib.rs | 1 - src/zk_middleware.rs | 5 +- 10 files changed, 764 insertions(+), 326 deletions(-) create mode 100644 abi/ContractDeployer.json create mode 100644 rust-toolchain.toml diff --git a/Cargo.lock b/Cargo.lock index 9528c11..2601b2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,19 +14,13 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -119,9 +113,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "arrayref" @@ -169,18 +163,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -208,7 +202,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -219,9 +213,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "aws-lc-rs" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae74d9bd0a7530e8afd1770739ad34b36838829d6ad61818f9230f683f5ad77" +checksum = "2f95446d919226d587817a7d21379e6eb099b97b45110a7f272a444ca5c54070" dependencies = [ "aws-lc-sys", "mirai-annotations", @@ -231,9 +225,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.20.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0e249228c6ad2d240c2dc94b714d711629d52bad946075d8e9b2f5391f0703" +checksum = "234314bd569802ec87011d653d6815c6d7b9ffb969e9fee5b8b20ef860e8dce9" dependencies = [ "bindgen", "cc", @@ -293,17 +287,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -365,31 +359,7 @@ checksum = "3ea340d5c1394ee4daf4415dd80e06f74e0ad9b08e21f73f6bb1fa3a9dfae80d" dependencies = [ "arrayvec 0.7.6", "bit-vec", - "blake2s_const 0.7.0", - "blake2s_simd", - "byteorder", - "cfg-if 1.0.0", - "crossbeam 0.7.3", - "futures", - "hex", - "lazy_static", - "num_cpus", - "pairing_ce", - "rand 0.4.6", - "serde", - "smallvec", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "bellman_ce" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aab6627603565b664e6c643a1dc7ea8bbff25b776f5fecd80ac88308fc7007b" -dependencies = [ - "arrayvec 0.7.6", - "bit-vec", - "blake2s_const 0.8.0", + "blake2s_const", "blake2s_simd", "byteorder", "cfg-if 1.0.0", @@ -446,7 +416,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.76", + "syn 2.0.77", "which", ] @@ -521,17 +491,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "blake2s_const" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db04f0f5f88d8c95977159949b23d2ed24d33309901cf7f7e48ed40f36de667" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "constant_time_eq", -] - [[package]] name = "blake2s_simd" version = "0.5.11" @@ -583,6 +542,37 @@ dependencies = [ "unroll", ] +[[package]] +name = "boojum" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ec2f007ff8f90cc459f03e9f30ca1065440170f013c868823646e2e48d0234" +dependencies = [ + "arrayvec 0.7.6", + "bincode", + "blake2", + "const_format", + "convert_case", + "crossbeam 0.8.4", + "crypto-bigint 0.5.5", + "derivative", + "ethereum-types", + "firestorm", + "itertools 0.10.5", + "lazy_static", + "num-modular", + "num_cpus", + "rand 0.8.5", + "rayon", + "serde", + "sha2", + "sha3_ce", + "smallvec", + "unroll", + "zksync_cs_derive", + "zksync_pairing", +] + [[package]] name = "bs58" version = "0.5.1" @@ -675,9 +665,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.15" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "jobserver", "libc", @@ -738,38 +728,38 @@ dependencies = [ [[package]] name = "circuit_encodings" -version = "0.140.1" +version = "0.140.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8438d7af992b730143b679e2c6938cb9e0193897ecaf668c59189af8ac296b7" +checksum = "cf6b7cc842eadb4c250cdc6a8bc1dd97624d9f08bbe54db3e11fb23c3a72be07" dependencies = [ "derivative", "serde", "zk_evm 0.140.0", - "zkevm_circuits 0.140.2", + "zkevm_circuits 0.140.3", ] [[package]] name = "circuit_encodings" -version = "0.141.1" +version = "0.141.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a2fcc80e97682104f355dd819cb4972583828a6c0f65ec26889a78a84b0c56" +checksum = "7898ffbf3cd413576b4b674fe1545a35488c67eb16bd5a4148425e42c2a2b65b" dependencies = [ "derivative", "serde", "zk_evm 0.141.0", - "zkevm_circuits 0.141.1", + "zkevm_circuits 0.141.2", ] [[package]] name = "circuit_encodings" -version = "0.142.1" +version = "0.142.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94be7afb5ace6024d6e3c105d521b4b9b563bac14a92c2f59c4683e9169a25d8" +checksum = "8364ecafcc4b2c896023f8d3af952c52a500aa55f14fd268bb5d9ab07f837369" dependencies = [ "derivative", "serde", "zk_evm 0.141.0", - "zkevm_circuits 0.141.1", + "zkevm_circuits 0.141.2", ] [[package]] @@ -786,57 +776,57 @@ dependencies = [ [[package]] name = "circuit_sequencer_api" -version = "0.133.0" +version = "0.133.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a87dc7bee6630d4954ac7982eb77e2007476662250cf18e5c460bbc5ee435f1" +checksum = "eb959b1f8c6bbd8be711994d182e85452a26a5d2213a709290b71c8262af1331" dependencies = [ - "bellman_ce 0.7.0", "derivative", "rayon", "serde", "zk_evm 0.133.0", + "zksync_bellman", ] [[package]] name = "circuit_sequencer_api" -version = "0.140.1" +version = "0.140.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9b15463f9da44561867e6416a5b9c343164636811f68503868d37675be2d59" +checksum = "fa5f22311ce609d852d7d9f4943535ea4610aeb785129ae6ff83d5201c4fb387" dependencies = [ - "bellman_ce 0.8.0", - "circuit_encodings 0.140.1", + "circuit_encodings 0.140.3", "derivative", "rayon", "serde", "zk_evm 0.140.0", + "zksync_bellman", ] [[package]] name = "circuit_sequencer_api" -version = "0.141.1" +version = "0.141.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55a257b31a8ea1c1723cab4fb5661c6b4c0ebe022d4b73bea9eb7c9150bd3bc1" +checksum = "4c47c71d6ba83a8beb0af13af70beffd627f5497caf3d44c6f96363e788b07ea" dependencies = [ - "bellman_ce 0.8.0", - "circuit_encodings 0.141.1", + "circuit_encodings 0.141.2", "derivative", "rayon", "serde", "zk_evm 0.141.0", + "zksync_bellman", ] [[package]] name = "circuit_sequencer_api" -version = "0.142.1" +version = "0.142.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273351e61b0f9a36b09550e244989c38f9877382b42d0329797c72004dcabef7" +checksum = "e264723359e6a1aad98110bdccf1ae3ad596e93e7d31da9e40f6adc07e4add54" dependencies = [ - "bellman_ce 0.8.0", - "circuit_encodings 0.142.1", + "circuit_encodings 0.142.2", "derivative", "rayon", "serde", "zk_evm 0.141.0", + "zksync_bellman", ] [[package]] @@ -845,7 +835,7 @@ version = "0.150.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42d1a86b9c2207f3bb2dff5f00d1af1cb95004b6d07e9bacb6519fe08f12c04b" dependencies = [ - "bellman_ce 0.7.0", + "bellman_ce", "circuit_encodings 0.150.4", "derivative", "rayon", @@ -865,9 +855,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -875,9 +865,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -894,7 +884,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1017,18 +1007,18 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const_format" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" dependencies = [ "proc-macro2", "quote", @@ -1068,9 +1058,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1271,7 +1261,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1384,7 +1374,7 @@ checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1404,7 +1394,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "unicode-xid", ] @@ -1606,7 +1596,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1647,6 +1637,14 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "eravm-stable-interface" +version = "0.1.0" +source = "git+https://github.com/matter-labs/vm2.git?rev=4ef15d46410ffc11744771a3a6c7c09dd9470c90#4ef15d46410ffc11744771a3a6c7c09dd9470c90" +dependencies = [ + "primitive-types", +] + [[package]] name = "errno" version = "0.3.9" @@ -1793,7 +1791,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.76", + "syn 2.0.77", "toml", "walkdir", ] @@ -1811,7 +1809,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1837,7 +1835,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.76", + "syn 2.0.77", "tempfile", "thiserror", "tiny-keccak 2.0.2", @@ -2083,7 +2081,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -2211,7 +2209,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2289,9 +2287,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "glob" @@ -2454,7 +2452,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -2473,7 +2471,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -2683,16 +2681,16 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", "hyper 1.4.1", "hyper-util", "log", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -2743,9 +2741,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ "bytes", "futures-channel", @@ -2856,9 +2854,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -2884,9 +2882,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is_terminal_polyfill" @@ -3003,7 +3001,7 @@ dependencies = [ "http 1.1.0", "jsonrpsee-core", "pin-project", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "rustls-platform-verifier", "soketto", @@ -3052,11 +3050,11 @@ dependencies = [ "base64 0.22.1", "http-body 1.0.1", "hyper 1.4.1", - "hyper-rustls 0.27.2", + "hyper-rustls 0.27.3", "hyper-util", "jsonrpsee-core", "jsonrpsee-types", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-platform-verifier", "serde", "serde_json", @@ -3077,7 +3075,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3297,7 +3295,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.6.29", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3381,7 +3379,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3406,15 +3404,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -3621,7 +3610,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3633,14 +3622,14 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -3699,7 +3688,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3772,7 +3761,7 @@ dependencies = [ "opentelemetry-http", "opentelemetry-proto", "opentelemetry_sdk", - "prost 0.13.1", + "prost 0.13.2", "reqwest 0.12.7", "thiserror", "tokio", @@ -3787,7 +3776,7 @@ checksum = "30ee9f20bff9c984511a02f082dc8ede839e4a9bf15cc2487c8d6fea5ad850d9" dependencies = [ "opentelemetry", "opentelemetry_sdk", - "prost 0.13.1", + "prost 0.13.2", "tonic", ] @@ -4010,7 +3999,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.4.0", + "indexmap 2.5.0", ] [[package]] @@ -4053,7 +4042,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4091,7 +4080,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4170,7 +4159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4268,7 +4257,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4299,12 +4288,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" dependencies = [ "bytes", - "prost-derive 0.13.1", + "prost-derive 0.13.2", ] [[package]] @@ -4324,7 +4313,7 @@ dependencies = [ "prost 0.12.6", "prost-types", "regex", - "syn 2.0.76", + "syn 2.0.77", "tempfile", ] @@ -4338,20 +4327,20 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "prost-derive" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" dependencies = [ "anyhow", "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4651,7 +4640,7 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "hyper 1.4.1", - "hyper-rustls 0.27.2", + "hyper-rustls 0.27.3", "hyper-tls 0.6.0", "hyper-util", "ipnet", @@ -4807,9 +4796,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -4832,16 +4821,16 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "aws-lc-rs", "log", "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -4895,13 +4884,13 @@ dependencies = [ "jni", "log", "once_cell", - "rustls 0.23.12", + "rustls 0.23.13", "rustls-native-certs", "rustls-platform-verifier-android", - "rustls-webpki 0.102.7", + "rustls-webpki 0.102.8", "security-framework", "security-framework-sys", - "webpki-roots 0.26.3", + "webpki-roots 0.26.5", "winapi", ] @@ -4923,9 +4912,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "aws-lc-rs", "ring 0.17.8", @@ -4989,11 +4978,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5240,9 +5229,9 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -5259,20 +5248,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -5330,7 +5319,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "itoa", "ryu", "serde", @@ -5597,7 +5586,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -5639,9 +5628,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -5752,7 +5741,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -5831,9 +5820,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -5855,7 +5844,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -5884,16 +5873,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.12", + "rustls 0.23.13", "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -5917,9 +5906,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -5956,7 +5945,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "toml_datetime", "winnow 0.5.40", ] @@ -5967,7 +5956,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", @@ -5994,7 +5983,7 @@ dependencies = [ "hyper-util", "percent-encoding", "pin-project", - "prost 0.13.1", + "prost 0.13.2", "socket2", "tokio", "tokio-stream", @@ -6056,7 +6045,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6216,9 +6205,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -6390,15 +6379,16 @@ checksum = "6a511871dc5de990a3b2a0e715facfbc5da848c0c0395597a1415029fb7c250a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "vm2" version = "0.1.0" -source = "git+https://github.com/matter-labs/vm2.git?rev=2276b7b5af520fca0477bdafe43781b51896d235#2276b7b5af520fca0477bdafe43781b51896d235" +source = "git+https://github.com/matter-labs/vm2.git?rev=4ef15d46410ffc11744771a3a6c7c09dd9470c90#4ef15d46410ffc11744771a3a6c7c09dd9470c90" dependencies = [ "enum_dispatch", + "eravm-stable-interface", "primitive-types", "zk_evm_abstractions 0.150.4", "zkevm_opcode_defs 0.150.4", @@ -6451,7 +6441,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-shared", ] @@ -6485,7 +6475,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6537,9 +6527,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.3" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" dependencies = [ "rustls-pki-types", ] @@ -6854,7 +6844,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -6862,20 +6852,6 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.76", -] [[package]] name = "zip" @@ -7019,14 +6995,13 @@ dependencies = [ [[package]] name = "zkevm_circuits" -version = "0.140.2" +version = "0.140.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8beed4cc1ab1f9d99a694506d18705e10059534b30742832be49637c4775e1f8" +checksum = "e3c365c801e0c6eda83fbd153df45575172beb406bfb663d386f9154b4325eda" dependencies = [ "arrayvec 0.7.6", "bincode", - "boojum", - "cs_derive", + "boojum 0.30.1", "derivative", "hex", "itertools 0.10.5", @@ -7037,18 +7012,18 @@ dependencies = [ "serde_json", "smallvec", "zkevm_opcode_defs 0.132.0", + "zksync_cs_derive", ] [[package]] name = "zkevm_circuits" -version = "0.141.1" +version = "0.141.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20f1a64d256cc5f5c58d19cf976cb45973df54e4e3010ca4a3e6fafe9f06075e" +checksum = "2ccd0352e122a4e6f0046d2163b7e692e627b23fc3264faa77331a21b65833fd" dependencies = [ "arrayvec 0.7.6", "bincode", - "boojum", - "cs_derive", + "boojum 0.30.1", "derivative", "hex", "itertools 0.10.5", @@ -7059,6 +7034,7 @@ dependencies = [ "serde_json", "smallvec", "zkevm_opcode_defs 0.141.0", + "zksync_cs_derive", ] [[package]] @@ -7068,7 +7044,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abdfaa95dfe0878fda219dd17a6cc8c28711e2067785910c0e06d3ffdca78629" dependencies = [ "arrayvec 0.7.6", - "boojum", + "boojum 0.2.2", "cs_derive", "derivative", "hex", @@ -7142,7 +7118,7 @@ dependencies = [ [[package]] name = "zksync-ethers-rs" -version = "0.1.1" +version = "0.2.1" dependencies = [ "async-trait", "clap", @@ -7168,7 +7144,7 @@ dependencies = [ [[package]] name = "zksync_basic_types" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "chrono", @@ -7184,11 +7160,34 @@ dependencies = [ "url", ] +[[package]] +name = "zksync_bellman" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffa03efe9bdb137a4b36b97d1a74237e18c9ae42b755163d903a9d48c1a5d80" +dependencies = [ + "arrayvec 0.7.6", + "bit-vec", + "blake2s_simd", + "byteorder", + "cfg-if 1.0.0", + "crossbeam 0.8.4", + "futures", + "hex", + "lazy_static", + "num_cpus", + "rand 0.4.6", + "serde", + "smallvec", + "tiny-keccak 1.5.0", + "zksync_pairing", +] + [[package]] name = "zksync_concurrency" -version = "0.1.0-rc.11" +version = "0.1.0-rc.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0e31a9fc9a390b440cd12bbe040330dc64f64697a8a8ecbc3beb98cd0747909" +checksum = "a49ad68bfaf6fb8542c68894b68b28be31514786549855aaa8a46b36defbb100" dependencies = [ "anyhow", "once_cell", @@ -7206,7 +7205,7 @@ dependencies = [ [[package]] name = "zksync_config" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "rand 0.8.5", @@ -7221,9 +7220,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.1.0-rc.11" +version = "0.1.0-rc.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ff679f8b5f671d887a750b8107f3b5c01fd6085f68eef37ab01de8d2bd0736b" +checksum = "4d624f55e2449f43b2c85588b5dd2a28b3c5ea629effc89df76e3254f8d9d2fb" dependencies = [ "anyhow", "rand 0.8.5", @@ -7234,7 +7233,7 @@ dependencies = [ [[package]] name = "zksync_contracts" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "envy", "ethabi", @@ -7248,7 +7247,7 @@ dependencies = [ [[package]] name = "zksync_crypto_primitives" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "blake2", @@ -7263,10 +7262,50 @@ dependencies = [ "zksync_utils", ] +[[package]] +name = "zksync_cs_derive" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5939e2df4288c263c706ff18ac718e984149223ad4289d6d957d767dcfc04c81" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "zksync_ff" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9524b06780b5e164e84b38840c7c428c739f051f35af6efc4d1285f629ceb88e" +dependencies = [ + "byteorder", + "hex", + "rand 0.4.6", + "serde", + "zksync_ff_derive", +] + +[[package]] +name = "zksync_ff_derive" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f91e58e75d65877f09f83bc3dca8f054847ae7ec4f3e64bfa610a557edd8e8e" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", +] + [[package]] name = "zksync_mini_merkle_tree" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "once_cell", "zksync_basic_types", @@ -7276,13 +7315,13 @@ dependencies = [ [[package]] name = "zksync_multivm" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", - "circuit_sequencer_api 0.133.0", - "circuit_sequencer_api 0.140.1", - "circuit_sequencer_api 0.141.1", - "circuit_sequencer_api 0.142.1", + "circuit_sequencer_api 0.133.1", + "circuit_sequencer_api 0.140.3", + "circuit_sequencer_api 0.141.2", + "circuit_sequencer_api 0.142.2", "circuit_sequencer_api 0.150.4", "hex", "itertools 0.10.5", @@ -7307,7 +7346,7 @@ dependencies = [ [[package]] name = "zksync_object_store" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "async-trait", @@ -7328,11 +7367,24 @@ dependencies = [ "zksync_types", ] +[[package]] +name = "zksync_pairing" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8412ae5574472fa567a097e183f9a01974b99dd0b5da3bfa1bbe6c57c579aa2" +dependencies = [ + "byteorder", + "cfg-if 1.0.0", + "rand 0.4.6", + "serde", + "zksync_ff", +] + [[package]] name = "zksync_protobuf" -version = "0.1.0-rc.11" +version = "0.1.0-rc.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f6ba3bf0aac20de18b4ae18a22d8c81b83f8f72e8fdec1c879525ecdacd2f5" +checksum = "d26fb2beb3aeafb5e9babf1acf6494662cc7157b893fa248bd151494f931d07f" dependencies = [ "anyhow", "bit-vec", @@ -7351,9 +7403,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.1.0-rc.11" +version = "0.1.0-rc.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7798c248b9a64505f0586bd5fadad6b26c999be4a8dec6b1a86b10b3888169c5" +checksum = "58e86c198e056d921b4f3f1d2755c23d090e942b5a70b03bcb7e7c02445aa491" dependencies = [ "anyhow", "heck", @@ -7363,13 +7415,13 @@ dependencies = [ "prost-reflect", "protox", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "zksync_prover_interface" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "chrono", "circuit_sequencer_api 0.150.4", @@ -7384,7 +7436,7 @@ dependencies = [ [[package]] name = "zksync_system_constants" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "once_cell", "zksync_basic_types", @@ -7394,7 +7446,7 @@ dependencies = [ [[package]] name = "zksync_types" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "bigdecimal", @@ -7428,13 +7480,12 @@ dependencies = [ [[package]] name = "zksync_utils" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "bigdecimal", "futures", "hex", - "itertools 0.10.5", "num", "once_cell", "reqwest 0.12.7", @@ -7451,7 +7502,7 @@ dependencies = [ [[package]] name = "zksync_vlog" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "chrono", @@ -7477,8 +7528,10 @@ dependencies = [ [[package]] name = "zksync_vm_interface" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ + "anyhow", + "async-trait", "hex", "serde", "thiserror", @@ -7491,7 +7544,7 @@ dependencies = [ [[package]] name = "zksync_web3_decl" version = "0.1.0" -source = "git+https://github.com/matter-labs/zksync-era.git#8ed086afecfcad30bfda44fc4d29a00beea71cca" +source = "git+https://github.com/matter-labs/zksync-era.git#ffb38380f132f15095ee710181512aef05b9ed64" dependencies = [ "anyhow", "async-trait", @@ -7499,7 +7552,7 @@ dependencies = [ "jsonrpsee", "pin-project-lite", "rlp", - "rustls 0.23.12", + "rustls 0.23.13", "serde", "serde_json", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 67506dd..f9e26b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zksync-ethers-rs" -version = "0.1.1" +version = "0.2.1" edition = "2021" license = "MIT" description = "Rust SDK for zkSync Era" diff --git a/abi/ContractDeployer.json b/abi/ContractDeployer.json new file mode 100644 index 0000000..5f749f9 --- /dev/null +++ b/abi/ContractDeployer.json @@ -0,0 +1,411 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "accountAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum IContractDeployer.AccountNonceOrdering", + "name": "nonceOrdering", + "type": "uint8" + } + ], + "name": "AccountNonceOrderingUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "accountAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "aaVersion", + "type": "uint8" + } + ], + "name": "AccountVersionUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "deployerAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "bytecodeHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "contractAddress", + "type": "address" + } + ], + "name": "ContractDeployed", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "create", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "create2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + }, + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "_aaVersion", + "type": "uint8" + } + ], + "name": "create2Account", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + }, + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "_aaVersion", + "type": "uint8" + } + ], + "name": "createAccount", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "extendedAccountVersion", + "outputs": [ + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "newAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "callConstructor", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "input", + "type": "bytes" + } + ], + "internalType": "struct ContractDeployer.ForceDeployment", + "name": "_deployment", + "type": "tuple" + }, + { + "internalType": "address", + "name": "_sender", + "type": "address" + } + ], + "name": "forceDeployOnAddress", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "newAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "callConstructor", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "input", + "type": "bytes" + } + ], + "internalType": "struct ContractDeployer.ForceDeployment[]", + "name": "_deployments", + "type": "tuple[]" + } + ], + "name": "forceDeployOnAddresses", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "getAccountInfo", + "outputs": [ + { + "components": [ + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "supportedAAVersion", + "type": "uint8" + }, + { + "internalType": "enum IContractDeployer.AccountNonceOrdering", + "name": "nonceOrdering", + "type": "uint8" + } + ], + "internalType": "struct IContractDeployer.AccountInfo", + "name": "info", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_senderNonce", + "type": "uint256" + } + ], + "name": "getNewAddressCreate", + "outputs": [ + { + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "getNewAddressCreate2", + "outputs": [ + { + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "_version", + "type": "uint8" + } + ], + "name": "updateAccountVersion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IContractDeployer.AccountNonceOrdering", + "name": "_nonceOrdering", + "type": "uint8" + } + ], + "name": "updateNonceOrdering", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] + \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly" diff --git a/src/eip712/meta.rs b/src/eip712/meta.rs index d3fc1fb..381838c 100644 --- a/src/eip712/meta.rs +++ b/src/eip712/meta.rs @@ -68,17 +68,15 @@ impl Encodable for Eip712Meta { // 12 stream.append(&self.gas_per_pubdata); // 13 - if !self.factory_deps.is_empty() { - stream.begin_list(self.factory_deps.len()); - for dep in self.factory_deps.iter() { - stream.append(dep); - } - } else { - stream.begin_list(0); + stream.begin_list(self.factory_deps.len()); + for dep in self.factory_deps.iter() { + stream.append(dep); } // 14 rlp_append_option(stream, self.custom_signature.clone().map(|v| v.to_vec())); // 15 - self.paymaster_params.rlp_append(stream); + if let Some(paymaster_params) = self.paymaster_params.clone() { + paymaster_params.rlp_append(stream); + } } } diff --git a/src/eip712/paymaster_params.rs b/src/eip712/paymaster_params.rs index fe8ed78..58470aa 100644 --- a/src/eip712/paymaster_params.rs +++ b/src/eip712/paymaster_params.rs @@ -1,25 +1,21 @@ -use super::rlp_append_option; -use ethers::{ - types::{Address, Bytes}, - utils::rlp::Encodable, -}; +use ethers::{types::Address, utils::rlp::Encodable}; use serde::Serialize; #[derive(Serialize, serde::Deserialize, Clone, Debug, Default)] #[serde(rename_all(serialize = "camelCase", deserialize = "camelCase"))] pub struct PaymasterParams { - pub paymaster: Option
, - pub paymaster_input: Option, + pub paymaster: Address, + pub paymaster_input: Vec, } impl PaymasterParams { pub fn paymaster(mut self, paymaster: Address) -> Self { - self.paymaster = Some(paymaster); + self.paymaster = paymaster; self } - pub fn paymaster_input(mut self, paymaster_input: Bytes) -> Self { - self.paymaster_input = Some(paymaster_input); + pub fn paymaster_input(mut self, paymaster_input: Vec) -> Self { + self.paymaster_input = paymaster_input; self } } @@ -27,7 +23,7 @@ impl PaymasterParams { impl Encodable for PaymasterParams { fn rlp_append(&self, stream: &mut ethers::utils::rlp::RlpStream) { stream.begin_list(2); - rlp_append_option(stream, self.paymaster); - rlp_append_option(stream, self.paymaster_input.clone().map(|v| v.to_vec())); + stream.append(&self.paymaster); + stream.append(&self.paymaster_input.clone()); } } diff --git a/src/eip712/transaction.rs b/src/eip712/transaction.rs index 1e177c3..70f8a45 100644 --- a/src/eip712/transaction.rs +++ b/src/eip712/transaction.rs @@ -291,12 +291,9 @@ impl TryFrom for Eip712Transaction { .chain_id(tx.chain_id); if let Some(paymaster_params) = tx.custom_data.paymaster_params { - if let Some(paymaster) = paymaster_params.paymaster { - eip712_transaction = eip712_transaction.paymaster(paymaster) - } - if let Some(paymaster_input) = paymaster_params.paymaster_input { - eip712_transaction = eip712_transaction.paymaster_input(paymaster_input) - } + eip712_transaction = eip712_transaction + .paymaster(paymaster_params.paymaster) + .paymaster_input(paymaster_params.paymaster_input); } if let Some(gas_limit) = tx.gas_limit { diff --git a/src/eip712/transaction_request.rs b/src/eip712/transaction_request.rs index e1b6d85..ee7c678 100644 --- a/src/eip712/transaction_request.rs +++ b/src/eip712/transaction_request.rs @@ -165,48 +165,29 @@ impl Eip712TransactionRequest { } pub fn rlp(&self, signature: Option) -> Result { - let mut stream = RlpStream::new(); - stream.begin_unbounded_list(); - - // 0 - stream.append(&self.nonce); - // 1 - stream.append(&self.max_priority_fee_per_gas); - // 2 - rlp_append_option(&mut stream, self.max_fee_per_gas); - // 3 (supped to be gas) - rlp_append_option(&mut stream, self.gas_limit); - // 4 - stream.append(&self.to); - // 5 - stream.append(&self.value); - // 6 - stream.append(&self.data.0); - // 7 - stream.append(&self.chain_id); - // 8 - stream.append(&""); - // 9 - stream.append(&""); - // 10 - stream.append(&self.chain_id); - // 11 - stream.append(&self.from); - // 12, 13, 14, 15 - if self.custom_data.custom_signature.clone().is_some() { - self.custom_data.rlp_append(&mut stream); - } else if let Some(signature) = signature { - let tx = self.clone().custom_data( - self.clone() - .custom_data - .custom_signature(signature.to_vec()), - ); - tx.custom_data.rlp_append(&mut stream); - } else { - return Err(Eip712Error::Message("No signature provided".to_owned())); + let mut rlp = RlpStream::new(); + rlp.begin_unbounded_list(); + rlp.append(&self.nonce); + rlp.append(&self.max_priority_fee_per_gas); + rlp.append(&self.gas_price); + rlp_append_option(&mut rlp, self.gas_limit); + rlp.append(&self.to); + rlp.append(&self.value); + rlp.append(&self.data.0); + if let Some(sig) = signature { + rlp.append(&sig.v); + // Convert to big-endian bytes (32 bytes in total) + let mut bytes = [0_u8; 32]; // U256 is 32 bytes + sig.r.to_big_endian(&mut bytes); + rlp.append(&bytes.as_slice()); + sig.s.to_big_endian(&mut bytes); + rlp.append(&bytes.as_slice()); } - stream.finalize_unbounded_list(); - Ok(stream.out().freeze().into()) + rlp.append(&self.chain_id); + rlp.append(&self.from); + self.custom_data.rlp_append(&mut rlp); + rlp.finalize_unbounded_list(); + Ok(rlp.out().freeze().into()) } } diff --git a/src/lib.rs b/src/lib.rs index fe72a28..7218354 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,6 @@ #![forbid(unsafe_code)] #![recursion_limit = "256"] #![warn( - clippy::allow_attributes_without_reason, clippy::as_conversions, clippy::as_ptr_cast_mut, clippy::unnecessary_cast, diff --git a/src/zk_middleware.rs b/src/zk_middleware.rs index f65b8b7..6d79ae9 100644 --- a/src/zk_middleware.rs +++ b/src/zk_middleware.rs @@ -597,12 +597,13 @@ where .map_err(|_e| ProviderError::CustomError("error on send_transaction_eip712".to_owned())) .map_err(M::convert_err)?; + let gas_price = self.get_gas_price().await?; request = request .from(wallet.address()) .chain_id(wallet.chain_id()) .nonce(self.get_transaction_count(wallet.address(), None).await?) - .gas_price(self.get_gas_price().await?) - .max_fee_per_gas(self.get_gas_price().await?); + .gas_price(gas_price) + .max_fee_per_gas(gas_price); let custom_data = request.clone().custom_data; let fee = self.estimate_fee(request.clone()).await?; From ff3110c1f94a79c1aa642da14e2e9dc90781d90d Mon Sep 17 00:00:00 2001 From: fborello-lambda Date: Wed, 11 Sep 2024 17:53:02 -0300 Subject: [PATCH 2/9] add send_transaction_eip712 to zk_wallet --- src/eip712/mod.rs | 2 + src/eip712/transaction_request.rs | 166 ++++++++++++++++++++---------- src/zk_wallet.rs | 75 +++++++++++++- 3 files changed, 185 insertions(+), 58 deletions(-) diff --git a/src/eip712/mod.rs b/src/eip712/mod.rs index 91862d8..ae9e218 100644 --- a/src/eip712/mod.rs +++ b/src/eip712/mod.rs @@ -17,6 +17,8 @@ pub use transaction::Eip712Transaction; mod paymaster_params; pub use paymaster_params::PaymasterParams; +pub use transaction_request::DeployRequest; + /// The 32-byte hash of the bytecode of a zkSync contract is calculated in the following way: /// /// * The first 2 bytes denote the version of bytecode hash format and are currently equal to [1,0]. diff --git a/src/eip712/transaction_request.rs b/src/eip712/transaction_request.rs index ee7c678..999c119 100644 --- a/src/eip712/transaction_request.rs +++ b/src/eip712/transaction_request.rs @@ -1,14 +1,19 @@ -use super::{rlp_append_option, Eip712Meta}; -use crate::{types::L1TxOverrides, utils::MAX_PRIORITY_FEE_PER_GAS}; +use super::{hash_bytecode, rlp_append_option, Eip712Meta}; +use crate::{ + types::L1TxOverrides, + utils::{self, MAX_PRIORITY_FEE_PER_GAS}, +}; use ethers::{ + abi::{Abi, Error, ParseError}, types::{ transaction::{eip2930::AccessList, eip712::Eip712Error}, Address, Bytes, Signature, U256, }, utils::rlp::{Encodable, RlpStream}, }; +use ethers_contract::{abigen, encode_function_data, AbiError}; use serde::{Deserialize, Serialize}; -use zksync_types::{DEFAULT_ERA_CHAIN_ID, EIP_712_TX_TYPE}; +use zksync_types::{CONTRACT_DEPLOYER_ADDRESS, DEFAULT_ERA_CHAIN_ID, EIP_712_TX_TYPE}; // TODO: Not all the fields are optional. This was copied from the JS implementation. #[derive(Serialize, Deserialize, Clone, Debug)] @@ -245,57 +250,108 @@ impl Default for Eip712TransactionRequest { // } // } -// impl TryFrom for Eip712TransactionRequest { -// type Error = ZKRequestError; +use std::{fmt::Debug, fs::File, io::BufReader, path::PathBuf}; -// fn try_from(request: DeployRequest) -> Result { -// let mut contract_deployer_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); -// contract_deployer_path.push("src/abi/ContractDeployer.json"); - -// let custom_data = Eip712Meta::new().factory_deps({ -// let mut factory_deps = Vec::new(); -// if let Some(factory_dependencies) = request.factory_deps { -// factory_deps.extend(factory_dependencies); -// } -// factory_deps.push(request.contract_bytecode.clone()); -// factory_deps -// }); - -// let contract_deployer = Abi::load(BufReader::new( -// File::open(contract_deployer_path).map_err(|e| { -// ZKRequestError::CustomError(format!( -// "Error opening contract deployer abi file {e:?}" -// )) -// })?, -// ))?; -// let create = contract_deployer.function("create")?; - -// // TODO: User could provide this instead of defaulting. -// let salt = [0_u8; 32]; -// let bytecode_hash = hash_bytecode(&request.contract_bytecode).map_err(|e| { -// ZKRequestError::CustomError(format!("Error hashing contract bytecode {e:?}")) -// })?; -// let call_data: Bytes = match ( -// request.contract_abi.constructor(), -// request.constructor_parameters.is_empty(), -// ) { -// (None, false) => { -// return Err(ZKRequestError::CustomError( -// "Constructor not present".to_owned(), -// )) -// } -// (None, true) | (Some(_), true) => Bytes::default(), -// (Some(constructor), false) => { -// utils::encode_constructor_args(constructor, &request.constructor_parameters)?.into() -// } -// }; - -// let data = encode_function_data(create, (salt, bytecode_hash, call_data))?; +#[derive(Clone, Debug)] +pub struct DeployRequest { + pub contract_abi: Abi, + pub contract_bytecode: Vec, + pub constructor_parameters: Vec, + pub from: Address, + pub factory_deps: Option>>, +} -// Ok(Eip712TransactionRequest::new() -// .r#type(EIP_712_TX_TYPE) -// .to(CONTRACT_DEPLOYER_ADDRESS) -// .custom_data(custom_data) -// .data(data)) -// } -// } +impl DeployRequest { + pub fn with( + contract_abi: Abi, + contract_bytecode: Vec, + constructor_parameters: Vec, + ) -> Self { + Self { + contract_abi, + contract_bytecode, + constructor_parameters, + from: Default::default(), + factory_deps: None, + } + } + + pub fn from(mut self, from: Address) -> Self { + self.from = from; + self + } + + pub fn factory_deps(mut self, factory_deps: Vec>) -> Self { + self.factory_deps = Some(factory_deps); + self + } +} + +#[derive(thiserror::Error, Debug)] +pub enum ZKRequestError { + #[error("Error parsing function: {0}")] + ParseFunctionError(#[from] ParseError), + #[error("ABI error: {0}")] + AbiError(#[from] AbiError), + #[error("Encoding or decoding error: {0}")] + Error(#[from] Error), + #[error("{0}")] + CustomError(String), +} + +abigen!(ContractDeployer, "abi/ContractDeployer.json"); + +impl TryFrom for Eip712TransactionRequest { + type Error = ZKRequestError; + + fn try_from(request: DeployRequest) -> Result { + let mut contract_deployer_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + contract_deployer_path.push("abi/ContractDeployer.json"); + + let custom_data = Eip712Meta::new().factory_deps({ + let mut factory_deps = Vec::new(); + if let Some(factory_dependencies) = request.factory_deps { + factory_deps.extend(factory_dependencies); + } + factory_deps.push(request.contract_bytecode.clone()); + factory_deps + }); + + let contract_deployer = Abi::load(BufReader::new( + File::open(contract_deployer_path).map_err(|e| { + ZKRequestError::CustomError(format!( + "Error opening contract deployer abi file {e:?}" + )) + })?, + ))?; + let create = contract_deployer.function("create")?; + + // TODO: User could provide this instead of defaulting. + let salt = [0_u8; 32]; + let bytecode_hash = hash_bytecode(&request.contract_bytecode).map_err(|e| { + ZKRequestError::CustomError(format!("Error hashing contract bytecode {e:?}")) + })?; + let call_data: Bytes = match ( + request.contract_abi.constructor(), + request.constructor_parameters.is_empty(), + ) { + (None, false) => { + return Err(ZKRequestError::CustomError( + "Constructor not present".to_owned(), + )) + } + (None, true) | (Some(_), true) => Bytes::default(), + (Some(constructor), false) => { + utils::encode_constructor_args(constructor, &request.constructor_parameters)?.into() + } + }; + + let data = encode_function_data(create, (salt, bytecode_hash, call_data))?; + + Ok(Eip712TransactionRequest::new() + .r#type(EIP_712_TX_TYPE) + .to(CONTRACT_DEPLOYER_ADDRESS) + .custom_data(custom_data) + .data(data)) + } +} diff --git a/src/zk_wallet.rs b/src/zk_wallet.rs index 44a05ac..0d89c1f 100644 --- a/src/zk_wallet.rs +++ b/src/zk_wallet.rs @@ -1,15 +1,23 @@ +// FIXME: Remove this after finishing the implementation. +#![allow(clippy::unwrap_used)] + use ethers::{ abi::{Address, Hash}, middleware::SignerMiddleware, providers::{Middleware, Provider}, signers::Signer, - types::U256, + types::{Signature, TransactionReceipt, U256}, }; use std::sync::Arc; -use zksync_types::L2_BASE_TOKEN_ADDRESS; +use zksync_types::{fee::Fee, EIP_712_TX_TYPE, L2_BASE_TOKEN_ADDRESS}; use crate::{ - deposit, transfer, types::L2TxOverrides, utils::L2_ETH_TOKEN_ADDRESS, withdraw, ZKMiddleware, + deposit, + eip712::{Eip712Transaction, Eip712TransactionRequest}, + transfer, + types::L2TxOverrides, + utils::L2_ETH_TOKEN_ADDRESS, + withdraw, ZKMiddleware, }; #[derive(thiserror::Error, Debug)] @@ -509,4 +517,65 @@ where .await .map_err(Into::into) } + + //value: MiddlewareError(JsonRpcClientError(JsonRpcError(JsonRpcError { code: -32000, message: "transaction type not supported", data: None }))) + pub async fn send_transaction_eip712( + &self, + transaction: Eip712TransactionRequest, + ) -> TransactionReceipt { + let mut request: Eip712TransactionRequest = transaction; + let gas_price = self.l2_provider().get_gas_price().await.unwrap(); + let l1_signer = self.l1_signer(); + request = request + .from(self.l2_address()) + .chain_id(self.l2_provider().get_chainid().await.unwrap()) + .nonce( + self.l2_provider() + .get_transaction_count(self.l2_address(), None) + .await + .unwrap(), + ) + .gas_price(gas_price) + .max_fee_per_gas(gas_price); + + let custom_data = request.clone().custom_data; + // TODO: estimate_fee is not working + //let fee = self + // .l2_provider() + // .estimate_fee(request.clone()) + // .await + // .unwrap(); + let fee = Fee { + max_fee_per_gas: U256::from(2000000), + max_priority_fee_per_gas: U256::from(2000000), + gas_limit: U256::from(2000000), + gas_per_pubdata_limit: U256::from(3000000), + }; + request = request + .max_priority_fee_per_gas(fee.max_priority_fee_per_gas) + .max_fee_per_gas(fee.max_fee_per_gas) + .gas_limit(fee.gas_limit); + let signable_data: Eip712Transaction = request.clone().try_into().unwrap(); + //.map_err(|e: Eip712Error| ProviderError::CustomError(e.to_string())) + //.map_err(M::convert_err)?; + let signature: Signature = self + .l1_signer() + .signer() + .sign_typed_data(&signable_data) + .await + .unwrap(); + //.map_err(|e| ProviderError::CustomError(format!("error signing transaction: {e}"))) + //.map_err(M::convert_err)?; + request = request.custom_data(custom_data.custom_signature(signature.to_vec())); + let encoded_rlp = &*request.rlp_signed(signature).unwrap(); + //.map_err(|e| ProviderError::CustomError(format!("Error in the rlp encoding {e}"))) + //.map_err(M::convert_err)?; + l1_signer + .send_raw_transaction([&[EIP_712_TX_TYPE], encoded_rlp].concat().into()) + .await + .unwrap() + .await + .unwrap() + .unwrap() + } } From 745420b5cc2e49f21bd63c492a2873395731efb7 Mon Sep 17 00:00:00 2001 From: fborello-lambda Date: Fri, 13 Sep 2024 19:12:49 -0300 Subject: [PATCH 3/9] wip: add fixes --- rust-toolchain.toml | 2 +- src/zk_wallet.rs | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d56faf..74f46e1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly" +channel = "nightly-2024-09-06" diff --git a/src/zk_wallet.rs b/src/zk_wallet.rs index 0d89c1f..952d228 100644 --- a/src/zk_wallet.rs +++ b/src/zk_wallet.rs @@ -3,13 +3,14 @@ use ethers::{ abi::{Address, Hash}, + core::k256::ecdsa::signature::hazmat::PrehashSigner, middleware::SignerMiddleware, providers::{Middleware, Provider}, signers::Signer, types::{Signature, TransactionReceipt, U256}, }; use std::sync::Arc; -use zksync_types::{fee::Fee, EIP_712_TX_TYPE, L2_BASE_TOKEN_ADDRESS}; +use zksync_types::{EIP_712_TX_TYPE, L2_BASE_TOKEN_ADDRESS}; use crate::{ deposit, @@ -525,7 +526,6 @@ where ) -> TransactionReceipt { let mut request: Eip712TransactionRequest = transaction; let gas_price = self.l2_provider().get_gas_price().await.unwrap(); - let l1_signer = self.l1_signer(); request = request .from(self.l2_address()) .chain_id(self.l2_provider().get_chainid().await.unwrap()) @@ -539,27 +539,28 @@ where .max_fee_per_gas(gas_price); let custom_data = request.clone().custom_data; - // TODO: estimate_fee is not working - //let fee = self - // .l2_provider() - // .estimate_fee(request.clone()) - // .await - // .unwrap(); - let fee = Fee { - max_fee_per_gas: U256::from(2000000), - max_priority_fee_per_gas: U256::from(2000000), - gas_limit: U256::from(2000000), - gas_per_pubdata_limit: U256::from(3000000), - }; + let fee = self + .l2_provider() + .estimate_fee(request.clone()) + .await + .unwrap(); request = request .max_priority_fee_per_gas(fee.max_priority_fee_per_gas) - .max_fee_per_gas(fee.max_fee_per_gas) .gas_limit(fee.gas_limit); let signable_data: Eip712Transaction = request.clone().try_into().unwrap(); //.map_err(|e: Eip712Error| ProviderError::CustomError(e.to_string())) //.map_err(M::convert_err)?; + + //Before: + // + // pub struct Wallet> + // RecoverableSignature == pub type Signature = ecdsa_core::Signature + // + //let encoded = signable_data.encode_eip712().unwrap(); + //let signature = PrehashSigner::sign_prehash(&self.l2_signer.signer(), encoded).unwrap(); + let signature: Signature = self - .l1_signer() + .l2_signer() .signer() .sign_typed_data(&signable_data) .await @@ -570,7 +571,7 @@ where let encoded_rlp = &*request.rlp_signed(signature).unwrap(); //.map_err(|e| ProviderError::CustomError(format!("Error in the rlp encoding {e}"))) //.map_err(M::convert_err)?; - l1_signer + self.l2_provider() .send_raw_transaction([&[EIP_712_TX_TYPE], encoded_rlp].concat().into()) .await .unwrap() From adb9baaafa6bc47bedeef9f05154caa507d4dcc8 Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Thu, 19 Sep 2024 18:53:00 -0300 Subject: [PATCH 4/9] Fix deploy and handle errors --- src/deposit/mod.rs | 2 +- src/eip712/transaction_request.rs | 17 ++++---- src/zk_wallet.rs | 67 ++++++++++++++----------------- tests/common/mod.rs | 10 ++++- tests/deploy.rs | 25 ++++++++++++ 5 files changed, 73 insertions(+), 48 deletions(-) create mode 100644 tests/deploy.rs diff --git a/src/deposit/mod.rs b/src/deposit/mod.rs index 88dbf67..fc633cb 100644 --- a/src/deposit/mod.rs +++ b/src/deposit/mod.rs @@ -79,7 +79,7 @@ where // overrides. if allowance < amount { erc20 - .approve(l1_shared_bridge_address, amount * 2) + .approve(l1_shared_bridge_address, amount * 2_u8) .send() .await .unwrap() diff --git a/src/eip712/transaction_request.rs b/src/eip712/transaction_request.rs index 999c119..bf896af 100644 --- a/src/eip712/transaction_request.rs +++ b/src/eip712/transaction_request.rs @@ -308,14 +308,15 @@ impl TryFrom for Eip712TransactionRequest { let mut contract_deployer_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); contract_deployer_path.push("abi/ContractDeployer.json"); - let custom_data = Eip712Meta::new().factory_deps({ - let mut factory_deps = Vec::new(); - if let Some(factory_dependencies) = request.factory_deps { - factory_deps.extend(factory_dependencies); - } - factory_deps.push(request.contract_bytecode.clone()); - factory_deps - }); + let custom_data = Eip712Meta::new() + .factory_deps({ + let mut factory_deps = Vec::new(); + if let Some(factory_dependencies) = request.factory_deps { + factory_deps.extend(factory_dependencies); + } + factory_deps.push(request.contract_bytecode.clone()); + factory_deps + }); let contract_deployer = Abi::load(BufReader::new( File::open(contract_deployer_path).map_err(|e| { diff --git a/src/zk_wallet.rs b/src/zk_wallet.rs index 952d228..6aff923 100644 --- a/src/zk_wallet.rs +++ b/src/zk_wallet.rs @@ -3,7 +3,6 @@ use ethers::{ abi::{Address, Hash}, - core::k256::ecdsa::signature::hazmat::PrehashSigner, middleware::SignerMiddleware, providers::{Middleware, Provider}, signers::Signer, @@ -25,6 +24,8 @@ use crate::{ pub enum ZKWalletError { #[error("Provider error: {0}")] ProviderError(#[from] ethers::providers::ProviderError), + #[error("Deploy error: {0}")] + DeployError(String), } /// A ZKsync wallet @@ -38,10 +39,13 @@ where M: Middleware, S: Signer, { - pub fn new(l1_signer: SignerMiddleware, l2_signer: SignerMiddleware) -> Self { + pub fn new( + l1_signer: Arc>, + l2_signer: Arc>, + ) -> Self { Self { - l1_signer: Arc::new(l1_signer), - l2_signer: Arc::new(l2_signer), + l1_signer, + l2_signer, } } @@ -519,64 +523,53 @@ where .map_err(Into::into) } - //value: MiddlewareError(JsonRpcClientError(JsonRpcError(JsonRpcError { code: -32000, message: "transaction type not supported", data: None }))) pub async fn send_transaction_eip712( &self, transaction: Eip712TransactionRequest, - ) -> TransactionReceipt { + ) -> Result { let mut request: Eip712TransactionRequest = transaction; - let gas_price = self.l2_provider().get_gas_price().await.unwrap(); + let gas_price = self.l2_provider().get_gas_price().await?; request = request .from(self.l2_address()) .chain_id(self.l2_provider().get_chainid().await.unwrap()) .nonce( self.l2_provider() .get_transaction_count(self.l2_address(), None) - .await - .unwrap(), + .await?, ) .gas_price(gas_price) .max_fee_per_gas(gas_price); let custom_data = request.clone().custom_data; - let fee = self - .l2_provider() - .estimate_fee(request.clone()) - .await - .unwrap(); + let fee = self.l2_provider().estimate_fee(request.clone()).await?; request = request .max_priority_fee_per_gas(fee.max_priority_fee_per_gas) - .gas_limit(fee.gas_limit); - let signable_data: Eip712Transaction = request.clone().try_into().unwrap(); - //.map_err(|e: Eip712Error| ProviderError::CustomError(e.to_string())) - //.map_err(M::convert_err)?; - - //Before: - // - // pub struct Wallet> - // RecoverableSignature == pub type Signature = ecdsa_core::Signature - // - //let encoded = signable_data.encode_eip712().unwrap(); - //let signature = PrehashSigner::sign_prehash(&self.l2_signer.signer(), encoded).unwrap(); + .gas_limit(fee.gas_limit) + .max_fee_per_gas(fee.max_fee_per_gas); + let signable_data: Eip712Transaction = request.clone().try_into().map_err(|e| { + ZKWalletError::DeployError(format!("error converting deploy to eip 712 {e}")) + })?; let signature: Signature = self .l2_signer() .signer() .sign_typed_data(&signable_data) .await - .unwrap(); - //.map_err(|e| ProviderError::CustomError(format!("error signing transaction: {e}"))) - //.map_err(M::convert_err)?; + .map_err(|e| { + ZKWalletError::DeployError(format!("error signing deploy transaction: {e}")) + })?; + request = request.custom_data(custom_data.custom_signature(signature.to_vec())); - let encoded_rlp = &*request.rlp_signed(signature).unwrap(); - //.map_err(|e| ProviderError::CustomError(format!("Error in the rlp encoding {e}"))) - //.map_err(M::convert_err)?; + let encoded_rlp = &*request + .rlp_signed(signature) + .map_err(|e| ZKWalletError::DeployError(format!("Error in the rlp encoding {e}")))?; + self.l2_provider() .send_raw_transaction([&[EIP_712_TX_TYPE], encoded_rlp].concat().into()) - .await - .unwrap() - .await - .unwrap() - .unwrap() + .await? + .await? + .ok_or(ZKWalletError::DeployError( + "Error sending the deploy transaction".to_string(), + )) } } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 919e19c..047e3fe 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,11 +1,11 @@ use std::{str::FromStr, sync::Arc}; use ethers::{ - abi::{Address, Hash}, + abi::{Abi, Address, Hash}, prelude::SignerMiddleware, providers::{Http, Middleware, Provider, ProviderExt}, signers::{LocalWallet, Signer}, - types::{U256, U64}, + types::{Bytes, U256, U64}, }; use zksync_ethers_rs::{ utils::{L1_ETH_TOKEN_ADDRESS, L2_ETH_TOKEN_ADDRESS}, @@ -17,6 +17,12 @@ pub const L2_EXPLORER_URL: &str = "http://127.0.0.1:3010"; pub const L1_EXPLORER_URL: &str = ""; pub const L1_RPC_URL: &str = "http://127.0.0.1:8545"; +#[derive(Debug, serde::Deserialize)] +pub struct CompiledContract { + pub abi: Abi, + pub bin: Bytes, +} + pub fn l1_explorer_url() -> String { std::env::var("L1_EXPLORER_URL").unwrap_or(L1_EXPLORER_URL.to_owned()) } diff --git a/tests/deploy.rs b/tests/deploy.rs new file mode 100644 index 0000000..3944528 --- /dev/null +++ b/tests/deploy.rs @@ -0,0 +1,25 @@ +use std::{fs::File, path::PathBuf}; + +use common::{ + l1_signer, l2_signer, CompiledContract, +}; +use zksync_ethers_rs::{ + eip712::{DeployRequest, Eip712TransactionRequest}, + zk_wallet::ZKWallet, +}; +mod common; + +#[tokio::test] +async fn test_deploy() { + let zk_wallet = ZKWallet::new(l1_signer().await, l2_signer().await); + let mut contract_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + contract_path.push("abi/test_contracts/storage_combined.json"); + let contract: CompiledContract = + serde_json::from_reader(File::open(contract_path).unwrap()).unwrap(); + let deploy_request = + DeployRequest::with(contract.abi, contract.bin.to_vec(), vec!["10".to_owned()]) + .from(zk_wallet.l2_address()); + let tx_request: Eip712TransactionRequest = deploy_request.clone().try_into().unwrap(); + let tx_result = zk_wallet.send_transaction_eip712(tx_request).await; + assert!(tx_result.is_ok()); +} From 7fe59015af99fbdab9ef37b5c06d5426f08ef8bd Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Thu, 19 Sep 2024 18:55:23 -0300 Subject: [PATCH 5/9] Remove allow unwrap for zk wallet --- src/zk_wallet.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/zk_wallet.rs b/src/zk_wallet.rs index 6aff923..8e69bf1 100644 --- a/src/zk_wallet.rs +++ b/src/zk_wallet.rs @@ -1,6 +1,3 @@ -// FIXME: Remove this after finishing the implementation. -#![allow(clippy::unwrap_used)] - use ethers::{ abi::{Address, Hash}, middleware::SignerMiddleware, @@ -531,7 +528,7 @@ where let gas_price = self.l2_provider().get_gas_price().await?; request = request .from(self.l2_address()) - .chain_id(self.l2_provider().get_chainid().await.unwrap()) + .chain_id(self.l2_provider().get_chainid().await?) .nonce( self.l2_provider() .get_transaction_count(self.l2_address(), None) From 514437208ae511ac2e62d858698b65d687d774df Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Thu, 19 Sep 2024 19:00:27 -0300 Subject: [PATCH 6/9] Rename error for sending eip712 transaction --- src/zk_wallet.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zk_wallet.rs b/src/zk_wallet.rs index 8e69bf1..e2cf6e2 100644 --- a/src/zk_wallet.rs +++ b/src/zk_wallet.rs @@ -22,7 +22,7 @@ pub enum ZKWalletError { #[error("Provider error: {0}")] ProviderError(#[from] ethers::providers::ProviderError), #[error("Deploy error: {0}")] - DeployError(String), + SendEIP712(String), } /// A ZKsync wallet @@ -544,7 +544,7 @@ where .gas_limit(fee.gas_limit) .max_fee_per_gas(fee.max_fee_per_gas); let signable_data: Eip712Transaction = request.clone().try_into().map_err(|e| { - ZKWalletError::DeployError(format!("error converting deploy to eip 712 {e}")) + ZKWalletError::SendEIP712(format!("error converting deploy to eip 712 {e}")) })?; let signature: Signature = self @@ -553,19 +553,19 @@ where .sign_typed_data(&signable_data) .await .map_err(|e| { - ZKWalletError::DeployError(format!("error signing deploy transaction: {e}")) + ZKWalletError::SendEIP712(format!("error signing deploy transaction: {e}")) })?; request = request.custom_data(custom_data.custom_signature(signature.to_vec())); let encoded_rlp = &*request .rlp_signed(signature) - .map_err(|e| ZKWalletError::DeployError(format!("Error in the rlp encoding {e}")))?; + .map_err(|e| ZKWalletError::SendEIP712(format!("Error in the rlp encoding {e}")))?; self.l2_provider() .send_raw_transaction([&[EIP_712_TX_TYPE], encoded_rlp].concat().into()) .await? .await? - .ok_or(ZKWalletError::DeployError( + .ok_or(ZKWalletError::SendEIP712( "Error sending the deploy transaction".to_string(), )) } From 3ad4a82e81dc0213995f1472934c6384a8c5b005 Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Thu, 19 Sep 2024 19:00:42 -0300 Subject: [PATCH 7/9] Remove send eip712 from middleware --- src/zk_middleware.rs | 91 -------------------------------------------- 1 file changed, 91 deletions(-) diff --git a/src/zk_middleware.rs b/src/zk_middleware.rs index 6d79ae9..c67ae0a 100644 --- a/src/zk_middleware.rs +++ b/src/zk_middleware.rs @@ -220,17 +220,6 @@ pub trait ZKMiddleware { tx: Bytes, ) -> Result; - async fn send_eip712( - &self, - wallet: &Wallet, - contract_address: Address, - function_signature: &str, - function_parameters: Option>, - overrides: Option, - ) -> Result, Self::Error> - where - D: PrehashSigner<(RecoverableSignature, RecoveryId)> + Send + Sync; - async fn send( &self, wallet: &Wallet, @@ -631,86 +620,6 @@ where .await } - async fn send_eip712( - &self, - wallet: &Wallet, - contract_address: Address, - function_signature: &str, - function_parameters: Option>, - overrides: Option, - ) -> Result, Self::Error> - where - D: PrehashSigner<(RecoverableSignature, RecoveryId)> + Send + Sync, - { - // Note: We couldn't implement Self::Error::LexerError because ethers-rs's LexerError is not exposed. - // TODO check for ECADD precompile address to get the function signature. - let function = HumanReadableParser::parse_function(function_signature) - .map_err(|e| ProviderError::CustomError(e.to_string())) - .map_err(M::convert_err)?; - - let mut send_request = if let Some(overrides) = overrides { - Eip712TransactionRequest::from_overrides(overrides) - } else { - Eip712TransactionRequest::new() - }; - - let function_args = if let Some(function_args) = function_parameters { - function - .decode_input( - &utils::encode_args(&function, &function_args) - .map_err(|e| ProviderError::CustomError(e.to_string())) - .map_err(M::convert_err)?, - ) - .map_err(|e| ProviderError::CustomError(e.to_string())) - .map_err(M::convert_err)? - } else { - vec![] - }; - - send_request = send_request - .r#type(EIP_712_TX_TYPE) - .from(wallet.address()) - .to(contract_address) - .chain_id(wallet.chain_id()) - .nonce(self.get_transaction_count(wallet.address(), None).await?) - .gas_price(self.get_gas_price().await?) - .max_fee_per_gas(self.get_gas_price().await?) - .data(if !function_args.is_empty() { - function - .encode_input(&function_args) - .map_err(|e| ProviderError::CustomError(e.to_string())) - .map_err(M::convert_err)? - } else { - function.short_signature().into() - }); - - let fee = self.estimate_fee(send_request.clone()).await?; - send_request = send_request - .max_priority_fee_per_gas(fee.max_priority_fee_per_gas) - .max_fee_per_gas(fee.max_fee_per_gas) - .gas_limit(fee.gas_limit); - - let signable_data: Eip712Transaction = send_request - .clone() - .try_into() - .map_err(|e: Eip712Error| ProviderError::CustomError(e.to_string())) - .map_err(M::convert_err)?; - let signature: Signature = wallet - .sign_typed_data(&signable_data) - .await - .map_err(|e| ProviderError::CustomError(format!("error signing transaction: {e}"))) - .map_err(M::convert_err)?; - send_request = - send_request.custom_data(Eip712Meta::new().custom_signature(signature.to_vec())); - - let encoded_rlp = &*send_request - .rlp_signed(signature) - .map_err(|e| ProviderError::CustomError(format!("error encoding transaction: {e}"))) - .map_err(M::convert_err)?; - self.send_raw_transaction([&[EIP_712_TX_TYPE], encoded_rlp].concat().into()) - .await - } - async fn send( &self, wallet: &Wallet, From a1dbfa3cc50f47457ecb7c600af891fc918f5200 Mon Sep 17 00:00:00 2001 From: fborello-lambda Date: Fri, 20 Sep 2024 15:04:51 -0300 Subject: [PATCH 8/9] wip: investigate how to set gas_per_pubdata dynamically --- src/eip712/transaction_request.rs | 3 ++- src/zk_middleware.rs | 2 +- src/zk_wallet.rs | 13 +++++++------ tests/common/mod.rs | 2 +- tests/deploy.rs | 9 ++++++--- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/eip712/transaction_request.rs b/src/eip712/transaction_request.rs index bf896af..546f87f 100644 --- a/src/eip712/transaction_request.rs +++ b/src/eip712/transaction_request.rs @@ -316,7 +316,8 @@ impl TryFrom for Eip712TransactionRequest { } factory_deps.push(request.contract_bytecode.clone()); factory_deps - }); + }) + .gas_per_pubdata(U256::from(50000_u32)); let contract_deployer = Abi::load(BufReader::new( File::open(contract_deployer_path).map_err(|e| { diff --git a/src/zk_middleware.rs b/src/zk_middleware.rs index c67ae0a..1d153aa 100644 --- a/src/zk_middleware.rs +++ b/src/zk_middleware.rs @@ -31,7 +31,7 @@ use ethers::{ }; use crate::{ - eip712::{Eip712Meta, Eip712Transaction, Eip712TransactionRequest}, + eip712::{Eip712Transaction, Eip712TransactionRequest}, types::L1TxOverrides, utils, }; diff --git a/src/zk_wallet.rs b/src/zk_wallet.rs index e2cf6e2..6494ce9 100644 --- a/src/zk_wallet.rs +++ b/src/zk_wallet.rs @@ -525,7 +525,7 @@ where transaction: Eip712TransactionRequest, ) -> Result { let mut request: Eip712TransactionRequest = transaction; - let gas_price = self.l2_provider().get_gas_price().await?; + request = request .from(self.l2_address()) .chain_id(self.l2_provider().get_chainid().await?) @@ -533,16 +533,17 @@ where self.l2_provider() .get_transaction_count(self.l2_address(), None) .await?, - ) - .gas_price(gas_price) - .max_fee_per_gas(gas_price); + ); let custom_data = request.clone().custom_data; let fee = self.l2_provider().estimate_fee(request.clone()).await?; + let gas = self.l2_provider().zk_estimate_gas(request.clone()).await?; + let gas_price = self.l2_provider().get_gas_price().await?; request = request .max_priority_fee_per_gas(fee.max_priority_fee_per_gas) - .gas_limit(fee.gas_limit) - .max_fee_per_gas(fee.max_fee_per_gas); + .gas_limit(gas) + .max_fee_per_gas(fee.max_fee_per_gas) + .gas_price(gas_price); let signable_data: Eip712Transaction = request.clone().try_into().map_err(|e| { ZKWalletError::SendEIP712(format!("error converting deploy to eip 712 {e}")) })?; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 047e3fe..9b993c0 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -46,7 +46,7 @@ pub async fn signer( Arc::new(SignerMiddleware::, LocalWallet>::new( provider, LocalWallet::from_str(&std::env::var("PRIVATE_KEY").unwrap_or( - "0x385c546456b6a603a1cfcaa9ec9494ba4832da08dd6bcf4de9a71e4a01b74924".to_owned(), + "0x850683b40d4a740aa6e745f889a6fdc8327be76e122f5aba645a5b02d0248db8".to_owned(), )) .unwrap() .with_chain_id(chain_id), diff --git a/tests/deploy.rs b/tests/deploy.rs index 3944528..0f76168 100644 --- a/tests/deploy.rs +++ b/tests/deploy.rs @@ -1,8 +1,7 @@ use std::{fs::File, path::PathBuf}; -use common::{ - l1_signer, l2_signer, CompiledContract, -}; +use common::{l1_signer, l2_signer, CompiledContract}; +use ethers::utils::parse_ether; use zksync_ethers_rs::{ eip712::{DeployRequest, Eip712TransactionRequest}, zk_wallet::ZKWallet, @@ -12,6 +11,10 @@ mod common; #[tokio::test] async fn test_deploy() { let zk_wallet = ZKWallet::new(l1_signer().await, l2_signer().await); + zk_wallet + .deposit_base_token(parse_ether("10").unwrap()) + .await + .unwrap(); let mut contract_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); contract_path.push("abi/test_contracts/storage_combined.json"); let contract: CompiledContract = From 1356be6b55c817924a835410cf4f30721288ebb3 Mon Sep 17 00:00:00 2001 From: fborello-lambda Date: Fri, 20 Sep 2024 17:08:30 -0300 Subject: [PATCH 9/9] add todo comment --- src/eip712/transaction_request.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eip712/transaction_request.rs b/src/eip712/transaction_request.rs index 546f87f..616e569 100644 --- a/src/eip712/transaction_request.rs +++ b/src/eip712/transaction_request.rs @@ -317,6 +317,8 @@ impl TryFrom for Eip712TransactionRequest { factory_deps.push(request.contract_bytecode.clone()); factory_deps }) + // TODO CHECK THIS GAS_PER_PUBDATA + // IT IS NEEDED TO COMPLETE THE TX, but is not set dynamically .gas_per_pubdata(U256::from(50000_u32)); let contract_deployer = Abi::load(BufReader::new(