From b786e6d8e064588d000e22a025c201b1a833b7b0 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Wed, 10 Apr 2024 03:47:05 -0400 Subject: [PATCH] Beta compiler fixes (#5543) * remove duplicate imports in gossip tests. get rid of duplicate trait bound locations * more double import fixes * cargo fmt --- .../gossipsub/src/behaviour/tests.rs | 8 +- .../gossipsub/src/config.rs | 1 - .../gossipsub/src/mcache.rs | 4 +- .../gossipsub/src/protocol.rs | 1 - .../gossipsub/src/subscription_filter.rs | 1 - beacon_node/operation_pool/src/lib.rs | 4 +- consensus/types/src/chain_spec.rs | 1 - consensus/types/src/execution_witness.rs | 257 ++++++++++++++++++ 8 files changed, 262 insertions(+), 15 deletions(-) create mode 100644 consensus/types/src/execution_witness.rs diff --git a/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs b/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs index 85f1ef5024a..2af0199ec93 100644 --- a/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs +++ b/beacon_node/lighthouse_network/gossipsub/src/behaviour/tests.rs @@ -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; diff --git a/beacon_node/lighthouse_network/gossipsub/src/config.rs b/beacon_node/lighthouse_network/gossipsub/src/config.rs index c91622a8dcf..1296e614c89 100644 --- a/beacon_node/lighthouse_network/gossipsub/src/config.rs +++ b/beacon_node/lighthouse_network/gossipsub/src/config.rs @@ -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; diff --git a/beacon_node/lighthouse_network/gossipsub/src/mcache.rs b/beacon_node/lighthouse_network/gossipsub/src/mcache.rs index 407164086be..eced0456d68 100644 --- a/beacon_node/lighthouse_network/gossipsub/src/mcache.rs +++ b/beacon_node/lighthouse_network/gossipsub/src/mcache.rs @@ -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| { diff --git a/beacon_node/lighthouse_network/gossipsub/src/protocol.rs b/beacon_node/lighthouse_network/gossipsub/src/protocol.rs index ca219f8ac7c..ba84ae0aa7a 100644 --- a/beacon_node/lighthouse_network/gossipsub/src/protocol.rs +++ b/beacon_node/lighthouse_network/gossipsub/src/protocol.rs @@ -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; diff --git a/beacon_node/lighthouse_network/gossipsub/src/subscription_filter.rs b/beacon_node/lighthouse_network/gossipsub/src/subscription_filter.rs index 09c323d7904..02bb9b4eab6 100644 --- a/beacon_node/lighthouse_network/gossipsub/src/subscription_filter.rs +++ b/beacon_node/lighthouse_network/gossipsub/src/subscription_filter.rs @@ -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() { diff --git a/beacon_node/operation_pool/src/lib.rs b/beacon_node/operation_pool/src/lib.rs index 6e62a2aeeec..9447e187542 100644 --- a/beacon_node/operation_pool/src/lib.rs +++ b/beacon_node/operation_pool/src/lib.rs @@ -708,7 +708,7 @@ impl OperationPool { } /// 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, @@ -718,7 +718,7 @@ where I: IntoIterator, F: Fn(&T) -> bool, G: Fn(&T) -> V, - T: Clone, + T: Clone + 'a, { operations .into_iter() diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index 3893610454d..56329e6ba4c 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -1640,7 +1640,6 @@ where mod tests { use super::*; use itertools::Itertools; - use safe_arith::SafeArith; #[test] fn test_mainnet_spec_can_be_constructed() { diff --git a/consensus/types/src/execution_witness.rs b/consensus/types/src/execution_witness.rs new file mode 100644 index 00000000000..c5fdcd20e0b --- /dev/null +++ b/consensus/types/src/execution_witness.rs @@ -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 { + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] + inner: FixedVector, +} + +#[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 { + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] + inner: FixedVector, +} + +#[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 { + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] + inner: FixedVector, +} + +#[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 { + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] + inner: FixedVector, +} + +#[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 { + //#[serde(with = "eth2_serde_utils::quoted_u8")] + pub suffix: u8, + // `None` means not currently present. + pub current_value: Optional>, + // `None` means value is not updated. + pub new_value: Optional>, +} + +#[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 { + pub stem: Stem, + pub suffix_diffs: VariableList, 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 { + pub inner: VariableList, 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 { + pub cl: FixedVector, E::IpaProofDepth>, + pub cr: FixedVector, E::IpaProofDepth>, + pub final_evaluation: BanderwagonFieldElement, +} + +#[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 { + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] + inner: FixedVector, +} + +#[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 { + pub other_stems: VariableList, E::MaxStems>, + #[serde(with = "ssz_types::serde_utils::hex_var_list")] + pub depth_extension_present: VariableList, + pub commitments_by_path: VariableList, E::MaxCommittments>, + pub d: BanderwagonGroupElement, + pub ipa_proof: IpaProof, +} + +#[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 { + pub state_diff: StateDiff, + pub verkle_proof: VerkleProof, +}