Skip to content

Commit

Permalink
Compiles after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanjay176 committed Mar 31, 2022
1 parent 3323ed9 commit 08ee162
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
12 changes: 7 additions & 5 deletions beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -656,11 +656,12 @@ mod tests {

/// Merge block with length < max_rpc_size.
fn merge_block_small(fork_context: &ForkContext) -> SignedBeaconBlock<Spec> {
let mut block = BeaconBlockMerge::empty(&Spec::default_spec());
let mut block: BeaconBlockMerge<_, FullPayload<Spec>> =
BeaconBlockMerge::empty(&Spec::default_spec());
let tx = VariableList::from(vec![0; 1024]);
let txs = VariableList::from(std::iter::repeat(tx).take(100).collect::<Vec<_>>());

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));
Expand All @@ -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<Spec> {
let mut block = BeaconBlockMerge::empty(&Spec::default_spec());
let mut block: BeaconBlockMerge<_, FullPayload<Spec>> =
BeaconBlockMerge::empty(&Spec::default_spec());
let tx = VariableList::from(vec![0; 1024]);
let txs = VariableList::from(std::iter::repeat(tx).take(100000).collect::<Vec<_>>());

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));
Expand Down
13 changes: 4 additions & 9 deletions beacon_node/lighthouse_network/src/rpc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<MainnetEthSpec>::from_block(
BeaconBlock::Merge(BeaconBlockMerge::<MainnetEthSpec>::full(&MainnetEthSpec::default_spec())),
Signature::empty(),
)
.as_ssz_bytes()
.len()
- types::ExecutionPayload::<MainnetEthSpec>::empty().as_ssz_bytes().len() // subtracting size of empty execution payload included above
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_size(); // adding max size of execution payload (~16gb)
// Size of a full altair block
*SIGNED_BEACON_BLOCK_ALTAIR_MAX
+ types::ExecutionPayload::<MainnetEthSpec>::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::<Hash256, MaxRequestBlocks>::from(Vec::<Hash256>::new())
Expand Down

0 comments on commit 08ee162

Please sign in to comment.