Skip to content

Commit b1a19a8

Browse files
authored
Remove ineffectual block RPC limits post merge (#6798)
* Remove ineffectual block RPC limits post merge * Remove more things
1 parent e98209d commit b1a19a8

File tree

3 files changed

+9
-326
lines changed

3 files changed

+9
-326
lines changed

beacon_node/lighthouse_network/src/rpc/protocol.rs

Lines changed: 8 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ use tokio_util::{
1717
compat::{Compat, FuturesAsyncReadCompatExt},
1818
};
1919
use types::{
20-
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockCapella, BeaconBlockElectra,
21-
BeaconBlockFulu, BlobSidecar, ChainSpec, DataColumnSidecar, EmptyBlock, EthSpec, EthSpecId,
22-
ForkContext, ForkName, LightClientBootstrap, LightClientBootstrapAltair,
23-
LightClientFinalityUpdate, LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
24-
LightClientOptimisticUpdateAltair, LightClientUpdate, MainnetEthSpec, MinimalEthSpec,
25-
Signature, SignedBeaconBlock,
20+
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BlobSidecar, ChainSpec, DataColumnSidecar,
21+
EmptyBlock, EthSpec, EthSpecId, ForkContext, ForkName, LightClientBootstrap,
22+
LightClientBootstrapAltair, LightClientFinalityUpdate, LightClientFinalityUpdateAltair,
23+
LightClientOptimisticUpdate, LightClientOptimisticUpdateAltair, LightClientUpdate,
24+
MainnetEthSpec, MinimalEthSpec, Signature, SignedBeaconBlock,
2625
};
2726

2827
// Note: Hardcoding the `EthSpec` type for `SignedBeaconBlock` as min/max values is
@@ -55,74 +54,16 @@ pub static SIGNED_BEACON_BLOCK_ALTAIR_MAX: LazyLock<usize> = LazyLock::new(|| {
5554
.len()
5655
});
5756

58-
pub static SIGNED_BEACON_BLOCK_CAPELLA_MAX_WITHOUT_PAYLOAD: LazyLock<usize> = LazyLock::new(|| {
59-
SignedBeaconBlock::<MainnetEthSpec>::from_block(
60-
BeaconBlock::Capella(BeaconBlockCapella::full(&MainnetEthSpec::default_spec())),
61-
Signature::empty(),
62-
)
63-
.as_ssz_bytes()
64-
.len()
65-
});
66-
67-
pub static SIGNED_BEACON_BLOCK_ELECTRA_MAX_WITHOUT_PAYLOAD: LazyLock<usize> = LazyLock::new(|| {
68-
SignedBeaconBlock::<MainnetEthSpec>::from_block(
69-
BeaconBlock::Electra(BeaconBlockElectra::full(&MainnetEthSpec::default_spec())),
70-
Signature::empty(),
71-
)
72-
.as_ssz_bytes()
73-
.len()
74-
});
75-
76-
pub static SIGNED_BEACON_BLOCK_FULU_MAX_WITHOUT_PAYLOAD: LazyLock<usize> = LazyLock::new(|| {
77-
SignedBeaconBlock::<MainnetEthSpec>::from_block(
78-
BeaconBlock::Fulu(BeaconBlockFulu::full(&MainnetEthSpec::default_spec())),
79-
Signature::empty(),
80-
)
81-
.as_ssz_bytes()
82-
.len()
83-
});
84-
8557
/// The `BeaconBlockBellatrix` block has an `ExecutionPayload` field which has a max size ~16 GiB for future proofing.
8658
/// We calculate the value from its fields instead of constructing the block and checking the length.
8759
/// Note: This is only the theoretical upper bound. We further bound the max size we receive over the network
8860
/// with `max_chunk_size`.
89-
///
90-
/// FIXME: Given that these limits are useless we should probably delete them. See:
91-
///
92-
/// https://github.com/sigp/lighthouse/issues/6790
9361
pub static SIGNED_BEACON_BLOCK_BELLATRIX_MAX: LazyLock<usize> =
9462
LazyLock::new(|| // Size of a full altair block
9563
*SIGNED_BEACON_BLOCK_ALTAIR_MAX
9664
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_bellatrix_size() // adding max size of execution payload (~16gb)
9765
+ ssz::BYTES_PER_LENGTH_OFFSET); // Adding the additional ssz offset for the `ExecutionPayload` field
9866

99-
pub static SIGNED_BEACON_BLOCK_CAPELLA_MAX: LazyLock<usize> = LazyLock::new(|| {
100-
*SIGNED_BEACON_BLOCK_CAPELLA_MAX_WITHOUT_PAYLOAD
101-
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_capella_size() // adding max size of execution payload (~16gb)
102-
+ ssz::BYTES_PER_LENGTH_OFFSET
103-
}); // Adding the additional ssz offset for the `ExecutionPayload` field
104-
105-
pub static SIGNED_BEACON_BLOCK_DENEB_MAX: LazyLock<usize> = LazyLock::new(|| {
106-
*SIGNED_BEACON_BLOCK_CAPELLA_MAX_WITHOUT_PAYLOAD
107-
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_deneb_size() // adding max size of execution payload (~16gb)
108-
+ ssz::BYTES_PER_LENGTH_OFFSET // Adding the additional offsets for the `ExecutionPayload`
109-
+ ssz::BYTES_PER_LENGTH_OFFSET
110-
}); // Length offset for the blob commitments field.
111-
//
112-
pub static SIGNED_BEACON_BLOCK_ELECTRA_MAX: LazyLock<usize> = LazyLock::new(|| {
113-
*SIGNED_BEACON_BLOCK_ELECTRA_MAX_WITHOUT_PAYLOAD
114-
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_electra_size() // adding max size of execution payload (~16gb)
115-
+ ssz::BYTES_PER_LENGTH_OFFSET // Adding the additional ssz offset for the `ExecutionPayload` field
116-
+ ssz::BYTES_PER_LENGTH_OFFSET
117-
}); // Length offset for the blob commitments field.
118-
119-
pub static SIGNED_BEACON_BLOCK_FULU_MAX: LazyLock<usize> = LazyLock::new(|| {
120-
*SIGNED_BEACON_BLOCK_FULU_MAX_WITHOUT_PAYLOAD
121-
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_fulu_size()
122-
+ ssz::BYTES_PER_LENGTH_OFFSET
123-
+ ssz::BYTES_PER_LENGTH_OFFSET
124-
});
125-
12667
pub static BLOB_SIDECAR_SIZE: LazyLock<usize> =
12768
LazyLock::new(BlobSidecar::<MainnetEthSpec>::max_size);
12869

@@ -203,26 +144,12 @@ pub fn rpc_block_limits_by_fork(current_fork: ForkName) -> RpcLimits {
203144
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair blocks
204145
*SIGNED_BEACON_BLOCK_ALTAIR_MAX, // Altair block is larger than base blocks
205146
),
206-
ForkName::Bellatrix => RpcLimits::new(
147+
// After the merge the max SSZ size of a block is absurdly big. The size is actually
148+
// bound by other constants, so here we default to the bellatrix's max value
149+
_ => RpcLimits::new(
207150
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
208151
*SIGNED_BEACON_BLOCK_BELLATRIX_MAX, // Bellatrix block is larger than base and altair blocks
209152
),
210-
ForkName::Capella => RpcLimits::new(
211-
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
212-
*SIGNED_BEACON_BLOCK_CAPELLA_MAX, // Capella block is larger than base, altair and merge blocks
213-
),
214-
ForkName::Deneb => RpcLimits::new(
215-
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
216-
*SIGNED_BEACON_BLOCK_DENEB_MAX, // Deneb block is larger than all prior fork blocks
217-
),
218-
ForkName::Electra => RpcLimits::new(
219-
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
220-
*SIGNED_BEACON_BLOCK_ELECTRA_MAX, // Electra block is larger than Deneb block
221-
),
222-
ForkName::Fulu => RpcLimits::new(
223-
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than all other blocks
224-
*SIGNED_BEACON_BLOCK_FULU_MAX, // Fulu block is largest
225-
),
226153
}
227154
}
228155

