diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index 0df2fc1a1bf..9a18b3336eb 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -618,7 +618,7 @@ mod tests { use std::sync::Arc; use types::{ BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, Epoch, ForkContext, - Hash256, Signature, SignedBeaconBlock, Slot, + FullPayload, Hash256, Signature, SignedBeaconBlock, Slot, }; use snap::write::FrameEncoder; @@ -656,11 +656,12 @@ mod tests { /// Merge block with length < max_rpc_size. fn merge_block_small(fork_context: &ForkContext) -> SignedBeaconBlock { - let mut block = BeaconBlockMerge::empty(&Spec::default_spec()); + let mut block: BeaconBlockMerge<_, FullPayload> = + BeaconBlockMerge::empty(&Spec::default_spec()); let tx = VariableList::from(vec![0; 1024]); let txs = VariableList::from(std::iter::repeat(tx).take(100).collect::>()); - block.body.execution_payload.transactions = txs; + block.body.execution_payload.execution_payload.transactions = txs; let block = BeaconBlock::Merge(block); assert!(block.ssz_bytes_len() <= max_rpc_size(fork_context)); @@ -671,11 +672,12 @@ mod tests { /// The max limit for a merge block is in the order of ~16GiB which wouldn't fit in memory. /// Hence, we generate a merge block just greater than `MAX_RPC_SIZE` to test rejection on the rpc layer. fn merge_block_large(fork_context: &ForkContext) -> SignedBeaconBlock { - let mut block = BeaconBlockMerge::empty(&Spec::default_spec()); + let mut block: BeaconBlockMerge<_, FullPayload> = + BeaconBlockMerge::empty(&Spec::default_spec()); let tx = VariableList::from(vec![0; 1024]); let txs = VariableList::from(std::iter::repeat(tx).take(100000).collect::>()); - block.body.execution_payload.transactions = txs; + block.body.execution_payload.execution_payload.transactions = txs; let block = BeaconBlock::Merge(block); assert!(block.ssz_bytes_len() > max_rpc_size(fork_context)); diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 8898d774125..c0431253735 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -66,15 +66,10 @@ lazy_static! { /// Note: This is only the theoretical upper bound. We further bound the max size we receive over the network /// with `MAX_RPC_SIZE_POST_MERGE`. pub static ref SIGNED_BEACON_BLOCK_MERGE_MAX: usize = - // Size of a full merge block with an empty execution payload - SignedBeaconBlock::::from_block( - BeaconBlock::Merge(BeaconBlockMerge::::full(&MainnetEthSpec::default_spec())), - Signature::empty(), - ) - .as_ssz_bytes() - .len() - - types::ExecutionPayload::::empty().as_ssz_bytes().len() // subtracting size of empty execution payload included above - + types::ExecutionPayload::::max_execution_payload_size(); // adding max size of execution payload (~16gb) + // Size of a full altair block + *SIGNED_BEACON_BLOCK_ALTAIR_MAX + + types::ExecutionPayload::::max_execution_payload_size() // adding max size of execution payload (~16gb) + + ssz::BYTES_PER_LENGTH_OFFSET; // Adding the additional ssz offset for the `ExecutionPayload` field pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize = VariableList::::from(Vec::::new())