Skip to content

Commit

Permalink
Merge branch 'main' into add-electra-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes authored May 7, 2024
2 parents 34cd802 + 2ce2ca4 commit 8b07ce8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ serde_yaml = "0.8"
itertools = "0.10.3"
thiserror = "1.0.30"
hex = "0.4.3"
ssz_rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "52cf0426922df94c0cb45a4736032d772c0a744f" }
ssz_rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "84ef2b71aa004f6767420badb42c902ad56b8b72" }
blst = "0.3.11"
rand = "0.8.4"
sha2 = "0.10.8"
Expand Down
11 changes: 10 additions & 1 deletion ethereum-consensus/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,16 @@ impl SecretKey {
}

#[derive(
Clone, Default, Hash, PartialEq, Eq, SimpleSerialize, serde::Serialize, serde::Deserialize,
Clone,
Default,
Hash,
PartialEq,
Eq,
PartialOrd,
Ord,
SimpleSerialize,
serde::Serialize,
serde::Deserialize,
)]
pub struct PublicKey(ByteVector<BLS_PUBLIC_KEY_BYTES_LEN>);

Expand Down
20 changes: 1 addition & 19 deletions ethereum-consensus/src/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl std::fmt::Display for Network {
Self::Sepolia => write!(f, "sepolia"),
Self::Goerli => write!(f, "goerli"),
Self::Holesky => write!(f, "holesky"),
Self::Custom(config_dir) => write!(f, "{config_dir}"),
Self::Custom(config_dir) => write!(f, "custom ({config_dir}/config.yaml)"),
}
}
}
Expand Down Expand Up @@ -70,21 +70,3 @@ impl TryFrom<Network> for Context {
pub fn typical_genesis_time(context: &Context) -> u64 {
context.min_genesis_time + context.genesis_delay
}

#[cfg(test)]
mod tests {
use super::*;

#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
struct File {
network: Network,
}

#[test]
fn test_serde() {
let file = File { network: Network::Custom("/path/to/foo.yaml".to_string()) };
let str = toml::to_string(&file).unwrap();
let recovered_file: File = toml::from_str(&str).unwrap();
assert_eq!(file, recovered_file);
}
}
12 changes: 11 additions & 1 deletion ethereum-consensus/src/ssz/byte_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ use std::{
ops::{Deref, DerefMut},
};

#[derive(Default, Clone, PartialEq, Eq, SimpleSerialize, serde::Serialize, serde::Deserialize)]
#[derive(
Default,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
SimpleSerialize,
serde::Serialize,
serde::Deserialize,
)]
pub struct ByteVector<const N: usize>(#[serde(with = "crate::serde::as_hex")] Vector<u8, N>);

impl<const N: usize> TryFrom<&[u8]> for ByteVector<N> {
Expand Down

0 comments on commit 8b07ce8

Please sign in to comment.