diff --git a/Cargo.lock b/Cargo.lock index b351a18ece36..695e93c7feb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,7 +59,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "const-random", "getrandom 0.2.15", "once_cell", "version_check", @@ -501,7 +500,7 @@ dependencies = [ "alloy-primitives", "alloy-pubsub", "alloy-rpc-client 0.4.2", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", "alloy-transport 0.4.2", @@ -635,18 +634,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-admin" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fefd12e99dd6b7de387ed13ad047ce2c90d8950ca62fc48b8a457ebb8f936c61" -dependencies = [ - "alloy-genesis 0.3.6", - "alloy-primitives", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-admin" version = "0.4.2" @@ -659,17 +646,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-anvil" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25cb45ad7c0930dd62eecf164d2afe4c3d2dd2c82af85680ad1f118e1e5cb83" -dependencies = [ - "alloy-primitives", - "alloy-serde 0.3.6", - "serde", -] - [[package]] name = "alloy-rpc-types-anvil" version = "0.4.2" @@ -681,20 +657,6 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-beacon" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7081d2206dca51ce23a06338d78d9b536931cc3f15134fc1c6535eb2b77f18" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rpc-types-engine 0.3.6", - "serde", - "serde_with", - "thiserror", -] - [[package]] name = "alloy-rpc-types-beacon" version = "0.4.2" @@ -731,7 +693,8 @@ dependencies = [ "alloy-rlp", "alloy-serde 0.3.6", "derive_more 1.0.0", - "jsonrpsee-types", + "jsonwebtoken", + "rand 0.8.5", "serde", ] @@ -771,7 +734,6 @@ dependencies = [ "derive_more 1.0.0", "hashbrown 0.14.5", "itertools 0.13.0", - "jsonrpsee-types", "serde", "serde_json", ] @@ -796,19 +758,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-mev" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922d92389e5022650c4c60ffd2f9b2467c3f853764f0f74ff16a23106f9017d5" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-serde 0.3.6", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-mev" version = "0.4.2" @@ -822,20 +771,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-rpc-types-trace" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98db35cd42c90b484377e6bc44d95377a7a38a5ebee996e67754ac0446d542ab" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth 0.3.6", - "alloy-serde 0.3.6", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "alloy-rpc-types-trace" version = "0.4.2" @@ -850,18 +785,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "alloy-rpc-types-txpool" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bac37082c3b21283b3faf5cc0e08974272aee2f756ce1adeb26db56a5fce0d5" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth 0.3.6", - "alloy-serde 0.3.6", - "serde", -] - [[package]] name = "alloy-rpc-types-txpool" version = "0.4.2" @@ -1223,42 +1146,10 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "antelope-client" -version = "0.2.1" -source = "git+https://github.com/telosnetwork/antelope-rs?branch=development#ed53c75b6b9ce14aa72002ddd491a6697ae563d9" -dependencies = [ - "antelope-client-macros", - "async-trait", - "base64 0.21.7", - "bs58", - "chrono", - "digest 0.10.7", - "ecdsa", - "flate2", - "hex", - "hmac 0.12.1", - "k256", - "log", - "once_cell", - "p256", - "rand 0.8.5", - "rand_core 0.6.4", - "reqwest 0.11.27", - "ripemd", - "serde", - "serde-big-array", - "serde_json", - "sha2 0.10.8", - "signature", - "thiserror", - "tokio", -] - [[package]] name = "antelope-client" version = "0.3.0" -source = "git+https://github.com/telosnetwork/antelope-rs?branch=master#fea2203b2edb5cfcedd5365031e5286b47dc5c66" +source = "git+https://github.com/telosnetwork/antelope-rs?rev=d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec#d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec" dependencies = [ "antelope-client-macros", "async-trait", @@ -1463,248 +1354,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "arrow" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219d05930b81663fd3b32e3bde8ce5bff3c4d23052a99f11a8fa50a3b47b2658" -dependencies = [ - "arrow-arith", - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-csv", - "arrow-data", - "arrow-ipc", - "arrow-json", - "arrow-ord", - "arrow-row", - "arrow-schema", - "arrow-select", - "arrow-string", -] - -[[package]] -name = "arrow-arith" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0272150200c07a86a390be651abdd320a2d12e84535f0837566ca87ecd8f95e0" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "num", -] - -[[package]] -name = "arrow-array" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8010572cf8c745e242d1b632bd97bd6d4f40fefed5ed1290a8f433abaa686fea" -dependencies = [ - "ahash", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "hashbrown 0.14.5", - "num", -] - -[[package]] -name = "arrow-buffer" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0a2432f0cba5692bf4cb757469c66791394bac9ec7ce63c1afe74744c37b27" -dependencies = [ - "bytes", - "half", - "num", -] - -[[package]] -name = "arrow-cast" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9abc10cd7995e83505cc290df9384d6e5412b207b79ce6bdff89a10505ed2cba" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "atoi", - "base64 0.22.1", - "chrono", - "half", - "lexical-core", - "num", - "ryu", -] - -[[package]] -name = "arrow-csv" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95cbcba196b862270bf2a5edb75927380a7f3a163622c61d40cbba416a6305f2" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "csv", - "csv-core", - "lazy_static", - "lexical-core", - "regex", -] - -[[package]] -name = "arrow-data" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2742ac1f6650696ab08c88f6dd3f0eb68ce10f8c253958a18c943a68cd04aec5" -dependencies = [ - "arrow-buffer", - "arrow-schema", - "half", - "num", -] - -[[package]] -name = "arrow-ipc" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ea853130f7e78b9b9d178cb4cd01dee0f78e64d96c2949dc0a915d6d9e19d" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "flatbuffers", -] - -[[package]] -name = "arrow-json" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaafb5714d4e59feae964714d724f880511500e3569cc2a94d02456b403a2a49" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "half", - "indexmap 2.6.0", - "lexical-core", - "num", - "serde", - "serde_json", -] - -[[package]] -name = "arrow-ord" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3e6b61e3dc468f503181dccc2fc705bdcc5f2f146755fa5b56d0a6c5943f412" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "half", - "num", -] - -[[package]] -name = "arrow-row" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848ee52bb92eb459b811fb471175ea3afcf620157674c8794f539838920f9228" -dependencies = [ - "ahash", - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "half", - "hashbrown 0.14.5", -] - -[[package]] -name = "arrow-schema" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d9483aaabe910c4781153ae1b6ae0393f72d9ef757d38d09d450070cf2e528" - -[[package]] -name = "arrow-select" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "849524fa70e0e3c5ab58394c770cb8f514d0122d20de08475f7b472ed8075830" -dependencies = [ - "ahash", - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "num", -] - -[[package]] -name = "arrow-string" -version = "51.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9373cb5a021aee58863498c37eb484998ef13377f69989c6c5ccfbd258236cdb" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "memchr", - "num", - "regex", - "regex-syntax 0.8.5", -] - -[[package]] -name = "arrowbatch" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e304bae8e33446c64842dba444042ce65cb23e2b1e439fa2f4abb7591db562c5" -dependencies = [ - "arrow", - "base64 0.22.1", - "chrono", - "env_logger 0.10.2", - "futures", - "futures-util", - "hex", - "log", - "moka", - "num", - "num-bigint", - "rlp", - "serde", - "serde_json", - "tokio", - "tokio-tungstenite 0.21.0", - "tungstenite 0.21.0", - "uuid", - "zstd", -] - [[package]] name = "asn1_der" version = "0.7.6" @@ -1802,15 +1451,6 @@ dependencies = [ "rustc_version 0.4.1", ] -[[package]] -name = "atoi" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" -dependencies = [ - "num-traits", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -2678,26 +2318,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "const-random" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" -dependencies = [ - "const-random-macro", -] - -[[package]] -name = "const-random-macro" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" -dependencies = [ - "getrandom 0.2.15", - "once_cell", - "tiny-keccak", -] - [[package]] name = "const_format" version = "0.2.33" @@ -3492,19 +3112,6 @@ dependencies = [ "regex", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.11.5" @@ -3545,7 +3152,7 @@ name = "example-beacon-api-sidecar-fetcher" version = "0.1.0" dependencies = [ "alloy-primitives", - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-beacon", "clap", "eyre", "futures-util", @@ -3561,7 +3168,7 @@ dependencies = [ name = "example-beacon-api-sse" version = "0.0.0" dependencies = [ - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-beacon", "clap", "futures-util", "mev-share-sse", @@ -3837,7 +3444,7 @@ name = "example-txpool-tracing" version = "0.0.0" dependencies = [ "alloy-primitives", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "clap", "futures-util", "reth", @@ -3948,16 +3555,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "flatbuffers" -version = "23.5.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac53e22462d78c16d64a1cd22371b54cc3fe94aa15e7886a2fa6e5d1ab8640" -dependencies = [ - "bitflags 1.3.2", - "rustc_version 0.4.1", -] - [[package]] name = "flate2" version = "1.0.34" @@ -4318,7 +3915,6 @@ checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", - "num-traits", ] [[package]] @@ -5495,70 +5091,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -[[package]] -name = "lexical-core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" -dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", -] - -[[package]] -name = "lexical-parse-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" -dependencies = [ - "lexical-parse-integer", - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-parse-integer" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" -dependencies = [ - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-util" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" -dependencies = [ - "static_assertions", -] - -[[package]] -name = "lexical-write-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" -dependencies = [ - "lexical-util", - "lexical-write-integer", - "static_assertions", -] - -[[package]] -name = "lexical-write-integer" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" -dependencies = [ - "lexical-util", - "static_assertions", -] - [[package]] name = "libc" version = "0.2.159" @@ -6365,20 +5897,6 @@ dependencies = [ "spin", ] -[[package]] -name = "op-alloy-genesis" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1b8a9b70da0e027242ec1762f0f3a386278b6291d00d12ff5a64929dc19f68" -dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-sol-types", - "serde", - "serde_repr", -] - [[package]] name = "op-alloy-genesis" version = "0.3.3" @@ -6407,23 +5925,6 @@ dependencies = [ "op-alloy-rpc-types 0.3.3", ] -[[package]] -name = "op-alloy-protocol" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf300a82ae2d30e2255bfea87a2259da49f63a25a44db561ae64cc9e3084139f" -dependencies = [ - "alloy-consensus 0.3.6", - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.3.6", - "hashbrown 0.14.5", - "op-alloy-consensus 0.2.12", - "op-alloy-genesis 0.2.12", - "serde", -] - [[package]] name = "op-alloy-protocol" version = "0.3.3" @@ -6437,7 +5938,7 @@ dependencies = [ "alloy-serde 0.4.2", "derive_more 1.0.0", "op-alloy-consensus 0.3.3", - "op-alloy-genesis 0.3.3", + "op-alloy-genesis", "serde", ] @@ -6476,23 +5977,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "op-alloy-rpc-types-engine" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2947272a81ebf988f4804b6f0f6a7c0b2f6f89a908cb410e36f8f3828f81c778" -dependencies = [ - "alloy-eips 0.3.6", - "alloy-primitives", - "alloy-rpc-types-engine 0.3.6", - "alloy-serde 0.3.6", - "derive_more 1.0.0", - "op-alloy-consensus 0.2.12", - "op-alloy-genesis 0.2.12", - "op-alloy-protocol 0.2.12", - "serde", -] - [[package]] name = "op-alloy-rpc-types-engine" version = "0.3.3" @@ -6503,7 +5987,7 @@ dependencies = [ "alloy-rpc-types-engine 0.4.2", "alloy-serde 0.4.2", "derive_more 1.0.0", - "op-alloy-protocol 0.3.3", + "op-alloy-protocol", "serde", ] @@ -8354,7 +7838,7 @@ dependencies = [ "futures-util", "jsonrpsee", "jsonrpsee-types", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "reth", "reth-chainspec", "reth-db", @@ -9107,7 +8591,7 @@ name = "reth-network-api" version = "1.0.8" dependencies = [ "alloy-primitives", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "auto_impl", "derive_more 1.0.0", "enr", @@ -9415,7 +8899,7 @@ dependencies = [ name = "reth-node-telos" version = "1.0.8" dependencies = [ - "alloy-consensus 0.4.2", + "alloy-consensus 0.3.6", "alloy-contract", "alloy-network 0.4.2", "alloy-primitives", @@ -9425,11 +8909,12 @@ dependencies = [ "alloy-signer-local", "alloy-sol-types", "alloy-transport-http 0.4.2", - "antelope-client 0.3.0", + "antelope-client", "clap", "derive_more 1.0.0", - "env_logger 0.11.5", + "env_logger", "eyre", + "num-bigint", "reqwest 0.12.8", "reth", "reth-auto-seal-consensus", @@ -9601,7 +9086,7 @@ dependencies = [ "jsonrpsee", "jsonrpsee-types", "op-alloy-consensus 0.3.3", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "parking_lot 0.12.3", "reqwest 0.12.8", "reth", @@ -9648,7 +9133,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types-engine 0.4.2", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "reth-basic-payload-builder", "reth-chain-state", "reth-chainspec", @@ -9760,7 +9245,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "async-trait", - "op-alloy-rpc-types-engine 0.3.3", + "op-alloy-rpc-types-engine", "pin-project", "reth-chain-state", "reth-chainspec", @@ -10042,12 +9527,12 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-types 0.4.2", - "alloy-rpc-types-admin 0.4.2", + "alloy-rpc-types-admin", "alloy-rpc-types-debug", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", - "alloy-rpc-types-trace 0.4.2", - "alloy-rpc-types-txpool 0.4.2", + "alloy-rpc-types-mev", + "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-serde 0.4.2", "alloy-signer 0.4.2", "alloy-signer-local", @@ -10107,15 +9592,15 @@ dependencies = [ "alloy-json-rpc 0.4.2", "alloy-primitives", "alloy-rpc-types 0.4.2", - "alloy-rpc-types-admin 0.4.2", - "alloy-rpc-types-anvil 0.4.2", - "alloy-rpc-types-beacon 0.4.2", + "alloy-rpc-types-admin", + "alloy-rpc-types-anvil", + "alloy-rpc-types-beacon", "alloy-rpc-types-debug", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", - "alloy-rpc-types-trace 0.4.2", - "alloy-rpc-types-txpool 0.4.2", + "alloy-rpc-types-mev", + "alloy-rpc-types-trace", + "alloy-rpc-types-txpool", "alloy-serde 0.4.2", "jsonrpsee", "reth-engine-primitives", @@ -10133,7 +9618,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "futures", "jsonrpsee", "jsonrpsee-http-client", @@ -10154,7 +9639,7 @@ dependencies = [ "alloy-rpc-types 0.4.2", "alloy-rpc-types-engine 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "alloy-serde 0.4.2", "clap", "http 1.1.0", @@ -10245,7 +9730,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types 0.4.2", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-mev 0.4.2", + "alloy-rpc-types-mev", "async-trait", "auto_impl", "dyn-clone", @@ -10348,26 +9833,6 @@ dependencies = [ "strum", ] -[[package]] -name = "reth-rpc-types" -version = "1.0.6" -source = "git+https://github.com/telosnetwork/telos-reth?branch=telos-main#63d23e00982a0ab7704a6dff97b3f5d355e11d56" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types 0.3.6", - "alloy-rpc-types-admin 0.3.6", - "alloy-rpc-types-anvil 0.3.6", - "alloy-rpc-types-beacon 0.3.6", - "alloy-rpc-types-engine 0.3.6", - "alloy-rpc-types-mev 0.3.6", - "alloy-rpc-types-trace 0.3.6", - "alloy-rpc-types-txpool 0.3.6", - "alloy-serde 0.3.6", - "jsonrpsee-types", - "op-alloy-rpc-types 0.2.12", - "op-alloy-rpc-types-engine 0.2.12", -] - [[package]] name = "reth-rpc-types-compat" version = "1.0.8" @@ -10610,12 +10075,13 @@ dependencies = [ "alloy-network 0.4.2", "alloy-primitives", "alloy-rpc-types 0.4.2", - "antelope-client 0.3.0", + "antelope-client", "async-trait", "derive_more 1.0.0", "jsonrpsee-types", "log", "parking_lot 0.12.3", + "regex", "reth-chainspec", "reth-evm", "reth-network-api", @@ -10899,7 +10365,7 @@ source = "git+https://github.com/telosnetwork/telos-evm-inspectors?branch=telos- dependencies = [ "alloy-primitives", "alloy-rpc-types-eth 0.4.2", - "alloy-rpc-types-trace 0.4.2", + "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "boa_engine", @@ -12078,13 +11544,14 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "telos-consensus-client" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=f8ecbe1aeea57911c9fbefdddf49efa92d8472ce#f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=9fadee1fd565e3a7ad51c1142e2673df52bd9028#9fadee1fd565e3a7ad51c1142e2673df52bd9028" dependencies = [ "alloy", "alloy-consensus 0.3.6", "alloy-rlp", - "antelope-client 0.2.1", - "arrowbatch", + "alloy-rpc-types 0.3.6", + "alloy-rpc-types-engine 0.3.6", + "antelope-client", "base64 0.22.1", "bytes", "chrono", @@ -12097,7 +11564,6 @@ dependencies = [ "rand 0.8.5", "reqwest 0.11.27", "reth-primitives 1.0.6", - "reth-rpc-types", "rocksdb", "serde", "serde_json", @@ -12131,13 +11597,14 @@ dependencies = [ [[package]] name = "telos-translator-rs" version = "0.1.0" -source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=f8ecbe1aeea57911c9fbefdddf49efa92d8472ce#f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" +source = "git+https://github.com/telosnetwork/telos-consensus-client?rev=9fadee1fd565e3a7ad51c1142e2673df52bd9028#9fadee1fd565e3a7ad51c1142e2673df52bd9028" dependencies = [ "alloy", "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-rlp", - "antelope-client 0.2.1", + "alloy-rpc-types-engine 0.3.6", + "antelope-client", "bytes", "clap", "dashmap 5.5.3", @@ -12149,7 +11616,6 @@ dependencies = [ "moka", "num-bigint", "reth-primitives 1.0.6", - "reth-rpc-types", "reth-telos-rpc-engine-api 1.0.6", "reth-trie-common 1.0.6", "rlp", @@ -12176,15 +11642,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "termtree" version = "0.4.1" @@ -12518,18 +11975,6 @@ dependencies = [ "tokio-util", ] -[[package]] -name = "tokio-tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.21.0", -] - [[package]] name = "tokio-tungstenite" version = "0.23.1" @@ -12894,25 +12339,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand 0.8.5", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.23.0" diff --git a/Cargo.toml b/Cargo.toml index 62025e2ea230..2938dfffdb71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -601,7 +601,9 @@ reth-node-telos = { path = "crates/telos/node" } reth-telos-rpc = { path = "crates/telos/rpc" } reth-telos-primitives-traits = { path = "crates/telos/primitives-traits" } reth-telos-rpc-engine-api = { path = "crates/telos/rpc-engine-api" } -antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "master" } +antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", rev = "d701cd9ca2e87e8e0fd99746f9c672cb3536e5ec" } +# antelope-client = { path = "../antelope-rs/crates/antelope" } + [patch.crates-io] #alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"} diff --git a/crates/telos/node/Cargo.toml b/crates/telos/node/Cargo.toml index a530dd01d848..d9a3f52d2a33 100644 --- a/crates/telos/node/Cargo.toml +++ b/crates/telos/node/Cargo.toml @@ -63,7 +63,9 @@ telos = [ ] [dev-dependencies] -alloy-consensus.workspace = true +# Translator and reth versions doesn't match, causing missing implementation of a TelosTxDecodable trait +alloy-consensus = "0.3.6" + alloy-contract = "0.4.2" alloy-primitives.workspace = true alloy-provider.workspace = true @@ -75,17 +77,16 @@ alloy-sol-types.workspace = true alloy-transport-http.workspace = true reqwest.workspace = true -reth.workspace = true -reth-chainspec.workspace = true reth-e2e-test-utils.workspace = true eyre.workspace = true -telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } -telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "f8ecbe1aeea57911c9fbefdddf49efa92d8472ce" } -#telos-consensus-client = { path = "../../../../telos-consensus-client/client" } -#telos-translator-rs = { path = "../../../../telos-consensus-client/translator" } +telos-consensus-client = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "9fadee1fd565e3a7ad51c1142e2673df52bd9028" } +telos-translator-rs = { git = "https://github.com/telosnetwork/telos-consensus-client", rev = "9fadee1fd565e3a7ad51c1142e2673df52bd9028" } +# telos-consensus-client = { path = "../../../../telos-consensus-client/client" } +# telos-translator-rs = { path = "../../../../telos-consensus-client/translator" } env_logger = "0.11.5" testcontainers = "0.21.1" derive_more.workspace = true +num-bigint = "0.4.5" diff --git a/crates/telos/node/tests/integration.rs b/crates/telos/node/tests/integration.rs index e6f09a9d715d..ac77b3f51558 100644 --- a/crates/telos/node/tests/integration.rs +++ b/crates/telos/node/tests/integration.rs @@ -1,4 +1,5 @@ -use alloy_provider::{Provider, ProviderBuilder}; +use alloy_primitives::Address; +use alloy_provider::{Provider, ProviderBuilder, ReqwestProvider}; use antelope::api::client::{APIClient, DefaultProvider}; use reqwest::Url; use reth::{ @@ -10,12 +11,14 @@ use reth_chainspec::{ChainSpec, ChainSpecBuilder, TEVMTESTNET}; use reth_e2e_test_utils::node::NodeTestContext; use reth_node_telos::{TelosArgs, TelosNode}; use reth_telos_rpc::TelosClient; +use std::str::FromStr; use std::{fs, path::PathBuf, sync::Arc, time::Duration}; use telos_consensus_client::{ client::ConsensusClient, config::{AppConfig, CliArgs}, main_utils::build_consensus_client, }; +use telos_translator_rs::types::evm_types::{AccountRow, EvmContractConfigRow}; use telos_translator_rs::{ block::TelosEVMBlock, translator::Translator, types::translator_types::ChainId, }; @@ -23,6 +26,7 @@ use testcontainers::{ core::ContainerPort::Tcp, runners::AsyncRunner, ContainerAsync, GenericImage, }; use tokio::sync::mpsc; +use tracing::info; pub mod live_test_runner; @@ -37,6 +41,10 @@ const CONTAINER_TAG: &str = // This is the last block in the container, after this block the node is done syncing and is running live const CONTAINER_LAST_EVM_BLOCK: u64 = 1010; +// evmuser address from the container +const EVM_USER_ADDRESS: &str = "0x4c641f9b61809fadeef2ec64f54ea2bcb398e4f3"; +const EVM_USER: &str = "evmuser"; + async fn start_ship() -> ContainerAsync { // Change this container to a local image if using new ship data, // then make sure to update the ship data in the testcontainer-nodeos-evm repo and build a new version @@ -112,12 +120,13 @@ async fn build_consensus_and_translator( jwt_secret: reth_handle.jwt_secret, ship_endpoint: format!("ws://localhost:{ship_port}"), chain_endpoint: format!("http://localhost:{chain_port}"), - batch_size: 1, + batch_size: 100, prev_hash: "b25034033c9ca7a40e879ddcc29cf69071a22df06688b5fe8cc2d68b4e0528f9".to_string(), validate_hash: None, evm_start_block: 1, // TODO: Determine a good stop block and test it here evm_stop_block: None, + evm_deploy_block: None, data_path: "temp/db".to_string(), block_checkpoint_interval: 1000, maximum_sync_range: 100000, @@ -201,6 +210,14 @@ async fn testing_chain_sync() { let rpc_url = Url::from(format!("http://localhost:{}", rpc_port).parse().unwrap()); let provider = ProviderBuilder::new().on_http(rpc_url.clone()); + info!("Client URL {:?}", format!("http://localhost:{chain_port}")); + + let api_client = APIClient::::default_provider( + format!("http://localhost:{chain_port}").to_string(), + Some(1), + ) + .unwrap(); + loop { tokio::time::sleep(Duration::from_secs(1)).await; let latest_block = provider.get_block_number().await.unwrap(); @@ -210,6 +227,10 @@ async fn testing_chain_sync() { break; } if latest_block > CONTAINER_LAST_EVM_BLOCK { + // test account nonce after successful reth sync from the container + test_evm_address_nonce(provider, api_client.clone()).await; + // test current revision from the transactions in the container + test_revision(api_client).await; break; } } @@ -228,3 +249,25 @@ async fn testing_chain_sync() { _ = tokio::join!(client_handle, translator_handle); println!("Translator shutdown done."); } + +async fn test_evm_address_nonce(provider: ReqwestProvider, api_client: APIClient) { + let params = live_test_runner::account_params(EVM_USER); + let row: &AccountRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; + + let account = provider.get_account(Address::from_str(EVM_USER_ADDRESS).unwrap()).await.unwrap(); + let tx_count = + provider.get_transaction_count(Address::from_str(EVM_USER_ADDRESS).unwrap()).await.unwrap(); + // assert nonce of the account that has sent transactions in the container blocks + assert_eq!(account.nonce, 2); + assert_eq!(account.nonce, tx_count); + assert_eq!(account.nonce, row.nonce); +} + +async fn test_revision(api_client: APIClient) { + // revision in the container transaction is set to 1 + let expected_revision = 1u32; + let params = live_test_runner::config_params(); + let row: &EvmContractConfigRow = &api_client.v1_chain.get_table_rows(params).await.unwrap().rows[0]; + + assert_eq!(*row.revision.value().unwrap(), expected_revision); +} diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 4ba71a7f2c3a..6f21e4452875 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -1,22 +1,58 @@ -use std::fmt::Debug; -use std::str::FromStr; +use alloy_consensus::{Signed, TxLegacy}; use alloy_contract::private::Transport; use alloy_network::{Ethereum, ReceiptResponse, TransactionBuilder}; -use alloy_primitives::{keccak256, Address, B256, U256}; +use alloy_primitives::{hex, keccak256, Address, Signature, B256, U256}; use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder}; -use alloy_rpc_types::{TransactionRequest}; +use alloy_rpc_types::TransactionRequest; + use alloy_signer_local::PrivateKeySigner; -use alloy_sol_types::private::primitives::TxKind::{Create}; +use alloy_sol_types::private::primitives::TxKind::Create; use alloy_sol_types::{sol, SolEvent}; -use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; -use reqwest::{Url}; -use tracing::info; +use antelope::api::v1::structs::{GetTableRowsParams, IndexPosition, TableIndexType}; +use antelope::chain::{checksum::Checksum256, name::Name}; +use antelope::{name}; +use num_bigint::{BigUint, ToBigUint}; +use reqwest::Url; use reth::primitives::BlockId; use reth::primitives::BlockNumberOrTag::Latest; +use reth::rpc::types::{BlockTransactionsKind, TransactionInput}; +use std::fmt::Debug; +use std::str::FromStr; +use telos_translator_rs::rlp::telos_rlp_decode::TelosTxDecodable; +use tracing::info; + use reth::primitives::revm_primitives::bytes::Bytes; use reth::revm::primitives::{AccessList, AccessListItem}; +pub(crate) fn account_params(account: &str) -> GetTableRowsParams { + GetTableRowsParams { + code: name!("eosio.evm"), + table: name!("account"), + scope: Some(name!("eosio.evm")), + lower_bound: Some(TableIndexType::NAME(name!(account))), + upper_bound: Some(TableIndexType::NAME(name!(account))), + limit: Some(1), + reverse: None, + index_position: Some(IndexPosition::TERTIARY), + show_payer: None, + } +} + +pub(crate) fn config_params() -> GetTableRowsParams { + GetTableRowsParams { + code: name!("eosio.evm"), + table: name!("config"), + scope: Some(name!("eosio.evm")), + lower_bound: None, + upper_bound: None, + limit: Some(1), + reverse: None, + index_position: None, + show_payer: None, + } +} + #[tokio::test] pub async fn run_local() { env_logger::builder().is_test(true).try_init().unwrap(); @@ -69,8 +105,6 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { let provider = ProviderBuilder::new().wallet(wallet.clone()).on_http(Url::from_str(url).unwrap()); - info!("Deploying contract using address {address}"); - let nonce = provider.get_transaction_count(address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); @@ -88,7 +122,7 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { let legacy_tx_request = TransactionRequest { from: Some(address), to: Some(legacy_tx.to), - gas: Some(legacy_tx.gas_limit), + gas: Some(legacy_tx.gas_limit as u64), gas_price: Some(legacy_tx.gas_price), value: Some(legacy_tx.value), input: TransactionInput::from(legacy_tx.input), @@ -130,29 +164,67 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { assert_eq!(U256::from(rpc_block_num), block_num_event.number); info!("Block numbers match inside transaction event"); + // wait for some blocks + while let Some(block) = provider.get_block_by_number(Latest, false).await.unwrap() { + if block.header.number == block_num_event.number.as_limbs()[0] + 8 { + break; + } + } + // test latest block and call get block from the contract + let latest_block = provider.get_block_by_number(Latest, false).await.unwrap().unwrap(); + let contract = BlockNumChecker::new(contract_address, provider.clone()); + let block_number = contract.getBlockNum().call().await.unwrap(); + assert_eq!(U256::from(latest_block.header.number), block_number._0); + assert!(latest_block.header.number > rpc_block_num); + + // call for history blocks + let block_num_five_back = block_num_checker + .getBlockNum() + .call() + .block(BlockId::number(latest_block.header.number - 5)) + .await + .unwrap(); + assert_eq!( + block_num_five_back._0, + U256::from(latest_block.header.number - 5), + "Block number 5 blocks back via historical eth_call is not correct" + ); + + info!("Deploying contract using address {address}"); + // test eip1559 transaction which is not supported test_1559_tx(provider.clone(), address).await; // test eip2930 transaction which is not supported test_2930_tx(provider.clone(), address).await; - // test double approve erc20 call + // test double approve erc20 call test_double_approve_erc20(provider.clone(), address).await; + // test incorrect rlp call + test_incorrect_rlp(provider.clone(), address).await; + test_unsigned_trx(provider.clone(), address).await; + test_unsigned_trx2(provider.clone(), address).await; + test_signed_trx(provider.clone(), address).await; + test_wrong_nonce(provider.clone(), address).await; + test_high_nonce(provider.clone(), address).await; + // The below needs to be done using LegacyTransaction style call... with the current code it's including base_fee_per_gas and being rejected by reth // let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); // assert!(block_num_latest._0 > U256::from(rpc_block_num), "Latest block number via call to getBlockNum is not greater than the block number in the previous log event"); // // let block_num_five_back = block_num_checker.getBlockNum().call().block(BlockId::number(rpc_block_num - 5)).await.unwrap(); // assert!(block_num_five_back._0 == U256::from(rpc_block_num - 5), "Block number 5 blocks back via historical eth_call is not correct"); - } // test_1559_tx tests sending eip1559 transaction that has max_priority_fee_per_gas and max_fee_per_gas set -pub async fn test_1559_tx(provider: impl Provider + Send + Sync, sender_address: Address) -where +pub async fn test_1559_tx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where T: Transport + Clone + Debug, { let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); - let to_address: Address = Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); + let to_address: Address = + Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); let tx = TransactionRequest::default() .with_to(to_address) @@ -164,20 +236,27 @@ where .with_max_fee_per_gas(20_000_000_000); let tx_result = provider.send_transaction(tx).await; + + info!("test_1559_tx"); + + + assert!(tx_result.is_err()); } // test_2930_tx tests sending eip2930 transaction which has access_list provided -pub async fn test_2930_tx(provider: impl Provider + Send + Sync, sender_address: Address) -where +pub async fn test_2930_tx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where T: Transport + Clone + Debug, - { let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - let to_address: Address = Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); + let to_address: Address = + Address::from_str("0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4").unwrap(); let tx = TransactionRequest::default() .to(to_address) .nonce(nonce) @@ -186,13 +265,17 @@ where .with_gas_price(gas_price) .with_gas_limit(20_000_000) .max_priority_fee_per_gas(1e11 as u128) - .with_access_list(AccessList::from(vec![AccessListItem { address: to_address, storage_keys: vec![B256::ZERO] }])) + .with_access_list(AccessList::from(vec![AccessListItem { + address: to_address, + storage_keys: vec![B256::ZERO], + }])) .max_fee_per_gas(2e9 as u128); let tx_result = provider.send_transaction(tx).await; + info!("test_2930_tx"); + assert!(tx_result.is_err()); } - // test_double_approve_erc20 sends 2 transactions for approve on the ERC20 token and asserts that only once it is success pub async fn test_double_approve_erc20( provider: impl Provider + Send + Sync, @@ -203,7 +286,7 @@ pub async fn test_double_approve_erc20( let nonce = provider.get_transaction_count(sender_address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); let gas_price = provider.get_gas_price().await.unwrap(); - + info!("Nonce: {}", nonce); let erc20_contract_address: Address = "0x49f54c5e2301eb9256438123e80762470c2c7ec2".parse().unwrap(); let spender: Address = "0x23CB6AE34A13a0977F4d7101eBc24B87Bb23F0d4".parse().unwrap(); @@ -235,7 +318,6 @@ pub async fn test_double_approve_erc20( let nonce = provider.get_transaction_count(sender_address).await.unwrap(); tx.nonce = Some(nonce); - // repeat approve let tx_result = provider.send_transaction(tx.clone()).await; assert!(tx_result.is_ok()); @@ -245,11 +327,263 @@ pub async fn test_double_approve_erc20( let block_number = receipt2.unwrap().block_number.unwrap(); - // make sure the block is included + // make sure the block is included and there is a progress while let Some(block) = provider.get_block_by_number(Latest, false).await.unwrap() { - if block.header.number == block_number { + if block.header.number >= block_number { break; } } } +pub async fn test_wrong_nonce( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(0); + let legacy_tx = tx_trailing_empty_values().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(legacy_tx.gas_price), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_err()); + let err = tx_result.unwrap_err(); + assert_eq!( + err.to_string(), + "server returned an error response: error code -32003: nonce too low: next nonce 9, tx nonce 0" + ) +} + +pub async fn test_high_nonce( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(500); + let legacy_tx = tx_trailing_empty_values().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(legacy_tx.gas_price), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_err()); + + let err = tx_result.unwrap_err(); + assert_eq!( + err.to_string(), + "server returned an error response: error code -32003: nonce too high" + ) +} + +pub async fn test_incorrect_rlp( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_trailing_empty_values().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(legacy_tx.gas_price), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); +} + +fn tx_trailing_empty_values() -> eyre::Result> { + let byte_array: [u8; 43] = [ + 234, 21, 133, 117, 98, 209, 251, 63, 131, 30, 132, 128, 148, 221, 124, 155, 23, 110, 221, + 57, 225, 22, 88, 115, 0, 111, 245, 56, 10, 44, 0, 51, 174, 130, 39, 16, 130, 0, 0, 128, + 128, 128, 128, + ]; + + let r = U256::from_str( + "7478307613393818857995123362551696556625819847066981460737539381080402549198", + )?; + let s = U256::from_str( + "93208746529385687702128536437164864077231874732405909428462768306792425324544", + )?; + let v = 42u64; + + let sig = Signature::from_rs_and_parity(r, s, v)?; + Ok(TxLegacy::decode_telos_signed_fields(&mut &byte_array[..], Some(sig))?) +} + +pub async fn test_unsigned_trx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_unsigned_trx().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(113378400387), + value: Some(U256::from(1)), // update balance to 0 since there is not enough from decoded data on the account + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); +} + +fn tx_unsigned_trx() -> eyre::Result> { + let raw = hex::decode( + "e7808082520894d80744e16d62c62c5fa2a04b92da3fe6b9efb5238b52e00fde054bb73290000080", + ) + .unwrap(); + + Ok(TxLegacy::decode_telos_signed_fields( + &mut raw.as_slice(), + Some(make_unique_vrs( + Checksum256::from_hex( + "00000032f9ff3095950dbef8701acc5f0eb193e3c2d089da0e2237659048d62b", + ) + .unwrap(), + Address::ZERO, + 0, + )), + )?) +} + +pub async fn test_unsigned_trx2( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_unsigned_trx2().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(113378400387), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); +} + +fn tx_unsigned_trx2() -> eyre::Result> { + let raw = hex::decode( + "f78212aa8575a1c379a28307a120947282835cf78a5e88a52fc701f09d1614635be4b8900000000000000000000000000000000080808080", + ) + .unwrap(); + + Ok(TxLegacy::decode_telos_signed_fields( + &mut raw.as_slice(), + Some(make_unique_vrs( + Checksum256::from_hex( + "00000032f9ff3095950dbef8701acc5f0eb193e3c2d089da0e2237659048d62b", + ) + .unwrap(), + Address::ZERO, + 0, + )), + )?) +} + +pub async fn test_signed_trx( + provider: impl Provider + Send + Sync, + sender_address: Address, +) where + T: Transport + Clone + Debug, +{ + let chain_id = Some(provider.get_chain_id().await.unwrap()); + let nonce = Some(provider.get_transaction_count(sender_address).await.unwrap()); + let legacy_tx = tx_signed_trx().unwrap().tx().clone(); + let legacy_tx_request = TransactionRequest { + from: Some(sender_address), + to: Some(legacy_tx.to), + gas: Some(legacy_tx.gas_limit as u64), + gas_price: Some(113378400387), + value: Some(legacy_tx.value), + input: TransactionInput::from(legacy_tx.input), + nonce, + chain_id, + ..Default::default() + }; + + let tx_result = provider.send_transaction(legacy_tx_request).await; + + assert!(tx_result.is_ok()); + let _ = tx_result.unwrap().get_receipt().await.unwrap(); +} + +fn tx_signed_trx() -> eyre::Result> { + let raw = hex::decode( + "f8aa11857a307efa8083023fa09479f5a8bd0d6a00a41ea62cda426cef0115117a6180b844e2bbb1580000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000073a0b40ec08b01a351dcbf5e86eeb15262bf7033dc7b99a054dfb198487636a79c5fa000b64d6775ba737738ccff7f1c0a29c287cbb91f2eb17e1d0b74ffb73d9daa85", + ).unwrap(); + + Ok(TxLegacy::decode_telos_signed_fields(&mut raw.as_slice(), None)?) +} + +pub fn make_unique_vrs( + block_hash_native: Checksum256, + sender_address: Address, + trx_index: usize, +) -> Signature { + let v = 42u64; + let hash_biguint = BigUint::from_bytes_be(&block_hash_native.data); + let trx_index_biguint: BigUint = trx_index.to_biguint().unwrap(); + let r_biguint = hash_biguint + trx_index_biguint; + + let mut s_bytes = [0x00u8; 32]; + s_bytes[..20].copy_from_slice(sender_address.as_slice()); + let r = U256::from_be_slice(r_biguint.to_bytes_be().as_slice()); + let s = U256::from_be_slice(&s_bytes); + Signature::from_rs_and_parity(r, s, v).expect("Failed to create signature") +} diff --git a/crates/telos/node/tests/main.rs b/crates/telos/node/tests/main.rs index a23cd12d3808..545e604d2459 100644 --- a/crates/telos/node/tests/main.rs +++ b/crates/telos/node/tests/main.rs @@ -2,4 +2,4 @@ // pub mod live_test_runner; pub mod storage_compare; -const fn main() {} \ No newline at end of file +const fn main() {} diff --git a/crates/telos/rpc/Cargo.toml b/crates/telos/rpc/Cargo.toml index f0023d2c01bf..7e919063562f 100644 --- a/crates/telos/rpc/Cargo.toml +++ b/crates/telos/rpc/Cargo.toml @@ -31,6 +31,7 @@ reth-rpc-eth-api.workspace = true reth-rpc-eth-types.workspace = true thiserror = "1.0.63" +regex = "1.10.5" tracing.workspace = true antelope-client.workspace = true diff --git a/crates/telos/rpc/src/eth/telos_client.rs b/crates/telos/rpc/src/eth/telos_client.rs index 7531da71f65e..2ad014b76337 100644 --- a/crates/telos/rpc/src/eth/telos_client.rs +++ b/crates/telos/rpc/src/eth/telos_client.rs @@ -1,17 +1,95 @@ +use std::fmt; +use std::future::Future; use std::sync::Arc; -use reth_rpc_eth_types::error::EthResult; + use antelope::api::client::{APIClient, DefaultProvider}; -use antelope::chain::name::Name; -use antelope::chain::private_key::PrivateKey; -use antelope::{chain::{Packer, Encoder, Decoder}, name, StructPacker}; +use antelope::api::v1::structs::{ClientError, SendTransaction2Options, SendTransactionResponse2Error}; use antelope::chain::action::{Action, PermissionLevel}; use antelope::chain::checksum::Checksum160; +use antelope::chain::name::Name; +use antelope::chain::private_key::PrivateKey; use antelope::chain::transaction::{SignedTransaction, Transaction}; -use backoff::Exponential; -use reth_rpc_eth_types::EthApiError; -use std::future::Future; +use antelope::serializer::Decoder; +use antelope::serializer::Encoder; +use antelope::{chain::Packer, name, StructPacker}; +use jsonrpsee_types::ErrorObject; +use regex::Regex; use tracing::{debug, error, warn}; +use backoff::Exponential; +use reth_primitives::revm_primitives::bitvec::macros::internal::funty::Fundamental; +use reth_rpc_eth_types::error::EthResult; +use reth_rpc_eth_types::{EthApiError, RpcInvalidTransactionError}; + +#[derive(Debug)] +struct TelosError(ClientError); + +impl fmt::Display for TelosError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) + } +} + +impl From for EthApiError { + fn from(err: TelosError) -> Self { + match err.0 { + ClientError::SERVER(server_error) => parse_server_error(server_error.error), + ClientError::SIMPLE(client_error) => EthApiError::EvmCustom(client_error.message), + ClientError::HTTP(http_error) => { + let http_error = + ErrorObject::owned(http_error.code.as_i32(), http_error.message, None::<()>); + EthApiError::Other(Box::new(http_error)) + } + ClientError::ENCODING(encoding_error) => EthApiError::EvmCustom(encoding_error.message), + ClientError::NETWORK(network_error) => EthApiError::EvmCustom(network_error), + } + } +} + +fn parse_error_message(message: String) -> Option { + if message.contains("Calling from_big_endian with oversized array") + || message.contains("Invalid packed transaction") + { + return Some(EthApiError::FailedToDecodeSignedTransaction); + } + if message.contains("Transaction gas price") { + // TODO: gas to high + return Some(EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooLow)); + } + if !message.contains("incorrect nonce") { + return Some(EthApiError::EvmCustom(message.to_string())); + } + let re = Regex::new(r"received (\d+) expected (\d+)").unwrap(); + let Some(captures) = re.captures(&message) else { + warn!("{message:?}"); + return None; + }; + let received: u64 = captures.get(1).unwrap().as_str().parse().ok().unwrap(); + let expected: u64 = captures.get(2).unwrap().as_str().parse().ok().unwrap(); + if received < expected { + return Some(EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooLow { + tx: received, + state: expected, + })); + } + Some(EthApiError::InvalidTransaction(RpcInvalidTransactionError::NonceTooHigh)) +} + +fn parse_server_error(server_error: SendTransactionResponse2Error) -> EthApiError { + let error_message = server_error.message; + for detail in server_error.details.unwrap_or_default() { + if let Some(error) = parse_error_message(detail.message) { + return error; + } + } + for error in server_error.stack { + if let Some(error) = parse_error_message(error.data.to_string()) { + return error; + } + } + EthApiError::EvmCustom(error_message) +} + /// A client to interact with a Telos node #[derive(Debug, Clone)] pub struct TelosClient { @@ -102,7 +180,11 @@ impl TelosClient { { panic!("Should not construct TelosClient without proper TelosArgs with telos_endpoint and signer args"); } - let api_client = APIClient::::default_provider(telos_client_args.telos_endpoint.unwrap().into(), Some(3)).unwrap(); + let api_client = APIClient::::default_provider( + telos_client_args.telos_endpoint.unwrap().into(), + Some(3), + ) + .unwrap(); let inner = TelosClientInner { api_client, signer_account: name!(&telos_client_args.signer_account.unwrap()), @@ -150,26 +232,24 @@ impl TelosClient { context_free_data: vec![], }; - let tx_response = retry(|| async { - self.inner - .api_client - .v1_chain - .send_transaction(signed_telos_transaction.clone()) - .await - .map_err(|error| { - warn!("{error:?}"); - format!("{error:?}") - }) - }) - .await; + let options = SendTransaction2Options{ + return_failure_trace: true, + retry_trx: true, + retry_trx_num_blocks: 2, + }; + + let tx_response = self + .inner + .api_client + .v1_chain + .send_transaction2(signed_telos_transaction.clone(), Some(options)) + .await; let tx = match tx_response { Ok(value) => value, Err(err) => { error!("Error sending transaction to Telos: {:?}", err); - return Err(EthApiError::EvmCustom( - "Error sending transaction to Telos".to_string(), - )); + return Err(EthApiError::from(TelosError(err))); } }; diff --git a/crates/telos/rpc/src/eth/transaction.rs b/crates/telos/rpc/src/eth/transaction.rs index e22f31c39f41..ee222436ccff 100644 --- a/crates/telos/rpc/src/eth/transaction.rs +++ b/crates/telos/rpc/src/eth/transaction.rs @@ -8,8 +8,7 @@ use reth_rpc_eth_api::{ FromEthApiError, FullEthApiTypes, }; use reth_rpc_eth_types::{utils::recover_raw_transaction, EthStateCache}; -use reth_transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool}; - +use reth_transaction_pool::{PoolTransaction, TransactionPool}; use crate::eth::TelosClient; use crate::eth::TelosEthApi; @@ -37,8 +36,8 @@ where if let Some(client) = self.raw_tx_forwarder().as_ref() { tracing::debug!( target: "rpc::eth", "forwarding raw transaction to Telos native"); let result = client.send_to_telos(&tx).await.inspect_err(|err| { - tracing::debug!(target: "rpc::eth", %err, hash=% *pool_transaction.hash(), "failed to forward raw transaction"); - }); + tracing::debug!(target: "rpc::eth", %err, hash=% *pool_transaction.hash(), "failed to forward raw transaction"); + }); // TODO: Retry here if it's a network error, parse errors from Telos and try to return appropriate error to client if let Err(err) = result { @@ -46,13 +45,7 @@ where } } - // submit the transaction to the pool with a `Local` origin - let hash = self - .pool() - .add_transaction(TransactionOrigin::Local, pool_transaction) - .await - .map_err(Self::Error::from_eth_err)?; - + let hash = *pool_transaction.hash(); Ok(hash) } } @@ -93,4 +86,4 @@ where pub fn raw_tx_forwarder(&self) -> Option { self.telos_client.get().cloned() } -} \ No newline at end of file +}