diff --git a/Cargo.lock b/Cargo.lock index 657f4e6..5ec52ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,20 +25,20 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" dependencies = [ - "getrandom 0.2.8", + "cfg-if", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" dependencies = [ "proc-macro2", "quote", @@ -252,11 +252,11 @@ dependencies = [ [[package]] name = "blake2" -version = "0.10.4" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +checksum = "b12e5fd123190ce1c2e559308a94c9bacad77907d4c6005d9e58fe1a0689e55e" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", ] [[package]] @@ -358,9 +358,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" dependencies = [ "serde", ] @@ -385,9 +385,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406c859255d568f4f742b3146d51851f3bfd49f734a2c289d9107c4395ee0062" +checksum = "982a0cf6a99c350d7246035613882e376d58cebe571785abc5da4f648d53ac0a" dependencies = [ "camino", "cargo-platform", @@ -399,9 +399,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.74" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cfg-if" @@ -411,9 +411,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ "iana-time-zone", "js-sys", @@ -481,7 +481,6 @@ dependencies = [ "client", "common", "config", - "ctrlc", "dirs", "env_logger", "eyre", @@ -497,6 +496,7 @@ dependencies = [ "common", "config", "consensus", + "ctrlc", "ethers", "execution", "eyre", @@ -529,7 +529,7 @@ dependencies = [ "bincode", "bs58", "coins-core", - "digest 0.10.5", + "digest 0.10.6", "getrandom 0.2.8", "hmac", "k256", @@ -566,7 +566,7 @@ dependencies = [ "base64 0.12.3", "bech32", "blake2", - "digest 0.10.5", + "digest 0.10.6", "generic-array 0.14.6", "hex", "ripemd", @@ -637,9 +637,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" +checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" [[package]] name = "convert_case" @@ -724,9 +724,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.80" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" +checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" dependencies = [ "cc", "cxxbridge-flags", @@ -736,9 +736,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.80" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" +checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" dependencies = [ "cc", "codespan-reporting", @@ -751,15 +751,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.80" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" +checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" [[package]] name = "cxxbridge-macro" -version = "1.0.80" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" +checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" dependencies = [ "proc-macro2", "quote", @@ -807,9 +807,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.3", "crypto-common", @@ -869,7 +869,7 @@ dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.5", + "digest 0.10.6", "ff", "generic-array 0.14.6", "group", @@ -891,9 +891,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -910,7 +910,7 @@ checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" dependencies = [ "aes", "ctr", - "digest 0.10.5", + "digest 0.10.6", "hex", "hmac", "pbkdf2", @@ -926,11 +926,11 @@ dependencies = [ [[package]] name = "ethabi" -version = "17.2.0" +version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4966fba78396ff92db3b817ee71143eccd98acf0f876b8d600e585a670c5d1b" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" dependencies = [ - "ethereum-types 0.13.1", + "ethereum-types 0.14.1", "hex", "once_cell", "regex", @@ -938,7 +938,7 @@ dependencies = [ "serde_json", "sha3", "thiserror", - "uint 0.9.4", + "uint 0.9.5", ] [[package]] @@ -956,15 +956,15 @@ dependencies = [ [[package]] name = "ethbloom" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11da94e443c60508eb62cf256243a64da87304c2802ac2528847f79d750007ef" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", - "fixed-hash 0.7.0", + "fixed-hash 0.8.0", "impl-codec 0.6.0", "impl-rlp 0.3.0", - "impl-serde 0.3.2", + "impl-serde 0.4.0", "scale-info", "tiny-keccak 2.0.2", ] @@ -985,24 +985,25 @@ dependencies = [ [[package]] name = "ethereum-types" -version = "0.13.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2827b94c556145446fcce834ca86b7abf0c39a805883fe20e72c5bfdb5a0dc6" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ - "ethbloom 0.12.1", - "fixed-hash 0.7.0", + "ethbloom 0.13.0", + "fixed-hash 0.8.0", "impl-codec 0.6.0", "impl-rlp 0.3.0", - "impl-serde 0.3.2", - "primitive-types 0.11.1", + "impl-serde 0.4.0", + "primitive-types 0.12.1", "scale-info", - "uint 0.9.4", + "uint 0.9.5", ] [[package]] name = "ethers" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f26f9d8d80da18ca72aca51804c65eb2153093af3bec74fd5ce32aa0c1f665" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -1015,8 +1016,9 @@ dependencies = [ [[package]] name = "ethers-addressbook" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4be54dd2260945d784e06ccdeb5ad573e8f1541838cee13a1ab885485eaa0b" dependencies = [ "ethers-core", "once_cell", @@ -1026,8 +1028,9 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c3c3e119a89f0a9a1e539e7faecea815f74ddcf7c90d0b00d1f524db2fdc9c" dependencies = [ "ethers-contract-abigen", "ethers-contract-derive", @@ -1044,8 +1047,9 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d4e5ad46aede34901f71afdb7bb555710ed9613d88d644245c657dc371aa228" dependencies = [ "Inflector", "cfg-if", @@ -1061,14 +1065,16 @@ dependencies = [ "serde", "serde_json", "syn", + "toml", "url", "walkdir", ] [[package]] name = "ethers-contract-derive" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f192e8e4cf2b038318aae01e94e7644e0659a76219e94bcd3203df744341d61f" dependencies = [ "ethers-contract-abigen", "ethers-core", @@ -1081,8 +1087,9 @@ dependencies = [ [[package]] name = "ethers-core" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade3e9c97727343984e1ceada4fdab11142d2ee3472d2c67027d56b1251d4f15" dependencies = [ "arrayvec 0.7.2", "bytes", @@ -1100,7 +1107,6 @@ dependencies = [ "rand 0.8.5", "rlp 0.5.2", "rlp-derive", - "rust_decimal", "serde", "serde_json", "strum", @@ -1112,8 +1118,9 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9713f525348e5dde025d09b0a4217429f8074e8ff22c886263cc191e87d8216" dependencies = [ "ethers-core", "getrandom 0.2.8", @@ -1128,8 +1135,9 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e71df7391b0a9a51208ffb5c7f2d068900e99d6b3128d3a4849d138f194778b7" dependencies = [ "async-trait", "auto_impl 0.5.0", @@ -1153,13 +1161,15 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a9e0597aa6b2fdc810ff58bc95e4eeaa2c219b3e615ed025106ecb027407d8" dependencies = [ "async-trait", "auto_impl 1.0.1", "base64 0.13.1", "ethers-core", + "futures-channel", "futures-core", "futures-timer", "futures-util", @@ -1175,6 +1185,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", + "tokio-tungstenite", "tracing", "tracing-futures", "url", @@ -1187,8 +1198,9 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "1.0.0" -source = "git+https://github.com/ncitron/ethers-rs?branch=fix-retry#04e375470b7ef52d55075aff2f1f7d93daa12a93" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f41ced186867f64773db2e55ffdd92959e094072a1d09a5e5e831d443204f98" dependencies = [ "async-trait", "coins-bip32", @@ -1296,9 +1308,9 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", "rand 0.8.5", @@ -1413,7 +1425,6 @@ checksum = "3eb42d4fb72227be5778429f9ef5240a38a358925a49f05b5cf702ce7c7e558a" dependencies = [ "futures-channel", "futures-task", - "tokio", ] [[package]] @@ -1540,9 +1551,9 @@ dependencies = [ [[package]] name = "gloo-net" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec897194fb9ac576c708f63d35604bc58f2a262b8cec0fabfed26f3991255f21" +checksum = "9050ff8617e950288d7bf7f300707639fdeda5ca0d0ecf380cff448cfd52f4a6" dependencies = [ "futures-channel", "futures-core", @@ -1560,9 +1571,9 @@ dependencies = [ [[package]] name = "gloo-timers" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" +checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" dependencies = [ "futures-channel", "futures-core", @@ -1572,9 +1583,9 @@ dependencies = [ [[package]] name = "gloo-utils" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40913a05c8297adca04392f707b1e73b12ba7b8eab7244a4961580b1fd34063c" +checksum = "a8e8fc851e9c7b9852508bc6e3f690f452f474417e8545ec9857b7f7377036b5" dependencies = [ "js-sys", "serde", @@ -1624,6 +1635,12 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" dependencies = [ "ahash", ] @@ -1678,7 +1695,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", ] [[package]] @@ -1732,9 +1749,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.22" +version = "0.14.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" dependencies = [ "bytes", "futures-channel", @@ -1756,9 +1773,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +checksum = "59df7c4e19c950e6e0e868dcc0a300b09a9b88e9ec55bd879ca819087a77355d" dependencies = [ "http", "hyper", @@ -1871,6 +1888,15 @@ dependencies = [ "serde", ] +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -1890,12 +1916,12 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -1927,9 +1953,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" [[package]] name = "itoa" @@ -2144,9 +2170,12 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] [[package]] name = "keccak-hasher" @@ -2170,9 +2199,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.137" +version = "0.2.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" [[package]] name = "link-cplusplus" @@ -2256,9 +2285,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ "autocfg", "bitflags", @@ -2393,14 +2422,14 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "open-fastrlp" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131de184f045153e72c537ef4f1d57babddf2a897ca19e67bdff697aebba7f3d" +checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" dependencies = [ "arrayvec 0.7.2", "auto_impl 1.0.1", "bytes", - "ethereum-types 0.13.1", + "ethereum-types 0.14.1", "open-fastrlp-derive", ] @@ -2418,9 +2447,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.42" +version = "0.10.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" +checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376" dependencies = [ "bitflags", "cfg-if", @@ -2459,9 +2488,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.77" +version = "0.9.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" +checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132" dependencies = [ "autocfg", "cc", @@ -2473,9 +2502,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.3.1" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] name = "parity-scale-codec" @@ -2539,7 +2568,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.4", + "parking_lot_core 0.9.5", ] [[package]] @@ -2558,9 +2587,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" dependencies = [ "cfg-if", "libc", @@ -2586,7 +2615,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", "hmac", "password-hash", "sha2 0.10.6", @@ -2690,9 +2719,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "primitive-types" @@ -2709,16 +2738,16 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ - "fixed-hash 0.7.0", + "fixed-hash 0.8.0", "impl-codec 0.6.0", "impl-rlp 0.3.0", - "impl-serde 0.3.2", + "impl-serde 0.4.0", "scale-info", - "uint 0.9.4", + "uint 0.9.5", ] [[package]] @@ -2892,9 +2921,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" dependencies = [ "aho-corasick", "memchr", @@ -2903,9 +2932,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "remove_dir_all" @@ -3008,16 +3037,16 @@ dependencies = [ [[package]] name = "revm" -version = "2.1.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87344ffd3eec06b568e1fc69c225e4cbd8d68d8d9051b6d2652d596947efa1ce" +checksum = "73d84c8f9836efb0f5f5f8de4700a953c4e1f3119e5cfcb0aad8e5be73daf991" dependencies = [ "arrayref", "auto_impl 1.0.1", "bytes", - "hashbrown", + "hashbrown 0.13.1", "num_enum", - "primitive-types 0.11.1", + "primitive-types 0.12.1", "revm_precompiles", "rlp 0.5.2", "sha3", @@ -3025,15 +3054,15 @@ dependencies = [ [[package]] name = "revm_precompiles" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e68901326fe20437526cb6d64a2898d2976383b7d222329dfce1717902da50" +checksum = "0353d456ef3e989dc9190f42c6020f09bc2025930c37895826029304413204b5" dependencies = [ "bytes", - "hashbrown", + "hashbrown 0.13.1", "num", "once_cell", - "primitive-types 0.11.1", + "primitive-types 0.12.1", "ripemd", "secp256k1", "sha2 0.10.6", @@ -3073,7 +3102,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", ] [[package]] @@ -3106,17 +3135,6 @@ dependencies = [ "syn", ] -[[package]] -name = "rust_decimal" -version = "1.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee9164faf726e4f3ece4978b25ca877ddc6802fa77f38cdccb32c7f805ecd70c" -dependencies = [ - "arrayvec 0.7.2", - "num-traits", - "serde", -] - [[package]] name = "rustc-hash" version = "1.1.0" @@ -3347,18 +3365,18 @@ checksum = "930c0acf610d3fdb5e2ab6213019aaa04e227ebe9547b0649ba599b16d788bd7" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] [[package]] name = "serde-aux" -version = "4.0.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79c1a5a310c28bf9f7a4b9bd848553051120d80a5952f993c7eb62f6ed6e4c5" +checksum = "c599b3fd89a75e0c18d6d2be693ddb12cccaf771db4ff9e39097104808a014c0" dependencies = [ "serde", "serde_json", @@ -3366,9 +3384,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -3377,9 +3395,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ "itoa", "ryu", @@ -3424,6 +3442,17 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + [[package]] name = "sha2" version = "0.8.2" @@ -3457,7 +3486,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.5", + "digest 0.10.6", ] [[package]] @@ -3466,7 +3495,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", "keccak", ] @@ -3485,7 +3514,7 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", "rand_core 0.6.4", ] @@ -3526,7 +3555,7 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "sha-1", + "sha-1 0.9.8", ] [[package]] @@ -3625,9 +3654,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.103" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" dependencies = [ "proc-macro2", "quote", @@ -3721,9 +3750,9 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -3765,9 +3794,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.21.2" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" dependencies = [ "autocfg", "bytes", @@ -3785,9 +3814,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.8.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", @@ -3826,6 +3855,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + [[package]] name = "tokio-util" version = "0.7.4" @@ -3924,6 +3965,25 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "tungstenite" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +dependencies = [ + "base64 0.13.1", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "rand 0.8.5", + "sha-1 0.10.1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.15.0" @@ -3944,9 +4004,9 @@ dependencies = [ [[package]] name = "uint" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", @@ -4034,6 +4094,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "uuid" version = "0.8.2" @@ -4108,8 +4174,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if", - "serde", - "serde_json", "wasm-bindgen-macro", ] @@ -4384,9 +4448,9 @@ dependencies = [ [[package]] name = "wyz" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] @@ -4408,9 +4472,9 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index a5cabc1..b3266cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,6 @@ common = { path = "./common" } consensus = { path = "./consensus" } execution = { path = "./execution" } -[patch.crates-io] -ethers = { git = "https://github.com/ncitron/ethers-rs", branch = "fix-retry" } - [dev-dependencies] tokio = { version = "1", features = ["full"] } eyre = "0.6.8" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 9462629..ea01005 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -17,7 +17,6 @@ eyre = "0.6.8" dirs = "4.0.0" env_logger = "0.9.0" log = "0.4.17" -ctrlc = "3.2.3" futures = "0.3.23" client = { path = "../client" } diff --git a/cli/src/cli.rs b/cli/src/cli.rs new file mode 100644 index 0000000..228a5af --- /dev/null +++ b/cli/src/cli.rs @@ -0,0 +1,84 @@ +use std::{fs, path::PathBuf, str::FromStr}; + +use clap::Parser; +use common::utils::hex_str_to_bytes; +use dirs::home_dir; + +use config::{CliConfig, Config}; + +#[derive(Parser)] +pub struct Cli { + #[clap(short, long, default_value = "mainnet")] + network: String, + #[clap(short = 'p', long, env)] + rpc_port: Option, + #[clap(short = 'w', long, env)] + checkpoint: Option, + #[clap(short, long, env)] + execution_rpc: Option, + #[clap(short, long, env)] + consensus_rpc: Option, + #[clap(short, long, env)] + data_dir: Option, + #[clap(short = 'f', long, env)] + fallback: Option, + #[clap(short = 'l', long, env)] + load_external_fallback: bool, + #[clap(short = 's', long, env)] + with_ws: bool, + #[clap(short = 'h', long, env)] + with_http: bool, +} + +impl Cli { + pub fn to_config() -> Config { + let cli = Cli::parse(); + let config_path = home_dir().unwrap().join(".helios/helios.toml"); + let cli_config = cli.as_cli_config(); + Config::from_file(&config_path, &cli.network, &cli_config) + } + + fn as_cli_config(&self) -> CliConfig { + let checkpoint = match &self.checkpoint { + Some(checkpoint) => Some(hex_str_to_bytes(checkpoint).expect("invalid checkpoint")), + None => self.get_cached_checkpoint(), + }; + + CliConfig { + checkpoint, + execution_rpc: self.execution_rpc.clone(), + consensus_rpc: self.consensus_rpc.clone(), + data_dir: self.get_data_dir(), + rpc_port: self.rpc_port, + fallback: self.fallback.clone(), + load_external_fallback: self.load_external_fallback, + with_ws: self.with_ws, + with_http: self.with_http, + } + } + + fn get_cached_checkpoint(&self) -> Option> { + let data_dir = self.get_data_dir(); + let checkpoint_file = data_dir.join("checkpoint"); + + if checkpoint_file.exists() { + let checkpoint_res = fs::read(checkpoint_file); + match checkpoint_res { + Ok(checkpoint) => Some(checkpoint), + Err(_) => None, + } + } else { + None + } + } + + fn get_data_dir(&self) -> PathBuf { + if let Some(dir) = &self.data_dir { + PathBuf::from_str(dir).expect("cannot find data dir") + } else { + home_dir() + .unwrap() + .join(format!(".helios/data/{}", self.network)) + } + } +} diff --git a/cli/src/main.rs b/cli/src/main.rs index 1c90139..2a4d7db 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,142 +1,19 @@ -use std::{ - fs, - path::PathBuf, - process::exit, - str::FromStr, - sync::{Arc, Mutex}, -}; - -use clap::Parser; -use common::utils::hex_str_to_bytes; -use dirs::home_dir; use env_logger::Env; use eyre::Result; -use client::{database::FileDB, Client, ClientBuilder}; -use config::{CliConfig, Config}; -use futures::executor::block_on; -use log::info; +use client::{Client, ClientBuilder}; + +mod cli; #[tokio::main] async fn main() -> Result<()> { env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); - let config = get_config(); + let config = cli::Cli::to_config(); let mut client = ClientBuilder::new().config(config).build()?; client.start().await?; - register_shutdown_handler(client); + Client::register_shutdown_handler(client); std::future::pending().await } - -fn register_shutdown_handler(client: Client) { - let client = Arc::new(client); - let shutdown_counter = Arc::new(Mutex::new(0)); - - ctrlc::set_handler(move || { - let mut counter = shutdown_counter.lock().unwrap(); - *counter += 1; - - let counter_value = *counter; - - if counter_value == 3 { - info!("forced shutdown"); - exit(0); - } - - info!( - "shutting down... press ctrl-c {} more times to force quit", - 3 - counter_value - ); - - if counter_value == 1 { - let client = client.clone(); - std::thread::spawn(move || { - block_on(client.shutdown()); - exit(0); - }); - } - }) - .expect("could not register shutdown handler"); -} - -fn get_config() -> Config { - let cli = Cli::parse(); - - let config_path = home_dir().unwrap().join(".helios/helios.toml"); - - let cli_config = cli.as_cli_config(); - - Config::from_file(&config_path, &cli.network, &cli_config) -} - -#[derive(Parser)] -struct Cli { - #[clap(short, long, default_value = "mainnet")] - network: String, - #[clap(short = 'p', long, env)] - rpc_port: Option, - #[clap(short = 'w', long, env)] - checkpoint: Option, - #[clap(short, long, env)] - execution_rpc: Option, - #[clap(short, long, env)] - consensus_rpc: Option, - #[clap(short, long, env)] - data_dir: Option, - #[clap(short = 'f', long, env)] - fallback: Option, - #[clap(short = 'l', long, env)] - load_external_fallback: bool, - #[clap(short = 's', long, env)] - with_ws: bool, - #[clap(short = 'h', long, env)] - with_http: bool, -} - -impl Cli { - fn as_cli_config(&self) -> CliConfig { - let checkpoint = match &self.checkpoint { - Some(checkpoint) => Some(hex_str_to_bytes(checkpoint).expect("invalid checkpoint")), - None => self.get_cached_checkpoint(), - }; - - CliConfig { - checkpoint, - execution_rpc: self.execution_rpc.clone(), - consensus_rpc: self.consensus_rpc.clone(), - data_dir: self.get_data_dir(), - rpc_port: self.rpc_port, - fallback: self.fallback.clone(), - load_external_fallback: self.load_external_fallback, - with_ws: self.with_ws, - with_http: self.with_http, - } - } - - fn get_cached_checkpoint(&self) -> Option> { - let data_dir = self.get_data_dir(); - let checkpoint_file = data_dir.join("checkpoint"); - - if checkpoint_file.exists() { - let checkpoint_res = fs::read(checkpoint_file); - match checkpoint_res { - Ok(checkpoint) => Some(checkpoint), - Err(_) => None, - } - } else { - None - } - } - - fn get_data_dir(&self) -> PathBuf { - if let Some(dir) = &self.data_dir { - PathBuf::from_str(dir).expect("cannot find data dir") - } else { - home_dir() - .unwrap() - .join(format!(".helios/data/{}", self.network)) - } - } -} diff --git a/client/Cargo.toml b/client/Cargo.toml index cbaa020..d8126f9 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -9,11 +9,12 @@ eyre = "0.6.8" serde = { version = "1.0.143", features = ["derive"] } hex = "0.4.3" ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "cb08f18ca919cc1b685b861d0fa9e2daabe89737" } -ethers = "1.0.0" +ethers = { version = "1.0.2", features = [ "ws", "default" ] } jsonrpsee = { version = "0.15.1", features = ["full"] } futures = "0.3.23" log = "0.4.17" thiserror = "1.0.37" +ctrlc = "3.2.3" common = { path = "../common" } consensus = { path = "../consensus" } diff --git a/client/src/builder.rs b/client/src/builder.rs index fe992ad..fbf087c 100644 --- a/client/src/builder.rs +++ b/client/src/builder.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; -use config::{Network, Config}; -use execution::rpc::ExecutionRpc; +use config::{Config, Network}; +use execution::rpc::WsRpc; use crate::{database::FileDB, Client}; @@ -100,7 +100,7 @@ impl ClientBuilder { self } - pub fn build(self) -> eyre::Result> { + fn build_base_config(&self) -> eyre::Result { let base_config = if let Some(network) = self.network { network.to_base_config() } else { @@ -111,7 +111,7 @@ impl ClientBuilder { config.to_base_config() }; - let consensus_rpc = self.consensus_rpc.unwrap_or_else(|| { + let consensus_rpc = self.consensus_rpc.clone().unwrap_or_else(|| { self.config .as_ref() .expect("missing consensus rpc") @@ -119,7 +119,7 @@ impl ClientBuilder { .clone() }); - let execution_rpc = self.execution_rpc.unwrap_or_else(|| { + let execution_rpc = self.execution_rpc.clone().unwrap_or_else(|| { self.config .as_ref() .expect("missing execution rpc") @@ -127,8 +127,8 @@ impl ClientBuilder { .clone() }); - let checkpoint = if let Some(checkpoint) = self.checkpoint { - checkpoint + let checkpoint = if let Some(checkpoint) = &self.checkpoint { + checkpoint.clone() } else if let Some(config) = &self.config { config.checkpoint.clone() } else { @@ -144,7 +144,7 @@ impl ClientBuilder { }; let data_dir = if self.data_dir.is_some() { - self.data_dir + self.data_dir.clone() } else if let Some(config) = &self.config { config.data_dir.clone() } else { @@ -152,7 +152,7 @@ impl ClientBuilder { }; let fallback = if self.fallback.is_some() { - self.fallback + self.fallback.clone() } else if let Some(config) = &self.config { config.fallback.clone() } else { @@ -177,7 +177,7 @@ impl ClientBuilder { self.with_http }; - let config = Config { + Ok(Config { consensus_rpc, execution_rpc, checkpoint, @@ -190,8 +190,13 @@ impl ClientBuilder { load_external_fallback, with_ws, with_http, - }; + }) + } +} +impl ClientBuilder { + pub fn build(self) -> eyre::Result> { + let config = self.build_base_config()?; Client::new(config) } -} \ No newline at end of file +} diff --git a/client/src/client.rs b/client/src/client.rs index 4fdff70..026f7e4 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -1,4 +1,5 @@ -use std::sync::Arc; +use std::process::exit; +use std::sync::{Arc, Mutex}; use config::networks::Network; use ethers::prelude::{Address, U256}; @@ -7,8 +8,9 @@ use ethers::types::{Filter, Log, Transaction, TransactionReceipt, H256}; use common::types::BlockTag; use config::{CheckpointFallback, Config}; use consensus::{types::Header, ConsensusClient}; -use execution::rpc::ExecutionRpc; +use execution::rpc::{ExecutionRpc, WsRpc}; use execution::types::{CallOpts, ExecutionBlock}; +use futures::executor::block_on; use log::{info, warn}; use tokio::spawn; use tokio::sync::RwLock; @@ -28,9 +30,10 @@ pub struct Client { http: bool, } -impl Client where R: ExecutionRpc { +impl Client { pub fn new(config: Config) -> eyre::Result { let config = Arc::new(config); + let node = Node::new(config.clone())?; let node = Arc::new(RwLock::new(node)); @@ -53,11 +56,48 @@ impl Client where R: ExecutionRpc { } } +impl Client { + pub fn register_shutdown_handler(client: Client) { + let client = Arc::new(client); + let shutdown_counter = Arc::new(Mutex::new(0)); + + ctrlc::set_handler(move || { + let mut counter = shutdown_counter.lock().unwrap(); + *counter += 1; + + let counter_value = *counter; + + if counter_value == 3 { + info!("forced shutdown"); + exit(0); + } + + info!( + "shutting down... press ctrl-c {} more times to force quit", + 3 - counter_value + ); + + if counter_value == 1 { + let client = client.clone(); + std::thread::spawn(move || { + block_on(client.shutdown()); + exit(0); + }); + } + }) + .expect("could not register shutdown handler"); + } +} + impl Client { pub async fn start(&mut self) -> eyre::Result<()> { if let Some(rpc) = &mut self.rpc { - if self.ws { rpc.start_ws().await?; } - if self.http { rpc.start_http().await?; } + if self.ws { + rpc.start_ws().await?; + } + if self.http { + rpc.start_http().await?; + } } if self.node.write().await.sync().await.is_err() { @@ -222,7 +262,10 @@ impl Client { .await } - pub async fn get_transaction_by_hash(&self, tx_hash: &H256) -> eyre::Result> { + pub async fn get_transaction_by_hash( + &self, + tx_hash: &H256, + ) -> eyre::Result> { self.node .read() .await diff --git a/client/src/lib.rs b/client/src/lib.rs index abc747c..935fa68 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,4 +1,3 @@ - /// Re-export builder logic mod builder; pub use crate::builder::*; diff --git a/client/src/node.rs b/client/src/node.rs index 4bf3489..6663472 100644 --- a/client/src/node.rs +++ b/client/src/node.rs @@ -4,7 +4,7 @@ use std::time::Duration; use ethers::prelude::{Address, U256}; use ethers::types::{Filter, Log, Transaction, TransactionReceipt, H256}; -use execution::rpc::ExecutionRpc; +use execution::rpc::{ExecutionRpc, WsRpc}; use eyre::{eyre, Result}; use common::errors::BlockNotFoundError; @@ -20,7 +20,7 @@ use execution::ExecutionClient; use crate::errors::NodeError; -pub struct Node where R: ExecutionRpc, { +pub struct Node { pub consensus: ConsensusClient, pub execution: Arc>, pub config: Arc, @@ -29,7 +29,7 @@ pub struct Node where R: ExecutionRpc, { pub history_size: usize, } -impl Node where R: ExecutionRpc { +impl Node { pub fn new(config: Arc) -> Result { let consensus_rpc = &config.consensus_rpc; let checkpoint_hash = &config.checkpoint; @@ -37,9 +37,18 @@ impl Node where R: ExecutionRpc { let consensus = ConsensusClient::new(consensus_rpc, checkpoint_hash, config.clone()) .map_err(NodeError::ConsensusClientCreationError)?; - let execution = Arc::new( - ExecutionClient::new(execution_rpc).map_err(NodeError::ExecutionClientCreationError)?, - ); + + let execution = if config.with_ws { + Arc::new( + ExecutionClient::new_with_ws(execution_rpc) + .map_err(NodeError::ExecutionClientCreationError)?, + ) + } else { + Arc::new( + ExecutionClient::new(execution_rpc) + .map_err(NodeError::ExecutionClientCreationError)?, + ) + }; let payloads = BTreeMap::new(); let finalized_payloads = BTreeMap::new(); @@ -53,7 +62,12 @@ impl Node where R: ExecutionRpc { history_size: 64, }) } +} +impl Node +where + R: ExecutionRpc, +{ pub async fn sync(&mut self) -> Result<(), NodeError> { self.consensus .sync() diff --git a/client/src/rpc.rs b/client/src/rpc.rs index 5ca83e0..4b9b6c8 100644 --- a/client/src/rpc.rs +++ b/client/src/rpc.rs @@ -16,9 +16,12 @@ use common::{ types::BlockTag, utils::{hex_str_to_bytes, u64_to_hex_string}, }; -use execution::{types::{CallOpts, ExecutionBlock}, rpc::ExecutionRpc}; +use execution::{ + rpc::ExecutionRpc, + types::{CallOpts, ExecutionBlock}, +}; -pub struct Rpc where R: ExecutionRpc { +pub struct Rpc { node: Arc>>, http_handle: Option, ws_handle: Option, @@ -27,7 +30,7 @@ pub struct Rpc where R: ExecutionRpc { port: u16, } -impl Rpc where R: ExecutionRpc { +impl Rpc { pub fn new(node: Arc>>, with_http: bool, with_ws: bool, port: u16) -> Self { Rpc { node, @@ -112,13 +115,13 @@ trait NetRpc { } #[derive(Clone)] -struct RpcInner where R: ExecutionRpc { +struct RpcInner { node: Arc>>, http_port: u16, ws_port: u16, } -impl From<&Rpc> for RpcInner where R: ExecutionRpc { +impl From<&Rpc> for RpcInner { fn from(rpc: &Rpc) -> Self { RpcInner { node: Arc::clone(&rpc.node), @@ -128,7 +131,7 @@ impl From<&Rpc> for RpcInner where R: ExecutionRpc { } } -impl RpcInner where R: ExecutionRpc { +impl RpcInner { pub async fn start_http(&self) -> Result<(HttpServerHandle, SocketAddr)> { let addr = format!("127.0.0.1:{}", self.http_port); let server = HttpServerBuilder::default().build(addr).await?; @@ -167,7 +170,7 @@ impl RpcInner where R: ExecutionRpc { } #[async_trait] -impl EthRpcServer for RpcInner where R: ExecutionRpc { +impl EthRpcServer for RpcInner { async fn get_balance(&self, address: &str, block: BlockTag) -> Result { let address = convert_err(Address::from_str(address))?; let node = self.node.read().await; @@ -181,7 +184,7 @@ impl EthRpcServer for RpcInner where R: ExecutionRpc { let node = self.node.read().await; let nonce = convert_err(node.get_nonce(&address, block).await)?; - Ok(format!("0x{:x}", nonce)) + Ok(format!("0x{nonce:x}")) } async fn get_code(&self, address: &str, block: BlockTag) -> Result { @@ -288,7 +291,7 @@ impl EthRpcServer for RpcInner where R: ExecutionRpc { } #[async_trait] -impl NetRpcServer for RpcInner where R: ExecutionRpc { +impl NetRpcServer for RpcInner { async fn version(&self) -> Result { let node = self.node.read().await; Ok(node.chain_id().to_string()) diff --git a/common/Cargo.toml b/common/Cargo.toml index 9ae1181..81deb6f 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -8,5 +8,5 @@ eyre = "0.6.8" serde = { version = "1.0.143", features = ["derive"] } hex = "0.4.3" ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "cb08f18ca919cc1b685b861d0fa9e2daabe89737" } -ethers = "1.0.0" +ethers = { version = "1.0.2", features = [ "ws", "default" ] } thiserror = "1.0.37" diff --git a/common/src/types.rs b/common/src/types.rs index af15ce9..5f8cbec 100644 --- a/common/src/types.rs +++ b/common/src/types.rs @@ -20,7 +20,7 @@ impl Display for BlockTag { Self::Number(num) => num.to_string(), }; - write!(f, "{}", formatted) + write!(f, "{formatted}") } } diff --git a/common/src/utils.rs b/common/src/utils.rs index 1e51a5e..81bab4c 100644 --- a/common/src/utils.rs +++ b/common/src/utils.rs @@ -14,7 +14,7 @@ pub fn format_hex(num: &U256) -> String { .unwrap() .trim_start_matches('0') .to_string(); - format!("0x{}", stripped) + format!("0x{stripped}") } pub fn hex_str_to_bytes(s: &str) -> Result> { @@ -35,5 +35,5 @@ pub fn address_to_hex_string(address: &Address) -> String { } pub fn u64_to_hex_string(val: u64) -> String { - format!("0x{:x}", val) + format!("0x{val:x}") } diff --git a/config/Cargo.toml b/config/Cargo.toml index 8162df8..1c52b37 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -10,7 +10,7 @@ eyre = "0.6.8" serde = { version = "1.0.143", features = ["derive"] } hex = "0.4.3" ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "cb08f18ca919cc1b685b861d0fa9e2daabe89737" } -ethers = "1.0.0" +ethers = { version = "1.0.2", features = [ "ws", "default" ] } figment = { version = "0.10.7", features = ["toml", "env"] } thiserror = "1.0.37" log = "0.4.17" diff --git a/config/src/checkpoints.rs b/config/src/checkpoints.rs index 7aa4c1f..827cac6 100644 --- a/config/src/checkpoints.rs +++ b/config/src/checkpoints.rs @@ -101,7 +101,7 @@ impl CheckpointFallback { let service_list = list .get(network.to_string().to_lowercase()) .ok_or_else(|| { - eyre::eyre!(format!("missing {} fallback checkpoint services", network)) + eyre::eyre!(format!("missing {network} fallback checkpoint services")) })?; let parsed: Vec = serde_yaml::from_value(service_list.clone())?; @@ -202,7 +202,7 @@ impl CheckpointFallback { /// assert_eq!("https://sync-mainnet.beaconcha.in/checkpointz/v1/beacon/slots", url); /// ``` pub fn construct_url(endpoint: &str) -> String { - format!("{}/checkpointz/v1/beacon/slots", endpoint) + format!("{endpoint}/checkpointz/v1/beacon/slots") } /// Returns a list of all checkpoint fallback endpoints. diff --git a/config/src/config.rs b/config/src/config.rs index bddb95c..9dd6b27 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -57,20 +57,14 @@ impl Config { figment::error::Kind::MissingField(field) => { let field = field.replace('_', "-"); - println!( - "\x1b[91merror\x1b[0m: missing configuration field: {}", - field - ); + println!("\x1b[91merror\x1b[0m: missing configuration field: {field}"); - println!( - "\n\ttry supplying the propoper command line argument: --{}", - field - ); + println!("\n\ttry supplying the propoper command line argument: --{field}"); println!("\talternatively, you can add the field to your helios.toml file or as an environment variable"); println!("\nfor more information, check the github README"); } - _ => println!("cannot parse configuration: {}", err), + _ => println!("cannot parse configuration: {err}"), } exit(1); } diff --git a/config/tests/checkpoints.rs b/config/tests/checkpoints.rs index acb535e..1d50e61 100644 --- a/config/tests/checkpoints.rs +++ b/config/tests/checkpoints.rs @@ -50,9 +50,9 @@ async fn test_get_all_fallback_endpoints() { .await .unwrap(); let urls = cf.get_all_fallback_endpoints(&networks::Network::MAINNET); - assert!(urls.len() > 0); + assert!(!urls.is_empty()); let urls = cf.get_all_fallback_endpoints(&networks::Network::GOERLI); - assert!(urls.len() > 0); + assert!(!urls.is_empty()); } #[tokio::test] @@ -62,7 +62,7 @@ async fn test_get_healthy_fallback_endpoints() { .await .unwrap(); let urls = cf.get_healthy_fallback_endpoints(&networks::Network::MAINNET); - assert!(urls.len() > 0); + assert!(!urls.is_empty()); let urls = cf.get_healthy_fallback_endpoints(&networks::Network::GOERLI); - assert!(urls.len() > 0); + assert!(!urls.is_empty()); } diff --git a/consensus/Cargo.toml b/consensus/Cargo.toml index bf96ac2..e5b8866 100644 --- a/consensus/Cargo.toml +++ b/consensus/Cargo.toml @@ -11,7 +11,7 @@ serde_json = "1.0.85" hex = "0.4.3" ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "cb08f18ca919cc1b685b861d0fa9e2daabe89737" } blst = "0.3.10" -ethers = "1.0.0" +ethers = { version = "1.0.2", features = [ "ws", "default" ] } bytes = "1.2.1" toml = "0.5.9" async-trait = "0.1.57" diff --git a/consensus/src/consensus.rs b/consensus/src/consensus.rs index 7c4d106..8eb6258 100644 --- a/consensus/src/consensus.rs +++ b/consensus/src/consensus.rs @@ -661,7 +661,7 @@ mod tests { let mut update = updates[0].clone(); update.finalized_header = Header::default(); - let err = client.verify_update(&mut update).err().unwrap(); + let err = client.verify_update(&update).err().unwrap(); assert_eq!( err.to_string(), ConsensusError::InvalidFinalityProof.to_string() @@ -681,7 +681,7 @@ mod tests { let mut update = updates[0].clone(); update.sync_aggregate.sync_committee_signature = Vector::default(); - let err = client.verify_update(&mut update).err().unwrap(); + let err = client.verify_update(&update).err().unwrap(); assert_eq!( err.to_string(), ConsensusError::InvalidSignature.to_string() diff --git a/examples/checkpoints.rs b/examples/checkpoints.rs index e74a4f0..1337a9f 100644 --- a/examples/checkpoints.rs +++ b/examples/checkpoints.rs @@ -19,24 +19,24 @@ async fn main() -> Result<()> { .fetch_latest_checkpoint(&networks::Network::GOERLI) .await .unwrap(); - println!("Fetched latest goerli checkpoint: {}", goerli_checkpoint); + println!("Fetched latest goerli checkpoint: {goerli_checkpoint}"); // Fetch the latest mainnet checkpoint let mainnet_checkpoint = cf .fetch_latest_checkpoint(&networks::Network::MAINNET) .await .unwrap(); - println!("Fetched latest mainnet checkpoint: {}", mainnet_checkpoint); + println!("Fetched latest mainnet checkpoint: {mainnet_checkpoint}"); // Let's get a list of all the fallback service endpoints for mainnet let endpoints = cf.get_all_fallback_endpoints(&networks::Network::MAINNET); - println!("Fetched all mainnet fallback endpoints: {:?}", endpoints); + println!("Fetched all mainnet fallback endpoints: {endpoints:?}"); // Since we built the checkpoint fallback services, we can also just get the raw checkpoint fallback services. // The `get_fallback_services` method returns a reference to the internal list of CheckpointFallbackService objects // for the given network. let services = cf.get_fallback_services(&networks::Network::MAINNET); - println!("Fetched all mainnet fallback services: {:?}", services); + println!("Fetched all mainnet fallback services: {services:?}"); Ok(()) } diff --git a/examples/config.rs b/examples/config.rs index c055477..e16d86d 100644 --- a/examples/config.rs +++ b/examples/config.rs @@ -8,7 +8,7 @@ async fn main() -> Result<()> { // Load the config from the global config file let config_path = home::home_dir().unwrap().join(".helios/helios.toml"); let config = Config::from_file(&config_path, "mainnet", &CliConfig::default()); - println!("Constructed config: {:#?}", config); + println!("Constructed config: {config:#?}"); Ok(()) } diff --git a/execution/Cargo.toml b/execution/Cargo.toml index ee819f5..bbcbd1d 100644 --- a/execution/Cargo.toml +++ b/execution/Cargo.toml @@ -11,7 +11,7 @@ serde = { version = "1.0.143", features = ["derive"] } serde_json = "1.0.85" hex = "0.4.3" ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "cb08f18ca919cc1b685b861d0fa9e2daabe89737" } -ethers = "1.0.0" +ethers = { version = "1.0.2", features = [ "ws", "default" ] } revm = "2.1.0" bytes = "1.2.1" futures = "0.3.23" diff --git a/execution/src/execution.rs b/execution/src/execution.rs index 400d027..ea115ff 100644 --- a/execution/src/execution.rs +++ b/execution/src/execution.rs @@ -15,6 +15,7 @@ use revm::KECCAK_EMPTY; use triehash_ethereum::ordered_trie_root; use crate::errors::ExecutionError; +use crate::rpc::WsRpc; use crate::types::Transactions; use super::proof::{encode_account, verify_proof}; @@ -30,6 +31,13 @@ pub struct ExecutionClient { pub rpc: R, } +impl ExecutionClient { + pub fn new_with_ws(rpc: &str) -> Result { + let rpc = WsRpc::new(rpc)?; + Ok(Self { rpc }) + } +} + impl ExecutionClient { pub fn new(rpc: &str) -> Result { let rpc = ExecutionRpc::new(rpc)?; diff --git a/execution/src/proof.rs b/execution/src/proof.rs index 72b5e9a..0d836ab 100644 --- a/execution/src/proof.rs +++ b/execution/src/proof.rs @@ -90,7 +90,7 @@ fn get_rest_path(p: &Vec, s: usize) -> String { let mut ret = String::new(); for i in s..p.len() * 2 { let n = get_nibble(p, i); - ret += &format!("{:01x}", n); + ret += &format!("{n:01x}"); } ret } diff --git a/execution/src/rpc/mod.rs b/execution/src/rpc/mod.rs index e5448fe..b6d9d74 100644 --- a/execution/src/rpc/mod.rs +++ b/execution/src/rpc/mod.rs @@ -8,6 +8,9 @@ use eyre::Result; use crate::types::CallOpts; pub mod http_rpc; +pub use http_rpc::*; +pub mod ws_rpc; +pub use ws_rpc::*; pub mod mock_rpc; #[async_trait] diff --git a/execution/src/rpc/ws_rpc.rs b/execution/src/rpc/ws_rpc.rs index 2f8e2d3..07754b4 100644 --- a/execution/src/rpc/ws_rpc.rs +++ b/execution/src/rpc/ws_rpc.rs @@ -1,14 +1,8 @@ -use std::str::FromStr; - use async_trait::async_trait; use common::errors::RpcError; -use ethers::prelude::{Address, Ws}; -use ethers::providers::{HttpRateLimitRetryPolicy, Middleware, Provider, RetryClient}; -use ethers::types::transaction::eip2718::TypedTransaction; -use ethers::types::transaction::eip2930::AccessList; -use ethers::types::{ - BlockId, Bytes, EIP1186ProofResponse, Eip1559TransactionRequest, Filter, Log, Transaction, - TransactionReceipt, H256, U256, +use ethers::{ + prelude::*, + types::transaction::{eip2718::TypedTransaction, eip2930::AccessList}, }; use eyre::Result; @@ -30,9 +24,9 @@ impl Clone for WsRpc { #[async_trait] impl ExecutionRpc for WsRpc { fn new(rpc: &str) -> Result { - Ok(WsRpc { + Ok(Self { url: rpc.to_string(), - provider: None, + provider: None::>, }) } @@ -51,6 +45,11 @@ impl ExecutionRpc for WsRpc { let block = Some(BlockId::from(block)); let proof_response = self .provider + .as_ref() + .ok_or(RpcError::new( + "get_proof", + eyre::eyre!("Provider not connected!"), + ))? .get_proof(*address, slots.to_vec(), block) .await .map_err(|e| RpcError::new("get_proof", e))?; @@ -76,6 +75,11 @@ impl ExecutionRpc for WsRpc { let tx = TypedTransaction::Eip1559(raw_tx); let list = self .provider + .as_ref() + .ok_or(RpcError::new( + "create_access_list", + eyre::eyre!("Provider not connected!"), + ))? .create_access_list(&tx, block) .await .map_err(|e| RpcError::new("create_access_list", e))?; @@ -87,6 +91,11 @@ impl ExecutionRpc for WsRpc { let block = Some(BlockId::from(block)); let code = self .provider + .as_ref() + .ok_or(RpcError::new( + "get_code", + eyre::eyre!("Provider not connected!"), + ))? .get_code(*address, block) .await .map_err(|e| RpcError::new("get_code", e))?; @@ -98,6 +107,11 @@ impl ExecutionRpc for WsRpc { let bytes = Bytes::from(bytes.to_owned()); let tx = self .provider + .as_ref() + .ok_or(RpcError::new( + "send_raw_transaction", + eyre::eyre!("Provider not connected!"), + ))? .send_raw_transaction(bytes) .await .map_err(|e| RpcError::new("send_raw_transaction", e))?; @@ -108,6 +122,11 @@ impl ExecutionRpc for WsRpc { async fn get_transaction_receipt(&self, tx_hash: &H256) -> Result> { let receipt = self .provider + .as_ref() + .ok_or(RpcError::new( + "get_transaction_receipt", + eyre::eyre!("Provider not connected!"), + ))? .get_transaction_receipt(*tx_hash) .await .map_err(|e| RpcError::new("get_transaction_receipt", e))?; @@ -118,6 +137,11 @@ impl ExecutionRpc for WsRpc { async fn get_transaction(&self, tx_hash: &H256) -> Result> { Ok(self .provider + .as_ref() + .ok_or(RpcError::new( + "get_transaction", + eyre::eyre!("Provider not connected!"), + ))? .get_transaction(*tx_hash) .await .map_err(|e| RpcError::new("get_transaction", e))?) @@ -126,6 +150,11 @@ impl ExecutionRpc for WsRpc { async fn get_logs(&self, filter: &Filter) -> Result> { Ok(self .provider + .as_ref() + .ok_or(RpcError::new( + "get_logs", + eyre::eyre!("Provider not connected!"), + ))? .get_logs(filter) .await .map_err(|e| RpcError::new("get_logs", e))?) diff --git a/execution/tests/execution.rs b/execution/tests/execution.rs index ddcd890..c83973d 100644 --- a/execution/tests/execution.rs +++ b/execution/tests/execution.rs @@ -18,11 +18,13 @@ async fn test_get_account() { let execution = get_client(); let address = Address::from_str("14f9D4aF749609c1438528C0Cce1cC3f6D411c47").unwrap(); - let mut payload = ExecutionPayload::default(); - payload.state_root = Vector::from_iter( - hex_str_to_bytes("0xaa02f5db2ee75e3da400d10f3c30e894b6016ce8a2501680380a907b6674ce0d") - .unwrap(), - ); + let payload = ExecutionPayload { + state_root: Vector::from_iter( + hex_str_to_bytes("0xaa02f5db2ee75e3da400d10f3c30e894b6016ce8a2501680380a907b6674ce0d") + .unwrap(), + ), + ..Default::default() + }; let account = execution .get_account(&address, None, &payload) @@ -102,11 +104,13 @@ async fn test_get_tx_not_included() { #[tokio::test] async fn test_get_logs() { let execution = get_client(); - let mut payload = ExecutionPayload::default(); - payload.receipts_root = Vector::from_iter( - hex_str_to_bytes("dd82a78eccb333854f0c99e5632906e092d8a49c27a21c25cae12b82ec2a113f") - .unwrap(), - ); + let mut payload = ExecutionPayload { + receipts_root: Vector::from_iter( + hex_str_to_bytes("dd82a78eccb333854f0c99e5632906e092d8a49c27a21c25cae12b82ec2a113f") + .unwrap(), + ), + ..ExecutionPayload::default() + }; payload.transactions.push(List::from_iter(hex_str_to_bytes("0x02f8b20583623355849502f900849502f91082ea6094326c977e6efc84e512bb9c30f76e30c160ed06fb80b844a9059cbb0000000000000000000000007daccf9b3c1ae2fa5c55f1c978aeef700bc83be0000000000000000000000000000000000000000000000001158e460913d00000c080a0e1445466b058b6f883c0222f1b1f3e2ad9bee7b5f688813d86e3fa8f93aa868ca0786d6e7f3aefa8fe73857c65c32e4884d8ba38d0ecfb947fbffb82e8ee80c167").unwrap())); @@ -130,11 +134,13 @@ async fn test_get_receipt() { let tx_hash = H256::from_str("2dac1b27ab58b493f902dda8b63979a112398d747f1761c0891777c0983e591f").unwrap(); - let mut payload = ExecutionPayload::default(); - payload.receipts_root = Vector::from_iter( - hex_str_to_bytes("dd82a78eccb333854f0c99e5632906e092d8a49c27a21c25cae12b82ec2a113f") - .unwrap(), - ); + let mut payload = ExecutionPayload { + receipts_root: Vector::from_iter( + hex_str_to_bytes("dd82a78eccb333854f0c99e5632906e092d8a49c27a21c25cae12b82ec2a113f") + .unwrap(), + ), + ..ExecutionPayload::default() + }; payload.transactions.push(List::from_iter(hex_str_to_bytes("0x02f8b20583623355849502f900849502f91082ea6094326c977e6efc84e512bb9c30f76e30c160ed06fb80b844a9059cbb0000000000000000000000007daccf9b3c1ae2fa5c55f1c978aeef700bc83be0000000000000000000000000000000000000000000000001158e460913d00000c080a0e1445466b058b6f883c0222f1b1f3e2ad9bee7b5f688813d86e3fa8f93aa868ca0786d6e7f3aefa8fe73857c65c32e4884d8ba38d0ecfb947fbffb82e8ee80c167").unwrap())); @@ -185,8 +191,10 @@ async fn test_get_receipt_not_included() { #[tokio::test] async fn test_get_block() { let execution = get_client(); - let mut payload = ExecutionPayload::default(); - payload.block_number = 12345; + let payload = ExecutionPayload { + block_number: 12345, + ..ExecutionPayload::default() + }; let block = execution.get_block(&payload, false).await.unwrap();