-
Notifications
You must be signed in to change notification settings - Fork 788
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix arbitrary check kintsugi * Add merge chain spec fields, and a function to determine which constant to use based on the state variant * increment spec test version * Remove `Transaction` enum wrapper * Remove Transaction new-type * Remove gas validations * Add `--terminal-block-hash-epoch-override` flag * Increment spec tests version to 1.1.5 * Remove extraneous gossip verification ethereum/consensus-specs#2687 * - Remove unused Error variants - Require both "terminal-block-hash-epoch-override" and "terminal-block-hash-override" when either flag is used * - Remove a couple more unused Error variants Co-authored-by: Paul Hauner <paul@paulhauner.com>
- Loading branch information
1 parent
10bc0a8
commit d746616
Showing
20 changed files
with
210 additions
and
208 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
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
77 changes: 77 additions & 0 deletions
77
consensus/ssz_types/src/serde_utils/list_of_hex_var_list.rs
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,77 @@ | ||
//! Serialize `VaraibleList<VariableList<u8, M>, N>` as list of 0x-prefixed hex string. | ||
use crate::VariableList; | ||
use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; | ||
use std::marker::PhantomData; | ||
use typenum::Unsigned; | ||
|
||
#[derive(Deserialize)] | ||
#[serde(transparent)] | ||
pub struct WrappedListOwned<N: Unsigned>( | ||
#[serde(with = "crate::serde_utils::hex_var_list")] VariableList<u8, N>, | ||
); | ||
|
||
#[derive(Serialize)] | ||
#[serde(transparent)] | ||
pub struct WrappedListRef<'a, N: Unsigned>( | ||
#[serde(with = "crate::serde_utils::hex_var_list")] &'a VariableList<u8, N>, | ||
); | ||
|
||
pub fn serialize<S, M, N>( | ||
list: &VariableList<VariableList<u8, M>, N>, | ||
serializer: S, | ||
) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
M: Unsigned, | ||
N: Unsigned, | ||
{ | ||
let mut seq = serializer.serialize_seq(Some(list.len()))?; | ||
for bytes in list { | ||
seq.serialize_element(&WrappedListRef(bytes))?; | ||
} | ||
seq.end() | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct Visitor<M, N> { | ||
_phantom_m: PhantomData<M>, | ||
_phantom_n: PhantomData<N>, | ||
} | ||
|
||
impl<'a, M, N> serde::de::Visitor<'a> for Visitor<M, N> | ||
where | ||
M: Unsigned, | ||
N: Unsigned, | ||
{ | ||
type Value = VariableList<VariableList<u8, M>, N>; | ||
|
||
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
write!(formatter, "a list of 0x-prefixed hex bytes") | ||
} | ||
|
||
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> | ||
where | ||
A: serde::de::SeqAccess<'a>, | ||
{ | ||
let mut list: VariableList<VariableList<u8, M>, N> = <_>::default(); | ||
|
||
while let Some(val) = seq.next_element::<WrappedListOwned<M>>()? { | ||
list.push(val.0).map_err(|e| { | ||
serde::de::Error::custom(format!("failed to push value to list: {:?}.", e)) | ||
})?; | ||
} | ||
|
||
Ok(list) | ||
} | ||
} | ||
|
||
pub fn deserialize<'de, D, M, N>( | ||
deserializer: D, | ||
) -> Result<VariableList<VariableList<u8, M>, N>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
M: Unsigned, | ||
N: Unsigned, | ||
{ | ||
deserializer.deserialize_seq(Visitor::default()) | ||
} |
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,4 +1,5 @@ | ||
pub mod hex_fixed_vec; | ||
pub mod hex_var_list; | ||
pub mod list_of_hex_var_list; | ||
pub mod quoted_u64_fixed_vec; | ||
pub mod quoted_u64_var_list; |
Oops, something went wrong.