mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
Add new field
This commit is contained in:
@@ -29,10 +29,12 @@ use types::{
|
||||
Address, Attestation, AttestationElectra, AttesterSlashing, AttesterSlashingElectra,
|
||||
BeaconBlock, BeaconBlockBodyGloas, BeaconBlockBodyHeze, BeaconBlockGloas, BeaconBlockHeze,
|
||||
BeaconState, BeaconStateError, BuilderIndex, ChainSpec, Deposit, Eth1Data, EthSpec,
|
||||
ExecutionBlockHash, ExecutionPayloadBid, ExecutionPayloadEnvelope, ExecutionPayloadGloas,
|
||||
ExecutionBlockHash, ExecutionPayloadBidGloas, ExecutionPayloadBidHeze,
|
||||
ExecutionPayloadEnvelope, ExecutionPayloadGloas,
|
||||
ExecutionRequests, FullPayload, Graffiti, Hash256, PayloadAttestation, ProposerSlashing,
|
||||
RelativeEpoch, SignedBeaconBlock, SignedBlsToExecutionChange, SignedExecutionPayloadBid,
|
||||
SignedExecutionPayloadEnvelope, SignedVoluntaryExit, Slot, SyncAggregate, Withdrawal,
|
||||
RelativeEpoch, SignedBeaconBlock, SignedBlsToExecutionChange, SignedExecutionPayloadBidGloas,
|
||||
SignedExecutionPayloadBidHeze, SignedExecutionPayloadEnvelope, SignedVoluntaryExit, Slot,
|
||||
SyncAggregate, Withdrawal,
|
||||
Withdrawals,
|
||||
};
|
||||
|
||||
@@ -512,7 +514,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
fn complete_partial_beacon_block_gloas(
|
||||
&self,
|
||||
partial_beacon_block: PartialBeaconBlock<T::EthSpec>,
|
||||
signed_execution_payload_bid: SignedExecutionPayloadBid<T::EthSpec>,
|
||||
signed_execution_payload_bid: SignedExecutionPayloadBidGloas<T::EthSpec>,
|
||||
parent_execution_requests: ExecutionRequests<T::EthSpec>,
|
||||
payload_data: Option<ExecutionPayloadData<T::EthSpec>>,
|
||||
mut state: BeaconState<T::EthSpec>,
|
||||
@@ -584,42 +586,63 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
_phantom: PhantomData::<FullPayload<T::EthSpec>>,
|
||||
},
|
||||
}),
|
||||
BeaconState::Heze(_) => BeaconBlock::Heze(BeaconBlockHeze {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::ZERO,
|
||||
body: BeaconBlockBodyHeze {
|
||||
randao_reveal,
|
||||
eth1_data,
|
||||
graffiti,
|
||||
proposer_slashings: proposer_slashings
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
attester_slashings: attester_slashings
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
attestations: attestations
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
deposits: deposits
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
voluntary_exits: voluntary_exits
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
sync_aggregate,
|
||||
bls_to_execution_changes: bls_to_execution_changes
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
parent_execution_requests,
|
||||
signed_execution_payload_bid,
|
||||
payload_attestations: payload_attestations
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
_phantom: PhantomData::<FullPayload<T::EthSpec>>,
|
||||
},
|
||||
}),
|
||||
BeaconState::Heze(_) => {
|
||||
let gloas_bid = signed_execution_payload_bid;
|
||||
let heze_bid = SignedExecutionPayloadBidHeze {
|
||||
message: ExecutionPayloadBidHeze {
|
||||
parent_block_hash: gloas_bid.message.parent_block_hash,
|
||||
parent_block_root: gloas_bid.message.parent_block_root,
|
||||
block_hash: gloas_bid.message.block_hash,
|
||||
prev_randao: gloas_bid.message.prev_randao,
|
||||
fee_recipient: gloas_bid.message.fee_recipient,
|
||||
gas_limit: gloas_bid.message.gas_limit,
|
||||
builder_index: gloas_bid.message.builder_index,
|
||||
slot: gloas_bid.message.slot,
|
||||
value: gloas_bid.message.value,
|
||||
execution_payment: gloas_bid.message.execution_payment,
|
||||
blob_kzg_commitments: gloas_bid.message.blob_kzg_commitments,
|
||||
execution_requests_root: gloas_bid.message.execution_requests_root,
|
||||
inclusion_list_bits: Default::default(),
|
||||
},
|
||||
signature: gloas_bid.signature,
|
||||
};
|
||||
BeaconBlock::Heze(BeaconBlockHeze {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::ZERO,
|
||||
body: BeaconBlockBodyHeze {
|
||||
randao_reveal,
|
||||
eth1_data,
|
||||
graffiti,
|
||||
proposer_slashings: proposer_slashings
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
attester_slashings: attester_slashings
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
attestations: attestations
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
deposits: deposits
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
voluntary_exits: voluntary_exits
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
sync_aggregate,
|
||||
bls_to_execution_changes: bls_to_execution_changes
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
parent_execution_requests,
|
||||
signed_execution_payload_bid: heze_bid,
|
||||
payload_attestations: payload_attestations
|
||||
.try_into()
|
||||
.map_err(BlockProductionError::SszTypesError)?,
|
||||
_phantom: PhantomData::<FullPayload<T::EthSpec>>,
|
||||
},
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
let signed_beacon_block = SignedBeaconBlock::from_block(
|
||||
@@ -750,7 +773,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
builder_index: BuilderIndex,
|
||||
) -> Result<
|
||||
(
|
||||
SignedExecutionPayloadBid<T::EthSpec>,
|
||||
SignedExecutionPayloadBidGloas<T::EthSpec>,
|
||||
BeaconState<T::EthSpec>,
|
||||
LocalBuildResult<T::EthSpec>,
|
||||
),
|
||||
@@ -798,10 +821,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
let parent_block_hash =
|
||||
if parent_payload_status == PayloadStatus::Full || parent_is_pre_gloas {
|
||||
// Build on parent bid's payload.
|
||||
parent_bid.block_hash
|
||||
parent_bid.block_hash()
|
||||
} else {
|
||||
// Skip parent bid's payload. For genesis this is the EL genesis hash.
|
||||
parent_bid.parent_block_hash
|
||||
parent_bid.parent_block_hash()
|
||||
};
|
||||
|
||||
// TODO(gloas) this should be BlockProductionVersion::V4
|
||||
@@ -833,7 +856,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
|
||||
// TODO(gloas) since we are defaulting to local building, execution payment is 0
|
||||
// execution payment should only be set to > 0 for trusted building.
|
||||
let bid = ExecutionPayloadBid::<T::EthSpec> {
|
||||
let bid = ExecutionPayloadBidGloas::<T::EthSpec> {
|
||||
parent_block_hash,
|
||||
parent_block_root: parent_root,
|
||||
block_hash: payload.block_hash,
|
||||
@@ -858,7 +881,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
};
|
||||
|
||||
Ok((
|
||||
SignedExecutionPayloadBid {
|
||||
SignedExecutionPayloadBidGloas {
|
||||
message: bid,
|
||||
signature: Signature::infinity().map_err(BlockProductionError::BlsError)?,
|
||||
},
|
||||
@@ -875,11 +898,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
/// parent_block_root)` of the local bid, then choose the winner.
|
||||
fn select_payload_bid(
|
||||
&self,
|
||||
local_signed_bid: SignedExecutionPayloadBid<T::EthSpec>,
|
||||
local_signed_bid: SignedExecutionPayloadBidGloas<T::EthSpec>,
|
||||
local_build: LocalBuildResult<T::EthSpec>,
|
||||
builder_boost_factor: Option<u64>,
|
||||
) -> (
|
||||
SignedExecutionPayloadBid<T::EthSpec>,
|
||||
SignedExecutionPayloadBidGloas<T::EthSpec>,
|
||||
Option<ExecutionPayloadData<T::EthSpec>>,
|
||||
) {
|
||||
let cached_bid = self.gossip_verified_payload_bid_cache.get_highest_bid(
|
||||
@@ -907,12 +930,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
///
|
||||
/// `cached_bid.value` is in gwei (`u64`); `payload_value` is in wei (`Uint256`); compared in wei.
|
||||
pub(crate) fn select_payload_bid_pure<E: EthSpec>(
|
||||
local_signed_bid: SignedExecutionPayloadBid<E>,
|
||||
local_signed_bid: SignedExecutionPayloadBidGloas<E>,
|
||||
local_build: LocalBuildResult<E>,
|
||||
cached_bid: Option<Arc<SignedExecutionPayloadBid<E>>>,
|
||||
cached_bid: Option<Arc<SignedExecutionPayloadBidGloas<E>>>,
|
||||
builder_boost_factor: Option<u64>,
|
||||
) -> (
|
||||
SignedExecutionPayloadBid<E>,
|
||||
SignedExecutionPayloadBidGloas<E>,
|
||||
Option<ExecutionPayloadData<E>>,
|
||||
) {
|
||||
let LocalBuildResult {
|
||||
@@ -993,9 +1016,9 @@ fn get_execution_payload_gloas<T: BeaconChainTypes>(
|
||||
|
||||
// TODO(gloas): this gas limit calc is not necessarily right
|
||||
let parent_bid = state.latest_execution_payload_bid()?;
|
||||
let latest_gas_limit = parent_bid.gas_limit;
|
||||
let latest_gas_limit = parent_bid.gas_limit();
|
||||
|
||||
let is_parent_block_full = parent_block_hash == parent_bid.block_hash;
|
||||
let is_parent_block_full = parent_block_hash == parent_bid.block_hash();
|
||||
|
||||
let withdrawals = if is_parent_block_full {
|
||||
if let Some(envelope) = parent_envelope {
|
||||
@@ -1306,9 +1329,9 @@ mod tests {
|
||||
types::Uint256::from(n).saturating_mul(types::Uint256::from(1_000_000_000u64))
|
||||
}
|
||||
|
||||
fn local_bid() -> SignedExecutionPayloadBid<TestSpec> {
|
||||
SignedExecutionPayloadBid {
|
||||
message: ExecutionPayloadBid {
|
||||
fn local_bid() -> SignedExecutionPayloadBidGloas<TestSpec> {
|
||||
SignedExecutionPayloadBidGloas {
|
||||
message: ExecutionPayloadBidGloas {
|
||||
builder_index: BUILDER_INDEX_SELF_BUILD,
|
||||
..Default::default()
|
||||
},
|
||||
@@ -1316,9 +1339,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn cached_bid(value_gwei: u64) -> Arc<SignedExecutionPayloadBid<TestSpec>> {
|
||||
Arc::new(SignedExecutionPayloadBid {
|
||||
message: ExecutionPayloadBid {
|
||||
fn cached_bid(value_gwei: u64) -> Arc<SignedExecutionPayloadBidGloas<TestSpec>> {
|
||||
Arc::new(SignedExecutionPayloadBidGloas {
|
||||
message: ExecutionPayloadBidGloas {
|
||||
builder_index: REMOTE_BUILDER,
|
||||
value: value_gwei,
|
||||
..Default::default()
|
||||
|
||||
@@ -889,10 +889,10 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
|
||||
|
||||
// [New in Gloas]: Verify bid.parent_block_root matches block.parent_root.
|
||||
if let Ok(bid) = block.message().body().signed_execution_payload_bid()
|
||||
&& bid.message.parent_block_root != block.message().parent_root()
|
||||
&& bid.message().parent_block_root() != block.message().parent_root()
|
||||
{
|
||||
return Err(BlockError::BidParentRootMismatch {
|
||||
bid_parent_root: bid.message.parent_block_root,
|
||||
bid_parent_root: bid.message().parent_block_root(),
|
||||
block_parent_root: block.message().parent_root(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ use state_processing::signature_sets::{
|
||||
};
|
||||
use tracing::debug;
|
||||
use types::{
|
||||
BeaconState, ChainSpec, EthSpec, ExecutionPayloadBid, SignedExecutionPayloadBid,
|
||||
SignedProposerPreferences, Slot,
|
||||
BeaconState, ChainSpec, EthSpec, ExecutionPayloadBidGloas, SignedExecutionPayloadBidGloas,
|
||||
SignedExecutionPayloadBidRef, SignedProposerPreferences, Slot,
|
||||
};
|
||||
|
||||
/// Verify that an execution payload bid is consistent with the current chain state
|
||||
/// and proposer preferences.
|
||||
pub(crate) fn verify_bid_consistency<E: EthSpec>(
|
||||
bid: &ExecutionPayloadBid<E>,
|
||||
bid: &ExecutionPayloadBidGloas<E>,
|
||||
current_slot: Slot,
|
||||
proposer_preferences: &SignedProposerPreferences,
|
||||
head_state: &BeaconState<E>,
|
||||
@@ -85,7 +85,7 @@ pub struct GossipVerificationContext<'a, T: BeaconChainTypes> {
|
||||
pub spec: &'a ChainSpec,
|
||||
}
|
||||
|
||||
/// A wrapper around a `SignedExecutionPayloadBid` that indicates it has been approved for re-gossiping on
|
||||
/// A wrapper around a `SignedExecutionPayloadBidGloas` that indicates it has been approved for re-gossiping on
|
||||
/// the p2p network.
|
||||
#[derive(Educe)]
|
||||
#[educe(
|
||||
@@ -93,12 +93,12 @@ pub struct GossipVerificationContext<'a, T: BeaconChainTypes> {
|
||||
Clone(bound = "T: BeaconChainTypes")
|
||||
)]
|
||||
pub struct GossipVerifiedPayloadBid<T: BeaconChainTypes> {
|
||||
pub signed_bid: Arc<SignedExecutionPayloadBid<T::EthSpec>>,
|
||||
pub signed_bid: Arc<SignedExecutionPayloadBidGloas<T::EthSpec>>,
|
||||
}
|
||||
|
||||
impl<T: BeaconChainTypes> GossipVerifiedPayloadBid<T> {
|
||||
pub fn new(
|
||||
signed_bid: Arc<SignedExecutionPayloadBid<T::EthSpec>>,
|
||||
signed_bid: Arc<SignedExecutionPayloadBidGloas<T::EthSpec>>,
|
||||
ctx: &GossipVerificationContext<'_, T>,
|
||||
) -> Result<Self, PayloadBidError> {
|
||||
let bid_slot = signed_bid.message.slot;
|
||||
@@ -177,7 +177,7 @@ impl<T: BeaconChainTypes> GossipVerifiedPayloadBid<T> {
|
||||
execution_payload_bid_signature_set(
|
||||
head_state,
|
||||
|i| get_builder_pubkey_from_state(head_state, i),
|
||||
&signed_bid,
|
||||
SignedExecutionPayloadBidRef::Gloas(&signed_bid),
|
||||
ctx.spec,
|
||||
)
|
||||
.map_err(|_| PayloadBidError::BadSignature)?
|
||||
@@ -219,7 +219,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
/// Returns an `Err` if the given bid was invalid, or an error was encountered during verification.
|
||||
pub fn verify_payload_bid_for_gossip(
|
||||
&self,
|
||||
bid: Arc<SignedExecutionPayloadBid<T::EthSpec>>,
|
||||
bid: Arc<SignedExecutionPayloadBidGloas<T::EthSpec>>,
|
||||
) -> Result<GossipVerifiedPayloadBid<T>, PayloadBidError> {
|
||||
let slot = bid.message.slot;
|
||||
let parent_block_root = bid.message.parent_block_root;
|
||||
@@ -269,7 +269,7 @@ mod tests {
|
||||
use kzg::KzgCommitment;
|
||||
use ssz_types::VariableList;
|
||||
use types::{
|
||||
Address, BeaconState, ChainSpec, EthSpec, ExecutionPayloadBid, MinimalEthSpec,
|
||||
Address, BeaconState, ChainSpec, EthSpec, ExecutionPayloadBidGloas, MinimalEthSpec,
|
||||
ProposerPreferences, SignedProposerPreferences, Slot,
|
||||
};
|
||||
|
||||
@@ -278,13 +278,13 @@ mod tests {
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
|
||||
fn make_bid(slot: Slot, fee_recipient: Address, gas_limit: u64) -> ExecutionPayloadBid<E> {
|
||||
ExecutionPayloadBid {
|
||||
fn make_bid(slot: Slot, fee_recipient: Address, gas_limit: u64) -> ExecutionPayloadBidGloas<E> {
|
||||
ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
fee_recipient,
|
||||
gas_limit,
|
||||
value: 100,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
BeaconChainTypes, payload_bid_verification::gossip_verified_bid::GossipVerifiedPayloadBid,
|
||||
};
|
||||
use parking_lot::RwLock;
|
||||
use types::{BuilderIndex, ExecutionBlockHash, Hash256, SignedExecutionPayloadBid, Slot};
|
||||
use types::{BuilderIndex, ExecutionBlockHash, Hash256, SignedExecutionPayloadBidGloas, Slot};
|
||||
|
||||
type HighestBidMap<T> =
|
||||
BTreeMap<Slot, HashMap<(ExecutionBlockHash, Hash256), GossipVerifiedPayloadBid<T>>>;
|
||||
@@ -33,7 +33,7 @@ impl<T: BeaconChainTypes> GossipVerifiedPayloadBidCache<T> {
|
||||
slot: Slot,
|
||||
parent_block_hash: ExecutionBlockHash,
|
||||
parent_block_root: Hash256,
|
||||
) -> Option<Arc<SignedExecutionPayloadBid<T::EthSpec>>> {
|
||||
) -> Option<Arc<SignedExecutionPayloadBidGloas<T::EthSpec>>> {
|
||||
self.highest_bid.read().get(&slot).and_then(|map| {
|
||||
map.get(&(parent_block_hash, parent_block_root))
|
||||
.map(|b| b.signed_bid.clone())
|
||||
@@ -52,6 +52,7 @@ impl<T: BeaconChainTypes> GossipVerifiedPayloadBidCache<T> {
|
||||
|
||||
if let Some(existing) = slot_map.get(&key)
|
||||
&& existing.signed_bid.message.value >= bid.signed_bid.message.value
|
||||
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -93,8 +94,8 @@ mod tests {
|
||||
|
||||
use bls::Signature;
|
||||
use types::{
|
||||
ExecutionBlockHash, ExecutionPayloadBid, Hash256, MinimalEthSpec,
|
||||
SignedExecutionPayloadBid, Slot,
|
||||
ExecutionBlockHash, ExecutionPayloadBidGloas, Hash256, MinimalEthSpec,
|
||||
SignedExecutionPayloadBidGloas, Slot,
|
||||
};
|
||||
|
||||
use super::GossipVerifiedPayloadBidCache;
|
||||
@@ -114,14 +115,14 @@ mod tests {
|
||||
value: u64,
|
||||
) -> GossipVerifiedPayloadBid<T> {
|
||||
GossipVerifiedPayloadBid {
|
||||
signed_bid: Arc::new(SignedExecutionPayloadBid {
|
||||
message: ExecutionPayloadBid {
|
||||
signed_bid: Arc::new(SignedExecutionPayloadBidGloas {
|
||||
message: ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
builder_index,
|
||||
parent_block_hash,
|
||||
parent_block_root,
|
||||
value,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
}),
|
||||
|
||||
@@ -14,8 +14,8 @@ use state_processing::genesis::genesis_block;
|
||||
use store::{HotColdDB, StoreConfig};
|
||||
use types::{
|
||||
Address, ChainSpec, Checkpoint, Domain, Epoch, EthSpec, ExecutionBlockHash,
|
||||
ExecutionPayloadBid, Hash256, MinimalEthSpec, ProposerPreferences, SignedBeaconBlock,
|
||||
SignedExecutionPayloadBid, SignedProposerPreferences, SignedRoot, Slot,
|
||||
ExecutionPayloadBidGloas, Hash256, MinimalEthSpec, ProposerPreferences, SignedBeaconBlock,
|
||||
SignedExecutionPayloadBidGloas, SignedProposerPreferences, SignedRoot, Slot,
|
||||
};
|
||||
|
||||
use proto_array::{Block as ProtoBlock, ExecutionStatus, PayloadStatus};
|
||||
@@ -154,7 +154,7 @@ impl TestContext {
|
||||
}
|
||||
}
|
||||
|
||||
fn sign_bid(&self, bid: ExecutionPayloadBid<E>) -> Arc<SignedExecutionPayloadBid<E>> {
|
||||
fn sign_bid(&self, bid: ExecutionPayloadBidGloas<E>) -> Arc<SignedExecutionPayloadBidGloas<E>> {
|
||||
let head = self.canonical_head.cached_head();
|
||||
let state = &head.snapshot.beacon_state;
|
||||
let domain = self.spec.get_domain(
|
||||
@@ -165,7 +165,7 @@ impl TestContext {
|
||||
);
|
||||
let message = bid.signing_root(domain);
|
||||
let signature = self.keypairs[bid.builder_index as usize].sk.sign(message);
|
||||
Arc::new(SignedExecutionPayloadBid {
|
||||
Arc::new(SignedExecutionPayloadBidGloas {
|
||||
message: bid,
|
||||
signature,
|
||||
})
|
||||
@@ -229,16 +229,16 @@ fn make_signed_bid(
|
||||
gas_limit: u64,
|
||||
value: u64,
|
||||
parent_block_root: Hash256,
|
||||
) -> Arc<SignedExecutionPayloadBid<E>> {
|
||||
Arc::new(SignedExecutionPayloadBid {
|
||||
message: ExecutionPayloadBid {
|
||||
) -> Arc<SignedExecutionPayloadBidGloas<E>> {
|
||||
Arc::new(SignedExecutionPayloadBidGloas {
|
||||
message: ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
builder_index,
|
||||
fee_recipient,
|
||||
gas_limit,
|
||||
value,
|
||||
parent_block_root,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
})
|
||||
@@ -420,13 +420,13 @@ fn execution_payment_nonzero() {
|
||||
let slot = Slot::new(0);
|
||||
seed_preferences(&ctx, slot, Address::ZERO, 30_000_000);
|
||||
|
||||
let bid = Arc::new(SignedExecutionPayloadBid {
|
||||
message: ExecutionPayloadBid {
|
||||
let bid = Arc::new(SignedExecutionPayloadBidGloas {
|
||||
message: ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
gas_limit: 30_000_000,
|
||||
execution_payment: 42,
|
||||
parent_block_root: ctx.genesis_block_root,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
});
|
||||
@@ -576,8 +576,8 @@ fn invalid_blob_kzg_commitments() {
|
||||
.map(|_| KzgCommitment::empty_for_testing())
|
||||
.collect();
|
||||
|
||||
let bid = Arc::new(SignedExecutionPayloadBid {
|
||||
message: ExecutionPayloadBid {
|
||||
let bid = Arc::new(SignedExecutionPayloadBidGloas {
|
||||
message: ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
builder_index: 0,
|
||||
fee_recipient: Address::ZERO,
|
||||
@@ -585,7 +585,7 @@ fn invalid_blob_kzg_commitments() {
|
||||
value: 0,
|
||||
parent_block_root: ctx.genesis_block_root,
|
||||
blob_kzg_commitments: VariableList::new(commitments).unwrap(),
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
},
|
||||
signature: Signature::empty(),
|
||||
});
|
||||
@@ -635,14 +635,14 @@ fn valid_bid() {
|
||||
let slot = Slot::new(0);
|
||||
seed_preferences(&ctx, slot, Address::ZERO, 30_000_000);
|
||||
|
||||
let bid = ctx.sign_bid(ExecutionPayloadBid {
|
||||
let bid = ctx.sign_bid(ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
builder_index: 0,
|
||||
fee_recipient: Address::ZERO,
|
||||
gas_limit: 30_000_000,
|
||||
value: 0,
|
||||
parent_block_root: ctx.genesis_block_root,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
});
|
||||
let result = GossipVerifiedPayloadBid::new(bid, &gossip);
|
||||
assert!(
|
||||
@@ -662,14 +662,14 @@ fn two_builders_coexist_in_cache() {
|
||||
let slot = Slot::new(0);
|
||||
seed_preferences(&ctx, slot, Address::ZERO, 30_000_000);
|
||||
|
||||
let bid_0 = ctx.sign_bid(ExecutionPayloadBid {
|
||||
let bid_0 = ctx.sign_bid(ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
builder_index: 0,
|
||||
fee_recipient: Address::ZERO,
|
||||
gas_limit: 30_000_000,
|
||||
value: 0,
|
||||
parent_block_root: ctx.genesis_block_root,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
});
|
||||
let result_0 = GossipVerifiedPayloadBid::new(bid_0, &gossip);
|
||||
assert!(
|
||||
@@ -679,14 +679,14 @@ fn two_builders_coexist_in_cache() {
|
||||
);
|
||||
|
||||
// Builder 1 must bid strictly higher than builder 0's cached value.
|
||||
let bid_1 = ctx.sign_bid(ExecutionPayloadBid {
|
||||
let bid_1 = ctx.sign_bid(ExecutionPayloadBidGloas {
|
||||
slot,
|
||||
builder_index: 1,
|
||||
fee_recipient: Address::ZERO,
|
||||
gas_limit: 30_000_000,
|
||||
value: 1,
|
||||
parent_block_root: ctx.genesis_block_root,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
});
|
||||
let result_1 = GossipVerifiedPayloadBid::new(bid_1, &gossip);
|
||||
assert!(
|
||||
@@ -705,6 +705,7 @@ fn two_builders_coexist_in_cache() {
|
||||
.expect("should have highest bid");
|
||||
assert_eq!(highest.message.value, 1);
|
||||
assert_eq!(highest.message.builder_index, 1);
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -6,7 +6,7 @@ use parking_lot::{Mutex, RwLock};
|
||||
use store::DatabaseBlock;
|
||||
use tracing::debug;
|
||||
use types::{
|
||||
ChainSpec, EthSpec, ExecutionPayloadBid, ExecutionPayloadEnvelope, Hash256, SignedBeaconBlock,
|
||||
ChainSpec, EthSpec, ExecutionPayloadBidRef, ExecutionPayloadEnvelope, Hash256, SignedBeaconBlock,
|
||||
SignedExecutionPayloadEnvelope, Slot, consts::gloas::BUILDER_INDEX_SELF_BUILD,
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ pub struct GossipVerificationContext<'a, T: BeaconChainTypes> {
|
||||
pub(crate) fn verify_envelope_consistency<E: EthSpec>(
|
||||
envelope: &ExecutionPayloadEnvelope<E>,
|
||||
block: &SignedBeaconBlock<E>,
|
||||
execution_bid: &ExecutionPayloadBid<E>,
|
||||
execution_bid: ExecutionPayloadBidRef<'_, E>,
|
||||
latest_finalized_slot: Slot,
|
||||
) -> Result<(), EnvelopeError> {
|
||||
// Check that the envelope's slot isn't from a slot prior
|
||||
@@ -58,17 +58,17 @@ pub(crate) fn verify_envelope_consistency<E: EthSpec>(
|
||||
}
|
||||
|
||||
// Builder index matches committed bid.
|
||||
if envelope.builder_index != execution_bid.builder_index {
|
||||
if envelope.builder_index != execution_bid.builder_index() {
|
||||
return Err(EnvelopeError::BuilderIndexMismatch {
|
||||
committed_bid: execution_bid.builder_index,
|
||||
committed_bid: execution_bid.builder_index(),
|
||||
envelope: envelope.builder_index,
|
||||
});
|
||||
}
|
||||
|
||||
// The block hash should match the block hash of the execution bid.
|
||||
if envelope.payload.block_hash != execution_bid.block_hash {
|
||||
if envelope.payload.block_hash != execution_bid.block_hash() {
|
||||
return Err(EnvelopeError::BlockHashMismatch {
|
||||
committed_bid: execution_bid.block_hash,
|
||||
committed_bid: execution_bid.block_hash(),
|
||||
envelope: envelope.payload.block_hash,
|
||||
});
|
||||
}
|
||||
@@ -130,11 +130,11 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
|
||||
)));
|
||||
}
|
||||
};
|
||||
let execution_bid = &block
|
||||
let execution_bid = block
|
||||
.message()
|
||||
.body()
|
||||
.signed_execution_payload_bid()?
|
||||
.message;
|
||||
.message();
|
||||
|
||||
verify_envelope_consistency(envelope, &block, execution_bid, latest_finalized_slot)?;
|
||||
|
||||
@@ -315,9 +315,9 @@ mod tests {
|
||||
use ssz_types::VariableList;
|
||||
use types::{
|
||||
BeaconBlock, BeaconBlockBodyGloas, BeaconBlockGloas, Eth1Data, ExecutionBlockHash,
|
||||
ExecutionPayloadBid, ExecutionPayloadEnvelope, ExecutionPayloadGloas, ExecutionRequests,
|
||||
Graffiti, Hash256, MinimalEthSpec, SignedBeaconBlock, SignedExecutionPayloadBid, Slot,
|
||||
SyncAggregate,
|
||||
ExecutionPayloadBidGloas, ExecutionPayloadBidRef, ExecutionPayloadEnvelope,
|
||||
ExecutionPayloadGloas, ExecutionRequests, Graffiti, Hash256, MinimalEthSpec,
|
||||
SignedBeaconBlock, SignedExecutionPayloadBidGloas, Slot, SyncAggregate,
|
||||
};
|
||||
|
||||
use super::verify_envelope_consistency;
|
||||
@@ -365,7 +365,7 @@ mod tests {
|
||||
sync_aggregate: SyncAggregate::empty(),
|
||||
bls_to_execution_changes: VariableList::empty(),
|
||||
parent_execution_requests: ExecutionRequests::default(),
|
||||
signed_execution_payload_bid: SignedExecutionPayloadBid::empty(),
|
||||
signed_execution_payload_bid: SignedExecutionPayloadBidGloas::empty(),
|
||||
payload_attestations: VariableList::empty(),
|
||||
_phantom: PhantomData,
|
||||
},
|
||||
@@ -373,11 +373,11 @@ mod tests {
|
||||
SignedBeaconBlock::from_block(block, Signature::empty())
|
||||
}
|
||||
|
||||
fn make_bid(builder_index: u64, block_hash: ExecutionBlockHash) -> ExecutionPayloadBid<E> {
|
||||
ExecutionPayloadBid {
|
||||
fn make_bid(builder_index: u64, block_hash: ExecutionBlockHash) -> ExecutionPayloadBidGloas<E> {
|
||||
ExecutionPayloadBidGloas {
|
||||
builder_index,
|
||||
block_hash,
|
||||
..ExecutionPayloadBid::default()
|
||||
..ExecutionPayloadBidGloas::default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ mod tests {
|
||||
let block = make_block(slot);
|
||||
let bid = make_bid(builder_index, block_hash);
|
||||
|
||||
assert!(verify_envelope_consistency::<E>(&envelope, &block, &bid, Slot::new(0)).is_ok());
|
||||
assert!(verify_envelope_consistency::<E>(&envelope, &block, ExecutionPayloadBidRef::Gloas(&bid), Slot::new(0)).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -406,7 +406,7 @@ mod tests {
|
||||
let latest_finalized_slot = Slot::new(10);
|
||||
|
||||
let result =
|
||||
verify_envelope_consistency::<E>(&envelope, &block, &bid, latest_finalized_slot);
|
||||
verify_envelope_consistency::<E>(&envelope, &block, ExecutionPayloadBidRef::Gloas(&bid), latest_finalized_slot);
|
||||
assert!(matches!(
|
||||
result,
|
||||
Err(EnvelopeError::PriorToFinalization { .. })
|
||||
@@ -422,7 +422,7 @@ mod tests {
|
||||
let block = make_block(Slot::new(20));
|
||||
let bid = make_bid(builder_index, block_hash);
|
||||
|
||||
let result = verify_envelope_consistency::<E>(&envelope, &block, &bid, Slot::new(0));
|
||||
let result = verify_envelope_consistency::<E>(&envelope, &block, ExecutionPayloadBidRef::Gloas(&bid), Slot::new(0));
|
||||
assert!(matches!(result, Err(EnvelopeError::SlotMismatch { .. })));
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ mod tests {
|
||||
let block = make_block(slot);
|
||||
let bid = make_bid(2, block_hash);
|
||||
|
||||
let result = verify_envelope_consistency::<E>(&envelope, &block, &bid, Slot::new(0));
|
||||
let result = verify_envelope_consistency::<E>(&envelope, &block, ExecutionPayloadBidRef::Gloas(&bid), Slot::new(0));
|
||||
assert!(matches!(
|
||||
result,
|
||||
Err(EnvelopeError::BuilderIndexMismatch { .. })
|
||||
@@ -451,7 +451,7 @@ mod tests {
|
||||
let block = make_block(slot);
|
||||
let bid = make_bid(builder_index, ExecutionBlockHash::repeat_byte(0xff));
|
||||
|
||||
let result = verify_envelope_consistency::<E>(&envelope, &block, &bid, Slot::new(0));
|
||||
let result = verify_envelope_consistency::<E>(&envelope, &block, ExecutionPayloadBidRef::Gloas(&bid), Slot::new(0));
|
||||
assert!(matches!(
|
||||
result,
|
||||
Err(EnvelopeError::BlockHashMismatch { .. })
|
||||
|
||||
@@ -72,15 +72,15 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
|
||||
envelope: &'a SignedExecutionPayloadEnvelope<T::EthSpec>,
|
||||
block: &'a SignedBeaconBlock<T::EthSpec>,
|
||||
) -> Result<NewPayloadRequest<'a, T::EthSpec>, BlockError> {
|
||||
let bid = &block
|
||||
let bid = block
|
||||
.message()
|
||||
.body()
|
||||
.signed_execution_payload_bid()
|
||||
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?
|
||||
.message;
|
||||
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?;
|
||||
let bid_message = bid.message();
|
||||
|
||||
let versioned_hashes = bid
|
||||
.blob_kzg_commitments
|
||||
let versioned_hashes = bid_message
|
||||
.blob_kzg_commitments()
|
||||
.iter()
|
||||
.map(kzg_commitment_to_versioned_hash)
|
||||
.collect();
|
||||
|
||||
@@ -2847,15 +2847,15 @@ where
|
||||
.expect("should read block from store")
|
||||
.expect("block should exist in store");
|
||||
|
||||
let bid = &block
|
||||
let bid = block
|
||||
.message()
|
||||
.body()
|
||||
.signed_execution_payload_bid()
|
||||
.expect("Gloas block should have a payload bid")
|
||||
.message;
|
||||
.expect("Gloas block should have a payload bid");
|
||||
let bid_message = bid.message();
|
||||
|
||||
let versioned_hashes = bid
|
||||
.blob_kzg_commitments
|
||||
let versioned_hashes = bid_message
|
||||
.blob_kzg_commitments()
|
||||
.iter()
|
||||
.map(kzg_commitment_to_versioned_hash)
|
||||
.collect();
|
||||
@@ -3878,13 +3878,12 @@ pub fn generate_data_column_sidecars_from_block<E: EthSpec>(
|
||||
// Load the precomputed column sidecar to avoid computing them for every block in the tests.
|
||||
// Then repeat the cells and proofs for every blob
|
||||
if block.fork_name_unchecked().heze_enabled() {
|
||||
let kzg_commitments = &block
|
||||
let bid_ref = block
|
||||
.message()
|
||||
.body()
|
||||
.signed_execution_payload_bid()
|
||||
.expect("Heze block should have a payload bid")
|
||||
.message
|
||||
.blob_kzg_commitments;
|
||||
.expect("Heze block should have a payload bid");
|
||||
let kzg_commitments = bid_ref.message().blob_kzg_commitments();
|
||||
if kzg_commitments.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
@@ -3922,13 +3921,12 @@ pub fn generate_data_column_sidecars_from_block<E: EthSpec>(
|
||||
)
|
||||
.unwrap()
|
||||
} else if block.fork_name_unchecked().gloas_enabled() {
|
||||
let kzg_commitments = &block
|
||||
let bid_ref = block
|
||||
.message()
|
||||
.body()
|
||||
.signed_execution_payload_bid()
|
||||
.expect("Gloas block should have a payload bid")
|
||||
.message
|
||||
.blob_kzg_commitments;
|
||||
.expect("Gloas block should have a payload bid");
|
||||
let kzg_commitments = bid_ref.message().blob_kzg_commitments();
|
||||
if kzg_commitments.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user