Skip to content

Commit

Permalink
Beta compiler fixes (sigp#5543)
Browse files Browse the repository at this point in the history
* remove duplicate imports in gossip tests. get rid of duplicate trait bound locations

* more double import fixes

* cargo fmt
  • Loading branch information
realbigsean authored and Mac L committed May 13, 2024
1 parent 969d12d commit b786e6d
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@

use super::*;
use crate::subscription_filter::WhitelistSubscriptionFilter;
use crate::transform::{DataTransform, IdentityTransform};
use crate::types::{RpcOut, RpcReceiver};
use crate::ValidationError;
use crate::{
config::Config, config::ConfigBuilder, types::Rpc, IdentTopic as Topic, TopicScoreParams,
};
use crate::types::RpcReceiver;
use crate::{config::ConfigBuilder, types::Rpc, IdentTopic as Topic};
use byteorder::{BigEndian, ByteOrder};
use libp2p::core::ConnectedPoint;
use rand::Rng;
Expand Down
1 change: 0 additions & 1 deletion beacon_node/lighthouse_network/gossipsub/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ impl std::fmt::Debug for Config {
mod test {
use super::*;
use crate::topic::IdentityHash;
use crate::types::PeerKind;
use crate::Topic;
use libp2p::core::UpgradeInfo;
use std::collections::hash_map::DefaultHasher;
Expand Down
4 changes: 1 addition & 3 deletions beacon_node/lighthouse_network/gossipsub/src/mcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,7 @@ impl MessageCache {
#[cfg(test)]
mod tests {
use super::*;
use crate::types::RawMessage;
use crate::{IdentTopic as Topic, TopicHash};
use libp2p::identity::PeerId;
use crate::IdentTopic as Topic;

fn gen_testm(x: u64, topic: TopicHash) -> (MessageId, RawMessage) {
let default_id = |message: &RawMessage| {
Expand Down
1 change: 0 additions & 1 deletion beacon_node/lighthouse_network/gossipsub/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ impl Decoder for GossipsubCodec {
mod tests {
use super::*;
use crate::config::Config;
use crate::protocol::{BytesMut, GossipsubCodec, HandlerEvent};
use crate::{Behaviour, ConfigBuilder, MessageAuthenticity};
use crate::{IdentTopic as Topic, Version};
use libp2p::identity::Keypair;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ impl TopicSubscriptionFilter for RegexSubscriptionFilter {
mod test {
use super::*;
use crate::types::SubscriptionAction::*;
use std::iter::FromIterator;

#[test]
fn test_filter_incoming_allow_all_with_duplicates() {
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/operation_pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ impl<E: EthSpec> OperationPool<E> {
}

/// Filter up to a maximum number of operations out of an iterator.
fn filter_limit_operations<'a, T: 'a, V: 'a, I, F, G>(
fn filter_limit_operations<'a, T, V: 'a, I, F, G>(
operations: I,
filter: F,
mapping: G,
Expand All @@ -718,7 +718,7 @@ where
I: IntoIterator<Item = &'a T>,
F: Fn(&T) -> bool,
G: Fn(&T) -> V,
T: Clone,
T: Clone + 'a,
{
operations
.into_iter()
Expand Down
1 change: 0 additions & 1 deletion consensus/types/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,6 @@ where
mod tests {
use super::*;
use itertools::Itertools;
use safe_arith::SafeArith;

#[test]
fn test_mainnet_spec_can_be_constructed() {
Expand Down
257 changes: 257 additions & 0 deletions consensus/types/src/execution_witness.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
use crate::{test_utils::TestRandom, *};
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash;

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(struct_behaviour = "transparent")]
#[serde(transparent)]
pub struct BanderwagonGroupElement<E: EthSpec> {
#[serde(with = "ssz_types::serde_utils::hex_fixed_vec")]
inner: FixedVector<u8, E::BytesPerBanderwagonElement>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(struct_behaviour = "transparent")]
#[serde(transparent)]
pub struct BanderwagonFieldElement<E: EthSpec> {
#[serde(with = "ssz_types::serde_utils::hex_fixed_vec")]
inner: FixedVector<u8, E::BytesPerBanderwagonElement>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(struct_behaviour = "transparent")]
#[serde(transparent)]
pub struct Stem<E: EthSpec> {
#[serde(with = "ssz_types::serde_utils::hex_fixed_vec")]
inner: FixedVector<u8, E::MaxStemLength>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(struct_behaviour = "transparent")]
#[serde(transparent)]
pub struct StateDiffValue<E: EthSpec> {
#[serde(with = "ssz_types::serde_utils::hex_fixed_vec")]
inner: FixedVector<u8, E::BytesPerSuffixStateDiffValue>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
pub struct SuffixStateDiff<E: EthSpec> {
//#[serde(with = "eth2_serde_utils::quoted_u8")]
pub suffix: u8,
// `None` means not currently present.
pub current_value: Optional<StateDiffValue<E>>,
// `None` means value is not updated.
pub new_value: Optional<StateDiffValue<E>>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
pub struct StemStateDiff<E: EthSpec> {
pub stem: Stem<E>,
pub suffix_diffs: VariableList<SuffixStateDiff<E>, E::MaxVerkleWidth>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(struct_behaviour = "transparent")]
#[serde(transparent)]
pub struct StateDiff<E: EthSpec> {
pub inner: VariableList<StemStateDiff<E>, E::MaxStems>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
pub struct IpaProof<E: EthSpec> {
pub cl: FixedVector<BanderwagonGroupElement<E>, E::IpaProofDepth>,
pub cr: FixedVector<BanderwagonGroupElement<E>, E::IpaProofDepth>,
pub final_evaluation: BanderwagonFieldElement<E>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(struct_behaviour = "transparent")]
#[serde(transparent)]
pub struct StemValue<E: EthSpec> {
#[serde(with = "ssz_types::serde_utils::hex_fixed_vec")]
inner: FixedVector<u8, E::MaxStemLength>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
pub struct VerkleProof<E: EthSpec> {
pub other_stems: VariableList<StemValue<E>, E::MaxStems>,
#[serde(with = "ssz_types::serde_utils::hex_var_list")]
pub depth_extension_present: VariableList<u8, E::MaxStems>,
pub commitments_by_path: VariableList<BanderwagonGroupElement<E>, E::MaxCommittments>,
pub d: BanderwagonGroupElement<E>,
pub ipa_proof: IpaProof<E>,
}

#[derive(
Default,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[arbitrary(bound = "E: EthSpec")]
#[serde(bound = "E: EthSpec")]
pub struct ExecutionWitness<E: EthSpec> {
pub state_diff: StateDiff<E>,
pub verkle_proof: VerkleProof<E>,
}

0 comments on commit b786e6d

Please sign in to comment.