From 231b850574c348059e63488d1bf9635dfe166dbe Mon Sep 17 00:00:00 2001 From: akhercha Date: Thu, 31 Oct 2024 20:28:37 +0100 Subject: [PATCH 01/55] dev(better_theoros): init --- README.md | 30 +- rust/Cargo.lock | 536 +- rust/Cargo.toml | 3 +- rust/pragma-cli/.private.seed.example | 1 - rust/pragma-cli/Cargo.toml | 37 - rust/pragma-cli/src/cli/list.rs | 17 - rust/pragma-cli/src/cli/mod.rs | 5 - rust/pragma-cli/src/cli/schedule.rs | 24 - rust/pragma-cli/src/cli/types.rs | 47 - rust/pragma-cli/src/lib.rs | 3 - rust/pragma-cli/src/main.rs | 58 - rust/pragma-cli/src/runtimes/README.md | 21 - .../src/runtimes/artifacts/madara_metadata.rs | 8131 ----------------- .../runtimes/artifacts/madara_metadata.scale | Bin 40937 -> 0 bytes rust/pragma-cli/src/runtimes/mod.rs | 1 - rust/pragma-cli/src/runtimes/support.rs | 33 - rust/pragma-cli/src/utils/constants.rs | 2 - rust/pragma-cli/src/utils/mod.rs | 1 - rust/rust-toolchain.toml | 2 +- rust/theoros/src/configs/evm_config.rs | 30 - rust/theoros/src/main.rs | 45 +- rust/theoros/src/rpc/evm/mod.rs | 4 - rust/theoros/src/services/hyperlane/mod.rs | 3 +- rust/theoros/src/services/indexer/mod.rs | 6 +- rust/theoros/src/storage/event.rs | 41 - rust/theoros/src/storage/feed_id.rs | 25 - rust/theoros/src/storage/mod.rs | 13 +- rust/theoros/src/storage/validator.rs | 10 - rust/theoros/src/types/calldata.rs | 2 +- .../hyperlane/checkpoint_fetchers/mod.rs | 2 + .../types/hyperlane/events/dispatch_event.rs | 17 +- rust/theoros/src/types/mod.rs | 1 + rust/theoros/src/types/state.rs | 30 + 33 files changed, 95 insertions(+), 9086 deletions(-) delete mode 100644 rust/pragma-cli/.private.seed.example delete mode 100644 rust/pragma-cli/Cargo.toml delete mode 100644 rust/pragma-cli/src/cli/list.rs delete mode 100644 rust/pragma-cli/src/cli/mod.rs delete mode 100644 rust/pragma-cli/src/cli/schedule.rs delete mode 100644 rust/pragma-cli/src/cli/types.rs delete mode 100644 rust/pragma-cli/src/lib.rs delete mode 100644 rust/pragma-cli/src/main.rs delete mode 100644 rust/pragma-cli/src/runtimes/README.md delete mode 100644 rust/pragma-cli/src/runtimes/artifacts/madara_metadata.rs delete mode 100644 rust/pragma-cli/src/runtimes/artifacts/madara_metadata.scale delete mode 100644 rust/pragma-cli/src/runtimes/mod.rs delete mode 100644 rust/pragma-cli/src/runtimes/support.rs delete mode 100644 rust/pragma-cli/src/utils/constants.rs delete mode 100644 rust/pragma-cli/src/utils/mod.rs create mode 100644 rust/theoros/src/types/state.rs diff --git a/README.md b/README.md index e7ab2e8d..b1b6d0b7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Pragma +# Pragma V2 [![GitHub Actions][gha-badge]][gha] [![codecov](https://codecov.io/gh/astraly-labs/pragma-monorepo/branch/main/graph/badge.svg?)](https://codecov.io/gh/astraly-labs/pragma-monorepo) [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license] @@ -12,14 +12,6 @@ ## Rust -Pragma CLI - -CLI used to interact with the Pragma protocol. - -- Register yourself as a data provider -- Schedule new data feeds -- Connect pragma to your protocol - Theoros Request the API to construct the calldata necessary for cross-chain updates. @@ -37,22 +29,6 @@ Solidity contracts & libraries. - Set of contracts used to store data relayed from Pragma chain using Hyperlane. - SDK that can be used by EVM protocols looking to integrate Pragma. -## Local Development - -### Foundry - -First ensure you have Foundry installed on your machine. - -Run the following to install `foundryup`: - -```bash -curl -L https://foundry.paradigm.xyz | bash -``` - -Then run `foundryup` to install `forge`, `cast`, `anvil` and `chisel`. - -```bash -foundryup -``` +## Typescript -Check out the [Foundry Book](https://book.getfoundry.sh/getting-started/installation) for more information. +(TODO: akhercha) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 97d324b7..59b127bf 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -109,7 +109,7 @@ dependencies = [ "alloy-serde", "auto_impl", "c-kzg", - "derive_more 1.0.0", + "derive_more", "serde", ] @@ -199,7 +199,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "c-kzg", - "derive_more 1.0.0", + "derive_more", "once_cell", "serde", "sha2 0.10.8", @@ -286,7 +286,7 @@ dependencies = [ "bytes", "cfg-if", "const-hex", - "derive_more 1.0.0", + "derive_more", "hashbrown 0.14.5", "hex-literal", "indexmap 2.6.0", @@ -434,7 +434,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-serde", - "derive_more 1.0.0", + "derive_more", "serde", "strum", ] @@ -452,7 +452,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", - "derive_more 1.0.0", + "derive_more", "itertools 0.13.0", "serde", "serde_json", @@ -939,12 +939,6 @@ dependencies = [ "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" @@ -1223,50 +1217,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "bollard" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41711ad46fda47cd701f6908e59d1bd6b9a2b7464c0d0aeab95c6d37096ff8a" -dependencies = [ - "base64 0.22.1", - "bollard-stubs", - "bytes", - "futures-core", - "futures-util", - "hex", - "http 1.1.0", - "http-body-util", - "hyper 1.4.1", - "hyper-named-pipe", - "hyper-util", - "hyperlocal", - "log", - "pin-project-lite", - "serde", - "serde_derive", - "serde_json", - "serde_repr", - "serde_urlencoded", - "thiserror", - "tokio", - "tokio-util", - "tower-service", - "url", - "winapi", -] - -[[package]] -name = "bollard-stubs" -version = "1.45.0-rc.26.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7c5415e3a6bc6d3e99eff6268e488fd4ee25e7b28c10f08fa6760bd9de16e4" -dependencies = [ - "serde", - "serde_repr", - "serde_with 3.9.0", -] - [[package]] name = "bumpalo" version = "3.16.0" @@ -1314,8 +1264,6 @@ version = "1.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" dependencies = [ - "jobserver", - "libc", "shlex", ] @@ -1464,31 +1412,6 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" -[[package]] -name = "crossterm" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" -dependencies = [ - "bitflags 1.3.2", - "crossterm_winapi", - "libc", - "mio 0.8.11", - "parking_lot", - "signal-hook", - "signal-hook-mio", - "winapi", -] - -[[package]] -name = "crossterm_winapi" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" -dependencies = [ - "winapi", -] - [[package]] name = "crunchy" version = "0.2.2" @@ -1646,17 +1569,6 @@ dependencies = [ "syn 2.0.75", ] -[[package]] -name = "derive_more" -version = "0.99.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.75", -] - [[package]] name = "derive_more" version = "1.0.0" @@ -1699,15 +1611,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs-next" version = "2.0.0" @@ -1718,18 +1621,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1776,12 +1667,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" -[[package]] -name = "dyn-clone" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" - [[package]] name = "ecdsa" version = "0.16.9" @@ -1830,29 +1715,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_filter" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - [[package]] name = "envy" version = "0.4.2" @@ -1937,16 +1799,6 @@ dependencies = [ "uint", ] -[[package]] -name = "eyre" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" -dependencies = [ - "indenter", - "once_cell", -] - [[package]] name = "fastrand" version = "2.1.0" @@ -2149,24 +2001,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" -[[package]] -name = "fuzzy-matcher" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" -dependencies = [ - "thread_local", -] - -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -2197,21 +2031,6 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" -[[package]] -name = "git2" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" -dependencies = [ - "bitflags 2.6.0", - "libc", - "libgit2-sys", - "log", - "openssl-probe", - "openssl-sys", - "url", -] - [[package]] name = "glob" version = "0.3.1" @@ -2268,25 +2087,6 @@ dependencies = [ "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.6.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -2477,7 +2277,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.26", + "h2", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -2500,7 +2300,6 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -2512,21 +2311,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-named-pipe" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278" -dependencies = [ - "hex", - "hyper 1.4.1", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", - "winapi", -] - [[package]] name = "hyper-rustls" version = "0.24.2" @@ -2622,21 +2406,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "hyperlocal" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "986c5ce3b994526b3cd75578e62554abd09f0899d6206de48b3e96ab34ccc8c7" -dependencies = [ - "hex", - "http-body-util", - "hyper 1.4.1", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", -] - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -2714,12 +2483,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - [[package]] name = "indexmap" version = "1.9.3" @@ -2751,23 +2514,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "inquire" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a" -dependencies = [ - "bitflags 2.6.0", - "crossterm", - "dyn-clone", - "fuzzy-matcher", - "fxhash", - "newline-converter", - "once_cell", - "unicode-segmentation", - "unicode-width", -] - [[package]] name = "interprocess" version = "2.2.1" @@ -2828,15 +2574,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "jobserver" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.70" @@ -2912,20 +2649,6 @@ version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" -[[package]] -name = "libgit2-sys" -version = "0.17.0+1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" -dependencies = [ - "cc", - "libc", - "libssh2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", -] - [[package]] name = "libm" version = "0.2.8" @@ -2942,32 +2665,6 @@ dependencies = [ "libc", ] -[[package]] -name = "libssh2-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "libz-sys" -version = "1.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc53a7799a7496ebc9fd29f31f7df80e83c9bda5299768af5f9e59eeea74647" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -3065,18 +2762,6 @@ dependencies = [ "adler2", ] -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.0.2" @@ -3112,15 +2797,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "newline-converter" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b6b097ecb1cbfed438542d16e84fd7ad9b0c76c8a65b7f9039212a3d14dc7f" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "no-std-compat" version = "0.4.1" @@ -3398,12 +3074,6 @@ dependencies = [ "tokio-stream", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "ordered-float" version = "4.2.2" @@ -3626,38 +3296,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "pragma-cli" -version = "0.1.0" -dependencies = [ - "alloy", - "anyhow", - "bollard", - "clap", - "dirs", - "env_logger", - "eyre", - "futures-util", - "git2", - "hex", - "inquire", - "parity-scale-codec", - "pragma-utils", - "rand", - "reqwest 0.12.7", - "scale-info", - "serde", - "serde_json", - "starknet 0.11.0", - "strum", - "strum_macros", - "thiserror", - "tokio", - "toml", - "tracing", - "url", -] - [[package]] name = "pragma-feeds" version = "0.1.0" @@ -3726,7 +3364,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit 0.21.1", + "toml_edit", ] [[package]] @@ -4139,7 +3777,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.3.26", + "h2", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", @@ -4157,7 +3795,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 0.1.2", - "system-configuration 0.5.1", + "system-configuration", "tokio", "tokio-rustls 0.24.1", "tower-service", @@ -4177,11 +3815,9 @@ checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64 0.22.1", "bytes", - "encoding_rs", "futures-channel", "futures-core", "futures-util", - "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "http-body-util", @@ -4205,7 +3841,6 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 1.0.1", - "system-configuration 0.6.1", "tokio", "tokio-native-tls", "tokio-rustls 0.26.0", @@ -4588,18 +4223,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scale-info" -version = "2.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" -dependencies = [ - "bitvec", - "cfg-if", - "derive_more 0.99.18", - "parity-scale-codec", -] - [[package]] name = "schannel" version = "0.1.23" @@ -4774,26 +4397,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_repr" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.75", -] - -[[package]] -name = "serde_spanned" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -4822,23 +4425,6 @@ dependencies = [ "time", ] -[[package]] -name = "serde_with" -version = "3.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" -dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.6.0", - "serde", - "serde_derive", - "serde_json", - "time", -] - [[package]] name = "serde_with_macros" version = "2.3.3" @@ -4934,27 +4520,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "signal-hook" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-mio" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" -dependencies = [ - "libc", - "mio 0.8.11", - "signal-hook", -] - [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -5089,7 +4654,7 @@ source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=7153d0e42#7153d0e4 dependencies = [ "serde", "serde_json", - "serde_with 2.3.3", + "serde_with", "starknet-accounts 0.9.0", "starknet-core 0.10.0", "starknet-providers 0.10.0", @@ -5104,7 +4669,7 @@ checksum = "a5f91344f1e0b81873b6dc235c50ae4d084c6ea4dd4a1e3e27ad895803adb610" dependencies = [ "serde", "serde_json", - "serde_with 2.3.3", + "serde_with", "starknet-accounts 0.10.0", "starknet-core 0.11.1", "starknet-providers 0.11.0", @@ -5122,7 +4687,7 @@ dependencies = [ "serde", "serde_json", "serde_json_pythonic", - "serde_with 2.3.3", + "serde_with", "sha3", "starknet-crypto 0.6.2", "starknet-ff", @@ -5141,7 +4706,7 @@ dependencies = [ "serde", "serde_json", "serde_json_pythonic", - "serde_with 2.3.3", + "serde_with", "sha3", "starknet-crypto 0.7.1", "starknet-types-core", @@ -5270,7 +4835,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "serde_with 2.3.3", + "serde_with", "starknet-core 0.10.0", "thiserror", "url", @@ -5291,7 +4856,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "serde_with 2.3.3", + "serde_with", "starknet-core 0.11.1", "thiserror", "url", @@ -5440,18 +5005,7 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", "core-foundation", - "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.6.0", - "core-foundation", - "system-configuration-sys 0.6.0", + "system-configuration-sys", ] [[package]] @@ -5464,16 +5018,6 @@ dependencies = [ "libc", ] -[[package]] -name = "system-configuration-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tame-gcs" version = "0.10.0" @@ -5661,7 +5205,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.2", + "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -5775,26 +5319,11 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.8.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.22.20", -] - [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -dependencies = [ - "serde", -] [[package]] name = "toml_edit" @@ -5807,19 +5336,6 @@ dependencies = [ "winnow 0.5.40", ] -[[package]] -name = "toml_edit" -version = "0.22.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" -dependencies = [ - "indexmap 2.6.0", - "serde", - "serde_spanned", - "toml_datetime", - "winnow 0.6.18", -] - [[package]] name = "tonic" version = "0.9.2" @@ -5833,7 +5349,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "h2 0.3.26", + "h2", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", @@ -5863,7 +5379,7 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "h2 0.3.26", + "h2", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", @@ -5894,7 +5410,7 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "h2 0.3.26", + "h2", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", @@ -6224,18 +5740,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" - -[[package]] -name = "unicode-width" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" - [[package]] name = "unicode-xid" version = "0.2.6" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 8c556bab..50d357e1 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["pragma-cli", "theoros", "pragma-utils", "pragma-feeds"] +members = ["theoros", "pragma-utils", "pragma-feeds"] [workspace.package] version = "0.1.0" @@ -88,7 +88,6 @@ apibara-sdk = { git = "https://github.com/apibara/dna", rev = "9caa385" } # Pragma packages pragma-utils = { path = "pragma-utils" } pragma-feeds = { path = "pragma-feeds" } -pragma-cli = { path = "pragma-cli" } theoros = { path = "theoros" } # Tests dependencies diff --git a/rust/pragma-cli/.private.seed.example b/rust/pragma-cli/.private.seed.example deleted file mode 100644 index b184776c..00000000 --- a/rust/pragma-cli/.private.seed.example +++ /dev/null @@ -1 +0,0 @@ -write your private seed here to sign the transactions \ No newline at end of file diff --git a/rust/pragma-cli/Cargo.toml b/rust/pragma-cli/Cargo.toml deleted file mode 100644 index 0609d3be..00000000 --- a/rust/pragma-cli/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -name = "pragma-cli" -version = "0.1.0" -edition = "2021" - -[[bin]] -name = "pragma" -path = "src/main.rs" - -[dependencies] -alloy = { workspace = true } -anyhow = { workspace = true } -bollard = { workspace = true } -clap = { workspace = true } -dirs = { workspace = true } -env_logger = { workspace = true } -eyre = { workspace = true } -futures-util = { workspace = true } -git2 = { workspace = true } -hex = { workspace = true } -inquire = { workspace = true } -rand = { workspace = true } -reqwest = { workspace = true } -scale = { workspace = true } -scale-info = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -starknet = { workspace = true } -strum = { workspace = true } -strum_macros = { workspace = true } -thiserror = { workspace = true } -tokio = { workspace = true } -toml = { workspace = true } -tracing = { workspace = true } -url = { workspace = true } - -pragma-utils = { path = "../pragma-utils" } diff --git a/rust/pragma-cli/src/cli/list.rs b/rust/pragma-cli/src/cli/list.rs deleted file mode 100644 index 3140e16d..00000000 --- a/rust/pragma-cli/src/cli/list.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::utils::constants::DATA_FEEDS; - -pub fn list() { - match get_data_feed_list() { - Ok(feeds) => { - tracing::info!("Data Feeds available: {:?}", feeds); - } - Err(err) => { - panic!("Failed to list: {}", err); - } - } -} - -fn get_data_feed_list() -> Result, Box> { - let data_feeds = DATA_FEEDS.iter().map(|x| x.to_string()).collect(); - Ok(data_feeds) -} diff --git a/rust/pragma-cli/src/cli/mod.rs b/rust/pragma-cli/src/cli/mod.rs deleted file mode 100644 index c0cbaa16..00000000 --- a/rust/pragma-cli/src/cli/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod list; - -pub mod schedule; - -pub mod types; diff --git a/rust/pragma-cli/src/cli/schedule.rs b/rust/pragma-cli/src/cli/schedule.rs deleted file mode 100644 index d225536d..00000000 --- a/rust/pragma-cli/src/cli/schedule.rs +++ /dev/null @@ -1,24 +0,0 @@ -use super::types::DataFeed; - -pub async fn schedule(rpc_url: &Option, frequency: &Option, data_feed: &DataFeed) { - let rpc_url = rpc_url.as_deref().unwrap_or("ws://127.0.0.1:9944"); - let frequency = frequency.unwrap_or(10); - - match schedule_data_feed(rpc_url, &frequency, data_feed).await { - Ok(_) => { - tracing::info!("Data Feed successfully scheduled!"); - } - Err(err) => { - tracing::error!("Failed to schedule the given data feed: {}", err); - } - } -} - -async fn schedule_data_feed( - _rpc_url: &str, - frequency: &u128, - data_feed: &DataFeed, -) -> Result<(), Box> { - tracing::info!("Scheduling data feed with frequency: {}, data feed: {:?}", frequency, data_feed); - Ok(()) -} diff --git a/rust/pragma-cli/src/cli/types.rs b/rust/pragma-cli/src/cli/types.rs deleted file mode 100644 index 6687881c..00000000 --- a/rust/pragma-cli/src/cli/types.rs +++ /dev/null @@ -1,47 +0,0 @@ -use serde::{Deserialize, Serialize}; -use starknet::core::{types::Felt, utils::cairo_short_string_to_felt}; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct DataFeed { - pub assets: Vec, - pub contract_address: String, - pub selector: String, - pub calldata: Vec, -} - -impl DataFeed { - pub fn new(assets: Vec, contract_address: String, selector: String) -> Self { - let calldata = assets.iter().map(|a| cairo_short_string_to_felt(a).unwrap()).collect(); - Self { assets, contract_address, selector, calldata } - } -} - -pub trait HasSelector { - fn to_selector(&self) -> String; -} - -pub enum AggregationMode { - Median, - Mean, -} - -pub enum StateUpdate { - Checkpoint, -} - -impl HasSelector for AggregationMode { - fn to_selector(&self) -> String { - match self { - AggregationMode::Median => "0x00".to_string(), - AggregationMode::Mean => "0x01".to_string(), - } - } -} - -impl HasSelector for StateUpdate { - fn to_selector(&self) -> String { - match self { - StateUpdate::Checkpoint => "0x0270c07fa4205f06222fb499351ee48b50054a57b9599b4a462ea03b8e2b84d5".to_string(), - } - } -} diff --git a/rust/pragma-cli/src/lib.rs b/rust/pragma-cli/src/lib.rs deleted file mode 100644 index 88a2fcae..00000000 --- a/rust/pragma-cli/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod cli; -pub mod runtimes; -pub mod utils; diff --git a/rust/pragma-cli/src/main.rs b/rust/pragma-cli/src/main.rs deleted file mode 100644 index fe084389..00000000 --- a/rust/pragma-cli/src/main.rs +++ /dev/null @@ -1,58 +0,0 @@ -use anyhow::Result; -use clap::{Parser, Subcommand}; -use pragma_utils::tracing::init_tracing; -use tracing::Level; - -use pragma_cli::{ - cli::{ - self, - types::{DataFeed, HasSelector, StateUpdate}, - }, - utils::constants::ORACLE_ADDRESS, -}; - -#[derive(Parser)] -#[command(author, version, about, long_about = None)] -struct Cli { - #[command(subcommand)] - command: Option, -} - -#[derive(Subcommand)] -enum Commands { - /// Lists all the existing data feeds - List, - /// Schedule a new data feed automation - Schedule { - /// RPC Url for the Madara node - #[clap(short, long = "rpc-url")] - rpc_url: Option, - /// Frequency of updates in blocks - #[clap(short)] - frequency: Option, - /// Assets to be included in the data feed - #[clap(short)] - assets: Vec, - /// Data feed name - #[clap(short, long = "data-feed-name")] - data_feed_name: String, - }, -} - -#[tokio::main] -async fn main() -> Result<()> { - init_tracing("pragma-cli", Level::INFO)?; - - let cli = Cli::parse(); - match &cli.command { - Some(Commands::List) => cli::list::list(), - Some(Commands::Schedule { rpc_url, frequency, assets, data_feed_name: _ }) => { - let data_feed = - DataFeed::new(assets.to_vec(), ORACLE_ADDRESS.to_string(), StateUpdate::Checkpoint.to_selector()); - cli::schedule::schedule(rpc_url, frequency, &data_feed).await - } - None => tracing::info!("Use --help to see the complete list of available commands"), - } - - Ok(()) -} diff --git a/rust/pragma-cli/src/runtimes/README.md b/rust/pragma-cli/src/runtimes/README.md deleted file mode 100644 index 67f8fbe6..00000000 --- a/rust/pragma-cli/src/runtimes/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Supported Runtimes - -- Sharingan - -TODO: Improve the runtimes implementation without the need of replicating -the same functions for each runtime. Note that _RuntimeApi_ is runtime -specific. It gives access to api functions specific for each runtime. - -## Generated files from subxt-cli - -Download metadata from a substrate node, for use with `subxt` codegen. - -```bash -subxt metadata --url ws://127.0.0.1:9944 -f bytes > madara_metadata.scale -``` - -Generate runtime API client code from metadata. - -```bash -subxt codegen --url ws://127.0.0.1:9944 | rustfmt --edition=2018 --emit=stdout > madara_metadata.rs -``` diff --git a/rust/pragma-cli/src/runtimes/artifacts/madara_metadata.rs b/rust/pragma-cli/src/runtimes/artifacts/madara_metadata.rs deleted file mode 100644 index 7a6a8f15..00000000 --- a/rust/pragma-cli/src/runtimes/artifacts/madara_metadata.rs +++ /dev/null @@ -1,8131 +0,0 @@ -#[allow(dead_code, unused_imports, non_camel_case_types)] -#[allow(clippy::all)] -#[allow(rustdoc::broken_intra_doc_links)] -pub mod api { - #[allow(unused_imports)] - mod root_mod { - pub use super::*; - } - pub static PALLETS: [&str; 6usize] = ["System", "Timestamp", "Aura", "Grandpa", "Starknet", "Autonomous"]; - pub static RUNTIME_APIS: [&str; 11usize] = [ - "Core", - "Metadata", - "BlockBuilder", - "TaggedTransactionQueue", - "OffchainWorkerApi", - "AuraApi", - "SessionKeys", - "GrandpaApi", - "AccountNonceApi", - "StarknetRuntimeApi", - "ConvertTransactionRuntimeApi", - ]; - #[doc = r" The error type returned when there is a runtime issue."] - pub type DispatchError = runtime_types::sp_runtime::DispatchError; - #[doc = r" The outer event enum."] - pub type Event = runtime_types::madara_runtime::RuntimeEvent; - #[doc = r" The outer extrinsic enum."] - pub type Call = runtime_types::madara_runtime::RuntimeCall; - #[doc = r" The outer error enum representing the DispatchError's Module variant."] - pub type Error = runtime_types::madara_runtime::RuntimeError; - pub fn constants() -> ConstantsApi { - ConstantsApi - } - pub fn storage() -> StorageApi { - StorageApi - } - pub fn tx() -> TransactionApi { - TransactionApi - } - pub fn apis() -> runtime_apis::RuntimeApi { - runtime_apis::RuntimeApi - } - pub mod runtime_apis { - use super::root_mod; - use super::runtime_types; - use ::subxt::ext::codec::Encode; - pub struct RuntimeApi; - impl RuntimeApi { - pub fn core(&self) -> core::Core { - core::Core - } - pub fn metadata(&self) -> metadata::Metadata { - metadata::Metadata - } - pub fn block_builder(&self) -> block_builder::BlockBuilder { - block_builder::BlockBuilder - } - pub fn tagged_transaction_queue(&self) -> tagged_transaction_queue::TaggedTransactionQueue { - tagged_transaction_queue::TaggedTransactionQueue - } - pub fn offchain_worker_api(&self) -> offchain_worker_api::OffchainWorkerApi { - offchain_worker_api::OffchainWorkerApi - } - pub fn aura_api(&self) -> aura_api::AuraApi { - aura_api::AuraApi - } - pub fn session_keys(&self) -> session_keys::SessionKeys { - session_keys::SessionKeys - } - pub fn grandpa_api(&self) -> grandpa_api::GrandpaApi { - grandpa_api::GrandpaApi - } - pub fn account_nonce_api(&self) -> account_nonce_api::AccountNonceApi { - account_nonce_api::AccountNonceApi - } - pub fn starknet_runtime_api(&self) -> starknet_runtime_api::StarknetRuntimeApi { - starknet_runtime_api::StarknetRuntimeApi - } - pub fn convert_transaction_runtime_api( - &self, - ) -> convert_transaction_runtime_api::ConvertTransactionRuntimeApi { - convert_transaction_runtime_api::ConvertTransactionRuntimeApi - } - } - pub mod core { - use super::root_mod; - use super::runtime_types; - #[doc = " The `Core` runtime api that every Substrate runtime needs to implement."] - pub struct Core; - impl Core { - #[doc = " Returns the version of the runtime."] - pub fn version(&self) -> ::subxt::runtime_api::Payload { - ::subxt::runtime_api::Payload::new_static( - "Core", - "version", - types::Version {}, - [ - 76u8, 202u8, 17u8, 117u8, 189u8, 237u8, 239u8, 237u8, 151u8, 17u8, 125u8, 159u8, 218u8, - 92u8, 57u8, 238u8, 64u8, 147u8, 40u8, 72u8, 157u8, 116u8, 37u8, 195u8, 156u8, 27u8, 123u8, - 173u8, 178u8, 102u8, 136u8, 6u8, - ], - ) - } - #[doc = " Execute the given block."] - pub fn execute_block( - &self, - block: types::execute_block::Block, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "Core", - "execute_block", - types::ExecuteBlock { block }, - [ - 133u8, 135u8, 228u8, 65u8, 106u8, 27u8, 85u8, 158u8, 112u8, 254u8, 93u8, 26u8, 102u8, - 201u8, 118u8, 216u8, 249u8, 247u8, 91u8, 74u8, 56u8, 208u8, 231u8, 115u8, 131u8, 29u8, - 209u8, 6u8, 65u8, 57u8, 214u8, 125u8, - ], - ) - } - #[doc = " Initialize a block with the given header."] - pub fn initialize_block( - &self, - header: types::initialize_block::Header, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "Core", - "initialize_block", - types::InitializeBlock { header }, - [ - 146u8, 138u8, 72u8, 240u8, 63u8, 96u8, 110u8, 189u8, 77u8, 92u8, 96u8, 232u8, 41u8, 217u8, - 105u8, 148u8, 83u8, 190u8, 152u8, 219u8, 19u8, 87u8, 163u8, 1u8, 232u8, 25u8, 221u8, 74u8, - 224u8, 67u8, 223u8, 34u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod version { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::sp_version::RuntimeVersion; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Version {} - pub mod execute_block { - use super::runtime_types; - pub type Block = runtime_types::sp_runtime::generic::block::Block< - runtime_types::sp_runtime::generic::header::Header<::core::primitive::u32>, - ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >, - >; - pub mod output { - use super::runtime_types; - pub type Output = (); - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ExecuteBlock { - pub block: execute_block::Block, - } - pub mod initialize_block { - use super::runtime_types; - pub type Header = runtime_types::sp_runtime::generic::header::Header<::core::primitive::u32>; - pub mod output { - use super::runtime_types; - pub type Output = (); - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct InitializeBlock { - pub header: initialize_block::Header, - } - } - } - pub mod metadata { - use super::root_mod; - use super::runtime_types; - #[doc = " The `Metadata` api trait that returns metadata for the runtime."] - pub struct Metadata; - impl Metadata { - #[doc = " Returns the metadata of a runtime."] - pub fn metadata( - &self, - ) -> ::subxt::runtime_api::Payload { - ::subxt::runtime_api::Payload::new_static( - "Metadata", - "metadata", - types::Metadata {}, - [ - 231u8, 24u8, 67u8, 152u8, 23u8, 26u8, 188u8, 82u8, 229u8, 6u8, 185u8, 27u8, 175u8, 68u8, - 83u8, 122u8, 69u8, 89u8, 185u8, 74u8, 248u8, 87u8, 217u8, 124u8, 193u8, 252u8, 199u8, - 186u8, 196u8, 179u8, 179u8, 96u8, - ], - ) - } - #[doc = " Returns the metadata at a given version."] - #[doc = ""] - #[doc = " If the given `version` isn't supported, this will return `None`."] - #[doc = " Use [`Self::metadata_versions`] to find out about supported metadata version of the runtime."] - pub fn metadata_at_version( - &self, - version: types::metadata_at_version::Version, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "Metadata", - "metadata_at_version", - types::MetadataAtVersion { version }, - [ - 131u8, 53u8, 212u8, 234u8, 16u8, 25u8, 120u8, 252u8, 153u8, 153u8, 216u8, 28u8, 54u8, - 113u8, 52u8, 236u8, 146u8, 68u8, 142u8, 8u8, 10u8, 169u8, 131u8, 142u8, 204u8, 38u8, 48u8, - 108u8, 134u8, 86u8, 226u8, 61u8, - ], - ) - } - #[doc = " Returns the supported metadata versions."] - #[doc = ""] - #[doc = " This can be used to call `metadata_at_version`."] - pub fn metadata_versions( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "Metadata", - "metadata_versions", - types::MetadataVersions {}, - [ - 23u8, 144u8, 137u8, 91u8, 188u8, 39u8, 231u8, 208u8, 252u8, 218u8, 224u8, 176u8, 77u8, - 32u8, 130u8, 212u8, 223u8, 76u8, 100u8, 190u8, 82u8, 94u8, 190u8, 8u8, 82u8, 244u8, 225u8, - 179u8, 85u8, 176u8, 56u8, 16u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod metadata { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::sp_core::OpaqueMetadata; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Metadata {} - pub mod metadata_at_version { - use super::runtime_types; - pub type Version = ::core::primitive::u32; - pub mod output { - use super::runtime_types; - pub type Output = ::core::option::Option; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct MetadataAtVersion { - pub version: metadata_at_version::Version, - } - pub mod metadata_versions { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = ::std::vec::Vec<::core::primitive::u32>; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct MetadataVersions {} - } - } - pub mod block_builder { - use super::root_mod; - use super::runtime_types; - #[doc = " The `BlockBuilder` api trait that provides the required functionality for building a block."] - pub struct BlockBuilder; - impl BlockBuilder { - #[doc = " Apply the given extrinsic."] - #[doc = ""] - #[doc = " Returns an inclusion outcome which specifies if this extrinsic is included in"] - #[doc = " this block or not."] - pub fn apply_extrinsic( - &self, - extrinsic: types::apply_extrinsic::Extrinsic, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "BlockBuilder", - "apply_extrinsic", - types::ApplyExtrinsic { extrinsic }, - [ - 72u8, 54u8, 139u8, 3u8, 118u8, 136u8, 65u8, 47u8, 6u8, 105u8, 125u8, 223u8, 160u8, 29u8, - 103u8, 74u8, 79u8, 149u8, 48u8, 90u8, 237u8, 2u8, 97u8, 201u8, 123u8, 34u8, 167u8, 37u8, - 187u8, 35u8, 176u8, 97u8, - ], - ) - } - #[doc = " Finish the current block."] - pub fn finalize_block( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "BlockBuilder", - "finalize_block", - types::FinalizeBlock {}, - [ - 244u8, 207u8, 24u8, 33u8, 13u8, 69u8, 9u8, 249u8, 145u8, 143u8, 122u8, 96u8, 197u8, 55u8, - 64u8, 111u8, 238u8, 224u8, 34u8, 201u8, 27u8, 146u8, 232u8, 99u8, 191u8, 30u8, 114u8, 16u8, - 32u8, 220u8, 58u8, 62u8, - ], - ) - } - #[doc = " Generate inherent extrinsics. The inherent data will vary from chain to chain."] - pub fn inherent_extrinsics( - &self, - inherent: types::inherent_extrinsics::Inherent, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "BlockBuilder", - "inherent_extrinsics", - types::InherentExtrinsics { inherent }, - [ - 254u8, 110u8, 245u8, 201u8, 250u8, 192u8, 27u8, 228u8, 151u8, 213u8, 166u8, 89u8, 94u8, - 81u8, 189u8, 234u8, 64u8, 18u8, 245u8, 80u8, 29u8, 18u8, 140u8, 129u8, 113u8, 236u8, 135u8, - 55u8, 79u8, 159u8, 175u8, 183u8, - ], - ) - } - #[doc = " Check that the inherents are valid. The inherent data will vary from chain to chain."] - pub fn check_inherents( - &self, - block: types::check_inherents::Block, - data: types::check_inherents::Data, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "BlockBuilder", - "check_inherents", - types::CheckInherents { block, data }, - [ - 153u8, 134u8, 1u8, 215u8, 139u8, 11u8, 53u8, 51u8, 210u8, 175u8, 197u8, 28u8, 38u8, 209u8, - 175u8, 247u8, 142u8, 157u8, 50u8, 151u8, 164u8, 191u8, 181u8, 118u8, 80u8, 97u8, 160u8, - 248u8, 110u8, 217u8, 181u8, 234u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod apply_extrinsic { - use super::runtime_types; - pub type Extrinsic = ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - ::core::result::Result<(), runtime_types::sp_runtime::DispatchError>, - runtime_types::sp_runtime::transaction_validity::TransactionValidityError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ApplyExtrinsic { - pub extrinsic: apply_extrinsic::Extrinsic, - } - pub mod finalize_block { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::sp_runtime::generic::header::Header<::core::primitive::u32>; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct FinalizeBlock {} - pub mod inherent_extrinsics { - use super::runtime_types; - pub type Inherent = runtime_types::sp_inherents::InherentData; - pub mod output { - use super::runtime_types; - pub type Output = ::std::vec::Vec< - ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct InherentExtrinsics { - pub inherent: inherent_extrinsics::Inherent, - } - pub mod check_inherents { - use super::runtime_types; - pub type Block = runtime_types::sp_runtime::generic::block::Block< - runtime_types::sp_runtime::generic::header::Header<::core::primitive::u32>, - ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >, - >; - pub type Data = runtime_types::sp_inherents::InherentData; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::sp_inherents::CheckInherentsResult; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckInherents { - pub block: check_inherents::Block, - pub data: check_inherents::Data, - } - } - } - pub mod tagged_transaction_queue { - use super::root_mod; - use super::runtime_types; - #[doc = " The `TaggedTransactionQueue` api trait for interfering with the transaction queue."] - pub struct TaggedTransactionQueue; - impl TaggedTransactionQueue { - #[doc = " Validate the transaction."] - #[doc = ""] - #[doc = " This method is invoked by the transaction pool to learn details about given transaction."] - #[doc = " The implementation should make sure to verify the correctness of the transaction"] - #[doc = " against current state. The given `block_hash` corresponds to the hash of the block"] - #[doc = " that is used as current state."] - #[doc = ""] - #[doc = " Note that this call may be performed by the pool multiple times and transactions"] - #[doc = " might be verified in any possible order."] - pub fn validate_transaction( - &self, - source: types::validate_transaction::Source, - tx: types::validate_transaction::Tx, - block_hash: types::validate_transaction::BlockHash, - ) -> ::subxt::runtime_api::Payload< - types::ValidateTransaction, - types::validate_transaction::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "TaggedTransactionQueue", - "validate_transaction", - types::ValidateTransaction { source, tx, block_hash }, - [ - 196u8, 50u8, 90u8, 49u8, 109u8, 251u8, 200u8, 35u8, 23u8, 150u8, 140u8, 143u8, 232u8, - 164u8, 133u8, 89u8, 32u8, 240u8, 115u8, 39u8, 95u8, 70u8, 162u8, 76u8, 122u8, 73u8, 151u8, - 144u8, 234u8, 120u8, 100u8, 29u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod validate_transaction { - use super::runtime_types; - pub type Source = runtime_types::sp_runtime::transaction_validity::TransactionSource; - pub type Tx = ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >; - pub type BlockHash = ::subxt::utils::H256; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - runtime_types::sp_runtime::transaction_validity::ValidTransaction, - runtime_types::sp_runtime::transaction_validity::TransactionValidityError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ValidateTransaction { - pub source: validate_transaction::Source, - pub tx: validate_transaction::Tx, - pub block_hash: validate_transaction::BlockHash, - } - } - } - pub mod offchain_worker_api { - use super::root_mod; - use super::runtime_types; - #[doc = " The offchain worker api."] - pub struct OffchainWorkerApi; - impl OffchainWorkerApi { - #[doc = " Starts the off-chain task for given block header."] - pub fn offchain_worker( - &self, - header: types::offchain_worker::Header, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "OffchainWorkerApi", - "offchain_worker", - types::OffchainWorker { header }, - [ - 10u8, 135u8, 19u8, 153u8, 33u8, 216u8, 18u8, 242u8, 33u8, 140u8, 4u8, 223u8, 200u8, 130u8, - 103u8, 118u8, 137u8, 24u8, 19u8, 127u8, 161u8, 29u8, 184u8, 111u8, 222u8, 111u8, 253u8, - 73u8, 45u8, 31u8, 79u8, 60u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod offchain_worker { - use super::runtime_types; - pub type Header = runtime_types::sp_runtime::generic::header::Header<::core::primitive::u32>; - pub mod output { - use super::runtime_types; - pub type Output = (); - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct OffchainWorker { - pub header: offchain_worker::Header, - } - } - } - pub mod aura_api { - use super::root_mod; - use super::runtime_types; - #[doc = " API necessary for block authorship with aura."] - pub struct AuraApi; - impl AuraApi { - #[doc = " Returns the slot duration for Aura."] - #[doc = ""] - #[doc = " Currently, only the value provided by this type at genesis will be used."] - pub fn slot_duration( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "AuraApi", - "slot_duration", - types::SlotDuration {}, - [ - 233u8, 210u8, 132u8, 172u8, 100u8, 125u8, 239u8, 92u8, 114u8, 82u8, 7u8, 110u8, 179u8, - 196u8, 10u8, 19u8, 211u8, 15u8, 174u8, 2u8, 91u8, 73u8, 133u8, 100u8, 205u8, 201u8, 191u8, - 60u8, 163u8, 122u8, 215u8, 10u8, - ], - ) - } - #[doc = " Return the current set of authorities."] - pub fn authorities( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "AuraApi", - "authorities", - types::Authorities {}, - [ - 96u8, 136u8, 226u8, 244u8, 105u8, 189u8, 8u8, 250u8, 71u8, 230u8, 37u8, 123u8, 218u8, 47u8, - 179u8, 16u8, 170u8, 181u8, 165u8, 77u8, 102u8, 51u8, 43u8, 51u8, 186u8, 84u8, 49u8, 15u8, - 208u8, 226u8, 129u8, 230u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod slot_duration { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::sp_consensus_slots::SlotDuration; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct SlotDuration {} - pub mod authorities { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = - ::std::vec::Vec; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Authorities {} - } - } - pub mod session_keys { - use super::root_mod; - use super::runtime_types; - #[doc = " Session keys runtime api."] - pub struct SessionKeys; - impl SessionKeys { - #[doc = " Generate a set of session keys with optionally using the given seed."] - #[doc = " The keys should be stored within the keystore exposed via runtime"] - #[doc = " externalities."] - #[doc = ""] - #[doc = " The seed needs to be a valid `utf8` string."] - #[doc = ""] - #[doc = " Returns the concatenated SCALE encoded public keys."] - pub fn generate_session_keys( - &self, - seed: types::generate_session_keys::Seed, - ) -> ::subxt::runtime_api::Payload< - types::GenerateSessionKeys, - types::generate_session_keys::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "SessionKeys", - "generate_session_keys", - types::GenerateSessionKeys { seed }, - [ - 96u8, 171u8, 164u8, 166u8, 175u8, 102u8, 101u8, 47u8, 133u8, 95u8, 102u8, 202u8, 83u8, - 26u8, 238u8, 47u8, 126u8, 132u8, 22u8, 11u8, 33u8, 190u8, 175u8, 94u8, 58u8, 245u8, 46u8, - 80u8, 195u8, 184u8, 107u8, 65u8, - ], - ) - } - #[doc = " Decode the given public session keys."] - #[doc = ""] - #[doc = " Returns the list of public raw public keys + key type."] - pub fn decode_session_keys( - &self, - encoded: types::decode_session_keys::Encoded, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "SessionKeys", - "decode_session_keys", - types::DecodeSessionKeys { encoded }, - [ - 57u8, 242u8, 18u8, 51u8, 132u8, 110u8, 238u8, 255u8, 39u8, 194u8, 8u8, 54u8, 198u8, 178u8, - 75u8, 151u8, 148u8, 176u8, 144u8, 197u8, 87u8, 29u8, 179u8, 235u8, 176u8, 78u8, 252u8, - 103u8, 72u8, 203u8, 151u8, 248u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod generate_session_keys { - use super::runtime_types; - pub type Seed = ::core::option::Option<::std::vec::Vec<::core::primitive::u8>>; - pub mod output { - use super::runtime_types; - pub type Output = ::std::vec::Vec<::core::primitive::u8>; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GenerateSessionKeys { - pub seed: generate_session_keys::Seed, - } - pub mod decode_session_keys { - use super::runtime_types; - pub type Encoded = ::std::vec::Vec<::core::primitive::u8>; - pub mod output { - use super::runtime_types; - pub type Output = ::core::option::Option< - ::std::vec::Vec<( - ::std::vec::Vec<::core::primitive::u8>, - runtime_types::sp_core::crypto::KeyTypeId, - )>, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct DecodeSessionKeys { - pub encoded: decode_session_keys::Encoded, - } - } - } - pub mod grandpa_api { - use super::root_mod; - use super::runtime_types; - #[doc = " APIs for integrating the GRANDPA finality gadget into runtimes."] - #[doc = " This should be implemented on the runtime side."] - #[doc = ""] - #[doc = " This is primarily used for negotiating authority-set changes for the"] - #[doc = " gadget. GRANDPA uses a signaling model of changing authority sets:"] - #[doc = " changes should be signaled with a delay of N blocks, and then automatically"] - #[doc = " applied in the runtime after those N blocks have passed."] - #[doc = ""] - #[doc = " The consensus protocol will coordinate the handoff externally."] - pub struct GrandpaApi; - impl GrandpaApi { - #[doc = " Get the current GRANDPA authorities and weights. This should not change except"] - #[doc = " for when changes are scheduled and the corresponding delay has passed."] - #[doc = ""] - #[doc = " When called at block B, it will return the set of authorities that should be"] - #[doc = " used to finalize descendants of this block (B+1, B+2, ...). The block B itself"] - #[doc = " is finalized by the authorities from block B-1."] - pub fn grandpa_authorities( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "GrandpaApi", - "grandpa_authorities", - types::GrandpaAuthorities {}, - [ - 166u8, 76u8, 160u8, 101u8, 242u8, 145u8, 213u8, 10u8, 16u8, 130u8, 230u8, 196u8, 125u8, - 152u8, 92u8, 143u8, 119u8, 223u8, 140u8, 189u8, 203u8, 95u8, 52u8, 105u8, 147u8, 107u8, - 135u8, 228u8, 62u8, 178u8, 128u8, 33u8, - ], - ) - } - #[doc = " Submits an unsigned extrinsic to report an equivocation. The caller"] - #[doc = " must provide the equivocation proof and a key ownership proof"] - #[doc = " (should be obtained using `generate_key_ownership_proof`). The"] - #[doc = " extrinsic will be unsigned and should only be accepted for local"] - #[doc = " authorship (not to be broadcast to the network). This method returns"] - #[doc = " `None` when creation of the extrinsic fails, e.g. if equivocation"] - #[doc = " reporting is disabled for the given runtime (i.e. this method is"] - #[doc = " hardcoded to return `None`). Only useful in an offchain context."] - pub fn submit_report_equivocation_unsigned_extrinsic( - &self, - equivocation_proof: types::submit_report_equivocation_unsigned_extrinsic::EquivocationProof, - key_owner_proof: types::submit_report_equivocation_unsigned_extrinsic::KeyOwnerProof, - ) -> ::subxt::runtime_api::Payload< - types::SubmitReportEquivocationUnsignedExtrinsic, - types::submit_report_equivocation_unsigned_extrinsic::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "GrandpaApi", - "submit_report_equivocation_unsigned_extrinsic", - types::SubmitReportEquivocationUnsignedExtrinsic { equivocation_proof, key_owner_proof }, - [ - 112u8, 94u8, 150u8, 250u8, 132u8, 127u8, 185u8, 24u8, 113u8, 62u8, 28u8, 171u8, 83u8, 9u8, - 41u8, 228u8, 92u8, 137u8, 29u8, 190u8, 214u8, 232u8, 100u8, 66u8, 100u8, 168u8, 149u8, - 122u8, 93u8, 17u8, 236u8, 104u8, - ], - ) - } - #[doc = " Generates a proof of key ownership for the given authority in the"] - #[doc = " given set. An example usage of this module is coupled with the"] - #[doc = " session historical module to prove that a given authority key is"] - #[doc = " tied to a given staking identity during a specific session. Proofs"] - #[doc = " of key ownership are necessary for submitting equivocation reports."] - #[doc = " NOTE: even though the API takes a `set_id` as parameter the current"] - #[doc = " implementations ignore this parameter and instead rely on this"] - #[doc = " method being called at the correct block height, i.e. any point at"] - #[doc = " which the given set id is live on-chain. Future implementations will"] - #[doc = " instead use indexed data through an offchain worker, not requiring"] - #[doc = " older states to be available."] - pub fn generate_key_ownership_proof( - &self, - set_id: types::generate_key_ownership_proof::SetId, - authority_id: types::generate_key_ownership_proof::AuthorityId, - ) -> ::subxt::runtime_api::Payload< - types::GenerateKeyOwnershipProof, - types::generate_key_ownership_proof::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "GrandpaApi", - "generate_key_ownership_proof", - types::GenerateKeyOwnershipProof { set_id, authority_id }, - [ - 40u8, 126u8, 113u8, 27u8, 245u8, 45u8, 123u8, 138u8, 12u8, 3u8, 125u8, 186u8, 151u8, 53u8, - 186u8, 93u8, 13u8, 150u8, 163u8, 176u8, 206u8, 89u8, 244u8, 127u8, 182u8, 85u8, 203u8, - 41u8, 101u8, 183u8, 209u8, 179u8, - ], - ) - } - #[doc = " Get current GRANDPA authority set id."] - pub fn current_set_id( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "GrandpaApi", - "current_set_id", - types::CurrentSetId {}, - [ - 42u8, 230u8, 120u8, 211u8, 156u8, 245u8, 109u8, 86u8, 100u8, 146u8, 234u8, 205u8, 41u8, - 183u8, 109u8, 42u8, 17u8, 33u8, 156u8, 25u8, 139u8, 84u8, 101u8, 75u8, 232u8, 198u8, 87u8, - 136u8, 218u8, 233u8, 103u8, 156u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod grandpa_authorities { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = - ::std::vec::Vec<(runtime_types::sp_consensus_grandpa::app::Public, ::core::primitive::u64)>; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GrandpaAuthorities {} - pub mod submit_report_equivocation_unsigned_extrinsic { - use super::runtime_types; - pub type EquivocationProof = runtime_types::sp_consensus_grandpa::EquivocationProof< - ::subxt::utils::H256, - ::core::primitive::u32, - >; - pub type KeyOwnerProof = runtime_types::sp_consensus_grandpa::OpaqueKeyOwnershipProof; - pub mod output { - use super::runtime_types; - pub type Output = ::core::option::Option<()>; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct SubmitReportEquivocationUnsignedExtrinsic { - pub equivocation_proof: submit_report_equivocation_unsigned_extrinsic::EquivocationProof, - pub key_owner_proof: submit_report_equivocation_unsigned_extrinsic::KeyOwnerProof, - } - pub mod generate_key_ownership_proof { - use super::runtime_types; - pub type SetId = ::core::primitive::u64; - pub type AuthorityId = runtime_types::sp_consensus_grandpa::app::Public; - pub mod output { - use super::runtime_types; - pub type Output = - ::core::option::Option; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GenerateKeyOwnershipProof { - pub set_id: generate_key_ownership_proof::SetId, - pub authority_id: generate_key_ownership_proof::AuthorityId, - } - pub mod current_set_id { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = ::core::primitive::u64; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CurrentSetId {} - } - } - pub mod account_nonce_api { - use super::root_mod; - use super::runtime_types; - #[doc = " The API to query account nonce."] - pub struct AccountNonceApi; - impl AccountNonceApi { - #[doc = " Get current account nonce of given `AccountId`."] - pub fn account_nonce( - &self, - account: types::account_nonce::Account, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "AccountNonceApi", - "account_nonce", - types::AccountNonce { account }, - [ - 231u8, 82u8, 7u8, 227u8, 131u8, 2u8, 215u8, 252u8, 173u8, 82u8, 11u8, 103u8, 200u8, 25u8, - 114u8, 116u8, 79u8, 229u8, 152u8, 150u8, 236u8, 37u8, 101u8, 26u8, 220u8, 146u8, 182u8, - 101u8, 73u8, 55u8, 191u8, 171u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod account_nonce { - use super::runtime_types; - pub type Account = ::subxt::utils::AccountId32; - pub mod output { - use super::runtime_types; - pub type Output = ::core::primitive::u32; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct AccountNonce { - pub account: account_nonce::Account, - } - } - } - pub mod starknet_runtime_api { - use super::root_mod; - use super::runtime_types; - pub struct StarknetRuntimeApi; - impl StarknetRuntimeApi { - #[doc = " Returns the nonce associated with the given address in the given block"] - pub fn nonce( - &self, - contract_address: types::nonce::ContractAddress, - ) -> ::subxt::runtime_api::Payload { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "nonce", - types::Nonce { contract_address }, - [ - 223u8, 78u8, 98u8, 162u8, 110u8, 80u8, 134u8, 64u8, 16u8, 48u8, 174u8, 206u8, 222u8, 135u8, - 239u8, 38u8, 46u8, 199u8, 130u8, 229u8, 239u8, 236u8, 210u8, 57u8, 184u8, 219u8, 75u8, 1u8, - 161u8, 76u8, 171u8, 90u8, - ], - ) - } - #[doc = " Returns a storage slot value"] - pub fn get_storage_at( - &self, - address: types::get_storage_at::Address, - key: types::get_storage_at::Key, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "get_storage_at", - types::GetStorageAt { address, key }, - [ - 218u8, 70u8, 23u8, 117u8, 134u8, 149u8, 149u8, 52u8, 107u8, 184u8, 92u8, 60u8, 234u8, 81u8, - 62u8, 254u8, 176u8, 3u8, 72u8, 252u8, 234u8, 226u8, 113u8, 3u8, 238u8, 139u8, 216u8, 182u8, - 56u8, 200u8, 225u8, 44u8, - ], - ) - } - #[doc = " Returns a `Call` response."] - pub fn call( - &self, - address: types::call::Address, - function_selector: types::call::FunctionSelector, - calldata: types::call::Calldata, - ) -> ::subxt::runtime_api::Payload { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "call", - types::Call { address, function_selector, calldata }, - [ - 243u8, 171u8, 64u8, 174u8, 161u8, 137u8, 230u8, 19u8, 218u8, 58u8, 240u8, 15u8, 226u8, - 41u8, 176u8, 172u8, 67u8, 234u8, 184u8, 21u8, 84u8, 198u8, 196u8, 55u8, 240u8, 128u8, - 163u8, 75u8, 84u8, 235u8, 250u8, 249u8, - ], - ) - } - #[doc = " Returns the contract class hash at the given address."] - pub fn contract_class_hash_by_address( - &self, - address: types::contract_class_hash_by_address::Address, - ) -> ::subxt::runtime_api::Payload< - types::ContractClassHashByAddress, - types::contract_class_hash_by_address::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "contract_class_hash_by_address", - types::ContractClassHashByAddress { address }, - [ - 10u8, 25u8, 149u8, 78u8, 109u8, 81u8, 246u8, 45u8, 195u8, 195u8, 151u8, 125u8, 46u8, 227u8, - 76u8, 43u8, 162u8, 103u8, 196u8, 137u8, 68u8, 10u8, 21u8, 70u8, 150u8, 244u8, 56u8, 61u8, - 195u8, 204u8, 14u8, 20u8, - ], - ) - } - #[doc = " Returns the contract class for the given class hash."] - pub fn contract_class_by_class_hash( - &self, - class_hash: types::contract_class_by_class_hash::ClassHash, - ) -> ::subxt::runtime_api::Payload< - types::ContractClassByClassHash, - types::contract_class_by_class_hash::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "contract_class_by_class_hash", - types::ContractClassByClassHash { class_hash }, - [ - 101u8, 25u8, 72u8, 124u8, 184u8, 103u8, 59u8, 96u8, 180u8, 149u8, 213u8, 146u8, 67u8, - 254u8, 43u8, 202u8, 71u8, 159u8, 249u8, 32u8, 59u8, 251u8, 35u8, 190u8, 128u8, 234u8, 61u8, - 248u8, 181u8, 29u8, 126u8, 251u8, - ], - ) - } - #[doc = " Returns the chain id."] - pub fn chain_id( - &self, - ) -> ::subxt::runtime_api::Payload { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "chain_id", - types::ChainId {}, - [ - 40u8, 205u8, 232u8, 235u8, 194u8, 248u8, 230u8, 70u8, 133u8, 162u8, 103u8, 163u8, 134u8, - 9u8, 208u8, 149u8, 122u8, 242u8, 92u8, 98u8, 67u8, 7u8, 67u8, 223u8, 132u8, 110u8, 186u8, - 220u8, 40u8, 179u8, 48u8, 91u8, - ], - ) - } - #[doc = " Returns the Starknet OS Cairo program hash."] - pub fn program_hash( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "program_hash", - types::ProgramHash {}, - [ - 172u8, 109u8, 196u8, 182u8, 116u8, 64u8, 49u8, 225u8, 138u8, 12u8, 135u8, 200u8, 217u8, - 136u8, 64u8, 130u8, 0u8, 209u8, 221u8, 190u8, 9u8, 2u8, 143u8, 54u8, 84u8, 210u8, 195u8, - 255u8, 110u8, 218u8, 216u8, 164u8, - ], - ) - } - #[doc = " Returns the Starknet config hash."] - pub fn config_hash( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "config_hash", - types::ConfigHash {}, - [ - 106u8, 73u8, 154u8, 190u8, 90u8, 106u8, 65u8, 70u8, 120u8, 248u8, 104u8, 75u8, 148u8, - 184u8, 129u8, 205u8, 252u8, 31u8, 150u8, 31u8, 73u8, 164u8, 12u8, 251u8, 38u8, 116u8, - 153u8, 79u8, 147u8, 193u8, 149u8, 0u8, - ], - ) - } - #[doc = " Returns the fee token address."] - pub fn fee_token_address( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "fee_token_address", - types::FeeTokenAddress {}, - [ - 31u8, 130u8, 101u8, 106u8, 209u8, 212u8, 137u8, 207u8, 58u8, 18u8, 142u8, 195u8, 120u8, - 208u8, 132u8, 228u8, 147u8, 115u8, 234u8, 25u8, 202u8, 254u8, 96u8, 39u8, 197u8, 144u8, - 42u8, 92u8, 172u8, 82u8, 201u8, 204u8, - ], - ) - } - #[doc = " Returns fee estimate"] - pub fn estimate_fee( - &self, - transactions: types::estimate_fee::Transactions, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "estimate_fee", - types::EstimateFee { transactions }, - [ - 184u8, 182u8, 60u8, 242u8, 255u8, 251u8, 46u8, 30u8, 204u8, 104u8, 57u8, 131u8, 38u8, 50u8, - 84u8, 156u8, 164u8, 26u8, 206u8, 149u8, 40u8, 170u8, 255u8, 7u8, 45u8, 93u8, 195u8, 64u8, - 17u8, 8u8, 222u8, 14u8, - ], - ) - } - #[doc = " Returns message fee estimate"] - pub fn estimate_message_fee( - &self, - message: types::estimate_message_fee::Message, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "estimate_message_fee", - types::EstimateMessageFee { message }, - [ - 109u8, 56u8, 101u8, 23u8, 94u8, 130u8, 118u8, 178u8, 136u8, 17u8, 122u8, 98u8, 86u8, 171u8, - 19u8, 88u8, 130u8, 255u8, 208u8, 116u8, 99u8, 35u8, 201u8, 33u8, 226u8, 0u8, 66u8, 130u8, - 74u8, 197u8, 253u8, 17u8, - ], - ) - } - #[doc = " Simulates single L1 Message and returns its trace"] - pub fn simulate_message( - &self, - message: types::simulate_message::Message, - simulation_flags: types::simulate_message::SimulationFlags, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "simulate_message", - types::SimulateMessage { message, simulation_flags }, - [ - 229u8, 57u8, 24u8, 201u8, 169u8, 96u8, 194u8, 117u8, 191u8, 75u8, 255u8, 98u8, 206u8, - 115u8, 39u8, 119u8, 25u8, 230u8, 146u8, 3u8, 93u8, 78u8, 38u8, 166u8, 255u8, 72u8, 163u8, - 33u8, 175u8, 71u8, 109u8, 116u8, - ], - ) - } - #[doc = " Simulates transactions and returns their trace"] - pub fn simulate_transactions( - &self, - transactions: types::simulate_transactions::Transactions, - simulation_flags: types::simulate_transactions::SimulationFlags, - ) -> ::subxt::runtime_api::Payload< - types::SimulateTransactions, - types::simulate_transactions::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "simulate_transactions", - types::SimulateTransactions { transactions, simulation_flags }, - [ - 188u8, 223u8, 156u8, 234u8, 56u8, 98u8, 85u8, 252u8, 78u8, 252u8, 164u8, 181u8, 16u8, 73u8, - 49u8, 103u8, 174u8, 45u8, 168u8, 68u8, 172u8, 38u8, 216u8, 167u8, 239u8, 201u8, 18u8, - 105u8, 242u8, 122u8, 227u8, 190u8, - ], - ) - } - #[doc = " Filters extrinsic transactions to return only Starknet transactions"] - #[doc = ""] - #[doc = " To support runtime upgrades, the client must be unaware of the specific extrinsic"] - #[doc = " details. To achieve this, the client uses an OpaqueExtrinsic type to represent and"] - #[doc = " manipulate extrinsics. However, the client cannot decode and filter extrinsics due to"] - #[doc = " this limitation. The solution is to offload decoding and filtering to the RuntimeApi in"] - #[doc = " the runtime itself, accomplished through the extrinsic_filter method. This enables the"] - #[doc = " client to operate seamlessly while abstracting the extrinsic complexity."] - pub fn extrinsic_filter( - &self, - xts: types::extrinsic_filter::Xts, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "extrinsic_filter", - types::ExtrinsicFilter { xts }, - [ - 174u8, 71u8, 247u8, 222u8, 153u8, 41u8, 101u8, 40u8, 89u8, 39u8, 48u8, 240u8, 136u8, 23u8, - 195u8, 201u8, 117u8, 235u8, 71u8, 30u8, 231u8, 151u8, 74u8, 224u8, 180u8, 205u8, 115u8, - 110u8, 203u8, 95u8, 138u8, 157u8, - ], - ) - } - #[doc = " Re-execute a block and return the TransactionExecutionInfos of every transaction in it, in the same order"] - pub fn re_execute_transactions( - &self, - transactions: types::re_execute_transactions::Transactions, - ) -> ::subxt::runtime_api::Payload< - types::ReExecuteTransactions, - types::re_execute_transactions::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "re_execute_transactions", - types::ReExecuteTransactions { transactions }, - [ - 162u8, 224u8, 209u8, 166u8, 12u8, 75u8, 210u8, 149u8, 129u8, 76u8, 32u8, 42u8, 152u8, 97u8, - 215u8, 135u8, 68u8, 92u8, 224u8, 141u8, 124u8, 175u8, 69u8, 116u8, 193u8, 49u8, 207u8, - 216u8, 168u8, 235u8, 17u8, 252u8, - ], - ) - } - pub fn get_index_and_tx_for_tx_hash( - &self, - xts: types::get_index_and_tx_for_tx_hash::Xts, - chain_id: types::get_index_and_tx_for_tx_hash::ChainId, - tx_hash: types::get_index_and_tx_for_tx_hash::TxHash, - ) -> ::subxt::runtime_api::Payload< - types::GetIndexAndTxForTxHash, - types::get_index_and_tx_for_tx_hash::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "get_index_and_tx_for_tx_hash", - types::GetIndexAndTxForTxHash { xts, chain_id, tx_hash }, - [ - 230u8, 69u8, 155u8, 160u8, 153u8, 166u8, 187u8, 237u8, 45u8, 101u8, 245u8, 24u8, 182u8, - 192u8, 118u8, 68u8, 46u8, 103u8, 243u8, 155u8, 243u8, 252u8, 168u8, 34u8, 245u8, 242u8, - 89u8, 4u8, 223u8, 150u8, 157u8, 155u8, - ], - ) - } - pub fn get_events_for_tx_by_hash( - &self, - tx_hash: types::get_events_for_tx_by_hash::TxHash, - ) -> ::subxt::runtime_api::Payload< - types::GetEventsForTxByHash, - types::get_events_for_tx_by_hash::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "get_events_for_tx_by_hash", - types::GetEventsForTxByHash { tx_hash }, - [ - 9u8, 218u8, 79u8, 180u8, 233u8, 108u8, 107u8, 4u8, 15u8, 241u8, 8u8, 29u8, 187u8, 119u8, - 92u8, 216u8, 95u8, 87u8, 115u8, 119u8, 234u8, 62u8, 227u8, 244u8, 20u8, 111u8, 17u8, 87u8, - 125u8, 152u8, 80u8, 232u8, - ], - ) - } - #[doc = " Return the outcome of the tx execution"] - pub fn get_tx_execution_outcome( - &self, - tx_hash: types::get_tx_execution_outcome::TxHash, - ) -> ::subxt::runtime_api::Payload< - types::GetTxExecutionOutcome, - types::get_tx_execution_outcome::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "get_tx_execution_outcome", - types::GetTxExecutionOutcome { tx_hash }, - [ - 177u8, 94u8, 132u8, 75u8, 36u8, 225u8, 133u8, 68u8, 20u8, 144u8, 67u8, 79u8, 105u8, 190u8, - 8u8, 234u8, 206u8, 112u8, 196u8, 133u8, 99u8, 175u8, 132u8, 113u8, 121u8, 7u8, 75u8, 9u8, - 60u8, 96u8, 104u8, 64u8, - ], - ) - } - #[doc = " Return the block context"] - pub fn get_block_context( - &self, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "get_block_context", - types::GetBlockContext {}, - [ - 93u8, 141u8, 157u8, 168u8, 2u8, 15u8, 159u8, 49u8, 184u8, 176u8, 84u8, 196u8, 14u8, 245u8, - 235u8, 121u8, 161u8, 89u8, 190u8, 195u8, 159u8, 128u8, 252u8, 231u8, 247u8, 142u8, 76u8, - 182u8, 185u8, 130u8, 164u8, 115u8, - ], - ) - } - #[doc = " Return is fee disabled in state"] - pub fn is_transaction_fee_disabled( - &self, - ) -> ::subxt::runtime_api::Payload< - types::IsTransactionFeeDisabled, - types::is_transaction_fee_disabled::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "is_transaction_fee_disabled", - types::IsTransactionFeeDisabled {}, - [ - 248u8, 144u8, 121u8, 219u8, 115u8, 71u8, 41u8, 92u8, 164u8, 48u8, 110u8, 95u8, 31u8, 84u8, - 38u8, 154u8, 47u8, 181u8, 115u8, 76u8, 138u8, 127u8, 209u8, 87u8, 70u8, 45u8, 237u8, 212u8, - 250u8, 118u8, 164u8, 60u8, - ], - ) - } - #[doc = " Return messages sent to L1 during tx execution"] - pub fn get_tx_messages_to_l1( - &self, - tx_hash: types::get_tx_messages_to_l1::TxHash, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "get_tx_messages_to_l1", - types::GetTxMessagesToL1 { tx_hash }, - [ - 117u8, 201u8, 150u8, 193u8, 49u8, 219u8, 210u8, 46u8, 10u8, 186u8, 195u8, 124u8, 137u8, - 73u8, 127u8, 83u8, 120u8, 28u8, 61u8, 149u8, 195u8, 209u8, 193u8, 183u8, 63u8, 61u8, 104u8, - 135u8, 236u8, 99u8, 104u8, 190u8, - ], - ) - } - #[doc = " Check if L1 Message Nonce has not been used"] - pub fn l1_nonce_unused( - &self, - nonce: types::l1_nonce_unused::Nonce, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "StarknetRuntimeApi", - "l1_nonce_unused", - types::L1NonceUnused { nonce }, - [ - 210u8, 236u8, 76u8, 166u8, 82u8, 158u8, 90u8, 74u8, 152u8, 155u8, 167u8, 49u8, 230u8, 42u8, - 155u8, 111u8, 168u8, 113u8, 135u8, 163u8, 139u8, 93u8, 179u8, 212u8, 169u8, 175u8, 53u8, - 65u8, 142u8, 138u8, 146u8, 232u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod nonce { - use super::runtime_types; - pub type ContractAddress = runtime_types::starknet_api::api_core::ContractAddress; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::starknet_api::api_core::Nonce; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Nonce { - pub contract_address: nonce::ContractAddress, - } - pub mod get_storage_at { - use super::runtime_types; - pub type Address = runtime_types::starknet_api::api_core::ContractAddress; - pub type Key = runtime_types::starknet_api::state::StorageKey; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - runtime_types::starknet_api::hash::StarkFelt, - runtime_types::sp_runtime::DispatchError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GetStorageAt { - pub address: get_storage_at::Address, - pub key: get_storage_at::Key, - } - pub mod call { - use super::runtime_types; - pub type Address = runtime_types::starknet_api::api_core::ContractAddress; - pub type FunctionSelector = runtime_types::starknet_api::api_core::EntryPointSelector; - pub type Calldata = runtime_types::starknet_api::transaction::Calldata; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - ::std::vec::Vec, - runtime_types::sp_runtime::DispatchError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Call { - pub address: call::Address, - pub function_selector: call::FunctionSelector, - pub calldata: call::Calldata, - } - pub mod contract_class_hash_by_address { - use super::runtime_types; - pub type Address = runtime_types::starknet_api::api_core::ContractAddress; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::starknet_api::api_core::ClassHash; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ContractClassHashByAddress { - pub address: contract_class_hash_by_address::Address, - } - pub mod contract_class_by_class_hash { - use super::runtime_types; - pub type ClassHash = runtime_types::starknet_api::api_core::ClassHash; - pub mod output { - use super::runtime_types; - pub type Output = - ::core::option::Option; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ContractClassByClassHash { - pub class_hash: contract_class_by_class_hash::ClassHash, - } - pub mod chain_id { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::mp_felt::Felt252Wrapper; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ChainId {} - pub mod program_hash { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::mp_felt::Felt252Wrapper; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ProgramHash {} - pub mod config_hash { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::starknet_api::hash::StarkFelt; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ConfigHash {} - pub mod fee_token_address { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::starknet_api::api_core::ContractAddress; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct FeeTokenAddress {} - pub mod estimate_fee { - use super::runtime_types; - pub type Transactions = ::std::vec::Vec; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - ::std::vec::Vec<(::core::primitive::u64, ::core::primitive::u64)>, - runtime_types::sp_runtime::DispatchError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EstimateFee { - pub transactions: estimate_fee::Transactions, - } - pub mod estimate_message_fee { - use super::runtime_types; - pub type Message = runtime_types::mp_transactions::HandleL1MessageTransaction; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - (::core::primitive::u128, ::core::primitive::u64, ::core::primitive::u64), - runtime_types::sp_runtime::DispatchError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EstimateMessageFee { - pub message: estimate_message_fee::Message, - } - pub mod simulate_message { - use super::runtime_types; - pub type Message = runtime_types::mp_transactions::HandleL1MessageTransaction; - pub type SimulationFlags = runtime_types::mp_simulations::SimulationFlags; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - ::core::result::Result< - runtime_types::blockifier::transaction::objects::TransactionExecutionInfo, - runtime_types::mp_simulations::PlaceHolderErrorTypeForFailedStarknetExecution, - >, - runtime_types::sp_runtime::DispatchError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct SimulateMessage { - pub message: simulate_message::Message, - pub simulation_flags: simulate_message::SimulationFlags, - } - pub mod simulate_transactions { - use super::runtime_types; - pub type Transactions = ::std::vec::Vec; - pub type SimulationFlags = runtime_types::mp_simulations::SimulationFlags; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - ::std::vec::Vec<( - runtime_types::blockifier::state::cached_state::CommitmentStateDiff, - ::core::result::Result< - runtime_types::blockifier::transaction::objects::TransactionExecutionInfo, - runtime_types::mp_simulations::PlaceHolderErrorTypeForFailedStarknetExecution, - >, - )>, - runtime_types::sp_runtime::DispatchError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct SimulateTransactions { - pub transactions: simulate_transactions::Transactions, - pub simulation_flags: simulate_transactions::SimulationFlags, - } - pub mod extrinsic_filter { - use super::runtime_types; - pub type Xts = ::std::vec::Vec< - ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >, - >; - pub mod output { - use super::runtime_types; - pub type Output = ::std::vec::Vec; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ExtrinsicFilter { - pub xts: extrinsic_filter::Xts, - } - pub mod re_execute_transactions { - use super::runtime_types; - pub type Transactions = ::std::vec::Vec; - pub mod output { - use super::runtime_types; - pub type Output = ::core::result::Result< - ::core::result::Result< - ::std::vec::Vec<( - runtime_types::blockifier::transaction::objects::TransactionExecutionInfo, - runtime_types::blockifier::state::cached_state::CommitmentStateDiff, - )>, - runtime_types::mp_simulations::PlaceHolderErrorTypeForFailedStarknetExecution, - >, - runtime_types::sp_runtime::DispatchError, - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ReExecuteTransactions { - pub transactions: re_execute_transactions::Transactions, - } - pub mod get_index_and_tx_for_tx_hash { - use super::runtime_types; - pub type Xts = ::std::vec::Vec< - ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >, - >; - pub type ChainId = runtime_types::mp_felt::Felt252Wrapper; - pub type TxHash = runtime_types::mp_felt::Felt252Wrapper; - pub mod output { - use super::runtime_types; - pub type Output = ::core::option::Option<( - ::core::primitive::u32, - runtime_types::mp_transactions::Transaction, - )>; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GetIndexAndTxForTxHash { - pub xts: get_index_and_tx_for_tx_hash::Xts, - pub chain_id: get_index_and_tx_for_tx_hash::ChainId, - pub tx_hash: get_index_and_tx_for_tx_hash::TxHash, - } - pub mod get_events_for_tx_by_hash { - use super::runtime_types; - pub type TxHash = runtime_types::starknet_api::transaction::TransactionHash; - pub mod output { - use super::runtime_types; - pub type Output = ::std::vec::Vec; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GetEventsForTxByHash { - pub tx_hash: get_events_for_tx_by_hash::TxHash, - } - pub mod get_tx_execution_outcome { - use super::runtime_types; - pub type TxHash = runtime_types::starknet_api::transaction::TransactionHash; - pub mod output { - use super::runtime_types; - pub type Output = ::core::option::Option<::std::vec::Vec<::core::primitive::u8>>; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GetTxExecutionOutcome { - pub tx_hash: get_tx_execution_outcome::TxHash, - } - pub mod get_block_context { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::pallet_starknet_runtime_api::BlockContext; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GetBlockContext {} - pub mod is_transaction_fee_disabled { - use super::runtime_types; - pub mod output { - use super::runtime_types; - pub type Output = ::core::primitive::bool; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct IsTransactionFeeDisabled {} - pub mod get_tx_messages_to_l1 { - use super::runtime_types; - pub type TxHash = runtime_types::starknet_api::transaction::TransactionHash; - pub mod output { - use super::runtime_types; - pub type Output = ::std::vec::Vec; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct GetTxMessagesToL1 { - pub tx_hash: get_tx_messages_to_l1::TxHash, - } - pub mod l1_nonce_unused { - use super::runtime_types; - pub type Nonce = runtime_types::starknet_api::api_core::Nonce; - pub mod output { - use super::runtime_types; - pub type Output = ::core::primitive::bool; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct L1NonceUnused { - pub nonce: l1_nonce_unused::Nonce, - } - } - } - pub mod convert_transaction_runtime_api { - use super::root_mod; - use super::runtime_types; - pub struct ConvertTransactionRuntimeApi; - impl ConvertTransactionRuntimeApi { - #[doc = " Converts the transaction to an UncheckedExtrinsic for submission to the pool."] - pub fn convert_transaction( - &self, - transaction: types::convert_transaction::Transaction, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "ConvertTransactionRuntimeApi", - "convert_transaction", - types::ConvertTransaction { transaction }, - [ - 2u8, 28u8, 195u8, 173u8, 73u8, 16u8, 65u8, 48u8, 228u8, 175u8, 103u8, 175u8, 208u8, 146u8, - 110u8, 70u8, 70u8, 124u8, 194u8, 14u8, 172u8, 153u8, 223u8, 148u8, 224u8, 104u8, 185u8, - 128u8, 129u8, 12u8, 21u8, 136u8, - ], - ) - } - #[doc = " Converts the L1 Message transaction to an UncheckedExtrinsic for submission to the pool."] - pub fn convert_l1_transaction( - &self, - transaction: types::convert_l1_transaction::Transaction, - fee: types::convert_l1_transaction::Fee, - ) -> ::subxt::runtime_api::Payload< - types::ConvertL1Transaction, - types::convert_l1_transaction::output::Output, - > { - ::subxt::runtime_api::Payload::new_static( - "ConvertTransactionRuntimeApi", - "convert_l1_transaction", - types::ConvertL1Transaction { transaction, fee }, - [ - 144u8, 54u8, 178u8, 219u8, 51u8, 230u8, 156u8, 233u8, 63u8, 216u8, 248u8, 105u8, 227u8, - 232u8, 201u8, 53u8, 243u8, 182u8, 84u8, 171u8, 249u8, 140u8, 79u8, 70u8, 95u8, 25u8, 196u8, - 10u8, 127u8, 75u8, 83u8, 65u8, - ], - ) - } - #[doc = " Converts the DispatchError to an understandable error for the client"] - pub fn convert_error( - &self, - error: types::convert_error::Error, - ) -> ::subxt::runtime_api::Payload - { - ::subxt::runtime_api::Payload::new_static( - "ConvertTransactionRuntimeApi", - "convert_error", - types::ConvertError { error }, - [ - 99u8, 109u8, 225u8, 103u8, 141u8, 72u8, 147u8, 132u8, 251u8, 176u8, 127u8, 246u8, 28u8, - 171u8, 244u8, 204u8, 159u8, 42u8, 215u8, 195u8, 88u8, 246u8, 173u8, 193u8, 46u8, 170u8, - 188u8, 147u8, 113u8, 158u8, 243u8, 203u8, - ], - ) - } - } - pub mod types { - use super::runtime_types; - pub mod convert_transaction { - use super::runtime_types; - pub type Transaction = runtime_types::mp_transactions::UserTransaction; - pub mod output { - use super::runtime_types; - pub type Output = ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ConvertTransaction { - pub transaction: convert_transaction::Transaction, - } - pub mod convert_l1_transaction { - use super::runtime_types; - pub type Transaction = runtime_types::mp_transactions::HandleL1MessageTransaction; - pub type Fee = runtime_types::starknet_api::transaction::Fee; - pub mod output { - use super::runtime_types; - pub type Output = ::subxt::utils::UncheckedExtrinsic< - ::subxt::utils::MultiAddress<::subxt::utils::AccountId32, ()>, - runtime_types::madara_runtime::RuntimeCall, - runtime_types::sp_runtime::MultiSignature, - ( - runtime_types::frame_system::extensions::check_non_zero_sender::CheckNonZeroSender, - runtime_types::frame_system::extensions::check_spec_version::CheckSpecVersion, - runtime_types::frame_system::extensions::check_tx_version::CheckTxVersion, - runtime_types::frame_system::extensions::check_genesis::CheckGenesis, - runtime_types::frame_system::extensions::check_mortality::CheckMortality, - runtime_types::frame_system::extensions::check_nonce::CheckNonce, - runtime_types::frame_system::extensions::check_weight::CheckWeight, - ), - >; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ConvertL1Transaction { - pub transaction: convert_l1_transaction::Transaction, - pub fee: convert_l1_transaction::Fee, - } - pub mod convert_error { - use super::runtime_types; - pub type Error = runtime_types::sp_runtime::DispatchError; - pub mod output { - use super::runtime_types; - pub type Output = runtime_types::pallet_starknet_runtime_api::StarknetTransactionExecutionError; - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ConvertError { - pub error: convert_error::Error, - } - } - } - } - pub fn custom() -> CustomValuesApi { - CustomValuesApi - } - pub struct CustomValuesApi; - impl CustomValuesApi {} - pub struct ConstantsApi; - impl ConstantsApi { - pub fn system(&self) -> system::constants::ConstantsApi { - system::constants::ConstantsApi - } - pub fn timestamp(&self) -> timestamp::constants::ConstantsApi { - timestamp::constants::ConstantsApi - } - pub fn grandpa(&self) -> grandpa::constants::ConstantsApi { - grandpa::constants::ConstantsApi - } - pub fn starknet(&self) -> starknet::constants::ConstantsApi { - starknet::constants::ConstantsApi - } - pub fn autonomous(&self) -> autonomous::constants::ConstantsApi { - autonomous::constants::ConstantsApi - } - } - pub struct StorageApi; - impl StorageApi { - pub fn system(&self) -> system::storage::StorageApi { - system::storage::StorageApi - } - pub fn timestamp(&self) -> timestamp::storage::StorageApi { - timestamp::storage::StorageApi - } - pub fn aura(&self) -> aura::storage::StorageApi { - aura::storage::StorageApi - } - pub fn grandpa(&self) -> grandpa::storage::StorageApi { - grandpa::storage::StorageApi - } - pub fn starknet(&self) -> starknet::storage::StorageApi { - starknet::storage::StorageApi - } - pub fn autonomous(&self) -> autonomous::storage::StorageApi { - autonomous::storage::StorageApi - } - } - pub struct TransactionApi; - impl TransactionApi { - pub fn system(&self) -> system::calls::TransactionApi { - system::calls::TransactionApi - } - pub fn timestamp(&self) -> timestamp::calls::TransactionApi { - timestamp::calls::TransactionApi - } - pub fn grandpa(&self) -> grandpa::calls::TransactionApi { - grandpa::calls::TransactionApi - } - pub fn starknet(&self) -> starknet::calls::TransactionApi { - starknet::calls::TransactionApi - } - pub fn autonomous(&self) -> autonomous::calls::TransactionApi { - autonomous::calls::TransactionApi - } - } - #[doc = r" check whether the metadata provided is aligned with this statically generated code."] - pub fn is_codegen_valid_for(metadata: &::subxt::Metadata) -> bool { - let runtime_metadata_hash = - metadata.hasher().only_these_pallets(&PALLETS).only_these_runtime_apis(&RUNTIME_APIS).hash(); - runtime_metadata_hash - == [ - 117u8, 185u8, 174u8, 237u8, 196u8, 139u8, 66u8, 59u8, 25u8, 86u8, 75u8, 39u8, 46u8, 226u8, 30u8, 205u8, - 54u8, 201u8, 140u8, 156u8, 175u8, 241u8, 134u8, 233u8, 233u8, 215u8, 159u8, 145u8, 119u8, 176u8, 38u8, - 59u8, - ] - } - pub mod system { - use super::root_mod; - use super::runtime_types; - #[doc = "Error for the System pallet"] - pub type Error = runtime_types::frame_system::pallet::Error; - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub type Call = runtime_types::frame_system::pallet::Call; - pub mod calls { - use super::root_mod; - use super::runtime_types; - type DispatchError = runtime_types::sp_runtime::DispatchError; - pub mod types { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::remark`]."] - pub struct Remark { - pub remark: remark::Remark, - } - pub mod remark { - use super::runtime_types; - pub type Remark = ::std::vec::Vec<::core::primitive::u8>; - } - impl ::subxt::blocks::StaticExtrinsic for Remark { - const PALLET: &'static str = "System"; - const CALL: &'static str = "remark"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::set_heap_pages`]."] - pub struct SetHeapPages { - pub pages: set_heap_pages::Pages, - } - pub mod set_heap_pages { - use super::runtime_types; - pub type Pages = ::core::primitive::u64; - } - impl ::subxt::blocks::StaticExtrinsic for SetHeapPages { - const PALLET: &'static str = "System"; - const CALL: &'static str = "set_heap_pages"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::set_code`]."] - pub struct SetCode { - pub code: set_code::Code, - } - pub mod set_code { - use super::runtime_types; - pub type Code = ::std::vec::Vec<::core::primitive::u8>; - } - impl ::subxt::blocks::StaticExtrinsic for SetCode { - const PALLET: &'static str = "System"; - const CALL: &'static str = "set_code"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::set_code_without_checks`]."] - pub struct SetCodeWithoutChecks { - pub code: set_code_without_checks::Code, - } - pub mod set_code_without_checks { - use super::runtime_types; - pub type Code = ::std::vec::Vec<::core::primitive::u8>; - } - impl ::subxt::blocks::StaticExtrinsic for SetCodeWithoutChecks { - const PALLET: &'static str = "System"; - const CALL: &'static str = "set_code_without_checks"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::set_storage`]."] - pub struct SetStorage { - pub items: set_storage::Items, - } - pub mod set_storage { - use super::runtime_types; - pub type Items = ::std::vec::Vec<( - ::std::vec::Vec<::core::primitive::u8>, - ::std::vec::Vec<::core::primitive::u8>, - )>; - } - impl ::subxt::blocks::StaticExtrinsic for SetStorage { - const PALLET: &'static str = "System"; - const CALL: &'static str = "set_storage"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::kill_storage`]."] - pub struct KillStorage { - pub keys: kill_storage::Keys, - } - pub mod kill_storage { - use super::runtime_types; - pub type Keys = ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>; - } - impl ::subxt::blocks::StaticExtrinsic for KillStorage { - const PALLET: &'static str = "System"; - const CALL: &'static str = "kill_storage"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::kill_prefix`]."] - pub struct KillPrefix { - pub prefix: kill_prefix::Prefix, - pub subkeys: kill_prefix::Subkeys, - } - pub mod kill_prefix { - use super::runtime_types; - pub type Prefix = ::std::vec::Vec<::core::primitive::u8>; - pub type Subkeys = ::core::primitive::u32; - } - impl ::subxt::blocks::StaticExtrinsic for KillPrefix { - const PALLET: &'static str = "System"; - const CALL: &'static str = "kill_prefix"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::remark_with_event`]."] - pub struct RemarkWithEvent { - pub remark: remark_with_event::Remark, - } - pub mod remark_with_event { - use super::runtime_types; - pub type Remark = ::std::vec::Vec<::core::primitive::u8>; - } - impl ::subxt::blocks::StaticExtrinsic for RemarkWithEvent { - const PALLET: &'static str = "System"; - const CALL: &'static str = "remark_with_event"; - } - } - pub struct TransactionApi; - impl TransactionApi { - #[doc = "See [`Pallet::remark`]."] - pub fn remark(&self, remark: types::remark::Remark) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "remark", - types::Remark { remark }, - [ - 43u8, 126u8, 180u8, 174u8, 141u8, 48u8, 52u8, 125u8, 166u8, 212u8, 216u8, 98u8, 100u8, - 24u8, 132u8, 71u8, 101u8, 64u8, 246u8, 169u8, 33u8, 250u8, 147u8, 208u8, 2u8, 40u8, 129u8, - 209u8, 232u8, 207u8, 207u8, 13u8, - ], - ) - } - #[doc = "See [`Pallet::set_heap_pages`]."] - pub fn set_heap_pages( - &self, - pages: types::set_heap_pages::Pages, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "set_heap_pages", - types::SetHeapPages { pages }, - [ - 188u8, 191u8, 99u8, 216u8, 219u8, 109u8, 141u8, 50u8, 78u8, 235u8, 215u8, 242u8, 195u8, - 24u8, 111u8, 76u8, 229u8, 64u8, 99u8, 225u8, 134u8, 121u8, 81u8, 209u8, 127u8, 223u8, 98u8, - 215u8, 150u8, 70u8, 57u8, 147u8, - ], - ) - } - #[doc = "See [`Pallet::set_code`]."] - pub fn set_code(&self, code: types::set_code::Code) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "set_code", - types::SetCode { code }, - [ - 233u8, 248u8, 88u8, 245u8, 28u8, 65u8, 25u8, 169u8, 35u8, 237u8, 19u8, 203u8, 136u8, 160u8, - 18u8, 3u8, 20u8, 197u8, 81u8, 169u8, 244u8, 188u8, 27u8, 147u8, 147u8, 236u8, 65u8, 25u8, - 3u8, 143u8, 182u8, 22u8, - ], - ) - } - #[doc = "See [`Pallet::set_code_without_checks`]."] - pub fn set_code_without_checks( - &self, - code: types::set_code_without_checks::Code, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "set_code_without_checks", - types::SetCodeWithoutChecks { code }, - [ - 82u8, 212u8, 157u8, 44u8, 70u8, 0u8, 143u8, 15u8, 109u8, 109u8, 107u8, 157u8, 141u8, 42u8, - 169u8, 11u8, 15u8, 186u8, 252u8, 138u8, 10u8, 147u8, 15u8, 178u8, 247u8, 229u8, 213u8, - 98u8, 207u8, 231u8, 119u8, 115u8, - ], - ) - } - #[doc = "See [`Pallet::set_storage`]."] - pub fn set_storage(&self, items: types::set_storage::Items) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "set_storage", - types::SetStorage { items }, - [ - 141u8, 216u8, 52u8, 222u8, 223u8, 136u8, 123u8, 181u8, 19u8, 75u8, 163u8, 102u8, 229u8, - 189u8, 158u8, 142u8, 95u8, 235u8, 240u8, 49u8, 150u8, 76u8, 78u8, 137u8, 126u8, 88u8, - 183u8, 88u8, 231u8, 146u8, 234u8, 43u8, - ], - ) - } - #[doc = "See [`Pallet::kill_storage`]."] - pub fn kill_storage( - &self, - keys: types::kill_storage::Keys, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "kill_storage", - types::KillStorage { keys }, - [ - 73u8, 63u8, 196u8, 36u8, 144u8, 114u8, 34u8, 213u8, 108u8, 93u8, 209u8, 234u8, 153u8, - 185u8, 33u8, 91u8, 187u8, 195u8, 223u8, 130u8, 58u8, 156u8, 63u8, 47u8, 228u8, 249u8, - 216u8, 139u8, 143u8, 177u8, 41u8, 35u8, - ], - ) - } - #[doc = "See [`Pallet::kill_prefix`]."] - pub fn kill_prefix( - &self, - prefix: types::kill_prefix::Prefix, - subkeys: types::kill_prefix::Subkeys, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "kill_prefix", - types::KillPrefix { prefix, subkeys }, - [ - 184u8, 57u8, 139u8, 24u8, 208u8, 87u8, 108u8, 215u8, 198u8, 189u8, 175u8, 242u8, 167u8, - 215u8, 97u8, 63u8, 110u8, 166u8, 238u8, 98u8, 67u8, 236u8, 111u8, 110u8, 234u8, 81u8, - 102u8, 5u8, 182u8, 5u8, 214u8, 85u8, - ], - ) - } - #[doc = "See [`Pallet::remark_with_event`]."] - pub fn remark_with_event( - &self, - remark: types::remark_with_event::Remark, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "System", - "remark_with_event", - types::RemarkWithEvent { remark }, - [ - 120u8, 120u8, 153u8, 92u8, 184u8, 85u8, 34u8, 2u8, 174u8, 206u8, 105u8, 228u8, 233u8, - 130u8, 80u8, 246u8, 228u8, 59u8, 234u8, 240u8, 4u8, 49u8, 147u8, 170u8, 115u8, 91u8, 149u8, - 200u8, 228u8, 181u8, 8u8, 154u8, - ], - ) - } - } - } - #[doc = "Event for the System pallet."] - pub type Event = runtime_types::frame_system::pallet::Event; - pub mod events { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "An extrinsic completed successfully."] - pub struct ExtrinsicSuccess { - pub dispatch_info: extrinsic_success::DispatchInfo, - } - pub mod extrinsic_success { - use super::runtime_types; - pub type DispatchInfo = runtime_types::frame_support::dispatch::DispatchInfo; - } - impl ::subxt::events::StaticEvent for ExtrinsicSuccess { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "ExtrinsicSuccess"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "An extrinsic failed."] - pub struct ExtrinsicFailed { - pub dispatch_error: extrinsic_failed::DispatchError, - pub dispatch_info: extrinsic_failed::DispatchInfo, - } - pub mod extrinsic_failed { - use super::runtime_types; - pub type DispatchError = runtime_types::sp_runtime::DispatchError; - pub type DispatchInfo = runtime_types::frame_support::dispatch::DispatchInfo; - } - impl ::subxt::events::StaticEvent for ExtrinsicFailed { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "ExtrinsicFailed"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "`:code` was updated."] - pub struct CodeUpdated; - impl ::subxt::events::StaticEvent for CodeUpdated { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "CodeUpdated"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "A new account was created."] - pub struct NewAccount { - pub account: new_account::Account, - } - pub mod new_account { - use super::runtime_types; - pub type Account = ::subxt::utils::AccountId32; - } - impl ::subxt::events::StaticEvent for NewAccount { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "NewAccount"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "An account was reaped."] - pub struct KilledAccount { - pub account: killed_account::Account, - } - pub mod killed_account { - use super::runtime_types; - pub type Account = ::subxt::utils::AccountId32; - } - impl ::subxt::events::StaticEvent for KilledAccount { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "KilledAccount"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "On on-chain remark happened."] - pub struct Remarked { - pub sender: remarked::Sender, - pub hash: remarked::Hash, - } - pub mod remarked { - use super::runtime_types; - pub type Sender = ::subxt::utils::AccountId32; - pub type Hash = ::subxt::utils::H256; - } - impl ::subxt::events::StaticEvent for Remarked { - const PALLET: &'static str = "System"; - const EVENT: &'static str = "Remarked"; - } - } - pub mod storage { - use super::runtime_types; - pub mod types { - use super::runtime_types; - pub mod account { - use super::runtime_types; - pub type Account = runtime_types::frame_system::AccountInfo<::core::primitive::u32, ()>; - pub type Param0 = ::subxt::utils::AccountId32; - } - pub mod extrinsic_count { - use super::runtime_types; - pub type ExtrinsicCount = ::core::primitive::u32; - } - pub mod block_weight { - use super::runtime_types; - pub type BlockWeight = runtime_types::frame_support::dispatch::PerDispatchClass< - runtime_types::sp_weights::weight_v2::Weight, - >; - } - pub mod all_extrinsics_len { - use super::runtime_types; - pub type AllExtrinsicsLen = ::core::primitive::u32; - } - pub mod block_hash { - use super::runtime_types; - pub type BlockHash = ::subxt::utils::H256; - pub type Param0 = ::core::primitive::u32; - } - pub mod extrinsic_data { - use super::runtime_types; - pub type ExtrinsicData = ::std::vec::Vec<::core::primitive::u8>; - pub type Param0 = ::core::primitive::u32; - } - pub mod number { - use super::runtime_types; - pub type Number = ::core::primitive::u32; - } - pub mod parent_hash { - use super::runtime_types; - pub type ParentHash = ::subxt::utils::H256; - } - pub mod digest { - use super::runtime_types; - pub type Digest = runtime_types::sp_runtime::generic::digest::Digest; - } - pub mod events { - use super::runtime_types; - pub type Events = ::std::vec::Vec< - runtime_types::frame_system::EventRecord< - runtime_types::madara_runtime::RuntimeEvent, - ::subxt::utils::H256, - >, - >; - } - pub mod event_count { - use super::runtime_types; - pub type EventCount = ::core::primitive::u32; - } - pub mod event_topics { - use super::runtime_types; - pub type EventTopics = ::std::vec::Vec<(::core::primitive::u32, ::core::primitive::u32)>; - pub type Param0 = ::subxt::utils::H256; - } - pub mod last_runtime_upgrade { - use super::runtime_types; - pub type LastRuntimeUpgrade = runtime_types::frame_system::LastRuntimeUpgradeInfo; - } - pub mod upgraded_to_u32_ref_count { - use super::runtime_types; - pub type UpgradedToU32RefCount = ::core::primitive::bool; - } - pub mod upgraded_to_triple_ref_count { - use super::runtime_types; - pub type UpgradedToTripleRefCount = ::core::primitive::bool; - } - pub mod execution_phase { - use super::runtime_types; - pub type ExecutionPhase = runtime_types::frame_system::Phase; - } - } - pub struct StorageApi; - impl StorageApi { - #[doc = " The full account information for a particular account ID."] - pub fn account_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::account::Account, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "System", - "Account", - (), - [ - 207u8, 128u8, 217u8, 6u8, 244u8, 231u8, 113u8, 230u8, 246u8, 220u8, 226u8, 62u8, 206u8, - 203u8, 104u8, 119u8, 181u8, 97u8, 211u8, 3u8, 157u8, 102u8, 196u8, 131u8, 51u8, 221u8, - 41u8, 183u8, 108u8, 28u8, 247u8, 73u8, - ], - ) - } - #[doc = " The full account information for a particular account ID."] - pub fn account( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::account::Account, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "Account", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 207u8, 128u8, 217u8, 6u8, 244u8, 231u8, 113u8, 230u8, 246u8, 220u8, 226u8, 62u8, 206u8, - 203u8, 104u8, 119u8, 181u8, 97u8, 211u8, 3u8, 157u8, 102u8, 196u8, 131u8, 51u8, 221u8, - 41u8, 183u8, 108u8, 28u8, 247u8, 73u8, - ], - ) - } - #[doc = " Total extrinsics count for the current block."] - pub fn extrinsic_count( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::extrinsic_count::ExtrinsicCount, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "ExtrinsicCount", - (), - [ - 102u8, 76u8, 236u8, 42u8, 40u8, 231u8, 33u8, 222u8, 123u8, 147u8, 153u8, 148u8, 234u8, - 203u8, 181u8, 119u8, 6u8, 187u8, 177u8, 199u8, 120u8, 47u8, 137u8, 254u8, 96u8, 100u8, - 165u8, 182u8, 249u8, 230u8, 159u8, 79u8, - ], - ) - } - #[doc = " The current weight for the block."] - pub fn block_weight( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::block_weight::BlockWeight, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "BlockWeight", - (), - [ - 158u8, 46u8, 228u8, 89u8, 210u8, 214u8, 84u8, 154u8, 50u8, 68u8, 63u8, 62u8, 43u8, 42u8, - 99u8, 27u8, 54u8, 42u8, 146u8, 44u8, 241u8, 216u8, 229u8, 30u8, 216u8, 255u8, 165u8, 238u8, - 181u8, 130u8, 36u8, 102u8, - ], - ) - } - #[doc = " Total length (in bytes) for all extrinsics put together, for the current block."] - pub fn all_extrinsics_len( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::all_extrinsics_len::AllExtrinsicsLen, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "AllExtrinsicsLen", - (), - [ - 117u8, 86u8, 61u8, 243u8, 41u8, 51u8, 102u8, 214u8, 137u8, 100u8, 243u8, 185u8, 122u8, - 174u8, 187u8, 117u8, 86u8, 189u8, 63u8, 135u8, 101u8, 218u8, 203u8, 201u8, 237u8, 254u8, - 128u8, 183u8, 169u8, 221u8, 242u8, 65u8, - ], - ) - } - #[doc = " Map of block numbers to block hashes."] - pub fn block_hash_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::block_hash::BlockHash, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "System", - "BlockHash", - (), - [ - 217u8, 32u8, 215u8, 253u8, 24u8, 182u8, 207u8, 178u8, 157u8, 24u8, 103u8, 100u8, 195u8, - 165u8, 69u8, 152u8, 112u8, 181u8, 56u8, 192u8, 164u8, 16u8, 20u8, 222u8, 28u8, 214u8, - 144u8, 142u8, 146u8, 69u8, 202u8, 118u8, - ], - ) - } - #[doc = " Map of block numbers to block hashes."] - pub fn block_hash( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::block_hash::BlockHash, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "BlockHash", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 217u8, 32u8, 215u8, 253u8, 24u8, 182u8, 207u8, 178u8, 157u8, 24u8, 103u8, 100u8, 195u8, - 165u8, 69u8, 152u8, 112u8, 181u8, 56u8, 192u8, 164u8, 16u8, 20u8, 222u8, 28u8, 214u8, - 144u8, 142u8, 146u8, 69u8, 202u8, 118u8, - ], - ) - } - #[doc = " Extrinsics data for the current block (maps an extrinsic's index to its data)."] - pub fn extrinsic_data_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::extrinsic_data::ExtrinsicData, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "System", - "ExtrinsicData", - (), - [ - 160u8, 180u8, 122u8, 18u8, 196u8, 26u8, 2u8, 37u8, 115u8, 232u8, 133u8, 220u8, 106u8, - 245u8, 4u8, 129u8, 42u8, 84u8, 241u8, 45u8, 199u8, 179u8, 128u8, 61u8, 170u8, 137u8, 231u8, - 156u8, 247u8, 57u8, 47u8, 38u8, - ], - ) - } - #[doc = " Extrinsics data for the current block (maps an extrinsic's index to its data)."] - pub fn extrinsic_data( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::extrinsic_data::ExtrinsicData, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "ExtrinsicData", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 160u8, 180u8, 122u8, 18u8, 196u8, 26u8, 2u8, 37u8, 115u8, 232u8, 133u8, 220u8, 106u8, - 245u8, 4u8, 129u8, 42u8, 84u8, 241u8, 45u8, 199u8, 179u8, 128u8, 61u8, 170u8, 137u8, 231u8, - 156u8, 247u8, 57u8, 47u8, 38u8, - ], - ) - } - #[doc = " The current block number being processed. Set by `execute_block`."] - pub fn number( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::number::Number, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "Number", - (), - [ - 30u8, 194u8, 177u8, 90u8, 194u8, 232u8, 46u8, 180u8, 85u8, 129u8, 14u8, 9u8, 8u8, 8u8, - 23u8, 95u8, 230u8, 5u8, 13u8, 105u8, 125u8, 2u8, 22u8, 200u8, 78u8, 93u8, 115u8, 28u8, - 150u8, 113u8, 48u8, 53u8, - ], - ) - } - #[doc = " Hash of the previous block."] - pub fn parent_hash( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::parent_hash::ParentHash, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "ParentHash", - (), - [ - 26u8, 130u8, 11u8, 216u8, 155u8, 71u8, 128u8, 170u8, 30u8, 153u8, 21u8, 192u8, 62u8, 93u8, - 137u8, 80u8, 120u8, 81u8, 202u8, 94u8, 248u8, 125u8, 71u8, 82u8, 141u8, 229u8, 32u8, 56u8, - 73u8, 50u8, 101u8, 78u8, - ], - ) - } - #[doc = " Digest of the current block, also part of the block header."] - pub fn digest( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::digest::Digest, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "Digest", - (), - [ - 61u8, 64u8, 237u8, 91u8, 145u8, 232u8, 17u8, 254u8, 181u8, 16u8, 234u8, 91u8, 51u8, 140u8, - 254u8, 131u8, 98u8, 135u8, 21u8, 37u8, 251u8, 20u8, 58u8, 92u8, 123u8, 141u8, 14u8, 227u8, - 146u8, 46u8, 222u8, 117u8, - ], - ) - } - #[doc = " Events deposited for the current block."] - #[doc = ""] - #[doc = " NOTE: The item is unbound and should therefore never be read on chain."] - #[doc = " It could otherwise inflate the PoV size of a block."] - #[doc = ""] - #[doc = " Events have a large in-memory size. Box the events to not go out-of-memory"] - #[doc = " just in case someone still reads them from within the runtime."] - pub fn events( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::events::Events, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "Events", - (), - [ - 255u8, 169u8, 249u8, 70u8, 39u8, 153u8, 238u8, 39u8, 195u8, 196u8, 92u8, 84u8, 82u8, 162u8, - 155u8, 174u8, 44u8, 174u8, 242u8, 82u8, 193u8, 130u8, 148u8, 194u8, 182u8, 64u8, 126u8, - 65u8, 148u8, 199u8, 233u8, 124u8, - ], - ) - } - #[doc = " The number of events in the `Events` list."] - pub fn event_count( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::event_count::EventCount, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "EventCount", - (), - [ - 175u8, 24u8, 252u8, 184u8, 210u8, 167u8, 146u8, 143u8, 164u8, 80u8, 151u8, 205u8, 189u8, - 189u8, 55u8, 220u8, 47u8, 101u8, 181u8, 33u8, 254u8, 131u8, 13u8, 143u8, 3u8, 244u8, 245u8, - 45u8, 2u8, 210u8, 79u8, 133u8, - ], - ) - } - #[doc = " Mapping between a topic (represented by T::Hash) and a vector of indexes"] - #[doc = " of events in the `>` list."] - #[doc = ""] - #[doc = " All topic vectors have deterministic storage locations depending on the topic. This"] - #[doc = " allows light-clients to leverage the changes trie storage tracking mechanism and"] - #[doc = " in case of changes fetch the list of events of interest."] - #[doc = ""] - #[doc = " The value has the type `(BlockNumberFor, EventIndex)` because if we used only just"] - #[doc = " the `EventIndex` then in case if the topic has the same contents on the next block"] - #[doc = " no notification will be triggered thus the event might be lost."] - pub fn event_topics_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::event_topics::EventTopics, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "System", - "EventTopics", - (), - [ - 40u8, 225u8, 14u8, 75u8, 44u8, 176u8, 76u8, 34u8, 143u8, 107u8, 69u8, 133u8, 114u8, 13u8, - 172u8, 250u8, 141u8, 73u8, 12u8, 65u8, 217u8, 63u8, 120u8, 241u8, 48u8, 106u8, 143u8, - 161u8, 128u8, 100u8, 166u8, 59u8, - ], - ) - } - #[doc = " Mapping between a topic (represented by T::Hash) and a vector of indexes"] - #[doc = " of events in the `>` list."] - #[doc = ""] - #[doc = " All topic vectors have deterministic storage locations depending on the topic. This"] - #[doc = " allows light-clients to leverage the changes trie storage tracking mechanism and"] - #[doc = " in case of changes fetch the list of events of interest."] - #[doc = ""] - #[doc = " The value has the type `(BlockNumberFor, EventIndex)` because if we used only just"] - #[doc = " the `EventIndex` then in case if the topic has the same contents on the next block"] - #[doc = " no notification will be triggered thus the event might be lost."] - pub fn event_topics( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::event_topics::EventTopics, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "EventTopics", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 40u8, 225u8, 14u8, 75u8, 44u8, 176u8, 76u8, 34u8, 143u8, 107u8, 69u8, 133u8, 114u8, 13u8, - 172u8, 250u8, 141u8, 73u8, 12u8, 65u8, 217u8, 63u8, 120u8, 241u8, 48u8, 106u8, 143u8, - 161u8, 128u8, 100u8, 166u8, 59u8, - ], - ) - } - #[doc = " Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened."] - pub fn last_runtime_upgrade( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::last_runtime_upgrade::LastRuntimeUpgrade, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "LastRuntimeUpgrade", - (), - [ - 137u8, 29u8, 175u8, 75u8, 197u8, 208u8, 91u8, 207u8, 156u8, 87u8, 148u8, 68u8, 91u8, 140u8, - 22u8, 233u8, 1u8, 229u8, 56u8, 34u8, 40u8, 194u8, 253u8, 30u8, 163u8, 39u8, 54u8, 209u8, - 13u8, 27u8, 139u8, 184u8, - ], - ) - } - #[doc = " True if we have upgraded so that `type RefCount` is `u32`. False (default) if not."] - pub fn upgraded_to_u32_ref_count( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::upgraded_to_u32_ref_count::UpgradedToU32RefCount, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "UpgradedToU32RefCount", - (), - [ - 229u8, 73u8, 9u8, 132u8, 186u8, 116u8, 151u8, 171u8, 145u8, 29u8, 34u8, 130u8, 52u8, 146u8, - 124u8, 175u8, 79u8, 189u8, 147u8, 230u8, 234u8, 107u8, 124u8, 31u8, 2u8, 22u8, 86u8, 190u8, - 4u8, 147u8, 50u8, 245u8, - ], - ) - } - #[doc = " True if we have upgraded so that AccountInfo contains three types of `RefCount`. False"] - #[doc = " (default) if not."] - pub fn upgraded_to_triple_ref_count( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::upgraded_to_triple_ref_count::UpgradedToTripleRefCount, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "UpgradedToTripleRefCount", - (), - [ - 97u8, 66u8, 124u8, 243u8, 27u8, 167u8, 147u8, 81u8, 254u8, 201u8, 101u8, 24u8, 40u8, 231u8, - 14u8, 179u8, 154u8, 163u8, 71u8, 81u8, 185u8, 167u8, 82u8, 254u8, 189u8, 3u8, 101u8, 207u8, - 206u8, 194u8, 155u8, 151u8, - ], - ) - } - #[doc = " The execution phase of the block."] - pub fn execution_phase( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::execution_phase::ExecutionPhase, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "System", - "ExecutionPhase", - (), - [ - 191u8, 129u8, 100u8, 134u8, 126u8, 116u8, 154u8, 203u8, 220u8, 200u8, 0u8, 26u8, 161u8, - 250u8, 133u8, 205u8, 146u8, 24u8, 5u8, 156u8, 158u8, 35u8, 36u8, 253u8, 52u8, 235u8, 86u8, - 167u8, 35u8, 100u8, 119u8, 27u8, - ], - ) - } - } - } - pub mod constants { - use super::runtime_types; - pub struct ConstantsApi; - impl ConstantsApi { - #[doc = " Block & extrinsics weights: base values and limits."] - pub fn block_weights( - &self, - ) -> ::subxt::constants::Address { - ::subxt::constants::Address::new_static( - "System", - "BlockWeights", - [ - 176u8, 124u8, 225u8, 136u8, 25u8, 73u8, 247u8, 33u8, 82u8, 206u8, 85u8, 190u8, 127u8, - 102u8, 71u8, 11u8, 185u8, 8u8, 58u8, 0u8, 94u8, 55u8, 163u8, 177u8, 104u8, 59u8, 60u8, - 136u8, 246u8, 116u8, 0u8, 239u8, - ], - ) - } - #[doc = " The maximum length of a block (in bytes)."] - pub fn block_length( - &self, - ) -> ::subxt::constants::Address { - ::subxt::constants::Address::new_static( - "System", - "BlockLength", - [ - 23u8, 242u8, 225u8, 39u8, 225u8, 67u8, 152u8, 41u8, 155u8, 104u8, 68u8, 229u8, 185u8, - 133u8, 10u8, 143u8, 184u8, 152u8, 234u8, 44u8, 140u8, 96u8, 166u8, 235u8, 162u8, 160u8, - 72u8, 7u8, 35u8, 194u8, 3u8, 37u8, - ], - ) - } - #[doc = " Maximum number of block number to block hash mappings to keep (oldest pruned first)."] - pub fn block_hash_count(&self) -> ::subxt::constants::Address<::core::primitive::u32> { - ::subxt::constants::Address::new_static( - "System", - "BlockHashCount", - [ - 98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, - 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, - 203u8, 100u8, 41u8, 145u8, - ], - ) - } - #[doc = " The weight of runtime database operations the runtime can invoke."] - pub fn db_weight(&self) -> ::subxt::constants::Address { - ::subxt::constants::Address::new_static( - "System", - "DbWeight", - [ - 42u8, 43u8, 178u8, 142u8, 243u8, 203u8, 60u8, 173u8, 118u8, 111u8, 200u8, 170u8, 102u8, - 70u8, 237u8, 187u8, 198u8, 120u8, 153u8, 232u8, 183u8, 76u8, 74u8, 10u8, 70u8, 243u8, 14u8, - 218u8, 213u8, 126u8, 29u8, 177u8, - ], - ) - } - #[doc = " Get the chain's current version."] - pub fn version(&self) -> ::subxt::constants::Address { - ::subxt::constants::Address::new_static( - "System", - "Version", - [ - 219u8, 45u8, 162u8, 245u8, 177u8, 246u8, 48u8, 126u8, 191u8, 157u8, 228u8, 83u8, 111u8, - 133u8, 183u8, 13u8, 148u8, 108u8, 92u8, 102u8, 72u8, 205u8, 74u8, 242u8, 233u8, 79u8, 20u8, - 170u8, 72u8, 202u8, 158u8, 165u8, - ], - ) - } - #[doc = " The designated SS58 prefix of this chain."] - #[doc = ""] - #[doc = " This replaces the \"ss58Format\" property declared in the chain spec. Reason is"] - #[doc = " that the runtime should know about the prefix in order to make use of it as"] - #[doc = " an identifier of the chain."] - pub fn ss58_prefix(&self) -> ::subxt::constants::Address<::core::primitive::u16> { - ::subxt::constants::Address::new_static( - "System", - "SS58Prefix", - [ - 116u8, 33u8, 2u8, 170u8, 181u8, 147u8, 171u8, 169u8, 167u8, 227u8, 41u8, 144u8, 11u8, - 236u8, 82u8, 100u8, 74u8, 60u8, 184u8, 72u8, 169u8, 90u8, 208u8, 135u8, 15u8, 117u8, 10u8, - 123u8, 128u8, 193u8, 29u8, 70u8, - ], - ) - } - } - } - } - pub mod timestamp { - use super::root_mod; - use super::runtime_types; - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub type Call = runtime_types::pallet_timestamp::pallet::Call; - pub mod calls { - use super::root_mod; - use super::runtime_types; - type DispatchError = runtime_types::sp_runtime::DispatchError; - pub mod types { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::set`]."] - pub struct Set { - #[codec(compact)] - pub now: set::Now, - } - pub mod set { - use super::runtime_types; - pub type Now = ::core::primitive::u64; - } - impl ::subxt::blocks::StaticExtrinsic for Set { - const PALLET: &'static str = "Timestamp"; - const CALL: &'static str = "set"; - } - } - pub struct TransactionApi; - impl TransactionApi { - #[doc = "See [`Pallet::set`]."] - pub fn set(&self, now: types::set::Now) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Timestamp", - "set", - types::Set { now }, - [ - 37u8, 95u8, 49u8, 218u8, 24u8, 22u8, 0u8, 95u8, 72u8, 35u8, 155u8, 199u8, 213u8, 54u8, - 207u8, 22u8, 185u8, 193u8, 221u8, 70u8, 18u8, 200u8, 4u8, 231u8, 195u8, 173u8, 6u8, 122u8, - 11u8, 203u8, 231u8, 227u8, - ], - ) - } - } - } - pub mod storage { - use super::runtime_types; - pub mod types { - use super::runtime_types; - pub mod now { - use super::runtime_types; - pub type Now = ::core::primitive::u64; - } - pub mod did_update { - use super::runtime_types; - pub type DidUpdate = ::core::primitive::bool; - } - } - pub struct StorageApi; - impl StorageApi { - #[doc = " The current time for the current block."] - pub fn now( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::now::Now, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Timestamp", - "Now", - (), - [ - 44u8, 50u8, 80u8, 30u8, 195u8, 146u8, 123u8, 238u8, 8u8, 163u8, 187u8, 92u8, 61u8, 39u8, - 51u8, 29u8, 173u8, 169u8, 217u8, 158u8, 85u8, 187u8, 141u8, 26u8, 12u8, 115u8, 51u8, 11u8, - 200u8, 244u8, 138u8, 152u8, - ], - ) - } - #[doc = " Whether the timestamp has been updated in this block."] - #[doc = ""] - #[doc = " This value is updated to `true` upon successful submission of a timestamp by a node."] - #[doc = " It is then checked at the end of each block execution in the `on_finalize` hook."] - pub fn did_update( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::did_update::DidUpdate, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Timestamp", - "DidUpdate", - (), - [ - 229u8, 175u8, 246u8, 102u8, 237u8, 158u8, 212u8, 229u8, 238u8, 214u8, 205u8, 160u8, 164u8, - 252u8, 195u8, 75u8, 139u8, 110u8, 22u8, 34u8, 248u8, 204u8, 107u8, 46u8, 20u8, 200u8, - 238u8, 167u8, 71u8, 41u8, 214u8, 140u8, - ], - ) - } - } - } - pub mod constants { - use super::runtime_types; - pub struct ConstantsApi; - impl ConstantsApi { - #[doc = " The minimum period between blocks."] - #[doc = ""] - #[doc = " Be aware that this is different to the *expected* period that the block production"] - #[doc = " apparatus provides. Your chosen consensus system will generally work with this to"] - #[doc = " determine a sensible block time. For example, in the Aura pallet it will be double this"] - #[doc = " period on default settings."] - pub fn minimum_period(&self) -> ::subxt::constants::Address<::core::primitive::u64> { - ::subxt::constants::Address::new_static( - "Timestamp", - "MinimumPeriod", - [ - 128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, - 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, - 42u8, 184u8, 239u8, 42u8, 246u8, - ], - ) - } - } - } - } - pub mod aura { - use super::root_mod; - use super::runtime_types; - pub mod storage { - use super::runtime_types; - pub mod types { - use super::runtime_types; - pub mod authorities { - use super::runtime_types; - pub type Authorities = runtime_types::bounded_collections::bounded_vec::BoundedVec< - runtime_types::sp_consensus_aura::sr25519::app_sr25519::Public, - >; - } - pub mod current_slot { - use super::runtime_types; - pub type CurrentSlot = runtime_types::sp_consensus_slots::Slot; - } - } - pub struct StorageApi; - impl StorageApi { - #[doc = " The current authority set."] - pub fn authorities( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::authorities::Authorities, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Aura", - "Authorities", - (), - [ - 232u8, 129u8, 167u8, 104u8, 47u8, 188u8, 238u8, 164u8, 6u8, 29u8, 129u8, 45u8, 64u8, 182u8, - 194u8, 47u8, 0u8, 73u8, 63u8, 102u8, 204u8, 94u8, 111u8, 96u8, 137u8, 7u8, 141u8, 110u8, - 180u8, 80u8, 228u8, 16u8, - ], - ) - } - #[doc = " The current slot of this block."] - #[doc = ""] - #[doc = " This will be set in `on_initialize`."] - pub fn current_slot( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::current_slot::CurrentSlot, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Aura", - "CurrentSlot", - (), - [ - 112u8, 199u8, 115u8, 248u8, 217u8, 242u8, 45u8, 231u8, 178u8, 53u8, 236u8, 167u8, 219u8, - 238u8, 81u8, 243u8, 39u8, 140u8, 68u8, 19u8, 201u8, 169u8, 211u8, 133u8, 135u8, 213u8, - 150u8, 105u8, 60u8, 252u8, 43u8, 57u8, - ], - ) - } - } - } - } - pub mod grandpa { - use super::root_mod; - use super::runtime_types; - #[doc = "The `Error` enum of this pallet."] - pub type Error = runtime_types::pallet_grandpa::pallet::Error; - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub type Call = runtime_types::pallet_grandpa::pallet::Call; - pub mod calls { - use super::root_mod; - use super::runtime_types; - type DispatchError = runtime_types::sp_runtime::DispatchError; - pub mod types { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::report_equivocation`]."] - pub struct ReportEquivocation { - pub equivocation_proof: ::std::boxed::Box, - pub key_owner_proof: report_equivocation::KeyOwnerProof, - } - pub mod report_equivocation { - use super::runtime_types; - pub type EquivocationProof = runtime_types::sp_consensus_grandpa::EquivocationProof< - ::subxt::utils::H256, - ::core::primitive::u32, - >; - pub type KeyOwnerProof = runtime_types::sp_core::Void; - } - impl ::subxt::blocks::StaticExtrinsic for ReportEquivocation { - const PALLET: &'static str = "Grandpa"; - const CALL: &'static str = "report_equivocation"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::report_equivocation_unsigned`]."] - pub struct ReportEquivocationUnsigned { - pub equivocation_proof: ::std::boxed::Box, - pub key_owner_proof: report_equivocation_unsigned::KeyOwnerProof, - } - pub mod report_equivocation_unsigned { - use super::runtime_types; - pub type EquivocationProof = runtime_types::sp_consensus_grandpa::EquivocationProof< - ::subxt::utils::H256, - ::core::primitive::u32, - >; - pub type KeyOwnerProof = runtime_types::sp_core::Void; - } - impl ::subxt::blocks::StaticExtrinsic for ReportEquivocationUnsigned { - const PALLET: &'static str = "Grandpa"; - const CALL: &'static str = "report_equivocation_unsigned"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::note_stalled`]."] - pub struct NoteStalled { - pub delay: note_stalled::Delay, - pub best_finalized_block_number: note_stalled::BestFinalizedBlockNumber, - } - pub mod note_stalled { - use super::runtime_types; - pub type Delay = ::core::primitive::u32; - pub type BestFinalizedBlockNumber = ::core::primitive::u32; - } - impl ::subxt::blocks::StaticExtrinsic for NoteStalled { - const PALLET: &'static str = "Grandpa"; - const CALL: &'static str = "note_stalled"; - } - } - pub struct TransactionApi; - impl TransactionApi { - #[doc = "See [`Pallet::report_equivocation`]."] - pub fn report_equivocation( - &self, - equivocation_proof: types::report_equivocation::EquivocationProof, - key_owner_proof: types::report_equivocation::KeyOwnerProof, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Grandpa", - "report_equivocation", - types::ReportEquivocation { - equivocation_proof: ::std::boxed::Box::new(equivocation_proof), - key_owner_proof, - }, - [ - 158u8, 70u8, 189u8, 51u8, 231u8, 191u8, 199u8, 33u8, 64u8, 156u8, 71u8, 243u8, 122u8, - 199u8, 216u8, 10u8, 45u8, 73u8, 198u8, 141u8, 31u8, 209u8, 58u8, 164u8, 219u8, 124u8, - 242u8, 26u8, 114u8, 52u8, 65u8, 106u8, - ], - ) - } - #[doc = "See [`Pallet::report_equivocation_unsigned`]."] - pub fn report_equivocation_unsigned( - &self, - equivocation_proof: types::report_equivocation_unsigned::EquivocationProof, - key_owner_proof: types::report_equivocation_unsigned::KeyOwnerProof, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Grandpa", - "report_equivocation_unsigned", - types::ReportEquivocationUnsigned { - equivocation_proof: ::std::boxed::Box::new(equivocation_proof), - key_owner_proof, - }, - [ - 53u8, 23u8, 255u8, 215u8, 105u8, 11u8, 67u8, 177u8, 234u8, 248u8, 183u8, 57u8, 230u8, - 239u8, 54u8, 238u8, 115u8, 170u8, 153u8, 18u8, 55u8, 195u8, 85u8, 98u8, 109u8, 194u8, 57u8, - 225u8, 139u8, 237u8, 171u8, 152u8, - ], - ) - } - #[doc = "See [`Pallet::note_stalled`]."] - pub fn note_stalled( - &self, - delay: types::note_stalled::Delay, - best_finalized_block_number: types::note_stalled::BestFinalizedBlockNumber, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Grandpa", - "note_stalled", - types::NoteStalled { delay, best_finalized_block_number }, - [ - 158u8, 25u8, 64u8, 114u8, 131u8, 139u8, 227u8, 132u8, 42u8, 107u8, 40u8, 249u8, 18u8, 93u8, - 254u8, 86u8, 37u8, 67u8, 250u8, 35u8, 241u8, 194u8, 209u8, 20u8, 39u8, 75u8, 186u8, 21u8, - 48u8, 124u8, 151u8, 31u8, - ], - ) - } - } - } - #[doc = "The `Event` enum of this pallet"] - pub type Event = runtime_types::pallet_grandpa::pallet::Event; - pub mod events { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "New authority set has been applied."] - pub struct NewAuthorities { - pub authority_set: new_authorities::AuthoritySet, - } - pub mod new_authorities { - use super::runtime_types; - pub type AuthoritySet = - ::std::vec::Vec<(runtime_types::sp_consensus_grandpa::app::Public, ::core::primitive::u64)>; - } - impl ::subxt::events::StaticEvent for NewAuthorities { - const PALLET: &'static str = "Grandpa"; - const EVENT: &'static str = "NewAuthorities"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Current authority set has been paused."] - pub struct Paused; - impl ::subxt::events::StaticEvent for Paused { - const PALLET: &'static str = "Grandpa"; - const EVENT: &'static str = "Paused"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Current authority set has been resumed."] - pub struct Resumed; - impl ::subxt::events::StaticEvent for Resumed { - const PALLET: &'static str = "Grandpa"; - const EVENT: &'static str = "Resumed"; - } - } - pub mod storage { - use super::runtime_types; - pub mod types { - use super::runtime_types; - pub mod state { - use super::runtime_types; - pub type State = runtime_types::pallet_grandpa::StoredState<::core::primitive::u32>; - } - pub mod pending_change { - use super::runtime_types; - pub type PendingChange = runtime_types::pallet_grandpa::StoredPendingChange<::core::primitive::u32>; - } - pub mod next_forced { - use super::runtime_types; - pub type NextForced = ::core::primitive::u32; - } - pub mod stalled { - use super::runtime_types; - pub type Stalled = (::core::primitive::u32, ::core::primitive::u32); - } - pub mod current_set_id { - use super::runtime_types; - pub type CurrentSetId = ::core::primitive::u64; - } - pub mod set_id_session { - use super::runtime_types; - pub type SetIdSession = ::core::primitive::u32; - pub type Param0 = ::core::primitive::u64; - } - } - pub struct StorageApi; - impl StorageApi { - #[doc = " State of the current authority set."] - pub fn state( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::state::State, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Grandpa", - "State", - (), - [ - 73u8, 71u8, 112u8, 83u8, 238u8, 75u8, 44u8, 9u8, 180u8, 33u8, 30u8, 121u8, 98u8, 96u8, - 61u8, 133u8, 16u8, 70u8, 30u8, 249u8, 34u8, 148u8, 15u8, 239u8, 164u8, 157u8, 52u8, 27u8, - 144u8, 52u8, 223u8, 109u8, - ], - ) - } - #[doc = " Pending change: (signaled at, scheduled change)."] - pub fn pending_change( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::pending_change::PendingChange, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Grandpa", - "PendingChange", - (), - [ - 150u8, 194u8, 185u8, 248u8, 239u8, 43u8, 141u8, 253u8, 61u8, 106u8, 74u8, 164u8, 209u8, - 204u8, 206u8, 200u8, 32u8, 38u8, 11u8, 78u8, 84u8, 243u8, 181u8, 142u8, 179u8, 151u8, 81u8, - 204u8, 244u8, 150u8, 137u8, 250u8, - ], - ) - } - #[doc = " next block number where we can force a change."] - pub fn next_forced( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::next_forced::NextForced, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Grandpa", - "NextForced", - (), - [ - 3u8, 231u8, 56u8, 18u8, 87u8, 112u8, 227u8, 126u8, 180u8, 131u8, 255u8, 141u8, 82u8, 34u8, - 61u8, 47u8, 234u8, 37u8, 95u8, 62u8, 33u8, 235u8, 231u8, 122u8, 125u8, 8u8, 223u8, 95u8, - 255u8, 204u8, 40u8, 97u8, - ], - ) - } - #[doc = " `true` if we are currently stalled."] - pub fn stalled( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::stalled::Stalled, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Grandpa", - "Stalled", - (), - [ - 6u8, 81u8, 205u8, 142u8, 195u8, 48u8, 0u8, 247u8, 108u8, 170u8, 10u8, 249u8, 72u8, 206u8, - 32u8, 103u8, 109u8, 57u8, 51u8, 21u8, 144u8, 204u8, 79u8, 8u8, 191u8, 185u8, 38u8, 34u8, - 118u8, 223u8, 75u8, 241u8, - ], - ) - } - #[doc = " The number of changes (both in terms of keys and underlying economic responsibilities)"] - #[doc = " in the \"set\" of Grandpa validators from genesis."] - pub fn current_set_id( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::current_set_id::CurrentSetId, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Grandpa", - "CurrentSetId", - (), - [ - 234u8, 215u8, 218u8, 42u8, 30u8, 76u8, 129u8, 40u8, 125u8, 137u8, 207u8, 47u8, 46u8, 213u8, - 159u8, 50u8, 175u8, 81u8, 155u8, 123u8, 246u8, 175u8, 156u8, 68u8, 22u8, 113u8, 135u8, - 137u8, 163u8, 18u8, 115u8, 73u8, - ], - ) - } - #[doc = " A mapping from grandpa set ID to the index of the *most recent* session for which its"] - #[doc = " members were responsible."] - #[doc = ""] - #[doc = " This is only used for validating equivocation proofs. An equivocation proof must"] - #[doc = " contains a key-ownership proof for a given session, therefore we need a way to tie"] - #[doc = " together sessions and GRANDPA set ids, i.e. we need to validate that a validator"] - #[doc = " was the owner of a given key on a given session, and what the active set ID was"] - #[doc = " during that session."] - #[doc = ""] - #[doc = " TWOX-NOTE: `SetId` is not under user control."] - pub fn set_id_session_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::set_id_session::SetIdSession, - (), - (), - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Grandpa", - "SetIdSession", - (), - [ - 47u8, 0u8, 239u8, 121u8, 187u8, 213u8, 254u8, 50u8, 238u8, 10u8, 162u8, 65u8, 189u8, 166u8, - 37u8, 74u8, 82u8, 81u8, 160u8, 20u8, 180u8, 253u8, 238u8, 18u8, 209u8, 203u8, 38u8, 148u8, - 16u8, 105u8, 72u8, 169u8, - ], - ) - } - #[doc = " A mapping from grandpa set ID to the index of the *most recent* session for which its"] - #[doc = " members were responsible."] - #[doc = ""] - #[doc = " This is only used for validating equivocation proofs. An equivocation proof must"] - #[doc = " contains a key-ownership proof for a given session, therefore we need a way to tie"] - #[doc = " together sessions and GRANDPA set ids, i.e. we need to validate that a validator"] - #[doc = " was the owner of a given key on a given session, and what the active set ID was"] - #[doc = " during that session."] - #[doc = ""] - #[doc = " TWOX-NOTE: `SetId` is not under user control."] - pub fn set_id_session( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::set_id_session::SetIdSession, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Grandpa", - "SetIdSession", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 47u8, 0u8, 239u8, 121u8, 187u8, 213u8, 254u8, 50u8, 238u8, 10u8, 162u8, 65u8, 189u8, 166u8, - 37u8, 74u8, 82u8, 81u8, 160u8, 20u8, 180u8, 253u8, 238u8, 18u8, 209u8, 203u8, 38u8, 148u8, - 16u8, 105u8, 72u8, 169u8, - ], - ) - } - } - } - pub mod constants { - use super::runtime_types; - pub struct ConstantsApi; - impl ConstantsApi { - #[doc = " Max Authorities in use"] - pub fn max_authorities(&self) -> ::subxt::constants::Address<::core::primitive::u32> { - ::subxt::constants::Address::new_static( - "Grandpa", - "MaxAuthorities", - [ - 98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, - 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, - 203u8, 100u8, 41u8, 145u8, - ], - ) - } - #[doc = " The maximum number of nominators for each validator."] - pub fn max_nominators(&self) -> ::subxt::constants::Address<::core::primitive::u32> { - ::subxt::constants::Address::new_static( - "Grandpa", - "MaxNominators", - [ - 98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, - 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, - 203u8, 100u8, 41u8, 145u8, - ], - ) - } - #[doc = " The maximum number of entries to keep in the set id to session index mapping."] - #[doc = ""] - #[doc = " Since the `SetIdSession` map is only used for validating equivocations this"] - #[doc = " value should relate to the bonding duration of whatever staking system is"] - #[doc = " being used (if any). If equivocation handling is not enabled then this value"] - #[doc = " can be zero."] - pub fn max_set_id_session_entries(&self) -> ::subxt::constants::Address<::core::primitive::u64> { - ::subxt::constants::Address::new_static( - "Grandpa", - "MaxSetIdSessionEntries", - [ - 128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, - 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, - 42u8, 184u8, 239u8, 42u8, 246u8, - ], - ) - } - } - } - } - pub mod starknet { - use super::root_mod; - use super::runtime_types; - #[doc = "The Starknet pallet custom errors."] - #[doc = "ERRORS"] - pub type Error = runtime_types::pallet_starknet::pallet::Error; - #[doc = "The Starknet pallet external functions."] - #[doc = "Dispatchable functions allows users to interact with the pallet and invoke state changes."] - #[doc = "These functions materialize as \"extrinsics\", which are often compared to transactions."] - #[doc = "Dispatchable functions must be annotated with a weight and must return a DispatchResult."] - pub type Call = runtime_types::pallet_starknet::pallet::Call; - pub mod calls { - use super::root_mod; - use super::runtime_types; - type DispatchError = runtime_types::sp_runtime::DispatchError; - pub mod types { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::set_sequencer_address`]."] - pub struct SetSequencerAddress { - pub addr: set_sequencer_address::Addr, - } - pub mod set_sequencer_address { - use super::runtime_types; - pub type Addr = [::core::primitive::u8; 32usize]; - } - impl ::subxt::blocks::StaticExtrinsic for SetSequencerAddress { - const PALLET: &'static str = "Starknet"; - const CALL: &'static str = "set_sequencer_address"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::invoke`]."] - pub struct Invoke { - pub transaction: invoke::Transaction, - } - pub mod invoke { - use super::runtime_types; - pub type Transaction = runtime_types::mp_transactions::InvokeTransaction; - } - impl ::subxt::blocks::StaticExtrinsic for Invoke { - const PALLET: &'static str = "Starknet"; - const CALL: &'static str = "invoke"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::declare`]."] - pub struct Declare { - pub transaction: declare::Transaction, - pub contract_class: declare::ContractClass, - } - pub mod declare { - use super::runtime_types; - pub type Transaction = runtime_types::mp_transactions::DeclareTransaction; - pub type ContractClass = runtime_types::blockifier::execution::contract_class::ContractClass; - } - impl ::subxt::blocks::StaticExtrinsic for Declare { - const PALLET: &'static str = "Starknet"; - const CALL: &'static str = "declare"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::deploy_account`]."] - pub struct DeployAccount { - pub transaction: deploy_account::Transaction, - } - pub mod deploy_account { - use super::runtime_types; - pub type Transaction = runtime_types::mp_transactions::DeployAccountTransaction; - } - impl ::subxt::blocks::StaticExtrinsic for DeployAccount { - const PALLET: &'static str = "Starknet"; - const CALL: &'static str = "deploy_account"; - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::consume_l1_message`]."] - pub struct ConsumeL1Message { - pub transaction: consume_l1_message::Transaction, - pub paid_fee_on_l1: consume_l1_message::PaidFeeOnL1, - } - pub mod consume_l1_message { - use super::runtime_types; - pub type Transaction = runtime_types::mp_transactions::HandleL1MessageTransaction; - pub type PaidFeeOnL1 = runtime_types::starknet_api::transaction::Fee; - } - impl ::subxt::blocks::StaticExtrinsic for ConsumeL1Message { - const PALLET: &'static str = "Starknet"; - const CALL: &'static str = "consume_l1_message"; - } - } - pub struct TransactionApi; - impl TransactionApi { - #[doc = "See [`Pallet::set_sequencer_address`]."] - pub fn set_sequencer_address( - &self, - addr: types::set_sequencer_address::Addr, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Starknet", - "set_sequencer_address", - types::SetSequencerAddress { addr }, - [ - 169u8, 26u8, 33u8, 250u8, 166u8, 134u8, 232u8, 133u8, 55u8, 175u8, 66u8, 239u8, 41u8, - 169u8, 98u8, 174u8, 140u8, 37u8, 219u8, 244u8, 241u8, 223u8, 217u8, 81u8, 149u8, 123u8, - 195u8, 228u8, 103u8, 201u8, 113u8, 94u8, - ], - ) - } - #[doc = "See [`Pallet::invoke`]."] - pub fn invoke(&self, transaction: types::invoke::Transaction) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Starknet", - "invoke", - types::Invoke { transaction }, - [ - 85u8, 17u8, 2u8, 235u8, 36u8, 132u8, 208u8, 46u8, 163u8, 207u8, 213u8, 244u8, 110u8, 92u8, - 166u8, 212u8, 59u8, 93u8, 234u8, 176u8, 75u8, 134u8, 172u8, 162u8, 64u8, 253u8, 136u8, - 29u8, 107u8, 128u8, 57u8, 153u8, - ], - ) - } - #[doc = "See [`Pallet::declare`]."] - pub fn declare( - &self, - transaction: types::declare::Transaction, - contract_class: types::declare::ContractClass, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Starknet", - "declare", - types::Declare { transaction, contract_class }, - [ - 51u8, 168u8, 26u8, 92u8, 124u8, 211u8, 249u8, 222u8, 97u8, 183u8, 74u8, 98u8, 198u8, 228u8, - 105u8, 222u8, 18u8, 138u8, 61u8, 48u8, 47u8, 228u8, 152u8, 205u8, 226u8, 55u8, 212u8, - 206u8, 122u8, 51u8, 201u8, 110u8, - ], - ) - } - #[doc = "See [`Pallet::deploy_account`]."] - pub fn deploy_account( - &self, - transaction: types::deploy_account::Transaction, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Starknet", - "deploy_account", - types::DeployAccount { transaction }, - [ - 83u8, 35u8, 190u8, 103u8, 87u8, 56u8, 43u8, 218u8, 33u8, 76u8, 114u8, 250u8, 228u8, 8u8, - 220u8, 189u8, 165u8, 197u8, 106u8, 131u8, 232u8, 15u8, 215u8, 178u8, 174u8, 235u8, 239u8, - 201u8, 162u8, 43u8, 175u8, 99u8, - ], - ) - } - #[doc = "See [`Pallet::consume_l1_message`]."] - pub fn consume_l1_message( - &self, - transaction: types::consume_l1_message::Transaction, - paid_fee_on_l1: types::consume_l1_message::PaidFeeOnL1, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Starknet", - "consume_l1_message", - types::ConsumeL1Message { transaction, paid_fee_on_l1 }, - [ - 163u8, 125u8, 67u8, 173u8, 100u8, 72u8, 223u8, 26u8, 56u8, 92u8, 169u8, 125u8, 58u8, 205u8, - 189u8, 68u8, 24u8, 158u8, 149u8, 26u8, 42u8, 81u8, 79u8, 16u8, 177u8, 200u8, 189u8, 224u8, - 44u8, 118u8, 0u8, 233u8, - ], - ) - } - } - } - pub mod storage { - use super::runtime_types; - pub mod types { - use super::runtime_types; - pub mod pending { - use super::runtime_types; - pub type Pending = ::std::vec::Vec; - } - pub mod pending_hashes { - use super::runtime_types; - pub type PendingHashes = ::std::vec::Vec; - } - pub mod tx_events { - use super::runtime_types; - pub type TxEvents = ::std::vec::Vec; - pub type Param0 = runtime_types::starknet_api::transaction::TransactionHash; - } - pub mod tx_messages { - use super::runtime_types; - pub type TxMessages = ::std::vec::Vec; - pub type Param0 = runtime_types::starknet_api::transaction::TransactionHash; - } - pub mod tx_revert_error { - use super::runtime_types; - pub type TxRevertError = ::std::string::String; - pub type Param0 = runtime_types::starknet_api::transaction::TransactionHash; - } - pub mod contracts_state_roots { - use super::runtime_types; - pub type ContractsStateRoots = runtime_types::mp_felt::Felt252Wrapper; - pub type Param0 = runtime_types::starknet_api::api_core::ContractAddress; - } - pub mod pending_storage_changes { - use super::runtime_types; - pub type PendingStorageChanges = ::std::vec::Vec<( - runtime_types::starknet_api::state::StorageKey, - runtime_types::mp_felt::Felt252Wrapper, - )>; - pub type Param0 = runtime_types::starknet_api::api_core::ContractAddress; - } - pub mod block_hash { - use super::runtime_types; - pub type BlockHash = runtime_types::mp_felt::Felt252Wrapper; - pub type Param0 = ::core::primitive::u64; - } - pub mod contract_class_hashes { - use super::runtime_types; - pub type ContractClassHashes = runtime_types::starknet_api::api_core::ClassHash; - pub type Param0 = runtime_types::starknet_api::api_core::ContractAddress; - } - pub mod contract_classes { - use super::runtime_types; - pub type ContractClasses = runtime_types::blockifier::execution::contract_class::ContractClass; - pub type Param0 = runtime_types::starknet_api::api_core::ClassHash; - } - pub mod compiled_class_hashes { - use super::runtime_types; - pub type CompiledClassHashes = runtime_types::starknet_api::api_core::CompiledClassHash; - pub type Param0 = runtime_types::starknet_api::api_core::ClassHash; - } - pub mod nonces { - use super::runtime_types; - pub type Nonces = runtime_types::starknet_api::api_core::Nonce; - pub type Param0 = runtime_types::starknet_api::api_core::ContractAddress; - } - pub mod storage_view { - use super::runtime_types; - pub type StorageView = runtime_types::starknet_api::hash::StarkFelt; - pub type Param0 = runtime_types::starknet_api::api_core::ContractAddress; - pub type Param1 = runtime_types::starknet_api::state::StorageKey; - } - pub mod last_known_eth_block { - use super::runtime_types; - pub type LastKnownEthBlock = ::core::primitive::u64; - } - pub mod fee_token_address { - use super::runtime_types; - pub type FeeTokenAddress = runtime_types::starknet_api::api_core::ContractAddress; - } - pub mod sequencer_address { - use super::runtime_types; - pub type SequencerAddress = runtime_types::starknet_api::api_core::ContractAddress; - } - pub mod seq_addr_update { - use super::runtime_types; - pub type SeqAddrUpdate = ::core::primitive::bool; - } - pub mod l1_messages { - use super::runtime_types; - pub type L1Messages = ::std::vec::Vec; - } - } - pub struct StorageApi; - impl StorageApi { - #[doc = " The Starknet pallet storage items."] - #[doc = " STORAGE"] - #[doc = " Current building block's transactions."] - pub fn pending( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::pending::Pending, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "Pending", - (), - [ - 84u8, 54u8, 119u8, 230u8, 72u8, 65u8, 155u8, 131u8, 53u8, 149u8, 140u8, 155u8, 24u8, 140u8, - 246u8, 87u8, 214u8, 136u8, 158u8, 39u8, 221u8, 39u8, 245u8, 53u8, 3u8, 36u8, 9u8, 178u8, - 17u8, 50u8, 126u8, 60u8, - ], - ) - } - pub fn pending_hashes( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::pending_hashes::PendingHashes, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "PendingHashes", - (), - [ - 66u8, 137u8, 130u8, 57u8, 29u8, 64u8, 57u8, 214u8, 150u8, 219u8, 146u8, 144u8, 151u8, - 215u8, 0u8, 55u8, 199u8, 44u8, 55u8, 64u8, 31u8, 113u8, 27u8, 86u8, 210u8, 4u8, 188u8, - 184u8, 217u8, 161u8, 76u8, 123u8, - ], - ) - } - pub fn tx_events_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::tx_events::TxEvents, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "TxEvents", - (), - [ - 121u8, 221u8, 127u8, 211u8, 86u8, 203u8, 128u8, 198u8, 221u8, 89u8, 110u8, 99u8, 184u8, - 167u8, 140u8, 177u8, 171u8, 25u8, 236u8, 201u8, 94u8, 6u8, 73u8, 35u8, 221u8, 204u8, 221u8, - 187u8, 247u8, 251u8, 173u8, 14u8, - ], - ) - } - pub fn tx_events( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::tx_events::TxEvents, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "TxEvents", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 121u8, 221u8, 127u8, 211u8, 86u8, 203u8, 128u8, 198u8, 221u8, 89u8, 110u8, 99u8, 184u8, - 167u8, 140u8, 177u8, 171u8, 25u8, 236u8, 201u8, 94u8, 6u8, 73u8, 35u8, 221u8, 204u8, 221u8, - 187u8, 247u8, 251u8, 173u8, 14u8, - ], - ) - } - pub fn tx_messages_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::tx_messages::TxMessages, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "TxMessages", - (), - [ - 167u8, 160u8, 91u8, 132u8, 79u8, 241u8, 107u8, 41u8, 163u8, 195u8, 225u8, 232u8, 145u8, - 217u8, 48u8, 98u8, 150u8, 247u8, 235u8, 102u8, 151u8, 238u8, 11u8, 107u8, 241u8, 54u8, - 137u8, 234u8, 168u8, 14u8, 73u8, 227u8, - ], - ) - } - pub fn tx_messages( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::tx_messages::TxMessages, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "TxMessages", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 167u8, 160u8, 91u8, 132u8, 79u8, 241u8, 107u8, 41u8, 163u8, 195u8, 225u8, 232u8, 145u8, - 217u8, 48u8, 98u8, 150u8, 247u8, 235u8, 102u8, 151u8, 238u8, 11u8, 107u8, 241u8, 54u8, - 137u8, 234u8, 168u8, 14u8, 73u8, 227u8, - ], - ) - } - pub fn tx_revert_error_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::tx_revert_error::TxRevertError, - (), - (), - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "TxRevertError", - (), - [ - 135u8, 202u8, 162u8, 217u8, 245u8, 163u8, 157u8, 219u8, 170u8, 92u8, 64u8, 59u8, 204u8, - 168u8, 146u8, 93u8, 221u8, 30u8, 79u8, 181u8, 70u8, 49u8, 136u8, 164u8, 1u8, 234u8, 28u8, - 13u8, 222u8, 32u8, 237u8, 60u8, - ], - ) - } - pub fn tx_revert_error( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::tx_revert_error::TxRevertError, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "TxRevertError", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 135u8, 202u8, 162u8, 217u8, 245u8, 163u8, 157u8, 219u8, 170u8, 92u8, 64u8, 59u8, 204u8, - 168u8, 146u8, 93u8, 221u8, 30u8, 79u8, 181u8, 70u8, 49u8, 136u8, 164u8, 1u8, 234u8, 28u8, - 13u8, 222u8, 32u8, 237u8, 60u8, - ], - ) - } - #[doc = " The Starknet pallet storage items."] - #[doc = " STORAGE"] - #[doc = " Mapping of contract address to state root."] - pub fn contracts_state_roots_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::contracts_state_roots::ContractsStateRoots, - (), - (), - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "ContractsStateRoots", - (), - [ - 229u8, 249u8, 42u8, 22u8, 180u8, 204u8, 109u8, 58u8, 8u8, 151u8, 244u8, 138u8, 112u8, - 214u8, 87u8, 191u8, 95u8, 114u8, 61u8, 127u8, 210u8, 88u8, 229u8, 154u8, 33u8, 62u8, 108u8, - 153u8, 150u8, 109u8, 103u8, 59u8, - ], - ) - } - #[doc = " The Starknet pallet storage items."] - #[doc = " STORAGE"] - #[doc = " Mapping of contract address to state root."] - pub fn contracts_state_roots( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::contracts_state_roots::ContractsStateRoots, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "ContractsStateRoots", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 229u8, 249u8, 42u8, 22u8, 180u8, 204u8, 109u8, 58u8, 8u8, 151u8, 244u8, 138u8, 112u8, - 214u8, 87u8, 191u8, 95u8, 114u8, 61u8, 127u8, 210u8, 88u8, 229u8, 154u8, 33u8, 62u8, 108u8, - 153u8, 150u8, 109u8, 103u8, 59u8, - ], - ) - } - #[doc = " Pending storage slot updates"] - #[doc = " STORAGE"] - #[doc = " Mapping storage key to storage value."] - pub fn pending_storage_changes_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::pending_storage_changes::PendingStorageChanges, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "PendingStorageChanges", - (), - [ - 164u8, 119u8, 210u8, 206u8, 60u8, 14u8, 39u8, 11u8, 109u8, 110u8, 175u8, 105u8, 56u8, - 188u8, 73u8, 130u8, 180u8, 56u8, 78u8, 81u8, 108u8, 255u8, 109u8, 246u8, 244u8, 20u8, - 157u8, 59u8, 134u8, 213u8, 167u8, 84u8, - ], - ) - } - #[doc = " Pending storage slot updates"] - #[doc = " STORAGE"] - #[doc = " Mapping storage key to storage value."] - pub fn pending_storage_changes( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::pending_storage_changes::PendingStorageChanges, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "PendingStorageChanges", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 164u8, 119u8, 210u8, 206u8, 60u8, 14u8, 39u8, 11u8, 109u8, 110u8, 175u8, 105u8, 56u8, - 188u8, 73u8, 130u8, 180u8, 56u8, 78u8, 81u8, 108u8, 255u8, 109u8, 246u8, 244u8, 20u8, - 157u8, 59u8, 134u8, 213u8, 167u8, 84u8, - ], - ) - } - #[doc = " Mapping for block number and hashes."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn block_hash_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::block_hash::BlockHash, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "BlockHash", - (), - [ - 136u8, 185u8, 29u8, 194u8, 72u8, 62u8, 93u8, 202u8, 59u8, 231u8, 199u8, 32u8, 71u8, 128u8, - 203u8, 237u8, 92u8, 50u8, 122u8, 167u8, 75u8, 26u8, 233u8, 203u8, 104u8, 139u8, 215u8, - 149u8, 55u8, 218u8, 50u8, 113u8, - ], - ) - } - #[doc = " Mapping for block number and hashes."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn block_hash( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::block_hash::BlockHash, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "BlockHash", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 136u8, 185u8, 29u8, 194u8, 72u8, 62u8, 93u8, 202u8, 59u8, 231u8, 199u8, 32u8, 71u8, 128u8, - 203u8, 237u8, 92u8, 50u8, 122u8, 167u8, 75u8, 26u8, 233u8, 203u8, 104u8, 139u8, 215u8, - 149u8, 55u8, 218u8, 50u8, 113u8, - ], - ) - } - #[doc = " Mapping from Starknet contract address to the contract's class hash."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn contract_class_hashes_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::contract_class_hashes::ContractClassHashes, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "ContractClassHashes", - (), - [ - 134u8, 45u8, 113u8, 42u8, 146u8, 136u8, 240u8, 221u8, 0u8, 154u8, 218u8, 167u8, 114u8, - 119u8, 133u8, 137u8, 235u8, 201u8, 135u8, 204u8, 174u8, 33u8, 130u8, 230u8, 244u8, 87u8, - 47u8, 164u8, 221u8, 71u8, 71u8, 138u8, - ], - ) - } - #[doc = " Mapping from Starknet contract address to the contract's class hash."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn contract_class_hashes( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::contract_class_hashes::ContractClassHashes, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "ContractClassHashes", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 134u8, 45u8, 113u8, 42u8, 146u8, 136u8, 240u8, 221u8, 0u8, 154u8, 218u8, 167u8, 114u8, - 119u8, 133u8, 137u8, 235u8, 201u8, 135u8, 204u8, 174u8, 33u8, 130u8, 230u8, 244u8, 87u8, - 47u8, 164u8, 221u8, 71u8, 71u8, 138u8, - ], - ) - } - #[doc = " Mapping from Starknet class hash to contract class."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn contract_classes_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::contract_classes::ContractClasses, - (), - (), - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "ContractClasses", - (), - [ - 249u8, 24u8, 108u8, 51u8, 136u8, 97u8, 170u8, 65u8, 255u8, 44u8, 91u8, 209u8, 79u8, 189u8, - 207u8, 200u8, 79u8, 5u8, 41u8, 9u8, 221u8, 220u8, 214u8, 145u8, 244u8, 158u8, 28u8, 182u8, - 223u8, 7u8, 244u8, 102u8, - ], - ) - } - #[doc = " Mapping from Starknet class hash to contract class."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn contract_classes( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::contract_classes::ContractClasses, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "ContractClasses", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 249u8, 24u8, 108u8, 51u8, 136u8, 97u8, 170u8, 65u8, 255u8, 44u8, 91u8, 209u8, 79u8, 189u8, - 207u8, 200u8, 79u8, 5u8, 41u8, 9u8, 221u8, 220u8, 214u8, 145u8, 244u8, 158u8, 28u8, 182u8, - 223u8, 7u8, 244u8, 102u8, - ], - ) - } - #[doc = " Mapping from Starknet Sierra class hash to Casm compiled contract class."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn compiled_class_hashes_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::compiled_class_hashes::CompiledClassHashes, - (), - (), - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "CompiledClassHashes", - (), - [ - 16u8, 255u8, 109u8, 187u8, 48u8, 225u8, 113u8, 26u8, 67u8, 134u8, 61u8, 248u8, 246u8, - 231u8, 191u8, 29u8, 140u8, 141u8, 55u8, 147u8, 127u8, 133u8, 130u8, 137u8, 189u8, 33u8, - 187u8, 109u8, 45u8, 67u8, 101u8, 73u8, - ], - ) - } - #[doc = " Mapping from Starknet Sierra class hash to Casm compiled contract class."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn compiled_class_hashes( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::compiled_class_hashes::CompiledClassHashes, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "CompiledClassHashes", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 16u8, 255u8, 109u8, 187u8, 48u8, 225u8, 113u8, 26u8, 67u8, 134u8, 61u8, 248u8, 246u8, - 231u8, 191u8, 29u8, 140u8, 141u8, 55u8, 147u8, 127u8, 133u8, 130u8, 137u8, 189u8, 33u8, - 187u8, 109u8, 45u8, 67u8, 101u8, 73u8, - ], - ) - } - #[doc = " Mapping from Starknet contract address to its nonce."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn nonces_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::nonces::Nonces, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "Nonces", - (), - [ - 235u8, 122u8, 110u8, 231u8, 171u8, 151u8, 159u8, 224u8, 190u8, 13u8, 0u8, 106u8, 250u8, - 25u8, 89u8, 242u8, 164u8, 98u8, 63u8, 56u8, 181u8, 34u8, 0u8, 155u8, 112u8, 144u8, 75u8, - 239u8, 21u8, 137u8, 225u8, 232u8, - ], - ) - } - #[doc = " Mapping from Starknet contract address to its nonce."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn nonces( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::nonces::Nonces, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "Nonces", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 235u8, 122u8, 110u8, 231u8, 171u8, 151u8, 159u8, 224u8, 190u8, 13u8, 0u8, 106u8, 250u8, - 25u8, 89u8, 242u8, 164u8, 98u8, 63u8, 56u8, 181u8, 34u8, 0u8, 155u8, 112u8, 144u8, 75u8, - 239u8, 21u8, 137u8, 225u8, 232u8, - ], - ) - } - #[doc = " Mapping from Starknet contract storage key to its value."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn storage_view_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::storage_view::StorageView, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "StorageView", - (), - [ - 167u8, 146u8, 218u8, 79u8, 41u8, 243u8, 153u8, 185u8, 246u8, 39u8, 34u8, 194u8, 2u8, 36u8, - 122u8, 249u8, 16u8, 241u8, 86u8, 76u8, 190u8, 193u8, 234u8, 31u8, 219u8, 20u8, 109u8, - 159u8, 24u8, 24u8, 236u8, 150u8, - ], - ) - } - #[doc = " Mapping from Starknet contract storage key to its value."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn storage_view_iter1( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::storage_view::StorageView, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "StorageView", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 167u8, 146u8, 218u8, 79u8, 41u8, 243u8, 153u8, 185u8, 246u8, 39u8, 34u8, 194u8, 2u8, 36u8, - 122u8, 249u8, 16u8, 241u8, 86u8, 76u8, 190u8, 193u8, 234u8, 31u8, 219u8, 20u8, 109u8, - 159u8, 24u8, 24u8, 236u8, 150u8, - ], - ) - } - #[doc = " Mapping from Starknet contract storage key to its value."] - #[doc = " Safe to use `Identity` as the key is already a hash."] - pub fn storage_view( - &self, - _0: impl ::std::borrow::Borrow, - _1: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ( - ::subxt::storage::address::StaticStorageKey, - ::subxt::storage::address::StaticStorageKey, - ), - types::storage_view::StorageView, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "StorageView", - ( - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - ::subxt::storage::address::StaticStorageKey::new(_1.borrow()), - ), - [ - 167u8, 146u8, 218u8, 79u8, 41u8, 243u8, 153u8, 185u8, 246u8, 39u8, 34u8, 194u8, 2u8, 36u8, - 122u8, 249u8, 16u8, 241u8, 86u8, 76u8, 190u8, 193u8, 234u8, 31u8, 219u8, 20u8, 109u8, - 159u8, 24u8, 24u8, 236u8, 150u8, - ], - ) - } - #[doc = " The last processed Ethereum block number for L1 messages consumption."] - #[doc = " This is used to avoid re-processing the same Ethereum block multiple times."] - #[doc = " This is used by the offchain worker."] - #[doc = " # TODO"] - #[doc = " * Find a more relevant name for this."] - pub fn last_known_eth_block( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::last_known_eth_block::LastKnownEthBlock, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "LastKnownEthBlock", - (), - [ - 166u8, 178u8, 57u8, 216u8, 0u8, 63u8, 226u8, 197u8, 145u8, 98u8, 38u8, 69u8, 113u8, 73u8, - 223u8, 181u8, 230u8, 158u8, 206u8, 68u8, 147u8, 217u8, 203u8, 228u8, 171u8, 114u8, 237u8, - 137u8, 100u8, 114u8, 94u8, 6u8, - ], - ) - } - #[doc = " The address of the fee token ERC20 contract."] - pub fn fee_token_address( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::fee_token_address::FeeTokenAddress, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "FeeTokenAddress", - (), - [ - 189u8, 33u8, 185u8, 103u8, 164u8, 79u8, 96u8, 107u8, 253u8, 109u8, 193u8, 77u8, 130u8, - 217u8, 61u8, 5u8, 155u8, 190u8, 216u8, 132u8, 55u8, 253u8, 98u8, 247u8, 211u8, 18u8, 93u8, - 165u8, 218u8, 121u8, 79u8, 18u8, - ], - ) - } - #[doc = " Current sequencer address."] - pub fn sequencer_address( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::sequencer_address::SequencerAddress, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "SequencerAddress", - (), - [ - 247u8, 120u8, 203u8, 213u8, 64u8, 34u8, 196u8, 214u8, 252u8, 242u8, 84u8, 7u8, 188u8, 8u8, - 97u8, 163u8, 191u8, 219u8, 78u8, 238u8, 10u8, 201u8, 226u8, 95u8, 21u8, 35u8, 218u8, 107u8, - 117u8, 32u8, 166u8, 2u8, - ], - ) - } - #[doc = " Ensure the sequencer address was updated for this block."] - pub fn seq_addr_update( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::seq_addr_update::SeqAddrUpdate, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "SeqAddrUpdate", - (), - [ - 86u8, 255u8, 158u8, 112u8, 88u8, 3u8, 203u8, 93u8, 42u8, 28u8, 71u8, 231u8, 161u8, 207u8, - 222u8, 62u8, 118u8, 196u8, 132u8, 133u8, 33u8, 226u8, 237u8, 95u8, 251u8, 75u8, 142u8, - 159u8, 110u8, 186u8, 84u8, 189u8, - ], - ) - } - #[doc = " Information about processed L1 Messages"] - #[doc = " Based on Nonce value."] - pub fn l1_messages( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::l1_messages::L1Messages, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Starknet", - "L1Messages", - (), - [ - 134u8, 94u8, 210u8, 225u8, 209u8, 59u8, 193u8, 228u8, 58u8, 14u8, 7u8, 117u8, 204u8, 238u8, - 47u8, 6u8, 101u8, 247u8, 209u8, 127u8, 126u8, 224u8, 8u8, 190u8, 20u8, 126u8, 19u8, 87u8, - 154u8, 11u8, 152u8, 220u8, - ], - ) - } - } - } - pub mod constants { - use super::runtime_types; - pub struct ConstantsApi; - impl ConstantsApi { - #[doc = " The gas price"] - pub fn l1_gas_price(&self) -> ::subxt::constants::Address { - ::subxt::constants::Address::new_static( - "Starknet", - "L1GasPrice", - [ - 144u8, 104u8, 160u8, 190u8, 161u8, 137u8, 14u8, 77u8, 96u8, 91u8, 140u8, 151u8, 150u8, - 217u8, 205u8, 36u8, 70u8, 81u8, 50u8, 2u8, 79u8, 140u8, 61u8, 37u8, 153u8, 86u8, 60u8, - 74u8, 56u8, 162u8, 239u8, 139u8, - ], - ) - } - #[doc = " A configuration for base priority of unsigned transactions."] - #[doc = ""] - #[doc = " This is exposed so that it can be tuned for particular runtime, when"] - #[doc = " multiple pallets send unsigned transactions."] - pub fn unsigned_priority(&self) -> ::subxt::constants::Address<::core::primitive::u64> { - ::subxt::constants::Address::new_static( - "Starknet", - "UnsignedPriority", - [ - 128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, - 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, - 42u8, 184u8, 239u8, 42u8, 246u8, - ], - ) - } - #[doc = " A configuration for longevity of transactions."] - #[doc = ""] - #[doc = " This is exposed so that it can be tuned for particular runtime to"] - #[doc = " set how long transactions are kept in the mempool."] - pub fn transaction_longevity(&self) -> ::subxt::constants::Address<::core::primitive::u64> { - ::subxt::constants::Address::new_static( - "Starknet", - "TransactionLongevity", - [ - 128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, - 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, - 42u8, 184u8, 239u8, 42u8, 246u8, - ], - ) - } - #[doc = " A bool to disable transaction fees and make all transactions free"] - pub fn disable_transaction_fee(&self) -> ::subxt::constants::Address<::core::primitive::bool> { - ::subxt::constants::Address::new_static( - "Starknet", - "DisableTransactionFee", - [ - 165u8, 28u8, 112u8, 190u8, 18u8, 129u8, 182u8, 206u8, 237u8, 1u8, 68u8, 252u8, 125u8, - 234u8, 185u8, 50u8, 149u8, 164u8, 47u8, 126u8, 134u8, 100u8, 14u8, 86u8, 209u8, 39u8, 20u8, - 4u8, 233u8, 115u8, 102u8, 131u8, - ], - ) - } - pub fn invoke_tx_max_n_steps(&self) -> ::subxt::constants::Address<::core::primitive::u32> { - ::subxt::constants::Address::new_static( - "Starknet", - "InvokeTxMaxNSteps", - [ - 98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, - 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, - 203u8, 100u8, 41u8, 145u8, - ], - ) - } - pub fn validate_max_n_steps(&self) -> ::subxt::constants::Address<::core::primitive::u32> { - ::subxt::constants::Address::new_static( - "Starknet", - "ValidateMaxNSteps", - [ - 98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, - 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, - 203u8, 100u8, 41u8, 145u8, - ], - ) - } - pub fn protocol_version(&self) -> ::subxt::constants::Address<::core::primitive::u8> { - ::subxt::constants::Address::new_static( - "Starknet", - "ProtocolVersion", - [ - 141u8, 130u8, 11u8, 35u8, 226u8, 114u8, 92u8, 179u8, 168u8, 110u8, 28u8, 91u8, 221u8, 64u8, - 4u8, 148u8, 201u8, 193u8, 185u8, 66u8, 226u8, 114u8, 97u8, 79u8, 62u8, 212u8, 202u8, 114u8, - 237u8, 228u8, 183u8, 165u8, - ], - ) - } - pub fn chain_id(&self) -> ::subxt::constants::Address { - ::subxt::constants::Address::new_static( - "Starknet", - "ChainId", - [ - 115u8, 233u8, 13u8, 223u8, 88u8, 20u8, 202u8, 139u8, 153u8, 28u8, 155u8, 157u8, 224u8, - 66u8, 3u8, 250u8, 23u8, 53u8, 88u8, 168u8, 211u8, 204u8, 122u8, 166u8, 248u8, 23u8, 174u8, - 225u8, 99u8, 108u8, 89u8, 135u8, - ], - ) - } - pub fn max_recursion_depth(&self) -> ::subxt::constants::Address<::core::primitive::u32> { - ::subxt::constants::Address::new_static( - "Starknet", - "MaxRecursionDepth", - [ - 98u8, 252u8, 116u8, 72u8, 26u8, 180u8, 225u8, 83u8, 200u8, 157u8, 125u8, 151u8, 53u8, 76u8, - 168u8, 26u8, 10u8, 9u8, 98u8, 68u8, 9u8, 178u8, 197u8, 113u8, 31u8, 79u8, 200u8, 90u8, - 203u8, 100u8, 41u8, 145u8, - ], - ) - } - pub fn program_hash(&self) -> ::subxt::constants::Address { - ::subxt::constants::Address::new_static( - "Starknet", - "ProgramHash", - [ - 115u8, 233u8, 13u8, 223u8, 88u8, 20u8, 202u8, 139u8, 153u8, 28u8, 155u8, 157u8, 224u8, - 66u8, 3u8, 250u8, 23u8, 53u8, 88u8, 168u8, 211u8, 204u8, 122u8, 166u8, 248u8, 23u8, 174u8, - 225u8, 99u8, 108u8, 89u8, 135u8, - ], - ) - } - } - } - } - pub mod autonomous { - use super::root_mod; - use super::runtime_types; - #[doc = "The pallet custom errors."] - #[doc = "ERRORS"] - pub type Error = runtime_types::pallet_autonomous::pallet::Error; - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub type Call = runtime_types::pallet_autonomous::pallet::Call; - pub mod calls { - use super::root_mod; - use super::runtime_types; - type DispatchError = runtime_types::sp_runtime::DispatchError; - pub mod types { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "See [`Pallet::register_job`]."] - pub struct RegisterJob { - pub user_job: register_job::UserJob, - } - pub mod register_job { - use super::runtime_types; - pub type UserJob = runtime_types::pallet_autonomous::types::UserJob; - } - impl ::subxt::blocks::StaticExtrinsic for RegisterJob { - const PALLET: &'static str = "Autonomous"; - const CALL: &'static str = "register_job"; - } - } - pub struct TransactionApi; - impl TransactionApi { - #[doc = "See [`Pallet::register_job`]."] - pub fn register_job( - &self, - user_job: types::register_job::UserJob, - ) -> ::subxt::tx::Payload { - ::subxt::tx::Payload::new_static( - "Autonomous", - "register_job", - types::RegisterJob { user_job }, - [ - 235u8, 87u8, 42u8, 245u8, 46u8, 177u8, 213u8, 219u8, 227u8, 178u8, 24u8, 223u8, 152u8, - 17u8, 214u8, 8u8, 194u8, 208u8, 94u8, 33u8, 67u8, 146u8, 166u8, 185u8, 210u8, 210u8, 215u8, - 150u8, 3u8, 83u8, 60u8, 104u8, - ], - ) - } - } - } - pub mod storage { - use super::runtime_types; - pub mod types { - use super::runtime_types; - pub mod jobs { - use super::runtime_types; - pub type Jobs = - ::std::vec::Vec<(::core::primitive::u128, runtime_types::pallet_autonomous::types::Job)>; - } - pub mod job_index { - use super::runtime_types; - pub type JobIndex = ::core::primitive::u64; - pub type Param0 = ::core::primitive::u64; - } - pub mod job_executed { - use super::runtime_types; - pub type JobExecuted = ::core::primitive::bool; - pub type Param0 = ::core::primitive::u128; - } - } - pub struct StorageApi; - impl StorageApi { - pub fn jobs( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::jobs::Jobs, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Autonomous", - "Jobs", - (), - [ - 35u8, 29u8, 5u8, 140u8, 69u8, 158u8, 192u8, 208u8, 136u8, 99u8, 8u8, 10u8, 134u8, 89u8, - 94u8, 69u8, 121u8, 204u8, 151u8, 115u8, 41u8, 252u8, 7u8, 214u8, 203u8, 168u8, 229u8, 18u8, - 4u8, 85u8, 175u8, 174u8, - ], - ) - } - pub fn job_index_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::job_index::JobIndex, - (), - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Autonomous", - "JobIndex", - (), - [ - 155u8, 145u8, 200u8, 155u8, 31u8, 32u8, 208u8, 242u8, 124u8, 193u8, 30u8, 200u8, 148u8, - 188u8, 101u8, 78u8, 155u8, 57u8, 120u8, 95u8, 136u8, 94u8, 13u8, 182u8, 98u8, 137u8, 176u8, - 242u8, 17u8, 57u8, 67u8, 220u8, - ], - ) - } - pub fn job_index( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::job_index::JobIndex, - ::subxt::storage::address::Yes, - ::subxt::storage::address::Yes, - (), - > { - ::subxt::storage::address::Address::new_static( - "Autonomous", - "JobIndex", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 155u8, 145u8, 200u8, 155u8, 31u8, 32u8, 208u8, 242u8, 124u8, 193u8, 30u8, 200u8, 148u8, - 188u8, 101u8, 78u8, 155u8, 57u8, 120u8, 95u8, 136u8, 94u8, 13u8, 182u8, 98u8, 137u8, 176u8, - 242u8, 17u8, 57u8, 67u8, 220u8, - ], - ) - } - pub fn job_executed_iter( - &self, - ) -> ::subxt::storage::address::Address< - (), - types::job_executed::JobExecuted, - (), - (), - ::subxt::storage::address::Yes, - > { - ::subxt::storage::address::Address::new_static( - "Autonomous", - "JobExecuted", - (), - [ - 155u8, 52u8, 157u8, 111u8, 102u8, 208u8, 219u8, 177u8, 103u8, 43u8, 3u8, 122u8, 255u8, - 139u8, 17u8, 99u8, 187u8, 148u8, 181u8, 244u8, 132u8, 234u8, 176u8, 156u8, 195u8, 246u8, - 248u8, 157u8, 215u8, 212u8, 194u8, 155u8, - ], - ) - } - pub fn job_executed( - &self, - _0: impl ::std::borrow::Borrow, - ) -> ::subxt::storage::address::Address< - ::subxt::storage::address::StaticStorageKey, - types::job_executed::JobExecuted, - ::subxt::storage::address::Yes, - (), - (), - > { - ::subxt::storage::address::Address::new_static( - "Autonomous", - "JobExecuted", - ::subxt::storage::address::StaticStorageKey::new(_0.borrow()), - [ - 155u8, 52u8, 157u8, 111u8, 102u8, 208u8, 219u8, 177u8, 103u8, 43u8, 3u8, 122u8, 255u8, - 139u8, 17u8, 99u8, 187u8, 148u8, 181u8, 244u8, 132u8, 234u8, 176u8, 156u8, 195u8, 246u8, - 248u8, 157u8, 215u8, 212u8, 194u8, 155u8, - ], - ) - } - } - } - pub mod constants { - use super::runtime_types; - pub struct ConstantsApi; - impl ConstantsApi { - #[doc = " Maximum gas allowed for a job."] - pub fn max_gas(&self) -> ::subxt::constants::Address<::core::primitive::u64> { - ::subxt::constants::Address::new_static( - "Autonomous", - "MaxGas", - [ - 128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, - 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, - 42u8, 184u8, 239u8, 42u8, 246u8, - ], - ) - } - #[doc = " Maximum offset allowed for a job. (in blocks)"] - pub fn validity_max_offset(&self) -> ::subxt::constants::Address<::core::primitive::u64> { - ::subxt::constants::Address::new_static( - "Autonomous", - "ValidityMaxOffset", - [ - 128u8, 214u8, 205u8, 242u8, 181u8, 142u8, 124u8, 231u8, 190u8, 146u8, 59u8, 226u8, 157u8, - 101u8, 103u8, 117u8, 249u8, 65u8, 18u8, 191u8, 103u8, 119u8, 53u8, 85u8, 81u8, 96u8, 220u8, - 42u8, 184u8, 239u8, 42u8, 246u8, - ], - ) - } - } - } - } - pub mod runtime_types { - use super::runtime_types; - pub mod blockifier { - use super::runtime_types; - pub mod execution { - use super::runtime_types; - pub mod contract_class { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum ContractClass { - #[codec(index = 0)] - V0(runtime_types::blockifier::execution::contract_class::ContractClassV0), - #[codec(index = 1)] - V1(runtime_types::blockifier::execution::contract_class::ContractClassV1), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ContractClassV0( - pub runtime_types::blockifier::execution::contract_class::ContractClassV0Inner, - ); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ContractClassV0Inner(pub ::std::vec::Vec<::core::primitive::u8>); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ContractClassV1( - pub runtime_types::blockifier::execution::contract_class::ContractClassV1Inner, - ); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ContractClassV1Inner(pub ::std::vec::Vec<::core::primitive::u8>); - } - } - pub mod state { - use super::runtime_types; - pub mod cached_state { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CommitmentStateDiff(pub ::std::vec::Vec<::core::primitive::u8>); - } - } - pub mod transaction { - use super::runtime_types; - pub mod objects { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct TransactionExecutionInfo(pub ::std::vec::Vec<::core::primitive::u8>); - } - } - } - pub mod bounded_collections { - use super::runtime_types; - pub mod bounded_vec { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct BoundedVec<_0>(pub ::std::vec::Vec<_0>); - } - pub mod weak_bounded_vec { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct WeakBoundedVec<_0>(pub ::std::vec::Vec<_0>); - } - } - pub mod finality_grandpa { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Equivocation<_0, _1, _2> { - pub round_number: ::core::primitive::u64, - pub identity: _0, - pub first: (_1, _2), - pub second: (_1, _2), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Precommit<_0, _1> { - pub target_hash: _0, - pub target_number: _1, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Prevote<_0, _1> { - pub target_hash: _0, - pub target_number: _1, - } - } - pub mod frame_support { - use super::runtime_types; - pub mod dispatch { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum DispatchClass { - #[codec(index = 0)] - Normal, - #[codec(index = 1)] - Operational, - #[codec(index = 2)] - Mandatory, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct DispatchInfo { - pub weight: runtime_types::sp_weights::weight_v2::Weight, - pub class: runtime_types::frame_support::dispatch::DispatchClass, - pub pays_fee: runtime_types::frame_support::dispatch::Pays, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum Pays { - #[codec(index = 0)] - Yes, - #[codec(index = 1)] - No, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct PerDispatchClass<_0> { - pub normal: _0, - pub operational: _0, - pub mandatory: _0, - } - } - } - pub mod frame_system { - use super::runtime_types; - pub mod extensions { - use super::runtime_types; - pub mod check_genesis { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckGenesis; - } - pub mod check_mortality { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckMortality(pub runtime_types::sp_runtime::generic::era::Era); - } - pub mod check_non_zero_sender { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckNonZeroSender; - } - pub mod check_nonce { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckNonce(#[codec(compact)] pub ::core::primitive::u32); - } - pub mod check_spec_version { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckSpecVersion; - } - pub mod check_tx_version { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckTxVersion; - } - pub mod check_weight { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckWeight; - } - } - pub mod limits { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct BlockLength { - pub max: runtime_types::frame_support::dispatch::PerDispatchClass<::core::primitive::u32>, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct BlockWeights { - pub base_block: runtime_types::sp_weights::weight_v2::Weight, - pub max_block: runtime_types::sp_weights::weight_v2::Weight, - pub per_class: runtime_types::frame_support::dispatch::PerDispatchClass< - runtime_types::frame_system::limits::WeightsPerClass, - >, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct WeightsPerClass { - pub base_extrinsic: runtime_types::sp_weights::weight_v2::Weight, - pub max_extrinsic: ::core::option::Option, - pub max_total: ::core::option::Option, - pub reserved: ::core::option::Option, - } - } - pub mod pallet { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub enum Call { - #[codec(index = 0)] - #[doc = "See [`Pallet::remark`]."] - remark { remark: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 1)] - #[doc = "See [`Pallet::set_heap_pages`]."] - set_heap_pages { pages: ::core::primitive::u64 }, - #[codec(index = 2)] - #[doc = "See [`Pallet::set_code`]."] - set_code { code: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 3)] - #[doc = "See [`Pallet::set_code_without_checks`]."] - set_code_without_checks { code: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 4)] - #[doc = "See [`Pallet::set_storage`]."] - set_storage { - items: ::std::vec::Vec<( - ::std::vec::Vec<::core::primitive::u8>, - ::std::vec::Vec<::core::primitive::u8>, - )>, - }, - #[codec(index = 5)] - #[doc = "See [`Pallet::kill_storage`]."] - kill_storage { keys: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>> }, - #[codec(index = 6)] - #[doc = "See [`Pallet::kill_prefix`]."] - kill_prefix { prefix: ::std::vec::Vec<::core::primitive::u8>, subkeys: ::core::primitive::u32 }, - #[codec(index = 7)] - #[doc = "See [`Pallet::remark_with_event`]."] - remark_with_event { remark: ::std::vec::Vec<::core::primitive::u8> }, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Error for the System pallet"] - pub enum Error { - #[codec(index = 0)] - #[doc = "The name of specification does not match between the current runtime"] - #[doc = "and the new runtime."] - InvalidSpecName, - #[codec(index = 1)] - #[doc = "The specification version is not allowed to decrease between the current runtime"] - #[doc = "and the new runtime."] - SpecVersionNeedsToIncrease, - #[codec(index = 2)] - #[doc = "Failed to extract the runtime version from the new runtime."] - #[doc = ""] - #[doc = "Either calling `Core_version` or decoding `RuntimeVersion` failed."] - FailedToExtractRuntimeVersion, - #[codec(index = 3)] - #[doc = "Suicide called when the account has non-default composite data."] - NonDefaultComposite, - #[codec(index = 4)] - #[doc = "There is a non-zero reference count preventing the account from being purged."] - NonZeroRefCount, - #[codec(index = 5)] - #[doc = "The origin filter prevent the call to be dispatched."] - CallFiltered, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Event for the System pallet."] - pub enum Event { - #[codec(index = 0)] - #[doc = "An extrinsic completed successfully."] - ExtrinsicSuccess { dispatch_info: runtime_types::frame_support::dispatch::DispatchInfo }, - #[codec(index = 1)] - #[doc = "An extrinsic failed."] - ExtrinsicFailed { - dispatch_error: runtime_types::sp_runtime::DispatchError, - dispatch_info: runtime_types::frame_support::dispatch::DispatchInfo, - }, - #[codec(index = 2)] - #[doc = "`:code` was updated."] - CodeUpdated, - #[codec(index = 3)] - #[doc = "A new account was created."] - NewAccount { account: ::subxt::utils::AccountId32 }, - #[codec(index = 4)] - #[doc = "An account was reaped."] - KilledAccount { account: ::subxt::utils::AccountId32 }, - #[codec(index = 5)] - #[doc = "On on-chain remark happened."] - Remarked { sender: ::subxt::utils::AccountId32, hash: ::subxt::utils::H256 }, - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct AccountInfo<_0, _1> { - pub nonce: _0, - pub consumers: ::core::primitive::u32, - pub providers: ::core::primitive::u32, - pub sufficients: ::core::primitive::u32, - pub data: _1, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EventRecord<_0, _1> { - pub phase: runtime_types::frame_system::Phase, - pub event: _0, - pub topics: ::std::vec::Vec<_1>, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct LastRuntimeUpgradeInfo { - #[codec(compact)] - pub spec_version: ::core::primitive::u32, - pub spec_name: ::std::string::String, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum Phase { - #[codec(index = 0)] - ApplyExtrinsic(::core::primitive::u32), - #[codec(index = 1)] - Finalization, - #[codec(index = 2)] - Initialization, - } - } - pub mod madara_runtime { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Runtime; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum RuntimeCall { - #[codec(index = 0)] - System(runtime_types::frame_system::pallet::Call), - #[codec(index = 1)] - Timestamp(runtime_types::pallet_timestamp::pallet::Call), - #[codec(index = 3)] - Grandpa(runtime_types::pallet_grandpa::pallet::Call), - #[codec(index = 4)] - Starknet(runtime_types::pallet_starknet::pallet::Call), - #[codec(index = 5)] - Autonomous(runtime_types::pallet_autonomous::pallet::Call), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum RuntimeError { - #[codec(index = 0)] - System(runtime_types::frame_system::pallet::Error), - #[codec(index = 3)] - Grandpa(runtime_types::pallet_grandpa::pallet::Error), - #[codec(index = 4)] - Starknet(runtime_types::pallet_starknet::pallet::Error), - #[codec(index = 5)] - Autonomous(runtime_types::pallet_autonomous::pallet::Error), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum RuntimeEvent { - #[codec(index = 0)] - System(runtime_types::frame_system::pallet::Event), - #[codec(index = 3)] - Grandpa(runtime_types::pallet_grandpa::pallet::Event), - } - } - pub mod mp_fee { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ResourcePrice { - pub price_in_strk: ::core::option::Option<::core::primitive::u64>, - pub price_in_wei: ::core::primitive::u128, - } - } - pub mod mp_felt { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Felt252Wrapper(pub [::core::primitive::u8; 32usize]); - } - pub mod mp_simulations { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct PlaceHolderErrorTypeForFailedStarknetExecution; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct SimulationFlags { - pub skip_validate: ::core::primitive::bool, - pub skip_fee_charge: ::core::primitive::bool, - } - } - pub mod mp_transactions { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum DeclareTransaction { - #[codec(index = 0)] - V0(runtime_types::mp_transactions::DeclareTransactionV0), - #[codec(index = 1)] - V1(runtime_types::mp_transactions::DeclareTransactionV1), - #[codec(index = 2)] - V2(runtime_types::mp_transactions::DeclareTransactionV2), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct DeclareTransactionV0 { - pub max_fee: ::core::primitive::u128, - pub signature: ::std::vec::Vec, - pub nonce: runtime_types::mp_felt::Felt252Wrapper, - pub class_hash: runtime_types::mp_felt::Felt252Wrapper, - pub sender_address: runtime_types::mp_felt::Felt252Wrapper, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct DeclareTransactionV1 { - pub max_fee: ::core::primitive::u128, - pub signature: ::std::vec::Vec, - pub nonce: runtime_types::mp_felt::Felt252Wrapper, - pub class_hash: runtime_types::mp_felt::Felt252Wrapper, - pub sender_address: runtime_types::mp_felt::Felt252Wrapper, - pub offset_version: ::core::primitive::bool, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct DeclareTransactionV2 { - pub max_fee: ::core::primitive::u128, - pub signature: ::std::vec::Vec, - pub nonce: runtime_types::mp_felt::Felt252Wrapper, - pub class_hash: runtime_types::mp_felt::Felt252Wrapper, - pub sender_address: runtime_types::mp_felt::Felt252Wrapper, - pub compiled_class_hash: runtime_types::mp_felt::Felt252Wrapper, - pub offset_version: ::core::primitive::bool, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct DeployAccountTransaction { - pub max_fee: ::core::primitive::u128, - pub signature: ::std::vec::Vec, - pub nonce: runtime_types::mp_felt::Felt252Wrapper, - pub contract_address_salt: runtime_types::mp_felt::Felt252Wrapper, - pub constructor_calldata: ::std::vec::Vec, - pub class_hash: runtime_types::mp_felt::Felt252Wrapper, - pub offset_version: ::core::primitive::bool, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct HandleL1MessageTransaction { - pub nonce: ::core::primitive::u64, - pub contract_address: runtime_types::mp_felt::Felt252Wrapper, - pub entry_point_selector: runtime_types::mp_felt::Felt252Wrapper, - pub calldata: ::std::vec::Vec, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum InvokeTransaction { - #[codec(index = 0)] - V0(runtime_types::mp_transactions::InvokeTransactionV0), - #[codec(index = 1)] - V1(runtime_types::mp_transactions::InvokeTransactionV1), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct InvokeTransactionV0 { - pub max_fee: ::core::primitive::u128, - pub signature: ::std::vec::Vec, - pub contract_address: runtime_types::mp_felt::Felt252Wrapper, - pub entry_point_selector: runtime_types::mp_felt::Felt252Wrapper, - pub calldata: ::std::vec::Vec, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct InvokeTransactionV1 { - pub max_fee: ::core::primitive::u128, - pub signature: ::std::vec::Vec, - pub nonce: runtime_types::mp_felt::Felt252Wrapper, - pub sender_address: runtime_types::mp_felt::Felt252Wrapper, - pub calldata: ::std::vec::Vec, - pub offset_version: ::core::primitive::bool, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum Transaction { - #[codec(index = 0)] - Declare( - runtime_types::mp_transactions::DeclareTransaction, - runtime_types::blockifier::execution::contract_class::ContractClass, - ), - #[codec(index = 1)] - DeployAccount(runtime_types::mp_transactions::DeployAccountTransaction), - #[codec(index = 2)] - Invoke(runtime_types::mp_transactions::InvokeTransaction), - #[codec(index = 3)] - L1Handler(runtime_types::mp_transactions::HandleL1MessageTransaction), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum UserOrL1HandlerTransaction { - #[codec(index = 0)] - User(runtime_types::mp_transactions::UserTransaction), - #[codec(index = 1)] - L1Handler( - runtime_types::mp_transactions::HandleL1MessageTransaction, - runtime_types::starknet_api::transaction::Fee, - ), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum UserTransaction { - #[codec(index = 0)] - Declare( - runtime_types::mp_transactions::DeclareTransaction, - runtime_types::blockifier::execution::contract_class::ContractClass, - ), - #[codec(index = 1)] - DeployAccount(runtime_types::mp_transactions::DeployAccountTransaction), - #[codec(index = 2)] - Invoke(runtime_types::mp_transactions::InvokeTransaction), - } - } - pub mod pallet_autonomous { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub enum Call { - #[codec(index = 0)] - #[doc = "See [`Pallet::register_job`]."] - register_job { user_job: runtime_types::pallet_autonomous::types::UserJob }, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "The pallet custom errors."] - #[doc = "ERRORS"] - pub enum Error { - #[codec(index = 0)] - JobAlreadyExecuted, - #[codec(index = 1)] - InvalidJob, - #[codec(index = 2)] - InvalidJobFrequency, - #[codec(index = 3)] - JobsLimitReached, - #[codec(index = 4)] - JobAlreadyRegistered, - #[codec(index = 5)] - JobGasLimitExceeded, - } - } - pub mod types { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Job { - pub emission_block_number: ::core::primitive::u64, - pub index: ::core::primitive::u64, - pub max_gas: ::core::primitive::u64, - pub actual_gas: ::core::primitive::u64, - pub calls: ::std::vec::Vec, - pub policy: runtime_types::pallet_autonomous::types::Policy, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Policy { - pub validity_start: ::core::primitive::u64, - pub validity_end: ::core::primitive::u64, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct UserJob { - pub calls: ::std::vec::Vec<::std::vec::Vec>, - pub policy: runtime_types::pallet_autonomous::types::UserPolicy, - } - #[derive( - :: subxt :: ext :: codec :: CompactAs, - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct UserPolicy { - pub frequency: ::core::primitive::u64, - } - } - } - pub mod pallet_grandpa { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub enum Call { - #[codec(index = 0)] - #[doc = "See [`Pallet::report_equivocation`]."] - report_equivocation { - equivocation_proof: ::std::boxed::Box< - runtime_types::sp_consensus_grandpa::EquivocationProof< - ::subxt::utils::H256, - ::core::primitive::u32, - >, - >, - key_owner_proof: runtime_types::sp_core::Void, - }, - #[codec(index = 1)] - #[doc = "See [`Pallet::report_equivocation_unsigned`]."] - report_equivocation_unsigned { - equivocation_proof: ::std::boxed::Box< - runtime_types::sp_consensus_grandpa::EquivocationProof< - ::subxt::utils::H256, - ::core::primitive::u32, - >, - >, - key_owner_proof: runtime_types::sp_core::Void, - }, - #[codec(index = 2)] - #[doc = "See [`Pallet::note_stalled`]."] - note_stalled { delay: ::core::primitive::u32, best_finalized_block_number: ::core::primitive::u32 }, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "The `Error` enum of this pallet."] - pub enum Error { - #[codec(index = 0)] - #[doc = "Attempt to signal GRANDPA pause when the authority set isn't live"] - #[doc = "(either paused or already pending pause)."] - PauseFailed, - #[codec(index = 1)] - #[doc = "Attempt to signal GRANDPA resume when the authority set isn't paused"] - #[doc = "(either live or already pending resume)."] - ResumeFailed, - #[codec(index = 2)] - #[doc = "Attempt to signal GRANDPA change with one already pending."] - ChangePending, - #[codec(index = 3)] - #[doc = "Cannot signal forced change so soon after last."] - TooSoon, - #[codec(index = 4)] - #[doc = "A key ownership proof provided as part of an equivocation report is invalid."] - InvalidKeyOwnershipProof, - #[codec(index = 5)] - #[doc = "An equivocation proof provided as part of an equivocation report is invalid."] - InvalidEquivocationProof, - #[codec(index = 6)] - #[doc = "A given equivocation report is valid but already previously reported."] - DuplicateOffenceReport, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "The `Event` enum of this pallet"] - pub enum Event { - #[codec(index = 0)] - #[doc = "New authority set has been applied."] - NewAuthorities { - authority_set: - ::std::vec::Vec<(runtime_types::sp_consensus_grandpa::app::Public, ::core::primitive::u64)>, - }, - #[codec(index = 1)] - #[doc = "Current authority set has been paused."] - Paused, - #[codec(index = 2)] - #[doc = "Current authority set has been resumed."] - Resumed, - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct StoredPendingChange<_0> { - pub scheduled_at: _0, - pub delay: _0, - pub next_authorities: runtime_types::bounded_collections::weak_bounded_vec::WeakBoundedVec<( - runtime_types::sp_consensus_grandpa::app::Public, - ::core::primitive::u64, - )>, - pub forced: ::core::option::Option<_0>, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum StoredState<_0> { - #[codec(index = 0)] - Live, - #[codec(index = 1)] - PendingPause { scheduled_at: _0, delay: _0 }, - #[codec(index = 2)] - Paused, - #[codec(index = 3)] - PendingResume { scheduled_at: _0, delay: _0 }, - } - } - pub mod pallet_starknet { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "The Starknet pallet external functions."] - #[doc = "Dispatchable functions allows users to interact with the pallet and invoke state changes."] - #[doc = "These functions materialize as \"extrinsics\", which are often compared to transactions."] - #[doc = "Dispatchable functions must be annotated with a weight and must return a DispatchResult."] - pub enum Call { - #[codec(index = 0)] - #[doc = "See [`Pallet::set_sequencer_address`]."] - set_sequencer_address { addr: [::core::primitive::u8; 32usize] }, - #[codec(index = 1)] - #[doc = "See [`Pallet::invoke`]."] - invoke { transaction: runtime_types::mp_transactions::InvokeTransaction }, - #[codec(index = 2)] - #[doc = "See [`Pallet::declare`]."] - declare { - transaction: runtime_types::mp_transactions::DeclareTransaction, - contract_class: runtime_types::blockifier::execution::contract_class::ContractClass, - }, - #[codec(index = 3)] - #[doc = "See [`Pallet::deploy_account`]."] - deploy_account { transaction: runtime_types::mp_transactions::DeployAccountTransaction }, - #[codec(index = 4)] - #[doc = "See [`Pallet::consume_l1_message`]."] - consume_l1_message { - transaction: runtime_types::mp_transactions::HandleL1MessageTransaction, - paid_fee_on_l1: runtime_types::starknet_api::transaction::Fee, - }, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "The Starknet pallet custom errors."] - #[doc = "ERRORS"] - pub enum Error { - #[codec(index = 0)] - AccountNotDeployed, - #[codec(index = 1)] - TransactionExecutionFailed, - #[codec(index = 2)] - ClassHashAlreadyDeclared, - #[codec(index = 3)] - ContractClassHashUnknown, - #[codec(index = 4)] - ContractClassAlreadyAssociated, - #[codec(index = 5)] - ContractClassMustBeSpecified, - #[codec(index = 6)] - AccountAlreadyDeployed, - #[codec(index = 7)] - ContractAddressAlreadyAssociated, - #[codec(index = 8)] - InvalidContractClass, - #[codec(index = 9)] - TooManyEmittedStarknetEvents, - #[codec(index = 10)] - StateReaderError, - #[codec(index = 11)] - EmitEventError, - #[codec(index = 12)] - StateDiffError, - #[codec(index = 13)] - ContractNotFound, - #[codec(index = 14)] - TransactionConversionError, - #[codec(index = 15)] - SequencerAddressNotValid, - #[codec(index = 16)] - InvalidContractClassForThisDeclareVersion, - #[codec(index = 17)] - Unimplemented, - #[codec(index = 18)] - MissingRevertReason, - #[codec(index = 19)] - MissingCallInfo, - #[codec(index = 20)] - FailedToCreateATransactionalStorageExecution, - #[codec(index = 21)] - L1MessageAlreadyExecuted, - #[codec(index = 22)] - MissingL1GasUsage, - } - } - } - pub mod pallet_starknet_runtime_api { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct BlockContext { - pub chain_id: ::std::string::String, - pub block_number: ::core::primitive::u64, - pub block_timestamp: ::core::primitive::u64, - pub sequencer_address: runtime_types::starknet_api::api_core::ContractAddress, - pub fee_token_address: runtime_types::starknet_api::api_core::ContractAddress, - pub vm_resource_fee_cost: - ::std::vec::Vec<(::std::string::String, runtime_types::sp_arithmetic::fixed_point::FixedU128)>, - pub gas_price: ::core::primitive::u128, - pub invoke_tx_max_n_steps: ::core::primitive::u32, - pub validate_max_n_steps: ::core::primitive::u32, - pub max_recursion_depth: ::core::primitive::u32, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum StarknetTransactionExecutionError { - #[codec(index = 0)] - ContractNotFound, - #[codec(index = 1)] - ClassAlreadyDeclared, - #[codec(index = 2)] - ClassHashNotFound, - #[codec(index = 3)] - InvalidContractClass, - #[codec(index = 4)] - ContractError, - } - } - pub mod pallet_timestamp { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - #[doc = "Contains a variant per dispatchable extrinsic that this pallet has."] - pub enum Call { - #[codec(index = 0)] - #[doc = "See [`Pallet::set`]."] - set { - #[codec(compact)] - now: ::core::primitive::u64, - }, - } - } - } - pub mod sp_arithmetic { - use super::runtime_types; - pub mod fixed_point { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: CompactAs, - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct FixedU128(pub ::core::primitive::u128); - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum ArithmeticError { - #[codec(index = 0)] - Underflow, - #[codec(index = 1)] - Overflow, - #[codec(index = 2)] - DivisionByZero, - } - } - pub mod sp_consensus_aura { - use super::runtime_types; - pub mod sr25519 { - use super::runtime_types; - pub mod app_sr25519 { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Public(pub runtime_types::sp_core::sr25519::Public); - } - } - } - pub mod sp_consensus_grandpa { - use super::runtime_types; - pub mod app { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Public(pub runtime_types::sp_core::ed25519::Public); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Signature(pub runtime_types::sp_core::ed25519::Signature); - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum Equivocation<_0, _1> { - #[codec(index = 0)] - Prevote( - runtime_types::finality_grandpa::Equivocation< - runtime_types::sp_consensus_grandpa::app::Public, - runtime_types::finality_grandpa::Prevote<_0, _1>, - runtime_types::sp_consensus_grandpa::app::Signature, - >, - ), - #[codec(index = 1)] - Precommit( - runtime_types::finality_grandpa::Equivocation< - runtime_types::sp_consensus_grandpa::app::Public, - runtime_types::finality_grandpa::Precommit<_0, _1>, - runtime_types::sp_consensus_grandpa::app::Signature, - >, - ), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EquivocationProof<_0, _1> { - pub set_id: ::core::primitive::u64, - pub equivocation: runtime_types::sp_consensus_grandpa::Equivocation<_0, _1>, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct OpaqueKeyOwnershipProof(pub ::std::vec::Vec<::core::primitive::u8>); - } - pub mod sp_consensus_slots { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: CompactAs, - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Slot(pub ::core::primitive::u64); - #[derive( - :: subxt :: ext :: codec :: CompactAs, - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct SlotDuration(pub ::core::primitive::u64); - } - pub mod sp_core { - use super::runtime_types; - pub mod crypto { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct KeyTypeId(pub [::core::primitive::u8; 4usize]); - } - pub mod ecdsa { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Signature(pub [::core::primitive::u8; 65usize]); - } - pub mod ed25519 { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Public(pub [::core::primitive::u8; 32usize]); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Signature(pub [::core::primitive::u8; 64usize]); - } - pub mod sr25519 { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Public(pub [::core::primitive::u8; 32usize]); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Signature(pub [::core::primitive::u8; 64usize]); - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct OpaqueMetadata(pub ::std::vec::Vec<::core::primitive::u8>); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum Void {} - } - pub mod sp_inherents { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CheckInherentsResult { - pub okay: ::core::primitive::bool, - pub fatal_error: ::core::primitive::bool, - pub errors: runtime_types::sp_inherents::InherentData, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct InherentData { - pub data: - ::subxt::utils::KeyedVec<[::core::primitive::u8; 8usize], ::std::vec::Vec<::core::primitive::u8>>, - } - } - pub mod sp_runtime { - use super::runtime_types; - pub mod generic { - use super::runtime_types; - pub mod block { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Block<_0, _1> { - pub header: _0, - pub extrinsics: ::std::vec::Vec<_1>, - } - } - pub mod digest { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Digest { - pub logs: ::std::vec::Vec, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum DigestItem { - #[codec(index = 6)] - PreRuntime([::core::primitive::u8; 4usize], ::std::vec::Vec<::core::primitive::u8>), - #[codec(index = 4)] - Consensus([::core::primitive::u8; 4usize], ::std::vec::Vec<::core::primitive::u8>), - #[codec(index = 5)] - Seal([::core::primitive::u8; 4usize], ::std::vec::Vec<::core::primitive::u8>), - #[codec(index = 0)] - Other(::std::vec::Vec<::core::primitive::u8>), - #[codec(index = 8)] - RuntimeEnvironmentUpdated, - } - } - pub mod era { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum Era { - #[codec(index = 0)] - Immortal, - #[codec(index = 1)] - Mortal1(::core::primitive::u8), - #[codec(index = 2)] - Mortal2(::core::primitive::u8), - #[codec(index = 3)] - Mortal3(::core::primitive::u8), - #[codec(index = 4)] - Mortal4(::core::primitive::u8), - #[codec(index = 5)] - Mortal5(::core::primitive::u8), - #[codec(index = 6)] - Mortal6(::core::primitive::u8), - #[codec(index = 7)] - Mortal7(::core::primitive::u8), - #[codec(index = 8)] - Mortal8(::core::primitive::u8), - #[codec(index = 9)] - Mortal9(::core::primitive::u8), - #[codec(index = 10)] - Mortal10(::core::primitive::u8), - #[codec(index = 11)] - Mortal11(::core::primitive::u8), - #[codec(index = 12)] - Mortal12(::core::primitive::u8), - #[codec(index = 13)] - Mortal13(::core::primitive::u8), - #[codec(index = 14)] - Mortal14(::core::primitive::u8), - #[codec(index = 15)] - Mortal15(::core::primitive::u8), - #[codec(index = 16)] - Mortal16(::core::primitive::u8), - #[codec(index = 17)] - Mortal17(::core::primitive::u8), - #[codec(index = 18)] - Mortal18(::core::primitive::u8), - #[codec(index = 19)] - Mortal19(::core::primitive::u8), - #[codec(index = 20)] - Mortal20(::core::primitive::u8), - #[codec(index = 21)] - Mortal21(::core::primitive::u8), - #[codec(index = 22)] - Mortal22(::core::primitive::u8), - #[codec(index = 23)] - Mortal23(::core::primitive::u8), - #[codec(index = 24)] - Mortal24(::core::primitive::u8), - #[codec(index = 25)] - Mortal25(::core::primitive::u8), - #[codec(index = 26)] - Mortal26(::core::primitive::u8), - #[codec(index = 27)] - Mortal27(::core::primitive::u8), - #[codec(index = 28)] - Mortal28(::core::primitive::u8), - #[codec(index = 29)] - Mortal29(::core::primitive::u8), - #[codec(index = 30)] - Mortal30(::core::primitive::u8), - #[codec(index = 31)] - Mortal31(::core::primitive::u8), - #[codec(index = 32)] - Mortal32(::core::primitive::u8), - #[codec(index = 33)] - Mortal33(::core::primitive::u8), - #[codec(index = 34)] - Mortal34(::core::primitive::u8), - #[codec(index = 35)] - Mortal35(::core::primitive::u8), - #[codec(index = 36)] - Mortal36(::core::primitive::u8), - #[codec(index = 37)] - Mortal37(::core::primitive::u8), - #[codec(index = 38)] - Mortal38(::core::primitive::u8), - #[codec(index = 39)] - Mortal39(::core::primitive::u8), - #[codec(index = 40)] - Mortal40(::core::primitive::u8), - #[codec(index = 41)] - Mortal41(::core::primitive::u8), - #[codec(index = 42)] - Mortal42(::core::primitive::u8), - #[codec(index = 43)] - Mortal43(::core::primitive::u8), - #[codec(index = 44)] - Mortal44(::core::primitive::u8), - #[codec(index = 45)] - Mortal45(::core::primitive::u8), - #[codec(index = 46)] - Mortal46(::core::primitive::u8), - #[codec(index = 47)] - Mortal47(::core::primitive::u8), - #[codec(index = 48)] - Mortal48(::core::primitive::u8), - #[codec(index = 49)] - Mortal49(::core::primitive::u8), - #[codec(index = 50)] - Mortal50(::core::primitive::u8), - #[codec(index = 51)] - Mortal51(::core::primitive::u8), - #[codec(index = 52)] - Mortal52(::core::primitive::u8), - #[codec(index = 53)] - Mortal53(::core::primitive::u8), - #[codec(index = 54)] - Mortal54(::core::primitive::u8), - #[codec(index = 55)] - Mortal55(::core::primitive::u8), - #[codec(index = 56)] - Mortal56(::core::primitive::u8), - #[codec(index = 57)] - Mortal57(::core::primitive::u8), - #[codec(index = 58)] - Mortal58(::core::primitive::u8), - #[codec(index = 59)] - Mortal59(::core::primitive::u8), - #[codec(index = 60)] - Mortal60(::core::primitive::u8), - #[codec(index = 61)] - Mortal61(::core::primitive::u8), - #[codec(index = 62)] - Mortal62(::core::primitive::u8), - #[codec(index = 63)] - Mortal63(::core::primitive::u8), - #[codec(index = 64)] - Mortal64(::core::primitive::u8), - #[codec(index = 65)] - Mortal65(::core::primitive::u8), - #[codec(index = 66)] - Mortal66(::core::primitive::u8), - #[codec(index = 67)] - Mortal67(::core::primitive::u8), - #[codec(index = 68)] - Mortal68(::core::primitive::u8), - #[codec(index = 69)] - Mortal69(::core::primitive::u8), - #[codec(index = 70)] - Mortal70(::core::primitive::u8), - #[codec(index = 71)] - Mortal71(::core::primitive::u8), - #[codec(index = 72)] - Mortal72(::core::primitive::u8), - #[codec(index = 73)] - Mortal73(::core::primitive::u8), - #[codec(index = 74)] - Mortal74(::core::primitive::u8), - #[codec(index = 75)] - Mortal75(::core::primitive::u8), - #[codec(index = 76)] - Mortal76(::core::primitive::u8), - #[codec(index = 77)] - Mortal77(::core::primitive::u8), - #[codec(index = 78)] - Mortal78(::core::primitive::u8), - #[codec(index = 79)] - Mortal79(::core::primitive::u8), - #[codec(index = 80)] - Mortal80(::core::primitive::u8), - #[codec(index = 81)] - Mortal81(::core::primitive::u8), - #[codec(index = 82)] - Mortal82(::core::primitive::u8), - #[codec(index = 83)] - Mortal83(::core::primitive::u8), - #[codec(index = 84)] - Mortal84(::core::primitive::u8), - #[codec(index = 85)] - Mortal85(::core::primitive::u8), - #[codec(index = 86)] - Mortal86(::core::primitive::u8), - #[codec(index = 87)] - Mortal87(::core::primitive::u8), - #[codec(index = 88)] - Mortal88(::core::primitive::u8), - #[codec(index = 89)] - Mortal89(::core::primitive::u8), - #[codec(index = 90)] - Mortal90(::core::primitive::u8), - #[codec(index = 91)] - Mortal91(::core::primitive::u8), - #[codec(index = 92)] - Mortal92(::core::primitive::u8), - #[codec(index = 93)] - Mortal93(::core::primitive::u8), - #[codec(index = 94)] - Mortal94(::core::primitive::u8), - #[codec(index = 95)] - Mortal95(::core::primitive::u8), - #[codec(index = 96)] - Mortal96(::core::primitive::u8), - #[codec(index = 97)] - Mortal97(::core::primitive::u8), - #[codec(index = 98)] - Mortal98(::core::primitive::u8), - #[codec(index = 99)] - Mortal99(::core::primitive::u8), - #[codec(index = 100)] - Mortal100(::core::primitive::u8), - #[codec(index = 101)] - Mortal101(::core::primitive::u8), - #[codec(index = 102)] - Mortal102(::core::primitive::u8), - #[codec(index = 103)] - Mortal103(::core::primitive::u8), - #[codec(index = 104)] - Mortal104(::core::primitive::u8), - #[codec(index = 105)] - Mortal105(::core::primitive::u8), - #[codec(index = 106)] - Mortal106(::core::primitive::u8), - #[codec(index = 107)] - Mortal107(::core::primitive::u8), - #[codec(index = 108)] - Mortal108(::core::primitive::u8), - #[codec(index = 109)] - Mortal109(::core::primitive::u8), - #[codec(index = 110)] - Mortal110(::core::primitive::u8), - #[codec(index = 111)] - Mortal111(::core::primitive::u8), - #[codec(index = 112)] - Mortal112(::core::primitive::u8), - #[codec(index = 113)] - Mortal113(::core::primitive::u8), - #[codec(index = 114)] - Mortal114(::core::primitive::u8), - #[codec(index = 115)] - Mortal115(::core::primitive::u8), - #[codec(index = 116)] - Mortal116(::core::primitive::u8), - #[codec(index = 117)] - Mortal117(::core::primitive::u8), - #[codec(index = 118)] - Mortal118(::core::primitive::u8), - #[codec(index = 119)] - Mortal119(::core::primitive::u8), - #[codec(index = 120)] - Mortal120(::core::primitive::u8), - #[codec(index = 121)] - Mortal121(::core::primitive::u8), - #[codec(index = 122)] - Mortal122(::core::primitive::u8), - #[codec(index = 123)] - Mortal123(::core::primitive::u8), - #[codec(index = 124)] - Mortal124(::core::primitive::u8), - #[codec(index = 125)] - Mortal125(::core::primitive::u8), - #[codec(index = 126)] - Mortal126(::core::primitive::u8), - #[codec(index = 127)] - Mortal127(::core::primitive::u8), - #[codec(index = 128)] - Mortal128(::core::primitive::u8), - #[codec(index = 129)] - Mortal129(::core::primitive::u8), - #[codec(index = 130)] - Mortal130(::core::primitive::u8), - #[codec(index = 131)] - Mortal131(::core::primitive::u8), - #[codec(index = 132)] - Mortal132(::core::primitive::u8), - #[codec(index = 133)] - Mortal133(::core::primitive::u8), - #[codec(index = 134)] - Mortal134(::core::primitive::u8), - #[codec(index = 135)] - Mortal135(::core::primitive::u8), - #[codec(index = 136)] - Mortal136(::core::primitive::u8), - #[codec(index = 137)] - Mortal137(::core::primitive::u8), - #[codec(index = 138)] - Mortal138(::core::primitive::u8), - #[codec(index = 139)] - Mortal139(::core::primitive::u8), - #[codec(index = 140)] - Mortal140(::core::primitive::u8), - #[codec(index = 141)] - Mortal141(::core::primitive::u8), - #[codec(index = 142)] - Mortal142(::core::primitive::u8), - #[codec(index = 143)] - Mortal143(::core::primitive::u8), - #[codec(index = 144)] - Mortal144(::core::primitive::u8), - #[codec(index = 145)] - Mortal145(::core::primitive::u8), - #[codec(index = 146)] - Mortal146(::core::primitive::u8), - #[codec(index = 147)] - Mortal147(::core::primitive::u8), - #[codec(index = 148)] - Mortal148(::core::primitive::u8), - #[codec(index = 149)] - Mortal149(::core::primitive::u8), - #[codec(index = 150)] - Mortal150(::core::primitive::u8), - #[codec(index = 151)] - Mortal151(::core::primitive::u8), - #[codec(index = 152)] - Mortal152(::core::primitive::u8), - #[codec(index = 153)] - Mortal153(::core::primitive::u8), - #[codec(index = 154)] - Mortal154(::core::primitive::u8), - #[codec(index = 155)] - Mortal155(::core::primitive::u8), - #[codec(index = 156)] - Mortal156(::core::primitive::u8), - #[codec(index = 157)] - Mortal157(::core::primitive::u8), - #[codec(index = 158)] - Mortal158(::core::primitive::u8), - #[codec(index = 159)] - Mortal159(::core::primitive::u8), - #[codec(index = 160)] - Mortal160(::core::primitive::u8), - #[codec(index = 161)] - Mortal161(::core::primitive::u8), - #[codec(index = 162)] - Mortal162(::core::primitive::u8), - #[codec(index = 163)] - Mortal163(::core::primitive::u8), - #[codec(index = 164)] - Mortal164(::core::primitive::u8), - #[codec(index = 165)] - Mortal165(::core::primitive::u8), - #[codec(index = 166)] - Mortal166(::core::primitive::u8), - #[codec(index = 167)] - Mortal167(::core::primitive::u8), - #[codec(index = 168)] - Mortal168(::core::primitive::u8), - #[codec(index = 169)] - Mortal169(::core::primitive::u8), - #[codec(index = 170)] - Mortal170(::core::primitive::u8), - #[codec(index = 171)] - Mortal171(::core::primitive::u8), - #[codec(index = 172)] - Mortal172(::core::primitive::u8), - #[codec(index = 173)] - Mortal173(::core::primitive::u8), - #[codec(index = 174)] - Mortal174(::core::primitive::u8), - #[codec(index = 175)] - Mortal175(::core::primitive::u8), - #[codec(index = 176)] - Mortal176(::core::primitive::u8), - #[codec(index = 177)] - Mortal177(::core::primitive::u8), - #[codec(index = 178)] - Mortal178(::core::primitive::u8), - #[codec(index = 179)] - Mortal179(::core::primitive::u8), - #[codec(index = 180)] - Mortal180(::core::primitive::u8), - #[codec(index = 181)] - Mortal181(::core::primitive::u8), - #[codec(index = 182)] - Mortal182(::core::primitive::u8), - #[codec(index = 183)] - Mortal183(::core::primitive::u8), - #[codec(index = 184)] - Mortal184(::core::primitive::u8), - #[codec(index = 185)] - Mortal185(::core::primitive::u8), - #[codec(index = 186)] - Mortal186(::core::primitive::u8), - #[codec(index = 187)] - Mortal187(::core::primitive::u8), - #[codec(index = 188)] - Mortal188(::core::primitive::u8), - #[codec(index = 189)] - Mortal189(::core::primitive::u8), - #[codec(index = 190)] - Mortal190(::core::primitive::u8), - #[codec(index = 191)] - Mortal191(::core::primitive::u8), - #[codec(index = 192)] - Mortal192(::core::primitive::u8), - #[codec(index = 193)] - Mortal193(::core::primitive::u8), - #[codec(index = 194)] - Mortal194(::core::primitive::u8), - #[codec(index = 195)] - Mortal195(::core::primitive::u8), - #[codec(index = 196)] - Mortal196(::core::primitive::u8), - #[codec(index = 197)] - Mortal197(::core::primitive::u8), - #[codec(index = 198)] - Mortal198(::core::primitive::u8), - #[codec(index = 199)] - Mortal199(::core::primitive::u8), - #[codec(index = 200)] - Mortal200(::core::primitive::u8), - #[codec(index = 201)] - Mortal201(::core::primitive::u8), - #[codec(index = 202)] - Mortal202(::core::primitive::u8), - #[codec(index = 203)] - Mortal203(::core::primitive::u8), - #[codec(index = 204)] - Mortal204(::core::primitive::u8), - #[codec(index = 205)] - Mortal205(::core::primitive::u8), - #[codec(index = 206)] - Mortal206(::core::primitive::u8), - #[codec(index = 207)] - Mortal207(::core::primitive::u8), - #[codec(index = 208)] - Mortal208(::core::primitive::u8), - #[codec(index = 209)] - Mortal209(::core::primitive::u8), - #[codec(index = 210)] - Mortal210(::core::primitive::u8), - #[codec(index = 211)] - Mortal211(::core::primitive::u8), - #[codec(index = 212)] - Mortal212(::core::primitive::u8), - #[codec(index = 213)] - Mortal213(::core::primitive::u8), - #[codec(index = 214)] - Mortal214(::core::primitive::u8), - #[codec(index = 215)] - Mortal215(::core::primitive::u8), - #[codec(index = 216)] - Mortal216(::core::primitive::u8), - #[codec(index = 217)] - Mortal217(::core::primitive::u8), - #[codec(index = 218)] - Mortal218(::core::primitive::u8), - #[codec(index = 219)] - Mortal219(::core::primitive::u8), - #[codec(index = 220)] - Mortal220(::core::primitive::u8), - #[codec(index = 221)] - Mortal221(::core::primitive::u8), - #[codec(index = 222)] - Mortal222(::core::primitive::u8), - #[codec(index = 223)] - Mortal223(::core::primitive::u8), - #[codec(index = 224)] - Mortal224(::core::primitive::u8), - #[codec(index = 225)] - Mortal225(::core::primitive::u8), - #[codec(index = 226)] - Mortal226(::core::primitive::u8), - #[codec(index = 227)] - Mortal227(::core::primitive::u8), - #[codec(index = 228)] - Mortal228(::core::primitive::u8), - #[codec(index = 229)] - Mortal229(::core::primitive::u8), - #[codec(index = 230)] - Mortal230(::core::primitive::u8), - #[codec(index = 231)] - Mortal231(::core::primitive::u8), - #[codec(index = 232)] - Mortal232(::core::primitive::u8), - #[codec(index = 233)] - Mortal233(::core::primitive::u8), - #[codec(index = 234)] - Mortal234(::core::primitive::u8), - #[codec(index = 235)] - Mortal235(::core::primitive::u8), - #[codec(index = 236)] - Mortal236(::core::primitive::u8), - #[codec(index = 237)] - Mortal237(::core::primitive::u8), - #[codec(index = 238)] - Mortal238(::core::primitive::u8), - #[codec(index = 239)] - Mortal239(::core::primitive::u8), - #[codec(index = 240)] - Mortal240(::core::primitive::u8), - #[codec(index = 241)] - Mortal241(::core::primitive::u8), - #[codec(index = 242)] - Mortal242(::core::primitive::u8), - #[codec(index = 243)] - Mortal243(::core::primitive::u8), - #[codec(index = 244)] - Mortal244(::core::primitive::u8), - #[codec(index = 245)] - Mortal245(::core::primitive::u8), - #[codec(index = 246)] - Mortal246(::core::primitive::u8), - #[codec(index = 247)] - Mortal247(::core::primitive::u8), - #[codec(index = 248)] - Mortal248(::core::primitive::u8), - #[codec(index = 249)] - Mortal249(::core::primitive::u8), - #[codec(index = 250)] - Mortal250(::core::primitive::u8), - #[codec(index = 251)] - Mortal251(::core::primitive::u8), - #[codec(index = 252)] - Mortal252(::core::primitive::u8), - #[codec(index = 253)] - Mortal253(::core::primitive::u8), - #[codec(index = 254)] - Mortal254(::core::primitive::u8), - #[codec(index = 255)] - Mortal255(::core::primitive::u8), - } - } - pub mod header { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Header<_0> { - pub parent_hash: ::subxt::utils::H256, - #[codec(compact)] - pub number: _0, - pub state_root: ::subxt::utils::H256, - pub extrinsics_root: ::subxt::utils::H256, - pub digest: runtime_types::sp_runtime::generic::digest::Digest, - } - } - } - pub mod transaction_validity { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum InvalidTransaction { - #[codec(index = 0)] - Call, - #[codec(index = 1)] - Payment, - #[codec(index = 2)] - Future, - #[codec(index = 3)] - Stale, - #[codec(index = 4)] - BadProof, - #[codec(index = 5)] - AncientBirthBlock, - #[codec(index = 6)] - ExhaustsResources, - #[codec(index = 7)] - Custom(::core::primitive::u8), - #[codec(index = 8)] - BadMandatory, - #[codec(index = 9)] - MandatoryValidation, - #[codec(index = 10)] - BadSigner, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum TransactionSource { - #[codec(index = 0)] - InBlock, - #[codec(index = 1)] - Local, - #[codec(index = 2)] - External, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum TransactionValidityError { - #[codec(index = 0)] - Invalid(runtime_types::sp_runtime::transaction_validity::InvalidTransaction), - #[codec(index = 1)] - Unknown(runtime_types::sp_runtime::transaction_validity::UnknownTransaction), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum UnknownTransaction { - #[codec(index = 0)] - CannotLookup, - #[codec(index = 1)] - NoUnsignedValidator, - #[codec(index = 2)] - Custom(::core::primitive::u8), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ValidTransaction { - pub priority: ::core::primitive::u64, - pub requires: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, - pub provides: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, - pub longevity: ::core::primitive::u64, - pub propagate: ::core::primitive::bool, - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum DispatchError { - #[codec(index = 0)] - Other, - #[codec(index = 1)] - CannotLookup, - #[codec(index = 2)] - BadOrigin, - #[codec(index = 3)] - Module(runtime_types::sp_runtime::ModuleError), - #[codec(index = 4)] - ConsumerRemaining, - #[codec(index = 5)] - NoProviders, - #[codec(index = 6)] - TooManyConsumers, - #[codec(index = 7)] - Token(runtime_types::sp_runtime::TokenError), - #[codec(index = 8)] - Arithmetic(runtime_types::sp_arithmetic::ArithmeticError), - #[codec(index = 9)] - Transactional(runtime_types::sp_runtime::TransactionalError), - #[codec(index = 10)] - Exhausted, - #[codec(index = 11)] - Corruption, - #[codec(index = 12)] - Unavailable, - #[codec(index = 13)] - RootNotAllowed, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ModuleError { - pub index: ::core::primitive::u8, - pub error: [::core::primitive::u8; 4usize], - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum MultiSignature { - #[codec(index = 0)] - Ed25519(runtime_types::sp_core::ed25519::Signature), - #[codec(index = 1)] - Sr25519(runtime_types::sp_core::sr25519::Signature), - #[codec(index = 2)] - Ecdsa(runtime_types::sp_core::ecdsa::Signature), - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum TokenError { - #[codec(index = 0)] - FundsUnavailable, - #[codec(index = 1)] - OnlyProvider, - #[codec(index = 2)] - BelowMinimum, - #[codec(index = 3)] - CannotCreate, - #[codec(index = 4)] - UnknownAsset, - #[codec(index = 5)] - Frozen, - #[codec(index = 6)] - Unsupported, - #[codec(index = 7)] - CannotCreateHold, - #[codec(index = 8)] - NotExpendable, - #[codec(index = 9)] - Blocked, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub enum TransactionalError { - #[codec(index = 0)] - LimitReached, - #[codec(index = 1)] - NoLayer, - } - } - pub mod sp_version { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct RuntimeVersion { - pub spec_name: ::std::string::String, - pub impl_name: ::std::string::String, - pub authoring_version: ::core::primitive::u32, - pub spec_version: ::core::primitive::u32, - pub impl_version: ::core::primitive::u32, - pub apis: ::std::vec::Vec<([::core::primitive::u8; 8usize], ::core::primitive::u32)>, - pub transaction_version: ::core::primitive::u32, - pub state_version: ::core::primitive::u8, - } - } - pub mod sp_weights { - use super::runtime_types; - pub mod weight_v2 { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Weight { - #[codec(compact)] - pub ref_time: ::core::primitive::u64, - #[codec(compact)] - pub proof_size: ::core::primitive::u64, - } - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct RuntimeDbWeight { - pub read: ::core::primitive::u64, - pub write: ::core::primitive::u64, - } - } - pub mod starknet_api { - use super::runtime_types; - pub mod api_core { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ClassHash(pub runtime_types::starknet_api::hash::StarkFelt); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct CompiledClassHash(pub runtime_types::starknet_api::hash::StarkFelt); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct ContractAddress(pub runtime_types::starknet_api::api_core::PatriciaKey); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EntryPointSelector(pub runtime_types::starknet_api::hash::StarkFelt); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EthAddress(pub ::subxt::utils::H160); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Nonce(pub runtime_types::starknet_api::hash::StarkFelt); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct PatriciaKey(pub runtime_types::starknet_api::hash::StarkFelt); - } - pub mod hash { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct StarkFelt(pub [::core::primitive::u8; 32usize]); - } - pub mod state { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct StorageKey(pub runtime_types::starknet_api::api_core::PatriciaKey); - } - pub mod transaction { - use super::runtime_types; - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Calldata(pub ::std::vec::Vec); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Event { - pub from_address: runtime_types::starknet_api::api_core::ContractAddress, - pub content: runtime_types::starknet_api::transaction::EventContent, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EventContent { - pub keys: ::std::vec::Vec, - pub data: runtime_types::starknet_api::transaction::EventData, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EventData(pub ::std::vec::Vec); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct EventKey(pub runtime_types::starknet_api::hash::StarkFelt); - #[derive( - :: subxt :: ext :: codec :: CompactAs, - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct Fee(pub ::core::primitive::u128); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct L2ToL1Payload(pub ::std::vec::Vec); - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct MessageToL1 { - pub from_address: runtime_types::starknet_api::api_core::ContractAddress, - pub to_address: runtime_types::starknet_api::api_core::EthAddress, - pub payload: runtime_types::starknet_api::transaction::L2ToL1Payload, - } - #[derive( - :: subxt :: ext :: codec :: Decode, - :: subxt :: ext :: codec :: Encode, - :: subxt :: ext :: scale_decode :: DecodeAsType, - :: subxt :: ext :: scale_encode :: EncodeAsType, - Debug, - )] - # [codec (crate = :: subxt :: ext :: codec)] - #[decode_as_type(crate_path = ":: subxt :: ext :: scale_decode")] - #[encode_as_type(crate_path = ":: subxt :: ext :: scale_encode")] - pub struct TransactionHash(pub runtime_types::starknet_api::hash::StarkFelt); - } - } - } -} diff --git a/rust/pragma-cli/src/runtimes/artifacts/madara_metadata.scale b/rust/pragma-cli/src/runtimes/artifacts/madara_metadata.scale deleted file mode 100644 index 083a4754b25c490e9c00a66922725a1d66d7b687..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40937 zcmd6Q4SZx*b>F?CxAqw1Fb;Aex1v0V9JDa|s$H}oE3zZ)O12cVyYfoAtb;eB(ae)H z>}X~@Z)SHz?bc3A3dJ;biW@ta#%@fC6Wp2<8r+%&QfMK8)}*F|1{!Eg0u4@ZiyKIs zr2liy{dn`CwIPsSmc={wzWZ_Rz2}~EHxH=6k)%;5)tm8fskzf=)$_BZ zQoUVkEtX$>K&e0lI($QW@<+l~A2>}(H4rMLviP6cgUZ?Qjb?E>E+jiiE8cc>Ya8|K z(9wFW6ziPLoGZ49dPoiFp&EV2X(^!eXsKRH+S_q6$?5QTym6SiM|PuGKU*nxXXlgl z#zv)7iEFLS^0_iP7}DwPl*$3jJ!*&{A0C`Az_uHWdb1UlD@mi+Ds9ay$IUtO`*5|G zBtfvMN7SGmuGO2{#p;L-R+Y}z8*#JPs?=*XXLP$*L#OrT4wq0PgJYP>b8%&JtCft( zzlF00hF{M)m^B?XG0|rN=PH`bHtCyvb%M%%L z(yE+|3$2|-oa7b`9DEH8r(<36N@cQYJV*UEF?;A?WHYYC%}QywT-l71*6bu81%!#uvnYQ&#>OaTgL%CGj2Ht(3^lfjNqoB=TBd(72Qigf z(80XY!>xLwQcB*UhiS;Gn9zmnaJj9ZwfmeSeb72Y?2TGEa5Mw*)9{-;fG zG^IwaYXaLE#XvRmYNJ@K#;wApWSP=xK&hp{jtx011&6pbU^Rf8nLpoZR%%J5w9+n> zVj#Poup6OJ!Ny(I<90JFA_IvKKJf+oh^s9sAj(#_|*(iUwUXJZTW`gClsS+~Q!gIwWY|HvaV@Kn2 zhKvPzq$mVU>G9R6DM#I~{9ChOEj|~T@7zME854#?6R)dahRe^{ND!O?km(lCKm!ec zkZl*6XJ{UVu_-{ty8G8TpwQNs9syJf_@(v)jbpX2UfWmNDpqPB71ThuRcth{lgm-i z;8hGa>dg@79t!G&vcl2wZp5u?F+tRXFpX$Sm-JAHh~BDSA0~oIqwSrfuo1_nbZ!|x zm0I1c7q_&g>frEECY?as{4q~Al~$uiEYVaMrB3bEpmeCSgEz$JS7ndZQCHoVO;I@4 zr$MJlAp&6LdCzw7zT^k=mnXR_k?)V24N<^DNM{q1F1CxE83g9^+rq-oIG`-aJ|`VH>i$!p~|1A z70+U86xXY<8dQ_V>-E;rdTX{?t)D~jOO;wnPg=*2!I6e4z|Henoo!DNHKUC=t?yut ze`NMl;mEPM6HD`j`Qyir9WTruJ$!6#ey*^x_~Y{s2FmGn(<9eoGuO6js@6-`j_MMnwz3o8lSQ{UJqx1;M^Dg} z-2i|gm&qKfU)7kMQV&cc+VrdH?fS4bxFBNx) zCMeYyoa`j$9YkB{!AYWK?bcQu09Rt7*F}@sDPU?^dcuC)S*j#05bQfpBXosA6apDZ z!u2=?t!gx?6_AtRWgrxQ(ZM~3+s!8U(QY*wTre6r9uvlwRVKLaIchYeWE9-I3PQEU zbZae)Ywhi@z5(J@NetNnu$lAfJV4IgJgROUTxMC+ND-F34Fcrh<@S2DQbIv>tDcU_ z2M!+Gf7R5K&Aru0u_NYNszQgPbbBYCw|snXau)Nl<9HaP4@hVv0ju$AE0FjqZ(`98 z3pTk}!#emJV8B~2j4^cw{(GmolLnK^sdsdCbZV)XvN?h*1k`dy_7dKW!hXJroO4vJ&+!A>OM%18FfGY ztJH&iMS|R6h!89hgu}vV0&RYzWHuGtxDvQQ0}eFO#XCqqpemr2hv(^qm8Y&bO!x* zw=xji-@lcvnt&xwjV6%eF#-&v0%gf_;{Kw$8V zAFUx&i&50%|-gKk|AI04P0@wAZOYgOe9^gOaL?rsiak zc$|fpB+Y(HdvWlVPJnu9p{d|f4Mx`jGfcu_cornH2s#0N?sO+2uPNcMwN-4TH#pIq z=snmN?^W-mjgil*N07>^_jh4sl?Y@q&Qx0TC9wTLJ+=-pyRc5QJ0-9{@jBm|39t$* z$$U`XzTBnJO`A56&k_nG>JRQFdh}HXAM@(qV?FAi#jDB?{Y?K^}#uhLRn+iY!NQS~5T__$u}nRBLG>f_(mJm>s8=X&N@a{N4VT78oF zuSm6tRhj12WyMMB&OxLoTgo(a4s0|wDfKwlHMDoq(9)Aaioy6h$nHcZsnw$uC_)7x z$=%=P4EL>VTEcGjZYQ;OncS2C!)E4+jY{%_9+|~Ipd(5zwY;?0-Rwltg5qLxMV?bn z1cQg`=V*aH3�btSBZVv zu)gvNSk_T6Bh4%b0mY1`cg7NM^g+4 z%g_oqpENR)7j02DW;Kq+aXDG7FV;v!Bh@=Q%N=)iXr?fPghAbcYmpQjw(22xDp&lr zfoO?7yILpV01UYcNiu_9lLFKU?Nk)uftW#r7Nm`4eYJmK;Nxf=BPK;H+~9267B@uWpjlpz9s41@ zxXM~mf4%r?gEL0BCYu=c$aces*Iob$2EqS9#h`3p!$TWC0tyK8j0%=JIV6gG*LdRB z2bb0{S>?D4DG1BMDqxbgd1vF&*dh6jt)ImX{zk9@h}5&*y7Z0QT!*+^Y&VM|Ns~q6 zJY?pA`JEDlzp1B9rk9<+>1F5M3LUcZvmhSdP+DgfI{Hnjb(msT@LvMZQr0~>+ojj! zS0G}=&3s&EPigu~iRkL~> zs@XKR2(CR0BTgwUU#9h_VdzI8kzA_#BE`(PxOk?J!i>q+Bcl^L&I@+5Ja$~B(+ob> z!{A{V2ZO&H>SbT;({GQ#rDja#@_!r{_}zq43u? zrj3a!AF||dw7tC^H?M`IVfC78FdNg5Z41!!A-{1u^IFfK21MUul*vs1weIZPjeVfP z?gZ`W0k+VFxpNaXw7-6+b@2Y@gxY}z@W;WmaGC;fj!mc*>*sprP3h`7=viSylvC^! z7Lp6lu`#zf-KR#TTLnq?^<5)uSLkeCEq<;CE3(0Y9;1y05e+udR-pnRZD=LN(Ua2S zY4m!D)(h$C(+l~KHq1+Q>1#Y)*ma|`Bg^1SnBYLYOzW$(H=m~vcG~UO#d1D$MNCcU zIsXDzXa$H>Y_*%v5S1E5DVWEh$pq>ut!Ka89;EJt`oNZbna0V9n^Yw>|{P%*$Xn2U^umM zDob72r*}K8Zlq_M04wp`hw&uio9{GwP<6*vdYjfHV7~zUZ} zv{((VJ3f1KZh01#JlGLa!lkuMve~hc)LzjFtKjkvj>RJAiaC)4+hUazvmMwInE6Xf zd!un-=B9HE1!MQl#nO1;-lfC)ZT|#Jzuu*(z0rh-07f2wweu^xcaM`ANDCp^qHu5n zQMYqM(FjfpR_d_R4+M{imD-K6rWLIjP0Mn@WUJB;P8bCH z^=t^988XkL4-k{VX6e6lVqOj**f)we;YMB&XLl*`24S7gz9GR^M3r+rrHQ8Ww1;}? zs{dE%>C{{s#%D+n@v)5!QW%aiFzTYA1uT|=6bEJ*V*aqMj@q9C;3&cUMrm&nTugfYQ|Z00<^~@(nZuw zT2GL9j8r~3_fl$NE^buoJNDpEy;i)D?gB}G5b?5oDyxavZS0^bfuXp)$ z%kyiv3odMdK;70C_*~R)7ZiVM?`-tpM+T+e4x-${tUOxZ)%P=__S<{A>EF_K z$Q5R~XSMHyLhWhp6dLtP4d;F_8Q)-->NE3fIla(qtGk}pc)k~;{<+zheopXrrS^CC z4(mda2Q*A!$5yrc>t2R?iBrEzt9R+aaTrgUXKG+!I6ldPI$Qsm>6EOrK>k*sJrBSD z2YY1mjAT5}Rh>PwqyPySRHMTn`flp>A*~+js+aCoeD5GpX?W(Bt{&jVQDLuLM^SAffbo4=Lw|!qK&euM`k;`}IW4YsXR)67 z_&`^^^tieJ#3>szlH^f{#3ZgU^ynLc8vEsb1QX49bD&*HJxUYzA+0`ifeu33M#nSNf}1Q4$>RR$OQ81?>uR-d4MKc&^DF3?)u3flE0?Bc=av4~@>x?SW? zYdtpK+OkWdN8nIbtryE*z$`5tSVfa?tD_91KHUX_TcUIWSliD)Mqb$e8p!CM!5-~# z4(2a``kXdKj|1Z{dVCJ!92jDw#}~S~Nv~)(Nc|`8OEhU;)(U@NKKZJSwfbsTqeIw& zt$2*=>QGS_1N$K5Q(d*(h(}qM+GUGAy<06f?}?0eq1w;vR@?ZZr%8ff+P8R^59_aL z_2)VW53M%i7$!a@Sv>)ZGp}QWcGi;Fyus-HujH^jCd#m*m^431@<} zPT)=R=xMUdDssV`3wDD2<_qb|1Kn;#oh_m51(KEErBntN9G46HDEw6!N7{&qC?@hNfxt>c1@1? zqF7s3X!f6RALPIqj?8e|NXXU(2?du9aH7m6COS=mt8Xg+b1@ ziL-ZH1R#es7^sr)<#b5R4&cel^RS#%a4-)u2W&-PJ$wd?6d#$VrY(tzyMeq7zf?Ms zWtUrYg@a}?hZRHd$UuHMn*YR;9MIHrzz26-YSpQzNyw6#hMk{479FaGF{=zMe0^t)9|j| z)-P7ePyxsn#1`dYz?Y<9T%_l54gxsrc3^g%!2fmzIW3s}-~!oXOC5ZgC#f)(kenB) zNiH>4+1QYrLHPNaxxnOJOXnGIZcfiEJ{zlr)c8IH5@g7%83t;?oey^K7pVvPL60-Z zRd}bG1vqK^fO2Z$1iX}S>wyeBn4ink(veD%;K2HLj4sKsH-VA&`_;6`Ccg%D?|iX( zMAmt=F8;~0DO4y{4U2R*ftyNe&bDXfTt1@L%hjA|erf-8#pDDLH}wN5`<8x0r-a3Z zze!B4J4rOm4%{nOfLUc;l2P~z-hEoXETdkQ8JsgL3kTTsT74TP)giuWH27onb+S>d z#@jSl(8Kf*qZReVf!wCpl($)QexPHZUF~AEkjfe&6*jptqnAl8I{`|UniA~N;YJ-c z;+=gNJ-p1nl)94O-kVW-Gd)JA?grp5{WrsKtM=_avuhj4W0+icl+9Cz6; zR+>z;zh8?z0!A?2j5py24%y<3^>qjo#7yYt!HgcE>E>naJ_}CQ0Vn(JIDQ`N2e2TQ zhXi*J7$dIA=uyH5+B+T%uFmK&0@|X&RfGyK%wD~F(;ejlJ-X2pDzIbcakgJwGmj}^ zKD>aL>fVG(jTyp0)2J0$FNmTbb*=3ObbAKrq{HcdKrQ>`j++(2uEyOjG|^| z__-l_kII&5UmJGccRSB#_`;!aG#lRrGp&#i3Atzd2qg^F%Z?g4k8@!)ZhzCg4~^TH zIQtF2;d~h|tf58v8mPsL?kJA|4<0X`3(`03a7JPJc{R=ifN$=)=z#lj0H+NdIthAQ z#7bT?q>f~|FUjSNn;Rhl?ELPI+=KdI4QtKD)D(_1N&nrdlyQO$c3-Nt%W(pI*x1SJ zb-Ssl&LUG&_Db3d;9rmCN&2FH$rnZLQ{_X`JD=yTTBoriS$p+AD^as9|-CH3c)qjBdQ;s7AAb$Eo-%AL5Unv;&D0O`% zeZ6Or_m%fQ0JoW!%P70MD5#MYamowSiHu%w4tS|n)X;pXoZxQf4H-QX)6c0X{}~(Q zM8>;0mBMc}FkRI! zPNgfHMa~BJQ`x<#1!;=BeC?Uk47ZbV4K}T8@7~Icw9-0n+nD4wR?iy|&$MvU?k!A6 z3v{VEsU+iE{W?jQ%I)1NPfO)(c+r7Zw05NTBR0tm;Oqvv=6th=Q<_Y_E7*fj1o^v$ z9b$1?8pGs`NIN*Mg)28mh9p6Xk<8fSt2sGflM|eTm%kJ~$jLo6`5I1MWRtJu70X@PIlr3Jn#U0UG#VV4&8USZP{ z0^gWR3w(QBTHt%7OACCja%q7t@6rO_K9?5wB9|8U{;o?4eB&-H@a?zhg96_HmlpV5 z?a~6@gi8y22VGj=dyPvAe6MwBfp5~K1-`3XTHu>A1-@%tTHw3Rr3JnPmlpUIU0UG# zF_#wjUgy#R-;zrUd`Dbb;5+Kl0^c#4o)q|&U0UF~-lYY;<1Q`mt+=$nx9ZXY-wBr% z_)faC!1sEW7WhuNw7_?ROe1<^!_k4yxdb7_ENN@2O0_orP83O4)@EHQ>tv*8_z0GA9_VSZH zLm>SrpCORm?lT0^H~S2M^rwA>K>81ThCuojpCORG)n^E#|Hx+uq;GQ>hSA*NGX&DN z`wW5fANve}^k;mAKzgUo5J>Ox83O6g`V4{epZE-c^c_A!AidjV7?$%-eTG2#b3Q{L zy~k$=r1$y^f%NBnhCupGpCORm=Q9M-cliu~^q=_*f%F$#hG9PU`wW5f0iPj|{&Sxp zkp8025J(^N83O6MeTG2#OFly&{TDt%AbpR|5J(?#8HNr0vd<7mf5m4Ar0?|^0_np( zLm>T^K0_e=S3W}^eZ*%7r0???0_m^%41x4ty9~pS-tRL6(hv9yf%M<_41x65e1<^! zL7yRzKI$_B(tqnS1k!)!GX&Dde1<^!A(vrT)4%r_0_m^&41x5+K0_e=h|ds6f5T@8 zr2oNZ2&5nN83O6Ye1<^!AAN>E`k!pZ0mGv{?lT0^PxuUh^f!HmK>AxgLm>U6&k#sI z`hCup1e1<^!J1)cUsL%Thf%FSLLm>U1K0_e=U7sP4e$i(Lq+jwG0_p$q z83O6=`3!;dNuME*e%WOh9`*Y^Lm>SFpCOQb#b*elU-cOR>Hqc_0_h+641x4(K0_dV z%4Z0qf8;X+(m!??hDUwfX9%QE`wW5f|M(1n^#A${f%F?bLm+*|X9%SK&u0jvf8sL) z(r@|;RX9%Q!snjjI+dlGQ`+zN|6pyjl z1QwtYE`Y-F6R3N1h?{<#qttD?w=yoR$dPiMo00qd#`yB)9xL*QvE!0`>8*VYDnopn zHFSuAOJs)^_&id-J%dAg4OE+`?iMG>d9M-Z2iTrLSaQbA$VyE;zk@6Gfa)8C6G z;jHrjwVYG$Mse{kpv%(_WrBJAFzRHFoe9)KC<0$DoDv7>VX1`zsp3N@eWNK%ep9CG zjoiV*9j7kK7?$-gEZ9T4wbY5`Nje>Z%}>sxag)Ft7{Mb7#$c03l}B$Q=8Qj3A3zb4 zNEg8{-}l^5^lMz_d3mT4xSsKS1&zpBZMtd!YvB;=@CYLY(?24n$sM3T&CS+0+~%Q5 zv$e&$1*cPUCL&p4oiGx34GbUVQ)gJ%IG)(Wi1Ae{`*?3z9Gl~mfg@(}v`9#$OE^9o znY$4X>jesfP9JOao#4KcGC1B5_Dw0oML?u5zWHmqqo{-3PyzuS&14aT2?t3O+yHS! z#}~~n@m7Ry7GdOvGWs3t|8=C;KpYGyyU2Ga=~_UZgZ&`VB`Cm$GR9R5MYF-{^cQg( zGY^FR2w@)mC-bq4!e5-ie=)B<(bfGj(>L1#%`gu0$oVi=KU3VXS2A>d13*;^e8lfE zhvmfoQ5@Xa24oPQdhS`BOX1iGd)Clt`eIGi97fY6-2TRqoC>j<*`*06qdwiSbw1Ov z(>_Dv?c8afd2Tpnc(qc%plbvpY*r`&8cuPSQlH@a!?}uLtKyy;4nH4}8$+o=tHn*6 zDBJ6CyA~L&)^VHfEcdaTs=j2i6$hn7peqnwJLBqenSSvQ#wi}c93nDsm_97MJ$(K` z2OZ1zkTFn4Z0|31l=^Znwfiz=7Uk%l%vUoCe}PN+r!wj(fAnJ_`i{Z_a}}{;amN>M zOzROo`k~vfPiOky)xJ?kG3xOJe1G+@izYwQ0p(E7SU@`g5H&r)4aEj&h!4 zKY*C3jtD=1W-J~F71jftPGin{bYY&H`xI_o>W=ZurUyTp8jj#JoA~8+v93pHrxDx&t*%r%D^tpsY-BK;bVY^WebZfQr$A-+dL} zRaeln3d#a3`Uf!_uh(jOAX_!wahPqnR$|<3$OA>f)sb6bd>#yX3^#5lbT0x~+^2_4 zL`FT%YDQP=g=xujL5U1^&~rVG;e9WP%+Wq;QPf#`)u3;&<+IxbFhpkMvNh{T>!tzy zI8ihB=TpeYJVJJ*Vxdk=ApjwyeZCwuHFYf|PT)@NUNF#6c<~`Z3tViS^Q>O2uX4!F`f-B59S6=6% zn%Tuqc0jr7qS6ywqHZIS(?4LiM9j`PXQ;3A1PtfUy(#A+=SST|5)+(+11C zh9rJF7lFDQ?jc=Rj}YUX?RR<V5)$%>M$&@1#e-fYz#XwOSlMRQgdduT6F*< zh?a;*Qs{pc77qrX%JCD!F~mAs-)Y6kUKtC<31VU#^bshHLT+rvEod8g*MaR#%@i|U%%hMJt6cG3J$>ygkoCY`v#J+g|^}(nsDHg3c-!%F@mc#$^RBY z5|sJ_7LIKf8weDa3LgIoiaG($LcZG2N;uBk-pHCl6vF1>PjCsQ2y5OkN&_S=8gTr$ zW}QOUBjQ7d%Q%?7a4lxPdJ`*jEgD;9V+zlTdLC2K2&pK|38osFg2a}P35tx71kRHf z{?~DTfnHRwWjnyk;|2$UdD!3^)Rvi2HX^|hnSTFt=u=6<>2hG{?;3<}y;?mv+c z0v&}%kFCy6@w`xcT8hBeu5nB-zF?6c7H*XTC?XgiF0&%AJsi{NS_TEnKx`7>Owr@v zVvFz{W$T1f=PC)J`PDWc@5Maw<@!m4D0vgdax9wRBlwPmbgOt4H$4!c1QH(V?c0vG z@%#nXh(g5v;x^DV#z<>iLkz~vdWbl^`|2B}@U!6?VI@FiTu(*k34-lW=#->|0J;n< zYHneK94?TqlAt8bqv5;J7*8SZXoNNrjKQWx3BhAp7XyK*DFLVxL>pT}C>q38$#WB{ z{9FUkov}MW&aTw7D;k7eHcn*`W5AOR;TYnOfRAESSRx>s31_yKryg-}`2sQZ%g7xk z@8|=AT!|zgEEI@A5`spUKBSQZ0dq0KWxTJ@+(u}0%t{GU!x!m7Y;zII31Q$rN1$S5 zX>u6O2(wU0=C!>=RHcVV_LUIs+bl;F^FmkhxQc|H!DKfpH2cy;3zv<~P`lePeXk_j zG{z_0YGI7F-bPFzJ*jh=)6|H09sob~NQ5{byflyl+A#+qXJ{cehihX@x5NwzDH=1A z7c^t%BvXkhWUFYQH_W$E?*P>} zp}}CWF{SES+MjWa(MYl=j4FbDV!$?7Cj|qtxQ_=ez`zmF(>)5YYGR3(SL-KUeZWTQ z)arh8i78rbV%BB)7_UryJl#>pI1s9Njc$5`w%!_%l{JLzU5mnNLCE58%)|!WORZpH zqBY;)YO{hXF}5!Ei903F-KTRv->CCiaCGU`7A{tXeD8#Yzh;}YkSz3q0`_j=aL8jU z>UIoT7_%?~k`Ef-WlYQn8JHAD`a!)k+!1N|{om4=H@x&TUQ-Bv?4eKV7yqUC^Bea+ z^b)0C_;}$Leksx~-jF}Pq+h7+`IBo-yJEi%mBE($gQs)9=t}-RN_IA=FII0k{>Ije z4OgDwYQ*v$4|y|$Kb&U%B32|*A%%xV^lfY*Vy9(nIH-Jykxe8H^G9(b`0HqC2Efed z;61$SAYjwu3ZW4-Ft3KBr=*T(l6xlZ$22vUTf-9xgs(?TZBJHt{w$fLK&&Kq(B|4g zfL|t^K<_$2Q^k#NjMQYHZUc0i7#qcw+Z%;8F7qd6X3pONSn=me&pUY;N7v~&`2KiR7Y5ZKq8|t@Srg~paek#Sg~C^ z!$h2btRRe6(f}@-7=&a$7vRlAMEWbRD!5A#2+M14Vq^!8*3W4*8e$IlPjElux}7&t zsdo{hM&~MJc{zxQRqnIl>$h04<`FwxoVf+Rm0{i!k~slsWPFbhWlN@2m>Nl9^6n6g zat(o6K*8G$OqhQk2|w4(B{~`=aygE`xFMXOIp$;L*ex{E4R%j8=>-w9 z?L3XMVh-HxZ8*@ia0`#$MEYwgm^dO&tROslrCuHlKlnnKx8Xa4M#xtR>W|M(^x>f< zkpdGr1c~n)aKo-WAjID?3{8AmLZc=Ger1gJR!WeNUTNEMxFU1{xK>6G8zA)}M3e?( zWCYGcpgIX!mqg(WFjQb4)FEgQW57RnODs%SPsF8SFk*hw4A$A5@LU~lBbiIlG-dUo zc2W~bs8qQ^Zxcx0G~eK9Q1RmPhyh)V^A^!(VWYRVtbmr5-4Rd}~Y)WKe2C^MA8>TqCg$wP^KqFr;b+c0xJk&k&ho$f1Wt*QB!ot+WnhWnkXD zwWAhASeEU9p&BH7hv1-v7tPU#)_?<8P)j^okyMyDTy6i-@yKz?TX&W`F!^uRD`5%^Nt9na$k4oN@~Ao zLO>db^F&s_*GQcOF4S-_5=G7xcX-g17;swCh#jP?kc~{rd!n3Rt4G-Uwh53cvj&Eu z(ZeQYO=dN}0!QSG0i=bqPyuSv7;Mr3Ndnn9%N23mnZk=w&sZG1Nw*r7+hk@H;%O>H z3JUA%kDb~lO8puyJqzEYFf)SjtzDk9X1y9|T>ry6QIN<|^d*-gdJ)`6f?Al$C)C55 zO(6RyuoK~lfo!?lR|Zh{38pLCJ(3-vu@q!HVK(DtB|3$s(&#ylBQ{{U=fT4)X~e)( z5jg#Z0t!-5S~3<34X=`=pCV?^KM)6cUdTz@w36)A zw8qedjI`23FnKa~2VTIVRp-OU4gGo|x-WOvaJa`Tc zlIufYwBO)mr9K~FEW^`gsMov)?9;D%QCA}L)4`Eyk@Wc8` z)N{*mFFSF}XhoV!-1M=vlG3qeGUNjo(Td_MY_$T`gHyR>;BB_|I zLsW$nE0|%Q2v>?5jI6-8a7{c;T01Zs5OT-FnP@u{O8k(9wLffbG(*y}fiZvH@&d>^U8HkjA76>Bv6u^{b!;pS=0K^lUAdqHJ zpLrgO`ot~}yXi{pBghD#T4?_}oIQT*1H0~IB|b-J_bvUv^MLTl=Yr5~IkN)^N~WUU zA(V4uu6rH5GKny4hsc@%tus(VSC9wB~BkM$jr^TDIxbciQVIsb~I z0Cs+oW%Df zy!1C7-2CI8UOaWt{=2UH!KZ%n*EVO9r+?>9qj#47>{CDa*bzKTd3mP84?w3Pb`0hy z1ddi$pa`ts^>sd^AyzO-Xl?%F@j=Y^(CG2)w8pe5y&sPE!+;XI$0JN|Gq{837qn$C znf$gJ?So?Y#`=0B69)H96g$RY%tynr=?Lfkwz5P(?o(f^;=~1@FwAE5s9-*GBy)YH zm>KC4yCTlOHH3WQQ;{eT$f7H<1O=twQYKi$O_{N-=nw78Sn6KHEt#S8^@iIrLvPN& zXBz~3aKxB|)#I?(9OqzqA^@6v-Y}qiX3ItsVj(m~;(=Uucxz@TDC7K|PELeS%Cig1 z(xMq}JCa~ufxG=MgfoRjXIa9G3lns438fjiD-i`R69$U#bxl}9t)U(+Q=rYTXp&~N z6Rxz^5vPw7FMOgZ&!;fL6;lQyalhMhYG=78&T8`9fMdJ#pe5q$aBcI5gYkOvJ-AFb3G- z+B!S|0salpW+{k~1J1ORtevKj!-5M-FTHcY#&p-N8@+o_&~RP5+;cq*;x5Es=MZ;q z4VKIg3w1Tzz{)G|_^yU)u5CY)Yf%7;lQqc zW4J@4mg3c_X;_7;JN~9gfKdA|AHc9yx-0YUOs*QvQi0SmxbJ+}VK)W%83%<--Y3ARYcs=%N| zxM6IMMygn^Khtv@uo#>OFh1B4KFu^Q5#k(W+ zK#~1`IQ%0rp=NBABx|=lUtxGO^N9={?J-4?B_gn0X=Z^Cs4H-+`F48_ZZg<#h$yI8 z(jJU}3`I}W2;njw`#2pmkx|hz&Z1bdv6c!$Xrfba;>VkjDIR=%J8s8;cQFLsSzE^7 zusA(_DwA!Uzbhk;H^{}RPiIEALd#is(Ngsyy!9cw00_T@;}Av(3a-n3A2e5~(jiF) zv}dbv5rIwNv{9^7!I*gC3Ykcirt=-1Q%l;!)?_SFEFXyQ3i~9^Vm1WLOLe@>UTPug z5L=Uv*ZLvKKbHP?9|*O4|+ce9z5cc z0xQX~hU&0ilU&6oi4nUspw+eh_>e|8!Xpl#i-RgsvmCEV^&H~LSv!vAATRI+dOa&q zvyDnHZ56A6C{}4!_;I#8kdG4}LAiZq7Z#H2Y8%0d2mNw zMDe4%J@o;JRL=(Y84k$ z?ehTz3omHZoGHMWrnND-hE50pBlUQPzyW=(gi*upj@m1SXP4$-B&LV%%kcYLM-Ws# zbc&X6Hjm8C$r&*v^Iysg-V-8VElThr$$(A$^dv><^BuiguPsxwSv;5SHGCD@6$w`& z@Hn$v43L$t716ECtM=nX z)K?wIhfx&a1Ys3@nEuf{g}VGOF(BKNBdBQr*!E~D?b{!{pB)WaaI4?_6;v;cWcxni z+Wj2s)0t;7;bl0BARh*d0@9UJ_`UE1HfUaJ!}s(-h>VM8xcNxM!@Q5h#pA3|b^w zfx%*U>9RY!k?H-kZjeZk594SvB8fFUTNsVZIN>&WF!l%UL@cDh>Q-ZX3d+if6K>E1 zE^C#A=I{z~h;{)DkRKy=OQ1B|?}Z%`vlCuNMq_{(H7+#oS^KW*xW(BWT#mWp^1mr38V-7g5NVt zS0+9^>SOelK!V(Wm7UG6s;9BQ;6M_g6**3Za!u1yZ*PiHLW~(O zks&Hv0}aCp@YxYL-~bbF#z|9bnESI{^)|l7@G~Q3$cW>s&>khZlf27eS>~g0DuM|y z*d>Rgp0aW$BF!2qw-uA`tT~<+Q4iu8s4zB}Xlqo*a&VaCSRR-6J8L3x!Ka7suJ=Gq z`Zr*)AOeT+8#fQIR(xXt{-!)ZAXW~gMb69fX|1Rx*jaF@Bi)qFfpJO0Z1&<=Y)dls zMU!UUz@2Ggae8nM5ZjC6-JFgce=w406v{JJ2IL($PEsnECoe9I+13)$50z-MSjHs~ zDhD##243N~AuA>ArIzgOPk@e5+71k>@piFUk^L<+qZV(%^;w{Bh`x`w zp5?M;KVo79pvXar2`2m!?;j#a*miN1@S5vVj%$(_X)?7RJ|WE29it~{jJz7%9xWP{ zjaH5d&VUpe-VWse(Shj}5TV%4laNO6wkQT}q&Pcpc~TYI0T^H#0nx+8wnD(O%y{Y8 zMjXzt?b*629HLZ*-a)<*B3{v{J`l!=}=lRsoR(j!9r7uKV%fIxKA25mOXzRe?BuRpUN) z%XJ0Rkdh%QF|3;8XypcdwK;1Bz-E$1+4KO5X0&7X4B)19HPznQVbq3gQCzR$=)4;( zAHA}|TUg(*W5+T`X!M8mQ#$ypYluc_Yo-rvAq)0QLe#J&%|nuC-gg$Hp5A*(IMvw%pYwru;3X3_)bk*z+#?<3EJ}pOR&elKX)-G#!#*qf zQ68hfL6TH{K*MJ~jS#M~l#(jF7fx}42ZMaNqCfsKGaZe?0UT5YiXFZM<0-Wp??2#< z`>Lx?b#38g`@_EA!?j1u0qflw*V{c_nOr((aShCv8|=7sO4=x%0P>aXH&_M>xb?J| z>>a=bb?EbQ(H%sLR7c1Q{)mq$j*;6)E+-REDPDD*q=%L58f2gDa3%b)RCnpx9X$d2 zDqzjj*Nl?~;oyr$BAdbB`Brjw=7=V_{94XRQlf1~n_jGAsn#uTx)2@($E`$b#CA-> zTo(b+QGS2`OM)=>*3=)}CW z_==r^p*NSWXnNofxs7{C4T?}e`k*ln!`o>Ar$MkCb-)T+Hc9BBK=bU%{G}>FJOfPR zKFkshU#(!tNA#AYUgf7=Nqz(@ApP`So3zMG4RVmQNhy?|x$vYI+~_p5>>05rc3@+; zrwU6TEXO218fk;p5o)dbGg5v^g58%X22qjOB%$WHK1W3;~-_o~=9By&lYAa&tiNx7YG*<~p zq_CYa_=eJm6;xF0{9+Vf^-azy@(JNz_awQ zlw+jtu)kvjkl%a5k+Dq8`jWUln{CO5`KN5J7-XvBY`WvS^&lqu66!wg>OM8djz?|GDv&fdJ}H$B^f62cd||mh4w)x?(3`U;r#jWEi+}x@9JLw diff --git a/rust/pragma-cli/src/runtimes/mod.rs b/rust/pragma-cli/src/runtimes/mod.rs deleted file mode 100644 index 05ed7c04..00000000 --- a/rust/pragma-cli/src/runtimes/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod support; diff --git a/rust/pragma-cli/src/runtimes/support.rs b/rust/pragma-cli/src/runtimes/support.rs deleted file mode 100644 index 6fc39236..00000000 --- a/rust/pragma-cli/src/runtimes/support.rs +++ /dev/null @@ -1,33 +0,0 @@ -pub type ChainPrefix = u16; -pub type ChainTokenSymbol = String; - -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum SupportedRuntime { - Madara, -} - -impl From for SupportedRuntime { - fn from(v: ChainPrefix) -> Self { - match v { - 0 => Self::Madara, - _ => unimplemented!("Chain prefix not supported"), - } - } -} - -impl From for SupportedRuntime { - fn from(v: ChainTokenSymbol) -> Self { - match v.as_str() { - "ETH" => Self::Madara, - _ => unimplemented!("Chain unit not supported"), - } - } -} - -impl std::fmt::Display for SupportedRuntime { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Madara => write!(f, "Madara"), - } - } -} diff --git a/rust/pragma-cli/src/utils/constants.rs b/rust/pragma-cli/src/utils/constants.rs deleted file mode 100644 index cd8b612c..00000000 --- a/rust/pragma-cli/src/utils/constants.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub const DATA_FEEDS: [&str; 2] = ["median", "average"]; -pub const ORACLE_ADDRESS: &str = "0x2a85bd616f912537c50a49a4076db02c00b29b2cdc8a197ce92ed1837fa875b"; diff --git a/rust/pragma-cli/src/utils/mod.rs b/rust/pragma-cli/src/utils/mod.rs deleted file mode 100644 index 0b6d2c4e..00000000 --- a/rust/pragma-cli/src/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod constants; diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml index 8c9c3a25..7d857086 100644 --- a/rust/rust-toolchain.toml +++ b/rust/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.81.0" +channel = "1.82.0" components = ["rustfmt", "clippy", "rust-analyzer"] targets = ["wasm32-unknown-unknown"] profile = "minimal" diff --git a/rust/theoros/src/configs/evm_config.rs b/rust/theoros/src/configs/evm_config.rs index 8c6358c9..5f4531f3 100644 --- a/rust/theoros/src/configs/evm_config.rs +++ b/rust/theoros/src/configs/evm_config.rs @@ -68,20 +68,10 @@ impl EvmConfig { Ok(config) } - /// Get configuration for a specific chain - pub fn chain_config(&self, chain_name: EvmChainName) -> Option<&EvmChainConfig> { - self.chains.get(&chain_name) - } - /// Get all configured chains pub fn chains(&self) -> &HashMap { &self.chains } - - /// Get all configured chains names - pub fn chain_names(&self) -> Vec { - self.chains.keys().cloned().collect() - } } #[derive(Error, Debug)] @@ -120,23 +110,3 @@ impl FromStr for EvmChainName { } } } - -#[cfg(test)] -mod tests { - use super::*; - - const EXAMPLE_CONFIG: &str = r#" - zircuit_testnet: - rpc_url: "https://zircuit1-testnet.p2pify.com" - hyperlane_address: "0xb9aB8aDC69Ad3B96a8CdF5610e9bFEcc0415D662" - "#; - - #[test] - fn test_parse_config() { - let config: EvmConfig = serde_yaml::from_str(EXAMPLE_CONFIG).unwrap(); - - let zircuit_config = config.chain_config(EvmChainName::ZircuitTestnet).unwrap(); - assert_eq!(zircuit_config.rpc_url, "https://zircuit1-testnet.p2pify.com"); - assert_eq!(zircuit_config.hyperlane_address, "0xb9aB8aDC69Ad3B96a8CdF5610e9bFEcc0415D662"); - } -} diff --git a/rust/theoros/src/main.rs b/rust/theoros/src/main.rs index 830187a9..a15cea2f 100644 --- a/rust/theoros/src/main.rs +++ b/rust/theoros/src/main.rs @@ -9,11 +9,10 @@ mod services; mod storage; mod types; -use std::sync::{atomic::AtomicUsize, Arc}; +use std::sync::Arc; use anyhow::Result; use clap::Parser; -use prometheus::Registry; use storage::TheorosStorage; use tracing::Level; @@ -25,29 +24,10 @@ use pragma_utils::{ use cli::TheorosCli; use rpc::{evm::HyperlaneValidatorsMapping, starknet::StarknetRpc}; use services::{ApiService, HyperlaneService, IndexerService, MetricsService}; +use types::state::{AppState, WsState}; const LOG_LEVEL: Level = Level::INFO; -#[derive(Clone)] -pub struct AppState { - pub starknet_rpc: Arc, - pub hyperlane_validators_mapping: Arc, - pub storage: Arc, - pub metrics_registry: Registry, // already wrapped into an Arc - pub ws: Arc, -} - -pub struct WsState { - pub subscriber_counter: AtomicUsize, -} - -#[allow(clippy::new_without_default)] -impl WsState { - pub fn new() -> Self { - Self { subscriber_counter: AtomicUsize::new(0) } - } -} - #[tokio::main] #[tracing::instrument] async fn main() -> Result<()> { @@ -56,15 +36,12 @@ async fn main() -> Result<()> { init_tracing(&config.app_name, LOG_LEVEL)?; let starknet_rpc = StarknetRpc::new(config.madara_rpc_url); - let hyperlane_rpcs = HyperlaneValidatorsMapping::from_config(&config.evm_config).await?; - - let (update_tx, _) = tokio::sync::broadcast::channel(1000); + let hyperlane_validators_mapping = HyperlaneValidatorsMapping::from_config(&config.evm_config).await?; let theoros_storage = TheorosStorage::from_rpc_state( &starknet_rpc, &config.pragma_feeds_registry_address, &config.hyperlane_validator_announce_address, - update_tx, ) .await?; @@ -72,7 +49,7 @@ async fn main() -> Result<()> { let state = AppState { starknet_rpc: Arc::new(starknet_rpc), - hyperlane_validators_mapping: Arc::new(hyperlane_rpcs), + hyperlane_validators_mapping: Arc::new(hyperlane_validators_mapping), storage: Arc::new(theoros_storage), metrics_registry: metrics_service.registry(), ws: Arc::new(WsState::new()), @@ -86,15 +63,19 @@ async fn main() -> Result<()> { config.pragma_feeds_registry_address, config.indexer_starting_block, )?; - let api_service = ApiService::new(state.clone(), &config.server_host, config.server_port); let hyperlane_service = HyperlaneService::new(state.clone()); + let api_service = ApiService::new(state.clone(), &config.server_host, config.server_port); - let theoros = - ServiceGroup::default().with(metrics_service).with(indexer_service).with(api_service).with(hyperlane_service); - - theoros.start_and_drive_to_end().await?; + ServiceGroup::default() + .with(metrics_service) + .with(indexer_service) + .with(hyperlane_service) + .with(api_service) + .start_and_drive_to_end() + .await?; // Ensure that the tracing provider is shutdown correctly opentelemetry::global::shutdown_tracer_provider(); + Ok(()) } diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index 32958de3..b3bd090d 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -35,10 +35,6 @@ impl HyperlaneValidatorsMapping { self.0.get(&chain_name) } - pub fn validators(&self) -> &HashMap> { - &self.0 - } - /// Get all configured chains names pub fn chain_names(&self) -> Vec { self.0.keys().cloned().collect() diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index dd9013a7..2cdcdcc9 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -77,8 +77,9 @@ impl HyperlaneService { } tracing::info!( - "πŸŒ‰ [Hyperlane] Validator {:#x} retrieved latest checkpoint for message {:#x}", + "πŸŒ‰ [Hyperlane] Validator {:#x} retrieved latest checkpoint for message [#{}] {:#x}", validator, + checkpoint.value.checkpoint.index, message_id ); if let Err(e) = self.state.storage.validators_checkpoints().add(validator, message_id, checkpoint).await { diff --git a/rust/theoros/src/services/indexer/mod.rs b/rust/theoros/src/services/indexer/mod.rs index 774245ca..4f8f0064 100644 --- a/rust/theoros/src/services/indexer/mod.rs +++ b/rust/theoros/src/services/indexer/mod.rs @@ -179,17 +179,19 @@ impl IndexerService { // overriten anyway? (we only store the latest update for a given feed) let dispatch_event = DispatchEvent::from_starknet_event_data(event_data).context("Failed to parse Dispatch")?; let message_id = dispatch_event.id(); + let nonce = dispatch_event.message.header.nonce; match &block.header { Some(h) => { tracing::info!( - "πŸ“¨ [Indexer] Received a Dispatch event at block #{}, message_id={:#x}", + "πŸ“¨ [Indexer] Received a Dispatch event at block #{}, (#{}) message_id={:#x}", h.block_number, + nonce, message_id ); } None => { - tracing::info!("πŸ“¨ [Indexer] Received a Dispatch event, message_id={:#x}", message_id); + tracing::info!("πŸ“¨ [Indexer] Received a Dispatch event, (#{}) message_id={:#x}", nonce, message_id); } }; diff --git a/rust/theoros/src/storage/event.rs b/rust/theoros/src/storage/event.rs index c6776cef..10224f6f 100644 --- a/rust/theoros/src/storage/event.rs +++ b/rust/theoros/src/storage/event.rs @@ -51,35 +51,6 @@ impl EventStorage { let feed_id = hex_str_to_u256(feed_id)?; Ok(events.get(&feed_id).cloned()) } - - /// Returns the current mapping as a Vec. - pub async fn as_vec(&self) -> Result> { - let events = self.events.read().await; - Ok(events.iter().map(|(k, v)| (*k, v.clone())).collect()) - } - - /// TODO, explain + re-assert the existence of this. - /// Retrieves multiple events by their feed IDs. - /// Returns a tuple of (found_events, first_missing_feed_id). - /// If all feed IDs are found, first_missing_feed_id will be None. - pub async fn get_vec(&self, feed_ids: &[String]) -> Result<(Vec, Option)> { - let events = self.events.read().await; - let mut result = Vec::with_capacity(feed_ids.len()); - let mut missing_feed_id = None; - - for feed_id in feed_ids { - let u256_feed_id = hex_str_to_u256(feed_id)?; - match events.get(&u256_feed_id) { - Some(event) => result.push(event.clone()), - None => { - missing_feed_id = Some(feed_id.clone()); - break; - } - } - } - - Ok((result, missing_feed_id)) - } } /// Contains a Mapping between message ids and the corresponding Event. @@ -95,18 +66,6 @@ impl EventCache { cache.insert(message_id, event.clone()); } - /// Returns the number of mappings stored. - pub async fn len(&self) -> usize { - self.cache.read().await.len() - } - - /// Returns the mappings as a Vec. - /// Will contain a tuple, first element being the message_id and second the Event. - pub async fn as_vec(&self) -> Vec<(U256, DispatchEvent)> { - let cache = self.cache.read().await; - cache.iter().map(|(k, v)| (*k, v.clone())).collect() - } - /// TODO, explain + re-assert the existence of this. /// Should probably be used in the context of the Hyperlane service: /// * each validators try to query the signatures for the cached events diff --git a/rust/theoros/src/storage/feed_id.rs b/rust/theoros/src/storage/feed_id.rs index 2e928118..0a73e8cd 100644 --- a/rust/theoros/src/storage/feed_id.rs +++ b/rust/theoros/src/storage/feed_id.rs @@ -7,10 +7,6 @@ use tokio::sync::RwLock; pub struct FeedIdsStorage(Arc>>); impl FeedIdsStorage { - pub fn new() -> Self { - Self(Arc::new(RwLock::new(HashSet::new()))) - } - pub fn from_rpc_response(feed_ids: Vec) -> Self { Self(Arc::new(RwLock::new(feed_ids.into_iter().collect()))) } @@ -44,27 +40,6 @@ impl FeedIdsStorage { feed_ids.len() } - /// Returns true if the storage is empty. - pub async fn is_empty(&self) -> bool { - let feed_ids = self.0.read().await; - feed_ids.is_empty() - } - - /// Returns a clone of the inner HashSet. - pub async fn clone_inner(&self) -> HashSet { - let feed_ids = self.0.read().await; - feed_ids.clone() - } - - /// Performs an operation on the inner HashSet while holding the write lock. - pub async fn with_inner(&self, f: F) -> R - where - F: FnOnce(&mut HashSet) -> R, - { - let mut feed_ids = self.0.write().await; - f(&mut feed_ids) - } - /// Returns an iterator over the feed IDs. pub async fn iter(&self) -> impl Iterator { let feed_ids = self.0.read().await; diff --git a/rust/theoros/src/storage/mod.rs b/rust/theoros/src/storage/mod.rs index 7ae978e4..0e5b5bc2 100644 --- a/rust/theoros/src/storage/mod.rs +++ b/rust/theoros/src/storage/mod.rs @@ -16,11 +16,11 @@ use crate::{ /// Theoros storage that contains: /// * a set of all available feed ids, -/// * a mapping of all the validators and their fetchers. -/// * a mapping of all the validators and their latest fetched checkpoints. -/// * an event cache, -/// * an events storage containing the most recents [DispatchEvent] events indexed. -/// * a channel to dispatch updates to the clients. +/// * a mapping of all the validators and their fetchers, +/// * a mapping of all the validators and their latest fetched checkpoints for a given message_id, +/// * an event cache, used to store events that have not been signed yet, +/// * an events storage containing the most recent [`DispatchUpdateInfos`] per feed_id, +/// * (websocket) a channel to dispatch updates to the clients. pub struct TheorosStorage { feed_ids: FeedIdsStorage, validators: ValidatorsLocationStorage, @@ -35,7 +35,6 @@ impl TheorosStorage { rpc_client: &StarknetRpc, pragma_feeds_registry_address: &Felt, hyperlane_validator_announce_address: &Felt, - update_tx: Sender, ) -> anyhow::Result { let initial_validators = rpc_client.get_announced_validators(hyperlane_validator_announce_address).await?; let initial_locations = rpc_client @@ -48,6 +47,8 @@ impl TheorosStorage { let supported_feed_ids = rpc_client.get_feed_ids(pragma_feeds_registry_address).await?; let feed_ids = FeedIdsStorage::from_rpc_response(supported_feed_ids); + let (update_tx, _) = tokio::sync::broadcast::channel(1000); + Ok(Self { feed_ids, validators, diff --git a/rust/theoros/src/storage/validator.rs b/rust/theoros/src/storage/validator.rs index 4bc57e5d..a3541e09 100644 --- a/rust/theoros/src/storage/validator.rs +++ b/rust/theoros/src/storage/validator.rs @@ -87,16 +87,6 @@ impl ValidatorsCheckpointsStorage { Ok(()) } - /// Returns all the checkpoints for each validator - pub async fn all(&self) -> HashMap<(Felt, U256), SignedCheckpointWithMessageId> { - self.0.read().await.clone() - } - - /// Returns the checkpoint for the given validator and message Id - pub async fn get(&self, validator: &Felt, message_id: U256) -> Option { - self.0.read().await.get(&(*validator, message_id)).cloned() - } - // Check if any of the validators has a checkpoint signed for the provided message id. pub async fn contains_message_id(&self, message_id: U256) -> bool { let all_checkpoints = self.0.read().await; diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index f6a5a09f..a14cccd2 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -11,7 +11,7 @@ use crate::{ errors::GetCalldataError, storage::DispatchUpdateInfos, types::hyperlane::CheckpointWithMessageId, - AppState, + types::state::AppState, }; use super::hyperlane::DispatchUpdate; diff --git a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs index e91aae15..44c372f2 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs @@ -26,10 +26,12 @@ use super::SignedCheckpointWithMessageId; #[async_trait] pub trait FetchFromStorage: Debug + Send + Sync { /// Attempt to fetch the signed (checkpoint, messageId) tuple at this index + #[allow(unused)] async fn fetch(&self, index: u32) -> Result>; /// Attemps to fetch the latest (checkpoint, messageId) tuple async fn fetch_latest(&self) -> Result>; /// Return the announcement storage location for this syncer + #[allow(unused)] fn announcement_location(&self) -> String; } diff --git a/rust/theoros/src/types/hyperlane/events/dispatch_event.rs b/rust/theoros/src/types/hyperlane/events/dispatch_event.rs index 4ff2e5e9..e7e72365 100644 --- a/rust/theoros/src/types/hyperlane/events/dispatch_event.rs +++ b/rust/theoros/src/types/hyperlane/events/dispatch_event.rs @@ -14,8 +14,11 @@ const SPOT_MEDIAN_UPDATE_SIZE: usize = 107; #[derive(Debug, Clone)] pub struct DispatchEvent { + #[allow(unused)] pub sender: U256, + #[allow(unused)] pub destination_domain: u32, + #[allow(unused)] pub recipient_address: U256, pub message: DispatchMessage, } @@ -218,14 +221,14 @@ impl DispatchUpdate { let raw_feed_type = u16::from_be_bytes(data.drain(..2).collect::>().try_into().unwrap()); let feed_type = FeedType::try_from(raw_feed_type)?; - let pair_id_low = u128::from_be_bytes(data.drain(..16).collect::>().try_into().unwrap()); + let pair_id_high = u128::from_be_bytes(data.drain(..16).collect::>().try_into().unwrap()); let mut padded_data = [0u8; 16]; let extracted_data = data.drain(..12).collect::>(); padded_data[4..].copy_from_slice(&extracted_data); - let pair_id_high = u128::from_be_bytes(padded_data); - let pair_id = U256::from_words(pair_id_high, pair_id_low); + let pair_id_low = u128::from_be_bytes(padded_data); + let pair_id = U256::from_words(pair_id_low, pair_id_high); - let feed_id = build_feed_id(raw_asset_class, raw_feed_type, pair_id_low, pair_id_high); + let feed_id = build_feed_id(raw_asset_class, raw_feed_type, pair_id_high, pair_id_low); let update = match feed_type { FeedType::UniqueSpotMedian => { @@ -271,10 +274,10 @@ impl SpotMedianUpdate { let decimals = u8::from_be_bytes(data.drain(..1).collect::>().try_into().unwrap()); let price_high = u128::from_be_bytes(data.drain(..16).collect::>().try_into().unwrap()); // U256 let price_low = u128::from_be_bytes(data.drain(..16).collect::>().try_into().unwrap()); - let price = U256::from_words(price_high, price_low); + let price = U256::from_words(price_low, price_high); let volume_high = u128::from_be_bytes(data.drain(..16).collect::>().try_into().unwrap()); // U256 let volume_low = u128::from_be_bytes(data.drain(..16).collect::>().try_into().unwrap()); - let volume = U256::from_words(volume_high, volume_low); + let volume = U256::from_words(volume_low, volume_high); Ok(Self { pair_id: U256::from(0_u8), // This will get populated later @@ -297,8 +300,8 @@ impl SpotMedianUpdate { bytes.extend_from_slice(&self.price.high().to_be_bytes()); bytes.extend_from_slice(&self.price.low().to_be_bytes()); - bytes.extend_from_slice(&self.volume.low().to_be_bytes()); bytes.extend_from_slice(&self.volume.high().to_be_bytes()); + bytes.extend_from_slice(&self.volume.low().to_be_bytes()); bytes } } diff --git a/rust/theoros/src/types/mod.rs b/rust/theoros/src/types/mod.rs index 10b3b61f..c1f9c34d 100644 --- a/rust/theoros/src/types/mod.rs +++ b/rust/theoros/src/types/mod.rs @@ -1,3 +1,4 @@ pub mod calldata; pub mod hyperlane; pub mod rpc; +pub mod state; diff --git a/rust/theoros/src/types/state.rs b/rust/theoros/src/types/state.rs new file mode 100644 index 00000000..330d7998 --- /dev/null +++ b/rust/theoros/src/types/state.rs @@ -0,0 +1,30 @@ +use std::sync::{atomic::AtomicUsize, Arc}; + +use prometheus::Registry; + +use crate::{ + rpc::{evm::HyperlaneValidatorsMapping, starknet::StarknetRpc}, + storage::TheorosStorage, +}; + +#[derive(Clone)] +pub struct AppState { + #[allow(unused)] + pub starknet_rpc: Arc, + pub hyperlane_validators_mapping: Arc, + pub storage: Arc, + #[allow(unused)] + pub metrics_registry: Registry, // already wrapped into an Arc + pub ws: Arc, +} + +pub struct WsState { + pub subscriber_counter: AtomicUsize, +} + +#[allow(clippy::new_without_default)] +impl WsState { + pub fn new() -> Self { + Self { subscriber_counter: AtomicUsize::new(0) } + } +} From 5817ccc3a05f8ff9c97d92269ae6d7e2fc35b81b Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 00:22:37 +0100 Subject: [PATCH 02/55] dev(better_theoros): pt1 --- rust/theoros/src/cli.rs | 3 - .../websocket/subscribe_to_calldata.rs | 14 +-- rust/theoros/src/main.rs | 4 +- rust/theoros/src/rpc/starknet/mod.rs | 7 +- rust/theoros/src/services/hyperlane/mod.rs | 106 +++++++++++++----- rust/theoros/src/services/indexer/mod.rs | 66 +++-------- rust/theoros/src/storage/checkpoints.rs | 79 +++++++++++++ rust/theoros/src/storage/event.rs | 96 ---------------- rust/theoros/src/storage/mod.rs | 64 +++++------ rust/theoros/src/storage/updates.rs | 28 +++++ rust/theoros/src/storage/validator.rs | 69 +----------- rust/theoros/src/types/calldata.rs | 26 ++--- .../theoros/src/types/hyperlane/checkpoint.rs | 13 +-- .../hyperlane/checkpoint_fetchers/gcs.rs | 8 -- .../hyperlane/checkpoint_fetchers/local.rs | 13 --- .../hyperlane/checkpoint_fetchers/mod.rs | 2 - .../types/hyperlane/checkpoint_fetchers/s3.rs | 19 ---- .../types/hyperlane/events/dispatch_event.rs | 71 ++++-------- 18 files changed, 281 insertions(+), 407 deletions(-) create mode 100644 rust/theoros/src/storage/checkpoints.rs delete mode 100644 rust/theoros/src/storage/event.rs create mode 100644 rust/theoros/src/storage/updates.rs diff --git a/rust/theoros/src/cli.rs b/rust/theoros/src/cli.rs index e4c563e7..46816f21 100644 --- a/rust/theoros/src/cli.rs +++ b/rust/theoros/src/cli.rs @@ -50,9 +50,6 @@ pub struct TheorosCli { value_parser = parse_evm_config )] pub evm_config: evm_config::EvmConfig, - - #[clap(env = "INDEXER_STARTING_BLOCK", long, default_value = "0")] - pub indexer_starting_block: u64, } /// Parse a Felt. diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index a0c03d8c..f21a12f8 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -22,7 +22,7 @@ use tokio::sync::broadcast::Receiver; use crate::constants::{DEFAULT_ACTIVE_CHAIN, MAX_CLIENT_MESSAGE_SIZE, PING_INTERVAL_DURATION}; use crate::types::calldata::AsCalldata; -use crate::types::{hyperlane::CheckpointMatchEvent, rpc::RpcDataFeed}; +use crate::types::{hyperlane::CheckpointSignedEvent, rpc::RpcDataFeed}; use crate::AppState; use crate::{configs::evm_config::EvmChainName, types::calldata::Calldata}; @@ -74,7 +74,7 @@ async fn websocket_handler(stream: WebSocket, state: AppState) { let (sender, receiver) = stream.split(); - let feeds_receiver = state.storage.feeds_channel.subscribe(); + let feeds_receiver = state.storage.feeds_updated_tx().subscribe(); let id = ws_state.subscriber_counter.fetch_add(1, Ordering::SeqCst); @@ -89,7 +89,7 @@ pub struct Subscriber { id: SubscriberId, closed: bool, state: Arc, - feeds_receiver: Receiver, + feeds_receiver: Receiver, receiver: SplitStream, sender: SplitSink, data_feeds_with_config: HashMap, @@ -102,7 +102,7 @@ impl Subscriber { pub fn new( id: SubscriberId, state: Arc, - feeds_receiver: Receiver, + feeds_receiver: Receiver, receiver: SplitStream, sender: SplitSink, ) -> Self { @@ -134,7 +134,7 @@ impl Subscriber { tokio::select! { maybe_update_feeds_event = self.feeds_receiver.recv() => { match maybe_update_feeds_event { - Ok(event) => self.handle_data_feeds_update(event).await, + Ok(_) => self.handle_data_feeds_update().await, Err(e) => Err(anyhow!("Failed to receive update from store: {:?}", e)), } }, @@ -162,8 +162,8 @@ impl Subscriber { } } - async fn handle_data_feeds_update(&mut self, event: CheckpointMatchEvent) -> Result<()> { - tracing::debug!(subscriber = self.id, n = event.block_number(), "Handling Data Feeds Update."); + async fn handle_data_feeds_update(&mut self) -> Result<()> { + tracing::debug!(subscriber = self.id, "Handling Data Feeds Update."); // Retrieve the updates for subscribed feed ids at the given slot let feed_ids = self.data_feeds_with_config.keys().cloned().collect::>(); // TODO: add support for multiple feeds diff --git a/rust/theoros/src/main.rs b/rust/theoros/src/main.rs index a15cea2f..248c4836 100644 --- a/rust/theoros/src/main.rs +++ b/rust/theoros/src/main.rs @@ -61,9 +61,9 @@ async fn main() -> Result<()> { config.hyperlane_mailbox_address, config.hyperlane_validator_announce_address, config.pragma_feeds_registry_address, - config.indexer_starting_block, + state.starknet_rpc.block_number().await?, )?; - let hyperlane_service = HyperlaneService::new(state.clone()); + let hyperlane_service = HyperlaneService::new(state.storage.clone()); let api_service = ApiService::new(state.clone(), &config.server_host, config.server_port); ServiceGroup::default() diff --git a/rust/theoros/src/rpc/starknet/mod.rs b/rust/theoros/src/rpc/starknet/mod.rs index 8641b8e6..917dff9d 100644 --- a/rust/theoros/src/rpc/starknet/mod.rs +++ b/rust/theoros/src/rpc/starknet/mod.rs @@ -4,7 +4,8 @@ pub mod pragma_feeds_registry; pub use hyperlane::*; pub use pragma_feeds_registry::*; -use starknet::providers::{jsonrpc::HttpTransport, JsonRpcClient}; +use anyhow::Context; +use starknet::providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; use url::Url; pub struct StarknetRpc(JsonRpcClient); @@ -13,4 +14,8 @@ impl StarknetRpc { pub fn new(rpc_url: Url) -> Self { Self(JsonRpcClient::new(HttpTransport::new(rpc_url))) } + + pub async fn block_number(&self) -> anyhow::Result { + self.0.block_number().await.context("Fetching block number") + } } diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 2cdcdcc9..5a7f0333 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -1,19 +1,20 @@ use std::{sync::Arc, time::Duration}; -use pragma_utils::services::Service; use starknet::core::types::Felt; use tokio::task::JoinSet; -use crate::{ - types::hyperlane::{FetchFromStorage, SignedCheckpointWithMessageId}, - AppState, +use pragma_utils::{conversions::alloy::hex_str_to_u256, services::Service}; + +use crate::storage::TheorosStorage; +use crate::types::hyperlane::{ + CheckpointSignedEvent, DispatchUpdateInfos, FetchFromStorage, SignedCheckpointWithMessageId, }; -const FETCH_INTERVAL: Duration = Duration::from_secs(2); +const FETCH_INTERVAL: Duration = Duration::from_secs(1); #[derive(Clone)] pub struct HyperlaneService { - state: AppState, + storage: Arc, } #[async_trait::async_trait] @@ -30,8 +31,8 @@ impl Service for HyperlaneService { } impl HyperlaneService { - pub fn new(state: AppState) -> Self { - Self { state } + pub fn new(storage: Arc) -> Self { + Self { storage } } /// Every [FETCH_INTERVAL] seconds, fetch the latest checkpoint signed for all @@ -44,46 +45,89 @@ impl HyperlaneService { } async fn process_validator_checkpoints(&self) { - let validators_locations = self.state.storage.validators_locations().all().await; - let futures = validators_locations - .into_iter() - .map(|(validator, fetcher)| self.process_single_validator(validator, fetcher)); + let validators_fetchers = self.storage.validators_fetchers().all().await; + let unsigned_nonces = self.storage.unsigned_checkpoints().nonces().await; + + let mut futures = Vec::new(); + + for (validator, fetcher) in validators_fetchers.into_iter() { + for &nonce in &unsigned_nonces { + let fut = self.process_single_validator_nonce(validator, fetcher.clone(), nonce); + futures.push(fut); + } + } futures::future::join_all(futures).await; } - async fn process_single_validator(&self, validator: Felt, fetcher: Arc>) { - match fetcher.fetch_latest().await { - Ok(Some(checkpoint)) => self.handle_checkpoint(validator, checkpoint).await, + async fn process_single_validator_nonce( + &self, + validator: Felt, + fetcher: Arc>, + nonce: u32, + ) -> anyhow::Result<()> { + match fetcher.fetch(nonce).await { + Ok(Some(checkpoint)) => { + self.handle_checkpoint(validator, checkpoint).await?; + self.store_event_updates(nonce).await?; + self.storage.unsigned_checkpoints().remove(nonce).await; + self.storage.feeds_updated_tx().send(CheckpointSignedEvent::New)?; + } Ok(None) => { - tracing::debug!("πŸŒ‰ [Hyperlane] No new checkpoint for validator {:#x}", validator) + tracing::debug!("πŸŒ‰ [Hyperlane] Checkpoint #{} not yet signed for validator {:#x}", nonce, validator,); } Err(e) => { - tracing::error!("πŸŒ‰ [Hyperlane] Failed to fetch checkpoint for validator {:#x}: {:?}", validator, e) + tracing::error!( + "πŸŒ‰ [Hyperlane] Failed to fetch checkpoint #{} for validator {:#x}: {:?}", + nonce, + validator, + e + ); } } + Ok(()) } - async fn handle_checkpoint(&self, validator: Felt, checkpoint: SignedCheckpointWithMessageId) { - let message_id = checkpoint.value.message_id; + async fn handle_checkpoint( + &self, + validator: Felt, + checkpoint: SignedCheckpointWithMessageId, + ) -> anyhow::Result<()> { + let nonce = checkpoint.value.checkpoint.index; - if self.state.storage.validators_checkpoints().exists(validator, message_id).await { + if self.storage.signed_checkpoints().exists(validator, nonce).await { tracing::debug!( - "πŸŒ‰ [Hyperlane] Skipping duplicate checkpoint for validator {:#x}: {:#x}", + "πŸŒ‰ [Hyperlane] Skipping already signed #{} checkpoint for validator {:#x}", + nonce, + validator + ); + return Ok(()); + } + + tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} retrieved signed checkpoint #{}", validator, nonce); + + if let Err(e) = self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await { + tracing::error!( + "πŸŒ‰ [Hyperlane] Failed to store signed checkpoint #{} for validator {:#x}: {:?}", + nonce, validator, - message_id + e ); - return; } + Ok(()) + } - tracing::info!( - "πŸŒ‰ [Hyperlane] Validator {:#x} retrieved latest checkpoint for message [#{}] {:#x}", - validator, - checkpoint.value.checkpoint.index, - message_id - ); - if let Err(e) = self.state.storage.validators_checkpoints().add(validator, message_id, checkpoint).await { - tracing::error!("πŸŒ‰ [Hyperlane] Failed to store checkpoint for validator {:#x}: {:?}", validator, e); + async fn store_event_updates(&self, nonce: u32) -> anyhow::Result<()> { + let event = match self.storage.unsigned_checkpoints().get(nonce).await { + Some(e) => e, + None => panic!("Should not happen!"), + }; + for update in event.message.body.updates.iter() { + let feed_id = update.feed_id(); + let feed_id = hex_str_to_u256(&feed_id)?; + let dispatch_update_infos = DispatchUpdateInfos::new(&event, update); + self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos).await?; } + Ok(()) } } diff --git a/rust/theoros/src/services/indexer/mod.rs b/rust/theoros/src/services/indexer/mod.rs index 4f8f0064..963794bf 100644 --- a/rust/theoros/src/services/indexer/mod.rs +++ b/rust/theoros/src/services/indexer/mod.rs @@ -14,14 +14,13 @@ use pragma_utils::{ services::Service, }; -use crate::{ - storage::DispatchUpdateInfos, - types::hyperlane::{CheckpointMatchEvent, DispatchEvent, FromStarknetEventData, ValidatorAnnouncementEvent}, - AppState, -}; +use crate::types::hyperlane::{DispatchEvent, FromStarknetEventData, ValidatorAnnouncementEvent}; +use crate::types::state::AppState; const INDEXING_STREAM_CHUNK_SIZE: usize = 1; +const START_INDEXER_DELTA: u64 = 5; + lazy_static::lazy_static! { // Pragma Dispatcher pub static ref DISPATCH_EVENT_SELECTOR: FieldElement = felt_as_apibara_field(&get_selector_from_name("Dispatch").unwrap()); @@ -37,7 +36,6 @@ pub struct IndexerService { state: AppState, uri: Uri, stream_config: Configuration, - reached_pending_block: bool, } #[async_trait::async_trait] @@ -60,10 +58,10 @@ impl IndexerService { hyperlane_mailbox_address: Felt, hyperlane_validator_announce_address: Felt, pragma_feeds_registry_address: Felt, - starting_block: u64, + current_block: u64, ) -> Result { let stream_config = Configuration::::default() - .with_starting_block(starting_block) + .with_starting_block(current_block - START_INDEXER_DELTA) .with_filter(|mut filter| { filter .with_header(HeaderFilter::weak()) @@ -86,7 +84,7 @@ impl IndexerService { }) .with_finality(DataFinality::DataStatusPending); - let indexer_service = Self { state, uri: apibara_uri, stream_config, reached_pending_block: false }; + let indexer_service = Self { state, uri: apibara_uri, stream_config }; Ok(indexer_service) } @@ -108,15 +106,6 @@ impl IndexerService { match stream.try_next().await { Ok(Some(response)) => { self.process_batch(response).await?; - // This should be done in Hyperlane service? Currently poisoning the thread. - self.state - .storage - .cached_events() - .process_cached_events( - self.state.storage.validators_checkpoints(), - self.state.storage.dispatch_events(), - ) - .await?; } Ok(None) => continue, Err(e) => bail!("Error while streaming indexed batch: {}", e), @@ -127,11 +116,7 @@ impl IndexerService { /// Process a batch of blocks indexed by Apibara DNA async fn process_batch(&mut self, batch: DataMessage) -> Result<()> { match batch { - DataMessage::Data { cursor: _, end_cursor: _, finality, batch } => { - if matches!(finality, DataFinality::DataStatusPending) && !self.reached_pending_block { - tracing::info!("[πŸ” Indexer] πŸ₯³πŸŽ‰ Reached pending block!"); - self.reached_pending_block = true; - } + DataMessage::Data { cursor: _, end_cursor: _, finality: _, batch } => { for block in batch { for event in block.clone().events.into_iter().filter_map(|e| e.event) { if event.from_address.is_none() { @@ -174,46 +159,21 @@ impl IndexerService { /// Decodes a DispatchEvent from the Starknet event data. async fn decode_dispatch_event(&self, event_data: Vec, block: &Block) -> anyhow::Result<()> { - // TODO: If we index from a toooooo far block, just ignore? - // What's the point of fetching storing etc for old events? Since they get - // overriten anyway? (we only store the latest update for a given feed) - let dispatch_event = DispatchEvent::from_starknet_event_data(event_data).context("Failed to parse Dispatch")?; - let message_id = dispatch_event.id(); + let dispatch_event = DispatchEvent::from_starknet_event_data(event_data).context("Parsing DispatchEvent")?; let nonce = dispatch_event.message.header.nonce; - match &block.header { Some(h) => { tracing::info!( - "πŸ“¨ [Indexer] Received a Dispatch event at block #{}, (#{}) message_id={:#x}", + "πŸ“¨ [Indexer] Received a Dispatch event at block #{} with nonce #{}", h.block_number, nonce, - message_id ); } None => { - tracing::info!("πŸ“¨ [Indexer] Received a Dispatch event, (#{}) message_id={:#x}", nonce, message_id); + tracing::info!("πŸ“¨ [Indexer] Received a Dispatch event, with nonce #{}", nonce); } }; - - for update in dispatch_event.message.body.updates.iter() { - let feed_id = update.feed_id(); - // Check if there's a corresponding signed checkpoints among validators - if self.state.storage.validators_checkpoints().contains_message_id(message_id).await { - tracing::debug!("Found corresponding checkpoint for message ID: {:?}", message_id); - let dispatch_update_infos = DispatchUpdateInfos::new(message_id, &dispatch_event, update); - self.state.storage.dispatch_events().add(feed_id, dispatch_update_infos).await?; - let _ = self - .state - .storage - .feeds_channel - .send(CheckpointMatchEvent::New { block_number: block.clone().header.unwrap().block_number }); - // If not, store the event and check later in `process_cached_events` - } else { - tracing::debug!("No checkpoint found, caching dispatch event"); - // If no checkpoint found, add to cache - self.state.storage.cached_events().add(message_id, &dispatch_event).await; - } - } + self.state.storage.unsigned_checkpoints().add(nonce, &dispatch_event).await; Ok(()) } @@ -222,7 +182,7 @@ impl IndexerService { tracing::info!("πŸ“¨ [Indexer] Received a ValidatorAnnouncement event"); let validator_announcement_event = ValidatorAnnouncementEvent::from_starknet_event_data(event_data) .context("Failed to parse ValidatorAnnouncement")?; - let validators = &mut self.state.storage.validators_locations(); + let validators = &mut self.state.storage.validators_fetchers(); validators.add_from_announcement_event(validator_announcement_event).await?; Ok(()) } diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs new file mode 100644 index 00000000..e3ff39a1 --- /dev/null +++ b/rust/theoros/src/storage/checkpoints.rs @@ -0,0 +1,79 @@ +use std::collections::HashMap; +use std::sync::Arc; + +use starknet::core::types::Felt; +use tokio::sync::RwLock; + +use crate::types::hyperlane::{DispatchEvent, SignedCheckpointWithMessageId}; + +/// Contains a Mapping between messages nonce and their corresponding Event. +#[derive(Clone, Default)] +pub struct UnsignedCheckpointsStorage { + cache: Arc>>, +} + +impl UnsignedCheckpointsStorage { + pub async fn add(&self, nonce: u32, event: &DispatchEvent) { + let mut cache = self.cache.write().await; + cache.insert(nonce, event.clone()); + } + + pub async fn get(&self, nonce: u32) -> Option { + let cache = self.cache.read().await; + cache.get(&nonce).cloned() + } + + pub async fn remove(&self, nonce: u32) { + let mut cache = self.cache.write().await; + cache.remove(&nonce); + } + + pub async fn nonces(&self) -> Vec { + let cache = self.cache.read().await; + cache.keys().cloned().collect() + } +} + +/// Contains a mapping between the validators and their latest fetched checkpoint. +#[derive(Debug, Default)] +pub struct SignedCheckpointsStorage(pub RwLock>); + +impl SignedCheckpointsStorage { + /// Adds or updates the [SignedCheckpointWithMessageId] for the given validator + pub async fn add( + &self, + validator: Felt, + nonce: u32, + checkpoint: SignedCheckpointWithMessageId, + ) -> anyhow::Result<()> { + let mut all_checkpoints = self.0.write().await; + all_checkpoints.insert((validator, nonce), checkpoint); + Ok(()) + } + + // Check if the given validator has a checkpoint for the given nonce. + pub async fn exists(&self, validator: Felt, nonce: u32) -> bool { + self.0.read().await.contains_key(&(validator, nonce)) + } + + // For the provided list of validators, returns all their signed checkpoints for the + // provided message_id. + pub async fn get( + &self, + validators: &[Felt], + searched_nonce: u32, + ) -> anyhow::Result> { + let lock = self.0.read().await; + + let mut checkpoints = Vec::new(); + // Iterate over the map with tuple key (validator, message_id) + for ((validator, nonce), checkpoint) in lock.iter() { + // Only include if validator is in the provided list and message_id matches + if nonce == &searched_nonce && validators.contains(validator) { + checkpoints.push(checkpoint.clone()); + } + } + + Ok(checkpoints) + } +} diff --git a/rust/theoros/src/storage/event.rs b/rust/theoros/src/storage/event.rs deleted file mode 100644 index 10224f6f..00000000 --- a/rust/theoros/src/storage/event.rs +++ /dev/null @@ -1,96 +0,0 @@ -use std::collections::HashMap; -use std::sync::Arc; - -use alloy::primitives::U256; -use anyhow::Result; -use pragma_utils::conversions::alloy::hex_str_to_u256; -use tokio::sync::RwLock; - -use crate::types::hyperlane::DispatchUpdate; -use crate::{storage::ValidatorsCheckpointsStorage, types::hyperlane::DispatchEvent}; - -#[derive(Debug, Clone)] -pub struct DispatchUpdateInfos { - pub update: DispatchUpdate, - pub emitter_chain_id: u32, - pub emitter_address: String, - pub nonce: u32, - pub message_id: U256, -} - -impl DispatchUpdateInfos { - pub fn new(message_id: U256, event: &DispatchEvent, update: &DispatchUpdate) -> Self { - DispatchUpdateInfos { - update: update.clone(), - emitter_address: event.message.header.sender.to_string(), - emitter_chain_id: event.message.header.origin, - nonce: event.message.header.nonce, - message_id, - } - } -} - -/// Contains a mapping between a feed_id and the latest dispatch update. -#[derive(Debug, Default)] -pub struct EventStorage { - events: RwLock>, -} - -impl EventStorage { - /// Insert the latest dispatch update for a feed_id. - pub async fn add(&self, feed_id: String, event: DispatchUpdateInfos) -> Result<()> { - let mut events = self.events.write().await; - let feed_id = hex_str_to_u256(&feed_id)?; - events.insert(feed_id, event); - Ok(()) - } - - /// Retrieves the latest dispatch update for a feed_id; - pub async fn get(&self, feed_id: &str) -> Result> { - let events = self.events.read().await; - let feed_id = hex_str_to_u256(feed_id)?; - Ok(events.get(&feed_id).cloned()) - } -} - -/// Contains a Mapping between message ids and the corresponding Event. -#[derive(Clone, Default)] -pub struct EventCache { - cache: Arc>>, -} - -impl EventCache { - /// Insert a new mapping between a message_id & an Event. - pub async fn add(&self, message_id: U256, event: &DispatchEvent) { - let mut cache = self.cache.write().await; - cache.insert(message_id, event.clone()); - } - - /// TODO, explain + re-assert the existence of this. - /// Should probably be used in the context of the Hyperlane service: - /// * each validators try to query the signatures for the cached events - /// * store signature for each successful queries - /// * if at least one signature is retrieved, remove from the cache - /// (hyperlane service query the latest events only, they should) - pub async fn process_cached_events( - &self, - checkpoint_storage: &ValidatorsCheckpointsStorage, - event_storage: &EventStorage, - ) -> Result<()> { - let mut cache_write = self.cache.write().await; - - for (message_id, dispatch_event) in cache_write.clone().into_iter() { - if checkpoint_storage.contains_message_id(message_id).await { - for update in dispatch_event.message.body.updates.iter() { - let feed_id = update.feed_id(); - let dispatch_update_infos = DispatchUpdateInfos::new(message_id, &dispatch_event, update); - event_storage.add(feed_id, dispatch_update_infos).await?; - // TODO: Emit the websocket notification - } - cache_write.remove(&message_id); - tracing::debug!("Processed cached event with message ID: {:x}", message_id); - } - } - Ok(()) - } -} diff --git a/rust/theoros/src/storage/mod.rs b/rust/theoros/src/storage/mod.rs index 0e5b5bc2..96e14b63 100644 --- a/rust/theoros/src/storage/mod.rs +++ b/rust/theoros/src/storage/mod.rs @@ -1,33 +1,29 @@ -pub mod event; +pub mod checkpoints; pub mod feed_id; +pub mod updates; pub mod validator; -pub use event::*; +pub use checkpoints::*; pub use feed_id::*; -use tokio::sync::broadcast::Sender; +pub use updates::*; pub use validator::*; use starknet::core::types::Felt; +use tokio::sync::broadcast::Sender; use crate::{ rpc::starknet::{HyperlaneCalls, PragmaFeedsRegistryCalls, StarknetRpc}, - types::hyperlane::CheckpointMatchEvent, + types::hyperlane::CheckpointSignedEvent, }; -/// Theoros storage that contains: -/// * a set of all available feed ids, -/// * a mapping of all the validators and their fetchers, -/// * a mapping of all the validators and their latest fetched checkpoints for a given message_id, -/// * an event cache, used to store events that have not been signed yet, -/// * an events storage containing the most recent [`DispatchUpdateInfos`] per feed_id, -/// * (websocket) a channel to dispatch updates to the clients. pub struct TheorosStorage { feed_ids: FeedIdsStorage, - validators: ValidatorsLocationStorage, - checkpoints: ValidatorsCheckpointsStorage, - cached_events: EventCache, - dispatch_events: EventStorage, - pub feeds_channel: Sender, + validators_fetchers: ValidatorsFetchersStorage, + signed_checkpoints: SignedCheckpointsStorage, + unsigned_checkpoints: UnsignedCheckpointsStorage, + latest_update_per_feed: LatestUpdatePerFeedStorage, + // websocket notifications + feeds_updated_tx: Sender, } impl TheorosStorage { @@ -41,21 +37,19 @@ impl TheorosStorage { .get_announced_storage_locations(hyperlane_validator_announce_address, &initial_validators) .await?; - let mut validators = ValidatorsLocationStorage::default(); - validators.fill_with_initial_state(initial_validators, initial_locations).await?; + let mut validators_fetchers = ValidatorsFetchersStorage::default(); + validators_fetchers.fill_with_initial_state(initial_validators, initial_locations).await?; let supported_feed_ids = rpc_client.get_feed_ids(pragma_feeds_registry_address).await?; let feed_ids = FeedIdsStorage::from_rpc_response(supported_feed_ids); - let (update_tx, _) = tokio::sync::broadcast::channel(1000); - Ok(Self { feed_ids, - validators, - checkpoints: ValidatorsCheckpointsStorage::default(), - cached_events: EventCache::default(), - dispatch_events: EventStorage::default(), - feeds_channel: update_tx, + validators_fetchers, + signed_checkpoints: SignedCheckpointsStorage::default(), + unsigned_checkpoints: UnsignedCheckpointsStorage::default(), + latest_update_per_feed: LatestUpdatePerFeedStorage::default(), + feeds_updated_tx: tokio::sync::broadcast::channel(1024).0, }) } @@ -63,19 +57,23 @@ impl TheorosStorage { &self.feed_ids } - pub fn validators_locations(&self) -> &ValidatorsLocationStorage { - &self.validators + pub fn validators_fetchers(&self) -> &ValidatorsFetchersStorage { + &self.validators_fetchers + } + + pub fn signed_checkpoints(&self) -> &SignedCheckpointsStorage { + &self.signed_checkpoints } - pub fn validators_checkpoints(&self) -> &ValidatorsCheckpointsStorage { - &self.checkpoints + pub fn latest_update_per_feed(&self) -> &LatestUpdatePerFeedStorage { + &self.latest_update_per_feed } - pub fn dispatch_events(&self) -> &EventStorage { - &self.dispatch_events + pub fn unsigned_checkpoints(&self) -> &UnsignedCheckpointsStorage { + &self.unsigned_checkpoints } - pub fn cached_events(&self) -> &EventCache { - &self.cached_events + pub fn feeds_updated_tx(&self) -> &Sender { + &self.feeds_updated_tx } } diff --git a/rust/theoros/src/storage/updates.rs b/rust/theoros/src/storage/updates.rs new file mode 100644 index 00000000..5f749904 --- /dev/null +++ b/rust/theoros/src/storage/updates.rs @@ -0,0 +1,28 @@ +use std::collections::HashMap; + +use alloy::primitives::U256; +use anyhow::Result; +use tokio::sync::RwLock; + +use crate::types::hyperlane::DispatchUpdateInfos; + +/// Contains a mapping between feed ids and their latest dispatch update. +#[derive(Debug, Default)] +pub struct LatestUpdatePerFeedStorage { + events: RwLock>, +} + +impl LatestUpdatePerFeedStorage { + /// Insert the latest dispatch update for a feed_id. + pub async fn add(&self, feed_id: U256, event: DispatchUpdateInfos) -> Result<()> { + let mut events = self.events.write().await; + events.insert(feed_id, event); + Ok(()) + } + + /// Retrieves the latest dispatch update for a feed_id; + pub async fn get(&self, feed_id: &U256) -> Result> { + let events = self.events.read().await; + Ok(events.get(feed_id).cloned()) + } +} diff --git a/rust/theoros/src/storage/validator.rs b/rust/theoros/src/storage/validator.rs index a3541e09..2abb879a 100644 --- a/rust/theoros/src/storage/validator.rs +++ b/rust/theoros/src/storage/validator.rs @@ -1,25 +1,18 @@ use std::str::FromStr; use std::{collections::HashMap, sync::Arc}; -use alloy::primitives::U256; use anyhow::bail; use starknet::core::types::Felt; use tokio::sync::RwLock; -use crate::types::hyperlane::{ - CheckpointStorage, FetchFromStorage, SignedCheckpointWithMessageId, ValidatorAnnouncementEvent, -}; - -// TODO: Rename this. It should be clear that it is a Validator => StorageLocation mapping. -// TODO: The ValidatorsLocationStorage should contain the builded Location, not the CheckpointStorage. -// Currently, we are building it everytime in the Hyperlane service using: checkpoint.build() +use crate::types::hyperlane::{CheckpointStorage, FetchFromStorage, ValidatorAnnouncementEvent}; /// Contains a mapping between the validators and their storages used to /// retrieve checkpoints. #[derive(Debug, Default)] -pub struct ValidatorsLocationStorage(RwLock>>>); +pub struct ValidatorsFetchersStorage(RwLock>>>); -impl ValidatorsLocationStorage { +impl ValidatorsFetchersStorage { /// Fills the [HashMap] with the initial state fetched from the RPC. pub async fn fill_with_initial_state( &mut self, @@ -69,59 +62,3 @@ impl ValidatorsLocationStorage { self.0.read().await.clone() } } - -/// Contains a mapping between the validators and their latest fetched checkpoint. -#[derive(Debug, Default)] -pub struct ValidatorsCheckpointsStorage(pub RwLock>); - -impl ValidatorsCheckpointsStorage { - /// Adds or updates the [SignedCheckpointWithMessageId] for the given validator - pub async fn add( - &self, - validator: Felt, - message_id: U256, - checkpoint: SignedCheckpointWithMessageId, - ) -> anyhow::Result<()> { - let mut all_checkpoints = self.0.write().await; - all_checkpoints.insert((validator, message_id), checkpoint); - Ok(()) - } - - // Check if any of the validators has a checkpoint signed for the provided message id. - pub async fn contains_message_id(&self, message_id: U256) -> bool { - let all_checkpoints = self.0.read().await; - - for checkpoint in all_checkpoints.values() { - if checkpoint.value.message_id == message_id { - return true; - } - } - false - } - - // Check if the given validator has a checkpoint for the given message_id. - pub async fn exists(&self, validator: Felt, message_id: U256) -> bool { - self.0.read().await.contains_key(&(validator, message_id)) - } - - // For the provided list of validators, returns all their signed checkpoints for the - // provided message_id. - pub async fn get_validators_signed_checkpoints( - &self, - validators: &[Felt], - searched_message_id: U256, - ) -> anyhow::Result> { - let checkpoints = self.0.read().await; - - let mut signatures = Vec::new(); - // Iterate over the map with tuple key (validator, message_id) - for ((validator, message_id), checkpoint) in checkpoints.iter() { - // Only include if validator is in the provided list and message_id matches - if message_id == &searched_message_id && validators.contains(validator) { - signatures.push(checkpoint.clone()); - } - } - - Ok(signatures) - } -} diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index a14cccd2..8c205fb5 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -1,6 +1,7 @@ // TODO: // Create tests for this module. It should produces the same than abi.encodePack use alloy::{primitives::U256, signers::Signature}; +use pragma_utils::conversions::alloy::hex_str_to_u256; use serde::{Deserialize, Serialize}; use starknet::core::types::Felt; use std::str::FromStr; @@ -9,13 +10,10 @@ use crate::{ configs::evm_config::EvmChainName, constants::{HYPERLANE_VERSION, PRAGMA_MAJOR_VERSION, PRAGMA_MINOR_VERSION, TRAILING_HEADER_SIZE}, errors::GetCalldataError, - storage::DispatchUpdateInfos, - types::hyperlane::CheckpointWithMessageId, + types::hyperlane::{CheckpointWithMessageId, DispatchUpdate, DispatchUpdateInfos}, types::state::AppState, }; -use super::hyperlane::DispatchUpdate; - pub trait AsCalldata { fn as_bytes(&self) -> Vec; } @@ -40,10 +38,10 @@ impl Calldata { chain_name: EvmChainName, feed_id: String, ) -> Result { - let event: DispatchUpdateInfos = state + let update_info: DispatchUpdateInfos = state .storage - .dispatch_events() - .get(&feed_id) + .latest_update_per_feed() + .get(&hex_str_to_u256(&feed_id).unwrap()) .await .map_err(|_| GetCalldataError::DispatchNotFound)? .ok_or(GetCalldataError::DispatchNotFound)?; @@ -55,15 +53,15 @@ impl Calldata { let checkpoints = state .storage - .validators_checkpoints() - .get_validators_signed_checkpoints(validators, event.message_id) + .signed_checkpoints() + .get(validators, update_info.nonce) .await .map_err(|_| GetCalldataError::ValidatorNotFound)?; // TODO: We only have one validator for now let checkpoint_infos = checkpoints.last().unwrap(); - let update = match event.update { + let update = match update_info.update { DispatchUpdate::SpotMedian { update, feed_id: _ } => update, }; @@ -74,7 +72,6 @@ impl Calldata { proof_len: 0, proof: vec![], update_data: update.to_bytes(), - // TODO: Store directly a U256. feed_id: U256::from_str(&feed_id).unwrap(), publish_time: update.metadata.timestamp, }; @@ -84,11 +81,10 @@ impl Calldata { // TODO: signers_len & signatures should work for multiple validators signers_len: 1_u8, signatures: vec![ValidatorSignature { validator_index: 0, signature: checkpoint_infos.signature }], - nonce: event.nonce, + nonce: update_info.nonce, timestamp: update.metadata.timestamp, - emitter_chain_id: event.emitter_chain_id, - // TODO: Store directly a Felt. - emitter_address: Felt::from_dec_str(&event.emitter_address).unwrap(), + emitter_chain_id: update_info.emitter_chain_id, + emitter_address: update_info.emitter_address, payload, }; diff --git a/rust/theoros/src/types/hyperlane/checkpoint.rs b/rust/theoros/src/types/hyperlane/checkpoint.rs index 5f09bf94..d8d819ae 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint.rs @@ -31,15 +31,6 @@ pub struct CheckpointWithMessageId { /// An event that is emitted when we find a match between a checkpoint and a message #[derive(Clone, PartialEq, Debug)] -pub enum CheckpointMatchEvent { - New { block_number: u64 }, -} - -impl CheckpointMatchEvent { - /// Returns the block number of the event - pub fn block_number(&self) -> u64 { - match self { - CheckpointMatchEvent::New { block_number } => *block_number, - } - } +pub enum CheckpointSignedEvent { + New, } diff --git a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/gcs.rs b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/gcs.rs index d019074e..5c247674 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/gcs.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/gcs.rs @@ -68,14 +68,6 @@ impl FetchFromStorage for GcsStorageClient { Ok(Some(serde_json::from_slice(res.as_ref())?)) } - async fn fetch_latest(&self) -> Result> { - let res = self.inner.get_object(&self.bucket, GcsStorageClient::get_latest_checkpoint_key()).await?; - let latest_index = serde_json::from_slice(&res)?; - - let res = self.inner.get_object(&self.bucket, GcsStorageClient::get_checkpoint_key(latest_index)).await?; - Ok(Some(serde_json::from_slice(res.as_ref())?)) - } - fn announcement_location(&self) -> String { format!("gs://{}/{}", &self.bucket, ANNOUNCEMENT_KEY) } diff --git a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/local.rs b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/local.rs index aea23bcd..dd182b29 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/local.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/local.rs @@ -26,10 +26,6 @@ impl LocalStorage { fn checkpoint_file_path(&self, index: u32) -> PathBuf { self.path.join(format!("{}_with_id.json", index)) } - - fn latest_checkpoint_file_path(&self) -> PathBuf { - self.path.join("index.json") - } } #[async_trait] @@ -42,15 +38,6 @@ impl FetchFromStorage for LocalStorage { Ok(Some(checkpoint)) } - async fn fetch_latest(&self) -> Result> { - let latest_index = serde_json::from_slice(&tokio::fs::read(self.latest_checkpoint_file_path()).await?)?; - let Ok(data) = tokio::fs::read(self.checkpoint_file_path(latest_index)).await else { - return Ok(None); - }; - let checkpoint = serde_json::from_slice(&data)?; - Ok(Some(checkpoint)) - } - fn announcement_location(&self) -> String { format!("file://{}", self.path.to_str().unwrap()) } diff --git a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs index 44c372f2..db4898cb 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs @@ -28,8 +28,6 @@ pub trait FetchFromStorage: Debug + Send + Sync { /// Attempt to fetch the signed (checkpoint, messageId) tuple at this index #[allow(unused)] async fn fetch(&self, index: u32) -> Result>; - /// Attemps to fetch the latest (checkpoint, messageId) tuple - async fn fetch_latest(&self) -> Result>; /// Return the announcement storage location for this syncer #[allow(unused)] fn announcement_location(&self) -> String; diff --git a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/s3.rs b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/s3.rs index 3a982611..9096f069 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/s3.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/s3.rs @@ -98,10 +98,6 @@ impl S3Storage { fn checkpoint_key(index: u32) -> String { format!("checkpoint_{index}_with_id.json") } - - fn latest_checkpoint_key() -> String { - "checkpoint_latest_index.json".to_string() - } } #[async_trait] @@ -114,21 +110,6 @@ impl FetchFromStorage for S3Storage { .map_err(Into::into) } - async fn fetch_latest(&self) -> Result> { - let latest_index: u32 = self - .anonymously_read_from_bucket(S3Storage::latest_checkpoint_key()) - .await? - .map(|data| serde_json::from_slice(&data)) - .transpose() - .unwrap() - .unwrap(); - self.anonymously_read_from_bucket(S3Storage::checkpoint_key(latest_index)) - .await? - .map(|data| serde_json::from_slice(&data)) - .transpose() - .map_err(Into::into) - } - fn announcement_location(&self) -> String { match self.folder.as_deref() { None | Some("") => format!("s3://{}/{}", self.bucket, self.region.name()), diff --git a/rust/theoros/src/types/hyperlane/events/dispatch_event.rs b/rust/theoros/src/types/hyperlane/events/dispatch_event.rs index e7e72365..529fb259 100644 --- a/rust/theoros/src/types/hyperlane/events/dispatch_event.rs +++ b/rust/theoros/src/types/hyperlane/events/dispatch_event.rs @@ -1,8 +1,6 @@ -use alloy::primitives::keccak256; -use alloy::primitives::{hex, U256 as alloy_U256}; +use alloy::primitives::hex; use anyhow::{Context, Result}; use pragma_feeds::FeedType; -use pragma_utils::conversions::alloy::hex_str_to_u256; use starknet::core::types::{Felt, U256}; use pragma_utils::conversions::apibara::FromFieldBytes; @@ -77,50 +75,6 @@ impl FromStarknetEventData for DispatchEvent { } } -impl DispatchEvent { - /// Generates a message id from a Dispatch Event. - pub fn id(&self) -> alloy_U256 { - let mut input = Vec::new(); - - // Formatting header part - input.push(self.message.header.version); - input.extend_from_slice(&self.message.header.nonce.to_be_bytes()); - input.extend_from_slice(&self.message.header.origin.to_be_bytes()); - input.extend_from_slice(&self.message.header.sender.high().to_be_bytes()); - input.extend_from_slice(&self.message.header.sender.low().to_be_bytes()); - input.extend_from_slice(&self.message.header.destination.to_be_bytes()); - input.extend_from_slice(&self.message.header.recipient.high().to_be_bytes()); - input.extend_from_slice(&self.message.header.recipient.low().to_be_bytes()); - - // Formatting body part - input.extend_from_slice(&self.message.body.nb_updated.to_be_bytes()); - - for update in &self.message.body.updates { - match update { - DispatchUpdate::SpotMedian { feed_id, update: spot_update } => { - let feed_id = hex_str_to_u256(feed_id).unwrap(); - input.extend_from_slice(&feed_id.to_be_bytes_vec()); - // Append metadata, i.e timestamp, nb sources & decimals - input.extend_from_slice(&spot_update.metadata.timestamp.to_be_bytes()); - input.extend_from_slice(&spot_update.metadata.num_sources_aggregated.to_be_bytes()); - input.extend_from_slice(&spot_update.metadata.decimals.to_be_bytes()); - // Append scaled price and volume - input.extend_from_slice(&spot_update.price.high().to_be_bytes()); - input.extend_from_slice(&spot_update.price.low().to_be_bytes()); - input.extend_from_slice(&spot_update.volume.high().to_be_bytes()); - input.extend_from_slice(&spot_update.volume.low().to_be_bytes()); - } - } - } - - let hash = keccak256(&input); - let message_id = - alloy_U256::from_be_bytes(<[u8; 32]>::try_from(hash.as_slice()).expect("Hash should be 32 bytes")); - - message_id - } -} - #[derive(Debug, Clone)] pub struct DispatchMessage { pub header: DispatchMessageHeader, @@ -129,11 +83,14 @@ pub struct DispatchMessage { #[derive(Debug, Clone)] pub struct DispatchMessageHeader { + #[allow(unused)] pub version: u8, pub nonce: u32, pub origin: u32, pub sender: U256, + #[allow(unused)] pub destination: u32, + #[allow(unused)] pub recipient: U256, } @@ -159,6 +116,7 @@ impl FromStarknetEventData for DispatchMessageHeader { #[derive(Debug, Clone)] pub struct DispatchMessageBody { + #[allow(unused)] pub nb_updated: u8, pub updates: Vec, } @@ -202,6 +160,25 @@ impl FromStarknetEventData for DispatchMessageBody { } } +#[derive(Debug, Clone)] +pub struct DispatchUpdateInfos { + pub nonce: u32, + pub emitter_chain_id: u32, + pub emitter_address: Felt, + pub update: DispatchUpdate, +} + +impl DispatchUpdateInfos { + pub fn new(event: &DispatchEvent, update: &DispatchUpdate) -> Self { + DispatchUpdateInfos { + nonce: event.message.header.nonce, + emitter_chain_id: event.message.header.origin, + emitter_address: Felt::from_dec_str(&event.message.header.sender.to_string()).unwrap(), + update: update.clone(), + } + } +} + // TODO: Should be a trait? #[derive(Debug, Clone)] pub enum DispatchUpdate { From 527a497da4ecce79a28449f65ade5ee5ead2546e Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 00:39:41 +0100 Subject: [PATCH 03/55] dev(better_theoros): --- rust/theoros/src/errors/calldata_error.rs | 2 ++ .../theoros/src/handlers/rest/get_calldata.rs | 4 ++- rust/theoros/src/services/hyperlane/mod.rs | 4 +-- rust/theoros/src/services/indexer/mod.rs | 12 +++---- rust/theoros/src/storage/checkpoints.rs | 12 +++---- rust/theoros/src/storage/updates.rs | 4 +-- rust/theoros/src/storage/validator.rs | 4 +-- rust/theoros/src/types/calldata.rs | 31 +++++-------------- 8 files changed, 29 insertions(+), 44 deletions(-) diff --git a/rust/theoros/src/errors/calldata_error.rs b/rust/theoros/src/errors/calldata_error.rs index 6c26557c..47dfef5f 100644 --- a/rust/theoros/src/errors/calldata_error.rs +++ b/rust/theoros/src/errors/calldata_error.rs @@ -23,6 +23,8 @@ pub enum GetCalldataError { ValidatorNotFound, #[error("The chain '{0}' is not supported")] ChainNotSupported(String), + #[error("Error while building the calldata: {0}")] + CalldataError(String), } impl IntoResponse for GetCalldataError { diff --git a/rust/theoros/src/handlers/rest/get_calldata.rs b/rust/theoros/src/handlers/rest/get_calldata.rs index ef3b049a..61927856 100644 --- a/rust/theoros/src/handlers/rest/get_calldata.rs +++ b/rust/theoros/src/handlers/rest/get_calldata.rs @@ -55,7 +55,9 @@ pub async fn get_calldata( return Err(GetCalldataError::FeedNotFound(feed_id)); }; - let calldata = Calldata::build_from(&state, chain_name, feed_id).await?; + let calldata = Calldata::build_from(&state, chain_name, feed_id) + .await + .map_err(|e| GetCalldataError::CalldataError(e.to_string()))?; let response = GetCalldataResponse { calldata: calldata.clone(), encoded_calldata: hex::encode(calldata.as_bytes()) }; diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 5a7f0333..645c974d 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -104,7 +104,7 @@ impl HyperlaneService { return Ok(()); } - tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} retrieved signed checkpoint #{}", validator, nonce); + tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed the checkpoint with nonce #{}", validator, nonce); if let Err(e) = self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await { tracing::error!( @@ -120,7 +120,7 @@ impl HyperlaneService { async fn store_event_updates(&self, nonce: u32) -> anyhow::Result<()> { let event = match self.storage.unsigned_checkpoints().get(nonce).await { Some(e) => e, - None => panic!("Should not happen!"), + None => unreachable!(), }; for update in event.message.body.updates.iter() { let feed_id = update.feed_id(); diff --git a/rust/theoros/src/services/indexer/mod.rs b/rust/theoros/src/services/indexer/mod.rs index 963794bf..9e986c52 100644 --- a/rust/theoros/src/services/indexer/mod.rs +++ b/rust/theoros/src/services/indexer/mod.rs @@ -127,7 +127,7 @@ impl IndexerService { } } DataMessage::Invalidate { cursor } => match cursor { - Some(c) => bail!("Received an invalidate request data at {}", &c.order_key), + Some(c) => bail!("Indexed an invalidate request data at {}", &c.order_key), None => bail!("Invalidate request without cursor provided"), }, DataMessage::Heartbeat => {} @@ -164,13 +164,13 @@ impl IndexerService { match &block.header { Some(h) => { tracing::info!( - "πŸ“¨ [Indexer] Received a Dispatch event at block #{} with nonce #{}", + "πŸ“¨ [Indexer] [Block {}] Indexed a Dispatch event with nonce #{}", h.block_number, nonce, ); } None => { - tracing::info!("πŸ“¨ [Indexer] Received a Dispatch event, with nonce #{}", nonce); + tracing::info!("πŸ“¨ [Indexer] Indexed a Dispatch event with nonce #{}", nonce); } }; self.state.storage.unsigned_checkpoints().add(nonce, &dispatch_event).await; @@ -179,7 +179,7 @@ impl IndexerService { /// Decodes a ValidatorAnnouncementEvent from the Starknet event data. async fn decode_validator_announce_event(&self, event_data: Vec) -> anyhow::Result<()> { - tracing::info!("πŸ“¨ [Indexer] Received a ValidatorAnnouncement event"); + tracing::info!("πŸ“¨ [Indexer] Indexed a ValidatorAnnouncement event"); let validator_announcement_event = ValidatorAnnouncementEvent::from_starknet_event_data(event_data) .context("Failed to parse ValidatorAnnouncement")?; let validators = &mut self.state.storage.validators_fetchers(); @@ -190,7 +190,7 @@ impl IndexerService { /// Decodes a NewFeedId event from the Starknet event data. async fn decode_new_feed_id_event(&self, event_data: Vec) -> anyhow::Result<()> { let feed_id = event_data[1].to_hex_string(); - tracing::info!("πŸ“¨ [Indexer] Received a NewFeedId event for: {}", feed_id); + tracing::info!("πŸ“¨ [Indexer] Indexed a NewFeedId event for: {}", feed_id); self.state.storage.feed_ids().add(feed_id).await; Ok(()) } @@ -198,7 +198,7 @@ impl IndexerService { /// Decodes a RemovedFeedId event from the Starknet event data. async fn decode_removed_feed_id_event(&self, event_data: Vec) -> anyhow::Result<()> { let feed_id = event_data[1].to_hex_string(); - tracing::info!("πŸ“¨ [Indexer] Received a RemovedFeedId event for: {}", feed_id); + tracing::info!("πŸ“¨ [Indexer] Indexed a RemovedFeedId event for: {}", feed_id); self.state.storage.feed_ids().remove(&feed_id).await; Ok(()) } diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index e3ff39a1..568cb6d9 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -6,7 +6,7 @@ use tokio::sync::RwLock; use crate::types::hyperlane::{DispatchEvent, SignedCheckpointWithMessageId}; -/// Contains a Mapping between messages nonce and their corresponding Event. +/// Mapping between messages nonces and their corresponding Event. #[derive(Clone, Default)] pub struct UnsignedCheckpointsStorage { cache: Arc>>, @@ -34,7 +34,7 @@ impl UnsignedCheckpointsStorage { } } -/// Contains a mapping between the validators and their latest fetched checkpoint. +/// Mapping between the validators and their signed checkpoint for a given nonce. #[derive(Debug, Default)] pub struct SignedCheckpointsStorage(pub RwLock>); @@ -58,11 +58,7 @@ impl SignedCheckpointsStorage { // For the provided list of validators, returns all their signed checkpoints for the // provided message_id. - pub async fn get( - &self, - validators: &[Felt], - searched_nonce: u32, - ) -> anyhow::Result> { + pub async fn get(&self, validators: &[Felt], searched_nonce: u32) -> Vec { let lock = self.0.read().await; let mut checkpoints = Vec::new(); @@ -74,6 +70,6 @@ impl SignedCheckpointsStorage { } } - Ok(checkpoints) + checkpoints } } diff --git a/rust/theoros/src/storage/updates.rs b/rust/theoros/src/storage/updates.rs index 5f749904..4dba8c25 100644 --- a/rust/theoros/src/storage/updates.rs +++ b/rust/theoros/src/storage/updates.rs @@ -13,14 +13,14 @@ pub struct LatestUpdatePerFeedStorage { } impl LatestUpdatePerFeedStorage { - /// Insert the latest dispatch update for a feed_id. + /// Insert the latest [`DispatchUpdateInfos`] for a feed id. pub async fn add(&self, feed_id: U256, event: DispatchUpdateInfos) -> Result<()> { let mut events = self.events.write().await; events.insert(feed_id, event); Ok(()) } - /// Retrieves the latest dispatch update for a feed_id; + /// Retrieves the latest [`DispatchUpdateInfos`] for a feed id. pub async fn get(&self, feed_id: &U256) -> Result> { let events = self.events.read().await; Ok(events.get(feed_id).cloned()) diff --git a/rust/theoros/src/storage/validator.rs b/rust/theoros/src/storage/validator.rs index 2abb879a..16caf959 100644 --- a/rust/theoros/src/storage/validator.rs +++ b/rust/theoros/src/storage/validator.rs @@ -7,8 +7,8 @@ use tokio::sync::RwLock; use crate::types::hyperlane::{CheckpointStorage, FetchFromStorage, ValidatorAnnouncementEvent}; -/// Contains a mapping between the validators and their storages used to -/// retrieve checkpoints. +/// Mapping between the validators and their fetcher used to +/// retrieve signed checkpoints. #[derive(Debug, Default)] pub struct ValidatorsFetchersStorage(RwLock>>>); diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index 8c205fb5..0011a6ff 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -1,6 +1,5 @@ -// TODO: -// Create tests for this module. It should produces the same than abi.encodePack use alloy::{primitives::U256, signers::Signature}; +use anyhow::Context; use pragma_utils::conversions::alloy::hex_str_to_u256; use serde::{Deserialize, Serialize}; use starknet::core::types::Felt; @@ -9,7 +8,6 @@ use std::str::FromStr; use crate::{ configs::evm_config::EvmChainName, constants::{HYPERLANE_VERSION, PRAGMA_MAJOR_VERSION, PRAGMA_MINOR_VERSION, TRAILING_HEADER_SIZE}, - errors::GetCalldataError, types::hyperlane::{CheckpointWithMessageId, DispatchUpdate, DispatchUpdateInfos}, types::state::AppState, }; @@ -33,32 +31,20 @@ pub struct Calldata { } impl Calldata { - pub async fn build_from( - state: &AppState, - chain_name: EvmChainName, - feed_id: String, - ) -> Result { + // TODO: Only works for ONE validator for now. + pub async fn build_from(state: &AppState, chain_name: EvmChainName, feed_id: String) -> anyhow::Result { let update_info: DispatchUpdateInfos = state .storage .latest_update_per_feed() .get(&hex_str_to_u256(&feed_id).unwrap()) - .await - .map_err(|_| GetCalldataError::DispatchNotFound)? - .ok_or(GetCalldataError::DispatchNotFound)?; + .await? + .context("No update found")?; - let validators = state - .hyperlane_validators_mapping - .get_validators(chain_name) - .ok_or(GetCalldataError::ChainNotSupported(format!("{:?}", chain_name)))?; + let validators = + state.hyperlane_validators_mapping.get_validators(chain_name).context("No validators found")?; - let checkpoints = state - .storage - .signed_checkpoints() - .get(validators, update_info.nonce) - .await - .map_err(|_| GetCalldataError::ValidatorNotFound)?; + let checkpoints = state.storage.signed_checkpoints().get(validators, update_info.nonce).await; - // TODO: We only have one validator for now let checkpoint_infos = checkpoints.last().unwrap(); let update = match update_info.update { @@ -78,7 +64,6 @@ impl Calldata { let hyperlane_message = HyperlaneMessage { hyperlane_version: HYPERLANE_VERSION, - // TODO: signers_len & signatures should work for multiple validators signers_len: 1_u8, signatures: vec![ValidatorSignature { validator_index: 0, signature: checkpoint_infos.signature }], nonce: update_info.nonce, From 58e0d43e59dbde750e1de0f34a67563d58a14994 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 01:15:33 +0100 Subject: [PATCH 04/55] dev(better_theoros): --- .../websocket/subscribe_to_calldata.rs | 6 +- rust/theoros/src/services/hyperlane/mod.rs | 76 ++++++++++++------- rust/theoros/src/storage/checkpoints.rs | 16 ++-- rust/theoros/src/storage/mod.rs | 6 +- .../theoros/src/types/hyperlane/checkpoint.rs | 2 +- 5 files changed, 67 insertions(+), 39 deletions(-) diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index f21a12f8..ca751087 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -22,7 +22,7 @@ use tokio::sync::broadcast::Receiver; use crate::constants::{DEFAULT_ACTIVE_CHAIN, MAX_CLIENT_MESSAGE_SIZE, PING_INTERVAL_DURATION}; use crate::types::calldata::AsCalldata; -use crate::types::{hyperlane::CheckpointSignedEvent, rpc::RpcDataFeed}; +use crate::types::{hyperlane::NewUpdatesAvailableEvent, rpc::RpcDataFeed}; use crate::AppState; use crate::{configs::evm_config::EvmChainName, types::calldata::Calldata}; @@ -89,7 +89,7 @@ pub struct Subscriber { id: SubscriberId, closed: bool, state: Arc, - feeds_receiver: Receiver, + feeds_receiver: Receiver, receiver: SplitStream, sender: SplitSink, data_feeds_with_config: HashMap, @@ -102,7 +102,7 @@ impl Subscriber { pub fn new( id: SubscriberId, state: Arc, - feeds_receiver: Receiver, + feeds_receiver: Receiver, receiver: SplitStream, sender: SplitSink, ) -> Self { diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 645c974d..1bdca526 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -7,7 +7,7 @@ use pragma_utils::{conversions::alloy::hex_str_to_u256, services::Service}; use crate::storage::TheorosStorage; use crate::types::hyperlane::{ - CheckpointSignedEvent, DispatchUpdateInfos, FetchFromStorage, SignedCheckpointWithMessageId, + DispatchUpdateInfos, FetchFromStorage, NewUpdatesAvailableEvent, SignedCheckpointWithMessageId, }; const FETCH_INTERVAL: Duration = Duration::from_secs(1); @@ -48,33 +48,61 @@ impl HyperlaneService { let validators_fetchers = self.storage.validators_fetchers().all().await; let unsigned_nonces = self.storage.unsigned_checkpoints().nonces().await; - let mut futures = Vec::new(); + if unsigned_nonces.is_empty() { + return; + } + + for &nonce in &unsigned_nonces { + let mut any_signed = false; + let mut futures = Vec::new(); - for (validator, fetcher) in validators_fetchers.into_iter() { - for &nonce in &unsigned_nonces { - let fut = self.process_single_validator_nonce(validator, fetcher.clone(), nonce); + for (validator, fetcher) in &validators_fetchers { + let fut = self.try_fetch_signed_checkpoint(*validator, fetcher.clone(), nonce); futures.push(fut); } - } - futures::future::join_all(futures).await; + let results = futures::future::join_all(futures).await; + + // Check if any validator has signed this nonce + for signed in results.into_iter().flatten() { + if signed { + any_signed = true; + } + } + + if any_signed { + if let Err(e) = self.store_event_updates(nonce).await { + tracing::error!("Failed to store event updates for nonce {}: {:?}", nonce, e); + } + self.storage.unsigned_checkpoints().remove(nonce).await; + } else { + // If none of the validators have signed this nonce, + // we can skip processing higher nonces for now + break; + } + } } - async fn process_single_validator_nonce( + /// Checks if a nonce has been signed by the validator by querying its fetcher. + /// Returns true if signed, else false. + async fn try_fetch_signed_checkpoint( &self, validator: Felt, fetcher: Arc>, nonce: u32, - ) -> anyhow::Result<()> { + ) -> anyhow::Result { + if self.storage.signed_checkpoints().exists(validator, nonce).await { + return Ok(true); + } + match fetcher.fetch(nonce).await { Ok(Some(checkpoint)) => { - self.handle_checkpoint(validator, checkpoint).await?; - self.store_event_updates(nonce).await?; - self.storage.unsigned_checkpoints().remove(nonce).await; - self.storage.feeds_updated_tx().send(CheckpointSignedEvent::New)?; + self.store_signed_checkpoint(validator, checkpoint).await?; + Ok(true) } Ok(None) => { tracing::debug!("πŸŒ‰ [Hyperlane] Checkpoint #{} not yet signed for validator {:#x}", nonce, validator,); + Ok(false) } Err(e) => { tracing::error!( @@ -83,12 +111,12 @@ impl HyperlaneService { validator, e ); + Ok(false) } } - Ok(()) } - async fn handle_checkpoint( + async fn store_signed_checkpoint( &self, validator: Felt, checkpoint: SignedCheckpointWithMessageId, @@ -97,7 +125,7 @@ impl HyperlaneService { if self.storage.signed_checkpoints().exists(validator, nonce).await { tracing::debug!( - "πŸŒ‰ [Hyperlane] Skipping already signed #{} checkpoint for validator {:#x}", + "πŸŒ‰ [Hyperlane] Skipping already signed checkpoint #{} for validator {:#x}", nonce, validator ); @@ -105,22 +133,17 @@ impl HyperlaneService { } tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed the checkpoint with nonce #{}", validator, nonce); - - if let Err(e) = self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await { - tracing::error!( - "πŸŒ‰ [Hyperlane] Failed to store signed checkpoint #{} for validator {:#x}: {:?}", - nonce, - validator, - e - ); - } + self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await?; Ok(()) } async fn store_event_updates(&self, nonce: u32) -> anyhow::Result<()> { let event = match self.storage.unsigned_checkpoints().get(nonce).await { Some(e) => e, - None => unreachable!(), + None => { + tracing::error!("Event not found for nonce {}", nonce); + return Ok(()); + } }; for update in event.message.body.updates.iter() { let feed_id = update.feed_id(); @@ -128,6 +151,7 @@ impl HyperlaneService { let dispatch_update_infos = DispatchUpdateInfos::new(&event, update); self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos).await?; } + let _ = self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New); Ok(()) } } diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index 568cb6d9..8bd442b0 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; use starknet::core::types::Felt; @@ -9,28 +9,32 @@ use crate::types::hyperlane::{DispatchEvent, SignedCheckpointWithMessageId}; /// Mapping between messages nonces and their corresponding Event. #[derive(Clone, Default)] pub struct UnsignedCheckpointsStorage { - cache: Arc>>, + cache: Arc>>, } impl UnsignedCheckpointsStorage { + /// Insert a new mapping between a nonce & an Event. pub async fn add(&self, nonce: u32, event: &DispatchEvent) { let mut cache = self.cache.write().await; cache.insert(nonce, event.clone()); } - pub async fn get(&self, nonce: u32) -> Option { + /// Retrieve all nonces currently stored, in sorted order. + pub async fn nonces(&self) -> Vec { let cache = self.cache.read().await; - cache.get(&nonce).cloned() + cache.keys().cloned().collect() } + /// Remove a nonce from the storage. pub async fn remove(&self, nonce: u32) { let mut cache = self.cache.write().await; cache.remove(&nonce); } - pub async fn nonces(&self) -> Vec { + /// Get the event associated with a nonce. + pub async fn get(&self, nonce: u32) -> Option { let cache = self.cache.read().await; - cache.keys().cloned().collect() + cache.get(&nonce).cloned() } } diff --git a/rust/theoros/src/storage/mod.rs b/rust/theoros/src/storage/mod.rs index 96e14b63..7200f09a 100644 --- a/rust/theoros/src/storage/mod.rs +++ b/rust/theoros/src/storage/mod.rs @@ -13,7 +13,7 @@ use tokio::sync::broadcast::Sender; use crate::{ rpc::starknet::{HyperlaneCalls, PragmaFeedsRegistryCalls, StarknetRpc}, - types::hyperlane::CheckpointSignedEvent, + types::hyperlane::NewUpdatesAvailableEvent, }; pub struct TheorosStorage { @@ -23,7 +23,7 @@ pub struct TheorosStorage { unsigned_checkpoints: UnsignedCheckpointsStorage, latest_update_per_feed: LatestUpdatePerFeedStorage, // websocket notifications - feeds_updated_tx: Sender, + feeds_updated_tx: Sender, } impl TheorosStorage { @@ -73,7 +73,7 @@ impl TheorosStorage { &self.unsigned_checkpoints } - pub fn feeds_updated_tx(&self) -> &Sender { + pub fn feeds_updated_tx(&self) -> &Sender { &self.feeds_updated_tx } } diff --git a/rust/theoros/src/types/hyperlane/checkpoint.rs b/rust/theoros/src/types/hyperlane/checkpoint.rs index d8d819ae..98c7e215 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint.rs @@ -31,6 +31,6 @@ pub struct CheckpointWithMessageId { /// An event that is emitted when we find a match between a checkpoint and a message #[derive(Clone, PartialEq, Debug)] -pub enum CheckpointSignedEvent { +pub enum NewUpdatesAvailableEvent { New, } From 3a7f411d0675c685c09a75626aeea2e0a0b14a29 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 11:53:36 +0100 Subject: [PATCH 05/55] dev(better_theoros): Hyperlane service --- rust/theoros/src/services/hyperlane/mod.rs | 80 +++++++++++----------- rust/theoros/src/storage/checkpoints.rs | 16 +++-- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 1bdca526..ad96e1a1 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -1,3 +1,4 @@ +use std::collections::HashMap; use std::{sync::Arc, time::Duration}; use starknet::core::types::Felt; @@ -10,6 +11,7 @@ use crate::types::hyperlane::{ DispatchUpdateInfos, FetchFromStorage, NewUpdatesAvailableEvent, SignedCheckpointWithMessageId, }; +/// Every [FETCH_INTERVAL] seconds, we check the pending checkpoints for all validators. const FETCH_INTERVAL: Duration = Duration::from_secs(1); #[derive(Clone)] @@ -52,88 +54,80 @@ impl HyperlaneService { return; } + let mut futures = Vec::new(); for &nonce in &unsigned_nonces { - let mut any_signed = false; - let mut futures = Vec::new(); - for (validator, fetcher) in &validators_fetchers { - let fut = self.try_fetch_signed_checkpoint(*validator, fetcher.clone(), nonce); + let fut = self.process_single_validator_nonce(*validator, fetcher.clone(), nonce); futures.push(fut); } + } + futures::future::join_all(futures).await; - let results = futures::future::join_all(futures).await; - - // Check if any validator has signed this nonce - for signed in results.into_iter().flatten() { - if signed { - any_signed = true; - } - } - - if any_signed { + for &nonce in &unsigned_nonces { + if self.all_validators_signed_nonce(&validators_fetchers, nonce).await { if let Err(e) = self.store_event_updates(nonce).await { - tracing::error!("Failed to store event updates for nonce {}: {:?}", nonce, e); + tracing::error!("😱 Failed to store event updates for nonce {}: {:?}", nonce, e); } self.storage.unsigned_checkpoints().remove(nonce).await; - } else { - // If none of the validators have signed this nonce, - // we can skip processing higher nonces for now - break; } } } - /// Checks if a nonce has been signed by the validator by querying its fetcher. - /// Returns true if signed, else false. - async fn try_fetch_signed_checkpoint( + /// Checks if all validators have signed a given nonce. + async fn all_validators_signed_nonce( + &self, + validators_fetchers: &HashMap>>, + nonce: u32, + ) -> bool { + let validators: Vec = validators_fetchers.keys().cloned().collect(); + self.storage.signed_checkpoints().all_validators_signed_nonce(&validators, nonce).await + } + + async fn process_single_validator_nonce( &self, validator: Felt, fetcher: Arc>, nonce: u32, - ) -> anyhow::Result { - if self.storage.signed_checkpoints().exists(validator, nonce).await { - return Ok(true); + ) -> anyhow::Result<()> { + // If the validator already signed this nonce, ignore + if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce).await { + return Ok(()); } match fetcher.fetch(nonce).await { Ok(Some(checkpoint)) => { - self.store_signed_checkpoint(validator, checkpoint).await?; - Ok(true) + self.handle_checkpoint(validator, checkpoint).await?; } Ok(None) => { - tracing::debug!("πŸŒ‰ [Hyperlane] Checkpoint #{} not yet signed for validator {:#x}", nonce, validator,); - Ok(false) + tracing::debug!("πŸŒ‰ [Hyperlane] Validator {:#x} has not yet signed nonce {}", validator, nonce); } Err(e) => { tracing::error!( - "πŸŒ‰ [Hyperlane] Failed to fetch checkpoint #{} for validator {:#x}: {:?}", - nonce, + "πŸŒ‰ [Hyperlane] Failed to fetch checkpoint for validator {:#x} and nonce {}: {:?}", validator, + nonce, e ); - Ok(false) } } + Ok(()) } - async fn store_signed_checkpoint( + async fn handle_checkpoint( &self, validator: Felt, checkpoint: SignedCheckpointWithMessageId, ) -> anyhow::Result<()> { let nonce = checkpoint.value.checkpoint.index; - if self.storage.signed_checkpoints().exists(validator, nonce).await { - tracing::debug!( - "πŸŒ‰ [Hyperlane] Skipping already signed checkpoint #{} for validator {:#x}", - nonce, - validator - ); + if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce).await { + tracing::debug!("πŸŒ‰ [Hyperlane] Skipping duplicate checkpoint for validator {:#x}: #{}", validator, nonce); return Ok(()); } - tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed the checkpoint with nonce #{}", validator, nonce); + tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed checkpoint #{}", validator, nonce); self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await?; + Ok(()) } @@ -151,7 +145,11 @@ impl HyperlaneService { let dispatch_update_infos = DispatchUpdateInfos::new(&event, update); self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos).await?; } - let _ = self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New); + + // Send websocket notification + if let Err(e) = self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New) { + tracing::error!("Failed to send feeds updated notification: {:?}", e); + } Ok(()) } } diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index 8bd442b0..68660c1a 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -55,11 +55,6 @@ impl SignedCheckpointsStorage { Ok(()) } - // Check if the given validator has a checkpoint for the given nonce. - pub async fn exists(&self, validator: Felt, nonce: u32) -> bool { - self.0.read().await.contains_key(&(validator, nonce)) - } - // For the provided list of validators, returns all their signed checkpoints for the // provided message_id. pub async fn get(&self, validators: &[Felt], searched_nonce: u32) -> Vec { @@ -76,4 +71,15 @@ impl SignedCheckpointsStorage { checkpoints } + + // Check if the given validator has a checkpoint for the given nonce. + pub async fn validator_signed_nonce(&self, validator: Felt, nonce: u32) -> bool { + self.0.read().await.contains_key(&(validator, nonce)) + } + + /// Checks if all validators have signed a nonce. + pub async fn all_validators_signed_nonce(&self, validators: &[Felt], nonce: u32) -> bool { + let inner = self.0.read().await; + validators.iter().all(|validator| inner.contains_key(&(*validator, nonce))) + } } From f3f702578fc378536c56b66a498885983f6bdf5e Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 11:59:31 +0100 Subject: [PATCH 06/55] dev(better_theoros): --- rust/theoros/src/services/hyperlane/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index ad96e1a1..6ae36d25 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -148,7 +148,7 @@ impl HyperlaneService { // Send websocket notification if let Err(e) = self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New) { - tracing::error!("Failed to send feeds updated notification: {:?}", e); + tracing::error!("😨 Failed to send websocket notification: {:?}", e); } Ok(()) } From 0282a02b49996112809b7f50544bf5b4fb54d299 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 12:05:54 +0100 Subject: [PATCH 07/55] dev(better_theoros): --- rust/theoros/src/services/hyperlane/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 6ae36d25..8922abae 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -63,6 +63,8 @@ impl HyperlaneService { } futures::future::join_all(futures).await; + // TODO: At the moment, we only process updates when ALL validators have signed a message. + // We should instead use a quorum method - if 66% have signed, consider it ok. for &nonce in &unsigned_nonces { if self.all_validators_signed_nonce(&validators_fetchers, nonce).await { if let Err(e) = self.store_event_updates(nonce).await { @@ -147,9 +149,16 @@ impl HyperlaneService { } // Send websocket notification - if let Err(e) = self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New) { - tracing::error!("😨 Failed to send websocket notification: {:?}", e); + match self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New) { + Ok(_) => { + tracing::debug!("πŸ•ΈοΈ [Websocket] πŸ”” Successfully sent websocket notification"); + } + Err(e) => { + // Only log as debug since this is expected when there are no subscribers + tracing::debug!("πŸ•ΈοΈ [Websocket] πŸ“ͺ No active websocket subscribers to receive notification: {}", e); + } } + Ok(()) } } From 7a6542dd965c7c92c939df10fde0273a7d458a5a Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 12:16:06 +0100 Subject: [PATCH 08/55] dev(better_theoros): --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b1b6d0b7..7f96b7e4 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,16 @@ Solidity contracts & libraries. ## Typescript -(TODO: akhercha) +Theoros SDK + +A SDK used to query data from Theoros in a simple way. + +- Fetch the latest calldata using either REST or Websocket endpoints. + +Pragma Deployer + +The main scripts used to deploy all our contracts (Cairo, Solidity, ...) are located there. + +Pragma Scripts + +Utils scripts that we use to make some actions on-chain. From 4f877fbca7c3bc6795e59982318714ae572bcf8d Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 12:23:12 +0100 Subject: [PATCH 09/55] dev(better_theoros): comms --- rust/theoros/src/services/hyperlane/mod.rs | 42 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 8922abae..3dfdfae1 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -46,14 +46,42 @@ impl HyperlaneService { } } + /// Processes validator checkpoints by fetching signed checkpoints from all validators for each unsigned nonce. + /// + /// This function performs the following steps: + /// + /// 1. **Retrieve Unsigned Nonces**: Fetches all the nonces currently stored in the `UnsignedCheckpointsStorage`. + /// - If there are no unsigned nonces, the function returns early. + /// + /// 2. **Retrieve Validators and Fetchers**: Gets all registered validators and their corresponding fetchers from the `ValidatorsFetchersStorage`. + /// + /// 3. **Fetch Signed Checkpoints**: + /// - Iterates over each unsigned nonce. + /// - For each nonce, it iterates over all validators. + /// - Attempts to fetch the signed checkpoint for the given nonce from each validator's fetcher. + /// - These fetch attempts are spawned as asynchronous tasks and collected into a `futures` vector. + /// - Waits for all fetch tasks to complete using `futures::future::join_all(futures).await`. + /// + /// 4. **Process Completed Nonces**: + /// - After all fetches are completed, iterates over the unsigned nonces again. + /// - Checks if all validators have signed the nonce using the `all_validators_signed_nonce` method. + /// - **Note**: Currently, the function only proceeds if **all** validators have signed the nonce. + /// - There's a `TODO` to modify this behavior to use a quorum method (e.g., consider a nonce as valid if 66% of validators have signed it). + /// - If all validators have signed the nonce: + /// - Calls `store_event_updates(nonce)` to process and store the updates associated with that nonce. + /// - Removes the nonce from the `UnsignedCheckpointsStorage`, as it has been fully processed. + /// + /// **Behavior Summary**: + /// - The function ensures that for every unsigned nonce, it collects signed checkpoints from all validators. + /// - Only when a nonce has been signed by all validators does it proceed to process the associated updates. + /// - This mechanism ensures data consistency and integrity by waiting for consensus among validators. async fn process_validator_checkpoints(&self) { - let validators_fetchers = self.storage.validators_fetchers().all().await; let unsigned_nonces = self.storage.unsigned_checkpoints().nonces().await; - if unsigned_nonces.is_empty() { return; } + let validators_fetchers = self.storage.validators_fetchers().all().await; let mut futures = Vec::new(); for &nonce in &unsigned_nonces { for (validator, fetcher) in &validators_fetchers { @@ -63,8 +91,8 @@ impl HyperlaneService { } futures::future::join_all(futures).await; - // TODO: At the moment, we only process updates when ALL validators have signed a message. - // We should instead use a quorum method - if 66% have signed, consider it ok. + // NOTE: At the moment, we only process updates when ALL validators have signed a message. + // TODO: We should instead use a quorum method - if 66% have signed, consider it ok. for &nonce in &unsigned_nonces { if self.all_validators_signed_nonce(&validators_fetchers, nonce).await { if let Err(e) = self.store_event_updates(nonce).await { @@ -98,7 +126,7 @@ impl HyperlaneService { match fetcher.fetch(nonce).await { Ok(Some(checkpoint)) => { - self.handle_checkpoint(validator, checkpoint).await?; + self.store_signed_checkpoint(validator, checkpoint).await?; } Ok(None) => { tracing::debug!("πŸŒ‰ [Hyperlane] Validator {:#x} has not yet signed nonce {}", validator, nonce); @@ -115,7 +143,8 @@ impl HyperlaneService { Ok(()) } - async fn handle_checkpoint( + /// Store the signed checkpoint for the validator ; nonce couple. + async fn store_signed_checkpoint( &self, validator: Felt, checkpoint: SignedCheckpointWithMessageId, @@ -133,6 +162,7 @@ impl HyperlaneService { Ok(()) } + /// Stores the event updates once it has been signed. async fn store_event_updates(&self, nonce: u32) -> anyhow::Result<()> { let event = match self.storage.unsigned_checkpoints().get(nonce).await { Some(e) => e, From ed2d9e88d76df3563e2e26be2fce48879aaa83cd Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 12:24:58 +0100 Subject: [PATCH 10/55] dev(better_theoros): better --- rust/theoros/src/services/hyperlane/mod.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 3dfdfae1..8a5afe93 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -56,8 +56,6 @@ impl HyperlaneService { /// 2. **Retrieve Validators and Fetchers**: Gets all registered validators and their corresponding fetchers from the `ValidatorsFetchersStorage`. /// /// 3. **Fetch Signed Checkpoints**: - /// - Iterates over each unsigned nonce. - /// - For each nonce, it iterates over all validators. /// - Attempts to fetch the signed checkpoint for the given nonce from each validator's fetcher. /// - These fetch attempts are spawned as asynchronous tasks and collected into a `futures` vector. /// - Waits for all fetch tasks to complete using `futures::future::join_all(futures).await`. @@ -71,10 +69,6 @@ impl HyperlaneService { /// - Calls `store_event_updates(nonce)` to process and store the updates associated with that nonce. /// - Removes the nonce from the `UnsignedCheckpointsStorage`, as it has been fully processed. /// - /// **Behavior Summary**: - /// - The function ensures that for every unsigned nonce, it collects signed checkpoints from all validators. - /// - Only when a nonce has been signed by all validators does it proceed to process the associated updates. - /// - This mechanism ensures data consistency and integrity by waiting for consensus among validators. async fn process_validator_checkpoints(&self) { let unsigned_nonces = self.storage.unsigned_checkpoints().nonces().await; if unsigned_nonces.is_empty() { From 85d0ad290034c47c5754bee78c507996b6463228 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 12:31:17 +0100 Subject: [PATCH 11/55] dev(better_theoros): logs --- rust/theoros/src/services/hyperlane/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 8a5afe93..cdd571d7 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -89,6 +89,10 @@ impl HyperlaneService { // TODO: We should instead use a quorum method - if 66% have signed, consider it ok. for &nonce in &unsigned_nonces { if self.all_validators_signed_nonce(&validators_fetchers, nonce).await { + tracing::info!( + "πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", + nonce + ); if let Err(e) = self.store_event_updates(nonce).await { tracing::error!("😱 Failed to store event updates for nonce {}: {:?}", nonce, e); } From ea11ed26c9557a08b91a4800e1411cc96b10e90f Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 12:48:19 +0100 Subject: [PATCH 12/55] dev(better_theoros): added todo --- rust/theoros/src/services/hyperlane/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index cdd571d7..4468715d 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -88,6 +88,7 @@ impl HyperlaneService { // NOTE: At the moment, we only process updates when ALL validators have signed a message. // TODO: We should instead use a quorum method - if 66% have signed, consider it ok. for &nonce in &unsigned_nonces { + // TODO: If the nonce n+1 is fully signed, shall we ignore every nonces before..? Or raise an alert? if self.all_validators_signed_nonce(&validators_fetchers, nonce).await { tracing::info!( "πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", From f2a18e64bcfccb4ec4ca93ede70acfc7471e2b0a Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 13:22:09 +0100 Subject: [PATCH 13/55] dev(better_theoros): --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f96b7e4..c392be13 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Pragma V2 -[![GitHub Actions][gha-badge]][gha] [![codecov](https://codecov.io/gh/astraly-labs/pragma-monorepo/branch/main/graph/badge.svg?)](https://codecov.io/gh/astraly-labs/pragma-monorepo) [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license] +[![GitHub Actions][gha-badge]][gha] [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license] [gha]: https://github.com/astraly-labs/pragma-monorepo/actions [gha-badge]: https://github.com/PaulRBerg/prb-math/actions/workflows/ci.yml/badge.svg [codecov-badge]: https://img.shields.io/codecov/c/github/astraly-labs/pragma-monorepo [foundry]: https://getfoundry.sh/ [foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg -[license]: https://www.apache.org/licenses/LICENSE-2.0 -[license-badge]: https://img.shields.io/badge/License-Apache-blue.svg +[license]: https://opensource.org/license/mit +[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg ## Rust From bd3453b4e36e211d6746090333ca01ad16672774 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 13:28:12 +0100 Subject: [PATCH 14/55] dev(better_theoros): updated README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index c392be13..106f0a70 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,16 @@ Request the API to construct the calldata necessary for cross-chain updates. - Retrieves the signatures of the Hyperlane Validators - Constructs the calldata for data feeds requested through HTTP/WebSocket +## Cairo + +Pragma Oracle + +Core Contacts of the Pragma Oracle. + +Pragma Dispatcher + +Wrapper around the Pragma Oracle that allows us to dispatch feed updates through Hyperlane. + ## Solidity Solidity SDK From 149dd457a668f7345f138f72beadb57f67c34351 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 13:47:31 +0100 Subject: [PATCH 15/55] dev(better_theoros): Removed default active chain in websocket --- rust/theoros/src/constants.rs | 4 ---- .../handlers/websocket/subscribe_to_calldata.rs | 16 ++++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rust/theoros/src/constants.rs b/rust/theoros/src/constants.rs index 4e838ab8..ecf2f59d 100644 --- a/rust/theoros/src/constants.rs +++ b/rust/theoros/src/constants.rs @@ -1,7 +1,5 @@ use std::time::Duration; -use crate::configs::evm_config::EvmChainName; - pub const HYPERLANE_VERSION: u8 = 3; pub const PRAGMA_MAJOR_VERSION: u8 = 1; @@ -15,5 +13,3 @@ pub const MAX_CLIENT_MESSAGE_SIZE: usize = 100 * 1024; // 100 KiB /// The maximum number of bytes that can be sent per second per IP address. /// If the limit is exceeded, the connection is closed. pub const _BYTES_LIMIT_PER_IP_PER_SECOND: u32 = 256 * 1024; // 256 KiB - -pub const DEFAULT_ACTIVE_CHAIN: EvmChainName = EvmChainName::Mainnet; diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index ca751087..6a5e6557 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -20,7 +20,7 @@ use futures::{ use serde::{Deserialize, Serialize}; use tokio::sync::broadcast::Receiver; -use crate::constants::{DEFAULT_ACTIVE_CHAIN, MAX_CLIENT_MESSAGE_SIZE, PING_INTERVAL_DURATION}; +use crate::constants::{MAX_CLIENT_MESSAGE_SIZE, PING_INTERVAL_DURATION}; use crate::types::calldata::AsCalldata; use crate::types::{hyperlane::NewUpdatesAvailableEvent, rpc::RpcDataFeed}; use crate::AppState; @@ -93,7 +93,7 @@ pub struct Subscriber { receiver: SplitStream, sender: SplitSink, data_feeds_with_config: HashMap, - active_chain: EvmChainName, + active_chain: Option, ping_interval: tokio::time::Interval, responded_to_ping: bool, } @@ -114,7 +114,7 @@ impl Subscriber { receiver, sender, data_feeds_with_config: HashMap::new(), - active_chain: DEFAULT_ACTIVE_CHAIN, + active_chain: None, ping_interval: tokio::time::interval(PING_INTERVAL_DURATION), responded_to_ping: true, } @@ -163,13 +163,17 @@ impl Subscriber { } async fn handle_data_feeds_update(&mut self) -> Result<()> { + if self.active_chain.is_none() { + return Ok(()); + } tracing::debug!(subscriber = self.id, "Handling Data Feeds Update."); // Retrieve the updates for subscribed feed ids at the given slot let feed_ids = self.data_feeds_with_config.keys().cloned().collect::>(); + // TODO: add support for multiple feeds let feed_id = feed_ids.first().unwrap(); - - let calldata = Calldata::build_from(self.state.as_ref(), self.active_chain, feed_id.to_owned()).await?; + let calldata = + Calldata::build_from(self.state.as_ref(), self.active_chain.unwrap(), feed_id.to_owned()).await?; let message = serde_json::to_string(&ServerMessage::DataFeedUpdate { data_feed: RpcDataFeed { feed_id: feed_id.clone(), calldata: Some(hex::encode(calldata.as_bytes())) }, @@ -245,7 +249,7 @@ impl Subscriber { None => { for feed_id in feed_ids { self.data_feeds_with_config.insert(feed_id, DataFeedClientConfig {}); - self.active_chain = chain_name; + self.active_chain = Some(chain_name); } } } From 2adf0e4f9b1fa80bf5ac1576242e76856f2c62a3 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 13:56:33 +0100 Subject: [PATCH 16/55] dev(better_theoros): better comment --- rust/theoros/src/services/hyperlane/mod.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 4468715d..4198064c 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -37,8 +37,6 @@ impl HyperlaneService { Self { storage } } - /// Every [FETCH_INTERVAL] seconds, fetch the latest checkpoint signed for all - /// registered validators. pub async fn run_forever(&self) -> anyhow::Result<()> { loop { self.process_validator_checkpoints().await; @@ -50,15 +48,14 @@ impl HyperlaneService { /// /// This function performs the following steps: /// - /// 1. **Retrieve Unsigned Nonces**: Fetches all the nonces currently stored in the `UnsignedCheckpointsStorage`. - /// - If there are no unsigned nonces, the function returns early. + /// 1. **Retrieve Unsigned Nonces**: + /// - Fetches all the nonces currently stored in the `UnsignedCheckpointsStorage`. /// - /// 2. **Retrieve Validators and Fetchers**: Gets all registered validators and their corresponding fetchers from the `ValidatorsFetchersStorage`. + /// 2. **Retrieve Validators and Fetchers**: + /// - Gets all registered validators and their corresponding fetchers from the `ValidatorsFetchersStorage`. /// /// 3. **Fetch Signed Checkpoints**: - /// - Attempts to fetch the signed checkpoint for the given nonce from each validator's fetcher. - /// - These fetch attempts are spawned as asynchronous tasks and collected into a `futures` vector. - /// - Waits for all fetch tasks to complete using `futures::future::join_all(futures).await`. + /// - Attempts to fetch the signed checkpoint all unsigned nonce from each validator's fetcher (in parallel), /// /// 4. **Process Completed Nonces**: /// - After all fetches are completed, iterates over the unsigned nonces again. From ac4907d2c65853c422f2f58e1d570980edc7648f Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 14:00:50 +0100 Subject: [PATCH 17/55] =?UTF-8?q?dev(better=5Ftheoros):=20last=20nitpick?= =?UTF-8?q?=20=F0=9F=92=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/theoros/src/services/hyperlane/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 4198064c..154d1450 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -91,7 +91,7 @@ impl HyperlaneService { "πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", nonce ); - if let Err(e) = self.store_event_updates(nonce).await { + if let Err(e) = self.store_dispatch_updates(nonce).await { tracing::error!("😱 Failed to store event updates for nonce {}: {:?}", nonce, e); } self.storage.unsigned_checkpoints().remove(nonce).await; @@ -158,14 +158,11 @@ impl HyperlaneService { Ok(()) } - /// Stores the event updates once it has been signed. - async fn store_event_updates(&self, nonce: u32) -> anyhow::Result<()> { + /// Stores the updates once it has been signed. + async fn store_dispatch_updates(&self, nonce: u32) -> anyhow::Result<()> { let event = match self.storage.unsigned_checkpoints().get(nonce).await { Some(e) => e, - None => { - tracing::error!("Event not found for nonce {}", nonce); - return Ok(()); - } + None => unreachable!(), }; for update in event.message.body.updates.iter() { let feed_id = update.feed_id(); From 733e8dfd4a95badadc6bee792b52d906d6b49981 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 15:23:48 +0100 Subject: [PATCH 18/55] dev(better_theoros): Simpler struct --- rust/theoros/src/storage/updates.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rust/theoros/src/storage/updates.rs b/rust/theoros/src/storage/updates.rs index 4dba8c25..a9e35acc 100644 --- a/rust/theoros/src/storage/updates.rs +++ b/rust/theoros/src/storage/updates.rs @@ -8,21 +8,19 @@ use crate::types::hyperlane::DispatchUpdateInfos; /// Contains a mapping between feed ids and their latest dispatch update. #[derive(Debug, Default)] -pub struct LatestUpdatePerFeedStorage { - events: RwLock>, -} +pub struct LatestUpdatePerFeedStorage(RwLock>); impl LatestUpdatePerFeedStorage { /// Insert the latest [`DispatchUpdateInfos`] for a feed id. pub async fn add(&self, feed_id: U256, event: DispatchUpdateInfos) -> Result<()> { - let mut events = self.events.write().await; + let mut events = self.0.write().await; events.insert(feed_id, event); Ok(()) } /// Retrieves the latest [`DispatchUpdateInfos`] for a feed id. pub async fn get(&self, feed_id: &U256) -> Result> { - let events = self.events.read().await; + let events = self.0.read().await; Ok(events.get(feed_id).cloned()) } } From cb6bfa74c39eac45be284c66f60fd87ffa41f72c Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 15:34:12 +0100 Subject: [PATCH 19/55] dev(better_theoros): used same terminology between structs --- rust/theoros/src/storage/checkpoints.rs | 30 ++++++++++++------------- rust/theoros/src/storage/feed_id.rs | 24 ++++++++++---------- rust/theoros/src/storage/updates.rs | 8 +++---- rust/theoros/src/storage/validator.rs | 8 +++---- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index 68660c1a..b3b0bf91 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -8,39 +8,37 @@ use crate::types::hyperlane::{DispatchEvent, SignedCheckpointWithMessageId}; /// Mapping between messages nonces and their corresponding Event. #[derive(Clone, Default)] -pub struct UnsignedCheckpointsStorage { - cache: Arc>>, -} +pub struct UnsignedCheckpointsStorage(Arc>>); impl UnsignedCheckpointsStorage { /// Insert a new mapping between a nonce & an Event. pub async fn add(&self, nonce: u32, event: &DispatchEvent) { - let mut cache = self.cache.write().await; - cache.insert(nonce, event.clone()); + let mut lock = self.0.write().await; + lock.insert(nonce, event.clone()); } /// Retrieve all nonces currently stored, in sorted order. pub async fn nonces(&self) -> Vec { - let cache = self.cache.read().await; - cache.keys().cloned().collect() + let lock = self.0.read().await; + lock.keys().cloned().collect() } /// Remove a nonce from the storage. pub async fn remove(&self, nonce: u32) { - let mut cache = self.cache.write().await; - cache.remove(&nonce); + let mut lock = self.0.write().await; + lock.remove(&nonce); } /// Get the event associated with a nonce. pub async fn get(&self, nonce: u32) -> Option { - let cache = self.cache.read().await; - cache.get(&nonce).cloned() + let lock = self.0.read().await; + lock.get(&nonce).cloned() } } /// Mapping between the validators and their signed checkpoint for a given nonce. #[derive(Debug, Default)] -pub struct SignedCheckpointsStorage(pub RwLock>); +pub struct SignedCheckpointsStorage(RwLock>); impl SignedCheckpointsStorage { /// Adds or updates the [SignedCheckpointWithMessageId] for the given validator @@ -50,8 +48,8 @@ impl SignedCheckpointsStorage { nonce: u32, checkpoint: SignedCheckpointWithMessageId, ) -> anyhow::Result<()> { - let mut all_checkpoints = self.0.write().await; - all_checkpoints.insert((validator, nonce), checkpoint); + let mut lock = self.0.write().await; + lock.insert((validator, nonce), checkpoint); Ok(()) } @@ -79,7 +77,7 @@ impl SignedCheckpointsStorage { /// Checks if all validators have signed a nonce. pub async fn all_validators_signed_nonce(&self, validators: &[Felt], nonce: u32) -> bool { - let inner = self.0.read().await; - validators.iter().all(|validator| inner.contains_key(&(*validator, nonce))) + let lock = self.0.read().await; + validators.iter().all(|validator| lock.contains_key(&(*validator, nonce))) } } diff --git a/rust/theoros/src/storage/feed_id.rs b/rust/theoros/src/storage/feed_id.rs index 0a73e8cd..a1fe8733 100644 --- a/rust/theoros/src/storage/feed_id.rs +++ b/rust/theoros/src/storage/feed_id.rs @@ -12,37 +12,37 @@ impl FeedIdsStorage { } pub async fn add(&self, feed_id: String) { - let mut feed_ids = self.0.write().await; - feed_ids.insert(feed_id); + let mut lock = self.0.write().await; + lock.insert(feed_id); } pub async fn remove(&self, feed_id: &str) { - let mut feed_ids = self.0.write().await; - feed_ids.remove(feed_id); + let mut lock = self.0.write().await; + lock.remove(feed_id); } /// Checks if the storage contains the given feed ID. pub async fn contains(&self, feed_id: &str) -> bool { - let feed_ids = self.0.read().await; - feed_ids.contains(feed_id) + let lock = self.0.read().await; + lock.contains(feed_id) } /// Checks if all feed IDs in the given vector are present in the storage. /// Returns None if all IDs are present, or Some(id) with the first missing ID. pub async fn contains_vec(&self, feed_ids: &[String]) -> Option { - let stored_feed_ids = self.0.read().await; - feed_ids.iter().find(|id| !stored_feed_ids.contains(*id)).cloned() + let lock = self.0.read().await; + feed_ids.iter().find(|id| !lock.contains(*id)).cloned() } /// Returns the number of feed IDs in the storage. pub async fn len(&self) -> usize { - let feed_ids = self.0.read().await; - feed_ids.len() + let lock = self.0.read().await; + lock.len() } /// Returns an iterator over the feed IDs. pub async fn iter(&self) -> impl Iterator { - let feed_ids = self.0.read().await; - feed_ids.iter().cloned().collect::>().into_iter() + let lock = self.0.read().await; + lock.iter().cloned().collect::>().into_iter() } } diff --git a/rust/theoros/src/storage/updates.rs b/rust/theoros/src/storage/updates.rs index a9e35acc..b94226dd 100644 --- a/rust/theoros/src/storage/updates.rs +++ b/rust/theoros/src/storage/updates.rs @@ -13,14 +13,14 @@ pub struct LatestUpdatePerFeedStorage(RwLock> impl LatestUpdatePerFeedStorage { /// Insert the latest [`DispatchUpdateInfos`] for a feed id. pub async fn add(&self, feed_id: U256, event: DispatchUpdateInfos) -> Result<()> { - let mut events = self.0.write().await; - events.insert(feed_id, event); + let mut lock = self.0.write().await; + lock.insert(feed_id, event); Ok(()) } /// Retrieves the latest [`DispatchUpdateInfos`] for a feed id. pub async fn get(&self, feed_id: &U256) -> Result> { - let events = self.0.read().await; - Ok(events.get(feed_id).cloned()) + let lock = self.0.read().await; + Ok(lock.get(feed_id).cloned()) } } diff --git a/rust/theoros/src/storage/validator.rs b/rust/theoros/src/storage/validator.rs index 16caf959..3925f5bf 100644 --- a/rust/theoros/src/storage/validator.rs +++ b/rust/theoros/src/storage/validator.rs @@ -23,7 +23,7 @@ impl ValidatorsFetchersStorage { bail!("β›” Validators and locations vectors must have the same length"); } - let mut all_storages = self.0.write().await; + let mut lock = self.0.write().await; for (validator, location) in validators.into_iter().zip(locations.into_iter()) { // TODO: This should be a feature. We sometime want to have a local storage. if location[location.len() - 1].starts_with("file") { @@ -31,7 +31,7 @@ impl ValidatorsFetchersStorage { } let storage = CheckpointStorage::from_str(&location[location.len() - 1])?; let storage_fetcher = storage.build().await?; - all_storages.insert(validator, Arc::new(storage_fetcher)); + lock.insert(validator, Arc::new(storage_fetcher)); } Ok(()) @@ -40,8 +40,8 @@ impl ValidatorsFetchersStorage { /// Adds or updates the [CheckpointStorage] for the given validator pub async fn add(&self, validator: Felt, storage: CheckpointStorage) -> anyhow::Result<()> { let storage_fetcher = storage.build().await?; - let mut all_storages = self.0.write().await; - all_storages.insert(validator, Arc::new(storage_fetcher)); + let mut lock = self.0.write().await; + lock.insert(validator, Arc::new(storage_fetcher)); Ok(()) } From d9bfb571dd03ee97e44461c95433a53986dadc1f Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 1 Nov 2024 15:46:26 +0100 Subject: [PATCH 20/55] dev(better_theoros): Added TODO for calldata --- rust/theoros/src/types/calldata.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index 0011a6ff..fce70bec 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -31,7 +31,6 @@ pub struct Calldata { } impl Calldata { - // TODO: Only works for ONE validator for now. pub async fn build_from(state: &AppState, chain_name: EvmChainName, feed_id: String) -> anyhow::Result { let update_info: DispatchUpdateInfos = state .storage @@ -53,23 +52,29 @@ impl Calldata { let payload = Payload { checkpoint: checkpoint_infos.value.clone(), + // TODO: We only handle 1 update per calldata. See if possible to have more. + // TODO: If not remove this and consider it to be always one? num_updates: 1, - update_data_len: 1, + // TODO: Remove proof proof_len: 0, proof: vec![], + update_data_len: update.to_bytes().len() as u16, update_data: update.to_bytes(), feed_id: U256::from_str(&feed_id).unwrap(), + // TODO: publish_time is already available in the update metadata. Remove. publish_time: update.metadata.timestamp, }; let hyperlane_message = HyperlaneMessage { hyperlane_version: HYPERLANE_VERSION, + emitter_chain_id: update_info.emitter_chain_id, + emitter_address: update_info.emitter_address, + nonce: update_info.nonce, + // TODO: Adapt for N signers signers_len: 1_u8, signatures: vec![ValidatorSignature { validator_index: 0, signature: checkpoint_infos.signature }], - nonce: update_info.nonce, + // TODO: Means we store once again the timestamp? Delete this? timestamp: update.metadata.timestamp, - emitter_chain_id: update_info.emitter_chain_id, - emitter_address: update_info.emitter_address, payload, }; @@ -147,13 +152,14 @@ pub struct Payload { pub checkpoint: CheckpointWithMessageId, /// Number of updates pub num_updates: u8, - pub update_data_len: u16, /// Length of the proof #[serde(skip)] pub proof_len: u16, #[serde(skip)] pub proof: Vec, #[serde(skip)] + pub update_data_len: u16, + #[serde(skip)] pub update_data: Vec, /// The id associated to the feed to be updated pub feed_id: U256, From dc0d74e2339f524e8a4698b934d1ff930a95bb53 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 13:47:20 +0100 Subject: [PATCH 21/55] dev(better_theoros): smol perf update --- rust/theoros/src/services/hyperlane/mod.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 154d1450..66b42a42 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::{sync::Arc, time::Duration}; use starknet::core::types::Felt; @@ -73,7 +72,7 @@ impl HyperlaneService { } let validators_fetchers = self.storage.validators_fetchers().all().await; - let mut futures = Vec::new(); + let mut futures = Vec::with_capacity(unsigned_nonces.len()); for &nonce in &unsigned_nonces { for (validator, fetcher) in &validators_fetchers { let fut = self.process_single_validator_nonce(*validator, fetcher.clone(), nonce); @@ -84,9 +83,10 @@ impl HyperlaneService { // NOTE: At the moment, we only process updates when ALL validators have signed a message. // TODO: We should instead use a quorum method - if 66% have signed, consider it ok. + let validator_addresses: Vec = validators_fetchers.keys().cloned().collect(); for &nonce in &unsigned_nonces { // TODO: If the nonce n+1 is fully signed, shall we ignore every nonces before..? Or raise an alert? - if self.all_validators_signed_nonce(&validators_fetchers, nonce).await { + if self.all_validators_signed_nonce(&validator_addresses, nonce).await { tracing::info!( "πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", nonce @@ -100,13 +100,8 @@ impl HyperlaneService { } /// Checks if all validators have signed a given nonce. - async fn all_validators_signed_nonce( - &self, - validators_fetchers: &HashMap>>, - nonce: u32, - ) -> bool { - let validators: Vec = validators_fetchers.keys().cloned().collect(); - self.storage.signed_checkpoints().all_validators_signed_nonce(&validators, nonce).await + async fn all_validators_signed_nonce(&self, validators_addresses: &[Felt], nonce: u32) -> bool { + self.storage.signed_checkpoints().all_validators_signed_nonce(validators_addresses, nonce).await } async fn process_single_validator_nonce( From 4fa9d6cb5773db04248ac36adc12e4fd3dd979f7 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 13:53:56 +0100 Subject: [PATCH 22/55] dev(better_theoros): reading improvements --- rust/theoros/src/services/hyperlane/mod.rs | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 66b42a42..c57a0cd8 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -75,7 +75,7 @@ impl HyperlaneService { let mut futures = Vec::with_capacity(unsigned_nonces.len()); for &nonce in &unsigned_nonces { for (validator, fetcher) in &validators_fetchers { - let fut = self.process_single_validator_nonce(*validator, fetcher.clone(), nonce); + let fut = self.fetch_checkpoint_for_validator(*validator, fetcher.clone(), nonce); futures.push(fut); } } @@ -85,17 +85,15 @@ impl HyperlaneService { // TODO: We should instead use a quorum method - if 66% have signed, consider it ok. let validator_addresses: Vec = validators_fetchers.keys().cloned().collect(); for &nonce in &unsigned_nonces { + if !self.all_validators_signed_nonce(&validator_addresses, nonce).await { + continue; + } // TODO: If the nonce n+1 is fully signed, shall we ignore every nonces before..? Or raise an alert? - if self.all_validators_signed_nonce(&validator_addresses, nonce).await { - tracing::info!( - "πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", - nonce - ); - if let Err(e) = self.store_dispatch_updates(nonce).await { - tracing::error!("😱 Failed to store event updates for nonce {}: {:?}", nonce, e); - } - self.storage.unsigned_checkpoints().remove(nonce).await; + tracing::info!("πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", nonce); + if let Err(e) = self.store_dispatch_updates(nonce).await { + tracing::error!("😱 Failed to store event updates for nonce {}: {:?}", nonce, e); } + self.storage.unsigned_checkpoints().remove(nonce).await; } } @@ -104,7 +102,9 @@ impl HyperlaneService { self.storage.signed_checkpoints().all_validators_signed_nonce(validators_addresses, nonce).await } - async fn process_single_validator_nonce( + /// Given a validator & a nonce, query the fetcher to try to get the signed checkpoint. + /// If it exists, it will get stored in the Signed Checkpoints storage. + async fn fetch_checkpoint_for_validator( &self, validator: Felt, fetcher: Arc>, @@ -134,7 +134,7 @@ impl HyperlaneService { Ok(()) } - /// Store the signed checkpoint for the validator ; nonce couple. + /// Store the signed checkpoint for the (validator;nonce) couple. async fn store_signed_checkpoint( &self, validator: Felt, @@ -147,22 +147,24 @@ impl HyperlaneService { return Ok(()); } - tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed checkpoint #{}", validator, nonce); self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await?; + tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed checkpoint #{}", validator, nonce); Ok(()) } /// Stores the updates once it has been signed. + /// Also sends an update to the websocket channel that an update has been stored. async fn store_dispatch_updates(&self, nonce: u32) -> anyhow::Result<()> { let event = match self.storage.unsigned_checkpoints().get(nonce).await { Some(e) => e, None => unreachable!(), }; + for update in event.message.body.updates.iter() { - let feed_id = update.feed_id(); - let feed_id = hex_str_to_u256(&feed_id)?; let dispatch_update_infos = DispatchUpdateInfos::new(&event, update); + + let feed_id = hex_str_to_u256(&update.feed_id())?; self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos).await?; } From 00a86e5cce454f7a12b7b9aa85460d311b7c738c Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Sat, 2 Nov 2024 13:03:44 +0000 Subject: [PATCH 23/55] fix: strum EnumString --- rust/Cargo.lock | 2 ++ rust/theoros/Cargo.toml | 2 ++ rust/theoros/src/configs/evm_config.rs | 46 +++----------------------- 3 files changed, 8 insertions(+), 42 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 59b127bf..e1cf355c 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -5088,6 +5088,8 @@ dependencies = [ "serde_json", "serde_yaml", "starknet 0.11.0", + "strum", + "strum_macros", "thiserror", "tokio", "tower-http", diff --git a/rust/theoros/Cargo.toml b/rust/theoros/Cargo.toml index 192bb0ab..f23dc5fe 100644 --- a/rust/theoros/Cargo.toml +++ b/rust/theoros/Cargo.toml @@ -32,6 +32,8 @@ rusoto_s3 = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } serde_yaml = { workspace = true } +strum = { workspace = true, features = ["derive"] } +strum_macros = { workspace = true } starknet = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["sync", "macros", "rt-multi-thread"] } diff --git a/rust/theoros/src/configs/evm_config.rs b/rust/theoros/src/configs/evm_config.rs index 5f4531f3..f0d47e63 100644 --- a/rust/theoros/src/configs/evm_config.rs +++ b/rust/theoros/src/configs/evm_config.rs @@ -1,9 +1,8 @@ +use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fs; use std::path::Path; -use std::str::FromStr; - -use serde::{Deserialize, Serialize}; +use strum_macros::EnumString; use thiserror::Error; pub const DEFAULT_CONFIG_PATH: &str = "evm_config.yaml"; @@ -11,8 +10,8 @@ pub const DEFAULT_CONFIG_PATH: &str = "evm_config.yaml"; /// Supported Chain identifiers // Must reflect the EVM chains here: // https://github.com/astraly-labs/pragma-monorepo/blob/main/typescript/pragma-utils/src/chains.ts -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, EnumString)] +#[strum(serialize_all = "snake_case")] pub enum EvmChainName { Mainnet, Sepolia, @@ -73,40 +72,3 @@ impl EvmConfig { &self.chains } } - -#[derive(Error, Debug)] -#[error("Unknown chain name: {0}")] -pub struct ParseChainError(String); - -impl FromStr for EvmChainName { - type Err = ParseChainError; - - fn from_str(s: &str) -> Result { - let chain_name = s.to_lowercase().replace('-', "_"); - match chain_name.as_str() { - "mainnet" => Ok(Self::Mainnet), - "sepolia" => Ok(Self::Sepolia), - "holesky" => Ok(Self::Holesky), - "bsc" => Ok(Self::Bsc), - "bsc_testnet" => Ok(Self::BscTestnet), - "polygon" => Ok(Self::Polygon), - "polygon_testnet" => Ok(Self::PolygonTestnet), - "polygon_zk_evm" => Ok(Self::PolygonZkEvm), - "avalanche" => Ok(Self::Avalanche), - "fantom" => Ok(Self::Fantom), - "arbitrum" => Ok(Self::Arbitrum), - "optimism" => Ok(Self::Optimism), - "base" => Ok(Self::Base), - "scroll" => Ok(Self::Scroll), - "scroll_testnet" => Ok(Self::ScrollTestnet), - "scroll_sepolia_testnet" => Ok(Self::ScrollSepoliaTestnet), - "zircuit_testnet" => Ok(Self::ZircuitTestnet), - "plume_testnet" => Ok(Self::PlumeTestnet), - "worldchain" => Ok(Self::Worldchain), - "worldchain_testnet" => Ok(Self::WorldchainTestnet), - "zksync" => Ok(Self::Zksync), - "zksync_testnet" => Ok(Self::ZksyncTestnet), - _ => Err(ParseChainError(s.to_string())), - } - } -} From 44305383970a3e308c5fb54dc87b3c34ab5c93b6 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 14:19:36 +0100 Subject: [PATCH 24/55] dev(better_theoros): Fixed EnumString deserialisation --- rust/theoros/src/cli.rs | 2 -- rust/theoros/src/configs/evm_config.rs | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/theoros/src/cli.rs b/rust/theoros/src/cli.rs index 46816f21..b67f7347 100644 --- a/rust/theoros/src/cli.rs +++ b/rust/theoros/src/cli.rs @@ -73,7 +73,5 @@ pub fn parse_evm_config(s: &str) -> anyhow::Result { if !std::path::Path::new(s).exists() { anyhow::bail!("EVM config file not found at path: {}", s); } - - // Load and parse the config evm_config::EvmConfig::from_file(s).with_context(|| format!("Failed to load EVM config from path: {}", s)) } diff --git a/rust/theoros/src/configs/evm_config.rs b/rust/theoros/src/configs/evm_config.rs index f0d47e63..699d961b 100644 --- a/rust/theoros/src/configs/evm_config.rs +++ b/rust/theoros/src/configs/evm_config.rs @@ -12,6 +12,8 @@ pub const DEFAULT_CONFIG_PATH: &str = "evm_config.yaml"; // https://github.com/astraly-labs/pragma-monorepo/blob/main/typescript/pragma-utils/src/chains.ts #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, EnumString)] #[strum(serialize_all = "snake_case")] +#[serde(rename_all = "snake_case")] +#[strum(ascii_case_insensitive)] pub enum EvmChainName { Mainnet, Sepolia, From 653d3ddeba404729f4ee7e5b7b3c7c617cc6ec81 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 16:39:54 +0100 Subject: [PATCH 25/55] dev(better_theoros): Works with N signatures --- rust/theoros/src/rpc/evm/mod.rs | 11 ++++++ rust/theoros/src/storage/checkpoints.rs | 4 +-- rust/theoros/src/types/calldata.rs | 48 +++++++++++++------------ 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index b3bd090d..2baafed4 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -39,4 +39,15 @@ impl HyperlaneValidatorsMapping { pub fn chain_names(&self) -> Vec { self.0.keys().cloned().collect() } + + /// Get the index of a validator for a chain + pub fn validator_index(&self, chain_name: &EvmChainName, searched_validator: &Felt) -> Option { + match self.0.get(chain_name) { + Some(validators) => validators + .iter() + .position(|validator| validator == searched_validator) + .and_then(|pos| pos.try_into().ok()), + None => None, + } + } } diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index b3b0bf91..6089cd53 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -55,7 +55,7 @@ impl SignedCheckpointsStorage { // For the provided list of validators, returns all their signed checkpoints for the // provided message_id. - pub async fn get(&self, validators: &[Felt], searched_nonce: u32) -> Vec { + pub async fn get(&self, validators: &[Felt], searched_nonce: u32) -> Vec<(Felt, SignedCheckpointWithMessageId)> { let lock = self.0.read().await; let mut checkpoints = Vec::new(); @@ -63,7 +63,7 @@ impl SignedCheckpointsStorage { for ((validator, nonce), checkpoint) in lock.iter() { // Only include if validator is in the provided list and message_id matches if nonce == &searched_nonce && validators.contains(validator) { - checkpoints.push(checkpoint.clone()); + checkpoints.push((*validator, checkpoint.clone())); } } diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index fce70bec..553b00ae 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -8,7 +8,7 @@ use std::str::FromStr; use crate::{ configs::evm_config::EvmChainName, constants::{HYPERLANE_VERSION, PRAGMA_MAJOR_VERSION, PRAGMA_MINOR_VERSION, TRAILING_HEADER_SIZE}, - types::hyperlane::{CheckpointWithMessageId, DispatchUpdate, DispatchUpdateInfos}, + types::hyperlane::{CheckpointWithMessageId, DispatchUpdate}, types::state::AppState, }; @@ -32,36 +32,44 @@ pub struct Calldata { impl Calldata { pub async fn build_from(state: &AppState, chain_name: EvmChainName, feed_id: String) -> anyhow::Result { - let update_info: DispatchUpdateInfos = state + // Get latest update for this feed + let update_info = state .storage .latest_update_per_feed() - .get(&hex_str_to_u256(&feed_id).unwrap()) + .get(&hex_str_to_u256(&feed_id)?) .await? .context("No update found")?; + // Get validators and their signatures let validators = state.hyperlane_validators_mapping.get_validators(chain_name).context("No validators found")?; let checkpoints = state.storage.signed_checkpoints().get(validators, update_info.nonce).await; - - let checkpoint_infos = checkpoints.last().unwrap(); - + anyhow::ensure!(!checkpoints.is_empty(), "No signatures found"); + + let signatures: Vec = checkpoints + .iter() + .filter_map(|(validator, signed_checkpoint)| { + state + .hyperlane_validators_mapping + .validator_index(&chain_name, validator) + .map(|idx| ValidatorSignature { validator_index: idx, signature: signed_checkpoint.signature }) + }) + .collect(); + + // Build payload using first checkpoint (all validators sign the same checkpoint since it's the same nonce) let update = match update_info.update { - DispatchUpdate::SpotMedian { update, feed_id: _ } => update, + DispatchUpdate::SpotMedian { update, .. } => update, }; let payload = Payload { - checkpoint: checkpoint_infos.value.clone(), - // TODO: We only handle 1 update per calldata. See if possible to have more. - // TODO: If not remove this and consider it to be always one? + checkpoint: checkpoints[0].1.value.clone(), num_updates: 1, - // TODO: Remove proof proof_len: 0, proof: vec![], update_data_len: update.to_bytes().len() as u16, update_data: update.to_bytes(), - feed_id: U256::from_str(&feed_id).unwrap(), - // TODO: publish_time is already available in the update metadata. Remove. + feed_id: U256::from_str(&feed_id)?, publish_time: update.metadata.timestamp, }; @@ -70,23 +78,19 @@ impl Calldata { emitter_chain_id: update_info.emitter_chain_id, emitter_address: update_info.emitter_address, nonce: update_info.nonce, - // TODO: Adapt for N signers - signers_len: 1_u8, - signatures: vec![ValidatorSignature { validator_index: 0, signature: checkpoint_infos.signature }], - // TODO: Means we store once again the timestamp? Delete this? + signers_len: signatures.len() as u8, + signatures, timestamp: update.metadata.timestamp, payload, }; - let calldata = Calldata { + Ok(Calldata { major_version: PRAGMA_MAJOR_VERSION, minor_version: PRAGMA_MINOR_VERSION, trailing_header_size: TRAILING_HEADER_SIZE, - hyperlane_msg_size: hyperlane_message.as_bytes().len().try_into().unwrap(), + hyperlane_msg_size: hyperlane_message.as_bytes().len().try_into()?, hyperlane_msg: hyperlane_message, - }; - - Ok(calldata) + }) } } From efbed1e37b8c7a50643422ca93ce6f31f61af7be Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 16:56:07 +0100 Subject: [PATCH 26/55] dev(better_theoros): --- .../websocket/subscribe_to_calldata.rs | 36 +++++++++---------- rust/theoros/src/types/mod.rs | 1 - rust/theoros/src/types/rpc.rs | 13 ------- rust/theoros/src/types/state.rs | 1 - solidity/test/PragmaDecoder.t.sol | 2 +- 5 files changed, 18 insertions(+), 35 deletions(-) delete mode 100644 rust/theoros/src/types/rpc.rs diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index 6a5e6557..138708af 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -19,10 +19,11 @@ use futures::{ }; use serde::{Deserialize, Serialize}; use tokio::sync::broadcast::Receiver; +use utoipa::ToSchema; use crate::constants::{MAX_CLIENT_MESSAGE_SIZE, PING_INTERVAL_DURATION}; use crate::types::calldata::AsCalldata; -use crate::types::{hyperlane::NewUpdatesAvailableEvent, rpc::RpcDataFeed}; +use crate::types::hyperlane::NewUpdatesAvailableEvent; use crate::AppState; use crate::{configs::evm_config::EvmChainName, types::calldata::Calldata}; @@ -40,6 +41,15 @@ enum ClientMessage { Unsubscribe { ids: Vec }, } +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +pub struct RpcDataFeed { + pub feed_id: String, + /// The calldata binary represented as a hex string. + #[serde(skip_serializing_if = "Option::is_none")] + #[schema(value_type = Option)] + pub encoded_calldata: Option, +} + #[derive(Serialize, Debug, Clone)] #[serde(tag = "type")] enum ServerMessage { @@ -70,14 +80,9 @@ pub async fn ws_route_handler( async fn websocket_handler(stream: WebSocket, state: AppState) { let ws_state = state.ws.clone(); - // TODO: add new connection to metrics - let (sender, receiver) = stream.split(); - let feeds_receiver = state.storage.feeds_updated_tx().subscribe(); - let id = ws_state.subscriber_counter.fetch_add(1, Ordering::SeqCst); - let mut subscriber = Subscriber::new(id, Arc::new(state), feeds_receiver, receiver, sender); subscriber.run().await; @@ -145,14 +150,6 @@ impl Subscriber { }, _ = self.ping_interval.tick() => { if !self.responded_to_ping { - // self.metrics - // .interactions - // .get_or_create(&Labels { - // interaction: Interaction::ClientHeartbeat, - // status: Status::Error, - // }) - // .inc(); - return Err(anyhow!("Subscriber did not respond to ping. Closing connection.")); } self.responded_to_ping = false; @@ -176,10 +173,12 @@ impl Subscriber { Calldata::build_from(self.state.as_ref(), self.active_chain.unwrap(), feed_id.to_owned()).await?; let message = serde_json::to_string(&ServerMessage::DataFeedUpdate { - data_feed: RpcDataFeed { feed_id: feed_id.clone(), calldata: Some(hex::encode(calldata.as_bytes())) }, + data_feed: RpcDataFeed { + feed_id: feed_id.clone(), + encoded_calldata: Some(hex::encode(calldata.as_bytes())), + }, })?; self.sender.send(message.into()).await?; - // TODO: success metric Ok(()) } @@ -229,13 +228,11 @@ impl Subscriber { Ok(ClientMessage::Subscribe { ids: feed_ids, chain_name }) => { let stored_feed_ids = self.state.storage.feed_ids(); - // TODO: Assert that the chain is supported? - // If there is a single feed id that is not found, we don't subscribe to any of the // asked feed ids and return an error to be more explicit and clear. match stored_feed_ids.contains_vec(&feed_ids).await { + // TODO: return multiple missing ids Some(missing_id) => { - // TODO: return multiple missing ids self.sender .send( serde_json::to_string(&ServerMessage::Response(ServerResponseMessage::Err { @@ -249,6 +246,7 @@ impl Subscriber { None => { for feed_id in feed_ids { self.data_feeds_with_config.insert(feed_id, DataFeedClientConfig {}); + // TODO: Assert that the chain is supported by theoros self.active_chain = Some(chain_name); } } diff --git a/rust/theoros/src/types/mod.rs b/rust/theoros/src/types/mod.rs index c1f9c34d..d6f6d340 100644 --- a/rust/theoros/src/types/mod.rs +++ b/rust/theoros/src/types/mod.rs @@ -1,4 +1,3 @@ pub mod calldata; pub mod hyperlane; -pub mod rpc; pub mod state; diff --git a/rust/theoros/src/types/rpc.rs b/rust/theoros/src/types/rpc.rs deleted file mode 100644 index 54feb797..00000000 --- a/rust/theoros/src/types/rpc.rs +++ /dev/null @@ -1,13 +0,0 @@ -use serde::{Deserialize, Serialize}; -use utoipa::ToSchema; - -pub type RpcDataFeedIdentifier = String; - -#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] -pub struct RpcDataFeed { - pub feed_id: RpcDataFeedIdentifier, - /// The calldata binary represented as a hex string. - #[serde(skip_serializing_if = "Option::is_none")] - #[schema(value_type = Option)] - pub calldata: Option, -} diff --git a/rust/theoros/src/types/state.rs b/rust/theoros/src/types/state.rs index 330d7998..279cca37 100644 --- a/rust/theoros/src/types/state.rs +++ b/rust/theoros/src/types/state.rs @@ -9,7 +9,6 @@ use crate::{ #[derive(Clone)] pub struct AppState { - #[allow(unused)] pub starknet_rpc: Arc, pub hyperlane_validators_mapping: Arc, pub storage: Arc, diff --git a/solidity/test/PragmaDecoder.t.sol b/solidity/test/PragmaDecoder.t.sol index 093282af..52779d49 100644 --- a/solidity/test/PragmaDecoder.t.sol +++ b/solidity/test/PragmaDecoder.t.sol @@ -37,7 +37,7 @@ contract PragmaHarnessTest is Test { setupRaw(); // encoded update bytes memory encodedUpdate = - hex"0100000170030100c1ec5070f1a4868b8e6bfa5bbd31ac77605c5af1a739bc4e7758d4ca1d88fa8835c1460646b647c4c4403b324c2297a04d70b84888dc873021f80d6d70ed015e1c00031b8b0000000067225b1100611a3d0060240f2bccef7e64f920eec05c5bfffbc48c6ceaa4efca8748772b60cbafc30536953cdd0dd5b8e24428e4fb6eab5c143daba15f62b24606e50d822508faefd53032e26a3b1d1510dfe82a2ab8d6c0fc0f010dcdd3c410ba2f9fdad3479b1400031b8b15704e0efd1955cfe1c1182ba083bd5309707bdd795397cbbbb106cfc9b29bb001000100000000000000000000004254432f555344000000000000000000000000000000000000000067225b1100080800000000000000000000068aa5cb9d63000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004254432f5553440000000067225b11"; + hex"0100000170030100aeffc47b4d795e4978f92378ba5276697dd58fea699470add9e855cbb782b19b05da6229faf0cd99fef5a908b976102af271f6ec0e8d736b22df6dfd794fc3a81b0003c3de000000006726476300611a3d0060240f2bccef7e64f920eec05c5bfffbc48c6ceaa4efca8748772b60cbafc30536953cdd0dd5b8e24428e4fb6eab5c143daba15f62b24606e50d822508faefba5410a4a5555b80baf66026cec6481aa28a3291a2f25546b1187bf9ac18306d0003c3dec2e4e2ec168d8437f4c052570f20994259cd442d7068ae2ee2f33401e5243bb301006b00000000000000000000004254432f5553440000000000000000000000000000000000000000672647630008080000000000000000000000000000000000000000000000000000064fd736747b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004254432f5553440000000067264763"; uint8 numUpdates = pragmaHarness.exposed_updateDataInfoFromUpdate(encodedUpdate); assertEq(numUpdates, 1, "Number of updates should be 1"); } From 28a5ad8495d71839f54442e99190df3c68e89d21 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 17:06:32 +0100 Subject: [PATCH 27/55] dev(better_theoros): better opti --- rust/theoros/src/rpc/evm/mod.rs | 18 +++++------------- rust/theoros/src/types/calldata.rs | 19 +++++++++---------- solidity/test/PragmaDecoder.t.sol | 2 +- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index 2baafed4..44907d6d 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -31,23 +31,15 @@ impl HyperlaneValidatorsMapping { Ok(Self(contracts)) } - pub fn get_validators(&self, chain_name: EvmChainName) -> Option<&Vec> { - self.0.get(&chain_name) + /// Get the available validators for a chain & their indexes + pub fn get_validators(&self, chain_name: &EvmChainName) -> Option> { + self.0 + .get(chain_name) + .map(|validators| validators.iter().enumerate().map(|(idx, validator)| (*validator, idx as u8)).collect()) } /// Get all configured chains names pub fn chain_names(&self) -> Vec { self.0.keys().cloned().collect() } - - /// Get the index of a validator for a chain - pub fn validator_index(&self, chain_name: &EvmChainName, searched_validator: &Felt) -> Option { - match self.0.get(chain_name) { - Some(validators) => validators - .iter() - .position(|validator| validator == searched_validator) - .and_then(|pos| pos.try_into().ok()), - None => None, - } - } } diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index 553b00ae..24d12d37 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -3,7 +3,7 @@ use anyhow::Context; use pragma_utils::conversions::alloy::hex_str_to_u256; use serde::{Deserialize, Serialize}; use starknet::core::types::Felt; -use std::str::FromStr; +use std::{collections::HashMap, str::FromStr}; use crate::{ configs::evm_config::EvmChainName, @@ -40,24 +40,23 @@ impl Calldata { .await? .context("No update found")?; - // Get validators and their signatures - let validators = - state.hyperlane_validators_mapping.get_validators(chain_name).context("No validators found")?; + let validators_with_indices = + state.hyperlane_validators_mapping.get_validators(&chain_name).context("No validators found")?; - let checkpoints = state.storage.signed_checkpoints().get(validators, update_info.nonce).await; + let validators: Vec = validators_with_indices.iter().map(|(validator, _)| *validator).collect(); + let checkpoints = state.storage.signed_checkpoints().get(&validators, update_info.nonce).await; anyhow::ensure!(!checkpoints.is_empty(), "No signatures found"); + let validator_index_map: HashMap = validators_with_indices.into_iter().collect(); let signatures: Vec = checkpoints .iter() .filter_map(|(validator, signed_checkpoint)| { - state - .hyperlane_validators_mapping - .validator_index(&chain_name, validator) - .map(|idx| ValidatorSignature { validator_index: idx, signature: signed_checkpoint.signature }) + validator_index_map + .get(validator) + .map(|&idx| ValidatorSignature { validator_index: idx, signature: signed_checkpoint.signature }) }) .collect(); - // Build payload using first checkpoint (all validators sign the same checkpoint since it's the same nonce) let update = match update_info.update { DispatchUpdate::SpotMedian { update, .. } => update, }; diff --git a/solidity/test/PragmaDecoder.t.sol b/solidity/test/PragmaDecoder.t.sol index 52779d49..64d6bd81 100644 --- a/solidity/test/PragmaDecoder.t.sol +++ b/solidity/test/PragmaDecoder.t.sol @@ -37,7 +37,7 @@ contract PragmaHarnessTest is Test { setupRaw(); // encoded update bytes memory encodedUpdate = - hex"0100000170030100aeffc47b4d795e4978f92378ba5276697dd58fea699470add9e855cbb782b19b05da6229faf0cd99fef5a908b976102af271f6ec0e8d736b22df6dfd794fc3a81b0003c3de000000006726476300611a3d0060240f2bccef7e64f920eec05c5bfffbc48c6ceaa4efca8748772b60cbafc30536953cdd0dd5b8e24428e4fb6eab5c143daba15f62b24606e50d822508faefba5410a4a5555b80baf66026cec6481aa28a3291a2f25546b1187bf9ac18306d0003c3dec2e4e2ec168d8437f4c052570f20994259cd442d7068ae2ee2f33401e5243bb301006b00000000000000000000004254432f5553440000000000000000000000000000000000000000672647630008080000000000000000000000000000000000000000000000000000064fd736747b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004254432f5553440000000067264763"; + hex"010000017003010084c952cde2a8b15194c9f60982a25399df800bf046f8984acef7e389cb2072ec23ac617442547a115cc69f038225bd36ceb1f748a8d8698f35de2110729d5f9a1b0003c4d1000000000000000000611a3d0060240f2bccef7e64f920eec05c5bfffbc48c6ceaa4efca8748772b60cbafc30536953cdd0dd5b8e24428e4fb6eab5c143daba15f62b24606e50d822508faef2bdfc6c6de418348c73cf78541d8f09c53e6f5eb56ef35a4db5b52e4919f302f0003c4d18660df2e348a6b5322d034079fc498a749263d71ba47a7acb222e3edece8eca901006b000000000000000000004c5553442f555344000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c5553442f5553440000000000000000"; uint8 numUpdates = pragmaHarness.exposed_updateDataInfoFromUpdate(encodedUpdate); assertEq(numUpdates, 1, "Number of updates should be 1"); } From f5f568f7dfb661ca9b7f333114ee5975cf7154e5 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 17:13:27 +0100 Subject: [PATCH 28/55] dev(better_theoros): last commit - assert that the checkpoint is the same --- rust/theoros/src/types/calldata.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index 24d12d37..7bbf72eb 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -47,6 +47,13 @@ impl Calldata { let checkpoints = state.storage.signed_checkpoints().get(&validators, update_info.nonce).await; anyhow::ensure!(!checkpoints.is_empty(), "No signatures found"); + // Ensure all nonce have the same checkpoint + let nonce_checkpoint = &checkpoints[0].1.value; + anyhow::ensure!( + checkpoints.iter().all(|(_, checkpoint)| &(checkpoint.value) == nonce_checkpoint), + "Inconsistent checkpoint values found" + ); + let validator_index_map: HashMap = validators_with_indices.into_iter().collect(); let signatures: Vec = checkpoints .iter() @@ -62,7 +69,7 @@ impl Calldata { }; let payload = Payload { - checkpoint: checkpoints[0].1.value.clone(), + checkpoint: nonce_checkpoint.clone(), num_updates: 1, proof_len: 0, proof: vec![], From 496d79f5d09ca722821d6746b19f9732654d0628 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 17:25:26 +0100 Subject: [PATCH 29/55] dev(better_theoros): Removed unused dependencies --- rust/Cargo.lock | 202 +---------------------------------- rust/Cargo.toml | 29 ----- rust/pragma-feeds/Cargo.toml | 8 -- rust/pragma-utils/Cargo.toml | 4 - rust/theoros/Cargo.toml | 7 -- 5 files changed, 2 insertions(+), 248 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e1cf355c..0b18362c 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -326,7 +326,7 @@ dependencies = [ "async-stream", "async-trait", "auto_impl", - "dashmap 6.0.1", + "dashmap", "futures", "futures-utils-wasm", "lru", @@ -1129,19 +1129,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bigdecimal" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d712318a27c7150326677b321a5fa91b55f6d9034ffd67f20319e147d40cee" -dependencies = [ - "autocfg", - "libm", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "bimap" version = "0.6.3" @@ -1494,19 +1481,6 @@ dependencies = [ "syn 2.0.75", ] -[[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 = "dashmap" version = "6.0.1" @@ -1649,18 +1623,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aac81fa3e28d21450aa4d2ac065992ba96a1d7303efbce51a95f4fd175b67562" -[[package]] -name = "dotenvy" -version = "0.15.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" - -[[package]] -name = "dtoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" - [[package]] name = "dunce" version = "1.0.5" @@ -1715,15 +1677,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "envy" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f47e0157f2cb54f5ae1bd371b30a2ae4311e1c028f575cd4e81de7353215965" -dependencies = [ - "serde", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1884,16 +1837,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "forwarded-header-value" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835f84f38484cc86f110a805655697908257fb9a7af005234060891557198e9" -dependencies = [ - "nonempty", - "thiserror", -] - [[package]] name = "funty" version = "2.0.0" @@ -1971,12 +1914,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" -[[package]] -name = "futures-timer" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" - [[package]] name = "futures-util" version = "0.3.30" @@ -2037,26 +1974,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "governor" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a7f542ee6b35af73b06abc0dad1c1bae89964e4e253bc4b587b91c9637867b" -dependencies = [ - "cfg-if", - "dashmap 5.5.3", - "futures", - "futures-timer", - "no-std-compat", - "nonzero_ext", - "parking_lot", - "portable-atomic", - "quanta", - "rand", - "smallvec", - "spinning_top", -] - [[package]] name = "group" version = "0.13.0" @@ -2797,24 +2714,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "no-std-compat" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" - -[[package]] -name = "nonempty" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7" - -[[package]] -name = "nonzero_ext" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" - [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -3275,12 +3174,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "portable-atomic" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" - [[package]] name = "powerfmt" version = "0.2.0" @@ -3301,18 +3194,10 @@ name = "pragma-feeds" version = "0.1.0" dependencies = [ "anyhow", - "apibara-core", - "async-trait", "hex", - "rusoto_core", "serde", - "starknet 0.11.0", "strum", "strum_macros", - "tokio", - "tracing", - "tracing-axiom", - "tracing-subscriber", ] [[package]] @@ -3323,12 +3208,8 @@ dependencies = [ "anyhow", "apibara-core", "async-trait", - "hex", "rusoto_core", - "serde", "starknet 0.11.0", - "strum", - "strum_macros", "tokio", "tracing", "tracing-axiom", @@ -3437,29 +3318,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "prometheus-client" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c99afa9a01501019ac3a14d71d9f94050346f55ca471ce90c799a15c58f61e2" -dependencies = [ - "dtoa", - "itoa", - "parking_lot", - "prometheus-client-derive-encode", -] - -[[package]] -name = "prometheus-client-derive-encode" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.75", -] - [[package]] name = "proptest" version = "1.5.0" @@ -3563,21 +3421,6 @@ version = "2.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" -[[package]] -name = "quanta" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" -dependencies = [ - "crossbeam-utils", - "libc", - "once_cell", - "raw-cpuid", - "wasi", - "web-sys", - "winapi", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -3687,15 +3530,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "raw-cpuid" -version = "11.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" -dependencies = [ - "bitflags 2.6.0", -] - [[package]] name = "recvmsg" version = "1.0.0" @@ -4570,15 +4404,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "spinning_top" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" -dependencies = [ - "lock_api", -] - [[package]] name = "spki" version = "0.7.3" @@ -4795,7 +4620,7 @@ version = "0.3.7" source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=7153d0e42#7153d0e42112f8c1348029557aa6cf2b881a5c84" dependencies = [ "ark-ff 0.4.2", - "bigdecimal 0.3.1", + "bigdecimal", "crypto-bigint", "getrandom", "hex", @@ -5066,22 +4891,16 @@ dependencies = [ "async-trait", "axum 0.7.5", "axum-macros", - "bigdecimal 0.4.5", "chrono", "clap", - "dotenvy", - "envy", "futures", "futures-util", "hyper 0.14.30", "lazy_static", - "num-bigint", - "num-traits", "opentelemetry 0.24.0", "pragma-feeds", "pragma-utils", "prometheus", - "prometheus-client", "rusoto_core", "rusoto_s3", "serde", @@ -5093,7 +4912,6 @@ dependencies = [ "thiserror", "tokio", "tower-http", - "tower_governor", "tracing", "url", "utoipa", @@ -5512,22 +5330,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" -[[package]] -name = "tower_governor" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aea939ea6cfa7c4880f3e7422616624f97a567c16df67b53b11f0d03917a8e46" -dependencies = [ - "axum 0.7.5", - "forwarded-header-value", - "governor", - "http 1.1.0", - "pin-project", - "thiserror", - "tower 0.5.1", - "tracing", -] - [[package]] name = "tracing" version = "0.1.40" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 50d357e1..ad1547a6 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -15,35 +15,15 @@ publish = false [workspace.dependencies] anyhow = "1.0.86" async-trait = "0.1.81" -bollard = "0.17.1" clap = { version = "4.5.16", features = ["derive", "env"] } chrono = { version = "0.4.38", features = ["serde"] } -derive_more = { version = "1", features = ["deref", "deref_mut"] } -dirs = "5.0.1" -dotenvy = "0.15.7" -envy = "0.4.2" -bigdecimal = "0.4.5" -deadpool-diesel = { version = "0.6.1", features = ["postgres"] } -diesel_migrations = "2.2.0" -diesel = { version = "2.2.3", features = [ - "postgres", - "extras", - "postgres_backend", - "serde_json", -] } -env_logger = "0.11.5" alloy = { version = "0.5.2", features = ["full"] } -eyre = "0.6.12" futures = { version = "0.3.30", features = ["std"] } futures-util = "0.3.30" -git2 = "0.19.0" hex = "0.4.3" -inquire = "0.7.5" tracing = "0.1.4" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing-axiom = "0.7" -rand = "0.8.5" -reqwest = { version = "0.12.7", features = ["json", "blocking"] } serde = { version = "1.0.208", features = ["derive"] } serde_json = "1.0.125" serde_yaml = "0.9.34" @@ -51,7 +31,6 @@ strum = { version = "0.26.3", features = ["derive"] } strum_macros = { version = "0.26.4", features = [] } thiserror = "1.0.63" prometheus = "0.13.4" -prometheus-client = { version = "0.21.2" } hyper = { version = "0.14", features = ["server"] } tokio = { version = "1.39.3", features = [ "rt", @@ -59,9 +38,6 @@ tokio = { version = "1.39.3", features = [ "macros", "signal", ] } -toml = "0.8.19" -tower_governor = { version = "0.4.3", features = ["axum", "tracing"] } -scale-info = "2.11.3" scale = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive", ] } @@ -78,8 +54,6 @@ ya-gcp = { version = "0.11.3", features = ["storage"] } rusoto_s3 = "0.48.0" rusoto_core = "0.48.0" lazy_static = "1.5.0" -num-bigint = "0.4" -num-traits = "0.2" # Apibara DNA (indexing) apibara-core = { git = "https://github.com/apibara/dna", rev = "9caa385" } @@ -90,9 +64,6 @@ pragma-utils = { path = "pragma-utils" } pragma-feeds = { path = "pragma-feeds" } theoros = { path = "theoros" } -# Tests dependencies -tracing-test = "0.2.5" - [profile.release] overflow-checks = true lto = "fat" diff --git a/rust/pragma-feeds/Cargo.toml b/rust/pragma-feeds/Cargo.toml index ed6f2aac..4a78aaef 100644 --- a/rust/pragma-feeds/Cargo.toml +++ b/rust/pragma-feeds/Cargo.toml @@ -5,15 +5,7 @@ edition = "2021" [dependencies] anyhow = { workspace = true } -apibara-core = { workspace = true } -async-trait = { workspace = true } hex = { workspace = true } -rusoto_core = { workspace = true } serde = { workspace = true, features = ["derive"] } -starknet = { workspace = true } strum = { workspace = true } strum_macros = { workspace = true } -tokio = { workspace = true, features = ["signal"] } -tracing = { workspace = true } -tracing-axiom = { workspace = true } -tracing-subscriber = { workspace = true } diff --git a/rust/pragma-utils/Cargo.toml b/rust/pragma-utils/Cargo.toml index a0c0e3d3..23149b15 100644 --- a/rust/pragma-utils/Cargo.toml +++ b/rust/pragma-utils/Cargo.toml @@ -8,12 +8,8 @@ alloy = { workspace = true } anyhow = { workspace = true } apibara-core = { workspace = true } async-trait = { workspace = true } -hex = { workspace = true } rusoto_core = { workspace = true } -serde = { workspace = true, features = ["derive"] } starknet = { workspace = true } -strum = { workspace = true } -strum_macros = { workspace = true } tokio = { workspace = true, features = ["signal"] } tracing = { workspace = true } tracing-axiom = { workspace = true } diff --git a/rust/theoros/Cargo.toml b/rust/theoros/Cargo.toml index f23dc5fe..cd0004ab 100644 --- a/rust/theoros/Cargo.toml +++ b/rust/theoros/Cargo.toml @@ -11,22 +11,16 @@ apibara-sdk = { workspace = true } async-trait = { workspace = true } axum = { workspace = true, features = ["macros", "ws", "tokio"] } axum-macros = { workspace = true } -bigdecimal = { workspace = true } chrono = { workspace = true, features = ["serde"] } clap = { workspace = true, features = ["derive", "env"] } -dotenvy = { workspace = true } -envy = { workspace = true } futures = { workspace = true, features = ["std"] } futures-util = { workspace = true } hyper = { workspace = true, features = ["server"] } lazy_static = { workspace = true } -num-bigint = { workspace = true } -num-traits = { workspace = true } opentelemetry = { workspace = true } pragma-feeds = { workspace = true } pragma-utils = { workspace = true } prometheus = { workspace = true } -prometheus-client = { workspace = true } rusoto_core = { workspace = true } rusoto_s3 = { workspace = true } serde = { workspace = true, features = ["derive"] } @@ -38,7 +32,6 @@ starknet = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["sync", "macros", "rt-multi-thread"] } tower-http = { workspace = true, features = ["fs", "trace", "cors"] } -tower_governor = { workspace = true, features = ["axum", "tracing"] } tracing = { workspace = true } url = { workspace = true } utoipa = { workspace = true, features = ["axum_extras", "chrono", "uuid"] } From 54daadc21d16c039e8cd2c17f52949bc19ada6ea Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 17:37:54 +0100 Subject: [PATCH 30/55] dev(better_theoros): --- rust/theoros/src/rpc/evm/mod.rs | 2 +- rust/theoros/src/types/calldata.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index 44907d6d..f978b96e 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -32,7 +32,7 @@ impl HyperlaneValidatorsMapping { } /// Get the available validators for a chain & their indexes - pub fn get_validators(&self, chain_name: &EvmChainName) -> Option> { + pub fn get_validators(&self, chain_name: &EvmChainName) -> Option> { self.0 .get(chain_name) .map(|validators| validators.iter().enumerate().map(|(idx, validator)| (*validator, idx as u8)).collect()) diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index 7bbf72eb..c3762a29 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -1,9 +1,10 @@ +use std::{collections::HashMap, str::FromStr}; + use alloy::{primitives::U256, signers::Signature}; use anyhow::Context; use pragma_utils::conversions::alloy::hex_str_to_u256; use serde::{Deserialize, Serialize}; use starknet::core::types::Felt; -use std::{collections::HashMap, str::FromStr}; use crate::{ configs::evm_config::EvmChainName, @@ -32,7 +33,6 @@ pub struct Calldata { impl Calldata { pub async fn build_from(state: &AppState, chain_name: EvmChainName, feed_id: String) -> anyhow::Result { - // Get latest update for this feed let update_info = state .storage .latest_update_per_feed() @@ -40,10 +40,10 @@ impl Calldata { .await? .context("No update found")?; - let validators_with_indices = + let validator_index_map: HashMap = state.hyperlane_validators_mapping.get_validators(&chain_name).context("No validators found")?; - let validators: Vec = validators_with_indices.iter().map(|(validator, _)| *validator).collect(); + let validators: Vec = validator_index_map.keys().copied().collect(); let checkpoints = state.storage.signed_checkpoints().get(&validators, update_info.nonce).await; anyhow::ensure!(!checkpoints.is_empty(), "No signatures found"); @@ -54,7 +54,6 @@ impl Calldata { "Inconsistent checkpoint values found" ); - let validator_index_map: HashMap = validators_with_indices.into_iter().collect(); let signatures: Vec = checkpoints .iter() .filter_map(|(validator, signed_checkpoint)| { @@ -71,11 +70,13 @@ impl Calldata { let payload = Payload { checkpoint: nonce_checkpoint.clone(), num_updates: 1, + // TODO: proof should be deleted proof_len: 0, proof: vec![], update_data_len: update.to_bytes().len() as u16, update_data: update.to_bytes(), feed_id: U256::from_str(&feed_id)?, + // TODO: publish_time is a duplicated of update timestamp - remove? publish_time: update.metadata.timestamp, }; @@ -86,6 +87,7 @@ impl Calldata { nonce: update_info.nonce, signers_len: signatures.len() as u8, signatures, + // TODO: timestamp is a duplicated of update timestamp - remove? timestamp: update.metadata.timestamp, payload, }; From 397d014ed602cf724784d55fea9b5b122504bea8 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 17:46:48 +0100 Subject: [PATCH 31/55] =?UTF-8?q?dev(better=5Ftheoros):=20=F0=9F=94=A8=20o?= =?UTF-8?q?ptimizations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/theoros/src/rpc/evm/hyperlane.rs | 9 ++++++--- rust/theoros/src/rpc/evm/mod.rs | 6 ++---- rust/theoros/src/types/calldata.rs | 10 +++------- solidity/test/PragmaDecoder.t.sol | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/rust/theoros/src/rpc/evm/hyperlane.rs b/rust/theoros/src/rpc/evm/hyperlane.rs index 3e00db92..457ba05d 100644 --- a/rust/theoros/src/rpc/evm/hyperlane.rs +++ b/rust/theoros/src/rpc/evm/hyperlane.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use alloy::network::Ethereum; use alloy::primitives::Address; use alloy::providers::fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller}; @@ -36,15 +38,16 @@ impl HyperlaneClient { Self(hyperlane_client) } - pub async fn get_validators(&self) -> Result> { - let mut validators = Vec::new(); + pub async fn get_validators(&self) -> Result> { + let mut validators = HashMap::new(); let mut index = 0; while let Ok(address) = self.0._validators(index.try_into()?).call().await { if address._0 == Address::ZERO { break; } - validators.push(Felt::from_bytes_be(&pad_left_to_32_bytes(&address._0.into_array()))); + let validator = Felt::from_bytes_be(&pad_left_to_32_bytes(&address._0.into_array())); + validators.insert(validator, index); index += 1; } diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index f978b96e..ecc159d0 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -12,7 +12,7 @@ use url::Url; use crate::configs::evm_config::{EvmChainName, EvmConfig}; #[derive(Debug, Default, Clone)] -pub struct HyperlaneValidatorsMapping(HashMap>); +pub struct HyperlaneValidatorsMapping(HashMap>); impl HyperlaneValidatorsMapping { pub async fn from_config(config: &EvmConfig) -> anyhow::Result { @@ -33,9 +33,7 @@ impl HyperlaneValidatorsMapping { /// Get the available validators for a chain & their indexes pub fn get_validators(&self, chain_name: &EvmChainName) -> Option> { - self.0 - .get(chain_name) - .map(|validators| validators.iter().enumerate().map(|(idx, validator)| (*validator, idx as u8)).collect()) + self.0.get(chain_name).cloned() } /// Get all configured chains names diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index c3762a29..424d5fda 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -33,12 +33,8 @@ pub struct Calldata { impl Calldata { pub async fn build_from(state: &AppState, chain_name: EvmChainName, feed_id: String) -> anyhow::Result { - let update_info = state - .storage - .latest_update_per_feed() - .get(&hex_str_to_u256(&feed_id)?) - .await? - .context("No update found")?; + let feed_id = hex_str_to_u256(&feed_id)?; + let update_info = state.storage.latest_update_per_feed().get(&feed_id).await?.context("No update found")?; let validator_index_map: HashMap = state.hyperlane_validators_mapping.get_validators(&chain_name).context("No validators found")?; @@ -75,7 +71,7 @@ impl Calldata { proof: vec![], update_data_len: update.to_bytes().len() as u16, update_data: update.to_bytes(), - feed_id: U256::from_str(&feed_id)?, + feed_id, // TODO: publish_time is a duplicated of update timestamp - remove? publish_time: update.metadata.timestamp, }; diff --git a/solidity/test/PragmaDecoder.t.sol b/solidity/test/PragmaDecoder.t.sol index 64d6bd81..3a67a8f1 100644 --- a/solidity/test/PragmaDecoder.t.sol +++ b/solidity/test/PragmaDecoder.t.sol @@ -37,7 +37,7 @@ contract PragmaHarnessTest is Test { setupRaw(); // encoded update bytes memory encodedUpdate = - hex"010000017003010084c952cde2a8b15194c9f60982a25399df800bf046f8984acef7e389cb2072ec23ac617442547a115cc69f038225bd36ceb1f748a8d8698f35de2110729d5f9a1b0003c4d1000000000000000000611a3d0060240f2bccef7e64f920eec05c5bfffbc48c6ceaa4efca8748772b60cbafc30536953cdd0dd5b8e24428e4fb6eab5c143daba15f62b24606e50d822508faef2bdfc6c6de418348c73cf78541d8f09c53e6f5eb56ef35a4db5b52e4919f302f0003c4d18660df2e348a6b5322d034079fc498a749263d71ba47a7acb222e3edece8eca901006b000000000000000000004c5553442f555344000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c5553442f5553440000000000000000"; + hex"010000017003010002c8960ad17eddf3ec435aea12d031c6a6298e5c8e786550c1238fb423a4f5661455ef5cac013d6cc34a4ce472ba2031cb2ae84dfd35d0ecd0b51b4d437dc0b81b0003c638000000000000000000611a3d0060240f2bccef7e64f920eec05c5bfffbc48c6ceaa4efca8748772b60cbafc30536953cdd0dd5b8e24428e4fb6eab5c143daba15f62b24606e50d822508faefff8c9ddbc7988bf343935dd1f19da8e03cccc7e63ae3cccadc04a64c9e6b79750003c638e03cccfc78838eafd29d5868d9e2333c684d10828874c31b7dbc01869ec98c2001006b000000000000000000004c5553442f555344000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c5553442f5553440000000000000000"; uint8 numUpdates = pragmaHarness.exposed_updateDataInfoFromUpdate(encodedUpdate); assertEq(numUpdates, 1, "Number of updates should be 1"); } From 66b53405aaa85dc9b8b182c2ad6128faae70ee14 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 18:27:30 +0100 Subject: [PATCH 32/55] =?UTF-8?q?dev(better=5Ftheoros):=20=F0=9F=94=A8=20n?= =?UTF-8?q?itpicking=20optis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/theoros/src/rpc/evm/mod.rs | 4 ++-- rust/theoros/src/types/calldata.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index ecc159d0..9ea948a7 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -32,8 +32,8 @@ impl HyperlaneValidatorsMapping { } /// Get the available validators for a chain & their indexes - pub fn get_validators(&self, chain_name: &EvmChainName) -> Option> { - self.0.get(chain_name).cloned() + pub fn get_validators(&self, chain_name: &EvmChainName) -> Option<&HashMap> { + self.0.get(chain_name) } /// Get all configured chains names diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index 424d5fda..ca5cd37e 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, str::FromStr}; +use std::str::FromStr; use alloy::{primitives::U256, signers::Signature}; use anyhow::Context; @@ -36,7 +36,7 @@ impl Calldata { let feed_id = hex_str_to_u256(&feed_id)?; let update_info = state.storage.latest_update_per_feed().get(&feed_id).await?.context("No update found")?; - let validator_index_map: HashMap = + let validator_index_map = state.hyperlane_validators_mapping.get_validators(&chain_name).context("No validators found")?; let validators: Vec = validator_index_map.keys().copied().collect(); From 8172260eebe536a3bb09f84659b4161c69c9a312 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 19:14:30 +0100 Subject: [PATCH 33/55] dev(better_theoros): supports N datafeeds + returns N calldata ! --- .../theoros/src/handlers/rest/get_calldata.rs | 87 +++++--- .../websocket/subscribe_to_calldata.rs | 203 ++++++++++-------- rust/theoros/src/services/api/router.rs | 4 +- rust/theoros/src/storage/checkpoints.rs | 2 +- rust/theoros/src/storage/feed_id.rs | 6 - 5 files changed, 168 insertions(+), 134 deletions(-) diff --git a/rust/theoros/src/handlers/rest/get_calldata.rs b/rust/theoros/src/handlers/rest/get_calldata.rs index 61927856..64435089 100644 --- a/rust/theoros/src/handlers/rest/get_calldata.rs +++ b/rust/theoros/src/handlers/rest/get_calldata.rs @@ -1,66 +1,89 @@ use std::str::FromStr; use alloy::hex; -use axum::extract::{Query, State}; -use axum::Json; +use axum::{ + extract::{Query, State}, + Json, +}; use serde::{Deserialize, Serialize}; use utoipa::{IntoParams, ToResponse, ToSchema}; -use crate::configs::evm_config::EvmChainName; -use crate::errors::GetCalldataError; -use crate::extractors::PathExtractor; -use crate::types::calldata::{AsCalldata, Calldata}; -use crate::AppState; +use crate::{ + configs::evm_config::EvmChainName, + errors::GetCalldataError, + types::calldata::{AsCalldata, Calldata}, + AppState, +}; -#[derive(Default, Deserialize, IntoParams, ToSchema)] -pub struct GetCalldataQuery {} +#[derive(Deserialize, IntoParams, ToSchema)] +pub struct GetCalldataQuery { + pub chain: String, + #[serde(deserialize_with = "deserialize_feed_ids")] + pub feed_ids: Vec, +} #[derive(Debug, Serialize, Deserialize, ToResponse, ToSchema)] pub struct GetCalldataResponse { - pub calldata: Calldata, + pub feed_id: String, pub encoded_calldata: String, } #[utoipa::path( get, - path = "/v1/calldata/{chain_name}/{feed_id}", + path = "/v1/calldata", + params( + GetCalldataQuery + ), responses( ( status = 200, - description = "Constructs the calldata used to update the feed id specified", + description = "Constructs the calldata used to update the specified feed IDs", body = [GetCalldataResponse] ), ( status = 404, - description = "Unknown Feed Id", - body = [GetCalldataError] + description = "Unknown Feed ID", + body = GetCalldataError ) ), - params( - GetCalldataQuery - ), )] pub async fn get_calldata( State(state): State, - PathExtractor(path_args): PathExtractor<(String, String)>, - Query(_params): Query, -) -> Result, GetCalldataError> { + Query(params): Query, +) -> Result>, GetCalldataError> { let started_at = std::time::Instant::now(); - let (raw_chain_name, feed_id) = path_args; - let chain_name = EvmChainName::from_str(&raw_chain_name) - .map_err(|_| GetCalldataError::ChainNotSupported(raw_chain_name.clone()))?; + + let chain_name = + EvmChainName::from_str(¶ms.chain).map_err(|_| GetCalldataError::ChainNotSupported(params.chain.clone()))?; let stored_feed_ids = state.storage.feed_ids(); - if !stored_feed_ids.contains(&feed_id).await { - return Err(GetCalldataError::FeedNotFound(feed_id)); - }; - let calldata = Calldata::build_from(&state, chain_name, feed_id) - .await - .map_err(|e| GetCalldataError::CalldataError(e.to_string()))?; + // Check if all requested feed IDs are supported. + if let Some(missing_id) = stored_feed_ids.contains_vec(¶ms.feed_ids).await { + return Err(GetCalldataError::FeedNotFound(missing_id)); + } + + // Build calldata for each feed ID. + let mut responses = Vec::with_capacity(params.feed_ids.len()); + for feed_id in ¶ms.feed_ids { + let calldata = Calldata::build_from(&state, chain_name, feed_id.clone()) + .await + .map_err(|e| GetCalldataError::CalldataError(e.to_string()))?; + + let response = + GetCalldataResponse { feed_id: feed_id.clone(), encoded_calldata: hex::encode(calldata.as_bytes()) }; + responses.push(response); + } - let response = - GetCalldataResponse { calldata: calldata.clone(), encoded_calldata: hex::encode(calldata.as_bytes()) }; tracing::info!("🌐 get_calldata - {:?}", started_at.elapsed()); - Ok(Json(response)) + Ok(Json(responses)) +} + +/// Deserialize a list of feed ids "A, B, C" into a Vec = [A, B, C]. +fn deserialize_feed_ids<'de, D>(deserializer: D) -> Result, D::Error> +where + D: serde::Deserializer<'de>, +{ + let s: String = String::deserialize(deserializer)?; + Ok(s.split(',').map(|s| s.trim().to_string()).collect()) } diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index 138708af..b7031294 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -5,7 +5,7 @@ use std::{ }; use alloy::hex; -use anyhow::{anyhow, Result}; +use anyhow::Result; use axum::{ extract::{ ws::{Message, WebSocket, WebSocketUpgrade}, @@ -21,14 +21,16 @@ use serde::{Deserialize, Serialize}; use tokio::sync::broadcast::Receiver; use utoipa::ToSchema; -use crate::constants::{MAX_CLIENT_MESSAGE_SIZE, PING_INTERVAL_DURATION}; -use crate::types::calldata::AsCalldata; -use crate::types::hyperlane::NewUpdatesAvailableEvent; -use crate::AppState; -use crate::{configs::evm_config::EvmChainName, types::calldata::Calldata}; +use crate::{ + configs::evm_config::EvmChainName, + constants::{MAX_CLIENT_MESSAGE_SIZE, PING_INTERVAL_DURATION}, + types::{ + calldata::{AsCalldata, Calldata}, + hyperlane::NewUpdatesAvailableEvent, + }, + AppState, +}; -// TODO: add config for the client -/// Configuration for a specific data feed. #[derive(Clone)] pub struct DataFeedClientConfig {} @@ -45,9 +47,7 @@ enum ClientMessage { pub struct RpcDataFeed { pub feed_id: String, /// The calldata binary represented as a hex string. - #[serde(skip_serializing_if = "Option::is_none")] - #[schema(value_type = Option)] - pub encoded_calldata: Option, + pub encoded_calldata: String, } #[derive(Serialize, Debug, Clone)] @@ -56,7 +56,7 @@ enum ServerMessage { #[serde(rename = "response")] Response(ServerResponseMessage), #[serde(rename = "data_feed_update")] - DataFeedUpdate { data_feed: RpcDataFeed }, + DataFeedUpdate { data_feeds: Vec }, } #[derive(Serialize, Debug, Clone)] @@ -68,6 +68,10 @@ enum ServerResponseMessage { Err { error: String }, } +/// WebSocket route handler. +/// +/// Upgrades the HTTP connection to a WebSocket connection and spawns a new +/// subscriber to handle incoming and outgoing messages. pub async fn ws_route_handler( ws: WebSocketUpgrade, AxumState(state): AxumState, @@ -76,6 +80,7 @@ pub async fn ws_route_handler( ws.max_message_size(MAX_CLIENT_MESSAGE_SIZE).on_upgrade(move |socket| websocket_handler(socket, state)) } +/// Handles the WebSocket connection for a single client. #[tracing::instrument(skip(stream, state))] async fn websocket_handler(stream: WebSocket, state: AppState) { let ws_state = state.ws.clone(); @@ -90,6 +95,10 @@ async fn websocket_handler(stream: WebSocket, state: AppState) { pub type SubscriberId = usize; +/// Represents a client connected via WebSocket. +/// +/// Manages subscriptions to data feeds, handles incoming client messages, +/// and sends updates to the client. pub struct Subscriber { id: SubscriberId, closed: bool, @@ -104,6 +113,7 @@ pub struct Subscriber { } impl Subscriber { + /// Creates a new `Subscriber` instance. pub fn new( id: SubscriberId, state: Arc, @@ -125,33 +135,42 @@ impl Subscriber { } } + /// Runs the subscriber event loop, handling messages and updates. #[tracing::instrument(skip(self))] pub async fn run(&mut self) { while !self.closed { if let Err(e) = self.handle_next().await { - tracing::error!(subscriber = self.id, error = ?e, "Error Handling Subscriber Message."); + tracing::error!( + subscriber = self.id, + error = ?e, + "Error handling subscriber message." + ); break; } } } + /// Handles the next event, whether it's an incoming message, a data feed update, or a ping. async fn handle_next(&mut self) -> Result<()> { tokio::select! { - maybe_update_feeds_event = self.feeds_receiver.recv() => { - match maybe_update_feeds_event { + maybe_update = self.feeds_receiver.recv() => { + match maybe_update { Ok(_) => self.handle_data_feeds_update().await, - Err(e) => Err(anyhow!("Failed to receive update from store: {:?}", e)), + Err(e) => anyhow::bail!("Failed to receive update from store: {:?}", e), } }, - maybe_message_or_err = self.receiver.next() => { - self.handle_client_message( - maybe_message_or_err.ok_or(anyhow!("Client channel is closed"))?? - ).await - }, - _ = self.ping_interval.tick() => { - if !self.responded_to_ping { - return Err(anyhow!("Subscriber did not respond to ping. Closing connection.")); + maybe_message = self.receiver.next() => { + match maybe_message { + Some(Ok(message)) => self.handle_client_message(message).await, + Some(Err(e)) => anyhow::bail!("WebSocket error: {:?}", e), + None => { + self.closed = true; + Ok(()) + } } + }, + _ = self.ping_interval.tick() => { + anyhow::ensure!(self.responded_to_ping, "Subscriber did not respond to ping. Closing connection."); self.responded_to_ping = false; self.sender.send(Message::Ping(vec![])).await?; Ok(()) @@ -159,110 +178,108 @@ impl Subscriber { } } + /// Handles data feed updates by sending new data to the client for all subscribed feeds. async fn handle_data_feeds_update(&mut self) -> Result<()> { - if self.active_chain.is_none() { + if self.active_chain.is_none() || self.data_feeds_with_config.is_empty() { return Ok(()); } - tracing::debug!(subscriber = self.id, "Handling Data Feeds Update."); - // Retrieve the updates for subscribed feed ids at the given slot - let feed_ids = self.data_feeds_with_config.keys().cloned().collect::>(); - // TODO: add support for multiple feeds - let feed_id = feed_ids.first().unwrap(); - let calldata = - Calldata::build_from(self.state.as_ref(), self.active_chain.unwrap(), feed_id.to_owned()).await?; + tracing::debug!(subscriber = self.id, "Handling data feeds update."); + + // Retrieve the list of subscribed feed IDs. + let feed_ids: Vec = self.data_feeds_with_config.keys().cloned().collect(); + + let mut data_feeds = Vec::with_capacity(feed_ids.len()); + // Build calldata for each subscribed feed and collect them. + for feed_id in feed_ids { + match Calldata::build_from(self.state.as_ref(), self.active_chain.unwrap(), feed_id.clone()).await { + Ok(calldata) => { + data_feeds.push(RpcDataFeed { + feed_id: feed_id.clone(), + encoded_calldata: hex::encode(calldata.as_bytes()), + }); + } + Err(e) => { + tracing::error!("Error building calldata for {}: {}", feed_id, e); + } + } + } + + // Send a single update containing all data feeds. + if !data_feeds.is_empty() { + let update = ServerMessage::DataFeedUpdate { data_feeds }; + let message = serde_json::to_string(&update)?; + self.sender.send(Message::Text(message)).await?; + } - let message = serde_json::to_string(&ServerMessage::DataFeedUpdate { - data_feed: RpcDataFeed { - feed_id: feed_id.clone(), - encoded_calldata: Some(hex::encode(calldata.as_bytes())), - }, - })?; - self.sender.send(message.into()).await?; Ok(()) } + /// Processes messages received from the client. #[tracing::instrument(skip(self, message))] async fn handle_client_message(&mut self, message: Message) -> Result<()> { - let maybe_client_message = match message { + match message { Message::Close(_) => { - // Closing the connection. We don't remove it from the subscribers - // list, instead when the Subscriber struct is dropped the channel - // to subscribers list will be closed and it will eventually get - // removed. tracing::trace!(id = self.id, "πŸ“¨ [CLOSE]"); - - // Send the close message to gracefully shut down the connection - // Otherwise the client might get an abnormal Websocket closure - // error. self.sender.close().await?; self.closed = true; - return Ok(()); + Ok(()) } - Message::Text(text) => serde_json::from_str::(&text), - Message::Binary(data) => serde_json::from_slice::(&data), - Message::Ping(_) => { - // Axum will send Pong automatically - return Ok(()); + Message::Text(text) => self.process_client_message(&text).await, + Message::Binary(data) => { + let text = String::from_utf8(data)?; + self.process_client_message(&text).await } + Message::Ping(_) => Ok(()), // Axum handles PONG responses automatically. Message::Pong(_) => { self.responded_to_ping = true; - return Ok(()); + Ok(()) } - }; + } + } - match maybe_client_message { + /// Parses and processes a client message in text format. + async fn process_client_message(&mut self, text: &str) -> Result<()> { + let client_message: ClientMessage = match serde_json::from_str(text) { + Ok(msg) => msg, Err(e) => { - tracing::error!("πŸ˜Άβ€πŸŒ«οΈ Client disconnected/error occurred. Closing the channel."); - self.sender - .send( - serde_json::to_string(&ServerMessage::Response(ServerResponseMessage::Err { - error: e.to_string(), - }))? - .into(), - ) - .await?; + tracing::error!("Invalid client message format: {}", e); + let message = ServerMessage::Response(ServerResponseMessage::Err { error: e.to_string() }); + self.sender.send(Message::Text(serde_json::to_string(&message)?)).await?; return Ok(()); } + }; - Ok(ClientMessage::Subscribe { ids: feed_ids, chain_name }) => { + match client_message { + ClientMessage::Subscribe { ids, chain_name } => { let stored_feed_ids = self.state.storage.feed_ids(); - // If there is a single feed id that is not found, we don't subscribe to any of the - // asked feed ids and return an error to be more explicit and clear. - match stored_feed_ids.contains_vec(&feed_ids).await { - // TODO: return multiple missing ids - Some(missing_id) => { - self.sender - .send( - serde_json::to_string(&ServerMessage::Response(ServerResponseMessage::Err { - error: format!("Can't subscribe: at least one of the requested feed ids is not supported ({:?})", missing_id), - }))? - .into(), - ) - .await?; - return Ok(()); - } - None => { - for feed_id in feed_ids { - self.data_feeds_with_config.insert(feed_id, DataFeedClientConfig {}); - // TODO: Assert that the chain is supported by theoros - self.active_chain = Some(chain_name); - } - } + // Check if all requested feed IDs are supported. + if let Some(missing_id) = stored_feed_ids.contains_vec(&ids).await { + let message = ServerResponseMessage::Err { + error: format!("Can't subscribe: feed ID not supported ({:?})", missing_id), + }; + self.sender.send(Message::Text(serde_json::to_string(&ServerMessage::Response(message))?)).await?; + return Ok(()); + } + + // Subscribe to the requested feed IDs. + self.active_chain = Some(chain_name); + for feed_id in ids { + self.data_feeds_with_config.insert(feed_id, DataFeedClientConfig {}); } } - Ok(ClientMessage::Unsubscribe { ids: feed_ids }) => { - for feed_id in feed_ids { + ClientMessage::Unsubscribe { ids } => { + for feed_id in ids { self.data_feeds_with_config.remove(&feed_id); } } } + // Acknowledge the successful processing of the client message. self.sender - .send(serde_json::to_string(&ServerMessage::Response(ServerResponseMessage::Success))?.into()) + .send(Message::Text(serde_json::to_string(&ServerMessage::Response(ServerResponseMessage::Success))?)) .await?; - Ok(()) } } diff --git a/rust/theoros/src/services/api/router.rs b/rust/theoros/src/services/api/router.rs index 67e54182..9a5d9c90 100644 --- a/rust/theoros/src/services/api/router.rs +++ b/rust/theoros/src/services/api/router.rs @@ -37,11 +37,11 @@ async fn handler_404() -> impl IntoResponse { } fn ws_route(state: AppState) -> Router { - Router::new().route("/ws", get(ws_route_handler)).with_state(state) + Router::new().route("/ws/calldata", get(ws_route_handler)).with_state(state) } fn calldata_routes(state: AppState) -> Router { - Router::new().route("/calldata/:chain_name/:feed_id", get(get_calldata)).with_state(state) + Router::new().route("/calldata", get(get_calldata)).with_state(state) } fn data_feeds_routes(state: AppState) -> Router { diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index 6089cd53..f2092605 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -58,7 +58,7 @@ impl SignedCheckpointsStorage { pub async fn get(&self, validators: &[Felt], searched_nonce: u32) -> Vec<(Felt, SignedCheckpointWithMessageId)> { let lock = self.0.read().await; - let mut checkpoints = Vec::new(); + let mut checkpoints = Vec::with_capacity(lock.len()); // Iterate over the map with tuple key (validator, message_id) for ((validator, nonce), checkpoint) in lock.iter() { // Only include if validator is in the provided list and message_id matches diff --git a/rust/theoros/src/storage/feed_id.rs b/rust/theoros/src/storage/feed_id.rs index a1fe8733..6195470a 100644 --- a/rust/theoros/src/storage/feed_id.rs +++ b/rust/theoros/src/storage/feed_id.rs @@ -21,12 +21,6 @@ impl FeedIdsStorage { lock.remove(feed_id); } - /// Checks if the storage contains the given feed ID. - pub async fn contains(&self, feed_id: &str) -> bool { - let lock = self.0.read().await; - lock.contains(feed_id) - } - /// Checks if all feed IDs in the given vector are present in the storage. /// Returns None if all IDs are present, or Some(id) with the first missing ID. pub async fn contains_vec(&self, feed_ids: &[String]) -> Option { From 2ff669939615dbfc6290295a4a3a5b3fe34b2529 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 19:21:21 +0100 Subject: [PATCH 34/55] dev(better_theoros): Updated openapi specs --- rust/theoros/openapi.json | 155 ++++++++++-------- .../theoros/src/handlers/rest/get_calldata.rs | 10 +- 2 files changed, 95 insertions(+), 70 deletions(-) diff --git a/rust/theoros/openapi.json b/rust/theoros/openapi.json index 42f5dde3..af969707 100644 --- a/rust/theoros/openapi.json +++ b/rust/theoros/openapi.json @@ -9,16 +9,34 @@ "version": "0.1.0" }, "paths": { - "/v1/calldata/{chain_name}/{feed_id}": { + "/v1/calldata": { "get": { - "tags": [ - "crate::handlers::get_calldata" - ], + "tags": ["crate::handlers::rest::get_calldata"], "operationId": "get_calldata", - "parameters": [], + "parameters": [ + { + "name": "chain", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "feed_ids", + "in": "query", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], "responses": { "200": { - "description": "Constructs the calldata used to update the feed id specified", + "description": "Constructs the calldata used to update the specified feed IDs", "content": { "application/json": { "schema": { @@ -31,14 +49,11 @@ } }, "404": { - "description": "Unknown Feed Id", + "description": "Unknown Feed ID", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GetCalldataError" - } + "$ref": "#/components/schemas/GetCalldataError" } } } @@ -48,9 +63,7 @@ }, "/v1/chains": { "get": { - "tags": [ - "crate::handlers::get_chains" - ], + "tags": ["crate::handlers::rest::get_chains"], "operationId": "get_chains", "responses": { "200": { @@ -71,9 +84,7 @@ }, "/v1/data_feeds": { "get": { - "tags": [ - "crate::handlers::get_data_feeds" - ], + "tags": ["crate::handlers::rest::get_data_feeds"], "operationId": "get_data_feeds", "responses": { "200": { @@ -95,37 +106,39 @@ }, "components": { "schemas": { + "CalldataResponse": { + "type": "object", + "required": ["feed_id", "encoded_calldata"], + "properties": { + "encoded_calldata": { + "type": "string" + }, + "feed_id": { + "type": "string" + } + } + }, "GetCalldataError": { "oneOf": [ { "type": "string", - "enum": [ - "InternalServerError" - ] + "enum": ["InternalServerError"] }, { "type": "string", - "enum": [ - "DatabaseConnection" - ] + "enum": ["DatabaseConnection"] }, { "type": "string", - "enum": [ - "InvalidFeedId" - ] + "enum": ["InvalidFeedId"] }, { "type": "string", - "enum": [ - "DispatchNotFound" - ] + "enum": ["DispatchNotFound"] }, { "type": "object", - "required": [ - "FeedNotFound" - ], + "required": ["FeedNotFound"], "properties": { "FeedNotFound": { "type": "string" @@ -134,54 +147,54 @@ }, { "type": "string", - "enum": [ - "FailedToCreateHyperlaneClient" - ] + "enum": ["FailedToCreateHyperlaneClient"] }, { "type": "string", - "enum": [ - "FailedToFetchOnchainValidators" - ] + "enum": ["FailedToFetchOnchainValidators"] }, { "type": "string", - "enum": [ - "ValidatorNotFound" - ] + "enum": ["ValidatorNotFound"] }, { "type": "object", - "required": [ - "ChainNotSupported" - ], + "required": ["ChainNotSupported"], "properties": { "ChainNotSupported": { "type": "string" } } + }, + { + "type": "object", + "required": ["CalldataError"], + "properties": { + "CalldataError": { + "type": "string" + } + } } ] }, "GetCalldataQuery": { - "type": "object" - }, - "GetCalldataResponse": { "type": "object", - "required": [ - "calldata" - ], + "required": ["chain", "feed_ids"], "properties": { - "calldata": { + "chain": { "type": "string" + }, + "feed_ids": { + "type": "array", + "items": { + "type": "string" + } } } }, "GetChainsError": { "type": "string", - "enum": [ - "InternalServerError" - ] + "enum": ["InternalServerError"] }, "GetChainsResponse": { "type": "array", @@ -193,9 +206,7 @@ "oneOf": [ { "type": "object", - "required": [ - "ParsingFeedId" - ], + "required": ["ParsingFeedId"], "properties": { "ParsingFeedId": { "type": "string" @@ -204,9 +215,7 @@ }, { "type": "string", - "enum": [ - "InternalServerError" - ] + "enum": ["InternalServerError"] } ] }, @@ -215,20 +224,34 @@ "items": { "$ref": "#/components/schemas/Feed" } + }, + "RpcDataFeed": { + "type": "object", + "required": ["feed_id", "encoded_calldata"], + "properties": { + "encoded_calldata": { + "type": "string", + "description": "The calldata binary represented as a hex string." + }, + "feed_id": { + "type": "string" + } + } } }, "responses": { - "GetCalldataResponse": { + "CalldataResponse": { "description": "", "content": { "application/json": { "schema": { "type": "object", - "required": [ - "calldata" - ], + "required": ["feed_id", "encoded_calldata"], "properties": { - "calldata": { + "encoded_calldata": { + "type": "string" + }, + "feed_id": { "type": "string" } } @@ -270,4 +293,4 @@ "description": "Theoros - The Pragma Consultant" } ] -} \ No newline at end of file +} diff --git a/rust/theoros/src/handlers/rest/get_calldata.rs b/rust/theoros/src/handlers/rest/get_calldata.rs index 64435089..a74f2450 100644 --- a/rust/theoros/src/handlers/rest/get_calldata.rs +++ b/rust/theoros/src/handlers/rest/get_calldata.rs @@ -23,11 +23,13 @@ pub struct GetCalldataQuery { } #[derive(Debug, Serialize, Deserialize, ToResponse, ToSchema)] -pub struct GetCalldataResponse { +pub struct CalldataResponse { pub feed_id: String, pub encoded_calldata: String, } +pub type GetCalldataResponse = Vec; + #[utoipa::path( get, path = "/v1/calldata", @@ -50,7 +52,7 @@ pub struct GetCalldataResponse { pub async fn get_calldata( State(state): State, Query(params): Query, -) -> Result>, GetCalldataError> { +) -> Result, GetCalldataError> { let started_at = std::time::Instant::now(); let chain_name = @@ -64,14 +66,14 @@ pub async fn get_calldata( } // Build calldata for each feed ID. - let mut responses = Vec::with_capacity(params.feed_ids.len()); + let mut responses: GetCalldataResponse = Vec::with_capacity(params.feed_ids.len()); for feed_id in ¶ms.feed_ids { let calldata = Calldata::build_from(&state, chain_name, feed_id.clone()) .await .map_err(|e| GetCalldataError::CalldataError(e.to_string()))?; let response = - GetCalldataResponse { feed_id: feed_id.clone(), encoded_calldata: hex::encode(calldata.as_bytes()) }; + CalldataResponse { feed_id: feed_id.clone(), encoded_calldata: hex::encode(calldata.as_bytes()) }; responses.push(response); } From 3623e5dea5d43ed4dce63833c1f0ba0ddad7d1bd Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 19:36:39 +0100 Subject: [PATCH 35/55] dev(better_theoros): Send error to ws client --- .../websocket/subscribe_to_calldata.rs | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index b7031294..56dc81f1 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -38,9 +38,9 @@ pub struct DataFeedClientConfig {} #[serde(tag = "type")] enum ClientMessage { #[serde(rename = "subscribe")] - Subscribe { ids: Vec, chain_name: EvmChainName }, + Subscribe { feed_ids: Vec, chain: EvmChainName }, #[serde(rename = "unsubscribe")] - Unsubscribe { ids: Vec }, + Unsubscribe { feed_ids: Vec }, } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] @@ -200,7 +200,7 @@ impl Subscriber { }); } Err(e) => { - tracing::error!("Error building calldata for {}: {}", feed_id, e); + self.send_error_to_client(format!("Error building calldata for {}: {}", feed_id, e)).await?; } } } @@ -243,34 +243,30 @@ impl Subscriber { let client_message: ClientMessage = match serde_json::from_str(text) { Ok(msg) => msg, Err(e) => { - tracing::error!("Invalid client message format: {}", e); - let message = ServerMessage::Response(ServerResponseMessage::Err { error: e.to_string() }); - self.sender.send(Message::Text(serde_json::to_string(&message)?)).await?; + self.send_error_to_client(e.to_string()).await?; return Ok(()); } }; match client_message { - ClientMessage::Subscribe { ids, chain_name } => { + ClientMessage::Subscribe { feed_ids, chain } => { let stored_feed_ids = self.state.storage.feed_ids(); // Check if all requested feed IDs are supported. - if let Some(missing_id) = stored_feed_ids.contains_vec(&ids).await { - let message = ServerResponseMessage::Err { - error: format!("Can't subscribe: feed ID not supported ({:?})", missing_id), - }; - self.sender.send(Message::Text(serde_json::to_string(&ServerMessage::Response(message))?)).await?; + if let Some(missing_id) = stored_feed_ids.contains_vec(&feed_ids).await { + self.send_error_to_client(format!("Can't subscribe: feed ID not supported {:}", missing_id)) + .await?; return Ok(()); } // Subscribe to the requested feed IDs. - self.active_chain = Some(chain_name); - for feed_id in ids { + self.active_chain = Some(chain); + for feed_id in feed_ids { self.data_feeds_with_config.insert(feed_id, DataFeedClientConfig {}); } } - ClientMessage::Unsubscribe { ids } => { - for feed_id in ids { + ClientMessage::Unsubscribe { feed_ids } => { + for feed_id in feed_ids { self.data_feeds_with_config.remove(&feed_id); } } @@ -282,4 +278,10 @@ impl Subscriber { .await?; Ok(()) } + + async fn send_error_to_client(&mut self, msg: String) -> anyhow::Result<()> { + let message = ServerResponseMessage::Err { error: msg }; + self.sender.send(Message::Text(serde_json::to_string(&ServerMessage::Response(message))?)).await?; + Ok(()) + } } From 7478b5a0c18d355941132dc8255225f529e11387 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 19:45:56 +0100 Subject: [PATCH 36/55] =?UTF-8?q?dev(better=5Ftheoros):=20=E2=9C=85=20Webs?= =?UTF-8?q?ocket=20finished?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/theoros/src/configs/evm_config.rs | 2 +- .../websocket/subscribe_to_calldata.rs | 21 ++++++++++--------- rust/theoros/src/rpc/evm/mod.rs | 5 +++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/rust/theoros/src/configs/evm_config.rs b/rust/theoros/src/configs/evm_config.rs index 699d961b..5448d519 100644 --- a/rust/theoros/src/configs/evm_config.rs +++ b/rust/theoros/src/configs/evm_config.rs @@ -10,7 +10,7 @@ pub const DEFAULT_CONFIG_PATH: &str = "evm_config.yaml"; /// Supported Chain identifiers // Must reflect the EVM chains here: // https://github.com/astraly-labs/pragma-monorepo/blob/main/typescript/pragma-utils/src/chains.ts -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, EnumString)] +#[derive(Debug, strum_macros::Display, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, EnumString)] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] #[strum(ascii_case_insensitive)] diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index 56dc81f1..c4a14cb9 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -139,14 +139,7 @@ impl Subscriber { #[tracing::instrument(skip(self))] pub async fn run(&mut self) { while !self.closed { - if let Err(e) = self.handle_next().await { - tracing::error!( - subscriber = self.id, - error = ?e, - "Error handling subscriber message." - ); - break; - } + let _ = self.handle_next().await; } } @@ -250,9 +243,17 @@ impl Subscriber { match client_message { ClientMessage::Subscribe { feed_ids, chain } => { - let stored_feed_ids = self.state.storage.feed_ids(); - + // Check if the chain is supported + if !self.state.hyperlane_validators_mapping.is_supported_chain(&chain) { + self.send_error_to_client(format!( + "The chain {} is not supported. Call /v1/chains to know the chains supported by Theoros.", + chain, + )) + .await?; + return Ok(()); + } // Check if all requested feed IDs are supported. + let stored_feed_ids = self.state.storage.feed_ids(); if let Some(missing_id) = stored_feed_ids.contains_vec(&feed_ids).await { self.send_error_to_client(format!("Can't subscribe: feed ID not supported {:}", missing_id)) .await?; diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index 9ea948a7..41476d41 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -40,4 +40,9 @@ impl HyperlaneValidatorsMapping { pub fn chain_names(&self) -> Vec { self.0.keys().cloned().collect() } + + /// Check if the provided chain is supported + pub fn is_supported_chain(&self, chain: &EvmChainName) -> bool { + self.0.contains_key(chain) + } } From 312734e995b29a8b95384b0b51df7b25ac8210d2 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 19:56:18 +0100 Subject: [PATCH 37/55] dev(better_theoros): Fixed loop --- rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs index c4a14cb9..053a30f6 100644 --- a/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs +++ b/rust/theoros/src/handlers/websocket/subscribe_to_calldata.rs @@ -139,7 +139,9 @@ impl Subscriber { #[tracing::instrument(skip(self))] pub async fn run(&mut self) { while !self.closed { - let _ = self.handle_next().await; + if self.handle_next().await.is_err() { + break; + } } } From 6561565acd59b22d5052ddf008446afbc1839e58 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 20:38:47 +0100 Subject: [PATCH 38/55] dev(better_theoros): Fixed js script to update EVM feeds --- monorepo.code-workspace | 4 - rust/Cargo.lock | 4 +- rust/pragma-feeds/Cargo.toml | 2 +- rust/pragma-utils/Cargo.toml | 2 +- typescript/pragma-scripts/bun.lockb | Bin 29212 -> 31495 bytes typescript/pragma-scripts/package-lock.json | 109 ++++++++++++++++-- typescript/pragma-scripts/package.json | 5 +- .../pragma-scripts/src/pragma/update_feed.ts | 76 +++++++----- 8 files changed, 152 insertions(+), 50 deletions(-) diff --git a/monorepo.code-workspace b/monorepo.code-workspace index 0fc0556d..e2216143 100644 --- a/monorepo.code-workspace +++ b/monorepo.code-workspace @@ -12,10 +12,6 @@ "name": "theoros", "path": "rust/theoros", }, - { - "name": "pragma-cli", - "path": "rust/pragma-cli", - }, { "name": "pragma-utils", "path": "rust/pragma-utils", diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 0b18362c..52a1f988 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -3191,7 +3191,7 @@ dependencies = [ [[package]] name = "pragma-feeds" -version = "0.1.0" +version = "1.0.0" dependencies = [ "anyhow", "hex", @@ -3202,7 +3202,7 @@ dependencies = [ [[package]] name = "pragma-utils" -version = "0.1.0" +version = "1.0.0" dependencies = [ "alloy", "anyhow", diff --git a/rust/pragma-feeds/Cargo.toml b/rust/pragma-feeds/Cargo.toml index 4a78aaef..db0c0799 100644 --- a/rust/pragma-feeds/Cargo.toml +++ b/rust/pragma-feeds/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pragma-feeds" -version = "0.1.0" +version = "1.0.0" edition = "2021" [dependencies] diff --git a/rust/pragma-utils/Cargo.toml b/rust/pragma-utils/Cargo.toml index 23149b15..cd43d24a 100644 --- a/rust/pragma-utils/Cargo.toml +++ b/rust/pragma-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pragma-utils" -version = "0.1.0" +version = "1.0.0" edition = "2021" [dependencies] diff --git a/typescript/pragma-scripts/bun.lockb b/typescript/pragma-scripts/bun.lockb index f924019b5a84dad4927d8433412f9a6231544ae2..a0e56744c94438d81cb7b6472c2b16e874ce589c 100755 GIT binary patch delta 3957 zcmeHKdr(y86~Ff`4;KV{AiFCftJW8?3kxjELl;rxWsqk;#UQT*QDJd+9R!RJ6Rj}` zil1RblTm|MwWcWBm}H<@#xv~GZlRE8=A2)R9&Fm7N zz&9|3U{pCKEx}9_)G{zl?lqRX*9HZ=7hFfAcf;(CHZeB0KCH z!@tCOonxf$Auq|8(uu8c(ed9{%Uoi-q@I{}HjEN>+*3EY3fe+yf*45L&~!T6=RCss zV`|4#?$OdIh&)Z~p&6l*nxWC4JPj)Cfc66QXKP$_QW+MA%tGrMsgtHai-0DOPuS$m z0(|ts4R5y6M=za(_ZA}hj(h2Z%yH~4d=2ARfJ`qv2VXRNJVhv#_&79;yH3#iu)8w7 zu+@hJ$o0}ryKf}TCp`9HN90j;NH!&$-Y6#nNQjXPP7a_LxbXl9G3gWRJP}MXl*z9o zBSZ<%IFkTM*;K$42n0yLNSp1SXDnfFDP(2TEm*YuE2Ad4P=J`KlG^F)jO>Xrl&KxE zBMLEvH^-)mEHJa6I1W`04*i~AR#7u5-E`XfNe<_+R>T4KVF94 z1IMKT6b4F)6Ijpq>2}CVzP!B z>@Hgw{r5`=JH}7ck{HO4+T#9SN=V87a4F%`fIO=$>q$S0&)l`6YX5rv!eHLM!>d|X z`e(GscI}nDYkB3vD>oYswLOW-=sEWr-GoQ?dIK7kXd9LtsB|ygoIg`>=Ss@S89~XX z@*`Mzn7ppy&N2Vcp!|-Gx2|qa$#Abev%C24{U>9x8#d3Av8H?RHQ)6eOgvT`kr{o& zFLlcLv*DL>%XU1fcK_g`53hHBGvzDPJkJe!4T9;t-*u$rwcktLebC*}^Z31b6Tl06> zuaC`)i3?R5#tzhOlfK>V+Adf0@9tiAG(7sz*~u*zUClkApYPfeTXi*G=D{v#`&?gY?yZBj`4hj0{NtPTUEMC#vB~jUt_}2T?f85{f4piz-@(l-x$$wA zvzhOn897@U7j%~T4h)GdflUg_VOzpI*ru?Bd=k3^EkftPwAzLILiUO_hkXt0HnbF` z3D4mdvDfiTWjFCmW0ATXKAknf*2v4E=vGfbu2Ism;_7)DA=C?3V`klv^x5!!~s;4@qiwn z!#I+yN%gJ6#x33;=)g<_VgNegHGm3G19Y?S1L%kk0_cdR2jl>y zFbbgKJ(v~;IYS2|#BKK4&=9>cOldA-k~F{3)RrQpap=5Fu&UB@{2~gLf~N%%(*kHA z6ehhYN-rfL1)wsa^d$rK>Um1OhxRF>3fb=T0M?a$;@RcaaWxhAyij$hI>a_Na$e63 z^eZBr{*fm*Y1!);Mr{KI!uzPd8Wj+@pLZpo=?(QQI|W__ixQSZ_9Rmw%;K0l zYqxK!z4`kc%kRIuU~j89K`4dM&Mssr_;%}^tQZMs`eIk1PQ2A)2*;fqK_g^p?f4FG z+~URMVnH0|_)>7(^X+{!!9Udp>2`cYIKBbI0RA z!V;sYT=Z8OS67#mtzOOc7x>N^W(`sW4YR4}y=YipnKJ%|@u(riBMz=YVWSN~5CbhX zmK)X;87eJh#)>LKp~`GA84AkHs-aVBp69@z&og6q{4tHef9kOD(Pfy8dFD@54NnG| O4ma8sXU(WMFZm~fV=sOH delta 2679 zcmcImYiv|i5WeTOwCuvR^a1Rpm9~lnOS^QDcDE0<&{9iTS}c!lA6T-jMU+T{h^7vVn__4^${h3v_FVONC3seA3pv7iAt>BckeA$L6o4AeEoK2 z&OK+&oH=v)>{a#3CAH6U-$(l!21_=4QMheuxp8{dC;783A5udXzKJi`mh7M_ofPpBcVdAklKU_#{q0$2^NZ%;RK)hI`(-&MY1Ck zAtF2&8(coea%g^Nx(p}!^gXHKbO-c{sj|c!aO9?G+Fa9@GRdbmrO8S7Bu$(~z;Oz` zGWe9FB>NoW(?_+w2|m3lT}~PSy*FK)(*llx`q*Jf`+%=0tOB`&j09 z1b325P`^K$9bxGb2oUD?sl<0OeN9uiMN~f6sLP z%kr^~`G2S%GsH3VWR}5=<%9LPqp@|vFR9;I{a6|O$MUiEfAc!Jqx#`4AlK{3Qg6`j zz1e`egXZ1{x9sZykD|X2le^6CPPDx1C`CRf$Nl;bGFf_N{B}Jt{RUis0=m-b!RUN0}KD3AO$VhJ-=1MnEeQ-M(DO(E(5N-e-KtQX8|{zgkTnO7YPni9lc ze#h)CGcDFF<+lmI-Ii^pIWdh)EgHWm{D8Ird)4ojiL)_R23F39(6SO(1vCO7pb2OO zT7VS*{+lv$^BF<4>M%vs*JU~=j?b)BReUtSs{=Q6aaibG6A-255Ts~md&&# z0}lf1xO`Wp18id@0Nb{kPRPCnWX9uSt8u8U6O~H;%9QVMq1BBjy4K9u+59t%e$qoc77F z`qsQS^JiLYZ`)-hnc-;}Cs5z`zaZM{Jm+(5+&)KFUXRxdy@45v4`h4gLdXz*$L!d~juGYDwE5xAg0-DJ9qVEnI=@PeEqvnBxZeSXGHG7` diff --git a/typescript/pragma-scripts/package-lock.json b/typescript/pragma-scripts/package-lock.json index 3939119e..cc28b423 100644 --- a/typescript/pragma-scripts/package-lock.json +++ b/typescript/pragma-scripts/package-lock.json @@ -11,6 +11,7 @@ "dotenv": "^16.4.5", "ethers": "^6.13.3", "js-yaml": "^4.1.0", + "node-fetch": "^3.3.2", "pragma-utils": "file:../pragma-utils", "starknet": "^6.11.0" }, @@ -260,6 +261,14 @@ "node": ">=18" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "engines": { + "node": ">= 12" + } + }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -331,6 +340,28 @@ "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==", "license": "MIT" }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/fetch-cookie": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-3.0.1.tgz", @@ -340,6 +371,17 @@ "tough-cookie": "^4.0.0" } }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/fs-extra": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", @@ -391,6 +433,25 @@ "whatwg-fetch": "^3.4.1" } }, + "node_modules/isomorphic-fetch/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -419,23 +480,39 @@ "resolved": "https://registry.npmjs.org/lossless-json/-/lossless-json-4.0.2.tgz", "integrity": "sha512-+z0EaLi2UcWi8MZRxA5iTb6m4Ys4E80uftGY+yG5KNFJb5EceQXOhdW/pWJZ8m97s26u7yZZAYMcKWNztSZssA==" }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", "dependencies": { - "whatwg-url": "^5.0.0" + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" }, "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" } }, "node_modules/pako": { @@ -655,6 +732,14 @@ "requires-port": "^1.0.0" } }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "engines": { + "node": ">= 8" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/typescript/pragma-scripts/package.json b/typescript/pragma-scripts/package.json index 4bc3bc5a..27e32d1c 100644 --- a/typescript/pragma-scripts/package.json +++ b/typescript/pragma-scripts/package.json @@ -14,8 +14,9 @@ "dotenv": "^16.4.5", "ethers": "^6.13.3", "js-yaml": "^4.1.0", - "starknet": "^6.11.0", - "pragma-utils": "file:../pragma-utils" + "node-fetch": "^3.3.2", + "pragma-utils": "file:../pragma-utils", + "starknet": "^6.11.0" }, "scripts": { "generate_feed_id": "bun run src/generate_feed_id.ts", diff --git a/typescript/pragma-scripts/src/pragma/update_feed.ts b/typescript/pragma-scripts/src/pragma/update_feed.ts index 7c3389f4..2b39252e 100644 --- a/typescript/pragma-scripts/src/pragma/update_feed.ts +++ b/typescript/pragma-scripts/src/pragma/update_feed.ts @@ -1,9 +1,10 @@ import { Command, type OptionValues } from "commander"; -import { ethers } from "ethers"; +import { encodeBytes32String, ethers, getBytes, solidityPacked } from "ethers"; import dotenv from "dotenv"; import { getDeployedAddress } from "pragma-utils"; +import fetch from "node-fetch"; -const PRAGMA_SOL_ABI_PATH = "../../../solidity/out/Pragma.sol/Pragma.json"; +const PRAGMA_SOL_ABI_PATH = "../../../../solidity/out/Pragma.sol/Pragma.json"; dotenv.config(); const RPC_URL = process.env.RPC_URL; @@ -11,6 +12,10 @@ if (!RPC_URL) { throw new Error("RPC URL not set in .env file"); } +function snakeToCamel(s: string): string { + return s.replace(/_([a-z])/g, (g) => g[1].toUpperCase()); +} + function parseCommandLineArguments(): OptionValues { const program = new Command(); @@ -23,9 +28,9 @@ function parseCommandLineArguments(): OptionValues { ) .requiredOption("--feed-id ", "ID of the feed to update") .option( - "--theoros-endpoint ", - "Theoros endpoint URL", - "https://theoros.pragma.build/", + "--theoros-url ", + "Theoros URL", + "https://theoros.pragma.build", ) .parse(process.argv); @@ -36,14 +41,14 @@ function parseCommandLineArguments(): OptionValues { process.exit(1); } - if (!Number.isInteger(Number(options.feedId))) { - console.error("Error: Feed ID must be an integer"); + if (!options.feedId || typeof options.feedId !== "string") { + console.error("Error: Feed ID must be a valid string"); process.exit(1); } - if (options.theorosEndpoint) { + if (options.theorosUrl) { try { - new URL(options.theorosEndpoint); + new URL(options.theorosUrl); } catch (error) { console.error("Error: The Theoros endpoint URL is not valid"); process.exit(1); @@ -54,11 +59,13 @@ function parseCommandLineArguments(): OptionValues { } async function getCalldataFromTheoros( - theorosEndpoint: string, - feedId: string, -): Promise { + theorosUrl: string, + chain: string, + feedIds: string[], +): Promise { try { - const url = `${theorosEndpoint}/v1/calldata/${feedId}`; + const feedIdsParam = feedIds.join(","); + const url = `${theorosUrl}/v1/calldata?chain=${chain}&feed_ids=${feedIdsParam}`; console.log(`Fetching calldata from: ${url}`); const response = await fetch(url); @@ -69,15 +76,24 @@ async function getCalldataFromTheoros( const data = await response.json(); - // Assuming that we retrieve calldata as hex string from theoros - // TODO: change this part with real calldata from theoros - if (!data.calldata || typeof data.calldata !== "string") { - throw new Error("Invalid response format: calldata missing or invalid"); + if (!Array.isArray(data) || data.length === 0) { + throw new Error("Invalid response format: data is not a non-empty array"); + } + + // Find the object with the matching feed_id + const calldataObj = data.find((item) => item.feed_id === feedIds[0]); + if (!calldataObj) { + throw new Error(`Feed ID ${feedIds[0]} not found in response`); + } + if ( + !calldataObj.encoded_calldata || + typeof calldataObj.encoded_calldata !== "string" + ) { + throw new Error( + "Invalid response format: encoded_calldata missing or invalid", + ); } - const calldataHex = data.calldata.startsWith("0x") - ? data.calldata.slice(2) - : data.calldata; - return new Uint8Array(Buffer.from(calldataHex, "hex")); + return `0x${calldataObj.encoded_calldata}`; } catch (error) { console.error("Error fetching data from Theoros:", error); throw error; @@ -89,9 +105,13 @@ async function main() { const chain = options.chain; const feedId = options.feedId; - const theorosEndpoint = options.theorosEndpoint; + const theorosUrl = options.theorosUrl; - const pragmaAddress = getDeployedAddress(chain, "pragma", "Pragma"); + const pragmaAddress = getDeployedAddress( + snakeToCamel(chain), + "pragma", + "Pragma", + ); const privateKey = process.env.ETH_PRIVATE_KEY; if (!privateKey) { @@ -101,19 +121,19 @@ async function main() { console.log( `Updating feed ${feedId} for contract ${pragmaAddress} on chain ${chain}`, ); - console.log(`Using Theoros endpoint: ${theorosEndpoint}`); + console.log(`Using Theoros endpoint: ${theorosUrl}`); // 2. Get calldata from Theoros - let calldata: Uint8Array; + let calldata: string; try { - calldata = await getCalldataFromTheoros(theorosEndpoint, feedId); + calldata = await getCalldataFromTheoros(theorosUrl, chain, [feedId]); console.log("Calldata retrieved from Theoros:", calldata); } catch (error) { console.error("Failed to retrieve calldata from Theoros:", error); process.exit(1); } - // 3. Call `updateDataFeeds` with the calldata + // 3. Call updateDataFeeds with the calldata let abi; try { abi = await import(PRAGMA_SOL_ABI_PATH); @@ -126,7 +146,7 @@ async function main() { const contract = new ethers.Contract(pragmaAddress, abi.abi, wallet); try { - const tx = await contract.updateDataFeeds(calldata); + const tx = await contract.updateDataFeeds([calldata]); console.log("Transaction sent. Transaction hash:", tx.hash); // 4. Assertions - check that everything is correctly updated on the destination chain From f00af536c5c3f204050ad7e99ac2676b19878275 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 20:56:51 +0100 Subject: [PATCH 39/55] dev(better_theoros): Theoros SDK --- typescript/theoros-sdk/README.md | 215 +++++++++++++++++++++------ typescript/theoros-sdk/src/index.ts | 217 ++++++++++++++++++++++++++-- 2 files changed, 378 insertions(+), 54 deletions(-) diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index 6a653bdc..942fee4d 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -1,18 +1,31 @@ # Theoros SDK -The official TypeScript SDK for interacting with the Pragma Theoros API. The Theoros SDK simplifies the process of fetching calldata for a given Feed ID, which can be used to update data on EVM chains. +The official TypeScript SDK for interacting with the Pragma Theoros API. The Theoros SDK simplifies the process of: -## Install +- Fetching calldata for given feed IDs. +- Subscribing to real-time data feed updates via WebSocket. +- Retrieving available feeds and supported chains. + +## Installation ```bash npm install @pragma/theoros-sdk ``` -## Usage +## Introduction + +The Theoros SDK provides a convenient way to interact with the Pragma Theoros API. It allows developers to: + +- Fetch available data feeds and their details. +- Retrieve the list of supported chains. +- Fetch calldata for specific feeds on a given chain. +- Subscribe to real-time updates for data feeds over WebSockets. + +## Getting Started ### Initializing the SDK -To start using the Theoros SDK, import it and create an instance: +Import the SDK and create an instance: ```typescript import { TheorosSDK } from "@pragma/theoros-sdk"; @@ -23,72 +36,192 @@ const sdk = new TheorosSDK({ }); ``` -- `baseUrl`: The base URL of the Pragma Theoros API. Defaults to `https://api.pragma.build/v1`. -- `timeout`: The request timeout in milliseconds. Defaults to `10000`. +- `baseUrl` (optional): The base URL of the Pragma Theoros API. Defaults to 'https://api.pragma.build/v1'. +- `timeout` (optional): The request timeout in milliseconds. Defaults to 10000. + +### Usage + +#### Fetching Available Feeds + +Retrieve the list of available feeds: + +```typescript +const feeds = await sdk.getAvailableFeeds(); +console.log("Available Feeds:", feeds); +``` + +This method returns a promise that resolves to an array of Feed objects, each containing: + +- `feed_id`: The unique identifier for the feed. +- `asset_class`: The asset class of the feed. +- `feed_type`: The type of the feed. +- `pair_id`: The pair identifier associated with the feed. + +#### Fetching Supported Chains + +Retrieve the list of supported chains: + +```typescript +const chains = await sdk.getSupportedChains(); +console.log("Supported Chains:", chains); +``` + +This method returns a promise that resolves to an array of strings representing the chain names. -### Fetching Available Feed IDs +#### Fetching Calldata -Retrieve the list of available Feed IDs using the `getAvailableFeedIds` method: +Fetch calldata for specific feed IDs on a given chain: ```typescript -const feedIds = await sdk.getAvailableFeedIds(); -console.log("Available Feed IDs:", feedIds); +const chain = "zircuit_testnet"; +const feedIds = ["0x4e5354522f555344", "0x4c5553442f555344"]; + +try { + const calldataResponses = await sdk.getCalldata(chain, feedIds); + console.log("Calldata Responses:", calldataResponses); +} catch (error) { + console.error("Error fetching calldata:", error); +} ``` -This method returns a promise that resolves to an array of string containing the Feed IDs. +- `chain`: The name of the chain. +- `feedIds`: An array of feed IDs. + +The method returns a promise that resolves to an array of CalldataResponse objects, each containing: + +- `feed_id`: The feed ID. +- `encoded_calldata`: The calldata encoded as a hex string. -### Fetching Calldata for a Feed ID +### Subscribing to Data Feeds -Once you have a Feed ID, you can fetch its calldata using the `getCalldata` method: +Subscribe to data feed updates over WebSocket: ```typescript -const feedId = feedIds[0]; // For example, use the first Feed ID -const calldataResponse = await sdk.getCalldata(feedId); -console.log("Calldata:", calldataResponse.calldata); +const chain = "zircuit_testnet"; +const feedIds = ["0x4e5354522f555344", "0x4c5553442f555344"]; + +const subscription = sdk.subscribe(chain, feedIds); ``` -- `feedId`: The Feed ID for which you want to fetch the calldata. - The getCalldata method returns a promise that resolves to a `CalldataResponse` object containing: -- `calldata`: An array of numbers representing the calldata. +#### Handling Updates + +Listen for updates and other events: + +```typescript +subscription.on("update", (dataFeeds) => { + console.log("Data Feed Update:", dataFeeds); +}); + +subscription.on("error", (error) => { + console.error("Subscription Error:", error); +}); + +subscription.on("close", () => { + console.log("Subscription Closed"); +}); +``` + +- `'update'`: Emitted when new data feed updates are received. The callback receives an array of RpcDataFeed objects. +- `'error'`: Emitted when an error occurs. The callback receives an error object. +- `'close'`: Emitted when the subscription is closed. + +#### Adding and Removing Feed IDs + +You can dynamically add or remove feed IDs from the subscription: + +```typescript +// Add new feed IDs +subscription.addFeedIds(["0x1234567890abcdef"]); + +// Remove feed IDs +subscription.removeFeedIds(["0x4e5354522f555344"]); +``` + +#### Unsubscribing + +To unsubscribe from all feeds and close the connection: + +```typescript +subscription.unsubscribe(); +``` #### Example -Here is a complete example demonstrating how to use the Theoros SDK: +Here's a complete example demonstrating how to use the SDK: ```typescript import { TheorosSDK } from "@pragma/theoros-sdk"; (async () => { - const sdk = new TheorosSDK({ - baseUrl: "https://api.pragma.build/v1", - }); + const sdk = new TheorosSDK(); try { - // Fetch available feed IDs - const feeds = await sdk.getAvailableFeedIds(); - console.log("Available Feed IDs:", feeds); - - if (feeds.length === 0) { - console.log("No feeds available."); - return; - } - - // Fetch calldata for the first available Feed ID - const calldataResponse = await sdk.getCalldata(feeds[0]); - console.log("Calldata:", calldataResponse.calldata); + // Fetch available feeds + const feeds = await sdk.getAvailableFeeds(); + console.log("Available Feeds:", feeds); + + // Fetch supported chains + const chains = await sdk.getSupportedChains(); + console.log("Supported Chains:", chains); + + // Choose a chain and feed IDs + const chain = chains[0]; + const feedIds = feeds.slice(0, 2).map((feed) => feed.feed_id); + + // Fetch calldata + const calldataResponses = await sdk.getCalldata(chain, feedIds); + console.log("Calldata Responses:", calldataResponses); + + // Subscribe to data feed updates + const subscription = sdk.subscribe(chain, feedIds); + + subscription.on("update", (dataFeeds) => { + console.log("Data Feed Update:", dataFeeds); + }); + + subscription.on("error", (error) => { + console.error("Subscription Error:", error); + }); + + // Add a new feed ID after some time + setTimeout(() => { + subscription.addFeedIds(["0x1234567890abcdef"]); + }, 5000); + + // Unsubscribe after some time + setTimeout(() => { + subscription.unsubscribe(); + }, 15000); } catch (error) { console.error("An error occurred:", error); } })(); ``` -This script: +### Error Handling + +The SDK uses a custom `TheorosSDKError` class for error handling. You can catch errors using `try...catc`h blocks: + +```typescript +try { + const calldataResponses = await sdk.getCalldata(chain, feedIds); +} catch (error) { + if (error instanceof TheorosSDKError) { + console.error("Theoros SDK Error:", error.message); + } else { + console.error("Unexpected Error:", error); + } +} +``` + +For subscriptions, listen to the 'error' event: -1. Initializes the SDK. -2. Retrieves the available Feed IDs. -3. Fetches the calldata for the first Feed ID. -4. Logs the calldata to the console. +```typescript +subscription.on("error", (error) => { + console.error("Subscription Error:", error); +}); +``` ## License -This project is licensed under the [MIT License](../../LICENSE.md). +This project is licensed under the [MIT](../../LICENSE) License. diff --git a/typescript/theoros-sdk/src/index.ts b/typescript/theoros-sdk/src/index.ts index 87a37e29..7bb79fb0 100644 --- a/typescript/theoros-sdk/src/index.ts +++ b/typescript/theoros-sdk/src/index.ts @@ -1,4 +1,5 @@ import axios, { type AxiosInstance } from "axios"; +import { EventEmitter } from "events"; export interface TheorosSDKConfig { baseUrl?: string; @@ -6,14 +7,167 @@ export interface TheorosSDKConfig { } export interface CalldataResponse { - calldata: number[]; + feed_id: string; + encoded_calldata: string; +} + +export interface Feed { + feed_id: string; + asset_class: string; + feed_type: string; + pair_id: string; +} + +export interface RpcDataFeed { + feed_id: string; + encoded_calldata: string; +} + +export class TheorosSDKError extends Error { + public cause?: any; + constructor(message: string, cause?: any) { + super(message); + this.name = "TheorosSDKError"; + this.cause = cause; + } +} + +export class Subscription extends EventEmitter { + private socket!: WebSocket; + private isClosed = false; + private chain: string; + private feedIds: Set; + private baseUrl: string; + private reconnectAttempts = 0; + private maxReconnectAttempts = 5; + + constructor(baseUrl: string, chain: string, feedIds: string[]) { + super(); + this.baseUrl = baseUrl; + this.chain = chain; + this.feedIds = new Set(feedIds); + this.connect(); + } + + private connect() { + const wsUrl = this.baseUrl.replace(/^http/, "ws") + "/ws"; + this.socket = new WebSocket(wsUrl); + + this.socket.addEventListener("open", () => { + this.reconnectAttempts = 0; + const subscribeMessage = JSON.stringify({ + type: "subscribe", + chain: this.chain, + feed_ids: Array.from(this.feedIds), + }); + this.socket.send(subscribeMessage); + this.emit("open"); + }); + + this.socket.addEventListener("message", (event) => { + try { + const data = JSON.parse(event.data); + if (data.type === "data_feed_update") { + this.emit("update", data.data_feeds as RpcDataFeed[]); + } else if (data.type === "response") { + if (data.status === "error") { + this.emit("error", new TheorosSDKError(data.error)); + } else if (data.status === "success") { + // Optional: Handle success responses if needed + } + } + } catch (e) { + this.emit( + "error", + new TheorosSDKError("Invalid JSON message received", e), + ); + } + }); + + this.socket.addEventListener("error", (event) => { + this.emit("error", new TheorosSDKError("WebSocket error", event)); + }); + + this.socket.addEventListener("close", () => { + this.emit("close"); + if ( + !this.isClosed && + this.reconnectAttempts < this.maxReconnectAttempts + ) { + const timeout = Math.pow(2, this.reconnectAttempts) * 1000; + this.reconnectAttempts += 1; + setTimeout(() => this.connect(), timeout); + } else if (!this.isClosed) { + this.emit( + "error", + new TheorosSDKError("Max reconnection attempts reached"), + ); + } + }); + } + + /** + * Adds new feed IDs to the subscription. + * @param feedIds - Array of feed IDs to subscribe to. + */ + addFeedIds(feedIds: string[]) { + for (const id of feedIds) { + if (!this.feedIds.has(id)) { + this.feedIds.add(id); + if (this.socket.readyState === WebSocket.OPEN) { + const subscribeMessage = JSON.stringify({ + type: "subscribe", + chain: this.chain, + feed_ids: [id], + }); + this.socket.send(subscribeMessage); + } + } + } + } + + /** + * Removes feed IDs from the subscription. + * @param feedIds - Array of feed IDs to unsubscribe from. + */ + removeFeedIds(feedIds: string[]) { + for (const id of feedIds) { + if (this.feedIds.has(id)) { + this.feedIds.delete(id); + if (this.socket.readyState === WebSocket.OPEN) { + const unsubscribeMessage = JSON.stringify({ + type: "unsubscribe", + feed_ids: [id], + }); + this.socket.send(unsubscribeMessage); + } + } + } + } + + /** + * Unsubscribes from all feeds and closes the WebSocket connection. + */ + unsubscribe() { + this.isClosed = true; + if (this.socket.readyState === WebSocket.OPEN) { + const unsubscribeMessage = JSON.stringify({ + type: "unsubscribe", + feed_ids: Array.from(this.feedIds), + }); + this.socket.send(unsubscribeMessage); + this.socket.close(); + } else { + this.socket.close(); + } + } } export class TheorosSDK { private baseUrl: string; private httpClient: AxiosInstance; - constructor(config: TheorosSDKConfig) { + constructor(config: TheorosSDKConfig = {}) { this.baseUrl = config.baseUrl || "https://api.pragma.build/v1"; this.httpClient = axios.create({ @@ -25,27 +179,64 @@ export class TheorosSDK { }); } - // Fetch available data feeds - async getAvailableFeedIds(): Promise { + /** + * Retrieves all available data feeds. + * @returns A promise that resolves to an array of Feed objects. + */ + async getAvailableFeeds(): Promise { try { - const response = await this.httpClient.get("/data_feeds"); + const response = await this.httpClient.get("/data_feeds"); return response.data; } catch (error) { - throw new Error(`Error fetching data feeds: ${error}`); + throw new TheorosSDKError("Error fetching data feeds", error); } } - // Fetch calldata for a given Feed ID - async getCalldata(feedId: string): Promise { + /** + * Retrieves all supported chains. + * @returns A promise that resolves to an array of chain names. + */ + async getSupportedChains(): Promise { try { - const response = await this.httpClient.get( - `/calldata/${feedId}`, - ); + const response = await this.httpClient.get("/chains"); return response.data; } catch (error) { - throw new Error( - `Error fetching calldata for feed ID ${feedId}: ${error}`, + throw new TheorosSDKError("Error fetching supported chains", error); + } + } + + /** + * Fetches calldata for the specified chain and feed IDs. + * @param chain - The chain name. + * @param feedIds - An array of feed IDs. + * @returns A promise that resolves to an array of CalldataResponse objects. + */ + async getCalldata( + chain: string, + feedIds: string[], + ): Promise { + try { + const params = { + chain, + feed_ids: feedIds.join(","), + }; + const response = await this.httpClient.get( + "/calldata", + { params }, ); + return response.data; + } catch (error) { + throw new TheorosSDKError("Error fetching calldata", error); } } + + /** + * Subscribes to data feed updates over WebSocket. + * @param chain - The chain name. + * @param feedIds - An array of feed IDs. + * @returns A Subscription object that emits events on data updates. + */ + subscribe(chain: string, feedIds: string[]): Subscription { + return new Subscription(this.baseUrl, chain, feedIds); + } } From 7fbb334721293b04a7b2c61b6766a031d9b800cc Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 20:57:56 +0100 Subject: [PATCH 40/55] dev(better_theoros): updated README for SDk --- typescript/theoros-sdk/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index 942fee4d..c5c82c9d 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -36,8 +36,8 @@ const sdk = new TheorosSDK({ }); ``` -- `baseUrl` (optional): The base URL of the Pragma Theoros API. Defaults to 'https://api.pragma.build/v1'. -- `timeout` (optional): The request timeout in milliseconds. Defaults to 10000. +- `baseUrl` (optional): The base URL of the Pragma Theoros API. Defaults to `'https://api.pragma.build/v1'`. +- `timeout` (optional): The request timeout in milliseconds. Defaults to `10000`. ### Usage @@ -87,7 +87,7 @@ try { - `chain`: The name of the chain. - `feedIds`: An array of feed IDs. -The method returns a promise that resolves to an array of CalldataResponse objects, each containing: +The method returns a promise that resolves to an array of `CalldataResponse` objects, each containing: - `feed_id`: The feed ID. - `encoded_calldata`: The calldata encoded as a hex string. From 0d890482dde7af1ae866187699a61d65c070d6cd Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 20:59:35 +0100 Subject: [PATCH 41/55] dev(better_theoros): --- typescript/theoros-sdk/src/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/typescript/theoros-sdk/src/index.ts b/typescript/theoros-sdk/src/index.ts index 7bb79fb0..eebd03f8 100644 --- a/typescript/theoros-sdk/src/index.ts +++ b/typescript/theoros-sdk/src/index.ts @@ -72,8 +72,6 @@ export class Subscription extends EventEmitter { } else if (data.type === "response") { if (data.status === "error") { this.emit("error", new TheorosSDKError(data.error)); - } else if (data.status === "success") { - // Optional: Handle success responses if needed } } } catch (e) { From 515e5da5d02add5db3b1e465b7beec55cb44f3c4 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 21:03:11 +0100 Subject: [PATCH 42/55] dev(better_theoros): Better example + README --- typescript/theoros-sdk/README.md | 63 +++++++++--------------- typescript/theoros-sdk/examples/index.ts | 51 +++++++++++++++++++ 2 files changed, 73 insertions(+), 41 deletions(-) create mode 100644 typescript/theoros-sdk/examples/index.ts diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index c5c82c9d..403311ef 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -6,13 +6,13 @@ The official TypeScript SDK for interacting with the Pragma Theoros API. The The - Subscribing to real-time data feed updates via WebSocket. - Retrieving available feeds and supported chains. -## Installation +# Installation ```bash npm install @pragma/theoros-sdk ``` -## Introduction +# Introduction The Theoros SDK provides a convenient way to interact with the Pragma Theoros API. It allows developers to: @@ -21,9 +21,9 @@ The Theoros SDK provides a convenient way to interact with the Pragma Theoros AP - Fetch calldata for specific feeds on a given chain. - Subscribe to real-time updates for data feeds over WebSockets. -## Getting Started +# Getting Started -### Initializing the SDK +## Initializing the SDK Import the SDK and create an instance: @@ -39,9 +39,9 @@ const sdk = new TheorosSDK({ - `baseUrl` (optional): The base URL of the Pragma Theoros API. Defaults to `'https://api.pragma.build/v1'`. - `timeout` (optional): The request timeout in milliseconds. Defaults to `10000`. -### Usage +## Usage -#### Fetching Available Feeds +### Fetching Available Feeds Retrieve the list of available feeds: @@ -57,7 +57,7 @@ This method returns a promise that resolves to an array of Feed objects, each co - `feed_type`: The type of the feed. - `pair_id`: The pair identifier associated with the feed. -#### Fetching Supported Chains +### Fetching Supported Chains Retrieve the list of supported chains: @@ -68,7 +68,7 @@ console.log("Supported Chains:", chains); This method returns a promise that resolves to an array of strings representing the chain names. -#### Fetching Calldata +### Fetching Calldata Fetch calldata for specific feed IDs on a given chain: @@ -103,7 +103,7 @@ const feedIds = ["0x4e5354522f555344", "0x4c5553442f555344"]; const subscription = sdk.subscribe(chain, feedIds); ``` -#### Handling Updates +### Handling Updates Listen for updates and other events: @@ -125,7 +125,7 @@ subscription.on("close", () => { - `'error'`: Emitted when an error occurs. The callback receives an error object. - `'close'`: Emitted when the subscription is closed. -#### Adding and Removing Feed IDs +### Adding and Removing Feed IDs You can dynamically add or remove feed IDs from the subscription: @@ -137,7 +137,7 @@ subscription.addFeedIds(["0x1234567890abcdef"]); subscription.removeFeedIds(["0x4e5354522f555344"]); ``` -#### Unsubscribing +### Unsubscribing To unsubscribe from all feeds and close the connection: @@ -145,12 +145,17 @@ To unsubscribe from all feeds and close the connection: subscription.unsubscribe(); ``` -#### Example +# Example Here's a complete example demonstrating how to use the SDK: ```typescript -import { TheorosSDK } from "@pragma/theoros-sdk"; +import { + TheorosSDK, + type Feed, + type RpcDataFeed, + type TheorosSDKError, +} from "@pragma/theoros-sdk"; (async () => { const sdk = new TheorosSDK(); @@ -166,7 +171,7 @@ import { TheorosSDK } from "@pragma/theoros-sdk"; // Choose a chain and feed IDs const chain = chains[0]; - const feedIds = feeds.slice(0, 2).map((feed) => feed.feed_id); + const feedIds = feeds.slice(0, 2).map((feed: Feed) => feed.feed_id); // Fetch calldata const calldataResponses = await sdk.getCalldata(chain, feedIds); @@ -175,11 +180,11 @@ import { TheorosSDK } from "@pragma/theoros-sdk"; // Subscribe to data feed updates const subscription = sdk.subscribe(chain, feedIds); - subscription.on("update", (dataFeeds) => { + subscription.on("update", (dataFeeds: RpcDataFeed[]) => { console.log("Data Feed Update:", dataFeeds); }); - subscription.on("error", (error) => { + subscription.on("error", (error: TheorosSDKError) => { console.error("Subscription Error:", error); }); @@ -198,30 +203,6 @@ import { TheorosSDK } from "@pragma/theoros-sdk"; })(); ``` -### Error Handling - -The SDK uses a custom `TheorosSDKError` class for error handling. You can catch errors using `try...catc`h blocks: - -```typescript -try { - const calldataResponses = await sdk.getCalldata(chain, feedIds); -} catch (error) { - if (error instanceof TheorosSDKError) { - console.error("Theoros SDK Error:", error.message); - } else { - console.error("Unexpected Error:", error); - } -} -``` - -For subscriptions, listen to the 'error' event: - -```typescript -subscription.on("error", (error) => { - console.error("Subscription Error:", error); -}); -``` - -## License +# License This project is licensed under the [MIT](../../LICENSE) License. diff --git a/typescript/theoros-sdk/examples/index.ts b/typescript/theoros-sdk/examples/index.ts new file mode 100644 index 00000000..80f560e0 --- /dev/null +++ b/typescript/theoros-sdk/examples/index.ts @@ -0,0 +1,51 @@ +import { + TheorosSDK, + type Feed, + type RpcDataFeed, + type TheorosSDKError, +} from "@pragma/theoros-sdk"; + +(async () => { + const sdk = new TheorosSDK(); + + try { + // Fetch available feeds + const feeds = await sdk.getAvailableFeeds(); + console.log("Available Feeds:", feeds); + + // Fetch supported chains + const chains = await sdk.getSupportedChains(); + console.log("Supported Chains:", chains); + + // Choose a chain and feed IDs + const chain = chains[0]; + const feedIds = feeds.slice(0, 2).map((feed: Feed) => feed.feed_id); + + // Fetch calldata + const calldataResponses = await sdk.getCalldata(chain, feedIds); + console.log("Calldata Responses:", calldataResponses); + + // Subscribe to data feed updates + const subscription = sdk.subscribe(chain, feedIds); + + subscription.on("update", (dataFeeds: RpcDataFeed[]) => { + console.log("Data Feed Update:", dataFeeds); + }); + + subscription.on("error", (error: TheorosSDKError) => { + console.error("Subscription Error:", error); + }); + + // Add a new feed ID after some time + setTimeout(() => { + subscription.addFeedIds(["0x1234567890abcdef"]); + }, 5000); + + // Unsubscribe after some time + setTimeout(() => { + subscription.unsubscribe(); + }, 15000); + } catch (error) { + console.error("An error occurred:", error); + } +})(); From d3d810da9413c9f8f4757a30de095dd1d2f4e3c0 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 21:04:17 +0100 Subject: [PATCH 43/55] =?UTF-8?q?dev(better=5Ftheoros):=20=E2=9C=85=20theo?= =?UTF-8?q?ros=20SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typescript/theoros-sdk/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index 403311ef..13119192 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -4,7 +4,6 @@ The official TypeScript SDK for interacting with the Pragma Theoros API. The The - Fetching calldata for given feed IDs. - Subscribing to real-time data feed updates via WebSocket. -- Retrieving available feeds and supported chains. # Installation From 60a9760ad5f131a018d247734d3cdb16eddc8b4c Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 21:06:06 +0100 Subject: [PATCH 44/55] dev(better_theoros): Updated SDK Readme --- typescript/theoros-sdk/README.md | 6 +++--- typescript/theoros-sdk/examples/index.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index 13119192..55a9c4f8 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -1,4 +1,4 @@ -# Theoros SDK +# 🧩 Theoros SDK The official TypeScript SDK for interacting with the Pragma Theoros API. The Theoros SDK simplifies the process of: @@ -130,7 +130,7 @@ You can dynamically add or remove feed IDs from the subscription: ```typescript // Add new feed IDs -subscription.addFeedIds(["0x1234567890abcdef"]); +subscription.addFeedIds(["0x4e5354522f555344"]); // Remove feed IDs subscription.removeFeedIds(["0x4e5354522f555344"]); @@ -189,7 +189,7 @@ import { // Add a new feed ID after some time setTimeout(() => { - subscription.addFeedIds(["0x1234567890abcdef"]); + subscription.addFeedIds(["0x4e5354522f555344"]); }, 5000); // Unsubscribe after some time diff --git a/typescript/theoros-sdk/examples/index.ts b/typescript/theoros-sdk/examples/index.ts index 80f560e0..8f87e8b6 100644 --- a/typescript/theoros-sdk/examples/index.ts +++ b/typescript/theoros-sdk/examples/index.ts @@ -38,7 +38,7 @@ import { // Add a new feed ID after some time setTimeout(() => { - subscription.addFeedIds(["0x1234567890abcdef"]); + subscription.addFeedIds(["0x4e5354522f555344"]); }, 5000); // Unsubscribe after some time From 0dd0d5f159c1f98ddd0c8c95ae084cfafe96a380 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 23:29:03 +0100 Subject: [PATCH 45/55] =?UTF-8?q?dev(better=5Ftheoros):=20=F0=9F=94=A8=20F?= =?UTF-8?q?ixed=20&=20Tested=20SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typescript/theoros-sdk/README.md | 88 ++++++++++++------------ typescript/theoros-sdk/examples/index.ts | 88 ++++++++++++------------ typescript/theoros-sdk/src/index.ts | 4 +- 3 files changed, 90 insertions(+), 90 deletions(-) diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index 55a9c4f8..1842f617 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -156,50 +156,50 @@ import { type TheorosSDKError, } from "@pragma/theoros-sdk"; -(async () => { - const sdk = new TheorosSDK(); - - try { - // Fetch available feeds - const feeds = await sdk.getAvailableFeeds(); - console.log("Available Feeds:", feeds); - - // Fetch supported chains - const chains = await sdk.getSupportedChains(); - console.log("Supported Chains:", chains); - - // Choose a chain and feed IDs - const chain = chains[0]; - const feedIds = feeds.slice(0, 2).map((feed: Feed) => feed.feed_id); - - // Fetch calldata - const calldataResponses = await sdk.getCalldata(chain, feedIds); - console.log("Calldata Responses:", calldataResponses); - - // Subscribe to data feed updates - const subscription = sdk.subscribe(chain, feedIds); - - subscription.on("update", (dataFeeds: RpcDataFeed[]) => { - console.log("Data Feed Update:", dataFeeds); - }); - - subscription.on("error", (error: TheorosSDKError) => { - console.error("Subscription Error:", error); - }); - - // Add a new feed ID after some time - setTimeout(() => { - subscription.addFeedIds(["0x4e5354522f555344"]); - }, 5000); - - // Unsubscribe after some time - setTimeout(() => { - subscription.unsubscribe(); - }, 15000); - } catch (error) { - console.error("An error occurred:", error); - } -})(); +const sdk = new TheorosSDK({ + baseUrl: "http://localhost:3000/v1", // Local Theoros instance +}); + +try { + // Fetch available feeds + const feeds = await sdk.getAvailableFeeds(); + console.log("πŸ“œ Available Feeds:", feeds); + + // Fetch supported chains + const chains = await sdk.getSupportedChains(); + console.log("⛓️‍πŸ’₯ Supported Chains:", chains); + + // Choose a chain and feed IDs + const chain = chains[0]; + const feedIds = feeds.slice(0, 2).map((feed: Feed) => feed.feed_id); + + // Fetch calldata + const calldataResponses = await sdk.getCalldata(chain, feedIds); + console.log("πŸ‘‰ Calldata Responses:", calldataResponses); + + // Subscribe to data feed updates + const subscription = sdk.subscribe(chain, feedIds); + + subscription.on("update", (dataFeeds: RpcDataFeed[]) => { + console.log("πŸ‘‰ Data Feed Update:", dataFeeds); + }); + + subscription.on("error", (error: TheorosSDKError) => { + console.error("😱😱 Subscription Error:", error); + }); + + // Add a new feed ID after some time + setTimeout(() => { + subscription.addFeedIds(["0x4e5354522f555344"]); + }, 5000); + + // Unsubscribe after some time + setTimeout(() => { + subscription.unsubscribe(); + }, 30000); +} catch (error) { + console.error("An error occurred:", error); +} ``` # License diff --git a/typescript/theoros-sdk/examples/index.ts b/typescript/theoros-sdk/examples/index.ts index 8f87e8b6..fd467f12 100644 --- a/typescript/theoros-sdk/examples/index.ts +++ b/typescript/theoros-sdk/examples/index.ts @@ -5,47 +5,47 @@ import { type TheorosSDKError, } from "@pragma/theoros-sdk"; -(async () => { - const sdk = new TheorosSDK(); - - try { - // Fetch available feeds - const feeds = await sdk.getAvailableFeeds(); - console.log("Available Feeds:", feeds); - - // Fetch supported chains - const chains = await sdk.getSupportedChains(); - console.log("Supported Chains:", chains); - - // Choose a chain and feed IDs - const chain = chains[0]; - const feedIds = feeds.slice(0, 2).map((feed: Feed) => feed.feed_id); - - // Fetch calldata - const calldataResponses = await sdk.getCalldata(chain, feedIds); - console.log("Calldata Responses:", calldataResponses); - - // Subscribe to data feed updates - const subscription = sdk.subscribe(chain, feedIds); - - subscription.on("update", (dataFeeds: RpcDataFeed[]) => { - console.log("Data Feed Update:", dataFeeds); - }); - - subscription.on("error", (error: TheorosSDKError) => { - console.error("Subscription Error:", error); - }); - - // Add a new feed ID after some time - setTimeout(() => { - subscription.addFeedIds(["0x4e5354522f555344"]); - }, 5000); - - // Unsubscribe after some time - setTimeout(() => { - subscription.unsubscribe(); - }, 15000); - } catch (error) { - console.error("An error occurred:", error); - } -})(); +const sdk = new TheorosSDK({ + baseUrl: "http://localhost:3000/v1", // Local Theoros instance +}); + +try { + // Fetch available feeds + const feeds = await sdk.getAvailableFeeds(); + console.log("πŸ“œ Available Feeds:", feeds); + + // Fetch supported chains + const chains = await sdk.getSupportedChains(); + console.log("⛓️‍πŸ’₯ Supported Chains:", chains); + + // Choose a chain and feed IDs + const chain = chains[0]; + const feedIds = feeds.slice(0, 2).map((feed: Feed) => feed.feed_id); + + // Fetch calldata + const calldataResponses = await sdk.getCalldata(chain, feedIds); + console.log("πŸ‘‰ Calldata Responses:", calldataResponses); + + // Subscribe to data feed updates + const subscription = sdk.subscribe(chain, feedIds); + + subscription.on("update", (dataFeeds: RpcDataFeed[]) => { + console.log("πŸ‘‰ Data Feed Update:", dataFeeds); + }); + + subscription.on("error", (error: TheorosSDKError) => { + console.error("😱😱 Subscription Error:", error); + }); + + // Add a new feed ID after some time + setTimeout(() => { + subscription.addFeedIds(["0x4e5354522f555344"]); + }, 5000); + + // Unsubscribe after some time + setTimeout(() => { + subscription.unsubscribe(); + }, 30000); +} catch (error) { + console.error("An error occurred:", error); +} diff --git a/typescript/theoros-sdk/src/index.ts b/typescript/theoros-sdk/src/index.ts index eebd03f8..886d391e 100644 --- a/typescript/theoros-sdk/src/index.ts +++ b/typescript/theoros-sdk/src/index.ts @@ -50,7 +50,7 @@ export class Subscription extends EventEmitter { } private connect() { - const wsUrl = this.baseUrl.replace(/^http/, "ws") + "/ws"; + const wsUrl = this.baseUrl + "/ws/calldata"; this.socket = new WebSocket(wsUrl); this.socket.addEventListener("open", () => { @@ -166,7 +166,7 @@ export class TheorosSDK { private httpClient: AxiosInstance; constructor(config: TheorosSDKConfig = {}) { - this.baseUrl = config.baseUrl || "https://api.pragma.build/v1"; + this.baseUrl = config.baseUrl || "https://theoros.pragma.build/v1"; this.httpClient = axios.create({ baseURL: this.baseUrl, From 01b90f841d40bbcadb1df4bca812aff6ea45dfb4 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sat, 2 Nov 2024 23:45:15 +0100 Subject: [PATCH 46/55] dev(better_theoros): Fixed example --- typescript/theoros-sdk/README.md | 4 ++-- typescript/theoros-sdk/examples/index.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index 1842f617..8b34e819 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -190,13 +190,13 @@ try { // Add a new feed ID after some time setTimeout(() => { - subscription.addFeedIds(["0x4e5354522f555344"]); + subscription.addFeedIds(["0x574254432f555344"]); }, 5000); // Unsubscribe after some time setTimeout(() => { subscription.unsubscribe(); - }, 30000); + }, 15000); } catch (error) { console.error("An error occurred:", error); } diff --git a/typescript/theoros-sdk/examples/index.ts b/typescript/theoros-sdk/examples/index.ts index fd467f12..c24d8acc 100644 --- a/typescript/theoros-sdk/examples/index.ts +++ b/typescript/theoros-sdk/examples/index.ts @@ -39,7 +39,7 @@ try { // Add a new feed ID after some time setTimeout(() => { - subscription.addFeedIds(["0x4e5354522f555344"]); + subscription.addFeedIds(["0x574254432f555344"]); }, 5000); // Unsubscribe after some time From a65dc5d5c46d607133d4c84b41011717c6cf96e8 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sun, 3 Nov 2024 01:19:38 +0100 Subject: [PATCH 47/55] dev(better_theoros): Prevent overflows in indexer --- rust/theoros/src/services/indexer/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/theoros/src/services/indexer/mod.rs b/rust/theoros/src/services/indexer/mod.rs index 9e986c52..e81d15ac 100644 --- a/rust/theoros/src/services/indexer/mod.rs +++ b/rust/theoros/src/services/indexer/mod.rs @@ -1,3 +1,5 @@ +use std::cmp::max; + use anyhow::{anyhow, bail, Context, Result}; use apibara_core::{ node::v1alpha2::DataFinality, @@ -61,7 +63,7 @@ impl IndexerService { current_block: u64, ) -> Result { let stream_config = Configuration::::default() - .with_starting_block(current_block - START_INDEXER_DELTA) + .with_starting_block(max(1, current_block.saturating_sub(START_INDEXER_DELTA))) .with_filter(|mut filter| { filter .with_header(HeaderFilter::weak()) From 34175f077aed27571077efa2ff178cb0e650cf35 Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Sun, 3 Nov 2024 16:47:56 +0100 Subject: [PATCH 48/55] fix: nit picks --- rust/theoros/src/constants.rs | 1 + rust/theoros/src/errors/calldata_error.rs | 1 + rust/theoros/src/rpc/evm/hyperlane.rs | 2 +- rust/theoros/src/rpc/evm/mod.rs | 2 +- rust/theoros/src/services/hyperlane/mod.rs | 10 ++++++++-- rust/theoros/src/storage/checkpoints.rs | 2 +- rust/theoros/src/storage/mod.rs | 3 ++- rust/theoros/src/storage/validator.rs | 7 ++++--- solidity/package-lock.json | 4 ++-- typescript/theoros-sdk/README.md | 6 +++--- typescript/theoros-sdk/examples/index.ts | 2 +- typescript/theoros-sdk/package-lock.json | 4 ++-- typescript/theoros-sdk/package.json | 2 +- 13 files changed, 28 insertions(+), 18 deletions(-) diff --git a/rust/theoros/src/constants.rs b/rust/theoros/src/constants.rs index ecf2f59d..0bafbb70 100644 --- a/rust/theoros/src/constants.rs +++ b/rust/theoros/src/constants.rs @@ -8,6 +8,7 @@ pub const TRAILING_HEADER_SIZE: u8 = 0; pub const PING_INTERVAL_DURATION: Duration = Duration::from_secs(30); pub const MAX_CLIENT_MESSAGE_SIZE: usize = 100 * 1024; // 100 KiB +pub const FEED_UPDATED_CHANNEL_CAPACITY: usize = 1024; // TODO: add support for this /// The maximum number of bytes that can be sent per second per IP address. diff --git a/rust/theoros/src/errors/calldata_error.rs b/rust/theoros/src/errors/calldata_error.rs index 47dfef5f..a849b990 100644 --- a/rust/theoros/src/errors/calldata_error.rs +++ b/rust/theoros/src/errors/calldata_error.rs @@ -39,6 +39,7 @@ impl IntoResponse for GetCalldataError { Self::DispatchNotFound => { (StatusCode::NOT_FOUND, "Could not find any Dispatch event for the provided Feed ID".into()) } + Self::CalldataError(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg), _ => (StatusCode::INTERNAL_SERVER_ERROR, String::from("Internal server error")), }; (status, Json(json!({"resource":"Calldata", "message": err_msg, "happened_at" : chrono::Utc::now() }))) diff --git a/rust/theoros/src/rpc/evm/hyperlane.rs b/rust/theoros/src/rpc/evm/hyperlane.rs index 457ba05d..07dbb9e7 100644 --- a/rust/theoros/src/rpc/evm/hyperlane.rs +++ b/rust/theoros/src/rpc/evm/hyperlane.rs @@ -38,7 +38,7 @@ impl HyperlaneClient { Self(hyperlane_client) } - pub async fn get_validators(&self) -> Result> { + pub async fn get_validators_with_index(&self) -> Result> { let mut validators = HashMap::new(); let mut index = 0; diff --git a/rust/theoros/src/rpc/evm/mod.rs b/rust/theoros/src/rpc/evm/mod.rs index 41476d41..226620a8 100644 --- a/rust/theoros/src/rpc/evm/mod.rs +++ b/rust/theoros/src/rpc/evm/mod.rs @@ -24,7 +24,7 @@ impl HyperlaneValidatorsMapping { .map_err(|e| anyhow::anyhow!("Invalid hyperlane address for {chain_name:?}: {e}"))?; let rpc_client = HyperlaneClient::new(rpc_url, address).await; - let validators = rpc_client.get_validators().await?; + let validators = rpc_client.get_validators_with_index().await?; contracts.insert(*chain_name, validators); } diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index c57a0cd8..00611c49 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -90,7 +90,7 @@ impl HyperlaneService { } // TODO: If the nonce n+1 is fully signed, shall we ignore every nonces before..? Or raise an alert? tracing::info!("πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", nonce); - if let Err(e) = self.store_dispatch_updates(nonce).await { + if let Err(e) = self.store_dispatch_updates_and_send_websocket_notification(nonce).await { tracing::error!("😱 Failed to store event updates for nonce {}: {:?}", nonce, e); } self.storage.unsigned_checkpoints().remove(nonce).await; @@ -155,7 +155,7 @@ impl HyperlaneService { /// Stores the updates once it has been signed. /// Also sends an update to the websocket channel that an update has been stored. - async fn store_dispatch_updates(&self, nonce: u32) -> anyhow::Result<()> { + async fn store_dispatch_updates_and_send_websocket_notification(&self, nonce: u32) -> anyhow::Result<()> { let event = match self.storage.unsigned_checkpoints().get(nonce).await { Some(e) => e, None => unreachable!(), @@ -169,6 +169,12 @@ impl HyperlaneService { } // Send websocket notification + self.update_websocket().await?; + + Ok(()) + } + + async fn update_websocket(&self) -> anyhow::Result<()> { match self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New) { Ok(_) => { tracing::debug!("πŸ•ΈοΈ [Websocket] πŸ”” Successfully sent websocket notification"); diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index f2092605..02a9c8b0 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -17,7 +17,7 @@ impl UnsignedCheckpointsStorage { lock.insert(nonce, event.clone()); } - /// Retrieve all nonces currently stored, in sorted order. + /// Retrieve all nonces currently stored, in ascending order. pub async fn nonces(&self) -> Vec { let lock = self.0.read().await; lock.keys().cloned().collect() diff --git a/rust/theoros/src/storage/mod.rs b/rust/theoros/src/storage/mod.rs index 7200f09a..c3819fdf 100644 --- a/rust/theoros/src/storage/mod.rs +++ b/rust/theoros/src/storage/mod.rs @@ -12,6 +12,7 @@ use starknet::core::types::Felt; use tokio::sync::broadcast::Sender; use crate::{ + constants::FEED_UPDATED_CHANNEL_CAPACITY, rpc::starknet::{HyperlaneCalls, PragmaFeedsRegistryCalls, StarknetRpc}, types::hyperlane::NewUpdatesAvailableEvent, }; @@ -49,7 +50,7 @@ impl TheorosStorage { signed_checkpoints: SignedCheckpointsStorage::default(), unsigned_checkpoints: UnsignedCheckpointsStorage::default(), latest_update_per_feed: LatestUpdatePerFeedStorage::default(), - feeds_updated_tx: tokio::sync::broadcast::channel(1024).0, + feeds_updated_tx: tokio::sync::broadcast::channel(FEED_UPDATED_CHANNEL_CAPACITY).0, }) } diff --git a/rust/theoros/src/storage/validator.rs b/rust/theoros/src/storage/validator.rs index 3925f5bf..3c7c5fb7 100644 --- a/rust/theoros/src/storage/validator.rs +++ b/rust/theoros/src/storage/validator.rs @@ -38,7 +38,7 @@ impl ValidatorsFetchersStorage { } /// Adds or updates the [CheckpointStorage] for the given validator - pub async fn add(&self, validator: Felt, storage: CheckpointStorage) -> anyhow::Result<()> { + pub async fn build_and_add(&self, validator: Felt, storage: CheckpointStorage) -> anyhow::Result<()> { let storage_fetcher = storage.build().await?; let mut lock = self.0.write().await; lock.insert(validator, Arc::new(storage_fetcher)); @@ -46,14 +46,15 @@ impl ValidatorsFetchersStorage { } /// Adds or updates the [CheckpointStorage] for the given validator from a [ValidatorAnnouncementEvent] + /// NOTE: This won't work with local storage. + /// TODO: This should be a feature. We sometime want to have a local storage. pub async fn add_from_announcement_event(&self, event: ValidatorAnnouncementEvent) -> anyhow::Result<()> { let validator: Felt = event.validator.into(); - // TODO: This should be a feature. We sometime want to have a local storage. if event.storage_location.starts_with("file") { return Ok(()); } let storage = CheckpointStorage::from_str(&event.storage_location)?; - self.add(validator, storage).await?; + self.build_and_add(validator, storage).await?; Ok(()) } diff --git a/solidity/package-lock.json b/solidity/package-lock.json index bb92d1fd..f16798bd 100644 --- a/solidity/package-lock.json +++ b/solidity/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@pragma/solidity-sdk", + "name": "@pragmaoracle/solidity-sdk", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@pragma/solidity-sdk", + "name": "@pragmaoracle/solidity-sdk", "version": "1.0.0", "license": "MIT", "devDependencies": { diff --git a/typescript/theoros-sdk/README.md b/typescript/theoros-sdk/README.md index 8b34e819..a64cf94c 100644 --- a/typescript/theoros-sdk/README.md +++ b/typescript/theoros-sdk/README.md @@ -8,7 +8,7 @@ The official TypeScript SDK for interacting with the Pragma Theoros API. The The # Installation ```bash -npm install @pragma/theoros-sdk +npm install @pragmaoracle/theoros-sdk ``` # Introduction @@ -27,7 +27,7 @@ The Theoros SDK provides a convenient way to interact with the Pragma Theoros AP Import the SDK and create an instance: ```typescript -import { TheorosSDK } from "@pragma/theoros-sdk"; +import { TheorosSDK } from "@pragmaoracle/theoros-sdk"; const sdk = new TheorosSDK({ baseUrl: "https://api.pragma.build/v1", // Optional, defaults to this value @@ -154,7 +154,7 @@ import { type Feed, type RpcDataFeed, type TheorosSDKError, -} from "@pragma/theoros-sdk"; +} from "@pragmaoracle/theoros-sdk"; const sdk = new TheorosSDK({ baseUrl: "http://localhost:3000/v1", // Local Theoros instance diff --git a/typescript/theoros-sdk/examples/index.ts b/typescript/theoros-sdk/examples/index.ts index c24d8acc..5f43a7b9 100644 --- a/typescript/theoros-sdk/examples/index.ts +++ b/typescript/theoros-sdk/examples/index.ts @@ -3,7 +3,7 @@ import { type Feed, type RpcDataFeed, type TheorosSDKError, -} from "@pragma/theoros-sdk"; +} from "@pragmaoracle/theoros-sdk"; const sdk = new TheorosSDK({ baseUrl: "http://localhost:3000/v1", // Local Theoros instance diff --git a/typescript/theoros-sdk/package-lock.json b/typescript/theoros-sdk/package-lock.json index 4f534e7a..9f232e40 100644 --- a/typescript/theoros-sdk/package-lock.json +++ b/typescript/theoros-sdk/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@pragma/theoros-sdk", + "name": "@pragmaoracle/theoros-sdk", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@pragma/theoros-sdk", + "name": "@pragmaoracle/theoros-sdk", "version": "1.0.0", "license": "MIT", "dependencies": { diff --git a/typescript/theoros-sdk/package.json b/typescript/theoros-sdk/package.json index 9edade03..3eeaabe4 100644 --- a/typescript/theoros-sdk/package.json +++ b/typescript/theoros-sdk/package.json @@ -1,5 +1,5 @@ { - "name": "@pragma/theoros-sdk", + "name": "@pragmaoracle/theoros-sdk", "description": "The official SDK for Pragma Theoros", "version": "1.0.0", "keywords": [ From 2fb8c6ba84aa78aad6bc570eb2af944443c7e3f6 Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Sun, 3 Nov 2024 16:59:31 +0100 Subject: [PATCH 49/55] Update tsconfig.json --- typescript/theoros-sdk/tsconfig.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/typescript/theoros-sdk/tsconfig.json b/typescript/theoros-sdk/tsconfig.json index 238655f2..e5b06d2b 100644 --- a/typescript/theoros-sdk/tsconfig.json +++ b/typescript/theoros-sdk/tsconfig.json @@ -22,6 +22,11 @@ // Some stricter flags (disabled by default) "noUnusedLocals": false, "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false + "noPropertyAccessFromIndexSignature": false, + "paths": { + "@pragmaoracle/theoros-sdk": [ + "./src/index.ts" + ] + }, } } From 1266168fe05861c6e36a0d1ac9f6c47c90e222d0 Mon Sep 17 00:00:00 2001 From: akhercha Date: Sun, 3 Nov 2024 17:38:15 +0100 Subject: [PATCH 50/55] dev(better_theoros): Fixes from review " r --- rust/theoros/src/services/hyperlane/mod.rs | 29 +++++++--------------- rust/theoros/src/services/indexer/mod.rs | 2 +- rust/theoros/src/storage/checkpoints.rs | 8 +----- rust/theoros/src/storage/updates.rs | 8 +++--- rust/theoros/src/types/calldata.rs | 2 +- 5 files changed, 15 insertions(+), 34 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 00611c49..221eb28f 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -90,9 +90,10 @@ impl HyperlaneService { } // TODO: If the nonce n+1 is fully signed, shall we ignore every nonces before..? Or raise an alert? tracing::info!("πŸŒ‰ [Hyperlane] βœ… Nonce #{} is fully signed by all validators! Storing updates...", nonce); - if let Err(e) = self.store_dispatch_updates_and_send_websocket_notification(nonce).await { + if let Err(e) = self.store_dispatch_updates(nonce).await { tracing::error!("😱 Failed to store event updates for nonce {}: {:?}", nonce, e); } + self.send_websocket_notification().await; self.storage.unsigned_checkpoints().remove(nonce).await; } } @@ -117,7 +118,7 @@ impl HyperlaneService { match fetcher.fetch(nonce).await { Ok(Some(checkpoint)) => { - self.store_signed_checkpoint(validator, checkpoint).await?; + self.store_signed_checkpoint(validator, checkpoint).await; } Ok(None) => { tracing::debug!("πŸŒ‰ [Hyperlane] Validator {:#x} has not yet signed nonce {}", validator, nonce); @@ -135,27 +136,21 @@ impl HyperlaneService { } /// Store the signed checkpoint for the (validator;nonce) couple. - async fn store_signed_checkpoint( - &self, - validator: Felt, - checkpoint: SignedCheckpointWithMessageId, - ) -> anyhow::Result<()> { + async fn store_signed_checkpoint(&self, validator: Felt, checkpoint: SignedCheckpointWithMessageId) { let nonce = checkpoint.value.checkpoint.index; if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce).await { tracing::debug!("πŸŒ‰ [Hyperlane] Skipping duplicate checkpoint for validator {:#x}: #{}", validator, nonce); - return Ok(()); + return; } - self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await?; + self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await; tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed checkpoint #{}", validator, nonce); - - Ok(()) } /// Stores the updates once it has been signed. /// Also sends an update to the websocket channel that an update has been stored. - async fn store_dispatch_updates_and_send_websocket_notification(&self, nonce: u32) -> anyhow::Result<()> { + async fn store_dispatch_updates(&self, nonce: u32) -> anyhow::Result<()> { let event = match self.storage.unsigned_checkpoints().get(nonce).await { Some(e) => e, None => unreachable!(), @@ -165,16 +160,12 @@ impl HyperlaneService { let dispatch_update_infos = DispatchUpdateInfos::new(&event, update); let feed_id = hex_str_to_u256(&update.feed_id())?; - self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos).await?; + self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos).await; } - - // Send websocket notification - self.update_websocket().await?; - Ok(()) } - async fn update_websocket(&self) -> anyhow::Result<()> { + async fn send_websocket_notification(&self) { match self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New) { Ok(_) => { tracing::debug!("πŸ•ΈοΈ [Websocket] πŸ”” Successfully sent websocket notification"); @@ -184,7 +175,5 @@ impl HyperlaneService { tracing::debug!("πŸ•ΈοΈ [Websocket] πŸ“ͺ No active websocket subscribers to receive notification: {}", e); } } - - Ok(()) } } diff --git a/rust/theoros/src/services/indexer/mod.rs b/rust/theoros/src/services/indexer/mod.rs index e81d15ac..570fcd38 100644 --- a/rust/theoros/src/services/indexer/mod.rs +++ b/rust/theoros/src/services/indexer/mod.rs @@ -63,7 +63,7 @@ impl IndexerService { current_block: u64, ) -> Result { let stream_config = Configuration::::default() - .with_starting_block(max(1, current_block.saturating_sub(START_INDEXER_DELTA))) + .with_starting_block(max(0, current_block.saturating_sub(START_INDEXER_DELTA))) .with_filter(|mut filter| { filter .with_header(HeaderFilter::weak()) diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index 02a9c8b0..b7d3d61f 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -42,15 +42,9 @@ pub struct SignedCheckpointsStorage(RwLock anyhow::Result<()> { + pub async fn add(&self, validator: Felt, nonce: u32, checkpoint: SignedCheckpointWithMessageId) { let mut lock = self.0.write().await; lock.insert((validator, nonce), checkpoint); - Ok(()) } // For the provided list of validators, returns all their signed checkpoints for the diff --git a/rust/theoros/src/storage/updates.rs b/rust/theoros/src/storage/updates.rs index b94226dd..9cc552cb 100644 --- a/rust/theoros/src/storage/updates.rs +++ b/rust/theoros/src/storage/updates.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use alloy::primitives::U256; -use anyhow::Result; use tokio::sync::RwLock; use crate::types::hyperlane::DispatchUpdateInfos; @@ -12,15 +11,14 @@ pub struct LatestUpdatePerFeedStorage(RwLock> impl LatestUpdatePerFeedStorage { /// Insert the latest [`DispatchUpdateInfos`] for a feed id. - pub async fn add(&self, feed_id: U256, event: DispatchUpdateInfos) -> Result<()> { + pub async fn add(&self, feed_id: U256, event: DispatchUpdateInfos) { let mut lock = self.0.write().await; lock.insert(feed_id, event); - Ok(()) } /// Retrieves the latest [`DispatchUpdateInfos`] for a feed id. - pub async fn get(&self, feed_id: &U256) -> Result> { + pub async fn get(&self, feed_id: &U256) -> Option { let lock = self.0.read().await; - Ok(lock.get(feed_id).cloned()) + lock.get(feed_id).cloned() } } diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index ca5cd37e..1b9725de 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -34,7 +34,7 @@ pub struct Calldata { impl Calldata { pub async fn build_from(state: &AppState, chain_name: EvmChainName, feed_id: String) -> anyhow::Result { let feed_id = hex_str_to_u256(&feed_id)?; - let update_info = state.storage.latest_update_per_feed().get(&feed_id).await?.context("No update found")?; + let update_info = state.storage.latest_update_per_feed().get(&feed_id).await.context("No update found")?; let validator_index_map = state.hyperlane_validators_mapping.get_validators(&chain_name).context("No validators found")?; From 3e9772223900bc8b1388d5f66f02a24715810b2e Mon Sep 17 00:00:00 2001 From: akhercha Date: Sun, 3 Nov 2024 17:40:01 +0100 Subject: [PATCH 51/55] dev(better_theoros): Lint --- typescript/theoros-sdk/tsconfig.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/typescript/theoros-sdk/tsconfig.json b/typescript/theoros-sdk/tsconfig.json index e5b06d2b..d5892f9e 100644 --- a/typescript/theoros-sdk/tsconfig.json +++ b/typescript/theoros-sdk/tsconfig.json @@ -24,9 +24,7 @@ "noUnusedParameters": false, "noPropertyAccessFromIndexSignature": false, "paths": { - "@pragmaoracle/theoros-sdk": [ - "./src/index.ts" - ] - }, + "@pragmaoracle/theoros-sdk": ["./src/index.ts"] + } } } From 0e9a31842b85884b0572f87e9d3eb11949e6da2e Mon Sep 17 00:00:00 2001 From: akhercha Date: Sun, 3 Nov 2024 17:41:39 +0100 Subject: [PATCH 52/55] dev(better_theoros): docs --- rust/theoros/src/services/hyperlane/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 221eb28f..776ddaa3 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -165,6 +165,8 @@ impl HyperlaneService { Ok(()) } + /// Sends a websocket notification to any client that *might* be listening. + /// Allows them to retrieve the latest update instantly after it is stored. async fn send_websocket_notification(&self) { match self.storage.feeds_updated_tx().send(NewUpdatesAvailableEvent::New) { Ok(_) => { From 2ddc683149284147141f741b8b13d0dfc413c2ab Mon Sep 17 00:00:00 2001 From: akhercha Date: Sun, 3 Nov 2024 18:07:48 +0100 Subject: [PATCH 53/55] dev(better_theoros): Use DashMap / DashSet where applicable --- rust/Cargo.lock | 5 +-- rust/Cargo.toml | 1 + rust/theoros/Cargo.toml | 1 + .../theoros/src/handlers/rest/get_calldata.rs | 2 +- .../src/handlers/rest/get_data_feeds.rs | 4 +-- .../websocket/subscribe_to_calldata.rs | 2 +- rust/theoros/src/services/hyperlane/mod.rs | 20 +++++------ rust/theoros/src/services/indexer/mod.rs | 14 ++++---- rust/theoros/src/storage/checkpoints.rs | 35 +++++++++--------- rust/theoros/src/storage/feed_id.rs | 36 +++++++++---------- rust/theoros/src/storage/updates.rs | 16 ++++----- rust/theoros/src/storage/validator.rs | 16 ++++----- rust/theoros/src/types/calldata.rs | 4 +-- 13 files changed, 76 insertions(+), 80 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 52a1f988..196c2c5b 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1483,9 +1483,9 @@ dependencies = [ [[package]] name = "dashmap" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", "crossbeam-utils", @@ -4893,6 +4893,7 @@ dependencies = [ "axum-macros", "chrono", "clap", + "dashmap", "futures", "futures-util", "hyper 0.14.30", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index ad1547a6..38ef2f02 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -17,6 +17,7 @@ anyhow = "1.0.86" async-trait = "0.1.81" clap = { version = "4.5.16", features = ["derive", "env"] } chrono = { version = "0.4.38", features = ["serde"] } +dashmap = { version = "6.1.0" } alloy = { version = "0.5.2", features = ["full"] } futures = { version = "0.3.30", features = ["std"] } futures-util = "0.3.30" diff --git a/rust/theoros/Cargo.toml b/rust/theoros/Cargo.toml index cd0004ab..b9af05a3 100644 --- a/rust/theoros/Cargo.toml +++ b/rust/theoros/Cargo.toml @@ -13,6 +13,7 @@ axum = { workspace = true, features = ["macros", "ws", "tokio"] } axum-macros = { workspace = true } chrono = { workspace = true, features = ["serde"] } clap = { workspace = true, features = ["derive", "env"] } +dashmap = { workspace = true } futures = { workspace = true, features = ["std"] } futures-util = { workspace = true } hyper = { workspace = true, features = ["server"] } diff --git a/rust/theoros/src/handlers/rest/get_calldata.rs b/rust/theoros/src/handlers/rest/get_calldata.rs index a74f2450..39c97ac5 100644 --- a/rust/theoros/src/handlers/rest/get_calldata.rs +++ b/rust/theoros/src/handlers/rest/get_calldata.rs @@ -61,7 +61,7 @@ pub async fn get_calldata( let stored_feed_ids = state.storage.feed_ids(); // Check if all requested feed IDs are supported. - if let Some(missing_id) = stored_feed_ids.contains_vec(¶ms.feed_ids).await { + if let Some(missing_id) = stored_feed_ids.contains_vec(¶ms.feed_ids) { return Err(GetCalldataError::FeedNotFound(missing_id)); } diff --git a/rust/theoros/src/handlers/rest/get_data_feeds.rs b/rust/theoros/src/handlers/rest/get_data_feeds.rs index 0af8769c..4e14e7d0 100644 --- a/rust/theoros/src/handlers/rest/get_data_feeds.rs +++ b/rust/theoros/src/handlers/rest/get_data_feeds.rs @@ -23,8 +23,8 @@ pub async fn get_data_feeds(State(state): State) -> Result = validators_fetchers.keys().cloned().collect(); for &nonce in &unsigned_nonces { - if !self.all_validators_signed_nonce(&validator_addresses, nonce).await { + if !self.all_validators_signed_nonce(&validator_addresses, nonce) { continue; } // TODO: If the nonce n+1 is fully signed, shall we ignore every nonces before..? Or raise an alert? @@ -99,8 +99,8 @@ impl HyperlaneService { } /// Checks if all validators have signed a given nonce. - async fn all_validators_signed_nonce(&self, validators_addresses: &[Felt], nonce: u32) -> bool { - self.storage.signed_checkpoints().all_validators_signed_nonce(validators_addresses, nonce).await + fn all_validators_signed_nonce(&self, validators_addresses: &[Felt], nonce: u32) -> bool { + self.storage.signed_checkpoints().all_validators_signed_nonce(validators_addresses, nonce) } /// Given a validator & a nonce, query the fetcher to try to get the signed checkpoint. @@ -112,13 +112,13 @@ impl HyperlaneService { nonce: u32, ) -> anyhow::Result<()> { // If the validator already signed this nonce, ignore - if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce).await { + if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce) { return Ok(()); } match fetcher.fetch(nonce).await { Ok(Some(checkpoint)) => { - self.store_signed_checkpoint(validator, checkpoint).await; + self.store_signed_checkpoint(validator, checkpoint); } Ok(None) => { tracing::debug!("πŸŒ‰ [Hyperlane] Validator {:#x} has not yet signed nonce {}", validator, nonce); @@ -136,15 +136,15 @@ impl HyperlaneService { } /// Store the signed checkpoint for the (validator;nonce) couple. - async fn store_signed_checkpoint(&self, validator: Felt, checkpoint: SignedCheckpointWithMessageId) { + fn store_signed_checkpoint(&self, validator: Felt, checkpoint: SignedCheckpointWithMessageId) { let nonce = checkpoint.value.checkpoint.index; - if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce).await { + if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce) { tracing::debug!("πŸŒ‰ [Hyperlane] Skipping duplicate checkpoint for validator {:#x}: #{}", validator, nonce); return; } - self.storage.signed_checkpoints().add(validator, nonce, checkpoint).await; + self.storage.signed_checkpoints().add(validator, nonce, checkpoint); tracing::info!("πŸŒ‰ [Hyperlane] Validator {:#x} signed checkpoint #{}", validator, nonce); } @@ -160,7 +160,7 @@ impl HyperlaneService { let dispatch_update_infos = DispatchUpdateInfos::new(&event, update); let feed_id = hex_str_to_u256(&update.feed_id())?; - self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos).await; + self.storage.latest_update_per_feed().add(feed_id, dispatch_update_infos); } Ok(()) } diff --git a/rust/theoros/src/services/indexer/mod.rs b/rust/theoros/src/services/indexer/mod.rs index 570fcd38..c2f72768 100644 --- a/rust/theoros/src/services/indexer/mod.rs +++ b/rust/theoros/src/services/indexer/mod.rs @@ -149,10 +149,10 @@ impl IndexerService { self.decode_validator_announce_event(event_data).await?; } selector if selector == &*NEW_FEED_ID_EVENT_SELECTOR => { - self.decode_new_feed_id_event(event_data).await?; + self.decode_new_feed_id_event(event_data); } selector if selector == &*REMOVED_FEED_ID_EVENT_SELECTOR => { - self.decode_removed_feed_id_event(event_data).await?; + self.decode_removed_feed_id_event(event_data); } _ => unreachable!(), } @@ -190,18 +190,16 @@ impl IndexerService { } /// Decodes a NewFeedId event from the Starknet event data. - async fn decode_new_feed_id_event(&self, event_data: Vec) -> anyhow::Result<()> { + fn decode_new_feed_id_event(&self, event_data: Vec) { let feed_id = event_data[1].to_hex_string(); tracing::info!("πŸ“¨ [Indexer] Indexed a NewFeedId event for: {}", feed_id); - self.state.storage.feed_ids().add(feed_id).await; - Ok(()) + self.state.storage.feed_ids().add(feed_id); } /// Decodes a RemovedFeedId event from the Starknet event data. - async fn decode_removed_feed_id_event(&self, event_data: Vec) -> anyhow::Result<()> { + fn decode_removed_feed_id_event(&self, event_data: Vec) { let feed_id = event_data[1].to_hex_string(); tracing::info!("πŸ“¨ [Indexer] Indexed a RemovedFeedId event for: {}", feed_id); - self.state.storage.feed_ids().remove(&feed_id).await; - Ok(()) + self.state.storage.feed_ids().remove(&feed_id); } } diff --git a/rust/theoros/src/storage/checkpoints.rs b/rust/theoros/src/storage/checkpoints.rs index b7d3d61f..7739b962 100644 --- a/rust/theoros/src/storage/checkpoints.rs +++ b/rust/theoros/src/storage/checkpoints.rs @@ -1,6 +1,7 @@ -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; use std::sync::Arc; +use dashmap::DashMap; use starknet::core::types::Felt; use tokio::sync::RwLock; @@ -38,26 +39,27 @@ impl UnsignedCheckpointsStorage { /// Mapping between the validators and their signed checkpoint for a given nonce. #[derive(Debug, Default)] -pub struct SignedCheckpointsStorage(RwLock>); +pub struct SignedCheckpointsStorage(Arc>); impl SignedCheckpointsStorage { + pub fn len(&self) -> usize { + self.0.len() + } + /// Adds or updates the [SignedCheckpointWithMessageId] for the given validator - pub async fn add(&self, validator: Felt, nonce: u32, checkpoint: SignedCheckpointWithMessageId) { - let mut lock = self.0.write().await; - lock.insert((validator, nonce), checkpoint); + pub fn add(&self, validator: Felt, nonce: u32, checkpoint: SignedCheckpointWithMessageId) { + self.0.insert((validator, nonce), checkpoint); } // For the provided list of validators, returns all their signed checkpoints for the // provided message_id. - pub async fn get(&self, validators: &[Felt], searched_nonce: u32) -> Vec<(Felt, SignedCheckpointWithMessageId)> { - let lock = self.0.read().await; - - let mut checkpoints = Vec::with_capacity(lock.len()); + pub fn get(&self, validators: &[Felt], searched_nonce: u32) -> Vec<(Felt, SignedCheckpointWithMessageId)> { + let mut checkpoints = Vec::with_capacity(self.len()); // Iterate over the map with tuple key (validator, message_id) - for ((validator, nonce), checkpoint) in lock.iter() { - // Only include if validator is in the provided list and message_id matches + for validator_signatures_map in self.0.iter() { + let (validator, nonce) = validator_signatures_map.key(); if nonce == &searched_nonce && validators.contains(validator) { - checkpoints.push((*validator, checkpoint.clone())); + checkpoints.push((*validator, validator_signatures_map.value().clone())); } } @@ -65,13 +67,12 @@ impl SignedCheckpointsStorage { } // Check if the given validator has a checkpoint for the given nonce. - pub async fn validator_signed_nonce(&self, validator: Felt, nonce: u32) -> bool { - self.0.read().await.contains_key(&(validator, nonce)) + pub fn validator_signed_nonce(&self, validator: Felt, nonce: u32) -> bool { + self.0.contains_key(&(validator, nonce)) } /// Checks if all validators have signed a nonce. - pub async fn all_validators_signed_nonce(&self, validators: &[Felt], nonce: u32) -> bool { - let lock = self.0.read().await; - validators.iter().all(|validator| lock.contains_key(&(*validator, nonce))) + pub fn all_validators_signed_nonce(&self, validators: &[Felt], nonce: u32) -> bool { + validators.iter().all(|validator| self.0.contains_key(&(*validator, nonce))) } } diff --git a/rust/theoros/src/storage/feed_id.rs b/rust/theoros/src/storage/feed_id.rs index 6195470a..72a05090 100644 --- a/rust/theoros/src/storage/feed_id.rs +++ b/rust/theoros/src/storage/feed_id.rs @@ -1,42 +1,40 @@ -use std::collections::HashSet; +use dashmap::DashSet; use std::sync::Arc; -use tokio::sync::RwLock; /// Contains the registered feed ids. #[derive(Debug, Default, Clone)] -pub struct FeedIdsStorage(Arc>>); +pub struct FeedIdsStorage(Arc>); impl FeedIdsStorage { pub fn from_rpc_response(feed_ids: Vec) -> Self { - Self(Arc::new(RwLock::new(feed_ids.into_iter().collect()))) + let set = DashSet::new(); + for id in feed_ids { + set.insert(id); + } + Self(Arc::new(set)) } - pub async fn add(&self, feed_id: String) { - let mut lock = self.0.write().await; - lock.insert(feed_id); + pub fn add(&self, feed_id: String) { + self.0.insert(feed_id); } - pub async fn remove(&self, feed_id: &str) { - let mut lock = self.0.write().await; - lock.remove(feed_id); + pub fn remove(&self, feed_id: &str) { + self.0.remove(feed_id); } /// Checks if all feed IDs in the given vector are present in the storage. /// Returns None if all IDs are present, or Some(id) with the first missing ID. - pub async fn contains_vec(&self, feed_ids: &[String]) -> Option { - let lock = self.0.read().await; - feed_ids.iter().find(|id| !lock.contains(*id)).cloned() + pub fn contains_vec(&self, feed_ids: &[String]) -> Option { + feed_ids.iter().find(|id| !self.0.contains(*id)).cloned() } /// Returns the number of feed IDs in the storage. - pub async fn len(&self) -> usize { - let lock = self.0.read().await; - lock.len() + pub fn len(&self) -> usize { + self.0.len() } /// Returns an iterator over the feed IDs. - pub async fn iter(&self) -> impl Iterator { - let lock = self.0.read().await; - lock.iter().cloned().collect::>().into_iter() + pub fn iter(&self) -> impl Iterator { + self.0.iter().map(|ref_multi| ref_multi.key().clone()).collect::>().into_iter() } } diff --git a/rust/theoros/src/storage/updates.rs b/rust/theoros/src/storage/updates.rs index 9cc552cb..495b83d2 100644 --- a/rust/theoros/src/storage/updates.rs +++ b/rust/theoros/src/storage/updates.rs @@ -1,24 +1,22 @@ -use std::collections::HashMap; +use std::sync::Arc; use alloy::primitives::U256; -use tokio::sync::RwLock; +use dashmap::DashMap; use crate::types::hyperlane::DispatchUpdateInfos; /// Contains a mapping between feed ids and their latest dispatch update. #[derive(Debug, Default)] -pub struct LatestUpdatePerFeedStorage(RwLock>); +pub struct LatestUpdatePerFeedStorage(Arc>); impl LatestUpdatePerFeedStorage { /// Insert the latest [`DispatchUpdateInfos`] for a feed id. - pub async fn add(&self, feed_id: U256, event: DispatchUpdateInfos) { - let mut lock = self.0.write().await; - lock.insert(feed_id, event); + pub fn add(&self, feed_id: U256, event: DispatchUpdateInfos) { + self.0.insert(feed_id, event); } /// Retrieves the latest [`DispatchUpdateInfos`] for a feed id. - pub async fn get(&self, feed_id: &U256) -> Option { - let lock = self.0.read().await; - lock.get(feed_id).cloned() + pub fn get(&self, feed_id: &U256) -> Option { + self.0.get(feed_id).map(|r| r.value().clone()) } } diff --git a/rust/theoros/src/storage/validator.rs b/rust/theoros/src/storage/validator.rs index 3c7c5fb7..191e3cca 100644 --- a/rust/theoros/src/storage/validator.rs +++ b/rust/theoros/src/storage/validator.rs @@ -2,18 +2,18 @@ use std::str::FromStr; use std::{collections::HashMap, sync::Arc}; use anyhow::bail; +use dashmap::DashMap; use starknet::core::types::Felt; -use tokio::sync::RwLock; use crate::types::hyperlane::{CheckpointStorage, FetchFromStorage, ValidatorAnnouncementEvent}; /// Mapping between the validators and their fetcher used to /// retrieve signed checkpoints. #[derive(Debug, Default)] -pub struct ValidatorsFetchersStorage(RwLock>>>); +pub struct ValidatorsFetchersStorage(Arc>>>); impl ValidatorsFetchersStorage { - /// Fills the [HashMap] with the initial state fetched from the RPC. + /// Fills the [DashMap] with the initial state fetched from the RPC. pub async fn fill_with_initial_state( &mut self, validators: Vec, @@ -23,7 +23,6 @@ impl ValidatorsFetchersStorage { bail!("β›” Validators and locations vectors must have the same length"); } - let mut lock = self.0.write().await; for (validator, location) in validators.into_iter().zip(locations.into_iter()) { // TODO: This should be a feature. We sometime want to have a local storage. if location[location.len() - 1].starts_with("file") { @@ -31,7 +30,7 @@ impl ValidatorsFetchersStorage { } let storage = CheckpointStorage::from_str(&location[location.len() - 1])?; let storage_fetcher = storage.build().await?; - lock.insert(validator, Arc::new(storage_fetcher)); + self.0.insert(validator, Arc::new(storage_fetcher)); } Ok(()) @@ -40,8 +39,7 @@ impl ValidatorsFetchersStorage { /// Adds or updates the [CheckpointStorage] for the given validator pub async fn build_and_add(&self, validator: Felt, storage: CheckpointStorage) -> anyhow::Result<()> { let storage_fetcher = storage.build().await?; - let mut lock = self.0.write().await; - lock.insert(validator, Arc::new(storage_fetcher)); + self.0.insert(validator, Arc::new(storage_fetcher)); Ok(()) } @@ -59,7 +57,7 @@ impl ValidatorsFetchersStorage { } /// Returns all registered mappings between validators & their location storage. - pub async fn all(&self) -> HashMap>> { - self.0.read().await.clone() + pub fn all(&self) -> HashMap>> { + self.0.iter().map(|entry| (*entry.key(), entry.value().clone())).collect() } } diff --git a/rust/theoros/src/types/calldata.rs b/rust/theoros/src/types/calldata.rs index 1b9725de..7f2dfd92 100644 --- a/rust/theoros/src/types/calldata.rs +++ b/rust/theoros/src/types/calldata.rs @@ -34,13 +34,13 @@ pub struct Calldata { impl Calldata { pub async fn build_from(state: &AppState, chain_name: EvmChainName, feed_id: String) -> anyhow::Result { let feed_id = hex_str_to_u256(&feed_id)?; - let update_info = state.storage.latest_update_per_feed().get(&feed_id).await.context("No update found")?; + let update_info = state.storage.latest_update_per_feed().get(&feed_id).context("No update found")?; let validator_index_map = state.hyperlane_validators_mapping.get_validators(&chain_name).context("No validators found")?; let validators: Vec = validator_index_map.keys().copied().collect(); - let checkpoints = state.storage.signed_checkpoints().get(&validators, update_info.nonce).await; + let checkpoints = state.storage.signed_checkpoints().get(&validators, update_info.nonce); anyhow::ensure!(!checkpoints.is_empty(), "No signatures found"); // Ensure all nonce have the same checkpoint From 98dffdd4a1445132e93e6ae32cfe585e1d8fed23 Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Sun, 3 Nov 2024 18:25:44 +0100 Subject: [PATCH 54/55] fix: remove box --- rust/theoros/src/services/hyperlane/mod.rs | 2 +- rust/theoros/src/storage/validator.rs | 8 ++++---- .../src/types/hyperlane/checkpoint_fetchers/mod.rs | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index 2f25c66e..b75c8329 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -108,7 +108,7 @@ impl HyperlaneService { async fn fetch_checkpoint_for_validator( &self, validator: Felt, - fetcher: Arc>, + fetcher: Arc, nonce: u32, ) -> anyhow::Result<()> { // If the validator already signed this nonce, ignore diff --git a/rust/theoros/src/storage/validator.rs b/rust/theoros/src/storage/validator.rs index 191e3cca..d09539a2 100644 --- a/rust/theoros/src/storage/validator.rs +++ b/rust/theoros/src/storage/validator.rs @@ -10,7 +10,7 @@ use crate::types::hyperlane::{CheckpointStorage, FetchFromStorage, ValidatorAnno /// Mapping between the validators and their fetcher used to /// retrieve signed checkpoints. #[derive(Debug, Default)] -pub struct ValidatorsFetchersStorage(Arc>>>); +pub struct ValidatorsFetchersStorage(Arc>>); impl ValidatorsFetchersStorage { /// Fills the [DashMap] with the initial state fetched from the RPC. @@ -30,7 +30,7 @@ impl ValidatorsFetchersStorage { } let storage = CheckpointStorage::from_str(&location[location.len() - 1])?; let storage_fetcher = storage.build().await?; - self.0.insert(validator, Arc::new(storage_fetcher)); + self.0.insert(validator, storage_fetcher); } Ok(()) @@ -39,7 +39,7 @@ impl ValidatorsFetchersStorage { /// Adds or updates the [CheckpointStorage] for the given validator pub async fn build_and_add(&self, validator: Felt, storage: CheckpointStorage) -> anyhow::Result<()> { let storage_fetcher = storage.build().await?; - self.0.insert(validator, Arc::new(storage_fetcher)); + self.0.insert(validator, storage_fetcher); Ok(()) } @@ -57,7 +57,7 @@ impl ValidatorsFetchersStorage { } /// Returns all registered mappings between validators & their location storage. - pub fn all(&self) -> HashMap>> { + pub fn all(&self) -> HashMap> { self.0.iter().map(|entry| (*entry.key(), entry.value().clone())).collect() } } diff --git a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs index db4898cb..6db41c73 100644 --- a/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs +++ b/rust/theoros/src/types/hyperlane/checkpoint_fetchers/mod.rs @@ -6,6 +6,7 @@ pub mod s3; // https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/3e90734310fb1ca9a607ce3d334015fa7aaa9208/rust/hyperlane-base/src/settings/checkpoint_syncer.rs#L14 use std::fmt::Debug; +use std::sync::Arc; use std::{env, path::PathBuf}; use anyhow::{anyhow, bail, Context, Error, Result}; @@ -115,11 +116,11 @@ impl FromStr for CheckpointStorage { impl CheckpointStorage { /// Turn conf info a Checkpoint Syncer - pub async fn build(&self) -> Result> { + pub async fn build(&self) -> Result> { Ok(match self { - CheckpointStorage::LocalStorage { path } => Box::new(LocalStorage::new(path.clone())?), + CheckpointStorage::LocalStorage { path } => Arc::new(LocalStorage::new(path.clone())?), CheckpointStorage::S3 { bucket, folder, region } => { - Box::new(S3Storage::new(bucket.clone(), folder.clone(), region.clone())) + Arc::new(S3Storage::new(bucket.clone(), folder.clone(), region.clone())) } CheckpointStorage::Gcs { bucket, folder, service_account_key, user_secrets } => { let auth = if let Some(path) = service_account_key { @@ -131,7 +132,7 @@ impl CheckpointStorage { AuthFlow::NoAuth }; - Box::new(GcsStorageClientBuilder::new(auth).build(bucket, folder.to_owned()).await?) + Arc::new(GcsStorageClientBuilder::new(auth).build(bucket, folder.to_owned()).await?) } }) } From c6a2de35f0128c92b4211c67c328a47264ea3fab Mon Sep 17 00:00:00 2001 From: akhercha Date: Sun, 3 Nov 2024 18:39:11 +0100 Subject: [PATCH 55/55] dev(better_theoros): Removed useless Result --- rust/theoros/src/services/hyperlane/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rust/theoros/src/services/hyperlane/mod.rs b/rust/theoros/src/services/hyperlane/mod.rs index b75c8329..9f31c398 100644 --- a/rust/theoros/src/services/hyperlane/mod.rs +++ b/rust/theoros/src/services/hyperlane/mod.rs @@ -110,10 +110,10 @@ impl HyperlaneService { validator: Felt, fetcher: Arc, nonce: u32, - ) -> anyhow::Result<()> { + ) { // If the validator already signed this nonce, ignore if self.storage.signed_checkpoints().validator_signed_nonce(validator, nonce) { - return Ok(()); + return; } match fetcher.fetch(nonce).await { @@ -132,7 +132,6 @@ impl HyperlaneService { ); } } - Ok(()) } /// Store the signed checkpoint for the (validator;nonce) couple.