diff --git a/Cargo.lock b/Cargo.lock index 2f829eb..39bfb60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,6 +34,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.8.11" @@ -67,9 +78,35 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f4a4aaae80afd4be443a6aecd92a6b255dcdd000f97996928efb33d8a71e100" dependencies = [ + "alloy-consensus", + "alloy-contract", "alloy-core", + "alloy-eips", + "alloy-genesis", + "alloy-json-rpc", + "alloy-network", + "alloy-provider", + "alloy-pubsub", + "alloy-rpc-client", + "alloy-rpc-types", + "alloy-serde", "alloy-signer", "alloy-signer-local", + "alloy-transport", + "alloy-transport-http", + "alloy-transport-ipc", + "alloy-transport-ws", +] + +[[package]] +name = "alloy-chains" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18c5c520273946ecf715c0010b4e3503d7eba9893cd9ce6b7fff5654c4a3c470" +dependencies = [ + "alloy-primitives 0.8.12", + "num_enum 0.7.3", + "strum", ] [[package]] @@ -79,45 +116,111 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04c309895995eaa4bfcc345f5515a39c7df9447798645cc8bf462b6c5bf1dc96" dependencies = [ "alloy-eips", - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-rlp", "alloy-serde", "c-kzg", "serde", ] +[[package]] +name = "alloy-contract" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f4e0ef72b0876ae3068b2ed7dfae9ae1779ce13cfaec2ee1f08f5bd0348dc57" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-network", + "alloy-network-primitives", + "alloy-primitives 0.7.7", + "alloy-provider", + "alloy-pubsub", + "alloy-rpc-types-eth", + "alloy-sol-types", + "alloy-transport", + "futures", + "futures-util", + "thiserror", +] + [[package]] name = "alloy-core" version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "529fc6310dc1126c8de51c376cbc59c79c7f662bd742be7dc67055d5421a81b4" dependencies = [ - "alloy-primitives", + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives 0.7.7", + "alloy-rlp", "alloy-sol-types", ] +[[package]] +name = "alloy-dyn-abi" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413902aa18a97569e60f679c23f46a18db1656d87ab4d4e49d0e1e52042f66df" +dependencies = [ + "alloy-json-abi", + "alloy-primitives 0.7.7", + "alloy-sol-type-parser", + "alloy-sol-types", + "const-hex", + "itoa", + "serde", + "serde_json", + "winnow 0.6.20", +] + [[package]] name = "alloy-eips" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9431c99a3b3fe606ede4b3d4043bdfbcb780c45b8d8d226c3804e2b75cfbe68" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-rlp", "alloy-serde", "c-kzg", + "derive_more 0.99.18", + "k256", "once_cell", "serde", "sha2", ] +[[package]] +name = "alloy-genesis" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79614dfe86144328da11098edcc7bc1a3f25ad8d3134a9eb9e857e06f0d9840d" +dependencies = [ + "alloy-primitives 0.7.7", + "alloy-serde", + "serde", +] + +[[package]] +name = "alloy-json-abi" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc05b04ac331a9f07e3a4036ef7926e49a8bf84a99a1ccfc7e2ab55a5fcbb372" +dependencies = [ + "alloy-primitives 0.7.7", + "alloy-sol-type-parser", + "serde", + "serde_json", +] + [[package]] name = "alloy-json-rpc" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57e2865c4c3bb4cdad3f0d9ec1ab5c0c657ba69a375651bd35e32fb6c180ccc2" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-sol-types", "serde", "serde_json", @@ -135,7 +238,7 @@ dependencies = [ "alloy-eips", "alloy-json-rpc", "alloy-network-primitives", - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-rpc-types-eth", "alloy-serde", "alloy-signer", @@ -152,7 +255,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec9d5a0f9170b10988b6774498a022845e13eda94318440d17709d50687f67f9" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-serde", "serde", ] @@ -179,6 +282,76 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "alloy-primitives" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fce5dbd6a4f118eecc4719eaa9c7ffc31c315e6c5ccde3642db927802312425" +dependencies = [ + "bytes", + "cfg-if", + "const-hex", + "derive_more 1.0.0", + "hex-literal", + "itoa", + "paste", + "ruint", + "tiny-keccak", +] + +[[package]] +name = "alloy-provider" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9c0ab10b93de601a6396fc7ff2ea10d3b28c46f079338fa562107ebf9857c8" +dependencies = [ + "alloy-chains", + "alloy-consensus", + "alloy-eips", + "alloy-json-rpc", + "alloy-network", + "alloy-network-primitives", + "alloy-primitives 0.7.7", + "alloy-pubsub", + "alloy-rpc-client", + "alloy-rpc-types-eth", + "alloy-rpc-types-trace", + "alloy-transport", + "alloy-transport-ipc", + "alloy-transport-ws", + "async-stream", + "async-trait", + "auto_impl", + "dashmap", + "futures", + "futures-utils-wasm", + "lru", + "pin-project", + "serde", + "serde_json", + "tokio", + "tracing", +] + +[[package]] +name = "alloy-pubsub" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f5da2c55cbaf229bad3c5f8b00b5ab66c74ef093e5f3a753d874cfecf7d2281" +dependencies = [ + "alloy-json-rpc", + "alloy-primitives 0.7.7", + "alloy-transport", + "bimap", + "futures", + "serde", + "serde_json", + "tokio", + "tokio-stream", + "tower", + "tracing", +] + [[package]] name = "alloy-rlp" version = "0.3.7" @@ -201,6 +374,61 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "alloy-rpc-client" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b38e3ffdb285df5d9f60cb988d336d9b8e3505acb78750c3bc60336a7af41d3" +dependencies = [ + "alloy-json-rpc", + "alloy-primitives 0.7.7", + "alloy-pubsub", + "alloy-transport", + "alloy-transport-http", + "alloy-transport-ipc", + "alloy-transport-ws", + "futures", + "pin-project", + "serde", + "serde_json", + "tokio", + "tokio-stream", + "tower", + "tracing", + "url", +] + +[[package]] +name = "alloy-rpc-types" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c31a3750b8f5a350d17354e46a52b0f2f19ec5f2006d816935af599dedc521" +dependencies = [ + "alloy-rpc-types-engine", + "alloy-rpc-types-eth", + "alloy-rpc-types-trace", + "alloy-serde", + "serde", +] + +[[package]] +name = "alloy-rpc-types-engine" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff63f51b2fb2f547df5218527fd0653afb1947bf7fead5b3ce58c75d170b30f7" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-primitives 0.7.7", + "alloy-rlp", + "alloy-rpc-types-eth", + "alloy-serde", + "jsonwebtoken", + "rand", + "serde", + "thiserror", +] + [[package]] name = "alloy-rpc-types-eth" version = "0.2.1" @@ -210,7 +438,7 @@ dependencies = [ "alloy-consensus", "alloy-eips", "alloy-network-primitives", - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-rlp", "alloy-serde", "alloy-sol-types", @@ -220,13 +448,27 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-rpc-types-trace" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a86eeb49ea0cc79f249faa1d35c20541bb1c317a59b5962cb07b1890355b0064" +dependencies = [ + "alloy-primitives 0.7.7", + "alloy-rpc-types-eth", + "alloy-serde", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "alloy-serde" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e33feda6a53e6079895aed1d08dcb98a1377b000d80d16370fbbdb8155d547ef" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.7", "serde", "serde_json", ] @@ -237,7 +479,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "740a25b92e849ed7b0fa013951fe2f64be9af1ad5abe805037b44fb7770c5c47" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.7", "async-trait", "auto_impl", "elliptic-curve", @@ -253,9 +495,11 @@ checksum = "1b0707d4f63e4356a110b30ef3add8732ab6d181dd7be4607bf79b8777105cee" dependencies = [ "alloy-consensus", "alloy-network", - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-signer", "async-trait", + "elliptic-curve", + "eth-keystore", "k256", "rand", "thiserror", @@ -281,10 +525,11 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" dependencies = [ + "alloy-json-abi", "alloy-sol-macro-input", "const-hex", "heck 0.5.0", - "indexmap", + "indexmap 2.2.6", "proc-macro-error", "proc-macro2", "quote", @@ -299,24 +544,104 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" dependencies = [ + "alloy-json-abi", "const-hex", "dunce", "heck 0.5.0", "proc-macro2", "quote", + "serde_json", "syn 2.0.87", "syn-solidity", ] +[[package]] +name = "alloy-sol-type-parser" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbcba3ca07cf7975f15d871b721fb18031eec8bce51103907f6dcce00b255d98" +dependencies = [ + "serde", + "winnow 0.6.20", +] + [[package]] name = "alloy-sol-types" version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" dependencies = [ - "alloy-primitives", + "alloy-json-abi", + "alloy-primitives 0.7.7", "alloy-sol-macro", "const-hex", + "serde", +] + +[[package]] +name = "alloy-transport" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d0590afbdacf2f8cca49d025a2466f3b6584a016a8b28f532f29f8da1007bae" +dependencies = [ + "alloy-json-rpc", + "base64 0.22.1", + "futures-util", + "futures-utils-wasm", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "tracing", + "url", +] + +[[package]] +name = "alloy-transport-http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2437d145d80ea1aecde8574d2058cceb8b3c9cba05f6aea8e67907c660d46698" +dependencies = [ + "alloy-transport", + "url", +] + +[[package]] +name = "alloy-transport-ipc" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804494366e20468776db4e18f9eb5db7db0fe14f1271eb6dbf155d867233405c" +dependencies = [ + "alloy-json-rpc", + "alloy-pubsub", + "alloy-transport", + "bytes", + "futures", + "interprocess", + "pin-project", + "serde_json", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "alloy-transport-ws" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af855163e7df008799941aa6dd324a43ef2bf264b08ba4b22d44aad6ced65300" +dependencies = [ + "alloy-pubsub", + "alloy-transport", + "futures", + "http 1.1.0", + "rustls 0.23.12", + "serde_json", + "tokio", + "tokio-tungstenite", + "tracing", + "ws_stream_wasm", ] [[package]] @@ -653,6 +978,28 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "async-trait" version = "0.1.81" @@ -664,6 +1011,23 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version 0.4.0", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "auto_impl" version = "1.2.0" @@ -681,6 +1045,53 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 1.0.1", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 1.0.1", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.73" @@ -721,6 +1132,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bimap" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" + [[package]] name = "bincode" version = "1.3.3" @@ -870,6 +1287,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "borsh" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" +dependencies = [ + "once_cell", + "proc-macro-crate 3.1.0", + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -989,6 +1429,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.38" @@ -998,9 +1444,20 @@ dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", + "serde", "windows-targets 0.52.6", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "clang-sys" version = "1.8.1" @@ -1229,6 +1686,15 @@ dependencies = [ "typenum", ] +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -1255,6 +1721,54 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "dashu" version = "0.4.2" @@ -1333,6 +1847,12 @@ dependencies = [ "rustversion", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "der" version = "0.7.9" @@ -1416,6 +1936,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.87", + "unicode-xid", ] [[package]] @@ -1486,6 +2007,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf673e0848ef09fa4aeeba78e681cf651c0c7d35f76ee38cec8e55bc32fa111" +[[package]] +name = "doctest-file" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac81fa3e28d21450aa4d2ac065992ba96a1d7303efbce51a95f4fd175b67562" + [[package]] name = "downcast-rs" version = "1.2.1" @@ -1536,6 +2063,15 @@ dependencies = [ "spki", ] +[[package]] +name = "eip4844" +version = "0.0.1" +source = "git+https://github.com/InfinityVM/InfinityVM.git?branch=sp1-feature-branch#fae28d89fd75d49692c31f4e0ffa6ec619c218af" +dependencies = [ + "alloy", + "c-kzg", +] + [[package]] name = "either" version = "1.13.0" @@ -1629,6 +2165,28 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "eth-keystore" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" +dependencies = [ + "aes", + "ctr", + "digest 0.10.7", + "hex", + "hmac", + "pbkdf2", + "rand", + "scrypt", + "serde", + "serde_json", + "sha2", + "sha3", + "thiserror", + "uuid", +] + [[package]] name = "eyre" version = "0.6.12" @@ -1901,8 +2459,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1969,7 +2529,26 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -1999,6 +2578,12 @@ dependencies = [ "rayon", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.13.2" @@ -2159,7 +2744,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -2182,9 +2767,11 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -2224,6 +2811,19 @@ dependencies = [ "webpki-roots 0.26.3", ] +[[package]] +name = "hyper-timeout" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.4.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -2280,6 +2880,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -2316,6 +2922,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -2339,6 +2955,30 @@ dependencies = [ "web-time", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "interprocess" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f4e4a06d42fab3e85ab1b419ad32b09eab58b901d40c57935ff92db3287a13" +dependencies = [ + "doctest-file", + "futures-core", + "libc", + "recvmsg", + "tokio", + "widestring", + "windows-sys 0.52.0", +] + [[package]] name = "inventory" version = "0.3.15" @@ -2385,10 +3025,51 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "ivm-abi" +version = "0.0.1" +source = "git+https://github.com/InfinityVM/InfinityVM.git?branch=sp1-feature-branch#fae28d89fd75d49692c31f4e0ffa6ec619c218af" +dependencies = [ + "alloy", +] + +[[package]] +name = "ivm-abi" +version = "0.0.1" +source = "git+https://github.com/InfinityVM/InfinityVM.git?rev=f360c96#f360c964cf7a22dd597237bfc458bf317b1bd8fe" +dependencies = [ + "alloy", +] + +[[package]] +name = "ivm-proto" +version = "0.0.1" +source = "git+https://github.com/InfinityVM/InfinityVM.git?branch=sp1-feature-branch#fae28d89fd75d49692c31f4e0ffa6ec619c218af" +dependencies = [ + "borsh", + "prost 0.13.3", + "serde", + "serde_with", + "tonic", +] + +[[package]] +name = "ivm-zkvm" +version = "0.0.1" +source = "git+https://github.com/InfinityVM/InfinityVM.git?branch=sp1-feature-branch#fae28d89fd75d49692c31f4e0ffa6ec619c218af" +dependencies = [ + "alloy", + "anyhow", + "risc0-binfmt", + "risc0-zkvm", + "sp1-sdk", + "thiserror", +] [[package]] name = "jobserver" @@ -2408,6 +3089,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "9.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ae10193d25051e74945f1ea2d0b42e03cc3b890f7e4cc5faa44997d808193f" +dependencies = [ + "base64 0.21.7", + "js-sys", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "jubjub" version = "0.9.0" @@ -2589,6 +3285,12 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "matrixmultiply" version = "0.3.8" @@ -2852,7 +3554,16 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" dependencies = [ - "num_enum_derive", + "num_enum_derive 0.5.11", +] + +[[package]] +name = "num_enum" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +dependencies = [ + "num_enum_derive 0.7.3", ] [[package]] @@ -2867,6 +3578,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "num_enum_derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "num_threads" version = "0.1.7" @@ -3306,6 +4028,25 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.1", + "serde", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -3323,6 +4064,16 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version 0.4.0", +] + [[package]] name = "pin-project" version = "1.1.5" @@ -3476,7 +4227,7 @@ dependencies = [ name = "programs" version = "0.1.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-sol-types", "risc0-build", "risc0-zkvm", @@ -3487,7 +4238,7 @@ dependencies = [ name = "programs-sp1" version = "0.1.0" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.7", "alloy-sol-types", "sp1-build 3.2.1", "sp1-helper", @@ -3521,7 +4272,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.12.6", +] + +[[package]] +name = "prost" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +dependencies = [ + "bytes", + "prost-derive 0.13.3", ] [[package]] @@ -3537,6 +4298,19 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "prost-derive" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -3678,6 +4452,12 @@ dependencies = [ "rayon", ] +[[package]] +name = "recvmsg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3edd4d5d42c92f0a659926464d4cce56b562761267ecf0f469d85b7de384175" + [[package]] name = "redox_syscall" version = "0.5.3" @@ -3753,7 +4533,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", @@ -4068,7 +4848,7 @@ dependencies = [ "hex", "lazy-regex", "nvtx", - "prost", + "prost 0.12.6", "rand", "rayon", "risc0-binfmt", @@ -4126,7 +4906,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3372685893a9f67d18e98e792d690017287fd17379a83d798d958e517d380fa9" dependencies = [ "downcast-rs", - "num_enum", + "num_enum 0.5.11", "paste", ] @@ -4316,6 +5096,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + [[package]] name = "scale-info" version = "2.11.5" @@ -4364,6 +5153,18 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scrypt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" +dependencies = [ + "hmac", + "pbkdf2", + "salsa20", + "sha2", +] + [[package]] name = "sct" version = "0.7.1" @@ -4444,6 +5245,12 @@ dependencies = [ "pest", ] +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" version = "1.0.215" @@ -4488,6 +5295,34 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "serial_test" version = "3.2.0" @@ -4513,6 +5348,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha2" version = "0.10.8" @@ -4575,6 +5421,18 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint 0.4.6", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "size" version = "0.4.1" @@ -5312,6 +6170,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", + "tracing", "windows-sys 0.52.0", ] @@ -5357,6 +6216,34 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" +dependencies = [ + "futures-util", + "log", + "rustls 0.23.12", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tungstenite", + "webpki-roots 0.26.3", +] + [[package]] name = "tokio-util" version = "0.7.11" @@ -5382,9 +6269,9 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap", + "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -5393,9 +6280,39 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap", + "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "tonic" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.22.1", + "bytes", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost 0.13.3", + "socket2", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", ] [[package]] @@ -5406,11 +6323,16 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", + "indexmap 1.9.3", "pin-project", "pin-project-lite", + "rand", + "slab", "tokio", + "tokio-util", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -5515,6 +6437,26 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tungstenite" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "rustls 0.23.12", + "rustls-pki-types", + "sha1", + "thiserror", + "utf-8", +] + [[package]] name = "twox-hash" version = "1.6.3" @@ -5618,6 +6560,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "untrusted" version = "0.9.0" @@ -5635,12 +6583,28 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" @@ -5831,6 +6795,12 @@ dependencies = [ "winsafe", ] +[[package]] +name = "widestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" + [[package]] name = "winapi" version = "0.3.9" @@ -6029,6 +6999,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -6055,6 +7034,25 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version 0.4.0", + "send_wrapper", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wyz" version = "0.5.1" @@ -6115,7 +7113,7 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap", + "indexmap 2.2.6", "memchr", "thiserror", "zopfli", @@ -6148,6 +7146,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "zkvm-executor" +version = "0.0.1" +source = "git+https://github.com/InfinityVM/InfinityVM.git?branch=sp1-feature-branch#fae28d89fd75d49692c31f4e0ffa6ec619c218af" +dependencies = [ + "alloy", + "eip4844", + "ivm-abi 0.0.1 (git+https://github.com/InfinityVM/InfinityVM.git?branch=sp1-feature-branch)", + "ivm-proto", + "ivm-zkvm", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "zkvm-utils" version = "0.0.1" @@ -6156,6 +7169,7 @@ dependencies = [ "alloy-sol-types", "anyhow", "clap", + "ivm-abi 0.0.1 (git+https://github.com/InfinityVM/InfinityVM.git?rev=f360c96)", "k256", "risc0-binfmt", "risc0-build", @@ -6166,6 +7180,7 @@ dependencies = [ "sp1-sdk", "sp1-zkvm", "tokio", + "zkvm-executor", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 46696a6..bc3cac7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,6 +102,9 @@ alloy-sol-types = { version = "0.7", default-features = false } clap = { version = "4", features = ["derive"] } +ivm-abi = { git = "https://github.com/InfinityVM/InfinityVM.git", rev = "f360c96" } +zkvm-executor = { git = "https://github.com/InfinityVM/InfinityVM.git", branch = "sp1-feature-branch" } + k256 = { version = "0.13", default-features = false } risc0-zkvm = { version = "1", features = ["prove"], default-features = false } diff --git a/README.md b/README.md index dc029a6..2e6a8b6 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The flow of the InfinityVM coprocessor looks like this: 2. The coprocessor executes this job and submits the result back to the contract. 3. The app contract can simply use the result from the coprocessor in any of their app logic. -![InfinityVM coprocessor flow](images/overview.png) +![InfinityVM coprocessor flow](assets/overview.png) ## Quick Start @@ -82,7 +82,7 @@ We can call the `square_root.rs` program from our app contract. We just need to 1. Call `requestJob()` with the program ID of `square_root.rs` from `ProgramID.sol` along with ABI-encoded inputs (the number we want to calculate the square root of). 2. Write a `_receiveResult()` function which accepts the output from the `square_root.rs` program and uses it in some application logic. -![Onchain request flow](images/onchain-request.png) +![Onchain request flow](assets/onchain-request.png) To build the contracts, you can run: ``` @@ -93,7 +93,7 @@ forge build We can also call the `square_root.rs` program offchain by sending a request directly to the coprocessor. The coprocessor will execute the job and submit the result to our app contract. The flow looks like this: -![Offchain request flow](images/offchain-request.png) +![Offchain request flow](assets/offchain-request.png) The offchain request to the coprocessor can be sent by an app, a user, or any authorized third-party. To support offchain requests for your app contract, you need to implement the `isValidSignature()` function in your contract, which is called to verify whether an offchain request is signed by an authorized signer/user. We've provided an example implementation of `isValidSignature()` in the `SquareRootConsumer.sol` contract (which checks that each job request is signed by a signer owned by the app), but you can implement any logic or checks you'd like. diff --git a/images/offchain-request.png b/assets/offchain-request.png similarity index 100% rename from images/offchain-request.png rename to assets/offchain-request.png diff --git a/images/onchain-request.png b/assets/onchain-request.png similarity index 100% rename from images/onchain-request.png rename to assets/onchain-request.png diff --git a/images/overview.png b/assets/overview.png similarity index 100% rename from images/overview.png rename to assets/overview.png diff --git a/zkvm-utils/Cargo.toml b/zkvm-utils/Cargo.toml index f8bfda8..aeac124 100644 --- a/zkvm-utils/Cargo.toml +++ b/zkvm-utils/Cargo.toml @@ -19,6 +19,9 @@ risc0-zkp = { workspace = true } risc0-zkvm = { workspace = true, features = ["client"] } tokio = { workspace = true } +ivm-abi = { workspace = true } +zkvm-executor = { workspace = true } + sp1-zkvm = { workspace = true } sp1-sdk = { workspace = true } sp1-helper = { workspace = true } diff --git a/zkvm-utils/src/main.rs b/zkvm-utils/src/main.rs index 30a3d4e..7f775d5 100644 --- a/zkvm-utils/src/main.rs +++ b/zkvm-utils/src/main.rs @@ -10,6 +10,10 @@ use alloy::{ use alloy_sol_types::{sol, SolType}; use anyhow::{Context, Result}; use clap::Parser; +use ivm_abi::{ + get_job_id, JobParams, abi_encode_offchain_job_request, abi_encode_result_with_metadata, + abi_encode_offchain_result_with_metadata, +}; use k256::ecdsa::SigningKey; use risc0_binfmt::compute_image_id; use risc0_zkvm::{Executor, ExecutorEnv, LocalProver}; @@ -117,10 +121,10 @@ async fn execute_onchain_job_ffi( let journal = execute_onchain_job(&elf, &onchain_input, max_cycles)?; let result_with_metadata = abi_encode_result_with_metadata( job_id, - onchain_input, + onchain_input.as_slice().try_into().unwrap(), max_cycles, program_id_bytes, - journal, + &journal, ); let zkvm_operator_signature = sign_message(&result_with_metadata, signer).await?; @@ -157,14 +161,15 @@ async fn execute_offchain_job_ffi( // Create a signed job request // This would normally be sent by the user/app signer, but we // construct it here to work with the foundry tests. - let job_request = abi_encode_offchain_job_request( + let job_params = JobParams { nonce, max_cycles, - &consumer, - program_id_bytes, - onchain_input.clone(), - offchain_input_hash.into(), - ); + consumer_address: **Address::from_str(&consumer).unwrap(), + program_id: program_id_bytes, + onchain_input: &onchain_input, + offchain_input_hash: offchain_input_hash.into(), + }; + let job_request = abi_encode_offchain_job_request(job_params); let offchain_signer = create_signer(&secret)?; let offchain_signer_signature = sign_message(&job_request, &offchain_signer).await?; @@ -181,7 +186,7 @@ async fn execute_offchain_job_ffi( offchain_input_hash.into(), max_cycles, program_id_bytes, - journal, + &journal, versioned_blob_hashes, ); let zkvm_operator_signature = sign_message(&offchain_result_with_metadata, signer).await?; @@ -255,30 +260,6 @@ pub type OffChainResultWithSignatureCalldata = sol! { tuple(bytes,bytes,bytes,bytes) }; -/// The payload that gets signed to signify that the zkvm executor has faithfully -/// executed an onchain job. Also the result payload the job manager contract expects. -/// -/// tuple(JobID,OnchainInputHash,MaxCycles,VerifyingKey,RawOutput) -pub type ResultWithMetadata = sol! { - tuple(bytes32,bytes32,uint64,bytes32,bytes) -}; - -/// The payload that gets signed to signify that the zkvm executor has faithfully -/// executed an offchain job. Also the result payload the job manager contract expects. -/// -/// tuple(JobID,OnchainInputHash,OffchainInputHash,OffchainStateHash,MaxCycles,VerifyingKey, -/// RawOutput,VersionedBlobHashes) -pub type OffChainResultWithMetadata = sol! { - tuple(bytes32,bytes32,bytes32,uint64,bytes32,bytes,bytes32[]) -}; - -/// The payload that gets signed by the entity sending an offchain job request. -/// This can be the user but the Consumer contract can decide who needs to -/// sign this request. -pub type OffchainJobRequest = sol! { - tuple(uint64,uint64,address,bytes32,bytes,bytes32) -}; - /// Returns ABI-encoded calldata with result and signature. This ABI-encoded response will be /// sent to the `JobManager` contract. pub fn abi_encode_result_with_signature_calldata(result: Vec, signature: Vec) -> Vec { @@ -301,81 +282,6 @@ pub fn abi_encode_offchain_result_with_signature_calldata( )) } -/// Returns an ABI-encoded result with metadata. This ABI-encoded response will be -/// signed by the coprocessor operator. -pub fn abi_encode_result_with_metadata( - job_id: [u8; 32], - onchain_input: Vec, - max_cycles: u64, - program_verifying_key: &[u8; 32], - raw_output: Vec, -) -> Vec { - let onchain_input_hash = keccak256(onchain_input); - ResultWithMetadata::abi_encode(&( - job_id, - onchain_input_hash, - max_cycles, - program_verifying_key, - raw_output, - )) -} - -/// Returns an ABI-encoded offchain result with metadata. This ABI-encoded response will be -/// signed by the coprocessor operator. -pub fn abi_encode_offchain_result_with_metadata( - job_id: [u8; 32], - onchain_input_hash: [u8; 32], - offchain_input_hash: [u8; 32], - max_cycles: u64, - program_verifying_key: &[u8; 32], - raw_output: Vec, - versioned_blob_hashes: Vec<[u8; 32]>, -) -> Vec { - OffChainResultWithMetadata::abi_encode(&( - job_id, - onchain_input_hash, - offchain_input_hash, - max_cycles, - program_verifying_key, - raw_output, - versioned_blob_hashes, - )) -} - -/// Returns an ABI-encoded offchain job request. This ABI-encoded request can be -/// signed by the user sending the request, but the Consumer contract can -/// decide who this request should be signed by. -pub fn abi_encode_offchain_job_request( - nonce: u64, - max_cycles: u64, - consumer: &str, - program_verifying_key: &[u8; 32], - onchain_input: Vec, - offchain_input_hash: [u8; 32], -) -> Vec { - OffchainJobRequest::abi_encode(&( - nonce, - max_cycles, - Address::from_str(consumer).unwrap(), - program_verifying_key, - onchain_input, - offchain_input_hash, - )) -} - -type NonceAndConsumer = sol! { - tuple(uint64, address) -}; - -fn abi_encode_nonce_and_consumer(nonce: u64, consumer: Address) -> Vec { - NonceAndConsumer::abi_encode_packed(&(nonce, consumer)) -} - -/// Returns the job ID hash for a given nonce and consumer address. -pub fn get_job_id(nonce: u64, consumer: Address) -> [u8; 32] { - keccak256(abi_encode_nonce_and_consumer(nonce, consumer)).into() -} - fn create_signer(secret: &str) -> Result> { let hex = if let Some(stripped) = secret.strip_prefix("0x") { stripped } else { secret }; let decoded = hex::decode(hex)?;