mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Rename Merge to Bellatrix (#5601)
* Rename Merge to Bellatrix * Remove tree-hash-cache which got readded from the rebase
This commit is contained in:
@@ -13,37 +13,37 @@ use std::time::Duration;
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio::time::sleep;
|
||||
use types::{
|
||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, BlobSidecar, ChainSpec,
|
||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockBellatrix, BlobSidecar, ChainSpec,
|
||||
EmptyBlock, Epoch, EthSpec, ForkContext, ForkName, Hash256, MinimalEthSpec, Signature,
|
||||
SignedBeaconBlock, Slot,
|
||||
};
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
|
||||
/// Merge block with length < max_rpc_size.
|
||||
fn merge_block_small(fork_context: &ForkContext, spec: &ChainSpec) -> BeaconBlock<E> {
|
||||
let mut block = BeaconBlockMerge::<E>::empty(spec);
|
||||
/// Bellatrix block with length < max_rpc_size.
|
||||
fn bellatrix_block_small(fork_context: &ForkContext, spec: &ChainSpec) -> BeaconBlock<E> {
|
||||
let mut block = BeaconBlockBellatrix::<E>::empty(spec);
|
||||
let tx = VariableList::from(vec![0; 1024]);
|
||||
let txs = VariableList::from(std::iter::repeat(tx).take(5000).collect::<Vec<_>>());
|
||||
|
||||
block.body.execution_payload.execution_payload.transactions = txs;
|
||||
|
||||
let block = BeaconBlock::Merge(block);
|
||||
let block = BeaconBlock::Bellatrix(block);
|
||||
assert!(block.ssz_bytes_len() <= max_rpc_size(fork_context, spec.max_chunk_size as usize));
|
||||
block
|
||||
}
|
||||
|
||||
/// Merge block with length > MAX_RPC_SIZE.
|
||||
/// 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, spec: &ChainSpec) -> BeaconBlock<E> {
|
||||
let mut block = BeaconBlockMerge::<E>::empty(spec);
|
||||
/// Bellatrix block with length > MAX_RPC_SIZE.
|
||||
/// The max limit for a bellatrix block is in the order of ~16GiB which wouldn't fit in memory.
|
||||
/// Hence, we generate a bellatrix block just greater than `MAX_RPC_SIZE` to test rejection on the rpc layer.
|
||||
fn bellatrix_block_large(fork_context: &ForkContext, spec: &ChainSpec) -> BeaconBlock<E> {
|
||||
let mut block = BeaconBlockBellatrix::<E>::empty(spec);
|
||||
let tx = VariableList::from(vec![0; 1024]);
|
||||
let txs = VariableList::from(std::iter::repeat(tx).take(100000).collect::<Vec<_>>());
|
||||
|
||||
block.body.execution_payload.execution_payload.transactions = txs;
|
||||
|
||||
let block = BeaconBlock::Merge(block);
|
||||
let block = BeaconBlock::Bellatrix(block);
|
||||
assert!(block.ssz_bytes_len() > max_rpc_size(fork_context, spec.max_chunk_size as usize));
|
||||
block
|
||||
}
|
||||
@@ -167,7 +167,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
|
||||
let (mut sender, mut receiver) = common::build_node_pair(
|
||||
Arc::downgrade(&rt),
|
||||
&log,
|
||||
ForkName::Merge,
|
||||
ForkName::Bellatrix,
|
||||
&spec,
|
||||
Protocol::Tcp,
|
||||
)
|
||||
@@ -187,9 +187,10 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
|
||||
let signed_full_block = SignedBeaconBlock::from_block(full_block, Signature::empty());
|
||||
let rpc_response_altair = Response::BlocksByRange(Some(Arc::new(signed_full_block)));
|
||||
|
||||
let full_block = merge_block_small(&common::fork_context(ForkName::Merge), &spec);
|
||||
let full_block = bellatrix_block_small(&common::fork_context(ForkName::Bellatrix), &spec);
|
||||
let signed_full_block = SignedBeaconBlock::from_block(full_block, Signature::empty());
|
||||
let rpc_response_merge_small = Response::BlocksByRange(Some(Arc::new(signed_full_block)));
|
||||
let rpc_response_bellatrix_small =
|
||||
Response::BlocksByRange(Some(Arc::new(signed_full_block)));
|
||||
|
||||
// keep count of the number of messages received
|
||||
let mut messages_received = 0;
|
||||
@@ -216,7 +217,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
|
||||
} else if messages_received < 4 {
|
||||
assert_eq!(response, rpc_response_altair.clone());
|
||||
} else {
|
||||
assert_eq!(response, rpc_response_merge_small.clone());
|
||||
assert_eq!(response, rpc_response_bellatrix_small.clone());
|
||||
}
|
||||
messages_received += 1;
|
||||
warn!(log, "Chunk received");
|
||||
@@ -249,13 +250,13 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
|
||||
warn!(log, "Receiver got request");
|
||||
for i in 0..messages_to_send {
|
||||
// Send first third of responses as base blocks,
|
||||
// second as altair and third as merge.
|
||||
// second as altair and third as bellatrix.
|
||||
let rpc_response = if i < 2 {
|
||||
rpc_response_base.clone()
|
||||
} else if i < 4 {
|
||||
rpc_response_altair.clone()
|
||||
} else {
|
||||
rpc_response_merge_small.clone()
|
||||
rpc_response_bellatrix_small.clone()
|
||||
};
|
||||
receiver.send_response(peer_id, id, rpc_response.clone());
|
||||
}
|
||||
@@ -368,7 +369,7 @@ fn test_blobs_by_range_chunked_rpc() {
|
||||
warn!(log, "Receiver got request");
|
||||
for _ in 0..messages_to_send {
|
||||
// Send first third of responses as base blocks,
|
||||
// second as altair and third as merge.
|
||||
// second as altair and third as bellatrix.
|
||||
receiver.send_response(peer_id, id, rpc_response.clone());
|
||||
}
|
||||
// send the stream termination
|
||||
@@ -411,7 +412,7 @@ fn test_tcp_blocks_by_range_over_limit() {
|
||||
let (mut sender, mut receiver) = common::build_node_pair(
|
||||
Arc::downgrade(&rt),
|
||||
&log,
|
||||
ForkName::Merge,
|
||||
ForkName::Bellatrix,
|
||||
&spec,
|
||||
Protocol::Tcp,
|
||||
)
|
||||
@@ -421,9 +422,10 @@ fn test_tcp_blocks_by_range_over_limit() {
|
||||
let rpc_request = Request::BlocksByRange(BlocksByRangeRequest::new(0, messages_to_send));
|
||||
|
||||
// BlocksByRange Response
|
||||
let full_block = merge_block_large(&common::fork_context(ForkName::Merge), &spec);
|
||||
let full_block = bellatrix_block_large(&common::fork_context(ForkName::Bellatrix), &spec);
|
||||
let signed_full_block = SignedBeaconBlock::from_block(full_block, Signature::empty());
|
||||
let rpc_response_merge_large = Response::BlocksByRange(Some(Arc::new(signed_full_block)));
|
||||
let rpc_response_bellatrix_large =
|
||||
Response::BlocksByRange(Some(Arc::new(signed_full_block)));
|
||||
|
||||
let request_id = messages_to_send as usize;
|
||||
// build the sender future
|
||||
@@ -458,7 +460,7 @@ fn test_tcp_blocks_by_range_over_limit() {
|
||||
// send the response
|
||||
warn!(log, "Receiver got request");
|
||||
for _ in 0..messages_to_send {
|
||||
let rpc_response = rpc_response_merge_large.clone();
|
||||
let rpc_response = rpc_response_bellatrix_large.clone();
|
||||
receiver.send_response(peer_id, id, rpc_response.clone());
|
||||
}
|
||||
// send the stream termination
|
||||
@@ -736,7 +738,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
let (mut sender, mut receiver) = common::build_node_pair(
|
||||
Arc::downgrade(&rt),
|
||||
&log,
|
||||
ForkName::Merge,
|
||||
ForkName::Bellatrix,
|
||||
&spec,
|
||||
Protocol::Tcp,
|
||||
)
|
||||
@@ -764,9 +766,10 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
let signed_full_block = SignedBeaconBlock::from_block(full_block, Signature::empty());
|
||||
let rpc_response_altair = Response::BlocksByRoot(Some(Arc::new(signed_full_block)));
|
||||
|
||||
let full_block = merge_block_small(&common::fork_context(ForkName::Merge), &spec);
|
||||
let full_block = bellatrix_block_small(&common::fork_context(ForkName::Bellatrix), &spec);
|
||||
let signed_full_block = SignedBeaconBlock::from_block(full_block, Signature::empty());
|
||||
let rpc_response_merge_small = Response::BlocksByRoot(Some(Arc::new(signed_full_block)));
|
||||
let rpc_response_bellatrix_small =
|
||||
Response::BlocksByRoot(Some(Arc::new(signed_full_block)));
|
||||
|
||||
// keep count of the number of messages received
|
||||
let mut messages_received = 0;
|
||||
@@ -790,7 +793,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
} else if messages_received < 4 {
|
||||
assert_eq!(response, rpc_response_altair.clone());
|
||||
} else {
|
||||
assert_eq!(response, rpc_response_merge_small.clone());
|
||||
assert_eq!(response, rpc_response_bellatrix_small.clone());
|
||||
}
|
||||
messages_received += 1;
|
||||
debug!(log, "Chunk received");
|
||||
@@ -822,13 +825,13 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
debug!(log, "Receiver got request");
|
||||
|
||||
for i in 0..messages_to_send {
|
||||
// Send equal base, altair and merge blocks
|
||||
// Send equal base, altair and bellatrix blocks
|
||||
let rpc_response = if i < 2 {
|
||||
rpc_response_base.clone()
|
||||
} else if i < 4 {
|
||||
rpc_response_altair.clone()
|
||||
} else {
|
||||
rpc_response_merge_small.clone()
|
||||
rpc_response_bellatrix_small.clone()
|
||||
};
|
||||
receiver.send_response(peer_id, id, rpc_response);
|
||||
debug!(log, "Sending message");
|
||||
|
||||
Reference in New Issue
Block a user