From 97c332d6b530d4eb534826bd3d44f0aaaf3f35e1 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 4 Aug 2025 15:43:41 +0200 Subject: [PATCH 1/2] feat(bin): order submitter Closes ENG-1193 --- Cargo.lock | 366 ++++++++++++++++++++------------------------ Cargo.toml | 8 +- README.md | 20 ++- bin/submit_order.rs | 140 +++++++++++++++++ src/lib.rs | 1 + 5 files changed, 336 insertions(+), 199 deletions(-) create mode 100644 bin/submit_order.rs diff --git a/Cargo.lock b/Cargo.lock index b826605..ec1139b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -425,7 +425,7 @@ dependencies = [ "lru", "parking_lot", "pin-project", - "reqwest 0.12.20", + "reqwest", "serde", "serde_json", "thiserror 2.0.12", @@ -494,7 +494,7 @@ dependencies = [ "async-stream", "futures", "pin-project", - "reqwest 0.12.20", + "reqwest", "serde", "serde_json", "tokio", @@ -801,7 +801,7 @@ checksum = "f643645a33a681d09ac1ca2112014c2ca09c68aad301da4400484d59c746bc70" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.20", + "reqwest", "serde_json", "tower", "tracing", @@ -894,6 +894,56 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" version = "1.0.98" @@ -1695,7 +1745,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tower", "tower-layer", @@ -1729,7 +1779,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tower", "tower-layer", @@ -1752,7 +1802,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.2", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -1772,7 +1822,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.2", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -1845,7 +1895,7 @@ version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ - "bitflags 2.9.1", + "bitflags", "cexpr", "clang-sys", "itertools 0.12.1", @@ -1893,12 +1943,6 @@ dependencies = [ "hex-conservative", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.9.1" @@ -1961,10 +2005,11 @@ dependencies = [ "eyre", "init4-bin-base", "openssl", - "reqwest 0.11.27", + "reqwest", "serde", "serde_json", "signet-constants", + "signet-orders", "signet-sim", "signet-tx-cache", "signet-types", @@ -2087,6 +2132,46 @@ dependencies = [ "libloading", ] +[[package]] +name = "clap" +version = "4.5.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + [[package]] name = "cmake" version = "0.1.54" @@ -2096,6 +2181,12 @@ dependencies = [ "cc", ] +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + [[package]] name = "const-hex" version = "1.14.1" @@ -3039,19 +3130,6 @@ dependencies = [ "webpki-roots 1.0.1", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.32", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -3087,7 +3165,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2", - "system-configuration 0.6.1", + "system-configuration", "tokio", "tower-service", "tracing", @@ -3301,7 +3379,7 @@ dependencies = [ "opentelemetry-otlp", "opentelemetry-semantic-conventions", "opentelemetry_sdk", - "reqwest 0.12.20", + "reqwest", "serde", "signet-constants", "signet-tx-cache", @@ -3358,6 +3436,12 @@ dependencies = [ "serde", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -3469,7 +3553,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.53.2", ] [[package]] @@ -3864,7 +3948,7 @@ dependencies = [ "getrandom 0.2.16", "http 1.3.1", "rand 0.8.5", - "reqwest 0.12.20", + "reqwest", "serde", "serde_json", "serde_path_to_error", @@ -3888,6 +3972,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -3900,7 +3990,7 @@ version = "0.10.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" dependencies = [ - "bitflags 2.9.1", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -3972,7 +4062,7 @@ dependencies = [ "bytes", "http 1.3.1", "opentelemetry", - "reqwest 0.12.20", + "reqwest", "tracing", ] @@ -3989,7 +4079,7 @@ dependencies = [ "opentelemetry-proto", "opentelemetry_sdk", "prost", - "reqwest 0.12.20", + "reqwest", "thiserror 2.0.12", "tracing", ] @@ -4337,7 +4427,7 @@ checksum = "6fcdab19deb5195a31cf7726a210015ff1496ba1464fd42cb4f537b8b01b471f" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.9.1", + "bitflags", "lazy_static", "num-traits", "rand 0.9.1", @@ -4566,7 +4656,7 @@ version = "11.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6df7ab838ed27997ba19a4664507e6f82b41fe6e20be42929332156e5e85146" dependencies = [ - "bitflags 2.9.1", + "bitflags", ] [[package]] @@ -4581,7 +4671,7 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" dependencies = [ - "bitflags 2.9.1", + "bitflags", ] [[package]] @@ -4656,49 +4746,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", - "hyper-tls 0.5.0", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration 0.5.1", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "reqwest" -version = "0.12.20" +version = "0.12.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813" +checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531" dependencies = [ "base64 0.22.1", "bytes", @@ -4712,7 +4762,7 @@ dependencies = [ "http-body-util", "hyper 1.6.0", "hyper-rustls 0.27.7", - "hyper-tls 0.6.0", + "hyper-tls", "hyper-util", "js-sys", "log", @@ -4722,11 +4772,12 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.28", + "rustls-native-certs 0.8.1", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tokio-native-tls", "tokio-rustls 0.26.2", @@ -4928,7 +4979,7 @@ version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "106fec5c634420118c7d07a6c37110186ae7f23025ceac3a5dbe182eea548363" dependencies = [ - "bitflags 2.9.1", + "bitflags", "revm-bytecode", "revm-primitives", "serde", @@ -5071,7 +5122,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.1", + "bitflags", "errno", "libc", "linux-raw-sys 0.4.15", @@ -5084,7 +5135,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.9.1", + "bitflags", "errno", "libc", "linux-raw-sys 0.9.4", @@ -5306,7 +5357,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.1", + "bitflags", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -5319,7 +5370,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" dependencies = [ - "bitflags 2.9.1", + "bitflags", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -5606,6 +5657,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "signet-orders" +version = "0.1.0" +source = "git+https://github.com/init4tech/signet-orders.git#19ed64770751a9943e0e3f65ebf487c56d70e988" +dependencies = [ + "alloy", + "chrono", + "clap", + "eyre", + "init4-bin-base", + "reqwest", + "signet-bundle", + "signet-constants", + "signet-tx-cache", + "signet-types", + "signet-zenith", + "tokio", + "tracing", +] + [[package]] name = "signet-sim" version = "0.8.1" @@ -5632,7 +5703,7 @@ checksum = "bd54146c10e797e9d9cf6309ebb0e00a1641b551b3c114539a94d625a06537ba" dependencies = [ "alloy", "eyre", - "reqwest 0.12.20", + "reqwest", "serde", "signet-bundle", "signet-types", @@ -5793,12 +5864,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.2" @@ -5819,36 +5884,15 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation 0.9.4", - "system-configuration-sys 0.5.0", -] - [[package]] name = "system-configuration" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.9.1", + "bitflags", "core-foundation 0.9.4", - "system-configuration-sys 0.6.0", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", + "system-configuration-sys", ] [[package]] @@ -6150,7 +6194,7 @@ dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tower-layer", "tower-service", @@ -6163,7 +6207,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" dependencies = [ - "bitflags 2.9.1", + "bitflags", "bytes", "futures-util", "http 1.3.1", @@ -6417,6 +6461,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.17.0" @@ -6718,15 +6768,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -6754,21 +6795,6 @@ dependencies = [ "windows-targets 0.53.2", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" @@ -6801,12 +6827,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -6819,12 +6839,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -6837,12 +6851,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -6867,12 +6875,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -6885,12 +6887,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -6903,12 +6899,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -6921,12 +6911,6 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -6948,23 +6932,13 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wit-bindgen-rt" version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.1", + "bitflags", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 16c758c..53e3d42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,10 @@ path = "bin/builder.rs" name = "transaction-submitter" path = "bin/submit_transaction.rs" +[[bin]] +name = "order-submitter" +path = "bin/submit_order.rs" + [features] integration = [] @@ -33,6 +37,8 @@ signet-tx-cache = { version = "0.8.0" } signet-types = { version = "0.8.0" } signet-zenith = { version = "0.8.0" } +signet-orders = { git = "https://github.com/init4tech/signet-orders.git" } + trevm = { version = "0.27.0", features = ["concurrent-db", "test-utils"] } alloy = { version = "1.0.19", features = [ @@ -51,7 +57,7 @@ serde = { version = "1.0.197", features = ["derive"] } axum = "0.7.5" eyre = "0.6.12" openssl = { version = "0.10", features = ["vendored"] } -reqwest = { version = "0.11.24", features = ["blocking", "json"] } +reqwest = { version = "0.12.22", features = ["blocking", "json"] } serde_json = "1.0" tokio = { version = "1.36.0", features = ["full", "macros", "rt-multi-thread"] } chrono = "0.4.40" diff --git a/README.md b/README.md index 873a32e..9f117a6 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ The previous header's basefee is tracked through the build loop and used for gas ## 📤 Transaction Sender -A binary (`bin/submit-transaction.rs`) for continously sending very small transactions for testing block construction. +A binary (`bin/submit_transaction.rs`) for continously sending very small transactions for testing block construction. The following values are available for configuring the transaction sender: @@ -139,7 +139,7 @@ The following values are available for configuring the transaction sender: | ------------------- | -------- | ------------------------------------------------ | | `RPC_URL` | Yes | RPC endpoint used for sending the transaction | | `RECIPIENT_ADDRESS` | Yes | Address to which the transaction is sent | -| `SLEEP_TIME` | No | Optional delay (in seconds) between transactions | +| `SLEEP_TIME` | Yes | Optional delay (in seconds) between transactions | | `SIGNER_CHAIN_ID` | Yes | Chain ID used for signing | | `SIGNER_KEY` | Yes | Signing key used to sign the transaction | @@ -149,6 +149,22 @@ Run the transaction submitter with `cargo run --bin transaction-submitter` --- +## 📤 Order Submitter + +A binary (`bin/submit_order.rs`) for continuously sending small example orders for testing block construction with fills. + +The following values need to be configured: + +| Key | Required | Description | +| ------------------- | -------- | ------------------------------------------------ | +| `RPC_URL` | Yes | RPC endpoint used for sending the transaction | +| `SEND_TO_ROLLUP` | Yes | Whether to make a rollup order (RU-RU) or host order (RU-HOST) | +| `SLEEP_TIME` | Yes | Optional delay (in seconds) between transactions | +| `SIGNER_CHAIN_ID` | Yes | Chain ID used for signing | +| `SIGNER_KEY` | Yes | Signing key used to sign the transaction | + +Run the order submitter with `cargo run --bin order-submitter` + ## 🛠️ Development ### Requirements diff --git a/bin/submit_order.rs b/bin/submit_order.rs new file mode 100644 index 0000000..02f4cfc --- /dev/null +++ b/bin/submit_order.rs @@ -0,0 +1,140 @@ +use alloy::{ + consensus::constants::GWEI_TO_WEI, + primitives::{Address, U256}, + signers::Signer, +}; +use chrono::Utc; +use init4_bin_base::{ + deps::tracing::{debug, info, instrument}, + utils::{from_env::FromEnv, signer::LocalOrAws, tracing::init_tracing}, +}; +use orders::{ + filler::{Filler, FillerConfig}, + order::SendOrder, + provider::{TxSenderProvider, connect_provider}, +}; +use signet_types::SignedOrder; +use signet_zenith::RollupOrders::{Input, Order, Output}; +use tokio::time::{Duration, sleep}; + +#[derive(Debug, FromEnv)] +struct OrdersArgs { + /// If present, the order will be filled on the rollup chain. + /// If absent, the order will be filled on the host chain. + #[from_env( + var = "SEND_TO_ROLLUP", + desc = "Whether to send the order to rollup or host. If true, it will be a RU-RU order. Else, it'll be a RU-HOST order." + )] + pub send_to_rollup: bool, + #[from_env(var = "SLEEP_TIME", desc = "Time to sleep between transactions, in ms")] + sleep_time: u64, +} + +/// Construct, sign, and send a Signet Order, then Fill the same Order. +#[tokio::main] +async fn main() -> eyre::Result<()> { + init_tracing(); + + let config = FillerConfig::from_env()?; + let OrdersArgs { send_to_rollup, sleep_time } = OrdersArgs::from_env()?; + + let signer = config.signer_config.connect().await?; + let provider = connect_provider(signer.clone(), config.ru_rpc_url.clone()).await?; + info!(signer_address = %signer.address(), "Connected to Signer and Provider"); + + loop { + let example_order = get_example_order(&config, signer.address(), send_to_rollup); + + let signed = send_order(example_order, &signer, &config).await?; + debug!(?signed, "Order contents"); + info!("Order signed and sent to transaction cache"); + + sleep(Duration::from_millis(500)).await; + + fill_orders(&signed, signer.clone(), provider.clone(), &config).await?; + info!("Order filled successfully"); + + sleep(Duration::from_millis(sleep_time)).await; + } +} + +/// Constructs an example [`Order`] based on the provided configuration and recipient address. +/// If `rollup` is true, it creates an order that targets the rollup; otherwise, it creates an order that targets the host chain. +fn get_example_order(config: &FillerConfig, recipient: Address, rollup: bool) -> Order { + if rollup { + Order { + inputs: vec![Input { + token: config.constants.rollup().tokens().weth(), + amount: U256::from(GWEI_TO_WEI), + }], + outputs: vec![Output { + token: config.constants.rollup().tokens().weth(), + amount: U256::from(GWEI_TO_WEI), + chainId: config.constants.rollup().chain_id() as u32, + recipient, + }], + deadline: U256::from(Utc::now().timestamp() + (60 * 10)), // 10 minutes from now + } + } else { + Order { + inputs: vec![Input { + token: config.constants.rollup().tokens().weth(), + amount: U256::from(GWEI_TO_WEI), + }], + outputs: vec![Output { + token: config.constants.host().tokens().weth(), + amount: U256::from(GWEI_TO_WEI), + chainId: config.constants.host().chain_id() as u32, + recipient, + }], + deadline: U256::from(Utc::now().timestamp() + (60 * 10)), // 10 minutes from now + } + } +} + +/// Sign and send an order to the transaction cache. +#[instrument(skip(order, signer, config), level = "debug", fields(signer_address = %signer.address()))] +async fn send_order( + order: Order, + signer: &LocalOrAws, + config: &FillerConfig, +) -> eyre::Result { + info!("signing and sending order"); + + let send_order = SendOrder::new(signer.clone(), config.constants.clone())?; + + // sign the order, return it back for comparison + let signed = send_order.sign_order(order).await?; + + // send the signed order to the transaction cache + send_order.send_order(signed.clone()).await?; + + Ok(signed) +} + +/// Fill example [`SignedOrder`]s from the transaction cache. +#[instrument(skip(target_order, signer, provider, config), level = "debug")] +async fn fill_orders( + target_order: &SignedOrder, + signer: LocalOrAws, + provider: TxSenderProvider, + config: &FillerConfig, +) -> eyre::Result<()> { + info!("filling orders from transaction cache"); + let filler = Filler::new(signer, provider, config.constants.clone())?; + + // get all the [`SignedOrder`]s from tx cache + let mut orders: Vec = filler.get_orders().await?; + debug!( + orders = ?orders, + "Queried order contents from transaction cache" + ); + + // Retain only the orders that match the target order + orders.retain(|o| o == target_order); + + // fill each individually + filler.fill_individually(orders.as_slice()).await?; + + Ok(()) +} diff --git a/src/lib.rs b/src/lib.rs index 8eab8d0..10b3717 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,3 +32,4 @@ pub mod test_utils; // Anonymous import suppresses warnings about unused imports. use openssl as _; +use orders as _; From 52b27e531b53d21964980c53a499b7b8556af15c Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 5 Aug 2025 12:54:06 +0200 Subject: [PATCH 2/2] stuff --- README.md | 4 ++-- bin/submit_order.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9f117a6..2164c0f 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ The following values are available for configuring the transaction sender: | ------------------- | -------- | ------------------------------------------------ | | `RPC_URL` | Yes | RPC endpoint used for sending the transaction | | `RECIPIENT_ADDRESS` | Yes | Address to which the transaction is sent | -| `SLEEP_TIME` | Yes | Optional delay (in seconds) between transactions | +| `SLEEP_TIME` | Yes | Optional delay (in ms) between transactions | | `SIGNER_CHAIN_ID` | Yes | Chain ID used for signing | | `SIGNER_KEY` | Yes | Signing key used to sign the transaction | @@ -159,7 +159,7 @@ The following values need to be configured: | ------------------- | -------- | ------------------------------------------------ | | `RPC_URL` | Yes | RPC endpoint used for sending the transaction | | `SEND_TO_ROLLUP` | Yes | Whether to make a rollup order (RU-RU) or host order (RU-HOST) | -| `SLEEP_TIME` | Yes | Optional delay (in seconds) between transactions | +| `SLEEP_TIME` | Yes | Optional delay (in ms) between transactions | | `SIGNER_CHAIN_ID` | Yes | Chain ID used for signing | | `SIGNER_KEY` | Yes | Signing key used to sign the transaction | diff --git a/bin/submit_order.rs b/bin/submit_order.rs index 02f4cfc..708fae1 100644 --- a/bin/submit_order.rs +++ b/bin/submit_order.rs @@ -19,8 +19,8 @@ use tokio::time::{Duration, sleep}; #[derive(Debug, FromEnv)] struct OrdersArgs { - /// If present, the order will be filled on the rollup chain. - /// If absent, the order will be filled on the host chain. + /// If true, the order will be filled on the rollup chain. + /// else, it will be filled on the host chain. #[from_env( var = "SEND_TO_ROLLUP", desc = "Whether to send the order to rollup or host. If true, it will be a RU-RU order. Else, it'll be a RU-HOST order."