From 0a73b31bdbdbb8570fef66e50d79c794171b2316 Mon Sep 17 00:00:00 2001 From: Milos Stankovic <82043364+morph-dev@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:52:07 +0300 Subject: [PATCH 01/10] Add Eq trait to FixedVector (#26) --- src/fixed_vector.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fixed_vector.rs b/src/fixed_vector.rs index fe0e6f9..ec8a913 100644 --- a/src/fixed_vector.rs +++ b/src/fixed_vector.rs @@ -46,7 +46,7 @@ pub use typenum; /// assert_eq!(&long[..], &[1, 2, 3, 4, 0]); /// ``` #[derive(Debug, Clone, Serialize, Deserialize, Derivative)] -#[derivative(PartialEq, Hash(bound = "T: std::hash::Hash"))] +#[derivative(PartialEq, Eq, Hash(bound = "T: std::hash::Hash"))] #[serde(transparent)] pub struct FixedVector { vec: Vec, From ec5c98edec167a8a0921ec536a5f49d05703e1ec Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 8 Jul 2024 02:45:09 +0100 Subject: [PATCH 02/10] Resize BitList (#24) * add function to extend a bitlist * rename from extend to resize * rename from extend to resize --- src/bitfield.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/bitfield.rs b/src/bitfield.rs index d090833..dedaf7a 100644 --- a/src/bitfield.rs +++ b/src/bitfield.rs @@ -240,6 +240,24 @@ impl Bitfield> { pub fn is_subset(&self, other: &Self) -> bool { self.difference(other).is_zero() } + + /// Returns a new BitList of length M, with the same bits set as `self`. + pub fn resize(&self) -> Result>, Error> { + if N::to_usize() > M::to_usize() { + return Err(Error::InvalidByteCount { + given: M::to_usize(), + expected: N::to_usize() + 1, + }); + } + + let mut resized = Bitfield::>::with_capacity(M::to_usize())?; + + for (i, bit) in self.iter().enumerate() { + resized.set(i, bit)?; + } + + Ok(resized) + } } impl Bitfield> { @@ -1403,4 +1421,21 @@ mod bitlist { fn size_of() { assert_eq!(std::mem::size_of::(), SMALLVEC_LEN + 24); } + + #[test] + fn resize() { + let mut bit_list = BitList1::with_capacity(1).unwrap(); + bit_list.set(0, true).unwrap(); + assert_eq!(bit_list.len(), 1); + assert_eq!(bit_list.num_set_bits(), 1); + assert_eq!(bit_list.highest_set_bit().unwrap(), 0); + + let resized_bit_list = bit_list.resize::().unwrap(); + assert_eq!(resized_bit_list.len(), 1024); + assert_eq!(resized_bit_list.num_set_bits(), 1); + assert_eq!(resized_bit_list.highest_set_bit().unwrap(), 0); + + // Can't extend a BitList to a smaller BitList + resized_bit_list.resize::().unwrap_err(); + } } From 5ba47dc32d0001e8f5179858acd7193768542a18 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 8 Jul 2024 11:52:35 +1000 Subject: [PATCH 03/10] Use API token for codecov --- .github/workflows/test-suite.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index fa7e154..a83755b 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -43,6 +43,7 @@ jobs: - name: Check code coverage with cargo-tarpaulin run: cargo-tarpaulin --workspace --all-features --out xml - name: Upload to codecov.io - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} From 26015c5a7c802aa7158da4e14019d5e538771b46 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 10 Jul 2024 15:09:53 +0100 Subject: [PATCH 04/10] update deps --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7e29c59..6372e27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,9 @@ keywords = ["ethereum"] categories = ["cryptography::cryptocurrencies"] [dependencies] -tree_hash = { git = "https://github.com/KolbyML/tree_hash.git", rev = "8aaf8bb4184148768d48e2cfbbdd0b95d1da8730" } -ethereum_serde_utils = "0.5" -ethereum_ssz = "0.5" +tree_hash = { git = "https://github.com/sigp/tree_hash", branch = "alloy" } +ethereum_serde_utils = { git = "https://github.com/sigp/ethereum_serde_utils", branch = "alloy" } +ethereum_ssz = { git = "https://github.com/sigp/ethereum_ssz", branch = "alloy" } serde = "1.0.0" serde_derive = "1.0.0" typenum = "1.12.0" From 5aebf7ea3402efed0c90db6abd96cc769f4e1fde Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 11 Jul 2024 12:21:18 +0100 Subject: [PATCH 05/10] update tree hash --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6372e27..672e7f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["ethereum"] categories = ["cryptography::cryptocurrencies"] [dependencies] -tree_hash = { git = "https://github.com/sigp/tree_hash", branch = "alloy" } +tree_hash = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} ethereum_serde_utils = { git = "https://github.com/sigp/ethereum_serde_utils", branch = "alloy" } ethereum_ssz = { git = "https://github.com/sigp/ethereum_ssz", branch = "alloy" } serde = "1.0.0" From 2adab87c27a4306709180f3b4c44abe0a0c80a45 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 11 Jul 2024 13:27:52 +0100 Subject: [PATCH 06/10] update --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 672e7f3..e69c670 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,4 +24,4 @@ itertools = "0.10.0" [dev-dependencies] serde_json = "1.0.0" -tree_hash_derive = { git = "https://github.com/KolbyML/tree_hash.git", rev = "8aaf8bb4184148768d48e2cfbbdd0b95d1da8730" } +tree_hash_derive = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} From 39e9fe8ab5fa22edafbc853fc3e165d0f01c7180 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 24 Jul 2024 06:20:12 -0700 Subject: [PATCH 07/10] fix toml --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e69c670..bcee438 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,9 @@ keywords = ["ethereum"] categories = ["cryptography::cryptocurrencies"] [dependencies] -tree_hash = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} -ethereum_serde_utils = { git = "https://github.com/sigp/ethereum_serde_utils", branch = "alloy" } -ethereum_ssz = { git = "https://github.com/sigp/ethereum_ssz", branch = "alloy" } +tree_hash = { git = "https://github.com/sigp/tree_hash", branch = "alloy"} +ethereum_serde_utils = "0.5" +ethereum_ssz = "0.5" serde = "1.0.0" serde_derive = "1.0.0" typenum = "1.12.0" @@ -24,4 +24,4 @@ itertools = "0.10.0" [dev-dependencies] serde_json = "1.0.0" -tree_hash_derive = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} +tree_hash_derive = { git = "https://github.com/sigp/tree_hash", branch = "alloy"} From 63aa70bc253cd78115ed4c9220efed7c251af2ff Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 25 Jul 2024 11:41:25 -0700 Subject: [PATCH 08/10] revert --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bcee438..e69c670 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,9 @@ keywords = ["ethereum"] categories = ["cryptography::cryptocurrencies"] [dependencies] -tree_hash = { git = "https://github.com/sigp/tree_hash", branch = "alloy"} -ethereum_serde_utils = "0.5" -ethereum_ssz = "0.5" +tree_hash = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} +ethereum_serde_utils = { git = "https://github.com/sigp/ethereum_serde_utils", branch = "alloy" } +ethereum_ssz = { git = "https://github.com/sigp/ethereum_ssz", branch = "alloy" } serde = "1.0.0" serde_derive = "1.0.0" typenum = "1.12.0" @@ -24,4 +24,4 @@ itertools = "0.10.0" [dev-dependencies] serde_json = "1.0.0" -tree_hash_derive = { git = "https://github.com/sigp/tree_hash", branch = "alloy"} +tree_hash_derive = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} From d4960efaa3f9516cafd9144d4cf875a73504a5cf Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 26 Jul 2024 16:24:31 -0700 Subject: [PATCH 09/10] tweak --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e69c670..144171b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,8 @@ categories = ["cryptography::cryptocurrencies"] [dependencies] tree_hash = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} -ethereum_serde_utils = { git = "https://github.com/sigp/ethereum_serde_utils", branch = "alloy" } -ethereum_ssz = { git = "https://github.com/sigp/ethereum_ssz", branch = "alloy" } +ethereum_serde_utils = { git = "https://github.com/eserilev/ethereum_serde_utils", branch = "alloy" } +ethereum_ssz = { git = "https://github.com/eserilev/ethereum_ssz", branch = "alloy" } serde = "1.0.0" serde_derive = "1.0.0" typenum = "1.12.0" From 83389701ccedc217f412ac33048a6dcd6c6a5aee Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 30 Jul 2024 08:25:24 -0700 Subject: [PATCH 10/10] revert deps --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 144171b..f96bebc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,8 @@ categories = ["cryptography::cryptocurrencies"] [dependencies] tree_hash = { git = "https://github.com/eserilev/tree_hash", branch = "alloy-deps"} -ethereum_serde_utils = { git = "https://github.com/eserilev/ethereum_serde_utils", branch = "alloy" } -ethereum_ssz = { git = "https://github.com/eserilev/ethereum_ssz", branch = "alloy" } +ethereum_serde_utils = "0.5" +ethereum_ssz = "0.5" serde = "1.0.0" serde_derive = "1.0.0" typenum = "1.12.0"