consensus/types/src/beacon_block.rs

Lines changed: 1 addition & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use test_random_derive::TestRandom;
1212
use tree_hash::TreeHash;
1313
use tree_hash_derive::TreeHash;
1414

15-
use self::indexed_attestation::{IndexedAttestationBase, IndexedAttestationElectra};
15+
use self::indexed_attestation::IndexedAttestationBase;
1616

1717
/// A block of the `BeaconChain`.
1818
#[superstruct(
@@ -499,52 +499,6 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockBell
499499
}
500500
}
501501

502-
impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockCapella<E, Payload> {
503-
/// Return a Capella block where the block has maximum size.
504-
pub fn full(spec: &ChainSpec) -> Self {
505-
let base_block: BeaconBlockBase<_, Payload> = BeaconBlockBase::full(spec);
506-
let bls_to_execution_changes = vec![
507-
SignedBlsToExecutionChange {
508-
message: BlsToExecutionChange {
509-
validator_index: 0,
510-
from_bls_pubkey: PublicKeyBytes::empty(),
511-
to_execution_address: Address::ZERO,
512-
},
513-
signature: Signature::empty()
514-
};
515-
E::max_bls_to_execution_changes()
516-
]
517-
.into();
518-
let sync_aggregate = SyncAggregate {
519-
sync_committee_signature: AggregateSignature::empty(),
520-
sync_committee_bits: BitVector::default(),
521-
};
522-
BeaconBlockCapella {
523-
slot: spec.genesis_slot,
524-
proposer_index: 0,
525-
parent_root: Hash256::zero(),
526-
state_root: Hash256::zero(),
527-
body: BeaconBlockBodyCapella {
528-
proposer_slashings: base_block.body.proposer_slashings,
529-
attester_slashings: base_block.body.attester_slashings,
530-
attestations: base_block.body.attestations,
531-
deposits: base_block.body.deposits,
532-
voluntary_exits: base_block.body.voluntary_exits,
533-
bls_to_execution_changes,
534-
sync_aggregate,
535-
randao_reveal: Signature::empty(),
536-
eth1_data: Eth1Data {
537-
deposit_root: Hash256::zero(),
538-
block_hash: Hash256::zero(),
539-
deposit_count: 0,
540-
},
541-
graffiti: Graffiti::default(),
542-
execution_payload: Payload::Capella::default(),
543-
},
544-
}
545-
}
546-
}
547-
548502
impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockCapella<E, Payload> {
549503
/// Returns an empty Capella block to be used during genesis.
550504
fn empty(spec: &ChainSpec) -> Self {
@@ -604,79 +558,6 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockDene
604558
}
605559
}
606560

