Skip to content

Commit

Permalink
Merge pull request #260 from ralexstokes/ssz
Browse files Browse the repository at this point in the history
re-export `ssz_rs` prelude in `ethereum-consensus`
  • Loading branch information
ralexstokes authored Sep 20, 2023
2 parents 02a70ad + d10b956 commit afbf742
Show file tree
Hide file tree
Showing 1,034 changed files with 38,994 additions and 27,557 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use ethereum_consensus::{
altair::mainnet as altair,
bellatrix::mainnet as bellatrix,
phase0::mainnet as phase0,
ssz::prelude::*,
state_transition::mainnet::{Context, ExecutionEngine, Executor},
};
use ssz_rs::prelude::*;
use std::error::Error;

fn main() -> std::result::Result<(), Box<dyn Error>> {
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/altair/beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
SignedVoluntaryExit,
},
primitives::{BlsSignature, Bytes32, Root, Slot, ValidatorIndex},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/altair/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
JUSTIFICATION_BITS_LENGTH,
},
primitives::{Bytes32, Gwei, ParticipationFlags, Root, Slot},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/altair/block_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ use crate::{
domains::DomainType,
primitives::{BlsPublicKey, ParticipationFlags, ValidatorIndex},
signing::compute_signing_root,
ssz::prelude::*,
state_transition::{
invalid_operation_error, Context, InvalidAttestation, InvalidDeposit, InvalidOperation,
InvalidSyncAggregate, Result,
},
};
use ssz_rs::prelude::*;
use std::{
collections::{HashMap, HashSet},
iter::zip,
Expand Down
1 change: 0 additions & 1 deletion ethereum-consensus/src/altair/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::{
phase0,
state_transition::{Context, Result},
};
use ssz_rs::prelude::*;

fn translate_participation<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/altair/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::{
Deposit, DepositData, Eth1Data, Fork, DEPOSIT_DATA_LIST_BOUND,
},
primitives::{Gwei, Hash32, GENESIS_EPOCH},
ssz::prelude::*,
state_transition::{Context, Result},
};
use ssz_rs::prelude::*;

pub fn initialize_beacon_state_from_eth1<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/altair/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use crate::{
crypto::{eth_aggregate_public_keys, hash},
domains::DomainType,
primitives::{BlsPublicKey, Epoch, Gwei, ParticipationFlags, ValidatorIndex},
ssz::prelude::Vector,
state_transition::{
invalid_operation_error, Context, Error, InvalidAttestation, InvalidOperation, Result,
},
};
use integer_sqrt::IntegerSquareRoot;
use ssz_rs::Vector;
use std::collections::HashSet;

// Return a new ``ParticipationFlags`` adding ``flag_index`` to ``flags``
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/altair/light_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
BeaconBlockHeader,
},
primitives::{Bytes32, Slot},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

pub const FINALIZED_ROOT_INDEX: usize = 105;
pub const FINALIZED_ROOT_INDEX_FLOOR_LOG_2: usize = 6;
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/altair/networking.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
altair::constants::SYNC_COMMITTEE_SUBNET_COUNT, phase0::networking::ATTESTATION_SUBNET_COUNT,
ssz::prelude::Bitvector,
};
use ssz_rs::prelude::Bitvector;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MetaData {
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/altair/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ pub use crate::{
};
use crate::{
crypto::{fast_aggregate_verify, hash, verify_signature},
ssz::*,
ssz::prelude::*,
};
use ssz_rs::prelude::*;
use std::{cmp, collections::HashSet};
pub fn process_proposer_slashing<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
6 changes: 4 additions & 2 deletions ethereum-consensus/src/altair/sync.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::primitives::{BlsPublicKey, BlsSignature};
use ssz_rs::prelude::*;
use crate::{
primitives::{BlsPublicKey, BlsSignature},
ssz::prelude::*,
};

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
6 changes: 4 additions & 2 deletions ethereum-consensus/src/altair/validator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::primitives::{BlsSignature, Root, Slot, ValidatorIndex};
use ssz_rs::prelude::*;
use crate::{
primitives::{BlsSignature, Root, Slot, ValidatorIndex},
ssz::prelude::*,
};

#[derive(Debug, Default, Clone, SimpleSerialize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/bellatrix/beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
SignedVoluntaryExit, SyncAggregate,
},
primitives::{BlsSignature, Bytes32, Root, Slot, ValidatorIndex},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/bellatrix/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
Validator, JUSTIFICATION_BITS_LENGTH,
},
primitives::{Bytes32, Gwei, ParticipationFlags, Root, Slot},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/bellatrix/blinded_beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
SignedVoluntaryExit, SyncAggregate,
},
primitives::{BlsSignature, Bytes32, Root, Slot, ValidatorIndex},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, Clone, SimpleSerialize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/bellatrix/block_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::{
process_randao, process_sync_aggregate, BeaconBlock, BeaconState, ExecutionEngine,
ExecutionPayload, ExecutionPayloadHeader, NewPayloadRequest,
},
ssz::prelude::*,
state_transition::{invalid_operation_error, Context, InvalidExecutionPayload, Result},
};
use ssz_rs::prelude::*;

