add const

This commit is contained in:
Eitan Seri- Levi
2026-02-09 20:55:39 -08:00
parent 525bed709f
commit ed5cc3b272
4 changed files with 16 additions and 44 deletions

View File

@@ -15,7 +15,7 @@ use state_processing::{
use state_processing::{VerifyOperation, state_advance::complete_state_advance}; use state_processing::{VerifyOperation, state_advance::complete_state_advance};
use tracing::{Span, debug, debug_span, error, instrument, trace, warn}; use tracing::{Span, debug, debug_span, error, instrument, trace, warn};
use tree_hash::TreeHash; use tree_hash::TreeHash;
use types::consts::gloas::{BID_VALUE_SELF_BUILD, BUILDER_INDEX_SELF_BUILD}; use types::consts::gloas::{BID_VALUE_SELF_BUILD, BUILDER_INDEX_SELF_BUILD, EXECUTION_PAYMENT_TRUSTLESS_BUILD};
use types::{ use types::{
Address, Attestation, AttestationElectra, AttesterSlashing, AttesterSlashingElectra, Address, Attestation, AttestationElectra, AttesterSlashing, AttesterSlashingElectra,
BeaconBlock, BeaconBlockBodyGloas, BeaconBlockGloas, BeaconState, BlockProductionVersion, BeaconBlock, BeaconBlockBodyGloas, BeaconBlockGloas, BeaconState, BlockProductionVersion,
@@ -148,7 +148,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// We'll need to build out trustless/trusted bid paths. // We'll need to build out trustless/trusted bid paths.
let (execution_payload_bid, state, payload_data) = self let (execution_payload_bid, state, payload_data) = self
.clone() .clone()
.produce_execution_payload_bid(state, state_root_opt, produce_at_slot, BID_VALUE_SELF_BUILD, BUILDER_INDEX_SELF_BUILD) .produce_execution_payload_bid(
state,
state_root_opt,
produce_at_slot,
BID_VALUE_SELF_BUILD,
BUILDER_INDEX_SELF_BUILD,
)
.await?; .await?;
// Part 3/3 (blocking) // Part 3/3 (blocking)
@@ -694,7 +700,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
} }
} }
BlockProposalContentsType::Blinded(_) => { BlockProposalContentsType::Blinded(_) => {
return Err(BlockProductionError::Unexpected("Should never produce a blinded block post-Gloas".to_owned())); return Err(BlockProductionError::Unexpected(
"Should never produce a blinded block post-Gloas".to_owned(),
));
} }
}; };
@@ -706,6 +714,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.map_err(|_| BlockProductionError::GloasNotImplemented)? .map_err(|_| BlockProductionError::GloasNotImplemented)?
.to_owned(); .to_owned();
// 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 = ExecutionPayloadBid::<T::EthSpec> {
parent_block_hash: state.latest_block_hash()?.to_owned(), parent_block_hash: state.latest_block_hash()?.to_owned(),
parent_block_root: state.get_latest_block_root(state_root), parent_block_root: state.get_latest_block_root(state_root),
@@ -716,7 +726,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
builder_index, builder_index,
slot: produce_at_slot, slot: produce_at_slot,
value: bid_value, value: bid_value,
execution_payment: 0, execution_payment: EXECUTION_PAYMENT_TRUSTLESS_BUILD,
blob_kzg_commitments, blob_kzg_commitments,
}; };

View File

@@ -61,6 +61,7 @@ impl<E: EthSpec> PendingPayloadEnvelopes<E> {
/// Prune envelopes older than `current_slot - max_slot_age`. /// Prune envelopes older than `current_slot - max_slot_age`.
/// ///
/// This removes stale envelopes from blocks that were never published. /// This removes stale envelopes from blocks that were never published.
// TODO(gloas) implement pruning
pub fn prune(&mut self, current_slot: Slot) { pub fn prune(&mut self, current_slot: Slot) {
let min_slot = current_slot.saturating_sub(self.max_slot_age); let min_slot = current_slot.saturating_sub(self.max_slot_age);
self.envelopes.retain(|slot, _| *slot >= min_slot); self.envelopes.retain(|slot, _| *slot >= min_slot);

View File

@@ -29,6 +29,7 @@ pub mod gloas {
pub const BUILDER_INDEX_SELF_BUILD: u64 = u64::MAX; pub const BUILDER_INDEX_SELF_BUILD: u64 = u64::MAX;
pub const BUILDER_INDEX_FLAG: u64 = 1 << 40; pub const BUILDER_INDEX_FLAG: u64 = 1 << 40;
pub const BID_VALUE_SELF_BUILD: u64 = 0; pub const BID_VALUE_SELF_BUILD: u64 = 0;
pub const EXECUTION_PAYMENT_TRUSTLESS_BUILD: u64 = 0;
// Fork choice constants // Fork choice constants
pub type PayloadStatus = u8; pub type PayloadStatus = u8;

View File

@@ -33,44 +33,4 @@ mod tests {
use rand_xorshift::XorShiftRng; use rand_xorshift::XorShiftRng;
ssz_and_tree_hash_tests!(ExecutionPayloadEnvelope<MainnetEthSpec>); ssz_and_tree_hash_tests!(ExecutionPayloadEnvelope<MainnetEthSpec>);
#[test]
fn signing_root_is_deterministic() {
let mut rng = XorShiftRng::from_seed([0x42; 16]);
let envelope = ExecutionPayloadEnvelope::<MainnetEthSpec>::random_for_test(&mut rng);
let domain = Hash256::random_for_test(&mut rng);
let signing_root_1 = envelope.signing_root(domain);
let signing_root_2 = envelope.signing_root(domain);
assert_eq!(signing_root_1, signing_root_2);
}
#[test]
fn signing_root_changes_with_domain() {
let mut rng = XorShiftRng::from_seed([0x42; 16]);
let envelope = ExecutionPayloadEnvelope::<MainnetEthSpec>::random_for_test(&mut rng);
let domain_1 = Hash256::random_for_test(&mut rng);
let domain_2 = Hash256::random_for_test(&mut rng);
let signing_root_1 = envelope.signing_root(domain_1);
let signing_root_2 = envelope.signing_root(domain_2);
assert_ne!(signing_root_1, signing_root_2);
}
#[test]
fn signing_root_changes_with_envelope_data() {
let mut rng = XorShiftRng::from_seed([0x42; 16]);
let envelope_1 = ExecutionPayloadEnvelope::<MainnetEthSpec>::random_for_test(&mut rng);
let mut envelope_2 = envelope_1.clone();
envelope_2.beacon_block_root = Hash256::random_for_test(&mut rng);
let domain = Hash256::random_for_test(&mut rng);
let signing_root_1 = envelope_1.signing_root(domain);
let signing_root_2 = envelope_2.signing_root(domain);
assert_ne!(signing_root_1, signing_root_2);
}
} }