607-
impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockElectra<E, Payload> {
608-
/// Return a Electra block where the block has maximum size.
609-
pub fn full(spec: &ChainSpec) -> Self {
610-
let base_block: BeaconBlockBase<_, Payload> = BeaconBlockBase::full(spec);
611-
let indexed_attestation: IndexedAttestationElectra<E> = IndexedAttestationElectra {
612-
attesting_indices: VariableList::new(vec![0_u64; E::MaxValidatorsPerSlot::to_usize()])
613-
.unwrap(),
614-
data: AttestationData::default(),
615-
signature: AggregateSignature::empty(),
616-
};
617-
let attester_slashings = vec![
618-
AttesterSlashingElectra {
619-
attestation_1: indexed_attestation.clone(),
620-
attestation_2: indexed_attestation,
621-
};
622-
E::max_attester_slashings_electra()
623-
]
624-
.into();
625-
let attestation = AttestationElectra {
626-
aggregation_bits: BitList::with_capacity(E::MaxValidatorsPerSlot::to_usize()).unwrap(),
627-
data: AttestationData::default(),
628-
signature: AggregateSignature::empty(),
629-
committee_bits: BitVector::new(),
630-
};
631-
let mut attestations_electra = vec![];
632-
for _ in 0..E::MaxAttestationsElectra::to_usize() {
633-
attestations_electra.push(attestation.clone());
634-
}
635-
636-
let bls_to_execution_changes = vec![
637-
SignedBlsToExecutionChange {
638-
message: BlsToExecutionChange {
639-
validator_index: 0,
640-
from_bls_pubkey: PublicKeyBytes::empty(),
641-
to_execution_address: Address::ZERO,
642-
},
643-
signature: Signature::empty()
644-
};
645-
E::max_bls_to_execution_changes()
646-
]
647-
.into();
648-
let sync_aggregate = SyncAggregate {
649-
sync_committee_signature: AggregateSignature::empty(),
650-
sync_committee_bits: BitVector::default(),
651-
};
652-
BeaconBlockElectra {
653-
slot: spec.genesis_slot,
654-
proposer_index: 0,
655-
parent_root: Hash256::zero(),
656-
state_root: Hash256::zero(),
657-
body: BeaconBlockBodyElectra {
658-
proposer_slashings: base_block.body.proposer_slashings,
659-
attester_slashings,
660-
attestations: attestations_electra.into(),
661-
deposits: base_block.body.deposits,
662-
voluntary_exits: base_block.body.voluntary_exits,
663-
bls_to_execution_changes,
664-
sync_aggregate,
665-
randao_reveal: Signature::empty(),
666-
eth1_data: Eth1Data {
667-
deposit_root: Hash256::zero(),
668-
block_hash: Hash256::zero(),
669-
deposit_count: 0,
670-
},
671-
graffiti: Graffiti::default(),
672-
execution_payload: Payload::Electra::default(),
673-
blob_kzg_commitments: VariableList::empty(),
674-
execution_requests: ExecutionRequests::default(),
675-
},
676-
}
677-
}
678-
}
679-
680561
impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockElectra<E, Payload> {
681562
/// Returns an empty Electra block to be used during genesis.
682563
fn empty(spec: &ChainSpec) -> Self {
@@ -708,79 +589,6 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockElec
708589
}
709590
}
710591