pub fn process_execution_payload<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
1 change: 0 additions & 1 deletion ethereum-consensus/src/bellatrix/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
bellatrix::execution_payload::ExecutionPayload,
state_transition::{self, ExecutionEngineError, Result},
};
use ssz_rs::prelude::*;

pub struct NewPayloadRequest<
'a,
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/bellatrix/execution_payload.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::{
primitives::{Bytes32, ExecutionAddress, Hash32, Root, U256},
ssz::{ByteList, ByteVector},
ssz::prelude::*,
state_transition::Error,
};
use ssz_rs::prelude::*;

pub type Transaction<const MAX_BYTES_PER_TRANSACTION: usize> = ByteList<MAX_BYTES_PER_TRANSACTION>;

Expand Down
1 change: 0 additions & 1 deletion ethereum-consensus/src/bellatrix/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{
bellatrix::{BeaconState, Fork},
state_transition::Context,
};
use ssz_rs::prelude::*;

pub fn upgrade_to_bellatrix<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/bellatrix/fork_choice.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::primitives::Hash32;
use ssz_rs::prelude::*;
use crate::{primitives::Hash32, ssz::prelude::*};

#[derive(Default, Debug, SimpleSerialize, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/bellatrix/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::{
Deposit, DepositData, Eth1Data, ExecutionPayloadHeader, Fork, DEPOSIT_DATA_LIST_BOUND,
},
primitives::{Gwei, Hash32, GENESIS_EPOCH},
ssz::prelude::*,
state_transition::{Context, Result},
};
use ssz_rs::prelude::*;

pub fn initialize_beacon_state_from_eth1<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/bellatrix/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ use crate::{
eth_aggregate_public_keys, eth_fast_aggregate_verify, fast_aggregate_verify, hash,
verify_signature,
},
ssz::*,
ssz::prelude::*,
};
use integer_sqrt::IntegerSquareRoot;
use ssz_rs::prelude::*;
use std::{
cmp,
collections::{HashMap, HashSet},
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/bellatrix/state_transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::{
process_block, process_slots, verify_block_signature, BeaconState, ExecutionEngine,
SignedBeaconBlock,
},
ssz::prelude::Merkleized,
state_transition::{Context, Error, Result, Validation},
};
use ssz_rs::prelude::Merkleized;

// `state_transition_block_in_slot` is separated out
// to facilitate upgrades across forks which take place
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/builder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
phase0::compute_domain,
primitives::{BlsPublicKey, BlsSignature, Domain, DomainType, ExecutionAddress},
ssz::prelude::*,
state_transition::{Context, Error},
};
use ssz_rs::prelude::*;

#[derive(Debug, Clone, Default, SimpleSerialize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/capella/beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
Attestation, AttesterSlashing, Deposit, Eth1Data, ProposerSlashing, SignedVoluntaryExit,
},
primitives::{BlsSignature, Bytes32, Root, Slot, ValidatorIndex},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/capella/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
capella::ExecutionPayloadHeader,
phase0::{BeaconBlockHeader, Checkpoint, Eth1Data, Fork, Validator, JUSTIFICATION_BITS_LENGTH},
primitives::{Bytes32, Gwei, ParticipationFlags, Root, Slot, ValidatorIndex, WithdrawalIndex},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/capella/blinded_beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
Attestation, AttesterSlashing, Deposit, Eth1Data, ProposerSlashing, SignedVoluntaryExit,
},
primitives::{BlsSignature, Bytes32, Root, Slot, ValidatorIndex},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, Clone, SimpleSerialize)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/capella/block_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use crate::{
BeaconBlock, BeaconBlockBody, BeaconState, ExecutionEngine, ExecutionPayload,
ExecutionPayloadHeader, NewPayloadRequest, SignedBlsToExecutionChange,
},
ssz::prelude::*,
state_transition::{
invalid_operation_error, Context, InvalidDeposit, InvalidExecutionPayload,
InvalidOperation, Result,
},
};
use ssz_rs::prelude::*;

