mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Merge remote-tracking branch 'origin/deneb-free-blobs' into tree-states-deneb
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::*;
|
||||
use derivative::Derivative;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use ssz_types::VariableList;
|
||||
use ssz_types::{FixedVector, VariableList};
|
||||
use std::marker::PhantomData;
|
||||
use superstruct::superstruct;
|
||||
use test_random_derive::TestRandom;
|
||||
@@ -11,6 +11,8 @@ use tree_hash_derive::TreeHash;
|
||||
|
||||
pub type KzgCommitments<T> =
|
||||
VariableList<KzgCommitment, <T as EthSpec>::MaxBlobCommitmentsPerBlock>;
|
||||
pub type KzgCommitmentOpts<T> =
|
||||
FixedVector<Option<KzgCommitment>, <T as EthSpec>::MaxBlobsPerBlock>;
|
||||
|
||||
/// The body of a `BeaconChain` block, containing operations.
|
||||
///
|
||||
|
||||
@@ -23,6 +23,19 @@ pub struct BlobIdentifier {
|
||||
pub index: u64,
|
||||
}
|
||||
|
||||
impl BlobIdentifier {
|
||||
pub fn get_all_blob_ids<E: EthSpec>(block_root: Hash256) -> Vec<BlobIdentifier> {
|
||||
let mut blob_ids = Vec::with_capacity(E::max_blobs_per_block());
|
||||
for i in 0..E::max_blobs_per_block() {
|
||||
blob_ids.push(BlobIdentifier {
|
||||
block_root,
|
||||
index: i as u64,
|
||||
});
|
||||
}
|
||||
blob_ids
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for BlobIdentifier {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
self.index.partial_cmp(&other.index)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::beacon_block_body::KzgCommitments;
|
||||
use crate::{
|
||||
BlobRootsList, ChainSpec, EthSpec, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb,
|
||||
ExecutionPayloadHeaderMerge, ExecutionPayloadHeaderRef, ForkName, ForkVersionDeserialize,
|
||||
KzgProofs, SignedRoot, Uint256,
|
||||
ExecutionPayloadHeaderMerge, ExecutionPayloadHeaderRef, ExecutionPayloadHeaderRefMut, ForkName,
|
||||
ForkVersionDeserialize, KzgProofs, SignedRoot, Uint256,
|
||||
};
|
||||
use bls::PublicKeyBytes;
|
||||
use bls::Signature;
|
||||
@@ -26,7 +26,8 @@ pub struct BlindedBlobsBundle<E: EthSpec> {
|
||||
derive(PartialEq, Debug, Serialize, Deserialize, TreeHash, Clone),
|
||||
serde(bound = "E: EthSpec", deny_unknown_fields)
|
||||
),
|
||||
map_ref_into(ExecutionPayloadHeaderRef)
|
||||
map_ref_into(ExecutionPayloadHeaderRef),
|
||||
map_ref_mut_into(ExecutionPayloadHeaderRefMut)
|
||||
)]
|
||||
#[derive(PartialEq, Debug, Serialize, Deserialize, TreeHash, Clone)]
|
||||
#[serde(bound = "E: EthSpec", deny_unknown_fields, untagged)]
|
||||
@@ -59,6 +60,14 @@ impl<'a, E: EthSpec> BuilderBidRef<'a, E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, E: EthSpec> BuilderBidRefMut<'a, E> {
|
||||
pub fn header_mut(self) -> ExecutionPayloadHeaderRefMut<'a, E> {
|
||||
map_builder_bid_ref_mut_into_execution_payload_header_ref_mut!(&'a _, self, |bid, cons| {
|
||||
cons(&mut bid.header)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> SignedRoot for BuilderBid<E> {}
|
||||
|
||||
/// Validator registration, for use in interacting with servers implementing the builder API.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::blob_sidecar::BlobIdentifier;
|
||||
use crate::*;
|
||||
use bls::Signature;
|
||||
use derivative::Derivative;
|
||||
@@ -257,30 +256,6 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> SignedBeaconBlock<E, Payload>
|
||||
.map(|c| c.len())
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
pub fn get_expected_blob_ids(&self, block_root: Option<Hash256>) -> Vec<BlobIdentifier> {
|
||||
self.get_filtered_blob_ids(block_root, |_, _| true)
|
||||
}
|
||||
|
||||
/// If the filter returns `true` the id for the corresponding index and root will be included.
|
||||
pub fn get_filtered_blob_ids(
|
||||
&self,
|
||||
block_root: Option<Hash256>,
|
||||
filter: impl Fn(usize, Hash256) -> bool,
|
||||
) -> Vec<BlobIdentifier> {
|
||||
let block_root = block_root.unwrap_or_else(|| self.canonical_root());
|
||||
let num_blobs_expected = self.num_expected_blobs();
|
||||
let mut blob_ids = Vec::with_capacity(num_blobs_expected);
|
||||
for i in 0..num_blobs_expected {
|
||||
if filter(i, block_root) {
|
||||
blob_ids.push(BlobIdentifier {
|
||||
block_root,
|
||||
index: i as u64,
|
||||
});
|
||||
}
|
||||
}
|
||||
blob_ids
|
||||
}
|
||||
}
|
||||
|
||||
// We can convert pre-Bellatrix blocks without payloads into blocks with payloads.
|
||||
|
||||
@@ -21,3 +21,17 @@ pub struct ValidatorRegistrationData {
|
||||
}
|
||||
|
||||
impl SignedRoot for ValidatorRegistrationData {}
|
||||
|
||||
impl SignedValidatorRegistrationData {
|
||||
pub fn verify_signature(&self, spec: &ChainSpec) -> bool {
|
||||
self.message
|
||||
.pubkey
|
||||
.decompress()
|
||||
.map(|pubkey| {
|
||||
let domain = spec.get_builder_domain();
|
||||
let message = self.message.signing_root(domain);
|
||||
self.signature.verify(&pubkey, message)
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user