711-
impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockFulu<E, Payload> {
712-
/// Return a Fulu block where the block has maximum size.
713-
pub fn full(spec: &ChainSpec) -> Self {
714-
let base_block: BeaconBlockBase<_, Payload> = BeaconBlockBase::full(spec);
715-
let indexed_attestation: IndexedAttestationElectra<E> = IndexedAttestationElectra {
716-
attesting_indices: VariableList::new(vec![0_u64; E::MaxValidatorsPerSlot::to_usize()])
717-
.unwrap(),
718-
data: AttestationData::default(),
719-
signature: AggregateSignature::empty(),
720-
};
721-
let attester_slashings = vec![
722-
AttesterSlashingElectra {
723-
attestation_1: indexed_attestation.clone(),
724-
attestation_2: indexed_attestation,
725-
};
726-
E::max_attester_slashings_electra()
727-
]
728-
.into();
729-
let attestation = AttestationElectra {
730-
aggregation_bits: BitList::with_capacity(E::MaxValidatorsPerSlot::to_usize()).unwrap(),
731-
data: AttestationData::default(),
732-
signature: AggregateSignature::empty(),
733-
committee_bits: BitVector::new(),
734-
};
735-
let mut attestations_electra = vec![];
736-
for _ in 0..E::MaxAttestationsElectra::to_usize() {
737-
attestations_electra.push(attestation.clone());
738-
}
739-
740-
let bls_to_execution_changes = vec![
741-
SignedBlsToExecutionChange {
742-
message: BlsToExecutionChange {
743-
validator_index: 0,
744-
from_bls_pubkey: PublicKeyBytes::empty(),
745-
to_execution_address: Address::ZERO,
746-
},
747-
signature: Signature::empty()
748-
};
749-
E::max_bls_to_execution_changes()
750-
]
751-
.into();
752-
let sync_aggregate = SyncAggregate {
753-
sync_committee_signature: AggregateSignature::empty(),
754-
sync_committee_bits: BitVector::default(),
755-
};
756-
BeaconBlockFulu {
757-
slot: spec.genesis_slot,
758-
proposer_index: 0,
759-
parent_root: Hash256::zero(),
760-
state_root: Hash256::zero(),
761-
body: BeaconBlockBodyFulu {
762-
proposer_slashings: base_block.body.proposer_slashings,
763-
attester_slashings,
764-
attestations: attestations_electra.into(),
765-
deposits: base_block.body.deposits,
766-
voluntary_exits: base_block.body.voluntary_exits,
767-
bls_to_execution_changes,
768-
sync_aggregate,
769-
randao_reveal: Signature::empty(),
770-
eth1_data: Eth1Data {
771-
deposit_root: Hash256::zero(),
772-
block_hash: Hash256::zero(),
773-
deposit_count: 0,
774-
},
775-
graffiti: Graffiti::default(),
776-
execution_payload: Payload::Fulu::default(),
777-
blob_kzg_commitments: VariableList::empty(),
778-
execution_requests: ExecutionRequests::default(),
779-
},
780-
}
781-
}
782-
}
783-
784592
impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockFulu<E, Payload> {
785593
/// Returns an empty Fulu block to be used during genesis.
786594
fn empty(spec: &ChainSpec) -> Self {

0 commit comments

Comments
 (0)