diff --git a/contracts/near/Cargo.lock b/contracts/near/Cargo.lock index 822ae64e..ac20624f 100644 --- a/contracts/near/Cargo.lock +++ b/contracts/near/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "amcl" version = "0.3.0" -source = "git+https://github.com/sigp/milagro_bls?tag=v1.4.2#16655aa033175a90c10ef02aa144e2835de23aec" +source = "git+https://github.com/sigp/milagro_bls?tag=v1.5.1#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" [[package]] name = "android_system_properties" @@ -433,17 +433,17 @@ dependencies = [ [[package]] name = "bls" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v4.6.0-wasm#7f7b139b5f9d81bcb9ed8bbdd5561cfb9e38bb12" dependencies = [ - "eth2_hashing", - "eth2_serde_utils", - "eth2_ssz", + "arbitrary", "ethereum-types 0.14.1", + "ethereum_hashing", + "ethereum_serde_utils", + "ethereum_ssz", "hex 0.4.3", "milagro_bls", - "rand 0.7.3", + "rand 0.8.5", "serde", - "serde_derive", "tree_hash", "zeroize", ] @@ -1125,10 +1125,10 @@ version = "0.1.0" dependencies = [ "borsh", "derive_more", - "eth2_serde_utils", - "eth2_ssz", - "eth2_ssz_derive", "ethereum-types 0.14.1", + "ethereum_serde_utils", + "ethereum_ssz", + "ethereum_ssz_derive", "hex 0.4.3", "near-sdk", "rlp 0.5.2", @@ -1151,12 +1151,13 @@ dependencies = [ "eth-types", "eth2-utility", "ethereum-types 0.14.1", + "ethereum_serde_utils", "hex 0.4.3", "lazy_static", - "merkle_proof", "near-plugins", "near-sdk", "near-units", + "serde", "serde_json", "tokio", "tree_hash", @@ -1171,55 +1172,14 @@ dependencies = [ "borsh", "eth-types", "ethereum-types 0.14.1", + "ethereum_hashing", "hex 0.4.3", "lazy_static", - "merkle_proof", "near-sdk", "serde_json", "tree_hash", ] -[[package]] -name = "eth2_hashing" -version = "0.3.0" -dependencies = [ - "lazy_static", - "near-sdk", -] - -[[package]] -name = "eth2_serde_utils" -version = "0.1.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "ethereum-types 0.14.1", - "hex 0.4.3", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "eth2_ssz" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "ethereum-types 0.14.1", - "itertools", - "smallvec 1.10.0", -] - -[[package]] -name = "eth2_ssz_derive" -version = "0.3.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "ethabi" version = "16.0.0" @@ -1232,7 +1192,7 @@ dependencies = [ "serde_json", "sha3 0.9.1", "thiserror", - "uint 0.9.5", + "uint 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1254,7 +1214,7 @@ checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" dependencies = [ "crunchy", "fixed-hash 0.7.0", - "impl-rlp 0.3.0", + "impl-rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.3.2", "tiny-keccak", ] @@ -1262,12 +1222,11 @@ dependencies = [ [[package]] name = "ethbloom" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" dependencies = [ "crunchy", "fixed-hash 0.8.0", - "impl-rlp 0.3.0", + "impl-rlp 0.3.0 (git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm)", "impl-serde 0.4.0", "tiny-keccak", ] @@ -1280,24 +1239,67 @@ checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf" dependencies = [ "ethbloom 0.11.1", "fixed-hash 0.7.0", - "impl-rlp 0.3.0", + "impl-rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.3.2", "primitive-types 0.10.1", - "uint 0.9.5", + "uint 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ethereum-types" version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" dependencies = [ "ethbloom 0.13.0", "fixed-hash 0.8.0", - "impl-rlp 0.3.0", + "impl-rlp 0.3.0 (git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm)", "impl-serde 0.4.0", "primitive-types 0.12.1", - "uint 0.9.5", + "uint 0.9.5 (git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm)", +] + +[[package]] +name = "ethereum_hashing" +version = "1.0.0-beta.2" +dependencies = [ + "lazy_static", + "near-sdk", +] + +[[package]] +name = "ethereum_serde_utils" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de4d5951468846963c24e8744c133d44f39dff2cd3a233f6be22b370d08a524f" +dependencies = [ + "ethereum-types 0.14.1", + "hex 0.4.3", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "ethereum_ssz" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e61ffea29f26e8249d35128a82ec8d3bd4fbc80179ea5f5e5e3daafef6a80fcb" +dependencies = [ + "ethereum-types 0.14.1", + "itertools", + "smallvec 1.10.0", +] + +[[package]] +name = "ethereum_ssz_derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6085d7fd3cf84bd2b8fec150d54c8467fb491d8db9c460607c5534f653a0ee38" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1373,8 +1375,7 @@ dependencies = [ [[package]] name = "fixed-hash" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" dependencies = [ "byteorder", "rustc-hex", @@ -1889,6 +1890,14 @@ dependencies = [ "rlp 0.5.2", ] +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" +dependencies = [ + "rlp 0.5.2", +] + [[package]] name = "impl-serde" version = "0.3.2" @@ -1901,8 +1910,7 @@ dependencies = [ [[package]] name = "impl-serde" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" dependencies = [ "serde", ] @@ -2122,26 +2130,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" -[[package]] -name = "merkle_proof" -version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "eth2_hashing", - "ethereum-types 0.14.1", - "lazy_static", - "safe_arith", -] - [[package]] name = "milagro_bls" -version = "1.4.2" -source = "git+https://github.com/sigp/milagro_bls?tag=v1.4.2#16655aa033175a90c10ef02aa144e2835de23aec" +version = "1.5.1" +source = "git+https://github.com/sigp/milagro_bls?tag=v1.5.1#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" dependencies = [ "amcl", "hex 0.4.3", "lazy_static", - "rand 0.7.3", + "rand 0.8.5", "zeroize", ] @@ -3230,21 +3227,20 @@ checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" dependencies = [ "fixed-hash 0.7.0", "impl-codec", - "impl-rlp 0.3.0", + "impl-rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.3.2", - "uint 0.9.5", + "uint 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primitive-types" version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" dependencies = [ "fixed-hash 0.8.0", - "impl-rlp 0.3.0", + "impl-rlp 0.3.0 (git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm)", "impl-serde 0.4.0", - "uint 0.9.5", + "uint 0.9.5 (git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm)", ] [[package]] @@ -3595,8 +3591,7 @@ dependencies = [ [[package]] name = "rlp" version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" dependencies = [ "bytes", "rustc-hex", @@ -3605,8 +3600,7 @@ dependencies = [ [[package]] name = "rlp-derive" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" dependencies = [ "proc-macro2", "quote", @@ -3672,11 +3666,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "safe_arith" -version = "0.1.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" - [[package]] name = "schannel" version = "0.1.21" @@ -4567,18 +4556,20 @@ dependencies = [ [[package]] name = "tree_hash" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c998ac5fe2b07c025444bdd522e6258110b63861c6698eedc610c071980238d" dependencies = [ - "eth2_hashing", "ethereum-types 0.14.1", + "ethereum_hashing", "smallvec 1.10.0", ] [[package]] name = "tree_hash_derive" -version = "0.4.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84303a9c7cda5f085a3ed9cd241d1e95e04d88aab1d679b02f212e653537ba86" dependencies = [ "darling", "quote", @@ -4621,6 +4612,17 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "uint" +version = "0.9.5" +source = "git+https://github.com/aurora-is-near/parity-common?tag=v0.14.1-wasm#2594d5a479cb9eb4962edf9d82434219be1c8f4f" +dependencies = [ + "byteorder", + "crunchy", + "hex 0.4.3", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.11" diff --git a/contracts/near/Cargo.toml b/contracts/near/Cargo.toml index b8b50805..44c56aa6 100644 --- a/contracts/near/Cargo.toml +++ b/contracts/near/Cargo.toml @@ -16,11 +16,26 @@ debug = false panic = "abort" overflow-checks = true +[workspace.dependencies] +near-sdk = "4.1.1" +borsh = "0.9.3" +rlp = "0.5.2" +rlp-derive = "0.1.0" +ethereum-types = "0.14.1" +tree_hash = "0.5" +tree_hash_derive = "0.5" +ethereum_ssz = "0.5" +ethereum_ssz_derive = "0.5" +ethereum_serde_utils = "0.5" +ethereum_hashing = "1.0.0-beta.2" +derive_more = "^0.99.2" +hex = "0.4.2" +bitvec = "1.0.0" +near-plugins = { git = "https://github.com/aurora-is-near/near-plugins", tag = "v0.1.0" } + [patch] [patch.crates-io] -eth2_hashing = { path = "eth2_hashing" } -eth2_ssz = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm"} -tree_hash_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm"} -eth2_serde_utils = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_ssz_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } \ No newline at end of file +ethereum_hashing = { path = "eth2_hashing" } +ethereum-types = { git = "https://github.com/aurora-is-near/parity-common", tag = "v0.14.1-wasm" } +rlp = { git = "https://github.com/aurora-is-near/parity-common", tag = "v0.14.1-wasm" } +rlp-derive = { git = "https://github.com/aurora-is-near/parity-common", tag = "v0.14.1-wasm" } diff --git a/contracts/near/eth-prover/Cargo.toml b/contracts/near/eth-prover/Cargo.toml index 6bc071dc..d3b009d4 100644 --- a/contracts/near/eth-prover/Cargo.toml +++ b/contracts/near/eth-prover/Cargo.toml @@ -9,15 +9,14 @@ crate-type = ["cdylib", "rlib"] [dependencies] eth-types = { path = "../eth-types", default-features = false } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -near-sdk = "4.1.1" -borsh = "0.9.3" -rlp = "0.5.2" -hex = "0.4.2" -near-plugins = { git = "https://github.com/aurora-is-near/near-plugins", tag = "v0.1.0" } +near-sdk.workspace = true +borsh.workspace = true +rlp.workspace = true +near-plugins.workspace = true [dev-dependencies] +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" hex = { version = "0.4.3", features = ["serde"] } indicatif = "0.14" lazy_static = "*" diff --git a/contracts/near/eth-types/Cargo.toml b/contracts/near/eth-types/Cargo.toml index 868c2c46..d5576a75 100644 --- a/contracts/near/eth-types/Cargo.toml +++ b/contracts/near/eth-types/Cargo.toml @@ -9,18 +9,18 @@ crate-type = ["cdylib", "rlib"] [dependencies] serde = { version = "1.0", features = ["derive"] } -near-sdk = "4.1.1" -borsh = "0.9.3" -rlp = "0.5.2" -rlp-derive = "0.1.0" -ethereum-types = { version = "0.14.1", features = ["rlp", "serialize"], default-features = false } -derive_more = "^0.99.2" -eth2_ssz = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm", optional = true } -eth2_ssz_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm", optional = true } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm", optional = true } -tree_hash_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm", optional = true } -eth2_serde_utils = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm", optional = true } -hex = "0.4.0" +near-sdk.workspace = true +borsh.workspace = true +rlp.workspace = true +rlp-derive.workspace = true +ethereum-types.workspace = true +derive_more.workspace = true +ethereum_ssz = { workspace = true, optional = true } +ethereum_ssz_derive = { workspace = true, optional = true } +tree_hash = { workspace = true, optional = true } +tree_hash_derive = { workspace = true, optional = true } +ethereum_serde_utils = { workspace = true, optional = true } +hex.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] serde-big-array = "0.4.1" @@ -28,4 +28,4 @@ sha3 = "0.10.0" [features] default = ["eth2"] -eth2 = ["dep:eth2_ssz", "dep:eth2_ssz_derive", "dep:tree_hash", "dep:tree_hash_derive", "dep:eth2_serde_utils"] \ No newline at end of file +eth2 = ["dep:ethereum_ssz", "dep:ethereum_ssz_derive", "dep:tree_hash", "dep:tree_hash_derive", "dep:ethereum_serde_utils"] \ No newline at end of file diff --git a/contracts/near/eth-types/src/eth2.rs b/contracts/near/eth-types/src/eth2.rs index fba9590a..e1908089 100644 --- a/contracts/near/eth-types/src/eth2.rs +++ b/contracts/near/eth-types/src/eth2.rs @@ -32,15 +32,9 @@ arr_wrapper_impl_tree_hash_and_borsh!(SyncCommitteeBits, SYNC_COMMITTEE_BITS_SIZ #[derive(Debug, Clone, BorshDeserialize, BorshSerialize, tree_hash_derive::TreeHash)] #[cfg_attr(not(target_arch = "wasm32"), derive(Serialize, Deserialize))] pub struct BeaconBlockHeader { - #[cfg_attr( - not(target_arch = "wasm32"), - serde(with = "eth2_serde_utils::quoted_u64") - )] + #[cfg_attr(not(target_arch = "wasm32"), serde(with = "serde_utils::quoted_u64"))] pub slot: Slot, - #[cfg_attr( - not(target_arch = "wasm32"), - serde(with = "eth2_serde_utils::quoted_u64") - )] + #[cfg_attr(not(target_arch = "wasm32"), serde(with = "serde_utils::quoted_u64"))] pub proposer_index: u64, pub parent_root: H256, pub state_root: H256, @@ -124,10 +118,7 @@ pub struct FinalizedHeaderUpdate { pub struct LightClientUpdate { pub attested_beacon_header: BeaconBlockHeader, pub sync_aggregate: SyncAggregate, - #[cfg_attr( - not(target_arch = "wasm32"), - serde(with = "eth2_serde_utils::quoted_u64") - )] + #[cfg_attr(not(target_arch = "wasm32"), serde(with = "serde_utils::quoted_u64"))] pub signature_slot: Slot, pub finality_update: FinalizedHeaderUpdate, pub sync_committee_update: Option, diff --git a/contracts/near/eth-types/src/lib.rs b/contracts/near/eth-types/src/lib.rs index c2fb72f6..7338a7cd 100644 --- a/contracts/near/eth-types/src/lib.rs +++ b/contracts/near/eth-types/src/lib.rs @@ -136,42 +136,66 @@ pub struct BlockHeader { pub difficulty: U256, #[cfg_attr( all(feature = "eth2", not(target_arch = "wasm32")), - serde(with = "eth2_serde_utils::u64_hex_be") + serde(with = "serde_utils::u64_hex_be") )] pub number: u64, pub gas_limit: U256, pub gas_used: U256, #[cfg_attr( all(feature = "eth2", not(target_arch = "wasm32")), - serde(with = "eth2_serde_utils::u64_hex_be") + serde(with = "serde_utils::u64_hex_be") )] pub timestamp: u64, #[cfg_attr( all(feature = "eth2", not(target_arch = "wasm32")), - serde(with = "eth2_serde_utils::hex_vec") + serde(with = "serde_utils::hex_vec") )] pub extra_data: Vec, pub mix_hash: H256, pub nonce: H64, #[cfg_attr( all(feature = "eth2", not(target_arch = "wasm32")), - serde(deserialize_with = "u64_hex_be_option") + serde(with = "u64_hex_be_option") )] pub base_fee_per_gas: Option, pub withdrawals_root: Option, + #[cfg_attr( + all(feature = "eth2", not(target_arch = "wasm32")), + serde(with = "u64_hex_be_option"), + serde(default) + )] + pub blob_gas_used: Option, + #[cfg_attr( + all(feature = "eth2", not(target_arch = "wasm32")), + serde(with = "u64_hex_be_option"), + serde(default) + )] + pub excess_blob_gas: Option, + #[cfg_attr(all(feature = "eth2", not(target_arch = "wasm32")), serde(default))] + pub parent_beacon_block_root: Option, pub hash: Option, pub partial_hash: Option, } - #[cfg(all(feature = "eth2", not(target_arch = "wasm32")))] -fn u64_hex_be_option<'de, D>(deserializer: D) -> Result, D::Error> -where - D: serde::Deserializer<'de>, -{ - Ok(Some(eth2_serde_utils::u64_hex_be::deserialize( - deserializer, - )?)) +pub mod u64_hex_be_option { + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: serde::Deserializer<'de>, + { + Ok(Some(serde_utils::u64_hex_be::deserialize(deserializer)?)) + } + + pub fn serialize(num: &Option, serializer: S) -> Result + where + S: serde::Serializer, + { + if let Some(num) = num { + serde_utils::u64_hex_be::serialize(num, serializer) + } else { + serializer.serialize_none() + } + } } impl BlockHeader { @@ -192,6 +216,15 @@ impl BlockHeader { if self.withdrawals_root.is_some() { list_size += 1; } + if self.blob_gas_used.is_some() { + list_size += 1; + } + if self.excess_blob_gas.is_some() { + list_size += 1; + } + if self.parent_beacon_block_root.is_some() { + list_size += 1; + } stream.begin_list(list_size); @@ -221,6 +254,18 @@ impl BlockHeader { if let Some(withdrawals_root) = &self.withdrawals_root { stream.append(withdrawals_root); } + + if let Some(blob_gas_used) = &self.blob_gas_used { + stream.append(blob_gas_used); + } + + if let Some(excess_blob_gas) = &self.excess_blob_gas { + stream.append(excess_blob_gas); + } + + if let Some(parent_beacon_block_root) = &self.parent_beacon_block_root { + stream.append(parent_beacon_block_root); + } } pub fn calculate_hash(&self) -> H256 { @@ -259,6 +304,9 @@ impl RlpDecodable for BlockHeader { nonce: serialized.val_at(14)?, base_fee_per_gas: serialized.val_at(15).ok(), withdrawals_root: serialized.val_at(16).ok(), + blob_gas_used: serialized.val_at(17).ok(), + excess_blob_gas: serialized.val_at(18).ok(), + parent_beacon_block_root: serialized.val_at(19).ok(), hash: None, partial_hash: None, }; diff --git a/contracts/near/eth-types/src/macros.rs b/contracts/near/eth-types/src/macros.rs index a885c60c..01be99e1 100644 --- a/contracts/near/eth-types/src/macros.rs +++ b/contracts/near/eth-types/src/macros.rs @@ -80,7 +80,10 @@ macro_rules! arr_wrapper_impl_tree_hash_and_borsh { #[cfg(not(target_arch = "wasm32"))] impl Serialize for $name { - fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> + fn serialize( + &self, + serializer: S, + ) -> Result<::Ok, ::Error> where S: Serializer, { diff --git a/contracts/near/eth2-client/Cargo.toml b/contracts/near/eth2-client/Cargo.toml index 30713547..6ad619bb 100644 --- a/contracts/near/eth2-client/Cargo.toml +++ b/contracts/near/eth2-client/Cargo.toml @@ -8,19 +8,20 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -ethereum-types = { version = "0.14.1", features = ["rlp", "serialize"], default-features = false } eth-types = { path = "../eth-types" } eth2-utility = { path = "../eth2-utility" } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -merkle_proof = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -bls = { git = "https://github.com/aurora-is-near/lighthouse.git", optional = true, tag = "v3.5.1-wasm", default-features = false, features = ["milagro"]} -near-sdk = "4.1.1" -borsh = "0.9.3" -bitvec = "1.0.0" -near-plugins = { git = "https://github.com/aurora-is-near/near-plugins", tag = "v0.1.0" } +bls = { git = "https://github.com/aurora-is-near/lighthouse.git", optional = true, tag = "v4.6.0-wasm", default-features = false, features = ["milagro"]} +ethereum-types.workspace = true +tree_hash.workspace = true +near-sdk.workspace = true +borsh.workspace = true +bitvec.workspace = true +near-plugins.workspace = true [dev-dependencies] +ethereum_serde_utils.workspace = true lazy_static = "1.4.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" hex = "0.4.0" workspaces = "0.7" diff --git a/contracts/near/eth2-client/src/lib.rs b/contracts/near/eth2-client/src/lib.rs index d9a05fea..15c2ac00 100644 --- a/contracts/near/eth2-client/src/lib.rs +++ b/contracts/near/eth2-client/src/lib.rs @@ -449,23 +449,25 @@ impl Eth2Client { // Verify that the `finality_branch`, confirms `finalized_header` // to match the finalized checkpoint root saved in the state of `attested_header`. - let branch = convert_branch(&update.finality_update.finality_branch); require!( - merkle_proof::verify_merkle_proof( - update - .finality_update - .header_update - .beacon_header - .tree_hash_root(), - &branch, + verify_merkle_proof( + H256( + update + .finality_update + .header_update + .beacon_header + .tree_hash_root() + ), + &update.finality_update.finality_branch, FINALITY_TREE_DEPTH.try_into().unwrap(), FINALITY_TREE_INDEX.try_into().unwrap(), - update.attested_beacon_header.state_root.0 + update.attested_beacon_header.state_root ), "Invalid finality proof" ); + let config = NetworkConfig::new(&self.network); require!( - validate_beacon_block_header_update(&update.finality_update.header_update), + config.validate_beacon_block_header_update(&update.finality_update.header_update), "Invalid execution block hash proof" ); @@ -476,14 +478,13 @@ impl Eth2Client { .sync_committee_update .as_ref() .unwrap_or_else(|| env::panic_str("The sync committee update is missed")); - let branch = convert_branch(&sync_committee_update.next_sync_committee_branch); require!( - merkle_proof::verify_merkle_proof( - sync_committee_update.next_sync_committee.tree_hash_root(), - &branch, + verify_merkle_proof( + H256(sync_committee_update.next_sync_committee.tree_hash_root()), + &sync_committee_update.next_sync_committee_branch, SYNC_COMMITTEE_TREE_DEPTH.try_into().unwrap(), SYNC_COMMITTEE_TREE_INDEX.try_into().unwrap(), - update.attested_beacon_header.state_root.0 + update.attested_beacon_header.state_root ), "Invalid next sync committee proof" ); diff --git a/contracts/near/eth2-client/src/tests/integration_tests.rs b/contracts/near/eth2-client/src/tests/integration_tests.rs index f85a2d36..f0121535 100644 --- a/contracts/near/eth2-client/src/tests/integration_tests.rs +++ b/contracts/near/eth2-client/src/tests/integration_tests.rs @@ -4,19 +4,54 @@ mod integration_tests { use borsh::{BorshDeserialize, BorshSerialize}; use eth2_utility::types::InitInput; use eth_types::eth2::{ExtendedBeaconBlockHeader, SyncCommittee}; - use eth_types::H256; + use eth_types::{Address, Bloom, H256, H64, U256}; use near_sdk::ONE_NEAR; use near_units::*; + use serde::{Deserialize, Serialize}; use workspaces::operations::Function; use workspaces::{Account, Contract}; const WASM_FILEPATH: &str = "../target/wasm32-unknown-unknown/release/eth2_client.wasm"; const WASM_V_0_1_0_FILEPATH: &str = "src/data/eth2_client_v0.1.0_testnet.wasm"; + #[derive(Debug, Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize)] + pub struct BlockHeaderV1 { + pub parent_hash: H256, + pub uncles_hash: H256, + pub author: Address, + pub state_root: H256, + pub transactions_root: H256, + pub receipts_root: H256, + pub log_bloom: Bloom, + pub difficulty: U256, + #[serde(with = "serde_utils::u64_hex_be")] + pub number: u64, + pub gas_limit: U256, + pub gas_used: U256, + #[serde(with = "serde_utils::u64_hex_be")] + pub timestamp: u64, + #[serde(with = "serde_utils::hex_vec")] + pub extra_data: Vec, + pub mix_hash: H256, + pub nonce: H64, + #[serde(with = "eth_types::u64_hex_be_option")] + pub base_fee_per_gas: Option, + pub withdrawals_root: Option, + + pub hash: Option, + pub partial_hash: Option, + } + + impl From for BlockHeaderV1 { + fn from(item: eth_types::BlockHeader) -> Self { + serde_json::from_str(&serde_json::to_string(&item).unwrap()).unwrap() + } + } + #[derive(Clone, BorshDeserialize, BorshSerialize)] pub struct InitInputV1 { pub network: String, - pub finalized_execution_header: eth_types::BlockHeader, + pub finalized_execution_header: BlockHeaderV1, pub finalized_beacon_header: ExtendedBeaconBlockHeader, pub current_sync_committee: SyncCommittee, pub next_sync_committee: SyncCommittee, @@ -31,7 +66,7 @@ mod integration_tests { fn from(message: InitInput) -> Self { Self { network: message.network, - finalized_execution_header: message.finalized_execution_header, + finalized_execution_header: message.finalized_execution_header.into(), finalized_beacon_header: message.finalized_beacon_header, current_sync_committee: message.current_sync_committee, next_sync_committee: message.next_sync_committee, @@ -148,9 +183,10 @@ mod integration_tests { for headers_chunk in headers.chunks(50) { let mut transaction = alice.batch(contract.id()); for header in headers_chunk { + let header_v1: BlockHeaderV1 = header.clone().into(); transaction = transaction.call( Function::new("submit_execution_header") - .args(header.try_to_vec()?) + .args(header_v1.try_to_vec()?) .gas(parse_gas!("6 T") as u64), ); } diff --git a/contracts/near/eth2-client/src/tests/unit_tests.rs b/contracts/near/eth2-client/src/tests/unit_tests.rs index 61104dca..92d979b3 100644 --- a/contracts/near/eth2-client/src/tests/unit_tests.rs +++ b/contracts/near/eth2-client/src/tests/unit_tests.rs @@ -71,14 +71,14 @@ mod tests { #[cfg(not(feature = "mainnet"))] mod generic_tests { use super::*; - use bitvec::order::Lsb0; use bitvec::bitarr; - use near_sdk::test_utils::accounts; + use bitvec::order::Lsb0; use eth2_utility::consensus::*; use eth_types::{H256, U256}; + use hex::FromHex; use near_plugins::Pausable; + use near_sdk::test_utils::accounts; use tree_hash::TreeHash; - use hex::FromHex; #[test] pub fn test_header_root() { diff --git a/contracts/near/eth2-utility/Cargo.toml b/contracts/near/eth2-utility/Cargo.toml index 4837d72a..e7c11f36 100644 --- a/contracts/near/eth2-utility/Cargo.toml +++ b/contracts/near/eth2-utility/Cargo.toml @@ -8,13 +8,13 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -ethereum-types = { version = "0.14.1", features = ["rlp", "serialize"], default-features = false } eth-types = { path = "../eth-types" } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -merkle_proof = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -near-sdk = "4.1.1" -borsh = "0.9.3" -bitvec = "1.0.0" +ethereum-types.workspace = true +tree_hash.workspace = true +ethereum_hashing.workspace = true +near-sdk.workspace = true +borsh.workspace = true +bitvec.workspace = true [dev-dependencies] lazy_static = "1.4.0" diff --git a/contracts/near/eth2-utility/src/consensus.rs b/contracts/near/eth2-utility/src/consensus.rs index 4174d9b8..a8878e76 100644 --- a/contracts/near/eth2-utility/src/consensus.rs +++ b/contracts/near/eth2-utility/src/consensus.rs @@ -19,18 +19,20 @@ pub const FINALITY_TREE_INDEX: u32 = get_subtree_index(FINALIZED_ROOT_INDEX); pub const SYNC_COMMITTEE_TREE_DEPTH: u32 = floorlog2(NEXT_SYNC_COMMITTEE_INDEX); pub const SYNC_COMMITTEE_TREE_INDEX: u32 = get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX); -pub const BEACON_BLOCK_BODY_TREE_DEPTH: usize = 4; -pub const L1_BEACON_BLOCK_BODY_TREE_EXECUTION_PAYLOAD_INDEX: usize = 9; -pub const L2_EXECUTION_PAYLOAD_TREE_EXECUTION_BLOCK_INDEX: usize = 12; -pub const L1_BEACON_BLOCK_BODY_PROOF_SIZE: usize = 4; -pub const L2_EXECUTION_PAYLOAD_PROOF_SIZE: usize = 4; -pub const EXECUTION_PROOF_SIZE: usize = - L1_BEACON_BLOCK_BODY_PROOF_SIZE + L2_EXECUTION_PAYLOAD_PROOF_SIZE; +pub struct ProofSize { + pub beacon_block_body_tree_depth: usize, + pub l1_beacon_block_body_tree_execution_payload_index: usize, + pub l2_execution_payload_tree_execution_block_index: usize, + pub l1_beacon_block_body_proof_size: usize, + pub l2_execution_payload_proof_size: usize, + pub execution_proof_size: usize, +} #[derive(PartialEq, BorshSerialize, BorshDeserialize)] pub enum Network { Mainnet, Goerli, + Sepolia, } impl FromStr for Network { @@ -39,6 +41,7 @@ impl FromStr for Network { match input { "mainnet" => Ok(Network::Mainnet), "goerli" => Ok(Network::Goerli), + "sepolia" => Ok(Network::Sepolia), _ => Err(format!("Unknown network {}", input)), } } @@ -50,6 +53,8 @@ pub struct NetworkConfig { pub bellatrix_fork_epoch: u64, pub capella_fork_version: ForkVersion, pub capella_fork_epoch: u64, + pub deneb_fork_version: ForkVersion, + pub deneb_fork_epoch: u64, } impl NetworkConfig { @@ -65,6 +70,8 @@ impl NetworkConfig { bellatrix_fork_epoch: 144896, capella_fork_version: [0x03, 0x00, 0x00, 0x00], capella_fork_epoch: 194048, + deneb_fork_version: [0x04, 0x00, 0x00, 0x00], + deneb_fork_epoch: 269568, }, Network::Goerli => Self { genesis_validators_root: [ @@ -76,11 +83,30 @@ impl NetworkConfig { bellatrix_fork_epoch: 112260, capella_fork_version: [0x03, 0x00, 0x10, 0x20], capella_fork_epoch: 162304, + deneb_fork_version: [0x04, 0x00, 0x10, 0x20], + deneb_fork_epoch: 231680, + }, + Network::Sepolia => Self { + genesis_validators_root: [ + 0xd8, 0xea, 0x17, 0x1f, 0x3c, 0x94, 0xae, 0xa2, 0x1e, 0xbc, 0x42, 0xa1, 0xed, + 0x61, 0x05, 0x2a, 0xcf, 0x3f, 0x92, 0x09, 0xc0, 0x0e, 0x4e, 0xfb, 0xaa, 0xdd, + 0xac, 0x09, 0xed, 0x9b, 0x80, 0x78, + ], + bellatrix_fork_version: [0x90, 0x00, 0x00, 0x71], + bellatrix_fork_epoch: 100, + capella_fork_version: [0x90, 0x00, 0x00, 0x72], + capella_fork_epoch: 56832, + deneb_fork_version: [0x90, 0x00, 0x00, 0x73], + deneb_fork_epoch: 132608, }, } } pub fn compute_fork_version(&self, epoch: Epoch) -> Option { + if epoch >= self.deneb_fork_epoch { + return Some(self.deneb_fork_version); + } + if epoch >= self.capella_fork_epoch { return Some(self.capella_fork_version); } @@ -95,6 +121,57 @@ impl NetworkConfig { pub fn compute_fork_version_by_slot(&self, slot: Slot) -> Option { self.compute_fork_version(compute_epoch_at_slot(slot)) } + + pub fn compute_proof_size(&self, epoch: Epoch) -> ProofSize { + if epoch >= self.deneb_fork_epoch { + return ProofSize { + beacon_block_body_tree_depth: 4, + l1_beacon_block_body_tree_execution_payload_index: 9, + l2_execution_payload_tree_execution_block_index: 12, + l1_beacon_block_body_proof_size: 4, + l2_execution_payload_proof_size: 5, + execution_proof_size: 9, + }; + } + + ProofSize { + beacon_block_body_tree_depth: 4, + l1_beacon_block_body_tree_execution_payload_index: 9, + l2_execution_payload_tree_execution_block_index: 12, + l1_beacon_block_body_proof_size: 4, + l2_execution_payload_proof_size: 4, + execution_proof_size: 8, + } + } + + pub fn compute_proof_size_by_slot(&self, slot: Slot) -> ProofSize { + self.compute_proof_size(compute_epoch_at_slot(slot)) + } + + pub fn validate_beacon_block_header_update(&self, header_update: &HeaderUpdate) -> bool { + let branch = &header_update.execution_hash_branch; + let proof_size = self.compute_proof_size_by_slot(header_update.beacon_header.slot); + if branch.len() != proof_size.execution_proof_size { + return false; + } + + let l2_proof = &branch[0..proof_size.l2_execution_payload_proof_size]; + let l1_proof = + &branch[proof_size.l2_execution_payload_proof_size..proof_size.execution_proof_size]; + let execution_payload_hash = merkle_root_from_branch( + header_update.execution_block_hash, + l2_proof, + proof_size.l2_execution_payload_proof_size, + proof_size.l2_execution_payload_tree_execution_block_index, + ); + verify_merkle_proof( + execution_payload_hash, + l1_proof, + proof_size.beacon_block_body_tree_depth, + proof_size.l1_beacon_block_body_tree_execution_payload_index, + header_update.beacon_header.body_root, + ) + } } pub const fn compute_epoch_at_slot(slot: Slot) -> u64 { @@ -163,29 +240,41 @@ pub fn get_participant_pubkeys( result } -pub fn convert_branch(branch: &[H256]) -> Vec { - branch.iter().map(|x| x.0).collect() +/// Verify a proof that `leaf` exists at `index` in a Merkle tree rooted at `root`. +/// +/// The `branch` argument is the main component of the proof: it should be a list of internal +/// node hashes such that the root can be reconstructed (in bottom-up order). +pub fn verify_merkle_proof( + leaf: H256, + branch: &[H256], + depth: usize, + index: usize, + root: H256, +) -> bool { + if branch.len() == depth { + merkle_root_from_branch(leaf, branch, depth, index) == root + } else { + false + } } -pub fn validate_beacon_block_header_update(header_update: &HeaderUpdate) -> bool { - let branch = convert_branch(&header_update.execution_hash_branch); - if branch.len() != EXECUTION_PROOF_SIZE { - return false; +/// Compute a root hash from a leaf and a Merkle proof. +pub fn merkle_root_from_branch(leaf: H256, branch: &[H256], depth: usize, index: usize) -> H256 { + assert_eq!(branch.len(), depth, "proof length should equal depth"); + + let mut merkle_root = leaf.0.as_bytes().to_vec(); + + for (i, leaf) in branch.iter().enumerate().take(depth) { + let ith_bit = (index >> i) & 0x01; + if ith_bit == 1 { + merkle_root = + ethereum_hashing::hash32_concat(leaf.0.as_bytes(), &merkle_root)[..].to_vec(); + } else { + let mut input = merkle_root; + input.extend_from_slice(leaf.0.as_bytes()); + merkle_root = ethereum_hashing::hash(&input); + } } - let l2_proof = &branch[0..L2_EXECUTION_PAYLOAD_PROOF_SIZE]; - let l1_proof = &branch[L2_EXECUTION_PAYLOAD_PROOF_SIZE..EXECUTION_PROOF_SIZE]; - let execution_payload_hash = merkle_proof::merkle_root_from_branch( - header_update.execution_block_hash.0, - l2_proof, - L2_EXECUTION_PAYLOAD_PROOF_SIZE, - L2_EXECUTION_PAYLOAD_TREE_EXECUTION_BLOCK_INDEX, - ); - merkle_proof::verify_merkle_proof( - execution_payload_hash, - l1_proof, - BEACON_BLOCK_BODY_TREE_DEPTH, - L1_BEACON_BLOCK_BODY_TREE_EXECUTION_PAYLOAD_INDEX, - header_update.beacon_header.body_root.0, - ) + H256(ethereum_types::H256::from_slice(&merkle_root)) } diff --git a/contracts/near/eth2_hashing/Cargo.toml b/contracts/near/eth2_hashing/Cargo.toml index 7fad833e..7e7c42e0 100644 --- a/contracts/near/eth2_hashing/Cargo.toml +++ b/contracts/near/eth2_hashing/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "eth2_hashing" -version = "0.3.0" +name = "ethereum_hashing" +version = "1.0.0-beta.2" authors = ["Aurora "] edition = "2021" license = "Apache-2.0" -description = "Reimplemented eth2_hashing using near-sdk, for usage in NEAR WASM contracts" +description = "Reimplemented ethereum_hashing using near-sdk, for usage in NEAR WASM contracts" [dependencies] lazy_static = { version = "1.4.0", optional = true } -near-sdk = "4.1.1" +near-sdk.workspace = true [dev-dependencies] rustc-hex = "2.1.0" diff --git a/contracts/near/res/eth2_client.wasm b/contracts/near/res/eth2_client.wasm index 9ab774fe..14017b52 100755 Binary files a/contracts/near/res/eth2_client.wasm and b/contracts/near/res/eth2_client.wasm differ diff --git a/contracts/near/res/eth_client.wasm b/contracts/near/res/eth_client.wasm index e78ba93a..425eb9b2 100755 Binary files a/contracts/near/res/eth_client.wasm and b/contracts/near/res/eth_client.wasm differ diff --git a/contracts/near/res/eth_prover.wasm b/contracts/near/res/eth_prover.wasm index 34613509..bcd87a96 100755 Binary files a/contracts/near/res/eth_prover.wasm and b/contracts/near/res/eth_prover.wasm differ diff --git a/eth2near/Cargo.lock b/eth2near/Cargo.lock index fcdf17c8..8f571524 100644 --- a/eth2near/Cargo.lock +++ b/eth2near/Cargo.lock @@ -16,7 +16,7 @@ checksum = "f728064aca1c318585bf4bb04ffcfac9e75e508ab4e8b1bd9ba5dfe04e2cbed5" dependencies = [ "actix-rt", "actix_derive", - "bitflags", + "bitflags 1.3.2", "bytes 1.4.0", "crossbeam-channel", "futures-core", @@ -50,7 +50,7 @@ checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -268,7 +268,7 @@ checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -285,7 +285,7 @@ checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -373,12 +373,41 @@ dependencies = [ "zip", ] +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.4.1", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.48", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "bitvec" version = "0.20.4" @@ -460,32 +489,30 @@ dependencies = [ [[package]] name = "bls" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ "arbitrary", "blst", - "eth2_hashing", - "eth2_serde_utils", - "eth2_ssz", "ethereum-types", + "ethereum_hashing", + "ethereum_serde_utils", + "ethereum_ssz", "hex 0.4.3", - "rand 0.7.3", + "rand 0.8.5", "serde", - "serde_derive", "tree_hash", "zeroize", ] [[package]] name = "blst" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a30d0edd9dd1c60ddb42b80341c7852f6f985279a5c1a83659dcb65899dec99" +checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" dependencies = [ "cc", "glob", "threadpool", - "which", "zeroize", ] @@ -509,7 +536,7 @@ dependencies = [ "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", - "syn", + "syn 1.0.109", ] [[package]] @@ -520,7 +547,7 @@ checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -531,7 +558,7 @@ checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -610,6 +637,20 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "c-kzg" +version = "0.1.0" +source = "git+https://github.com/ethereum/c-kzg-4844?rev=748283cced543c486145d5f3f38684becdfe3e1b#748283cced543c486145d5f3f38684becdfe3e1b" +dependencies = [ + "bindgen", + "blst", + "cc", + "glob", + "hex 0.4.3", + "libc", + "serde", +] + [[package]] name = "c2-chacha" version = "0.3.3" @@ -623,14 +664,14 @@ dependencies = [ [[package]] name = "cached_tree_hash" version = "0.1.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ - "eth2_hashing", - "eth2_ssz", - "eth2_ssz_derive", - "eth2_ssz_types", "ethereum-types", + "ethereum_hashing", + "ethereum_ssz", + "ethereum_ssz_derive", "smallvec", + "ssz_types", "tree_hash", ] @@ -640,6 +681,15 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -677,6 +727,17 @@ dependencies = [ "generic-array", ] +[[package]] +name = "clang-sys" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "3.2.23" @@ -684,7 +745,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", "indexmap", @@ -704,7 +765,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -729,15 +790,18 @@ dependencies = [ [[package]] name = "compare_fields" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" +dependencies = [ + "itertools", +] [[package]] name = "compare_fields_derive" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -894,7 +958,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -964,7 +1028,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.109", ] [[package]] @@ -981,7 +1045,7 @@ checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1005,7 +1069,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.109", ] [[package]] @@ -1016,7 +1080,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1027,7 +1091,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1038,7 +1102,7 @@ checksum = "f3cdeb9ec472d588e539a818b2dee436825730da08ad0017c4b1a17676bdc8b7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1051,7 +1115,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", ] [[package]] @@ -1183,7 +1247,7 @@ checksum = "2a4da76b3b6116d758c7ba93f7ec6a35d2e2cf24feda76c6e38a375f4d5c59f2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1199,6 +1263,15 @@ dependencies = [ "termcolor", ] +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + [[package]] name = "errno" version = "0.2.8" @@ -1226,10 +1299,10 @@ version = "0.1.0" dependencies = [ "borsh", "derive_more", - "eth2_serde_utils", - "eth2_ssz", - "eth2_ssz_derive", "ethereum-types", + "ethereum_serde_utils", + "ethereum_ssz", + "ethereum_ssz_derive", "hex 0.4.3", "near-sdk", "rlp", @@ -1254,7 +1327,6 @@ dependencies = [ "eth2near-logger", "eth_rpc_client", "log", - "merkle_proof", "near-primitives 0.16.0", "near-sdk", "reqwest", @@ -1275,84 +1347,23 @@ dependencies = [ "borsh", "eth-types", "ethereum-types", - "merkle_proof", + "ethereum_hashing", "near-sdk", "tree_hash", ] -[[package]] -name = "eth2_hashing" -version = "0.3.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "cpufeatures", - "lazy_static", - "ring", - "sha2 0.10.6", -] - [[package]] name = "eth2_interop_keypairs" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ "bls", - "eth2_hashing", + "ethereum_hashing", "hex 0.4.3", "lazy_static", "num-bigint 0.4.3", "serde", - "serde_derive", - "serde_yaml 0.8.26", -] - -[[package]] -name = "eth2_serde_utils" -version = "0.1.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "ethereum-types", - "hex 0.4.3", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "eth2_ssz" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "ethereum-types", - "itertools", - "smallvec", -] - -[[package]] -name = "eth2_ssz_derive" -version = "0.3.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "eth2_ssz_types" -version = "0.2.2" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" -dependencies = [ - "arbitrary", - "derivative", - "eth2_serde_utils", - "eth2_ssz", - "serde", - "serde_derive", - "smallvec", - "tree_hash", - "typenum", + "serde_yaml", ] [[package]] @@ -1370,11 +1381,11 @@ dependencies = [ "eth-types", "eth2-contract-init", "eth2-utility", - "eth2_hashing", - "eth2_ssz", "eth2near-logger", "eth_rpc_client", "ethereum-types", + "ethereum_hashing", + "ethereum_ssz", "finality-update-verify", "futures", "hex 0.4.3", @@ -1392,6 +1403,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "smallvec", "tokio 1.19.2", "toml", "tree_hash", @@ -1421,9 +1433,10 @@ dependencies = [ "dotenv", "env_logger", "eth-types", - "eth2_hashing", - "eth2_ssz", + "eth2-utility", "ethereum-types", + "ethereum_hashing", + "ethereum_ssz", "finality-update-verify", "futures", "hex 0.4.3", @@ -1468,6 +1481,54 @@ dependencies = [ "uint", ] +[[package]] +name = "ethereum_hashing" +version = "1.0.0-beta.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233dc6f434ce680dbabf4451ee3380cec46cb3c45d66660445a435619710dd35" +dependencies = [ + "cpufeatures", + "lazy_static", + "ring", + "sha2 0.10.6", +] + +[[package]] +name = "ethereum_serde_utils" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de4d5951468846963c24e8744c133d44f39dff2cd3a233f6be22b370d08a524f" +dependencies = [ + "ethereum-types", + "hex 0.4.3", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "ethereum_ssz" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e61ffea29f26e8249d35128a82ec8d3bd4fbc80179ea5f5e5e3daafef6a80fcb" +dependencies = [ + "ethereum-types", + "itertools", + "smallvec", +] + +[[package]] +name = "ethereum_ssz_derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6085d7fd3cf84bd2b8fec150d54c8467fb491d8db9c460607c5534f653a0ee38" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -1492,7 +1553,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -1632,7 +1693,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fuchsia-zircon-sys", ] @@ -1725,7 +1786,7 @@ checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1887,7 +1948,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ "base64 0.13.1", - "bitflags", + "bitflags 1.3.2", "bytes 1.4.0", "headers-core", "http", @@ -2175,7 +2236,7 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2209,7 +2270,7 @@ dependencies = [ [[package]] name = "int_to_bytes" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ "bytes 1.4.0", ] @@ -2312,6 +2373,23 @@ dependencies = [ "log", ] +[[package]] +name = "kzg" +version = "0.1.0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" +dependencies = [ + "arbitrary", + "c-kzg", + "derivative", + "ethereum_hashing", + "ethereum_serde_utils", + "ethereum_ssz", + "ethereum_ssz_derive", + "hex 0.4.3", + "serde", + "tree_hash", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -2321,6 +2399,12 @@ dependencies = [ "spin", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.140" @@ -2347,6 +2431,16 @@ dependencies = [ "rle-decode-fast", ] +[[package]] +name = "libloading" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +dependencies = [ + "cfg-if 1.0.0", + "windows-sys 0.48.0", +] + [[package]] name = "libsqlite3-sys" version = "0.25.2" @@ -2379,12 +2473,6 @@ dependencies = [ "cc", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -2451,10 +2539,10 @@ checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" [[package]] name = "merkle_proof" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ - "eth2_hashing", "ethereum-types", + "ethereum_hashing", "lazy_static", "safe_arith", ] @@ -2479,7 +2567,7 @@ dependencies = [ "proc-macro2", "quote", "smallvec", - "syn", + "syn 1.0.109", ] [[package]] @@ -2498,6 +2586,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.6.2" @@ -2946,7 +3040,7 @@ dependencies = [ "reed-solomon-erasure", "serde", "serde_json", - "serde_yaml 0.9.19", + "serde_yaml", "smart-default", "strum", "thiserror", @@ -3017,7 +3111,7 @@ checksum = "93ee0b41c75ef859c193a8ff1dadfa0c8207bc0ac447cc22259721ad769a1408" dependencies = [ "quote", "serde", - "syn", + "syn 1.0.109", ] [[package]] @@ -3028,7 +3122,7 @@ checksum = "36addf90cc04bd547a627b3a292f59d7de4dd6fb5042115419ae901b93ce6c2d" dependencies = [ "quote", "serde", - "syn", + "syn 1.0.109", ] [[package]] @@ -3039,7 +3133,7 @@ checksum = "d7c867980c023741a39509a58fffe3f700f18de7600b08be54299c2fc4abc52c" dependencies = [ "quote", "serde", - "syn", + "syn 1.0.109", ] [[package]] @@ -3050,7 +3144,7 @@ checksum = "8e837bd4bacd807073ec5ceb85708da7f721b46a4c2a978de86027fb0034ce31" dependencies = [ "near-rpc-error-core 0.14.0", "serde", - "syn", + "syn 1.0.109", ] [[package]] @@ -3061,7 +3155,7 @@ checksum = "0b5beb352f3b91d8c491646c2fa4fdbbbf463c7b9c0226951c28f0197de44f99" dependencies = [ "near-rpc-error-core 0.15.0", "serde", - "syn", + "syn 1.0.109", ] [[package]] @@ -3073,7 +3167,7 @@ dependencies = [ "fs2", "near-rpc-error-core 0.16.0", "serde", - "syn", + "syn 1.0.109", ] [[package]] @@ -3123,7 +3217,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3210,6 +3304,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -3311,7 +3415,7 @@ version = "0.10.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd2523381e46256e40930512c7fd25562b9eae4812cb52078f155e87217c9d1e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "foreign-types", "libc", @@ -3328,7 +3432,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3447,7 +3551,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3459,7 +3563,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3503,6 +3607,12 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.2.0" @@ -3545,7 +3655,7 @@ checksum = "851c8d0ce9bebe43790dedfc86614c23494ac9f423dd618d3a61fc693eafe61e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3556,7 +3666,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3590,7 +3700,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e1f879b2998099c2d69ab9605d145d5b661195627eccc680002c4918a7fb6fa" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "concurrent-queue", "libc", @@ -3614,6 +3724,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +dependencies = [ + "proc-macro2", + "syn 2.0.48", +] + [[package]] name = "primitive-types" version = "0.10.1" @@ -3666,7 +3786,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -3683,9 +3803,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -3696,7 +3816,7 @@ version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c434e93ef69c216e68e4f417c927b4f31502c3560b72cfdb6827e2321c5c6b3e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "hex 0.4.3", "lazy_static", @@ -3775,7 +3895,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3802,9 +3922,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.26" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -3935,7 +4055,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -4080,7 +4200,7 @@ checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4089,7 +4209,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -4115,6 +4235,12 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -4136,7 +4262,7 @@ version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -4159,7 +4285,7 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safe_arith" version = "0.1.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" [[package]] name = "safemem" @@ -4197,7 +4323,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 1.0.109", ] [[package]] @@ -4243,7 +4369,7 @@ version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -4268,9 +4394,9 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.156" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] @@ -4286,13 +4412,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.156" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -4303,7 +4429,7 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4325,7 +4451,7 @@ checksum = "395627de918015623b32e7669714206363a7fc00382bf477e72c1f7533e8eafc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4352,40 +4478,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" -dependencies = [ - "serde", - "serde_with_macros", -] - -[[package]] -name = "serde_with_macros" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_yaml" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" -dependencies = [ - "indexmap", - "ryu", - "serde", - "yaml-rust", -] - [[package]] name = "serde_yaml" version = "0.9.19" @@ -4466,6 +4558,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + [[package]] name = "signal-hook" version = "0.3.15" @@ -4511,12 +4609,15 @@ name = "slog" version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" +dependencies = [ + "erased-serde", +] [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smart-default" @@ -4526,7 +4627,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4556,6 +4657,24 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "ssz_types" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382939886cb24ee8ac885d09116a60f6262d827c7a9e36012b4f6d3d0116d0b3" +dependencies = [ + "arbitrary", + "derivative", + "ethereum_serde_utils", + "ethereum_ssz", + "itertools", + "serde", + "serde_derive", + "smallvec", + "tree_hash", + "typenum", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -4587,7 +4706,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] @@ -4607,16 +4726,16 @@ dependencies = [ "proc-macro2", "quote", "smallvec", - "syn", + "syn 1.0.109", ] [[package]] name = "swap_or_not_shuffle" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ - "eth2_hashing", "ethereum-types", + "ethereum_hashing", ] [[package]] @@ -4630,6 +4749,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -4638,7 +4768,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] @@ -4684,10 +4814,10 @@ dependencies = [ [[package]] name = "test_random_derive" version = "0.2.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4713,7 +4843,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4852,7 +4982,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -5008,7 +5138,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -5075,7 +5205,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -5143,22 +5273,24 @@ dependencies = [ [[package]] name = "tree_hash" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c998ac5fe2b07c025444bdd522e6258110b63861c6698eedc610c071980238d" dependencies = [ - "eth2_hashing", "ethereum-types", + "ethereum_hashing", "smallvec", ] [[package]] name = "tree_hash_derive" -version = "0.4.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84303a9c7cda5f085a3ed9cd241d1e95e04d88aab1d679b02f212e653537ba86" dependencies = [ "darling", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -5204,7 +5336,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "types" version = "0.2.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?tag=v3.5.1-wasm#ce4e2b44630f5ddc04eda933eaa69c33d582c3f0" +source = "git+https://github.com/sigp/lighthouse.git?tag=v4.6.0-rc.0#2e8e1606796cc8392edcb277b698f06ea130d4f1" dependencies = [ "arbitrary", "bls", @@ -5212,16 +5344,16 @@ dependencies = [ "compare_fields", "compare_fields_derive", "derivative", - "eth2_hashing", "eth2_interop_keypairs", - "eth2_serde_utils", - "eth2_ssz", - "eth2_ssz_derive", - "eth2_ssz_types", "ethereum-types", + "ethereum_hashing", + "ethereum_serde_utils", + "ethereum_ssz", + "ethereum_ssz_derive", "hex 0.4.3", "int_to_bytes", "itertools", + "kzg", "lazy_static", "log", "maplit", @@ -5235,12 +5367,12 @@ dependencies = [ "rusqlite", "safe_arith", "serde", - "serde_derive", "serde_json", - "serde_with", - "serde_yaml 0.8.26", + "serde_yaml", "slog", "smallvec", + "ssz_types", + "strum", "superstruct", "swap_or_not_shuffle", "tempfile", @@ -5466,7 +5598,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -5500,7 +5632,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5593,13 +5725,13 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -5608,7 +5740,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -5617,13 +5758,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -5632,42 +5788,84 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "winnow" version = "0.3.6" @@ -5753,15 +5951,6 @@ dependencies = [ "libc", ] -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "zeroize" version = "1.5.7" @@ -5779,7 +5968,7 @@ checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] diff --git a/eth2near/Cargo.toml b/eth2near/Cargo.toml index be768805..c67c93f7 100644 --- a/eth2near/Cargo.toml +++ b/eth2near/Cargo.toml @@ -9,12 +9,12 @@ members = [ "logger", ] -[patch] -[patch.crates-io] -eth2_ssz = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_ssz_types = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_hashing = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm"} -tree_hash_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm"} -eth2_serde_utils = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_ssz_derive = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } \ No newline at end of file +[workspace.dependencies] +bls = { git = "https://github.com/sigp/lighthouse.git", tag = "v4.6.0-rc.0" } +types = { git = "https://github.com/sigp/lighthouse.git", tag = "v4.6.0-rc.0" } +merkle_proof = { git = "https://github.com/sigp/lighthouse.git", tag = "v4.6.0-rc.0" } +tree_hash = "0.5" +tree_hash_derive = "0.5" +ethereum_ssz = "0.5" +ethereum_hashing = "1.0.0-beta.2" +smallvec = "1.11.0" diff --git a/eth2near/contract_wrapper/src/eth_network.rs b/eth2near/contract_wrapper/src/eth_network.rs index 20518a4c..58a01897 100644 --- a/eth2near/contract_wrapper/src/eth_network.rs +++ b/eth2near/contract_wrapper/src/eth_network.rs @@ -10,6 +10,7 @@ pub enum EthNetwork { Kiln, Ropsten, Goerli, + Sepolia, } #[derive(Debug, Clone, Deserialize)] @@ -19,7 +20,7 @@ impl Display for IncorrectEthNetwork { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, - "Unknown Ethereum network. Possible networks: 'Mainnet', 'Kiln', 'Goerli', 'Ropsten'" + "Unknown Ethereum network. Possible networks: 'Mainnet', 'Kiln', 'Goerli', 'Ropsten', 'Sepolia'" ) } } @@ -39,6 +40,7 @@ impl EthNetwork { EthNetwork::Kiln => "kiln", EthNetwork::Goerli => "goerli", EthNetwork::Ropsten => "ropsten", + EthNetwork::Sepolia => "sepolia", } } } @@ -52,6 +54,7 @@ impl FromStr for EthNetwork { "kiln" => Ok(EthNetwork::Kiln), "goerli" => Ok(EthNetwork::Goerli), "ropsten" => Ok(EthNetwork::Ropsten), + "sepolia" => Ok(EthNetwork::Sepolia), _ => Err(IncorrectEthNetwork), } } diff --git a/eth2near/eth2-contract-init/Cargo.toml b/eth2near/eth2-contract-init/Cargo.toml index bdbd133f..f25cce18 100644 --- a/eth2near/eth2-contract-init/Cargo.toml +++ b/eth2near/eth2-contract-init/Cargo.toml @@ -4,10 +4,9 @@ version = "0.3.0" edition = "2021" [dependencies] -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -merkle_proof = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -types = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_to_near_relay = { path = "../eth2near-block-relay-rs" } +tree_hash = { workspace = true } +types = { workspace = true } +eth2_to_near_relay = { path = "../eth2near-block-relay-rs"} eth_rpc_client = { path = "../eth_rpc_client" } eth-types = { path = "../../contracts/near/eth-types/" } eth2-utility = { path = "../../contracts/near/eth2-utility" } diff --git a/eth2near/eth2-contract-init/src/init_contract.rs b/eth2near/eth2-contract-init/src/init_contract.rs index 44c66883..1f95bec4 100644 --- a/eth2near/eth2-contract-init/src/init_contract.rs +++ b/eth2near/eth2-contract-init/src/init_contract.rs @@ -30,15 +30,16 @@ pub fn verify_light_client_snapshot( return false; } - let branch = consensus::convert_branch(&light_client_snapshot.current_sync_committee_branch); - merkle_proof::verify_merkle_proof( - light_client_snapshot - .current_sync_committee - .tree_hash_root(), - &branch, + consensus::verify_merkle_proof( + eth_types::H256( + light_client_snapshot + .current_sync_committee + .tree_hash_root(), + ), + &light_client_snapshot.current_sync_committee_branch, CURRENT_SYNC_COMMITTEE_TREE_DEPTH.try_into().unwrap(), CURRENT_SYNC_COMMITTEE_TREE_INDEX.try_into().unwrap(), - light_client_snapshot.beacon_header.state_root.0, + light_client_snapshot.beacon_header.state_root, ) } @@ -64,10 +65,12 @@ pub fn init_contract( ); let eth1_rpc_client = Eth1RPCClient::new(&config.eth1_endpoint); - let last_period = BeaconRPCClient::get_period_for_slot(beacon_rpc_client - .get_last_slot_number() - .expect("Error on fetching last slot number") - .as_u64()); + let last_period = BeaconRPCClient::get_period_for_slot( + beacon_rpc_client + .get_last_slot_number() + .expect("Error on fetching last slot number") + .as_u64(), + ); let light_client_update_with_next_sync_committee = beacon_rpc_client .get_light_client_update(last_period) @@ -253,12 +256,6 @@ mod tests { let mut init_config = get_init_config(&config_for_test, ð_client_contract); init_config.beacon_rpc_version = BeaconRPCVersion::V1_5; - init_contract(&init_config, &mut eth_client_contract).unwrap(); - - let last_finalized_slot_eth_client = eth_client_contract - .get_finalized_beacon_block_slot() - .expect("Error on getting last finalized beacon block slot(Eth client)"); - let beacon_rpc_client = BeaconRPCClient::new( &init_config.beacon_endpoint, init_config.eth_requests_timeout_seconds.unwrap_or(10), @@ -270,8 +267,14 @@ mod tests { .get_last_finalized_slot_number() .expect("Error on getting last finalized beacon block slot"); - const MAX_GAP_IN_EPOCH_BETWEEN_FINALIZED_SLOTS: u64 = 3; + init_contract(&init_config, &mut eth_client_contract).unwrap(); + let last_finalized_slot_eth_client = eth_client_contract + .get_finalized_beacon_block_slot() + .expect("Error on getting last finalized beacon block slot(Eth client)"); + + const MAX_GAP_IN_EPOCH_BETWEEN_FINALIZED_SLOTS: u64 = 3; + assert!( last_finalized_slot_eth_client + ONE_EPOCH_IN_SLOTS * MAX_GAP_IN_EPOCH_BETWEEN_FINALIZED_SLOTS diff --git a/eth2near/eth2near-block-relay-rs/Cargo.toml b/eth2near/eth2near-block-relay-rs/Cargo.toml index 9503c93c..4e7d2484 100644 --- a/eth2near/eth2near-block-relay-rs/Cargo.toml +++ b/eth2near/eth2near-block-relay-rs/Cargo.toml @@ -4,11 +4,12 @@ version = "0.3.0" edition = "2021" [dependencies] -types = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -merkle_proof = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_hashing = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_ssz = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } +smallvec = "1" +types = { workspace = true } +tree_hash = { workspace = true } +merkle_proof = { workspace = true } +ethereum_hashing = { workspace = true } +ethereum_ssz = { workspace = true } eth-types = { path = "../../contracts/near/eth-types/" } eth2-utility = { path = "../../contracts/near/eth2-utility" } diff --git a/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs b/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs index a3c303cc..c7ddeb47 100644 --- a/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs +++ b/eth2near/eth2near-block-relay-rs/src/eth2near_relay.rs @@ -2,13 +2,14 @@ use crate::config::Config; use crate::prometheus_metrics; use crate::prometheus_metrics::{ CHAIN_FINALIZED_EXECUTION_BLOCK_HEIGHT_ON_ETH, CHAIN_FINALIZED_EXECUTION_BLOCK_HEIGHT_ON_NEAR, - FAILS_ON_HEADERS_SUBMISSION, FAILS_ON_UPDATES_SUBMISSION, - LAST_FINALIZED_ETH_SLOT, LAST_FINALIZED_ETH_SLOT_ON_NEAR, + FAILS_ON_HEADERS_SUBMISSION, FAILS_ON_UPDATES_SUBMISSION, LAST_FINALIZED_ETH_SLOT, + LAST_FINALIZED_ETH_SLOT_ON_NEAR, }; use bitvec::macros::internal::funty::Fundamental; use contract_wrapper::eth_client_contract_trait::EthClientContractTrait; use contract_wrapper::near_rpc_client::NearRPCClient; use eth2_utility::consensus::{EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH}; +use eth2_utility::types::ClientMode; use eth_rpc_client::beacon_rpc_client::BeaconRPCClient; use eth_rpc_client::eth1_rpc_client::Eth1RPCClient; use eth_rpc_client::hand_made_finality_light_client_update::HandMadeFinalityLightClientUpdate; @@ -16,7 +17,6 @@ use eth_types::eth2::LightClientUpdate; use eth_types::BlockHeader; use log::{debug, info, trace, warn}; use near_primitives::views::FinalExecutionStatus; -use std::{cmp, fmt}; use std::cmp::max; use std::error::Error; use std::fmt::Display; @@ -24,7 +24,7 @@ use std::thread; use std::thread::sleep; use std::time::Duration; use std::vec::Vec; -use eth2_utility::types::ClientMode; +use std::{cmp, fmt}; use types::Slot; const ONE_EPOCH_IN_SLOTS: u64 = 32; @@ -86,10 +86,7 @@ pub struct SlotByBlockNumberNotFound; impl Display for SlotByBlockNumberNotFound { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "Slot wasn't found for given block number" - ) + write!(f, "Slot wasn't found for given block number") } } @@ -113,10 +110,7 @@ pub struct Eth2NearRelay { } impl Eth2NearRelay { - pub fn init( - config: &Config, - eth_contract: Box, - ) -> Self { + pub fn init(config: &Config, eth_contract: Box) -> Self { info!(target: "relay", "=== Relay initialization === "); let beacon_rpc_client = BeaconRPCClient::new( @@ -216,14 +210,15 @@ impl Eth2NearRelay { info!(target: "relay", "== New relay loop =="); sleep(Duration::from_secs(12)); - let client_mode: ClientMode = skip_fail!(self.eth_client_contract.get_client_mode(), + let client_mode: ClientMode = skip_fail!( + self.eth_client_contract.get_client_mode(), "Fail to get client mode", self.sleep_time_on_sync_secs ); let submitted_in_this_iteration = match client_mode { ClientMode::SubmitLightClientUpdate => self.submit_light_client_update(), - ClientMode::SubmitHeader => self.submit_headers() + ClientMode::SubmitHeader => self.submit_headers(), }; if !submitted_in_this_iteration { @@ -239,11 +234,15 @@ impl Eth2NearRelay { } fn get_max_block_number(&mut self) -> Result> { - if let Some(tail_block_number) = self.eth_client_contract.get_unfinalized_tail_block_number()? { + if let Some(tail_block_number) = self + .eth_client_contract + .get_unfinalized_tail_block_number()? + { Ok(tail_block_number - 1) } else { - self.beacon_rpc_client.get_block_number_for_slot( - Slot::new(self.eth_client_contract.get_finalized_beacon_block_slot()?)) + self.beacon_rpc_client.get_block_number_for_slot(Slot::new( + self.eth_client_contract.get_finalized_beacon_block_slot()?, + )) } } @@ -265,18 +264,17 @@ impl Eth2NearRelay { false ); - let min_block_number_in_batch = - max(min_block_number, current_block_number - self.headers_batch_size + 1); + let min_block_number_in_batch = max( + min_block_number, + current_block_number - self.headers_batch_size + 1, + ); info!(target: "relay", "Get headers block_number=[{}, {}]", min_block_number_in_batch, current_block_number); let mut headers = skip_fail!( - self.get_execution_blocks_between( - min_block_number_in_batch, - current_block_number, - ), - "Network problems during fetching execution blocks", - self.sleep_time_on_sync_secs - ); + self.get_execution_blocks_between(min_block_number_in_batch, current_block_number,), + "Network problems during fetching execution blocks", + self.sleep_time_on_sync_secs + ); headers.reverse(); if !self.submit_execution_blocks(headers) { @@ -346,20 +344,19 @@ impl Eth2NearRelay { for current_block_number in min_block_number..=max_block_number { debug!(target: "relay", "Try add block header for block number={}", current_block_number); - headers.push(self.eth1_rpc_client.get_block_header_by_number(current_block_number)?); + headers.push( + self.eth1_rpc_client + .get_block_header_by_number(current_block_number)?, + ); } Ok(headers) } - fn submit_execution_blocks( - &mut self, - headers: Vec, - ) -> bool { + fn submit_execution_blocks(&mut self, headers: Vec) -> bool { info!(target: "relay", "Try submit headers batch"); let execution_outcome = return_val_on_fail!( - self.eth_client_contract - .send_headers(&headers), + self.eth_client_contract.send_headers(&headers), "Error on header submission", false ); @@ -450,10 +447,7 @@ impl Eth2NearRelay { last_finalized_slot_on_near, last_finalized_slot_on_eth, ) { - self.send_light_client_updates( - last_finalized_slot_on_near, - last_finalized_slot_on_eth, - ); + self.send_light_client_updates(last_finalized_slot_on_near, last_finalized_slot_on_eth); return true; } @@ -651,10 +645,10 @@ impl Eth2NearRelay { light_client_update: LightClientUpdate, ) -> bool { let verification_result = return_val_on_fail!( - self.verify_bls_signature_for_finality_update(&light_client_update), - "Error on bls verification. Skip sending the light client update", - false - ); + self.verify_bls_signature_for_finality_update(&light_client_update), + "Error on bls verification. Skip sending the light client update", + false + ); if verification_result { info!(target: "relay", "PASS bls signature verification!"); @@ -664,12 +658,12 @@ impl Eth2NearRelay { } let execution_outcome = return_val_on_fail_and_sleep!( - self.eth_client_contract - .send_light_client_update(light_client_update.clone()), - "Fail to send light client update", - self.sleep_time_on_sync_secs, - false - ); + self.eth_client_contract + .send_light_client_update(light_client_update.clone()), + "Fail to send light client update", + self.sleep_time_on_sync_secs, + false + ); info!(target: "relay", "Sending light client update"); @@ -682,18 +676,18 @@ impl Eth2NearRelay { self.near_network_name, execution_outcome.transaction.hash); let finalized_block_number = return_val_on_fail!( - self.beacon_rpc_client - .get_block_number_for_slot(types::Slot::new( - light_client_update - .finality_update - .header_update - .beacon_header - .slot - .as_u64() - )), - "Fail on getting finalized block number", - false - ); + self.beacon_rpc_client + .get_block_number_for_slot(types::Slot::new( + light_client_update + .finality_update + .header_update + .beacon_header + .slot + .as_u64() + )), + "Fail on getting finalized block number", + false + ); info!(target: "relay", "Finalized block number from light client update = {}", finalized_block_number); sleep(Duration::from_secs(self.sleep_time_after_submission_secs)); @@ -704,9 +698,9 @@ impl Eth2NearRelay { #[cfg(test)] mod tests { use crate::config_for_tests::ConfigForTests; + use crate::eth2near_relay::ClientMode; use crate::eth2near_relay::{Eth2NearRelay, ONE_EPOCH_IN_SLOTS}; use crate::test_utils::{get_relay, get_relay_from_slot, get_relay_with_update_from_file}; - use crate::eth2near_relay::ClientMode; use eth_rpc_client::beacon_rpc_client::BeaconRPCClient; use eth_rpc_client::hand_made_finality_light_client_update::HandMadeFinalityLightClientUpdate; use eth_types::eth2::LightClientUpdate; @@ -725,7 +719,10 @@ mod tests { .unwrap() } - fn get_execution_block_by_slot(relay: &Eth2NearRelay, slot: u64) -> Result> { + fn get_execution_block_by_slot( + relay: &Eth2NearRelay, + slot: u64, + ) -> Result> { match relay .beacon_rpc_client .get_block_number_for_slot(types::Slot::new(slot)) @@ -741,7 +738,7 @@ mod tests { fn test_submit_zero_headers() { let config_for_test = get_test_config(); - let mut relay = get_relay( true, &config_for_test); + let mut relay = get_relay(true, &config_for_test); let blocks: Vec = vec![]; if let Ok(_) = relay.eth_client_contract.send_headers(&blocks) { @@ -794,10 +791,13 @@ mod tests { let relay = get_relay(true, &config_for_test); - let last_period = BeaconRPCClient::get_period_for_slot(relay.beacon_rpc_client - .get_last_slot_number() - .unwrap() - .as_u64()); + let last_period = BeaconRPCClient::get_period_for_slot( + relay + .beacon_rpc_client + .get_last_slot_number() + .unwrap() + .as_u64(), + ); let light_client_update = relay .beacon_rpc_client @@ -855,7 +855,7 @@ mod tests { fn test_hand_made_light_client_update() { let config_for_test = get_test_config(); - let mut relay = get_relay( true, &config_for_test); + let mut relay = get_relay(true, &config_for_test); let light_client_updates: Vec = serde_json::from_str( &std::fs::read_to_string(config_for_test.path_to_light_client_updates) @@ -890,7 +890,7 @@ mod tests { fn test_send_light_client_update() { let config_for_test = get_test_config(); - let mut relay = get_relay( false, &config_for_test); + let mut relay = get_relay(false, &config_for_test); let finality_slot = get_finalized_slot(&relay); assert!(relay.send_light_client_updates_with_checks()); @@ -976,17 +976,15 @@ mod tests { let light_client_updates: Vec = serde_json::from_str( &std::fs::read_to_string(config_for_test.path_to_light_client_updates) .expect("Unable to read file"), - ).unwrap(); + ) + .unwrap(); relay.send_specific_light_client_update(light_client_updates[1].clone()); let min_block_number = relay.eth_client_contract.get_last_block_number().unwrap() + 1; let max_block_number = relay.get_max_block_number().unwrap(); let blocks = relay - .get_execution_blocks_between( - min_block_number, - max_block_number, - ) + .get_execution_blocks_between(min_block_number, max_block_number) .unwrap(); relay.submit_execution_blocks(blocks); } @@ -1000,9 +998,7 @@ mod tests { let possible_attested_slot = finalized_slot + ONE_EPOCH_IN_SLOTS * 2 + ONE_EPOCH_IN_SLOTS * relay.interval_between_light_client_updates_submission_in_epochs; - if get_execution_block_by_slot(&relay, possible_attested_slot) - .is_ok() - { + if get_execution_block_by_slot(&relay, possible_attested_slot).is_ok() { panic!("possible attested slot has execution block"); } @@ -1016,7 +1012,11 @@ mod tests { let config_for_test = get_test_config(); let mut relay = get_relay(false, &config_for_test); let finality_slot = get_finalized_slot(&relay); - let finality_slot_on_eth = relay.beacon_rpc_client.get_last_finalized_slot_number().unwrap().as_u64(); + let finality_slot_on_eth = relay + .beacon_rpc_client + .get_last_finalized_slot_number() + .unwrap() + .as_u64(); relay.send_regular_light_client_update(finality_slot_on_eth, finality_slot); diff --git a/eth2near/eth2near-block-relay-rs/src/main.rs b/eth2near/eth2near-block-relay-rs/src/main.rs index 6b7ac550..6bf76cd1 100644 --- a/eth2near/eth2near-block-relay-rs/src/main.rs +++ b/eth2near/eth2near-block-relay-rs/src/main.rs @@ -101,10 +101,7 @@ fn main() -> Result<(), Box> { ); init_log(&args, &config); - let mut eth2near_relay = Eth2NearRelay::init( - &config, - get_eth_client_contract(&config) - ); + let mut eth2near_relay = Eth2NearRelay::init(&config, get_eth_client_contract(&config)); eth2near_relay.run(None); Ok(()) diff --git a/eth2near/eth_rpc_client/Cargo.toml b/eth2near/eth_rpc_client/Cargo.toml index 83b6c7fe..400405ac 100644 --- a/eth2near/eth_rpc_client/Cargo.toml +++ b/eth2near/eth_rpc_client/Cargo.toml @@ -6,17 +6,18 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -types = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -merkle_proof = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_hashing = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -eth2_ssz = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } +types = { workspace = true } +tree_hash = { workspace = true } +merkle_proof = { workspace = true } +ethereum_hashing = { workspace = true } +ethereum_ssz = { workspace = true } log = { version = "0.4", features = ["std", "serde"] } serde_json = "1.0.74" serde = { version = "1.0", features = ["derive"] } ethereum-types = { version = "0.14.1", features = ["rlp", "serialize"], default-features = false } reqwest = { version = "0.11", features = ["blocking"] } eth-types = { path = "../../contracts/near/eth-types/" } +eth2-utility = { path = "../../contracts/near/eth2-utility/" } contract_wrapper = { path = "../contract_wrapper" } clap = { version = "3.1.6", features = ["derive"] } tokio = { version = "1.1", features = ["macros", "rt", "time"] } diff --git a/eth2near/eth_rpc_client/src/beacon_block_body_merkle_tree.rs b/eth2near/eth_rpc_client/src/beacon_block_body_merkle_tree.rs index 89c84361..cecf1914 100644 --- a/eth2near/eth_rpc_client/src/beacon_block_body_merkle_tree.rs +++ b/eth2near/eth_rpc_client/src/beacon_block_body_merkle_tree.rs @@ -10,7 +10,7 @@ use types::{BeaconBlockBody, BeaconState, ExecutionPayload, MainnetEthSpec}; pub struct BeaconBlockBodyMerkleTree(pub MerkleTree); impl BeaconBlockBodyMerkleTree { - pub const BEACON_BLOCK_BODY_TREE_NUM_LEAVES: usize = 11; + pub const BEACON_BLOCK_BODY_TREE_NUM_LEAVES: usize = 12; pub const BEACON_BLOCK_BODY_TREE_DEPTH: usize = 4; pub fn new(beacon_block_body: &BeaconBlockBody) -> Self { @@ -38,6 +38,12 @@ impl BeaconBlockBodyMerkleTree { } else { H256::zero() }, + + if let Ok(blob_kzg_commitments) = beacon_block_body.blob_kzg_commitments() { + blob_kzg_commitments.tree_hash_root() + } else { + H256::zero() + } ]; Self(MerkleTree::create( @@ -56,11 +62,9 @@ impl BeaconBlockBodyMerkleTree { pub struct ExecutionPayloadMerkleTree(pub MerkleTree); impl ExecutionPayloadMerkleTree { - pub const TREE_NUM_LEAVES: usize = 15; - pub const TREE_DEPTH: usize = 4; - pub fn new(execution_payload: &ExecutionPayload) -> Self { - let leaves: [H256; Self::TREE_NUM_LEAVES] = [ + let mut depth: usize = 4; + let mut leaves: Vec = vec![ execution_payload.parent_hash().tree_hash_root(), execution_payload.fee_recipient().tree_hash_root(), execution_payload.state_root().tree_hash_root(), @@ -82,7 +86,16 @@ impl ExecutionPayloadMerkleTree { }, ]; - Self(MerkleTree::create(&leaves, Self::TREE_DEPTH)) + if let Ok(blob_gas_used) = execution_payload.blob_gas_used() { + depth += 1; + leaves.push(blob_gas_used.tree_hash_root()); + } + + if let Ok(excess_blob_gas) = execution_payload.excess_blob_gas() { + leaves.push(excess_blob_gas.tree_hash_root()); + } + + Self(MerkleTree::create(&leaves, depth)) } } diff --git a/eth2near/eth_rpc_client/src/eth1_rpc_client.rs b/eth2near/eth_rpc_client/src/eth1_rpc_client.rs index 4ab2e8d2..ffbbf1ad 100644 --- a/eth2near/eth_rpc_client/src/eth1_rpc_client.rs +++ b/eth2near/eth_rpc_client/src/eth1_rpc_client.rs @@ -50,6 +50,9 @@ impl Eth1RPCClient { block_json = block_json.replace("parentHash", "parent_hash"); block_json = block_json.replace("miner", "author"); block_json = block_json.replace("withdrawalsRoot", "withdrawals_root"); + block_json = block_json.replace("blobGasUsed", "blob_gas_used"); + block_json = block_json.replace("excessBlobGas", "excess_blob_gas"); + block_json = block_json.replace("parentBeaconBlockRoot", "parent_beacon_block_root"); let block_header: BlockHeader = serde_json::from_str(&block_json)?; Ok(block_header) diff --git a/eth2near/eth_rpc_client/src/execution_block_proof.rs b/eth2near/eth_rpc_client/src/execution_block_proof.rs index 064341dd..eb04f850 100644 --- a/eth2near/eth_rpc_client/src/execution_block_proof.rs +++ b/eth2near/eth_rpc_client/src/execution_block_proof.rs @@ -1,11 +1,12 @@ use crate::beacon_block_body_merkle_tree::{BeaconBlockBodyMerkleTree, ExecutionPayloadMerkleTree}; use crate::errors::{MerkleTreeError, MissExecutionPayload}; -use eth2_hashing; +use eth2_utility::consensus::ProofSize; +use ethereum_hashing; use ethereum_types::H256; use std::error::Error; use std::fmt; use std::fmt::Display; -use types::{BeaconBlockBody, ExecutionPayload, MainnetEthSpec}; +use types::{BeaconBlockBody, ExecutionPayload, ForkName, MainnetEthSpec}; /// `ExecutionBlockProof` contains a `block_hash` (execution block) and /// a proof of its inclusion in the `BeaconBlockBody` tree hash. @@ -17,29 +18,26 @@ use types::{BeaconBlockBody, ExecutionPayload, MainnetEthSpec}; /// The proof starts from the leaf. pub struct ExecutionBlockProof { block_hash: H256, - proof: [H256; Self::PROOF_SIZE], + proof: Vec, } impl ExecutionBlockProof { pub const L1_BEACON_BLOCK_BODY_TREE_EXECUTION_PAYLOAD_INDEX: usize = 9; + pub const L1_BEACON_BLOCK_BODY_PROOF_SIZE: usize = 4; pub const L2_EXECUTION_PAYLOAD_TREE_EXECUTION_BLOCK_INDEX: usize = 12; - pub const L1_BEACON_BLOCK_BODY_PROOF_SIZE: usize = - BeaconBlockBodyMerkleTree::BEACON_BLOCK_BODY_TREE_DEPTH; - pub const L2_EXECUTION_PAYLOAD_PROOF_SIZE: usize = ExecutionPayloadMerkleTree::TREE_DEPTH; - pub const PROOF_SIZE: usize = - Self::L1_BEACON_BLOCK_BODY_PROOF_SIZE + Self::L2_EXECUTION_PAYLOAD_PROOF_SIZE; - - pub fn construct_from_raw_data(block_hash: &H256, proof: &[H256; Self::PROOF_SIZE]) -> Self { - Self { - block_hash: *block_hash, - proof: *proof, - } + pub fn construct_from_raw_data(block_hash: H256, proof: Vec) -> Self { + Self { block_hash, proof } } pub fn construct_from_beacon_block_body( beacon_block_body: &BeaconBlockBody, ) -> Result> { + let l2_execution_payload_proof_size = match beacon_block_body.to_ref().fork_name() { + ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => 4, + _ => 5, + }; + let beacon_block_merkle_tree = &BeaconBlockBodyMerkleTree::new(beacon_block_body); let execution_payload_merkle_tree = &ExecutionPayloadMerkleTree::new( @@ -61,7 +59,7 @@ impl ExecutionBlockProof { .0 .generate_proof( Self::L2_EXECUTION_PAYLOAD_TREE_EXECUTION_BLOCK_INDEX, - Self::L2_EXECUTION_PAYLOAD_PROOF_SIZE, + l2_execution_payload_proof_size, ) .map_err(|err| MerkleTreeError(err))? .1; @@ -77,8 +75,8 @@ impl ExecutionBlockProof { }) } - pub fn get_proof(&self) -> [H256; Self::PROOF_SIZE] { - self.proof + pub fn get_proof(&self) -> Vec { + self.proof.clone() } pub fn get_execution_block_hash(&self) -> H256 { @@ -88,22 +86,23 @@ impl ExecutionBlockProof { pub fn verify_proof_for_hash( &self, beacon_block_body_hash: &H256, + proof_size: &ProofSize, ) -> Result { - let l2_proof: &[H256] = &self.proof[0..Self::L2_EXECUTION_PAYLOAD_PROOF_SIZE]; - let l1_proof: &[H256] = - &self.proof[Self::L2_EXECUTION_PAYLOAD_PROOF_SIZE..Self::PROOF_SIZE]; + let l2_proof = &self.proof[0..proof_size.l2_execution_payload_proof_size]; + let l1_proof = &self.proof + [proof_size.l2_execution_payload_proof_size..proof_size.execution_proof_size]; let execution_payload_hash = Self::merkle_root_from_branch( self.block_hash, l2_proof, - Self::L2_EXECUTION_PAYLOAD_PROOF_SIZE, - Self::L2_EXECUTION_PAYLOAD_TREE_EXECUTION_BLOCK_INDEX, + proof_size.l2_execution_payload_proof_size, + proof_size.l2_execution_payload_tree_execution_block_index, )?; Ok(merkle_proof::verify_merkle_proof( execution_payload_hash, l1_proof, BeaconBlockBodyMerkleTree::BEACON_BLOCK_BODY_TREE_DEPTH, - Self::L1_BEACON_BLOCK_BODY_TREE_EXECUTION_PAYLOAD_INDEX, + proof_size.l1_beacon_block_body_tree_execution_payload_index, *beacon_block_body_hash, )) } @@ -124,11 +123,11 @@ impl ExecutionBlockProof { let ith_bit = (index >> i) & 0x01; if ith_bit == 1 { merkle_root = - eth2_hashing::hash32_concat(leaf.as_bytes(), &merkle_root)[..].to_vec(); + ethereum_hashing::hash32_concat(leaf.as_bytes(), &merkle_root)[..].to_vec(); } else { let mut input = merkle_root; input.extend_from_slice(leaf.as_bytes()); - merkle_root = eth2_hashing::hash(&input); + merkle_root = ethereum_hashing::hash(&input); } } @@ -154,6 +153,7 @@ impl Error for IncorrectBranchLength {} mod tests { use crate::config_for_tests::ConfigForTests; use crate::utils::read_json_file_from_data_dir; + use eth2_utility::consensus::{Network, NetworkConfig}; use types::MainnetEthSpec; use types::{BeaconBlockBody, ExecutionPayload}; @@ -166,8 +166,10 @@ mod tests { #[test] fn test_beacon_block_body_root_verification() { + let slot = 5262172; + let config = NetworkConfig::new(&Network::Goerli); let beacon_block_body_json_str = - read_json_file_from_data_dir("beacon_block_body_goerli_slot_5262172.json"); + read_json_file_from_data_dir(&format!("beacon_block_body_goerli_slot_{slot}.json")); let beacon_block_body: BeaconBlockBody = serde_json::from_str(&beacon_block_body_json_str).unwrap(); @@ -195,17 +197,18 @@ mod tests { types::ExecutionBlockHash::from_root(execution_block_proof.get_execution_block_hash()) ); + let proof_size = config.compute_proof_size_by_slot(slot); assert!(execution_block_proof - .verify_proof_for_hash(&beacon_block_body_merkle_tree.0.hash()) + .verify_proof_for_hash(&beacon_block_body_merkle_tree.0.hash(), &proof_size) .unwrap()); let execution_block_proof_copy = crate::execution_block_proof::ExecutionBlockProof::construct_from_raw_data( - &execution_block_proof.get_execution_block_hash(), - &execution_block_proof.get_proof(), + execution_block_proof.get_execution_block_hash(), + execution_block_proof.get_proof(), ); assert!(execution_block_proof_copy - .verify_proof_for_hash(&beacon_block_body_merkle_tree.0.hash()) + .verify_proof_for_hash(&beacon_block_body_merkle_tree.0.hash(), &proof_size) .unwrap()); } diff --git a/eth2near/finality-update-verify/Cargo.toml b/eth2near/finality-update-verify/Cargo.toml index 8ffbd70b..30cc90e1 100644 --- a/eth2near/finality-update-verify/Cargo.toml +++ b/eth2near/finality-update-verify/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2021" [dependencies] -bls = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -tree_hash = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } -types = { git = "https://github.com/aurora-is-near/lighthouse.git", tag = "v3.5.1-wasm" } +bls = { workspace = true } +tree_hash = { workspace = true } +types = { workspace = true } eth-types = { path ="../../contracts/near/eth-types/" } eth2-utility = { path ="../../contracts/near/eth2-utility"} bitvec = "1.0.0"