Merge branch 'unstable' into merge-unstable-to-deneb-20230808

# Conflicts:
#	Cargo.lock
#	beacon_node/beacon_chain/src/lib.rs
#	beacon_node/execution_layer/src/engine_api.rs
#	beacon_node/execution_layer/src/engine_api/http.rs
#	beacon_node/execution_layer/src/test_utils/mod.rs
#	beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs
#	beacon_node/lighthouse_network/src/rpc/handler.rs
#	beacon_node/lighthouse_network/src/rpc/protocol.rs
#	beacon_node/lighthouse_network/src/service/utils.rs
#	beacon_node/lighthouse_network/tests/rpc_tests.rs
#	beacon_node/network/Cargo.toml
#	beacon_node/network/src/network_beacon_processor/tests.rs
#	lcli/src/parse_ssz.rs
#	scripts/cross/Dockerfile
#	validator_client/src/block_service.rs
#	validator_client/src/validator_store.rs
This commit is contained in:
Jimmy Chen
2023-08-08 16:33:32 +10:00
161 changed files with 8729 additions and 3368 deletions

View File

@@ -1,5 +1,5 @@
#![cfg(test)]
use libp2p::gossipsub::GossipsubConfigBuilder;
use libp2p::gossipsub;
use lighthouse_network::service::Network as LibP2PService;
use lighthouse_network::Enr;
use lighthouse_network::EnrExt;
@@ -84,7 +84,7 @@ pub fn build_config(port: u16, mut boot_nodes: Vec<Enr>) -> NetworkConfig {
config.boot_nodes_enr.append(&mut boot_nodes);
config.network_dir = path.into_path();
// Reduce gossipsub heartbeat parameters
config.gs_config = GossipsubConfigBuilder::from(config.gs_config)
config.gs_config = gossipsub::ConfigBuilder::from(config.gs_config)
.heartbeat_initial_delay(Duration::from_millis(500))
.heartbeat_interval(Duration::from_millis(500))
.build()
@@ -97,6 +97,7 @@ pub async fn build_libp2p_instance(
boot_nodes: Vec<Enr>,
log: slog::Logger,
fork_name: ForkName,
spec: &ChainSpec,
) -> Libp2pInstance {
let port = unused_tcp4_port().unwrap();
let config = build_config(port, boot_nodes);
@@ -109,7 +110,7 @@ pub async fn build_libp2p_instance(
config: &config,
enr_fork_id: EnrForkId::default(),
fork_context: Arc::new(fork_context(fork_name)),
chain_spec: &ChainSpec::minimal(),
chain_spec: spec,
gossipsub_registry: None,
};
Libp2pInstance(
@@ -133,12 +134,13 @@ pub async fn build_node_pair(
rt: Weak<Runtime>,
log: &slog::Logger,
fork_name: ForkName,
spec: &ChainSpec,
) -> (Libp2pInstance, Libp2pInstance) {
let sender_log = log.new(o!("who" => "sender"));
let receiver_log = log.new(o!("who" => "receiver"));
let mut sender = build_libp2p_instance(rt.clone(), vec![], sender_log, fork_name).await;
let mut receiver = build_libp2p_instance(rt, vec![], receiver_log, fork_name).await;
let mut sender = build_libp2p_instance(rt.clone(), vec![], sender_log, fork_name, spec).await;
let mut receiver = build_libp2p_instance(rt, vec![], receiver_log, fork_name, spec).await;
let receiver_multiaddr = receiver.local_enr().multiaddr()[1].clone();
@@ -183,10 +185,11 @@ pub async fn build_linear(
log: slog::Logger,
n: usize,
fork_name: ForkName,
spec: &ChainSpec,
) -> Vec<Libp2pInstance> {
let mut nodes = Vec::with_capacity(n);
for _ in 0..n {
nodes.push(build_libp2p_instance(rt.clone(), vec![], log.clone(), fork_name).await);
nodes.push(build_libp2p_instance(rt.clone(), vec![], log.clone(), fork_name, spec).await);
}
let multiaddrs: Vec<Multiaddr> = nodes

View File

@@ -9,9 +9,9 @@ use std::time::Duration;
use tokio::runtime::Runtime;
use tokio::time::sleep;
use types::{
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, BlobSidecar, EmptyBlock,
Epoch, EthSpec, ForkContext, ForkName, Hash256, MinimalEthSpec, Signature, SignedBeaconBlock,
Slot,
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, BlobSidecar, ChainSpec,
EmptyBlock, Epoch, EthSpec, ForkContext, ForkName, Hash256, MinimalEthSpec, Signature,
SignedBeaconBlock, Slot,
};
mod common;
@@ -19,30 +19,30 @@ mod common;
type E = MinimalEthSpec;
/// Merge block with length < max_rpc_size.
fn merge_block_small(fork_context: &ForkContext) -> BeaconBlock<E> {
let mut block = BeaconBlockMerge::<E>::empty(&E::default_spec());
fn merge_block_small(fork_context: &ForkContext, spec: &ChainSpec) -> BeaconBlock<E> {
let mut block = BeaconBlockMerge::<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);
assert!(block.ssz_bytes_len() <= max_rpc_size(fork_context));
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) -> BeaconBlock<E> {
let mut block = BeaconBlockMerge::<E>::empty(&E::default_spec());
fn merge_block_large(fork_context: &ForkContext, spec: &ChainSpec) -> BeaconBlock<E> {
let mut block = BeaconBlockMerge::<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);
assert!(block.ssz_bytes_len() > max_rpc_size(fork_context));
assert!(block.ssz_bytes_len() > max_rpc_size(fork_context, spec.max_chunk_size as usize));
block
}
@@ -58,10 +58,12 @@ fn test_status_rpc() {
let log = common::build_log(log_level, enable_logging);
let spec = E::default_spec();
rt.block_on(async {
// get sender/receiver
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base, &spec).await;
// Dummy STATUS RPC message
let rpc_request = Request::Status(StatusMessage {
@@ -150,10 +152,12 @@ fn test_blocks_by_range_chunked_rpc() {
let rt = Arc::new(Runtime::new().unwrap());
let spec = E::default_spec();
rt.block_on(async {
// get sender/receiver
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Merge).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Merge, &spec).await;
// BlocksByRange Request
let rpc_request = Request::BlocksByRange(BlocksByRangeRequest::new(0, messages_to_send));
@@ -169,7 +173,7 @@ fn test_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));
let full_block = merge_block_small(&common::fork_context(ForkName::Merge), &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)));
@@ -277,8 +281,9 @@ fn test_blobs_by_range_chunked_rpc() {
rt.block_on(async {
// get sender/receiver
let spec = E::default_spec();
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Deneb).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Deneb, &spec).await;
// BlobsByRange Request
let rpc_request = Request::BlobsByRange(BlobsByRangeRequest {
@@ -379,16 +384,18 @@ fn test_blocks_by_range_over_limit() {
let rt = Arc::new(Runtime::new().unwrap());
let spec = E::default_spec();
rt.block_on(async {
// get sender/receiver
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Merge).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Merge, &spec).await;
// BlocksByRange Request
let rpc_request = Request::BlocksByRange(BlocksByRangeRequest::new(0, messages_to_send));
// BlocksByRange Response
let full_block = merge_block_large(&common::fork_context(ForkName::Merge));
let full_block = merge_block_large(&common::fork_context(ForkName::Merge), &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)));
@@ -461,10 +468,12 @@ fn test_blocks_by_range_chunked_rpc_terminates_correctly() {
let rt = Arc::new(Runtime::new().unwrap());
let spec = E::default_spec();
rt.block_on(async {
// get sender/receiver
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base, &spec).await;
// BlocksByRange Request
let rpc_request = Request::BlocksByRange(BlocksByRangeRequest::new(0, messages_to_send));
@@ -581,10 +590,12 @@ fn test_blocks_by_range_single_empty_rpc() {
let log = common::build_log(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
let spec = E::default_spec();
rt.block_on(async {
// get sender/receiver
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base, &spec).await;
// BlocksByRange Request
let rpc_request = Request::BlocksByRange(BlocksByRangeRequest::new(0, 10));
@@ -685,7 +696,7 @@ fn test_blocks_by_root_chunked_rpc() {
// get sender/receiver
rt.block_on(async {
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Merge).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Merge, &spec).await;
// BlocksByRoot Request
let rpc_request =
@@ -707,7 +718,7 @@ fn test_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));
let full_block = merge_block_small(&common::fork_context(ForkName::Merge), &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)));
@@ -812,7 +823,7 @@ fn test_blocks_by_root_chunked_rpc_terminates_correctly() {
// get sender/receiver
rt.block_on(async {
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base, &spec).await;
// BlocksByRoot Request
let rpc_request =
@@ -939,10 +950,13 @@ fn test_goodbye_rpc() {
let log = common::build_log(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
let spec = E::default_spec();
// get sender/receiver
rt.block_on(async {
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base).await;
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base, &spec).await;
// build the sender future
let sender_future = async {