mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 20:04:41 +00:00
Payload builder version
This commit is contained in:
@@ -11,7 +11,10 @@ use signature_sets::{
|
||||
use std::borrow::Cow;
|
||||
use tree_hash::TreeHash;
|
||||
use typenum::Unsigned;
|
||||
use types::{consts::gloas::BUILDER_INDEX_SELF_BUILD, *};
|
||||
use types::{
|
||||
consts::gloas::{BUILDER_INDEX_SELF_BUILD, PAYLOAD_BUILDER_VERSION},
|
||||
*,
|
||||
};
|
||||
|
||||
pub use self::verify_attester_slashing::{
|
||||
get_slashable_indices, get_slashable_indices_modular, verify_attester_slashing,
|
||||
@@ -698,6 +701,16 @@ pub fn process_execution_payload_bid<E: EthSpec, Payload: AbstractExecPayload<E>
|
||||
ExecutionPayloadBidInvalid::BuilderNotActive(builder_index).into()
|
||||
);
|
||||
|
||||
// Verify that the builder is a payload builder
|
||||
block_verify!(
|
||||
builder.version == PAYLOAD_BUILDER_VERSION,
|
||||
ExecutionPayloadBidInvalid::InvalidBuilderVersion {
|
||||
builder_index,
|
||||
version: builder.version,
|
||||
}
|
||||
.into()
|
||||
);
|
||||
|
||||
// Verify that the builder has funds to cover the bid
|
||||
block_verify!(
|
||||
state.can_builder_cover_bid(builder_index, amount, spec)?,
|
||||
|
||||
@@ -527,6 +527,8 @@ pub enum ExecutionPayloadBidInvalid {
|
||||
BadSignature,
|
||||
/// The builder is not active.
|
||||
BuilderNotActive(u64),
|
||||
/// The builder's version is not `PAYLOAD_BUILDER_VERSION`.
|
||||
InvalidBuilderVersion { builder_index: u64, version: u8 },
|
||||
/// The builder has insufficient balance to cover the bid
|
||||
InsufficientBalance {
|
||||
builder_index: u64,
|
||||
|
||||
@@ -970,11 +970,18 @@ pub fn process_deposit_request_post_gloas<E: EthSpec>(
|
||||
&& !is_validator
|
||||
&& !is_pending_validator(state.pending_deposits()?, &deposit_request.pubkey, spec))
|
||||
{
|
||||
// Apply builder deposits immediately
|
||||
// Apply builder deposits immediately. The builder version is taken from the
|
||||
// withdrawal credentials prefix byte (spec: `process_builder_deposit_request`).
|
||||
let version = *deposit_request
|
||||
.withdrawal_credentials
|
||||
.as_slice()
|
||||
.first()
|
||||
.ok_or(BeaconStateError::WithdrawalCredentialMissingVersion)?;
|
||||
apply_deposit_for_builder(
|
||||
state,
|
||||
builder_index,
|
||||
deposit_request.pubkey,
|
||||
version,
|
||||
deposit_request.withdrawal_credentials,
|
||||
deposit_request.amount,
|
||||
deposit_request.signature.clone(),
|
||||
@@ -1002,6 +1009,7 @@ pub fn apply_deposit_for_builder<E: EthSpec>(
|
||||
state: &mut BeaconState<E>,
|
||||
builder_index_opt: Option<BuilderIndex>,
|
||||
pubkey: PublicKeyBytes,
|
||||
version: u8,
|
||||
withdrawal_credentials: Hash256,
|
||||
amount: u64,
|
||||
signature: SignatureBytes,
|
||||
@@ -1020,6 +1028,7 @@ pub fn apply_deposit_for_builder<E: EthSpec>(
|
||||
if is_valid_deposit_signature(&deposit_data, spec).is_ok() {
|
||||
let builder_index = state.add_builder_to_registry(
|
||||
pubkey,
|
||||
version,
|
||||
withdrawal_credentials,
|
||||
amount,
|
||||
slot,
|
||||
|
||||
@@ -10,7 +10,8 @@ use tree_hash::TreeHash;
|
||||
use typenum::Unsigned;
|
||||
use types::{
|
||||
BeaconState, BeaconStateError as Error, BeaconStateGloas, BuilderPendingPayment, ChainSpec,
|
||||
EthSpec, ExecutionPayloadBid, ExecutionRequests, Fork, is_builder_withdrawal_credential,
|
||||
EthSpec, ExecutionPayloadBid, ExecutionRequests, Fork, consts::gloas::PAYLOAD_BUILDER_VERSION,
|
||||
is_builder_withdrawal_credential,
|
||||
};
|
||||
|
||||
/// Transform a `Fulu` state into a `Gloas` state.
|
||||
@@ -208,6 +209,7 @@ fn onboard_builders_from_pending_deposits<E: EthSpec>(
|
||||
state,
|
||||
builder_index,
|
||||
deposit.pubkey,
|
||||
PAYLOAD_BUILDER_VERSION,
|
||||
deposit.withdrawal_credentials,
|
||||
deposit.amount,
|
||||
deposit.signature.clone(),
|
||||
|
||||
Reference in New Issue
Block a user