-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix consensus, SSZ, tree hash & run merge EF tests (#2622)
* Update to v1.1.0-beta.4 (squash of #2548) * SSZ, cached tree hash, EF tests
- Loading branch information
1 parent
3718c36
commit ef6158f
Showing
23 changed files
with
309 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::FixedVector; | ||
use eth2_serde_utils::hex::{self, PrefixedHexVisitor}; | ||
use serde::{Deserializer, Serializer}; | ||
use typenum::Unsigned; | ||
|
||
pub fn serialize<S, U>(bytes: &FixedVector<u8, U>, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
U: Unsigned, | ||
{ | ||
let mut hex_string: String = "0x".to_string(); | ||
hex_string.push_str(&hex::encode(&bytes[..])); | ||
|
||
serializer.serialize_str(&hex_string) | ||
} | ||
|
||
pub fn deserialize<'de, D, U>(deserializer: D) -> Result<FixedVector<u8, U>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
U: Unsigned, | ||
{ | ||
let vec = deserializer.deserialize_string(PrefixedHexVisitor)?; | ||
FixedVector::new(vec) | ||
.map_err(|e| serde::de::Error::custom(format!("invalid fixed vector: {:?}", e))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Serialize `VariableList<u8, N>` as 0x-prefixed hex string. | ||
use crate::VariableList; | ||
use eth2_serde_utils::hex::{self, PrefixedHexVisitor}; | ||
use serde::{Deserializer, Serializer}; | ||
use typenum::Unsigned; | ||
|
||
pub fn serialize<S, N>(bytes: &VariableList<u8, N>, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
N: Unsigned, | ||
{ | ||
let mut hex_string: String = "0x".to_string(); | ||
hex_string.push_str(&hex::encode(&**bytes)); | ||
|
||
serializer.serialize_str(&hex_string) | ||
} | ||
|
||
pub fn deserialize<'de, D, N>(deserializer: D) -> Result<VariableList<u8, N>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
N: Unsigned, | ||
{ | ||
let bytes = deserializer.deserialize_str(PrefixedHexVisitor)?; | ||
VariableList::new(bytes) | ||
.map_err(|e| serde::de::Error::custom(format!("invalid variable list: {:?}", e))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub mod hex_fixed_vec; | ||
pub mod hex_var_list; | ||
pub mod quoted_u64_fixed_vec; | ||
pub mod quoted_u64_var_list; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.