mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
more fixes
This commit is contained in:
@@ -668,16 +668,48 @@ fn handle_rpc_response<E: EthSpec>(
|
|||||||
SupportedProtocol::BlocksByRootV1 => Ok(Some(RpcSuccessResponse::BlocksByRoot(Arc::new(
|
SupportedProtocol::BlocksByRootV1 => Ok(Some(RpcSuccessResponse::BlocksByRoot(Arc::new(
|
||||||
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
|
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
|
||||||
)))),
|
)))),
|
||||||
SupportedProtocol::PayloadEnvelopesByRangeV1 => {
|
SupportedProtocol::PayloadEnvelopesByRangeV1 => match fork_name {
|
||||||
Ok(Some(RpcSuccessResponse::PayloadEnvelopesByRange(Arc::new(
|
Some(fork_name) => {
|
||||||
SignedExecutionPayloadEnvelope::from_ssz_bytes(decoded_buffer)?,
|
if fork_name.gloas_enabled() {
|
||||||
))))
|
Ok(Some(RpcSuccessResponse::PayloadEnvelopesByRange(Arc::new(
|
||||||
}
|
SignedExecutionPayloadEnvelope::from_ssz_bytes(decoded_buffer)?,
|
||||||
SupportedProtocol::PayloadEnvelopesByRootV1 => {
|
))))
|
||||||
Ok(Some(RpcSuccessResponse::PayloadEnvelopesByRoot(Arc::new(
|
} else {
|
||||||
SignedExecutionPayloadEnvelope::from_ssz_bytes(decoded_buffer)?,
|
Err(RPCError::ErrorResponse(
|
||||||
))))
|
RpcErrorResponse::InvalidRequest,
|
||||||
}
|
"Invalid fork name for payload envelopes by range".to_string(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => Err(RPCError::ErrorResponse(
|
||||||
|
RpcErrorResponse::InvalidRequest,
|
||||||
|
format!(
|
||||||
|
"No context bytes provided for {:?} response",
|
||||||
|
versioned_protocol
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
},
|
||||||
|
SupportedProtocol::PayloadEnvelopesByRootV1 => match fork_name {
|
||||||
|
Some(fork_name) => {
|
||||||
|
if fork_name.gloas_enabled() {
|
||||||
|
Ok(Some(RpcSuccessResponse::PayloadEnvelopesByRoot(Arc::new(
|
||||||
|
SignedExecutionPayloadEnvelope::from_ssz_bytes(decoded_buffer)?,
|
||||||
|
))))
|
||||||
|
} else {
|
||||||
|
Err(RPCError::ErrorResponse(
|
||||||
|
RpcErrorResponse::InvalidRequest,
|
||||||
|
"Invalid fork name for payload envelopes by root".to_string(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => Err(RPCError::ErrorResponse(
|
||||||
|
RpcErrorResponse::InvalidRequest,
|
||||||
|
format!(
|
||||||
|
"No context bytes provided for {:?} response",
|
||||||
|
versioned_protocol
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
},
|
||||||
SupportedProtocol::BlobsByRangeV1 => match fork_name {
|
SupportedProtocol::BlobsByRangeV1 => match fork_name {
|
||||||
Some(fork_name) => {
|
Some(fork_name) => {
|
||||||
if fork_name.deneb_enabled() {
|
if fork_name.deneb_enabled() {
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ use tokio_util::{
|
|||||||
compat::{Compat, FuturesAsyncReadCompatExt},
|
compat::{Compat, FuturesAsyncReadCompatExt},
|
||||||
};
|
};
|
||||||
use types::{
|
use types::{
|
||||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BlobSidecar, ChainSpec, DataColumnSidecarFulu,
|
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockGloas, BlobSidecar, ChainSpec,
|
||||||
DataColumnSidecarGloas, EmptyBlock, Epoch, EthSpec, EthSpecId, ForkContext, ForkName,
|
DataColumnSidecarFulu, DataColumnSidecarGloas, EmptyBlock, Epoch, EthSpec, EthSpecId,
|
||||||
LightClientBootstrap, LightClientBootstrapAltair, LightClientFinalityUpdate,
|
ForkContext, ForkName, LightClientBootstrap, LightClientBootstrapAltair,
|
||||||
LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
|
LightClientFinalityUpdate, LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
|
||||||
LightClientOptimisticUpdateAltair, LightClientUpdate, MainnetEthSpec, MinimalEthSpec,
|
LightClientOptimisticUpdateAltair, LightClientUpdate, MainnetEthSpec, MinimalEthSpec,
|
||||||
SignedBeaconBlock, SignedExecutionPayloadEnvelope,
|
SignedBeaconBlock, SignedExecutionPayloadEnvelope,
|
||||||
};
|
};
|
||||||
@@ -65,6 +65,17 @@ pub static SIGNED_BEACON_BLOCK_BELLATRIX_MAX: LazyLock<usize> =
|
|||||||
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_bellatrix_size() // adding max size of execution payload (~16gb)
|
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_bellatrix_size() // adding max size of execution payload (~16gb)
|
||||||
+ ssz::BYTES_PER_LENGTH_OFFSET); // Adding the additional ssz offset for the `ExecutionPayload` field
|
+ ssz::BYTES_PER_LENGTH_OFFSET); // Adding the additional ssz offset for the `ExecutionPayload` field
|
||||||
|
|
||||||
|
/// Gloas blocks no longer contain an execution payload (it's in the envelope),
|
||||||
|
/// so they are significantly smaller than Bellatrix+ blocks.
|
||||||
|
pub static SIGNED_BEACON_BLOCK_GLOAS_MAX: LazyLock<usize> = LazyLock::new(|| {
|
||||||
|
SignedBeaconBlock::<MainnetEthSpec>::from_block(
|
||||||
|
BeaconBlock::Gloas(BeaconBlockGloas::full(&MainnetEthSpec::default_spec())),
|
||||||
|
Signature::empty(),
|
||||||
|
)
|
||||||
|
.as_ssz_bytes()
|
||||||
|
.len()
|
||||||
|
});
|
||||||
|
|
||||||
pub static SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MIN: LazyLock<usize> =
|
pub static SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MIN: LazyLock<usize> =
|
||||||
LazyLock::new(SignedExecutionPayloadEnvelope::<MainnetEthSpec>::min_size);
|
LazyLock::new(SignedExecutionPayloadEnvelope::<MainnetEthSpec>::min_size);
|
||||||
|
|
||||||
@@ -146,10 +157,19 @@ pub fn rpc_block_limits_by_fork(current_fork: ForkName) -> RpcLimits {
|
|||||||
),
|
),
|
||||||
// After the merge the max SSZ size of a block is absurdly big. The size is actually
|
// After the merge the max SSZ size of a block is absurdly big. The size is actually
|
||||||
// bound by other constants, so here we default to the bellatrix's max value
|
// bound by other constants, so here we default to the bellatrix's max value
|
||||||
_ => RpcLimits::new(
|
ForkName::Bellatrix
|
||||||
|
| ForkName::Capella
|
||||||
|
| ForkName::Deneb
|
||||||
|
| ForkName::Electra
|
||||||
|
| ForkName::Fulu => RpcLimits::new(
|
||||||
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
|
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
|
||||||
*SIGNED_BEACON_BLOCK_BELLATRIX_MAX, // Bellatrix block is larger than base and altair blocks
|
*SIGNED_BEACON_BLOCK_BELLATRIX_MAX, // Bellatrix block is larger than base and altair blocks
|
||||||
),
|
),
|
||||||
|
// Gloas blocks no longer contain the execution payload, so they are much smaller
|
||||||
|
ForkName::Gloas => RpcLimits::new(
|
||||||
|
*SIGNED_BEACON_BLOCK_BASE_MIN,
|
||||||
|
*SIGNED_BEACON_BLOCK_GLOAS_MAX,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,9 +616,7 @@ impl ProtocolId {
|
|||||||
Protocol::Goodbye => RpcLimits::new(0, 0), // Goodbye request has no response
|
Protocol::Goodbye => RpcLimits::new(0, 0), // Goodbye request has no response
|
||||||
Protocol::BlocksByRange => rpc_block_limits_by_fork(fork_context.current_fork_name()),
|
Protocol::BlocksByRange => rpc_block_limits_by_fork(fork_context.current_fork_name()),
|
||||||
Protocol::BlocksByRoot => rpc_block_limits_by_fork(fork_context.current_fork_name()),
|
Protocol::BlocksByRoot => rpc_block_limits_by_fork(fork_context.current_fork_name()),
|
||||||
Protocol::PayloadEnvelopesByRange => {
|
Protocol::PayloadEnvelopesByRange => rpc_payload_limits(),
|
||||||
rpc_block_limits_by_fork(fork_context.current_fork_name())
|
|
||||||
}
|
|
||||||
Protocol::PayloadEnvelopesByRoot => rpc_payload_limits(),
|
Protocol::PayloadEnvelopesByRoot => rpc_payload_limits(),
|
||||||
Protocol::BlobsByRange => rpc_blob_limits::<E>(),
|
Protocol::BlobsByRange => rpc_blob_limits::<E>(),
|
||||||
Protocol::BlobsByRoot => rpc_blob_limits::<E>(),
|
Protocol::BlobsByRoot => rpc_blob_limits::<E>(),
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ use tree_hash_derive::TreeHash;
|
|||||||
use typenum::Unsigned;
|
use typenum::Unsigned;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
SignedExecutionPayloadBid,
|
Address, SignedBlsToExecutionChange, SignedExecutionPayloadBid,
|
||||||
attestation::{AttestationBase, AttestationData, IndexedAttestationBase},
|
attestation::{
|
||||||
|
AttestationBase, AttestationData, AttestationElectra, IndexedAttestationBase,
|
||||||
|
IndexedAttestationElectra, PayloadAttestation, PayloadAttestationData,
|
||||||
|
},
|
||||||
block::{
|
block::{
|
||||||
BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyBellatrix,
|
BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyBellatrix,
|
||||||
BeaconBlockBodyCapella, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconBlockBodyFulu,
|
BeaconBlockBodyCapella, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconBlockBodyFulu,
|
||||||
@@ -26,12 +29,12 @@ use crate::{
|
|||||||
core::{ChainSpec, Domain, Epoch, EthSpec, Graffiti, Hash256, SignedRoot, Slot},
|
core::{ChainSpec, Domain, Epoch, EthSpec, Graffiti, Hash256, SignedRoot, Slot},
|
||||||
deposit::{Deposit, DepositData},
|
deposit::{Deposit, DepositData},
|
||||||
execution::{
|
execution::{
|
||||||
AbstractExecPayload, BlindedPayload, Eth1Data, ExecutionPayload, ExecutionRequests,
|
AbstractExecPayload, BlindedPayload, BlsToExecutionChange, Eth1Data, ExecutionPayload,
|
||||||
FullPayload,
|
ExecutionRequests, FullPayload,
|
||||||
},
|
},
|
||||||
exit::{SignedVoluntaryExit, VoluntaryExit},
|
exit::{SignedVoluntaryExit, VoluntaryExit},
|
||||||
fork::{Fork, ForkName, InconsistentFork, map_fork_name},
|
fork::{Fork, ForkName, InconsistentFork, map_fork_name},
|
||||||
slashing::{AttesterSlashingBase, ProposerSlashing},
|
slashing::{AttesterSlashingBase, AttesterSlashingElectra, ProposerSlashing},
|
||||||
state::BeaconStateError,
|
state::BeaconStateError,
|
||||||
sync_committee::SyncAggregate,
|
sync_committee::SyncAggregate,
|
||||||
test_utils::TestRandom,
|
test_utils::TestRandom,
|
||||||
@@ -724,6 +727,135 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockGloa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockGloas<E, Payload> {
|
||||||
|
/// Returns a full Gloas block with all variable-length fields at max capacity.
|
||||||
|
/// Used for computing the maximum SSZ-encoded size.
|
||||||
|
pub fn full(spec: &ChainSpec) -> Self {
|
||||||
|
let header = BeaconBlockHeader {
|
||||||
|
slot: Slot::new(1),
|
||||||
|
proposer_index: 0,
|
||||||
|
parent_root: Hash256::zero(),
|
||||||
|
state_root: Hash256::zero(),
|
||||||
|
body_root: Hash256::zero(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let signed_header = SignedBeaconBlockHeader {
|
||||||
|
message: header,
|
||||||
|
signature: Signature::empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let indexed_attestation = IndexedAttestationElectra {
|
||||||
|
attesting_indices: VariableList::new(vec![0_u64; E::MaxValidatorsPerSlot::to_usize()])
|
||||||
|
.unwrap(),
|
||||||
|
data: AttestationData::default(),
|
||||||
|
signature: AggregateSignature::empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let proposer_slashing = ProposerSlashing {
|
||||||
|
signed_header_1: signed_header.clone(),
|
||||||
|
signed_header_2: signed_header,
|
||||||
|
};
|
||||||
|
|
||||||
|
let attester_slashing = AttesterSlashingElectra {
|
||||||
|
attestation_1: indexed_attestation.clone(),
|
||||||
|
attestation_2: indexed_attestation,
|
||||||
|
};
|
||||||
|
|
||||||
|
let attestation = AttestationElectra {
|
||||||
|
aggregation_bits: BitList::with_capacity(E::MaxValidatorsPerSlot::to_usize()).unwrap(),
|
||||||
|
data: AttestationData::default(),
|
||||||
|
signature: AggregateSignature::empty(),
|
||||||
|
committee_bits: BitVector::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let deposit_data = DepositData {
|
||||||
|
pubkey: PublicKeyBytes::empty(),
|
||||||
|
withdrawal_credentials: Hash256::zero(),
|
||||||
|
amount: 0,
|
||||||
|
signature: SignatureBytes::empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let deposit = Deposit {
|
||||||
|
proof: FixedVector::from_elem(Hash256::zero()),
|
||||||
|
data: deposit_data,
|
||||||
|
};
|
||||||
|
|
||||||
|
let signed_voluntary_exit = SignedVoluntaryExit {
|
||||||
|
message: VoluntaryExit {
|
||||||
|
epoch: Epoch::new(1),
|
||||||
|
validator_index: 1,
|
||||||
|
},
|
||||||
|
signature: Signature::empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let signed_bls_to_execution_change = SignedBlsToExecutionChange {
|
||||||
|
message: BlsToExecutionChange {
|
||||||
|
validator_index: 0,
|
||||||
|
from_bls_pubkey: PublicKeyBytes::empty(),
|
||||||
|
to_execution_address: Address::zero(),
|
||||||
|
},
|
||||||
|
signature: Signature::empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let payload_attestation = PayloadAttestation {
|
||||||
|
aggregation_bits: BitVector::default(),
|
||||||
|
data: PayloadAttestationData {
|
||||||
|
beacon_block_root: Hash256::zero(),
|
||||||
|
slot: Slot::new(0),
|
||||||
|
payload_present: false,
|
||||||
|
blob_data_available: false,
|
||||||
|
},
|
||||||
|
signature: AggregateSignature::empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut block = BeaconBlockGloas::<E, Payload>::empty(spec);
|
||||||
|
|
||||||
|
for _ in 0..E::MaxProposerSlashings::to_usize() {
|
||||||
|
block
|
||||||
|
.body
|
||||||
|
.proposer_slashings
|
||||||
|
.push(proposer_slashing.clone())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
for _ in 0..E::max_attester_slashings_electra() {
|
||||||
|
block
|
||||||
|
.body
|
||||||
|
.attester_slashings
|
||||||
|
.push(attester_slashing.clone())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
for _ in 0..E::max_attestations_electra() {
|
||||||
|
block.body.attestations.push(attestation.clone()).unwrap();
|
||||||
|
}
|
||||||
|
for _ in 0..E::MaxDeposits::to_usize() {
|
||||||
|
block.body.deposits.push(deposit.clone()).unwrap();
|
||||||
|
}
|
||||||
|
for _ in 0..E::MaxVoluntaryExits::to_usize() {
|
||||||
|
block
|
||||||
|
.body
|
||||||
|
.voluntary_exits
|
||||||
|
.push(signed_voluntary_exit.clone())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
for _ in 0..E::MaxBlsToExecutionChanges::to_usize() {
|
||||||
|
block
|
||||||
|
.body
|
||||||
|
.bls_to_execution_changes
|
||||||
|
.push(signed_bls_to_execution_change.clone())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
for _ in 0..E::MaxPayloadAttestations::to_usize() {
|
||||||
|
block
|
||||||
|
.body
|
||||||
|
.payload_attestations
|
||||||
|
.push(payload_attestation.clone())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
block
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(EIP-7732) Mark's branch had the following implementation but not sure if it's needed so will just add header below for reference
|
// TODO(EIP-7732) Mark's branch had the following implementation but not sure if it's needed so will just add header below for reference
|
||||||
// impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockEIP7732<E, Payload> {
|
// impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockEIP7732<E, Payload> {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user