pub fn process_bls_to_execution_change<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
6 changes: 4 additions & 2 deletions ethereum-consensus/src/capella/bls_to_execution_change.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::primitives::{BlsPublicKey, BlsSignature, ExecutionAddress, ValidatorIndex};
use ssz_rs::prelude::*;
use crate::{
primitives::{BlsPublicKey, BlsSignature, ExecutionAddress, ValidatorIndex},
ssz::prelude::*,
};

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/capella/epoch_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::{
process_rewards_and_penalties, process_slashings, process_slashings_reset,
process_sync_committee_updates, BeaconState, HistoricalSummary,
},
ssz::prelude::*,
state_transition::{Context, Result},
};
use ssz_rs::prelude::*;

pub fn process_historical_summaries_update<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
1 change: 0 additions & 1 deletion ethereum-consensus/src/capella/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
capella::execution_payload::ExecutionPayload,
state_transition::{ExecutionEngineError, Result},
};
use ssz_rs::prelude::*;

pub struct NewPayloadRequest<
'a,
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/capella/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use crate::{
bellatrix::Transaction,
capella::withdrawal::Withdrawal,
primitives::{Bytes32, ExecutionAddress, Hash32, Root, U256},
ssz::{ByteList, ByteVector},
ssz::prelude::*,
state_transition::Error,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
1 change: 0 additions & 1 deletion ethereum-consensus/src/capella/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{
capella::{BeaconState, ExecutionPayloadHeader, Fork},
state_transition::Context,
};
use ssz_rs::prelude::*;

pub fn upgrade_to_capella<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/capella/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::{
Deposit, DepositData, Eth1Data, ExecutionPayloadHeader, Fork, DEPOSIT_DATA_LIST_BOUND,
},
primitives::{Gwei, Hash32, GENESIS_EPOCH},
ssz::prelude::*,
state_transition::{Context, Result},
};
use ssz_rs::prelude::*;

pub fn initialize_beacon_state_from_eth1<
const SLOTS_PER_HISTORICAL_ROOT: usize,
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/capella/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ use crate::{
eth_aggregate_public_keys, eth_fast_aggregate_verify, fast_aggregate_verify, hash,
verify_signature,
},
ssz::*,
ssz::prelude::*,
};
use integer_sqrt::IntegerSquareRoot;
use ssz_rs::prelude::*;
use std::{
cmp,
collections::{HashMap, HashSet},
Expand Down
6 changes: 4 additions & 2 deletions ethereum-consensus/src/capella/withdrawal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::primitives::{ExecutionAddress, Gwei, ValidatorIndex, WithdrawalIndex};
use ssz_rs::prelude::*;
use crate::{
primitives::{ExecutionAddress, Gwei, ValidatorIndex, WithdrawalIndex},
ssz::prelude::*,
};

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
3 changes: 1 addition & 2 deletions ethereum-consensus/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#[cfg(feature = "serde")]
use crate::serde::{try_bytes_from_hex_str, HexError};
use crate::{primitives::Bytes32, ssz::ByteVector};
use crate::{primitives::Bytes32, ssz::prelude::*};
use blst::{min_pk as bls_impl, BLST_ERROR};
use sha2::{digest::FixedOutput, Digest, Sha256};
use ssz_rs::prelude::*;
use std::{
fmt,
ops::{Deref, DerefMut},
Expand Down
2 changes: 1 addition & 1 deletion ethereum-consensus/src/deneb/beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
Attestation, AttesterSlashing, Deposit, Eth1Data, ProposerSlashing, SignedVoluntaryExit,
},
primitives::{BlsSignature, Bytes32, Root, Slot, ValidatorIndex},
ssz::prelude::*,
};
use ssz_rs::prelude::*;

#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
Loading

0 comments on commit afbf742

Please sign in to comment.