From 7d5db8015d3c1d23333919b895790671c561886c Mon Sep 17 00:00:00 2001 From: realbigsean Date: Mon, 19 Dec 2022 19:07:21 -0500 Subject: [PATCH 1/8] correctly respond without skips on first range response --- .../beacon_processor/worker/rpc_methods.rs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index 6eae7eed5..1938f389b 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -433,7 +433,17 @@ impl Worker { }; // Pick out the required blocks, ignoring skip-slots. - let mut last_block_root = None; + let mut last_block_root = req + .start_slot + .checked_sub(0) + .map(|prev_slot| { + self.chain + .block_root_at_slot(Slot::new(prev_slot), WhenSlotSkipped::Prev) + }) + .transpose() + .ok() + .flatten() + .flatten(); let maybe_block_roots = process_results(forwards_block_root_iter, |iter| { iter.take_while(|(_, slot)| slot.as_u64() < req.start_slot.saturating_add(req.count)) // map skip slots to None @@ -602,7 +612,17 @@ impl Worker { }; // Pick out the required blocks, ignoring skip-slots. - let mut last_block_root = None; + let mut last_block_root = req + .start_slot + .checked_sub(0) + .map(|prev_slot| { + self.chain + .block_root_at_slot(Slot::new(prev_slot), WhenSlotSkipped::Prev) + }) + .transpose() + .ok() + .flatten() + .flatten(); let maybe_block_roots = process_results(forwards_block_root_iter, |iter| { iter.take_while(|(_, slot)| slot.as_u64() < req.start_slot.saturating_add(req.count)) // map skip slots to None From 9c46a1cb215099456628d1150b9e7a44e5b16afd Mon Sep 17 00:00:00 2001 From: realbigsean Date: Tue, 20 Dec 2022 18:56:07 -0500 Subject: [PATCH 2/8] fix rate limits, and a couple other bugs --- .../src/rpc/codec/ssz_snappy.rs | 4 ++-- .../lighthouse_network/src/rpc/protocol.rs | 19 +++++++++++++++---- .../beacon_processor/worker/rpc_methods.rs | 4 ++-- .../network/src/sync/network_context.rs | 12 ++++++++++-- beacon_node/store/src/hot_cold_store.rs | 4 +--- 5 files changed, 30 insertions(+), 13 deletions(-) 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 ce6e30ebf..e6654a308 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -298,8 +298,8 @@ impl Decoder for SSZSnappyOutboundCodec { .rpc_response_limits::(&self.fork_context); if ssz_limits.is_out_of_bounds(length, self.max_packet_size) { return Err(RPCError::InvalidData(format!( - "RPC response length is out of bounds, length {}", - length + "RPC response length is out of bounds, length {}, max {}, min {}", + length, ssz_limits.max, ssz_limits.min ))); } // Calculate worst case compression length for given uncompressed length diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 0773197e8..2a91a4bb4 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -23,7 +23,7 @@ use tokio_util::{ use types::BlobsSidecar; use types::{ BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, Blob, EmptyBlock, EthSpec, - ForkContext, ForkName, Hash256, MainnetEthSpec, Signature, SignedBeaconBlock, + ForkContext, ForkName, Hash256, MainnetEthSpec, Signature, SignedBeaconBlock }; lazy_static! { @@ -107,6 +107,12 @@ lazy_static! { .as_ssz_bytes() .len(); + pub static ref BLOBS_SIDECAR_MIN: usize = BlobsSidecar::::empty().as_ssz_bytes().len(); + pub static ref BLOBS_SIDECAR_MAX: usize = BlobsSidecar::::max_size(); + + //FIXME(sean) these are underestimates + pub static ref SIGNED_BLOCK_AND_BLOBS_MIN: usize = *BLOBS_SIDECAR_MIN + *SIGNED_BEACON_BLOCK_BASE_MIN; + pub static ref SIGNED_BLOCK_AND_BLOBS_MAX: usize =*BLOBS_SIDECAR_MAX + *SIGNED_BEACON_BLOCK_EIP4844_MAX; } /// The maximum bytes that can be sent across the RPC pre-merge. @@ -359,9 +365,14 @@ impl ProtocolId { Protocol::BlocksByRange => rpc_block_limits_by_fork(fork_context.current_fork()), Protocol::BlocksByRoot => rpc_block_limits_by_fork(fork_context.current_fork()), - //FIXME(sean) add blob sizes - Protocol::BlobsByRange => rpc_block_limits_by_fork(fork_context.current_fork()), - Protocol::BlobsByRoot => rpc_block_limits_by_fork(fork_context.current_fork()), + Protocol::BlobsByRange => RpcLimits::new( + *BLOBS_SIDECAR_MIN, + *BLOBS_SIDECAR_MAX, + ), + Protocol::BlobsByRoot => RpcLimits::new( + *SIGNED_BLOCK_AND_BLOBS_MIN, + *SIGNED_BLOCK_AND_BLOBS_MAX, + ), Protocol::Ping => RpcLimits::new( ::ssz_fixed_len(), diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index 1938f389b..0824ca171 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -435,7 +435,7 @@ impl Worker { // Pick out the required blocks, ignoring skip-slots. let mut last_block_root = req .start_slot - .checked_sub(0) + .checked_sub(1) .map(|prev_slot| { self.chain .block_root_at_slot(Slot::new(prev_slot), WhenSlotSkipped::Prev) @@ -614,7 +614,7 @@ impl Worker { // Pick out the required blocks, ignoring skip-slots. let mut last_block_root = req .start_slot - .checked_sub(0) + .checked_sub(1) .map(|prev_slot| { self.chain .block_root_at_slot(Slot::new(prev_slot), WhenSlotSkipped::Prev) diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index 5917c7ecc..45cbb1935 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -314,14 +314,18 @@ impl SyncNetworkContext { let (chain_id, batch_id, info) = entry.get_mut(); let chain_id = chain_id.clone(); let batch_id = batch_id.clone(); + let stream_terminator = maybe_block.is_none(); info.add_block_response(maybe_block); - let maybe_block = info.pop_response().map(|block_sidecar_pair| { + let maybe_block_wrapped = info.pop_response().map(|block_sidecar_pair| { BlockWrapper::BlockAndBlob { block_sidecar_pair } }); if info.is_finished() { entry.remove(); } - Some((chain_id, batch_id, maybe_block)) + if !stream_terminator && maybe_block_wrapped.is_none() { + return None + } + Some((chain_id, batch_id, maybe_block_wrapped)) } Entry::Vacant(_) => None, } @@ -356,6 +360,7 @@ impl SyncNetworkContext { let (chain_id, batch_id, info) = entry.get_mut(); let chain_id = chain_id.clone(); let batch_id = batch_id.clone(); + let stream_terminator = maybe_sidecar.is_none(); info.add_sidecar_response(maybe_sidecar); let maybe_block = info .pop_response() @@ -363,6 +368,9 @@ impl SyncNetworkContext { if info.is_finished() { entry.remove(); } + if !stream_terminator && maybe_block.is_none() { + return None + } Some((chain_id, batch_id, maybe_block)) } Entry::Vacant(_) => None, diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 732795fce..439c99c01 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -503,9 +503,7 @@ impl, Cold: ItemStore> HotColdDB } pub fn get_blobs(&self, block_root: &Hash256) -> Result>, Error> { - if let Some(blobs) = self.blob_cache.lock().get(block_root) { - Ok(Some(blobs.clone())) - } else if let Some(bytes) = self + if let Some(bytes) = self .hot_db .get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())? { From a67fa516c7f574e33df78d047c5158e003d1cbfd Mon Sep 17 00:00:00 2001 From: realbigsean Date: Tue, 20 Dec 2022 19:32:54 -0500 Subject: [PATCH 3/8] don't expect context bytes for blob messages --- .../src/rpc/codec/ssz_snappy.rs | 64 ++++++++++--------- beacon_node/store/src/hot_cold_store.rs | 2 + scripts/local_testnet/genesis.json | 4 +- scripts/local_testnet/vars.env | 2 +- 4 files changed, 39 insertions(+), 33 deletions(-) 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 e6654a308..ae86ec220 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -570,38 +570,42 @@ fn handle_v1_response( SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?), )))), Protocol::BlobsByRange => { - let fork_name = fork_name.take().ok_or_else(|| { - RPCError::ErrorResponse( - RPCResponseErrorCode::InvalidRequest, - format!("No context bytes provided for {} response", protocol), - ) - })?; - match fork_name { - ForkName::Eip4844 => Ok(Some(RPCResponse::BlobsByRange(Arc::new( - BlobsSidecar::from_ssz_bytes(decoded_buffer)?, - )))), - _ => Err(RPCError::ErrorResponse( - RPCResponseErrorCode::InvalidRequest, - "Invalid forkname for blobsbyrange".to_string(), - )), - } + Ok(Some(RPCResponse::BlobsByRange(Arc::new( + BlobsSidecar::from_ssz_bytes(decoded_buffer)?, + )))) + //FIXME(sean) do we need context bytes? + // let fork_name = fork_name.take().ok_or_else(|| { + // RPCError::ErrorResponse( + // RPCResponseErrorCode::InvalidRequest, + // format!("No context bytes provided for {} response", protocol), + // ) + // })?; + // match fork_name { + // ForkName::Eip4844 => , + // _ => Err(RPCError::ErrorResponse( + // RPCResponseErrorCode::InvalidRequest, + // "Invalid forkname for blobsbyrange".to_string(), + // )), + // } } Protocol::BlobsByRoot => { - let fork_name = fork_name.take().ok_or_else(|| { - RPCError::ErrorResponse( - RPCResponseErrorCode::InvalidRequest, - format!("No context bytes provided for {} response", protocol), - ) - })?; - match fork_name { - ForkName::Eip4844 => Ok(Some(RPCResponse::BlobsByRoot(Arc::new( - SignedBeaconBlockAndBlobsSidecar::from_ssz_bytes(decoded_buffer)?, - )))), - _ => Err(RPCError::ErrorResponse( - RPCResponseErrorCode::InvalidRequest, - "Invalid forkname for blobsbyroot".to_string(), - )), - } + Ok(Some(RPCResponse::BlobsByRoot(Arc::new( + SignedBeaconBlockAndBlobsSidecar::from_ssz_bytes(decoded_buffer)?, + )))) + //FIXME(sean) do we need context bytes? + // let fork_name = fork_name.take().ok_or_else(|| { + // RPCError::ErrorResponse( + // RPCResponseErrorCode::InvalidRequest, + // format!("No context bytes provided for {} response", protocol), + // ) + // })?; + // match fork_name { + // ForkName::Eip4844 => + // _ => Err(RPCError::ErrorResponse( + // RPCResponseErrorCode::InvalidRequest, + // "Invalid forkname for blobsbyroot".to_string(), + // )), + // } } Protocol::Ping => Ok(Some(RPCResponse::Pong(Ping { data: u64::from_ssz_bytes(decoded_buffer)?, diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 439c99c01..00aa0b2af 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -503,6 +503,8 @@ impl, Cold: ItemStore> HotColdDB } pub fn get_blobs(&self, block_root: &Hash256) -> Result>, Error> { + // FIXME(sean) I was attempting to use a blob cache here but was getting deadlocks, + // may want to attempt to use one again if let Some(bytes) = self .hot_db .get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())? diff --git a/scripts/local_testnet/genesis.json b/scripts/local_testnet/genesis.json index 751176048..f89435677 100644 --- a/scripts/local_testnet/genesis.json +++ b/scripts/local_testnet/genesis.json @@ -12,8 +12,8 @@ "berlinBlock": 0, "londonBlock": 0, "mergeNetsplitBlock": 0, - "shanghaiTime": 0, - "shardingForkTime": 0, + "shanghaiTime": 1671582851, + "shardingForkTime": 1671582947, "terminalTotalDifficulty": 0 }, "alloc": { diff --git a/scripts/local_testnet/vars.env b/scripts/local_testnet/vars.env index dbfc41e91..07e315f60 100644 --- a/scripts/local_testnet/vars.env +++ b/scripts/local_testnet/vars.env @@ -1,4 +1,4 @@ -GETH_BINARY=geth +GETH_BINARY=/home/sean/CLionProjects/eip4844-interop/geth/go-ethereum/build/bin/geth # Base directories for the validator keys and secrets DATADIR=~/.lighthouse/local-testnet From ff772311fa6b73cabb3b02c822960038121b40ad Mon Sep 17 00:00:00 2001 From: realbigsean Date: Wed, 21 Dec 2022 13:56:52 -0500 Subject: [PATCH 4/8] add context bytes to blob messages, fix rpc limits, sync past finalized checkpoint during finalized sync so we can advance our own finalization, fix stream termination bug in blobs by range --- .../src/rpc/codec/ssz_snappy.rs | 67 +++++++++---------- .../lighthouse_network/src/rpc/protocol.rs | 27 ++++---- .../beacon_processor/worker/rpc_methods.rs | 2 +- .../network/src/sync/network_context.rs | 25 +++++-- .../network/src/sync/range_sync/chain.rs | 8 ++- scripts/local_testnet/genesis.json | 4 +- 6 files changed, 74 insertions(+), 59 deletions(-) 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 ae86ec220..fb07e6831 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -439,6 +439,9 @@ fn context_bytes( SignedBeaconBlock::Base { .. } => Some(fork_context.genesis_context_bytes()), }; } + if let RPCResponse::BlobsByRange(_) | RPCResponse::BlobsByRoot(_) = rpc_variant { + return fork_context.to_context_bytes(ForkName::Eip4844); + } } } None @@ -570,42 +573,38 @@ fn handle_v1_response( SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?), )))), Protocol::BlobsByRange => { - Ok(Some(RPCResponse::BlobsByRange(Arc::new( - BlobsSidecar::from_ssz_bytes(decoded_buffer)?, - )))) - //FIXME(sean) do we need context bytes? - // let fork_name = fork_name.take().ok_or_else(|| { - // RPCError::ErrorResponse( - // RPCResponseErrorCode::InvalidRequest, - // format!("No context bytes provided for {} response", protocol), - // ) - // })?; - // match fork_name { - // ForkName::Eip4844 => , - // _ => Err(RPCError::ErrorResponse( - // RPCResponseErrorCode::InvalidRequest, - // "Invalid forkname for blobsbyrange".to_string(), - // )), - // } + let fork_name = fork_name.take().ok_or_else(|| { + RPCError::ErrorResponse( + RPCResponseErrorCode::InvalidRequest, + format!("No context bytes provided for {} response", protocol), + ) + })?; + match fork_name { + ForkName::Eip4844 => Ok(Some(RPCResponse::BlobsByRange(Arc::new( + BlobsSidecar::from_ssz_bytes(decoded_buffer)?, + )))), + _ => Err(RPCError::ErrorResponse( + RPCResponseErrorCode::InvalidRequest, + "Invalid forkname for blobsbyrange".to_string(), + )), + } } Protocol::BlobsByRoot => { - Ok(Some(RPCResponse::BlobsByRoot(Arc::new( - SignedBeaconBlockAndBlobsSidecar::from_ssz_bytes(decoded_buffer)?, - )))) - //FIXME(sean) do we need context bytes? - // let fork_name = fork_name.take().ok_or_else(|| { - // RPCError::ErrorResponse( - // RPCResponseErrorCode::InvalidRequest, - // format!("No context bytes provided for {} response", protocol), - // ) - // })?; - // match fork_name { - // ForkName::Eip4844 => - // _ => Err(RPCError::ErrorResponse( - // RPCResponseErrorCode::InvalidRequest, - // "Invalid forkname for blobsbyroot".to_string(), - // )), - // } + let fork_name = fork_name.take().ok_or_else(|| { + RPCError::ErrorResponse( + RPCResponseErrorCode::InvalidRequest, + format!("No context bytes provided for {} response", protocol), + ) + })?; + match fork_name { + ForkName::Eip4844 => Ok(Some(RPCResponse::BlobsByRoot(Arc::new( + SignedBeaconBlockAndBlobsSidecar::from_ssz_bytes(decoded_buffer)?, + )))), + _ => Err(RPCError::ErrorResponse( + RPCResponseErrorCode::InvalidRequest, + "Invalid forkname for blobsbyroot".to_string(), + )), + } } Protocol::Ping => Ok(Some(RPCResponse::Pong(Ping { data: u64::from_ssz_bytes(decoded_buffer)?, diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 2a91a4bb4..8a3149fc5 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -23,7 +23,7 @@ use tokio_util::{ use types::BlobsSidecar; use types::{ BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, Blob, EmptyBlock, EthSpec, - ForkContext, ForkName, Hash256, MainnetEthSpec, Signature, SignedBeaconBlock + ForkContext, ForkName, Hash256, MainnetEthSpec, Signature, SignedBeaconBlock, }; lazy_static! { @@ -364,16 +364,10 @@ impl ProtocolId { Protocol::Goodbye => RpcLimits::new(0, 0), // Goodbye request has no response Protocol::BlocksByRange => rpc_block_limits_by_fork(fork_context.current_fork()), Protocol::BlocksByRoot => rpc_block_limits_by_fork(fork_context.current_fork()), - - Protocol::BlobsByRange => RpcLimits::new( - *BLOBS_SIDECAR_MIN, - *BLOBS_SIDECAR_MAX, - ), - Protocol::BlobsByRoot => RpcLimits::new( - *SIGNED_BLOCK_AND_BLOBS_MIN, - *SIGNED_BLOCK_AND_BLOBS_MAX, - ), - + Protocol::BlobsByRange => RpcLimits::new(*BLOBS_SIDECAR_MIN, *BLOBS_SIDECAR_MAX), + Protocol::BlobsByRoot => { + RpcLimits::new(*SIGNED_BLOCK_AND_BLOBS_MIN, *SIGNED_BLOCK_AND_BLOBS_MAX) + } Protocol::Ping => RpcLimits::new( ::ssz_fixed_len(), ::ssz_fixed_len(), @@ -392,13 +386,16 @@ impl ProtocolId { /// Returns `true` if the given `ProtocolId` should expect `context_bytes` in the /// beginning of the stream, else returns `false`. pub fn has_context_bytes(&self) -> bool { - if self.version == Version::V2 { - match self.message_name { + match self.version { + Version::V2 => match self.message_name { Protocol::BlocksByRange | Protocol::BlocksByRoot => return true, _ => return false, - } + }, + Version::V1 => match self.message_name { + Protocol::BlobsByRange | Protocol::BlobsByRoot => return true, + _ => return false, + }, } - false } } diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index 0824ca171..d85bb1f20 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -689,7 +689,7 @@ impl Worker { self.log, "BlobsByRange Response processed"; "peer" => %peer_id, - "msg" => "Failed to return all requested blocks", + "msg" => "Failed to return all requested blobs", "start_slot" => req.start_slot, "current_slot" => current_slot, "requested" => req.count, diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index 45cbb1935..978bd69d0 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -319,12 +319,18 @@ impl SyncNetworkContext { let maybe_block_wrapped = info.pop_response().map(|block_sidecar_pair| { BlockWrapper::BlockAndBlob { block_sidecar_pair } }); + + if stream_terminator && !info.is_finished() { + return None; + } + if !stream_terminator && maybe_block_wrapped.is_none() { + return None; + } + if info.is_finished() { entry.remove(); } - if !stream_terminator && maybe_block_wrapped.is_none() { - return None - } + Some((chain_id, batch_id, maybe_block_wrapped)) } Entry::Vacant(_) => None, @@ -365,12 +371,19 @@ impl SyncNetworkContext { let maybe_block = info .pop_response() .map(|block_sidecar_pair| BlockWrapper::BlockAndBlob { block_sidecar_pair }); + + if stream_terminator && !info.is_finished() { + return None; + } + + if !stream_terminator && maybe_block.is_none() { + return None; + } + if info.is_finished() { entry.remove(); } - if !stream_terminator && maybe_block.is_none() { - return None - } + Some((chain_id, batch_id, maybe_block)) } Entry::Vacant(_) => None, diff --git a/beacon_node/network/src/sync/range_sync/chain.rs b/beacon_node/network/src/sync/range_sync/chain.rs index 199be788e..46b6d05d7 100644 --- a/beacon_node/network/src/sync/range_sync/chain.rs +++ b/beacon_node/network/src/sync/range_sync/chain.rs @@ -137,10 +137,16 @@ impl SyncingChain { let id = SyncingChain::::id(&target_head_root, &target_head_slot); + let target_slot = if is_finalized_segment { + target_head_slot + (2 * T::EthSpec::slots_per_epoch()) + 1 + } else { + target_head_slot + }; + SyncingChain { id, start_epoch, - target_head_slot, + target_head_slot: target_slot, target_head_root, batches: BTreeMap::new(), peers, diff --git a/scripts/local_testnet/genesis.json b/scripts/local_testnet/genesis.json index f89435677..751176048 100644 --- a/scripts/local_testnet/genesis.json +++ b/scripts/local_testnet/genesis.json @@ -12,8 +12,8 @@ "berlinBlock": 0, "londonBlock": 0, "mergeNetsplitBlock": 0, - "shanghaiTime": 1671582851, - "shardingForkTime": 1671582947, + "shanghaiTime": 0, + "shardingForkTime": 0, "terminalTotalDifficulty": 0 }, "alloc": { From 2f4c44fd88ff50af5bd4225e16f62953f3203f08 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Wed, 21 Dec 2022 14:04:14 -0500 Subject: [PATCH 5/8] remove my binary path for geth --- scripts/local_testnet/vars.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/local_testnet/vars.env b/scripts/local_testnet/vars.env index 07e315f60..dbfc41e91 100644 --- a/scripts/local_testnet/vars.env +++ b/scripts/local_testnet/vars.env @@ -1,4 +1,4 @@ -GETH_BINARY=/home/sean/CLionProjects/eip4844-interop/geth/go-ethereum/build/bin/geth +GETH_BINARY=geth # Base directories for the validator keys and secrets DATADIR=~/.lighthouse/local-testnet From cb28201f5b66243f9150b874c53d62688797f52b Mon Sep 17 00:00:00 2001 From: realbigsean Date: Thu, 22 Dec 2022 08:54:24 -0500 Subject: [PATCH 6/8] update built in 4844 testnet --- .../eip4844/boot_enr.yaml | 6 +- .../eip4844/config.yaml | 94 +++++------------- .../eip4844/genesis.ssz.zip | Bin 3546 -> 3514 bytes scripts/local_testnet/vars.env | 2 +- 4 files changed, 27 insertions(+), 75 deletions(-) diff --git a/common/eth2_network_config/built_in_network_configs/eip4844/boot_enr.yaml b/common/eth2_network_config/built_in_network_configs/eip4844/boot_enr.yaml index 4d52cc597..143387543 100644 --- a/common/eth2_network_config/built_in_network_configs/eip4844/boot_enr.yaml +++ b/common/eth2_network_config/built_in_network_configs/eip4844/boot_enr.yaml @@ -1,3 +1,3 @@ -- enr:-MK4QLij8YaVQ6fIi09rDuD9fufxBlCZRXwfM1q6SbNJfy5ZZdAvtlnsfqhIeI0IqeOZdaPExVCfZfR4JJTIuKXFR76GAYJGrqHnh2F0dG5ldHOIAAAAAAAAAACEZXRoMpBCynldgwAP_QMAAAAAAAAAgmlkgnY0gmlwhCJ7uEyJc2VjcDI1NmsxoQJpeftU6RbmIhcFllICznlAMJXL3EwHEGhn73_Gk0wrCYhzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A -- enr:-JG4QK27MZvV3QbwdLt055Yhei27SjAsDXMFGCdl-Q7SDiCgR_qbiW3BmcOClehFVJgMa6IfjHeJBdbC0jvrr2NycOqGAYJLWb5kgmlkgnY0gmlwhCJE_eeJc2VjcDI1NmsxoQIecO7Y9C7J2Bs7RNxXaUkU6BfmPKIhEsDScKAoxENaRYN0Y3CCdl-DdWRwgnZf -- enr:-JG4QExcHW3vzBcE0f_r-93nSA4iBy4qNLthSyTw7p0tlPwjMl1JVTAgLSNHLLZJzOGtelJO4sw37LliuHyJ55zN5J6GAYJLWTvzgmlkgnY0gmlwhCKq1cmJc2VjcDI1NmsxoQJT2d4jtKQbHNw3tZPLhoMlR73o5LNdi-bk_bYq6siwuIN0Y3CCdl-DdWRwgnZf \ No newline at end of file +- enr:-MK4QFnkGjrt5qw5Ct5XXT9QYvfqmH8Cf6xqKuczTHWixDUZQmngyLrlftv-tMRbXDAxZZQDxNciNTjx7XpW0G4yQguGAYU2Pmnxh2F0dG5ldHOIAAAAAAAAAACEZXRoMpA3FbaXIAAAk___________gmlkgnY0gmlwhCJ5ITWJc2VjcDI1NmsxoQIlwaxycUgJ_Ht4lYdDlInbIuRxu0HcHcFbu0D7As2SLYhzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A +- enr:-MK4QBqN5McD5YYgfEnfQjWUvrSaCITjBvQevlP5q0nCVbKuZRoa2XvGWOBwTDQyLNYiqgeettVwXs0PrSc1rOY2rjKGAYU2M7A8h2F0dG5ldHOIAAAAAAAAAgCEZXRoMpA3FbaXIAAAk___________gmlkgnY0gmlwhCJ6vpeJc2VjcDI1NmsxoQNJzjxNKr7-a-iEDs0KvaL_vo1UH91kefEiWzgAdwSntYhzeW5jbmV0cw-DdGNwgjLIg3VkcIIu4A +- enr:-MK4QEzb6r0hpSyiko9u-mbEX1TzdTD9RcSiU4jhey5jJbTAHLdXNFR32CfjingVa6QMyCPtZRUfzSGbJ0ur3-Pdxe-GAYU2OwM5h2F0dG5ldHOIAAAAAAAAAACEZXRoMpA3FbaXIAAAk___________gmlkgnY0gmlwhCPi7faJc2VjcDI1NmsxoQIKBTGU_riCSYrscdRCLuocbNzhF9RTNItPfD4_PmYngIhzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A diff --git a/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml b/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml index d6e6aef57..88c3107ea 100644 --- a/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml @@ -1,85 +1,37 @@ -# Prater config - -# Extends the mainnet preset -CONFIG_NAME: 'eip4844' -PRESET_BASE: 'mainnet' - -# Transition -# --------------------------------------------------------------- -TERMINAL_TOTAL_DIFFICULTY: 40 -# By default, don't use these params -TERMINAL_BLOCK_HASH: 0x0000000000000000000000000000000000000000000000000000000000000000 -TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: 18446744073709551615 +CONFIG_NAME: testnet +PRESET_BASE: mainnet # Genesis -# --------------------------------------------------------------- -# `2**14` (= 16,384) -MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 2 -# Mar-01-2021 08:53:32 AM +UTC -MIN_GENESIS_TIME: 1653318000 -# Prater area code (Vienna) +# The genesis fork version looks weird for legacy reasons GENESIS_FORK_VERSION: 0x00000ffd -# Customized for Prater: 1919188 seconds (Mar-23-2021 02:00:00 PM +UTC) -GENESIS_DELAY: 0 - - -# Forking -# --------------------------------------------------------------- -# Some forks are disabled for now: -# - These may be re-assigned to another fork-version later -# - Temporarily set to max uint64 value: 2**64 - 1 # Altair -ALTAIR_FORK_VERSION: 0x01000ffd -ALTAIR_FORK_EPOCH: 1 +ALTAIR_FORK_EPOCH: 2 +ALTAIR_FORK_VERSION: 0x20000090 + # Merge -BELLATRIX_FORK_VERSION: 0x02000ffd -BELLATRIX_FORK_EPOCH: 2 -# Sharding -EIP4844_FORK_VERSION: 0x83000ffd -EIP4844_FORK_EPOCH: 3 +BELLATRIX_FORK_EPOCH: 3 +BELLATRIX_FORK_VERSION: 0x20000091 +TERMINAL_TOTAL_DIFFICULTY: 2 -# TBD, 2**32 is a placeholder. Merge transition approach is in active R&D. -TRANSITION_TOTAL_DIFFICULTY: 40 +# Capella +CAPELLA_FORK_EPOCH: 4 +CAPELLA_FORK_VERSION: 0x20000092 +MAX_WITHDRAWALS_PER_PAYLOAD: 4 +# EIP4844 +EIP4844_FORK_EPOCH: 5 +EIP4844_FORK_VERSION: 0x20000093 # Time parameters -# --------------------------------------------------------------- -# 12 seconds SECONDS_PER_SLOT: 12 -# 14 (estimate from Eth1 mainnet) -SECONDS_PER_ETH1_BLOCK: 14 -# 2**8 (= 256) epochs ~27 hours -MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256 -# 2**8 (= 256) epochs ~27 hours -SHARD_COMMITTEE_PERIOD: 256 -# 2**11 (= 2,048) Eth1 blocks ~8 hours -ETH1_FOLLOW_DISTANCE: 15 - - -# Validator cycle -# --------------------------------------------------------------- -# 2**2 (= 4) -INACTIVITY_SCORE_BIAS: 4 -# 2**4 (= 16) -INACTIVITY_SCORE_RECOVERY_RATE: 16 -# 2**4 * 10**9 (= 16,000,000,000) Gwei -EJECTION_BALANCE: 16000000000 -# 2**2 (= 4) -MIN_PER_EPOCH_CHURN_LIMIT: 4 -# 2**16 (= 65,536) -CHURN_LIMIT_QUOTIENT: 65536 - - -# Fork choice -# --------------------------------------------------------------- -# 40% -PROPOSER_SCORE_BOOST: 40 +SLOTS_PER_EPOCH: 32 # Deposit contract -# --------------------------------------------------------------- -# Ethereum Goerli testnet +DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242 + DEPOSIT_CHAIN_ID: 1331 -DEPOSIT_NETWORK_ID: 69 -# Prater test deposit contract on Goerli Testnet -DEPOSIT_CONTRACT_ADDRESS: 0x8A04d14125D0FDCDc742F4A05C051De07232EDa4 +DEPOSIT_NETWORK_ID: 1331 + +ETH1_FOLLOW_DISTANCE: 1 +MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 2 diff --git a/common/eth2_network_config/built_in_network_configs/eip4844/genesis.ssz.zip b/common/eth2_network_config/built_in_network_configs/eip4844/genesis.ssz.zip index 88b405071058d5163f5757e775c7cea3dd4b1183..06c1b45fdcc2cde730587ba28932b174f0ee21a4 100644 GIT binary patch delta 901 zcmV;01A6@08@d}cP)h>@6aWGM2mt*>mR0`Y|4a@I000&QDF6!q8~|r!Ze??6b1rjp zdR0^j00RwRq+=Xlq>(ute{CM6piCuCrY<~kDZ`j{=u9b6Hjn0gU@D5jY#FIBM@^jv zuFW>Du*e+h>(aC_&!A9;=I}sL=1P~Fny#s6u4M-j5x6hmm){Q_o-Ys2KWgE|iGll? zUJSG>Y(8{ec*%ud%Mz}hXtRIJ`tVINXU%`QVMgTLV0qwy#?^n#CI92-t`6g-buGEF zC^lhl)~)pSjwNn6P`7k`)w+HCSJbq-b}qAF1N;G6@DMBOL974<$Bi6uq@-MfvV?bL;p$Z{MSSDp>@mmpw2K`!`?pm|YhS$?_%!wEiNvrwuRPxJ_FLl+l*mC-uBe0=hK&M)jg%?@a){Q>t%ChzMNLj zK0ac><<&!K!nSp)D4Z0t^y*KgqZ+>ySW{Bnx!2Ku>z{Y5*LUlwW?%lea%Vwz? z$se?OXJp5WT8FnKWF!qfHFjpvtu8l?48PZBM_!*M!2@A!v)4R1WKzVE$eVdLdSC0@ zV)XR5<8Pno*0oh&eB5idUc9tBX;k*lqu+1&aeme2=F^%i8eF=gdeFPk1>v<0FS&9f zn7eL&f6=)019PS%m&Fu!58lqMer$N|Tj{-qecxzjX}|VW@skcri=N&iX6(3ntplri z92ycV%RRVk#3yI=Hcd%wKk$dD)-y7G$;&^T^Fs34T8AGTK4kw6P)h*<9s?8r0ssgA z{Y92l{^9>j4h;YR76d5(3ji1Z000000001!k_{9r1posLV5DPpcnbgl1n2_*00ig* b002-+1qJ{B000310RT||002`B00000Wa+Mq literal 3546 zcmWIWW@Zs#-~dAQe7jHvC=g@OWZ-5{U`S8ROD)bU)+;Wq3Ju|9U_Wndo?P2!1IDEl z+zgB?FPIq^z{K0LnHgd%5(hqpFTYu{*W2;tls(gqI~Y&j)RWnMZi-TB+}Y%~8C{DE zqusJ9rW_9nG{0@5)qQH=K0jY+WBx@3;m=N}1U(CyK0A7s+0kTO>j@nTY6TVR>?f_Cfb@`kC4Vby-KgCKNu{b}Y31 z+}y$v|KA&fcZtNr2+ZDK|Mt|S>-*%keNA|KXs4*O{oCD}cIDn&X?>Ly=G{?x#D%~= z`>?C8L{_}GQTq9b{vvs;nIh&puRW{$YGuDk+uCGJUGs}vQSI*U^Jc|P5w%dH) zs>1IpzVSZ`6En{d{`xNbdD&Ipcb{(lICXaEaj(LY?;cw!n$8Cl7HVi z#y9il>sLp3&xf$xi;t+PiMX+K`TN|Txj|)@JB@>miL*|#7mNDy;Yf>YxbyR8^^>F| z<8AaRkDfiBt!^eM>~%tNkGg<)QrX^m?$G~-uUT$9_(7EU8r$}m{*L!I7nQ%;b<6#n zdg{}qXS0O=e)}%J$Ke03g&oh&O}Rh+|DRh+uVy-XF)eI+d;QDH;2R4qLhS6)o?UV6 z{Of0~bwgZQYF~!?sXc<)*)nyXZ#^vJUK|zg@%!1A&OFUZ_p~& Date: Thu, 22 Dec 2022 10:26:09 -0500 Subject: [PATCH 7/8] config updates --- .../eip4844/config.yaml | 52 +++++++++++++++++-- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml b/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml index 88c3107ea..d5e185591 100644 --- a/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/eip4844/config.yaml @@ -1,9 +1,28 @@ CONFIG_NAME: testnet PRESET_BASE: mainnet +# Transition +# --------------------------------------------------------------- +TERMINAL_TOTAL_DIFFICULTY: 2 +# By default, don't use these params +TERMINAL_BLOCK_HASH: 0x0000000000000000000000000000000000000000000000000000000000000000 +TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: 18446744073709551615 + # Genesis +# --------------------------------------------------------------- # The genesis fork version looks weird for legacy reasons +MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 2 +# Dec 1, 2020, 12pm UTC +MIN_GENESIS_TIME: 1606824000 GENESIS_FORK_VERSION: 0x00000ffd +# 604800 seconds (7 days) +GENESIS_DELAY: 604800 + +# Forking +# --------------------------------------------------------------- +# Some forks are disabled for now: +# - These may be re-assigned to another fork-version later +# - Temporarily set to max uint64 value: 2**64 - 1 # Altair ALTAIR_FORK_EPOCH: 2 @@ -12,7 +31,6 @@ ALTAIR_FORK_VERSION: 0x20000090 # Merge BELLATRIX_FORK_EPOCH: 3 BELLATRIX_FORK_VERSION: 0x20000091 -TERMINAL_TOTAL_DIFFICULTY: 2 # Capella CAPELLA_FORK_EPOCH: 4 @@ -24,14 +42,38 @@ EIP4844_FORK_EPOCH: 5 EIP4844_FORK_VERSION: 0x20000093 # Time parameters +# --------------------------------------------------------------- +# 12 seconds SECONDS_PER_SLOT: 12 -SLOTS_PER_EPOCH: 32 +# 14 (estimate from Eth1 mainnet) +SECONDS_PER_ETH1_BLOCK: 14 +# 2**8 (= 256) epochs ~27 hours +MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256 +# 2**8 (= 256) epochs ~27 hours +SHARD_COMMITTEE_PERIOD: 256 +ETH1_FOLLOW_DISTANCE: 1 + +# Validator cycle +# --------------------------------------------------------------- +# 2**2 (= 4) +INACTIVITY_SCORE_BIAS: 4 +# 2**4 (= 16) +INACTIVITY_SCORE_RECOVERY_RATE: 16 +# 2**4 * 10**9 (= 16,000,000,000) Gwei +EJECTION_BALANCE: 16000000000 +# 2**2 (= 4) +MIN_PER_EPOCH_CHURN_LIMIT: 4 +# 2**16 (= 65,536) +CHURN_LIMIT_QUOTIENT: 65536 + +# Fork choice +# --------------------------------------------------------------- +# 40% +PROPOSER_SCORE_BOOST: 40 # Deposit contract +# --------------------------------------------------------------- DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242 - DEPOSIT_CHAIN_ID: 1331 DEPOSIT_NETWORK_ID: 1331 -ETH1_FOLLOW_DISTANCE: 1 -MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 2 From 12402b309df4f01c503a75d638ac4f1432da28c1 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Thu, 22 Dec 2022 14:08:38 -0500 Subject: [PATCH 8/8] fix geth binary path --- scripts/local_testnet/vars.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/local_testnet/vars.env b/scripts/local_testnet/vars.env index bf3c4f3c1..9a7c22ea5 100644 --- a/scripts/local_testnet/vars.env +++ b/scripts/local_testnet/vars.env @@ -1,4 +1,4 @@ -GETH_BINARY=/geth +GETH_BINARY=geth BOOTNODE_BINARY=bootnode # Base directories for the validator keys and secrets