mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
compile
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::beacon_block_body::{
|
||||
BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyMerge, BeaconBlockBodyRef,
|
||||
BeaconBlockBodyRefMut, BeaconBlockBodyEip4844
|
||||
BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyEip4844, BeaconBlockBodyMerge,
|
||||
BeaconBlockBodyRef, BeaconBlockBodyRefMut,
|
||||
};
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::*;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::kzg_commitment::KzgCommitment;
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::*;
|
||||
use derivative::Derivative;
|
||||
@@ -8,7 +9,6 @@ use std::marker::PhantomData;
|
||||
use superstruct::superstruct;
|
||||
use test_random_derive::TestRandom;
|
||||
use tree_hash_derive::TreeHash;
|
||||
use crate::kzg_commitment::KzgCommitment;
|
||||
|
||||
/// The body of a `BeaconChain` block, containing operations.
|
||||
///
|
||||
@@ -256,10 +256,10 @@ impl<E: EthSpec> From<BeaconBlockBodyMerge<E, FullPayload<E>>>
|
||||
}
|
||||
|
||||
impl<E: EthSpec> From<BeaconBlockBodyEip4844<E, FullPayload<E>>>
|
||||
for (
|
||||
BeaconBlockBodyEip4844<E, BlindedPayload<E>>,
|
||||
Option<ExecutionPayload<E>>,
|
||||
)
|
||||
for (
|
||||
BeaconBlockBodyEip4844<E, BlindedPayload<E>>,
|
||||
Option<ExecutionPayload<E>>,
|
||||
)
|
||||
{
|
||||
fn from(body: BeaconBlockBodyEip4844<E, FullPayload<E>>) -> Self {
|
||||
let BeaconBlockBodyEip4844 {
|
||||
@@ -272,7 +272,7 @@ for (
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: FullPayload { execution_payload},
|
||||
execution_payload: FullPayload { execution_payload },
|
||||
blob_kzg_commitments,
|
||||
} = body;
|
||||
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
use ssz_types::VariableList;
|
||||
use crate::bls_field_element::BlsFieldElement;
|
||||
use crate::test_utils::RngCore;
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::{EthSpec, Uint256};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use ssz::{Decode, DecodeError, Encode};
|
||||
use ssz_types::VariableList;
|
||||
use tree_hash::{PackedEncoding, TreeHash};
|
||||
use crate::test_utils::RngCore;
|
||||
use crate::bls_field_element::BlsFieldElement;
|
||||
use crate::{EthSpec, Uint256};
|
||||
use crate::test_utils::TestRandom;
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Hash, Clone, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct Blob<T: EthSpec>(pub VariableList<BlsFieldElement, T::FieldElementsPerBlob>);
|
||||
|
||||
impl <T: EthSpec> TestRandom for Blob<T> {
|
||||
impl<T: EthSpec> TestRandom for Blob<T> {
|
||||
fn random_for_test(rng: &mut impl RngCore) -> Self {
|
||||
let mut res = Blob(VariableList::empty());
|
||||
for i in 0..4096 {
|
||||
let slice = ethereum_types::U256([rng.next_u64(), rng.next_u64(), rng.next_u64(), rng.next_u64()]);
|
||||
let elem =BlsFieldElement(slice);
|
||||
let slice = ethereum_types::U256([
|
||||
rng.next_u64(),
|
||||
rng.next_u64(),
|
||||
rng.next_u64(),
|
||||
rng.next_u64(),
|
||||
]);
|
||||
let elem = BlsFieldElement(slice);
|
||||
res.0.push(elem);
|
||||
}
|
||||
res
|
||||
@@ -60,7 +65,7 @@ impl<T: EthSpec> TreeHash for Blob<T> {
|
||||
<VariableList<BlsFieldElement, T::FieldElementsPerBlob>>::tree_hash_type()
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding{
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
self.0.tree_hash_packed_encoding()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::kzg_proof::KzgProof;
|
||||
use crate::{Blob, EthSpec, Hash256, Slot};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz::Encode;
|
||||
@@ -5,7 +6,6 @@ use ssz_derive::{Decode, Encode};
|
||||
use ssz_types::VariableList;
|
||||
use tree_hash::TreeHash;
|
||||
use tree_hash_derive::TreeHash;
|
||||
use crate::kzg_proof::KzgProof;
|
||||
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq, Default)]
|
||||
@@ -24,6 +24,6 @@ impl<E: EthSpec> BlobsSidecar<E> {
|
||||
// Fixed part
|
||||
Self::empty().as_ssz_bytes().len()
|
||||
// Max size of variable length `blobs` field
|
||||
+ (E::max_object_list_size() * <Blob<E::FieldElementsPerBlob> as Encode>::ssz_fixed_len())
|
||||
+ (E::max_blobs_per_block() * <Blob<E::FieldElementsPerBlob> as Encode>::ssz_fixed_len())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use tree_hash::{PackedEncoding, TreeHash};
|
||||
#[serde(transparent)]
|
||||
pub struct BlsFieldElement(pub Uint256);
|
||||
|
||||
|
||||
impl Encode for BlsFieldElement {
|
||||
fn is_ssz_fixed_len() -> bool {
|
||||
<Uint256 as Encode>::is_ssz_fixed_len()
|
||||
@@ -45,7 +44,7 @@ impl TreeHash for BlsFieldElement {
|
||||
<Uint256>::tree_hash_type()
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding{
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
self.0.tree_hash_packed_encoding()
|
||||
}
|
||||
|
||||
|
||||
@@ -246,9 +246,8 @@ impl ChainSpec {
|
||||
Some(fork_epoch) if epoch >= fork_epoch => ForkName::Altair,
|
||||
_ => ForkName::Base,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Returns the fork version for a named fork.
|
||||
|
||||
@@ -228,7 +228,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
|
||||
Self::BytesPerLogsBloom::to_usize()
|
||||
}
|
||||
|
||||
fn max_object_list_size() -> usize {
|
||||
fn max_blobs_per_block() -> usize {
|
||||
Self::MaxBlobsPerBlock::to_usize()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use crate::{test_utils::TestRandom, test_utils::RngCore, *, kzg_commitment::KzgCommitment, kzg_proof::KzgProof, blob::Blob};
|
||||
use crate::{
|
||||
blob::Blob, kzg_commitment::KzgCommitment, kzg_proof::KzgProof, test_utils::RngCore,
|
||||
test_utils::TestRandom, *,
|
||||
};
|
||||
use derivative::Derivative;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz::Encode;
|
||||
|
||||
@@ -50,10 +50,7 @@ impl ForkContext {
|
||||
if spec.eip4844_fork_epoch.is_some() {
|
||||
fork_to_digest.push((
|
||||
ForkName::Eip4844,
|
||||
ChainSpec::compute_fork_digest(
|
||||
spec.eip4844_fork_version,
|
||||
genesis_validators_root,
|
||||
),
|
||||
ChainSpec::compute_fork_digest(spec.eip4844_fork_version, genesis_validators_root),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,17 @@ pub enum ForkName {
|
||||
Base,
|
||||
Altair,
|
||||
Merge,
|
||||
Eip4844
|
||||
Eip4844,
|
||||
}
|
||||
|
||||
impl ForkName {
|
||||
pub fn list_all() -> Vec<ForkName> {
|
||||
vec![ForkName::Base, ForkName::Altair, ForkName::Merge, ForkName::Eip4844]
|
||||
vec![
|
||||
ForkName::Base,
|
||||
ForkName::Altair,
|
||||
ForkName::Merge,
|
||||
ForkName::Eip4844,
|
||||
]
|
||||
}
|
||||
|
||||
/// Set the activation slots in the given `ChainSpec` so that the fork named by `self`
|
||||
|
||||
@@ -14,7 +14,7 @@ impl TreeHash for KzgCommitment {
|
||||
<[u8; 48] as TreeHash>::tree_hash_type()
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding{
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
self.0.tree_hash_packed_encoding()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::fmt;
|
||||
use crate::test_utils::{RngCore, TestRandom};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use ssz::{Decode, DecodeError, Encode};
|
||||
use std::fmt;
|
||||
use tree_hash::{PackedEncoding, TreeHash};
|
||||
use crate::test_utils::{RngCore, TestRandom};
|
||||
|
||||
const KZG_PROOF_BYTES_LEN: usize = 48;
|
||||
|
||||
@@ -35,19 +35,19 @@ impl Into<[u8; KZG_PROOF_BYTES_LEN]> for KzgProof {
|
||||
}
|
||||
|
||||
pub mod serde_kzg_proof {
|
||||
use serde::de::Error;
|
||||
use super::*;
|
||||
use serde::de::Error;
|
||||
|
||||
pub fn serialize<S>(bytes: &[u8; KZG_PROOF_BYTES_LEN], serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(ð2_serde_utils::hex::encode(bytes))
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<[u8; KZG_PROOF_BYTES_LEN], D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s: String = Deserialize::deserialize(deserializer)?;
|
||||
|
||||
|
||||
@@ -90,12 +90,12 @@ pub mod slot_data;
|
||||
#[cfg(feature = "sqlite")]
|
||||
pub mod sqlite;
|
||||
|
||||
pub mod blob;
|
||||
pub mod blobs_sidecar;
|
||||
pub mod bls_field_element;
|
||||
pub mod kzg_commitment;
|
||||
pub mod kzg_proof;
|
||||
pub mod bls_field_element;
|
||||
pub mod blob;
|
||||
pub mod signed_blobs_sidecar;
|
||||
pub mod blobs_sidecar;
|
||||
|
||||
use ethereum_types::{H160, H256};
|
||||
|
||||
@@ -105,12 +105,12 @@ pub use crate::attestation_data::AttestationData;
|
||||
pub use crate::attestation_duty::AttestationDuty;
|
||||
pub use crate::attester_slashing::AttesterSlashing;
|
||||
pub use crate::beacon_block::{
|
||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, BeaconBlockRef,
|
||||
BeaconBlockRefMut, BeaconBlockEip4844
|
||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockEip4844, BeaconBlockMerge,
|
||||
BeaconBlockRef, BeaconBlockRefMut,
|
||||
};
|
||||
pub use crate::beacon_block_body::{
|
||||
BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyMerge,
|
||||
BeaconBlockBodyRef, BeaconBlockBodyRefMut, BeaconBlockBodyEip4844
|
||||
BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyEip4844,
|
||||
BeaconBlockBodyMerge, BeaconBlockBodyRef, BeaconBlockBodyRefMut,
|
||||
};
|
||||
pub use crate::beacon_block_header::BeaconBlockHeader;
|
||||
pub use crate::beacon_committee::{BeaconCommittee, OwnedBeaconCommittee};
|
||||
@@ -139,6 +139,8 @@ pub use crate::free_attestation::FreeAttestation;
|
||||
pub use crate::graffiti::{Graffiti, GRAFFITI_BYTES_LEN};
|
||||
pub use crate::historical_batch::HistoricalBatch;
|
||||
pub use crate::indexed_attestation::IndexedAttestation;
|
||||
pub use crate::kzg_commitment::KzgCommitment;
|
||||
pub use crate::kzg_proof::KzgProof;
|
||||
pub use crate::participation_flags::ParticipationFlags;
|
||||
pub use crate::participation_list::ParticipationList;
|
||||
pub use crate::payload::{BlindedPayload, BlockType, ExecPayload, FullPayload};
|
||||
@@ -151,8 +153,8 @@ pub use crate::selection_proof::SelectionProof;
|
||||
pub use crate::shuffling_id::AttestationShufflingId;
|
||||
pub use crate::signed_aggregate_and_proof::SignedAggregateAndProof;
|
||||
pub use crate::signed_beacon_block::{
|
||||
SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockHash,
|
||||
SignedBeaconBlockMerge, SignedBlindedBeaconBlock, SignedBeaconBlockEip4844,
|
||||
SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockEip4844,
|
||||
SignedBeaconBlockHash, SignedBeaconBlockMerge, SignedBlindedBeaconBlock,
|
||||
};
|
||||
pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader;
|
||||
pub use crate::signed_contribution_and_proof::SignedContributionAndProof;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::{test_utils::TestRandom, *};
|
||||
use core::hash::Hasher;
|
||||
use derivative::Derivative;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -8,7 +9,6 @@ use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use test_random_derive::TestRandom;
|
||||
use tree_hash::{PackedEncoding, TreeHash};
|
||||
use core::hash::Hasher;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum BlockType {
|
||||
|
||||
@@ -319,26 +319,26 @@ impl<E: EthSpec> SignedBeaconBlockEip4844<E, BlindedPayload<E>> {
|
||||
) -> SignedBeaconBlockEip4844<E, FullPayload<E>> {
|
||||
let SignedBeaconBlockEip4844 {
|
||||
message:
|
||||
BeaconBlockEip4844 {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root,
|
||||
body:
|
||||
BeaconBlockBodyEip4844 {
|
||||
randao_reveal,
|
||||
eth1_data,
|
||||
graffiti,
|
||||
proposer_slashings,
|
||||
attester_slashings,
|
||||
attestations,
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: BlindedPayload { .. },
|
||||
blob_kzg_commitments,
|
||||
BeaconBlockEip4844 {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root,
|
||||
body:
|
||||
BeaconBlockBodyEip4844 {
|
||||
randao_reveal,
|
||||
eth1_data,
|
||||
graffiti,
|
||||
proposer_slashings,
|
||||
attester_slashings,
|
||||
attestations,
|
||||
deposits,
|
||||
voluntary_exits,
|
||||
sync_aggregate,
|
||||
execution_payload: BlindedPayload { .. },
|
||||
blob_kzg_commitments,
|
||||
},
|
||||
},
|
||||
},
|
||||
signature,
|
||||
} = self;
|
||||
SignedBeaconBlockEip4844 {
|
||||
|
||||
Reference in New Issue
Block a user