diff --git a/.env.test b/.env.test index adb5e43f..4fdaae38 100644 --- a/.env.test +++ b/.env.test @@ -30,5 +30,5 @@ MONGODB_CONNECTION_STRING="mongodb://localhost:27017" # Ethereum Settlement DEFAULT_SETTLEMENT_CLIENT_RPC="http://localhost:3000" DEFAULT_L1_CORE_CONTRACT_ADDRESS="0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4" -TEST_IMPERSONATE_OPERATOR=0 +TEST_IMPERSONATE_OPERATOR="1" TEST_DUMMY_CONTRACT_ADDRESS="0xE5b6F5e695BA6E4aeD92B68c4CC8Df1160D69A81" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index bd538040..973fa262 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,28 +87,28 @@ dependencies = [ [[package]] name = "alloy" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9134b68e24175eff6c3c4d2bffeefb0a1b7435462130862c88d1524ca376e7e5" +checksum = "3f4a4aaae80afd4be443a6aecd92a6b255dcdd000f97996928efb33d8a71e100" dependencies = [ - "alloy-consensus 0.1.2", + "alloy-consensus 0.2.1", "alloy-contract", - "alloy-core 0.7.6", - "alloy-eips 0.1.2", + "alloy-core 0.7.7", + "alloy-eips 0.2.1", "alloy-genesis", - "alloy-network 0.1.2", - "alloy-provider 0.1.2", + "alloy-network 0.2.1", + "alloy-node-bindings", + "alloy-provider 0.2.1", "alloy-pubsub", - "alloy-rpc-client 0.1.2", - "alloy-rpc-types 0.1.2", - "alloy-serde 0.1.2", - "alloy-signer 0.1.2", + "alloy-rpc-client 0.2.1", + "alloy-rpc-types 0.2.1", + "alloy-serde 0.2.1", + "alloy-signer 0.2.1", "alloy-signer-local", - "alloy-transport 0.1.2", - "alloy-transport-http 0.1.2", + "alloy-transport 0.2.1", + "alloy-transport-http 0.2.1", "alloy-transport-ipc", "alloy-transport-ws", - "reqwest 0.12.5", ] [[package]] @@ -134,33 +134,34 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a016bfa21193744d4c38b3f3ab845462284d129e5e23c7cc0fafca7e92d9db37" +checksum = "04c309895995eaa4bfcc345f5515a39c7df9447798645cc8bf462b6c5bf1dc96" dependencies = [ - "alloy-eips 0.1.2", - "alloy-primitives 0.7.6", + "alloy-eips 0.2.1", + "alloy-primitives 0.7.7", "alloy-rlp", - "alloy-serde 0.1.2", + "alloy-serde 0.2.1", "c-kzg", "serde", ] [[package]] name = "alloy-contract" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e47b2a620fd588d463ccf0f5931b41357664b293a8d31592768845a2a101bb9e" +checksum = "3f4e0ef72b0876ae3068b2ed7dfae9ae1779ce13cfaec2ee1f08f5bd0348dc57" dependencies = [ - "alloy-dyn-abi 0.7.6", - "alloy-json-abi 0.7.6", - "alloy-network 0.1.2", - "alloy-primitives 0.7.6", - "alloy-provider 0.1.2", + "alloy-dyn-abi 0.7.7", + "alloy-json-abi 0.7.7", + "alloy-network 0.2.1", + "alloy-network-primitives", + "alloy-primitives 0.7.7", + "alloy-provider 0.2.1", "alloy-pubsub", "alloy-rpc-types-eth", - "alloy-sol-types 0.7.6", - "alloy-transport 0.1.2", + "alloy-sol-types 0.7.7", + "alloy-transport 0.2.1", "futures", "futures-util", "thiserror", @@ -180,14 +181,14 @@ dependencies = [ [[package]] name = "alloy-core" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5af3faff14c12c8b11037e0a093dd157c3702becb8435577a2408534d0758315" +checksum = "529fc6310dc1126c8de51c376cbc59c79c7f662bd742be7dc67055d5421a81b4" dependencies = [ - "alloy-dyn-abi 0.7.6", - "alloy-json-abi 0.7.6", - "alloy-primitives 0.7.6", - "alloy-sol-types 0.7.6", + "alloy-dyn-abi 0.7.7", + "alloy-json-abi 0.7.7", + "alloy-primitives 0.7.7", + "alloy-sol-types 0.7.7", ] [[package]] @@ -209,14 +210,14 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6e6436a9530f25010d13653e206fab4c9feddacf21a54de8d7311b275bc56b" +checksum = "413902aa18a97569e60f679c23f46a18db1656d87ab4d4e49d0e1e52042f66df" dependencies = [ - "alloy-json-abi 0.7.6", - "alloy-primitives 0.7.6", - "alloy-sol-type-parser 0.7.6", - "alloy-sol-types 0.7.6", + "alloy-json-abi 0.7.7", + "alloy-primitives 0.7.7", + "alloy-sol-type-parser 0.7.7", + "alloy-sol-types 0.7.7", "const-hex", "itoa", "serde", @@ -239,15 +240,16 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d6d8118b83b0489cfb7e6435106948add2b35217f4a5004ef895f613f60299" +checksum = "d9431c99a3b3fe606ede4b3d4043bdfbcb780c45b8d8d226c3804e2b75cfbe68" dependencies = [ - "alloy-primitives 0.7.6", + "alloy-primitives 0.7.7", "alloy-rlp", - "alloy-serde 0.1.2", + "alloy-serde 0.2.1", "c-kzg", "derive_more", + "k256", "once_cell", "serde", "sha2", @@ -255,12 +257,12 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "894f33a7822abb018db56b10ab90398e63273ce1b5a33282afd186c132d764a6" +checksum = "79614dfe86144328da11098edcc7bc1a3f25ad8d3134a9eb9e857e06f0d9840d" dependencies = [ - "alloy-primitives 0.7.6", - "alloy-serde 0.1.2", + "alloy-primitives 0.7.7", + "alloy-serde 0.2.1", "serde", ] @@ -278,12 +280,12 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" +checksum = "bc05b04ac331a9f07e3a4036ef7926e49a8bf84a99a1ccfc7e2ab55a5fcbb372" dependencies = [ - "alloy-primitives 0.7.6", - "alloy-sol-type-parser 0.7.6", + "alloy-primitives 0.7.7", + "alloy-sol-type-parser 0.7.7", "serde", "serde_json", ] @@ -301,11 +303,12 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61f0ae6e93b885cc70fe8dae449e7fd629751dbee8f59767eaaa7285333c5727" +checksum = "57e2865c4c3bb4cdad3f0d9ec1ab5c0c657ba69a375651bd35e32fb6c180ccc2" dependencies = [ - "alloy-primitives 0.7.6", + "alloy-primitives 0.7.7", + "alloy-sol-types 0.7.7", "serde", "serde_json", "thiserror", @@ -331,24 +334,52 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc122cbee2b8523854cc11d87bcd5773741602c553d2d2d106d82eeb9c16924a" +checksum = "6e701fc87ef9a3139154b0b4ccb935b565d27ffd9de020fe541bf2dec5ae4ede" dependencies = [ - "alloy-consensus 0.1.2", - "alloy-eips 0.1.2", - "alloy-json-rpc 0.1.2", - "alloy-primitives 0.7.6", + "alloy-consensus 0.2.1", + "alloy-eips 0.2.1", + "alloy-json-rpc 0.2.1", + "alloy-network-primitives", + "alloy-primitives 0.7.7", "alloy-rpc-types-eth", - "alloy-serde 0.1.2", - "alloy-signer 0.1.2", - "alloy-sol-types 0.7.6", + "alloy-serde 0.2.1", + "alloy-signer 0.2.1", + "alloy-sol-types 0.7.7", "async-trait", "auto_impl", "futures-utils-wasm", "thiserror", ] +[[package]] +name = "alloy-network-primitives" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec9d5a0f9170b10988b6774498a022845e13eda94318440d17709d50687f67f9" +dependencies = [ + "alloy-primitives 0.7.7", + "alloy-serde 0.2.1", + "serde", +] + +[[package]] +name = "alloy-node-bindings" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16faebb9ea31a244fd6ce3288d47df4be96797d9c3c020144b8f2c31543a4512" +dependencies = [ + "alloy-genesis", + "alloy-primitives 0.7.7", + "k256", + "serde_json", + "tempfile", + "thiserror", + "tracing", + "url", +] + [[package]] name = "alloy-primitives" version = "0.6.4" @@ -373,9 +404,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" +checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" dependencies = [ "alloy-rlp", "bytes", @@ -420,21 +451,25 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d5af289798fe8783acd0c5f10644d9d26f54a12bc52a083e4f3b31718e9bf92" +checksum = "3f9c0ab10b93de601a6396fc7ff2ea10d3b28c46f079338fa562107ebf9857c8" dependencies = [ "alloy-chains", - "alloy-consensus 0.1.2", - "alloy-eips 0.1.2", - "alloy-json-rpc 0.1.2", - "alloy-network 0.1.2", - "alloy-primitives 0.7.6", + "alloy-consensus 0.2.1", + "alloy-eips 0.2.1", + "alloy-json-rpc 0.2.1", + "alloy-network 0.2.1", + "alloy-network-primitives", + "alloy-node-bindings", + "alloy-primitives 0.7.7", "alloy-pubsub", - "alloy-rpc-client 0.1.2", + "alloy-rpc-client 0.2.1", + "alloy-rpc-types-anvil", "alloy-rpc-types-eth", - "alloy-transport 0.1.2", - "alloy-transport-http 0.1.2", + "alloy-signer-local", + "alloy-transport 0.2.1", + "alloy-transport-http 0.2.1", "alloy-transport-ipc", "alloy-transport-ws", "async-stream", @@ -455,13 +490,13 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702f330b7da123a71465ab9d39616292f8344a2811c28f2cc8d8438a69d79e35" +checksum = "3f5da2c55cbaf229bad3c5f8b00b5ab66c74ef093e5f3a753d874cfecf7d2281" dependencies = [ - "alloy-json-rpc 0.1.2", - "alloy-primitives 0.7.6", - "alloy-transport 0.1.2", + "alloy-json-rpc 0.2.1", + "alloy-primitives 0.7.7", + "alloy-transport 0.2.1", "bimap", "futures", "serde", @@ -516,15 +551,15 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40fcb53b2a9d0a78a4968b2eca8805a4b7011b9ee3fdfa2acaf137c5128f36b" +checksum = "5b38e3ffdb285df5d9f60cb988d336d9b8e3505acb78750c3bc60336a7af41d3" dependencies = [ - "alloy-json-rpc 0.1.2", - "alloy-primitives 0.7.6", + "alloy-json-rpc 0.2.1", + "alloy-primitives 0.7.7", "alloy-pubsub", - "alloy-transport 0.1.2", - "alloy-transport-http 0.1.2", + "alloy-transport 0.2.1", + "alloy-transport-http 0.2.1", "alloy-transport-ipc", "alloy-transport-ws", "futures", @@ -569,27 +604,39 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f2fbe956a3e0f0975c798f488dc6be96b669544df3737e18f4a325b42f4c86" +checksum = "e6c31a3750b8f5a350d17354e46a52b0f2f19ec5f2006d816935af599dedc521" dependencies = [ "alloy-rpc-types-engine", "alloy-rpc-types-eth", - "alloy-serde 0.1.2", + "alloy-serde 0.2.1", + "serde", +] + +[[package]] +name = "alloy-rpc-types-anvil" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ab6509cd38b2e8c8da726e0f61c1e314a81df06a38d37ddec8bced3f8d25ed" +dependencies = [ + "alloy-primitives 0.7.7", + "alloy-serde 0.2.1", + "serde", ] [[package]] name = "alloy-rpc-types-engine" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd473d98ec552f8229cd6d566bd2b0bbfc5bb4efcefbb5288c834aa8fd832020" +checksum = "ff63f51b2fb2f547df5218527fd0653afb1947bf7fead5b3ce58c75d170b30f7" dependencies = [ - "alloy-consensus 0.1.2", - "alloy-eips 0.1.2", - "alloy-primitives 0.7.6", + "alloy-consensus 0.2.1", + "alloy-eips 0.2.1", + "alloy-primitives 0.7.7", "alloy-rlp", "alloy-rpc-types-eth", - "alloy-serde 0.1.2", + "alloy-serde 0.2.1", "jsonwebtoken", "rand", "serde", @@ -598,16 +645,17 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "083f443a83b9313373817236a8f4bea09cca862618e9177d822aee579640a5d6" +checksum = "81e18424d962d7700a882fe423714bd5b9dde74c7a7589d4255ea64068773aef" dependencies = [ - "alloy-consensus 0.1.2", - "alloy-eips 0.1.2", - "alloy-primitives 0.7.6", + "alloy-consensus 0.2.1", + "alloy-eips 0.2.1", + "alloy-network-primitives", + "alloy-primitives 0.7.7", "alloy-rlp", - "alloy-serde 0.1.2", - "alloy-sol-types 0.7.6", + "alloy-serde 0.2.1", + "alloy-sol-types 0.7.7", "itertools 0.13.0", "serde", "serde_json", @@ -626,11 +674,11 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d94da1c0c4e27cc344b05626fe22a89dc6b8b531b9475f3b7691dbf6913e4109" +checksum = "e33feda6a53e6079895aed1d08dcb98a1377b000d80d16370fbbdb8155d547ef" dependencies = [ - "alloy-primitives 0.7.6", + "alloy-primitives 0.7.7", "serde", "serde_json", ] @@ -650,11 +698,11 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58d876be3afd8b78979540084ff63995292a26aa527ad0d44276405780aa0ffd" +checksum = "740a25b92e849ed7b0fa013951fe2f64be9af1ad5abe805037b44fb7770c5c47" dependencies = [ - "alloy-primitives 0.7.6", + "alloy-primitives 0.7.7", "async-trait", "auto_impl", "elliptic-curve 0.13.8", @@ -664,14 +712,14 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40a37dc216c269b8a7244047cb1c18a9c69f7a0332ab2c4c2aa4cbb1a31468b" +checksum = "1b0707d4f63e4356a110b30ef3add8732ab6d181dd7be4607bf79b8777105cee" dependencies = [ - "alloy-consensus 0.1.2", - "alloy-network 0.1.2", - "alloy-primitives 0.7.6", - "alloy-signer 0.1.2", + "alloy-consensus 0.2.1", + "alloy-network 0.2.1", + "alloy-primitives 0.7.7", + "alloy-signer 0.2.1", "async-trait", "k256", "rand", @@ -713,9 +761,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" +checksum = "2b40397ddcdcc266f59f959770f601ce1280e699a91fc1862f29cef91707cd09" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -727,11 +775,11 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" +checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" dependencies = [ - "alloy-json-abi 0.7.6", + "alloy-json-abi 0.7.7", "alloy-sol-macro-input", "const-hex", "heck 0.5.0", @@ -740,17 +788,17 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.66", - "syn-solidity 0.7.6", + "syn-solidity 0.7.7", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" +checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" dependencies = [ - "alloy-json-abi 0.7.6", + "alloy-json-abi 0.7.7", "const-hex", "dunce", "heck 0.5.0", @@ -758,7 +806,7 @@ dependencies = [ "quote", "serde_json", "syn 2.0.66", - "syn-solidity 0.7.6", + "syn-solidity 0.7.7", ] [[package]] @@ -772,10 +820,11 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" +checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" dependencies = [ + "serde", "winnow 0.6.13", ] @@ -793,13 +842,13 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" +checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" dependencies = [ - "alloy-json-abi 0.7.6", - "alloy-primitives 0.7.6", - "alloy-sol-macro 0.7.6", + "alloy-json-abi 0.7.7", + "alloy-primitives 0.7.7", + "alloy-sol-macro 0.7.7", "const-hex", "serde", ] @@ -824,11 +873,11 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245af9541f0a0dbd5258669c80dfe3af118164cacec978a520041fc130550deb" +checksum = "3d0590afbdacf2f8cca49d025a2466f3b6584a016a8b28f532f29f8da1007bae" dependencies = [ - "alloy-json-rpc 0.1.2", + "alloy-json-rpc 0.2.1", "base64 0.22.1", "futures-util", "futures-utils-wasm", @@ -837,6 +886,7 @@ dependencies = [ "thiserror", "tokio", "tower", + "tracing", "url", ] @@ -855,12 +905,12 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5619c017e1fdaa1db87f9182f4f0ed97c53d674957f4902fba655e972d359c6c" +checksum = "2437d145d80ea1aecde8574d2058cceb8b3c9cba05f6aea8e67907c660d46698" dependencies = [ - "alloy-json-rpc 0.1.2", - "alloy-transport 0.1.2", + "alloy-json-rpc 0.2.1", + "alloy-transport 0.2.1", "reqwest 0.12.5", "serde_json", "tower", @@ -870,13 +920,13 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173cefa110afac7a53cf2e75519327761f2344d305eea2993f3af1b2c1fc1c44" +checksum = "804494366e20468776db4e18f9eb5db7db0fe14f1271eb6dbf155d867233405c" dependencies = [ - "alloy-json-rpc 0.1.2", + "alloy-json-rpc 0.2.1", "alloy-pubsub", - "alloy-transport 0.1.2", + "alloy-transport 0.2.1", "bytes", "futures", "interprocess", @@ -889,12 +939,12 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.1.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c0aff8af5be5e58856c5cdd1e46db2c67c7ecd3a652d9100b4822c96c899947" +checksum = "af855163e7df008799941aa6dd324a43ef2bf264b08ba4b22d44aad6ced65300" dependencies = [ "alloy-pubsub", - "alloy-transport 0.1.2", + "alloy-transport 0.2.1", "futures", "http 1.1.0", "rustls 0.23.10", @@ -4079,11 +4129,14 @@ dependencies = [ name = "ethereum-settlement-client" version = "0.1.0" dependencies = [ - "alloy 0.1.2", + "alloy 0.2.1", + "alloy-primitives 0.7.7", "async-trait", "c-kzg", "color-eyre", "dotenv", + "dotenvy", + "lazy_static", "mockall 0.12.1", "reqwest 0.12.5", "rstest 0.18.2", @@ -4620,7 +4673,7 @@ dependencies = [ name = "gps-fact-checker" version = "0.1.0" dependencies = [ - "alloy 0.1.2", + "alloy 0.2.1", "async-trait", "cairo-vm 1.0.0-rc3", "itertools 0.13.0", @@ -6314,7 +6367,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" name = "orchestrator" version = "0.1.0" dependencies = [ - "alloy 0.1.2", + "alloy 0.2.1", "arc-swap", "assert_matches", "async-std", @@ -8283,7 +8336,7 @@ dependencies = [ name = "sharp-service" version = "0.1.0" dependencies = [ - "alloy 0.1.2", + "alloy 0.2.1", "async-trait", "cairo-vm 1.0.0-rc3", "gps-fact-checker", @@ -8954,9 +9007,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" +checksum = "c837dc8852cb7074e46b444afb81783140dab12c58867b49fb3898fbafedf7ea" dependencies = [ "paste", "proc-macro2", diff --git a/crates/settlement-clients/ethereum/Cargo.toml b/crates/settlement-clients/ethereum/Cargo.toml index d885e979..a6f2155b 100644 --- a/crates/settlement-clients/ethereum/Cargo.toml +++ b/crates/settlement-clients/ethereum/Cargo.toml @@ -7,6 +7,7 @@ edition.workspace = true alloy = { workspace = true, features = ["full", "node-bindings" ] } alloy-primitives = { version = "0.7.7", default-features = false } async-trait = { workspace = true } +lazy_static = "1.4.0" c-kzg = "1.0.0" color-eyre = { workspace = true } dotenv = "0.15" diff --git a/crates/settlement-clients/ethereum/src/lib.rs b/crates/settlement-clients/ethereum/src/lib.rs index eeee49c8..d920152f 100644 --- a/crates/settlement-clients/ethereum/src/lib.rs +++ b/crates/settlement-clients/ethereum/src/lib.rs @@ -39,6 +39,15 @@ use crate::conversion::{slice_slice_u8_to_vec_u256, slice_u8_to_u256}; pub mod clients; pub mod config; pub mod conversion; + +#[cfg(test)] +lazy_static! { + static ref SHOULD_IMPERSONATE_ACCOUNT: bool = get_env_var_or_panic("TEST_IMPERSONATE_OPERATOR") == "1".to_string(); + static ref TEST_DUMMY_CONTRACT_ADDRESS: String = get_env_var_or_panic("TEST_DUMMY_CONTRACT_ADDRESS"); + static ref ADDRESS_TO_IMPERSONATE: Address = Address::from_str("0x2C169DFe5fBbA12957Bdd0Ba47d9CEDbFE260CA7").expect("Unable to parse address"); + static ref TEST_NONCE: u64 = 666068; +} + #[cfg(test)] mod tests; pub mod types; @@ -104,14 +113,14 @@ impl EthereumSettlementClient { ProviderBuilder::new().with_recommended_fillers().wallet(wallet.clone()).on_http(settlement_cfg.rpc_url), ); - let core_contract_address = if get_env_var_or_panic("TEST_IMPERSONATE_OPERATOR") == "0".to_string() { - get_env_var_or_panic("TEST_DUMMY_CONTRACT_ADDRESS") + let core_contract_address = if *SHOULD_IMPERSONATE_ACCOUNT { + &settlement_cfg.core_contract_address } else { - settlement_cfg.core_contract_address + &*TEST_DUMMY_CONTRACT_ADDRESS }; let core_contract_client = StarknetValidityContractClient::new( - Address::from_str(&core_contract_address).unwrap().0.into(), + Address::from_str(core_contract_address).unwrap().0.into(), fill_provider, ); @@ -186,6 +195,7 @@ impl SettlementClient for EthereumSettlementClient { nonce: u64, ) -> Result { //TODO: better file management + let trusted_setup = KzgSettings::load_trusted_setup_file(Path::new("/Users/dexterhv/Work/Karnot/madara-alliance/madara-orchestrator/crates/settlement-clients/ethereum/src/trusted_setup.txt"))?; let (sidecar_blobs, sidecar_commitments, sidecar_proofs) = prepare_sidecar(&state_diff, &trusted_setup).await?; let sidecar = BlobTransactionSidecar::new(sidecar_blobs, sidecar_commitments, sidecar_proofs); @@ -224,7 +234,6 @@ impl SettlementClient for EthereumSettlementClient { let tx_sidecar = TxEip4844WithSidecar { tx: tx.clone(), sidecar: sidecar.clone() }; - println!("CONTTRRAACCTTT {:?}", tx.to); let mut variant = TxEip4844Variant::from(tx_sidecar); let signature = self.wallet.default_signer().sign_transaction(&mut variant).await?; let tx_signed = variant.into_signed(signature); @@ -232,25 +241,15 @@ impl SettlementClient for EthereumSettlementClient { // IMP: this conversion strips signature from the transaction let mut txn_request: TransactionRequest = tx_envelope.into(); - println!("CONTTRRAACCTTT #2 {:?}", tx.to); - - if cfg!(test) && get_env_var_or_panic("TEST_IMPERSONATE_OPERATOR") == "1".to_string() { - txn_request.set_nonce(666068); + #[cfg(test)] + if *SHOULD_IMPERSONATE_ACCOUNT { + txn_request.set_nonce(*TEST_NONCE); txn_request = txn_request.with_from( - Address::from_str("0x2C169DFe5fBbA12957Bdd0Ba47d9CEDbFE260CA7") - .expect("Unable to impersonate operator."), + *ADDRESS_TO_IMPERSONATE ); } - println!("CONTTRRAACCTTT #3 {:?}", tx.to); - - - // let encoded = tx_envelope.encoded_2718(); - // let pending_tx = self.provider.send_raw_transaction(&encoded).await?; - let pending_transaction = self.provider.send_transaction(txn_request).await?; - println!("CONTTRRAACCTTT #4 {:?}", pending_transaction.tx_hash().to_string()); - return Ok(pending_transaction.tx_hash().to_string()); } diff --git a/crates/settlement-clients/ethereum/src/tests/mod.rs b/crates/settlement-clients/ethereum/src/tests/mod.rs index 43cc02f3..826d912b 100644 --- a/crates/settlement-clients/ethereum/src/tests/mod.rs +++ b/crates/settlement-clients/ethereum/src/tests/mod.rs @@ -1,12 +1,14 @@ +use alloy::node_bindings::AnvilInstance; use alloy::{node_bindings::Anvil, sol}; use utils::env_utils::get_env_var_or_panic; +use std::env; use std::io::BufRead; +use std::path::PathBuf; use std::{ fs::{self, File}, io::BufReader, str::FromStr, }; -use url::Url; use alloy::primitives::U256; use alloy::providers::{ext::AnvilApi, ProviderBuilder}; @@ -17,136 +19,150 @@ use rstest::*; use settlement_client_interface::SettlementClient; use utils::settings::default::DefaultSettingsProvider; +use alloy::providers::Provider; +use alloy_primitives::FixedBytes; use crate::EthereumSettlementClient; +use crate::conversion::to_padded_hex; -fn hex_string_to_u8_vec(hex_str: &str) -> color_eyre::Result> { - // Remove any spaces or non-hex characters from the input string - let cleaned_str: String = hex_str.chars().filter(|c| c.is_ascii_hexdigit()).collect(); - - // Convert the cleaned hex string to a Vec - let mut result = Vec::new(); - for chunk in cleaned_str.as_bytes().chunks(2) { - if let Ok(byte_val) = u8::from_str_radix(std::str::from_utf8(chunk)?, 16) { - result.push(byte_val); - } else { - return Err(eyre!("Error parsing hex string: {}", cleaned_str)); - } +// Using the Pipe trait to write chained operations easier +trait Pipe: Sized { + fn pipe T>(self, f: F) -> T { + f(self) } - - Ok(result) } -// Codegen from ABI file to interact with the contract. -sol!( - #[allow(missing_docs)] - #[sol(rpc)] - STARKNET_CORE_CONTRACT, - "src/test_data/ABI/starknet_core_contract.json" -); +// Implement Pipe for all types +impl Pipe for S {} // TODO: betterment of file routes - - - // TODO: Checking send_transaction // Create a dummy contract and deploy on anvil with same methodId as core contract // Make an env variable that will tell if we are testing impersonation or not // Check against the env variable, if we are not impersonation then we should talk to the dummy address -sol! { - #[allow(missing_docs)] - #[sol(rpc, bytecode="6080604052348015600e575f80fd5b506101c18061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063b72d42a11461002d575b5f80fd5b6100476004803603810190610042919061010d565b610049565b005b50505050565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f8083601f84011261007857610077610057565b5b8235905067ffffffffffffffff8111156100955761009461005b565b5b6020830191508360208202830111156100b1576100b061005f565b5b9250929050565b5f8083601f8401126100cd576100cc610057565b5b8235905067ffffffffffffffff8111156100ea576100e961005b565b5b6020830191508360018202830111156101065761010561005f565b5b9250929050565b5f805f80604085870312156101255761012461004f565b5b5f85013567ffffffffffffffff81111561014257610141610053565b5b61014e87828801610063565b9450945050602085013567ffffffffffffffff81111561017157610170610053565b5b61017d878288016100b8565b92509250509295919450925056fea2646970667358221220fa7488d5a2a9e6c21e6f46145a831b0f04fdebab83868dc2b996c17f8cba4d8064736f6c634300081a0033")] - contract DummyCoreContract { - function updateStateKzgDA(uint256[] calldata programOutput, bytes calldata kzgProof) external { - } - } +use lazy_static::lazy_static; + +lazy_static! { + static ref ENV_FILE_PATH: PathBuf = PathBuf::from(".env.test"); + static ref CURRENT_PATH: String = env::current_dir() + .expect("Failed to get current directory") + .to_str() + .expect("Path contains invalid Unicode") + .to_string(); + static ref PORT : u16 = 3000_u16; + static ref ETH_RPC : String = "https://eth.llamarpc.com".to_string(); + static ref SHOULD_IMPERSONATE_ACCOUNT: bool = get_env_var_or_panic("TEST_IMPERSONATE_OPERATOR") == "1".to_string(); + static ref TEST_DUMMY_CONTRACT_ADDRESS : String = get_env_var_or_panic("TEST_DUMMY_CONTRACT_ADDRESS"); + static ref STARKNET_OPERATOR_ADDRESS : Address = Address::from_str("0x2C169DFe5fBbA12957Bdd0Ba47d9CEDbFE260CA7").expect("Could not impersonate account."); + static ref STARKNET_CORE_CONTRACT_ADDRESS : Address = Address::from_str("0xc662c410c0ecf747543f5ba90660f6abebd9c8c4").expect("Could not impersonate account."); } -#[rstest] -#[tokio::test] -#[case::basic(20468828)] -async fn update_state_blob_works(#[case] block_no: u64) { - use std::time::Duration; - - use alloy::providers::Provider; - use alloy_primitives::FixedBytes; - use tokio::time::sleep; +pub struct TestFixture { + pub anvil: AnvilInstance, + pub ethereum_settlement_client: EthereumSettlementClient, + pub provider: alloy::providers::RootProvider> +} +fn ethereum_test_fixture(block_no: u64) -> TestFixture { // Load ENV vars - use crate::conversion::to_padded_hex; - dotenvy::from_filename("../.env.test").expect("Could not load .env.test file."); - let current_path = std::env::current_dir().unwrap().to_str().unwrap().to_string(); + dotenvy::from_filename(&*ENV_FILE_PATH).expect("Could not load .env.test file."); // Setup Anvil - let _anvil = Anvil::new() - .port(3000_u16) - .fork("https://eth.llamarpc.com") + let anvil = Anvil::new() + .port(*PORT) + .fork(&*ETH_RPC) .fork_block_number(block_no - 1) .try_spawn() .expect("Could not spawn Anvil."); // Setup Provider let provider = - ProviderBuilder::new().on_http(Url::from_str("http://localhost:3000").expect("Could not create provider.")); + ProviderBuilder::new().on_http(anvil.endpoint_url()); // Setup EthereumSettlementClient let settings_provider: DefaultSettingsProvider = DefaultSettingsProvider {}; let ethereum_settlement_client = EthereumSettlementClient::with_test_settings(&settings_provider, provider.clone()); - let impersonate_acount = get_env_var_or_panic("TEST_IMPERSONATE_OPERATOR"); - - if impersonate_acount == "0".to_string(){ - let contract = DummyCoreContract::deploy(&provider).await.expect("Unable to deploy address"); - println!("Deployed contract at address: {}", contract.address()); - } else { - provider - .anvil_impersonate_account( - Address::from_str("0x2C169DFe5fBbA12957Bdd0Ba47d9CEDbFE260CA7").expect("Could not impersonate account."), - ) - .await - .expect("Unable to impersonate account."); + TestFixture { + anvil, + ethereum_settlement_client, + provider, } +} + +#[rstest] +#[tokio::test] +#[case::basic(20468828)] +async fn update_state_blob_with_dummy_contract_works(#[case] block_no: u64) { + env::set_var("TEST_IMPERSONATE_OPERATOR", "0"); + + let TestFixture { + anvil, + ethereum_settlement_client, + provider, + } = ethereum_test_fixture(block_no); + + + // Deploying a dummy contract + let contract = DummyCoreContract::deploy(&provider).await.expect("Unable to deploy address"); + assert_eq!(contract.address().to_string(), *TEST_DUMMY_CONTRACT_ADDRESS, "Dummy Contract got deployed on unexpected address"); + + // Getting latest nonce after deployment + let nonce = ethereum_settlement_client.get_nonce().await.expect("Unable to fetch nonce"); + + // generating program output and blob vector + let program_output = get_program_output(block_no); + let blob_data_vec = get_blob_data(block_no); + + // Calling update_state_with_blobs + let update_state_result = ethereum_settlement_client + .update_state_with_blobs(program_output, blob_data_vec, nonce) + .await + .expect("Could not go through update_state_with_blobs."); + + // Asserting, Expected to receive transaction hash. + assert!(!update_state_result.is_empty(), "No transaction Hash received."); + + let txn = provider.get_transaction_by_hash(FixedBytes::from_str(update_state_result.as_str()).expect("Unable to convert txn")) + .await.expect("did not get txn from hash").unwrap(); + + assert_eq!(txn.hash.to_string(),update_state_result.to_string()); + assert!(txn.signature.is_some()); + assert_eq!(txn.to.unwrap().to_string(), *TEST_DUMMY_CONTRACT_ADDRESS); +} + +#[rstest] +#[tokio::test] +#[case::basic(20468828)] +async fn update_state_blob_with_impersonation_works(#[case] block_no: u64) { + + let TestFixture { + anvil, + ethereum_settlement_client, + provider, + } = ethereum_test_fixture(block_no); + + provider + .anvil_impersonate_account( + *STARKNET_OPERATOR_ADDRESS, + ) + .await + .expect("Unable to impersonate account."); let nonce = ethereum_settlement_client.get_nonce().await.expect("Unable to fetch nonce"); // Create a contract instance. let contract = STARKNET_CORE_CONTRACT::new( - Address::from_str("0xc662c410c0ecf747543f5ba90660f6abebd9c8c4").expect("sd"), + *STARKNET_CORE_CONTRACT_ADDRESS, provider.clone(), ); // Call the contract, retrieve the current stateBlockNumber. let prev_block_number = contract.stateBlockNumber().call().await.unwrap(); - // Program Output - let program_output_file_path = - format!("{}{}{}{}", current_path.clone(), "/src/test_data/program_output/", block_no, ".txt"); - - let mut program_output: Vec<[u8; 32]> = Vec::new(); - { - let file = File::open(program_output_file_path).expect("Failed to read program output file"); - let reader = BufReader::new(file); - - for line in reader.lines() { - let line = line.expect("can't read line"); - let trimmed = line.trim(); - if !trimmed.is_empty() { - let v_0 = U256::from_str(trimmed).expect("Unable to convert line").to_be_bytes_vec(); - let v_1 = v_0.as_slice(); - let v_2 = to_padded_hex(v_1); - // let v_3 = v_2.replace("0x", ""); - let v_4 = hex_string_to_u8_vec(&v_2).expect("unable to convert"); - let v_5: [u8; 32] = v_4.try_into().expect("Vector length must be 32"); - program_output.push(v_5) - } - } - } - - // Blob Data - let blob_data_file_path = format!("{}{}{}{}", current_path.clone(), "/src/test_data/blob_data/", block_no, ".txt"); - println!("{}", blob_data_file_path); - let blob_data = fs::read_to_string(blob_data_file_path).expect("Failed to read the blob data txt file"); - let blob_data_vec = vec![hex_string_to_u8_vec(&blob_data).unwrap()]; + // generating program output and blob vector + let program_output = get_program_output(block_no); + let blob_data_vec = get_blob_data(block_no); // Calling update_state_with_blobs let update_state_result = ethereum_settlement_client @@ -160,23 +176,9 @@ async fn update_state_blob_works(#[case] block_no: u64) { // Call the contract, retrieve the latest stateBlockNumber. let latest_block_number = contract.stateBlockNumber().call().await.unwrap(); - if impersonate_acount == "1".to_string() { - println!("PREVIOUS BLOCK NUMBER {}", prev_block_number._0); - println!("CURRENT BLOCK HASH {}", latest_block_number._0); - assert_eq!(prev_block_number._0.as_u32() + 1, latest_block_number._0.as_u32()); - } else { - sleep(Duration::from_secs(2)).await; - let txn = provider.get_transaction_by_hash(FixedBytes::from_str(update_state_result.as_str()).expect("couln't convert")) - .await - .expect("did not get txn from hash"); - println!("{:?}", txn); - sleep(Duration::from_secs(2)).await; - - assert!(!txn.is_none()); - - - } - + println!("PREVIOUS BLOCK NUMBER {}", prev_block_number._0); + println!("CURRENT BLOCK HASH {}", latest_block_number._0); + assert_eq!(prev_block_number._0.as_u32() + 1, latest_block_number._0.as_u32()); } #[rstest] @@ -226,3 +228,91 @@ async fn creating_input_data_works(#[case] block_no: u64) { let expected = "0xb72d42a100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000340000000000000000000000000000000000000000000000000000000000000001706ac7b2661801b4c0733da6ed1d2910b3b97259534ca95a63940932513111fba028bccc051eaae1b9a69b53e64a68021233b4dee2030aeda4be886324b3fbb3e00000000000000000000000000000000000000000000000000000000000a29b8070626a88de6a77855ecd683757207cdd18ba56553dca6c0c98ec523b827bee005ba2078240f1585f96424c2d1ee48211da3b3f9177bf2b9880b4fc91d59e9a2000000000000000000000000000000000000000000000000000000000000000100000000000000002b4e335bc41dc46c71f29928a5094a8c96a0c3536cabe53e0000000000000000810abb1929a0d45cdd62a20f9ccfd5807502334e7deb35d404c86d8b63a5741770fefca2f9b8efb7e663d89097edb3c60595b236f6e78e6f000000000000000000000000000000004a4b8a979fefc4d6b82e030fb082ca98000000000000000000000000000000004e8371c6774260e87b92447d4a2b0e170000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000bf67f59d2988a46fbff7ed79a621778a3cd3985b0088eedbe2fe3918b69ccb411713b7fa72079d4eddf291103ccbe41e78a9615c0000000000000000000000000000000000000000000000000000000000194fe601b64b1b3b690b43b9b514fb81377518f4039cd3e4f4914d8a6bdf01d679fb1900000000000000000000000000000000000000000000000000000000000000050000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca000000000000000000000000012ccc443d39da45e5f640b3e71f0c7502152dbac01d4988e248d342439aa025b302e1f07595f6a5c810dcce23e7379e48f05d4cf000000000000000000000000000000000000000000000007f189b5374ad2a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030ab015987628cffee3ef99b9768ef8ca12c6244525f0cd10310046eaa21291b5aca164d044c5b4ad7212c767b165ed5e300000000000000000000000000000000"; assert_eq!(input_bytes, expected); } + + + + +// SOLIDITY FUNCTIONS NEEDED +sol!( + #[allow(missing_docs)] + #[sol(rpc)] + STARKNET_CORE_CONTRACT, + "src/test_data/ABI/starknet_core_contract.json" +); + +sol! { + #[allow(missing_docs)] + #[sol(rpc, bytecode="6080604052348015600e575f80fd5b506101c18061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063b72d42a11461002d575b5f80fd5b6100476004803603810190610042919061010d565b610049565b005b50505050565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f8083601f84011261007857610077610057565b5b8235905067ffffffffffffffff8111156100955761009461005b565b5b6020830191508360208202830111156100b1576100b061005f565b5b9250929050565b5f8083601f8401126100cd576100cc610057565b5b8235905067ffffffffffffffff8111156100ea576100e961005b565b5b6020830191508360018202830111156101065761010561005f565b5b9250929050565b5f805f80604085870312156101255761012461004f565b5b5f85013567ffffffffffffffff81111561014257610141610053565b5b61014e87828801610063565b9450945050602085013567ffffffffffffffff81111561017157610170610053565b5b61017d878288016100b8565b92509250509295919450925056fea2646970667358221220fa7488d5a2a9e6c21e6f46145a831b0f04fdebab83868dc2b996c17f8cba4d8064736f6c634300081a0033")] + contract DummyCoreContract { + function updateStateKzgDA(uint256[] calldata programOutput, bytes calldata kzgProof) external { + } + } +} + + + + + + + + + + + + + +// UTILITY FUNCTIONS NEEDED + +fn get_program_output(block_no : u64) -> Vec<[u8; 32]> { + // Program Output + let program_output_file_path = + format!("{}{}{}{}", *CURRENT_PATH, "/src/test_data/program_output/", block_no, ".txt"); + + let mut program_output: Vec<[u8; 32]> = Vec::new(); + let file = File::open(program_output_file_path).expect("Failed to read program output file"); + let reader = BufReader::new(file); + + for line in reader.lines() { + let line = line.expect("can't read line"); + let trimmed = line.trim(); + assert!(!trimmed.is_empty()); + + let result: [u8; 32] = U256::from_str(trimmed) + .expect("Unable to convert line") + .to_be_bytes_vec() + .as_slice() + .pipe(|bytes| to_padded_hex(bytes)) + .pipe(|hex| hex_string_to_u8_vec(&hex).expect("unable to convert")) + .try_into() + .expect("Vector length must be 32"); + + program_output.push(result) + } + program_output +} + +fn get_blob_data(block_no : u64) -> Vec> { + // Blob Data + let blob_data_file_path = format!("{}{}{}{}", *CURRENT_PATH, "/src/test_data/blob_data/", block_no, ".txt"); + let blob_data = fs::read_to_string(blob_data_file_path).expect("Failed to read the blob data txt file"); + let blob_data_vec = vec![hex_string_to_u8_vec(&blob_data).unwrap()]; + blob_data_vec +} + + +fn hex_string_to_u8_vec(hex_str: &str) -> color_eyre::Result> { + // Remove any spaces or non-hex characters from the input string + let cleaned_str: String = hex_str.chars().filter(|c| c.is_ascii_hexdigit()).collect(); + + // Convert the cleaned hex string to a Vec + let mut result = Vec::new(); + for chunk in cleaned_str.as_bytes().chunks(2) { + if let Ok(byte_val) = u8::from_str_radix(std::str::from_utf8(chunk)?, 16) { + result.push(byte_val); + } else { + return Err(eyre!("Error parsing hex string: {}", cleaned_str)); + } + } + + Ok(result) +}