mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Initial merge changes
Added Execution Payload from Rayonism Fork Updated new Containers to match Merge Spec Updated BeaconBlockBody for Merge Spec Completed updating BeaconState and BeaconBlockBody Modified ExecutionPayload<T> to use Transaction<T> Mostly Finished Changes for beacon-chain.md Added some things for fork-choice.md Update to match new fork-choice.md/fork.md changes ran cargo fmt Added Missing Pieces in eth2_libp2p for Merge fix ef test Various Changes to Conform Closer to Merge Spec
This commit is contained in:
@@ -17,7 +17,7 @@ use std::sync::Arc;
|
||||
use tokio_util::codec::{Decoder, Encoder};
|
||||
use types::{
|
||||
EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair,
|
||||
SignedBeaconBlockBase,
|
||||
SignedBeaconBlockBase, SignedBeaconBlockMerge,
|
||||
};
|
||||
use unsigned_varint::codec::Uvi;
|
||||
|
||||
@@ -375,7 +375,7 @@ fn handle_error<T>(
|
||||
}
|
||||
|
||||
/// Returns `Some(context_bytes)` for encoding RPC responses that require context bytes.
|
||||
/// Returns `None` when context bytes are not required.
|
||||
/// Returns `None` when context bytes are not required.
|
||||
fn context_bytes<T: EthSpec>(
|
||||
protocol: &ProtocolId,
|
||||
fork_context: &ForkContext,
|
||||
@@ -383,23 +383,25 @@ fn context_bytes<T: EthSpec>(
|
||||
) -> Option<[u8; CONTEXT_BYTES_LEN]> {
|
||||
// Add the context bytes if required
|
||||
if protocol.has_context_bytes() {
|
||||
if let RPCCodedResponse::Success(RPCResponse::BlocksByRange(res)) = resp {
|
||||
if let SignedBeaconBlock::Altair { .. } = **res {
|
||||
// Altair context being `None` implies that "altair never happened".
|
||||
// This code should be unreachable if altair is disabled since only Version::V1 would be valid in that case.
|
||||
return fork_context.to_context_bytes(ForkName::Altair);
|
||||
} else if let SignedBeaconBlock::Base { .. } = **res {
|
||||
return Some(fork_context.genesis_context_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
if let RPCCodedResponse::Success(RPCResponse::BlocksByRoot(res)) = resp {
|
||||
if let SignedBeaconBlock::Altair { .. } = **res {
|
||||
// Altair context being `None` implies that "altair never happened".
|
||||
// This code should be unreachable if altair is disabled since only Version::V1 would be valid in that case.
|
||||
return fork_context.to_context_bytes(ForkName::Altair);
|
||||
} else if let SignedBeaconBlock::Base { .. } = **res {
|
||||
return Some(fork_context.genesis_context_bytes());
|
||||
if let RPCCodedResponse::Success(rpc_variant) = resp {
|
||||
if let RPCResponse::BlocksByRange(ref_box_block)
|
||||
| RPCResponse::BlocksByRoot(ref_box_block) = rpc_variant
|
||||
{
|
||||
return match **ref_box_block {
|
||||
// NOTE: If you are adding another fork type here, be sure to modify the
|
||||
// `fork_context.to_context_bytes()` function to support it as well!
|
||||
SignedBeaconBlock::Merge { .. } => {
|
||||
// TODO: check this
|
||||
// Merge context being `None` implies that "merge never happened".
|
||||
fork_context.to_context_bytes(ForkName::Merge)
|
||||
}
|
||||
SignedBeaconBlock::Altair { .. } => {
|
||||
// Altair context being `None` implies that "altair never happened".
|
||||
// This code should be unreachable if altair is disabled since only Version::V1 would be valid in that case.
|
||||
fork_context.to_context_bytes(ForkName::Altair)
|
||||
}
|
||||
SignedBeaconBlock::Base { .. } => Some(fork_context.genesis_context_bytes()),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -559,6 +561,12 @@ fn handle_v2_response<T: EthSpec>(
|
||||
ForkName::Base => Ok(Some(RPCResponse::BlocksByRange(Box::new(
|
||||
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
|
||||
)))),
|
||||
// TODO: check this (though it seems okay)
|
||||
ForkName::Merge => Ok(Some(RPCResponse::BlocksByRange(Box::new(
|
||||
SignedBeaconBlock::Merge(SignedBeaconBlockMerge::from_ssz_bytes(
|
||||
decoded_buffer,
|
||||
)?),
|
||||
)))),
|
||||
},
|
||||
Protocol::BlocksByRoot => match fork_name {
|
||||
ForkName::Altair => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
|
||||
@@ -569,6 +577,12 @@ fn handle_v2_response<T: EthSpec>(
|
||||
ForkName::Base => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
|
||||
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
|
||||
)))),
|
||||
// TODO: check this (though it seems right)
|
||||
ForkName::Merge => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
|
||||
SignedBeaconBlock::Merge(SignedBeaconBlockMerge::from_ssz_bytes(
|
||||
decoded_buffer,
|
||||
)?),
|
||||
)))),
|
||||
},
|
||||
_ => Err(RPCError::ErrorResponse(
|
||||
RPCResponseErrorCode::InvalidRequest,
|
||||
|
||||
@@ -21,8 +21,8 @@ use tokio_util::{
|
||||
compat::{Compat, FuturesAsyncReadCompatExt},
|
||||
};
|
||||
use types::{
|
||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, EthSpec, ForkContext, Hash256, MainnetEthSpec,
|
||||
Signature, SignedBeaconBlock,
|
||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, EthSpec, ForkContext,
|
||||
Hash256, MainnetEthSpec, Signature, SignedBeaconBlock,
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
@@ -53,6 +53,20 @@ lazy_static! {
|
||||
)
|
||||
.as_ssz_bytes()
|
||||
.len();
|
||||
|
||||
pub static ref SIGNED_BEACON_BLOCK_MERGE_MIN: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
|
||||
BeaconBlock::Merge(BeaconBlockMerge::<MainnetEthSpec>::empty(&MainnetEthSpec::default_spec())),
|
||||
Signature::empty(),
|
||||
)
|
||||
.as_ssz_bytes()
|
||||
.len();
|
||||
pub static ref SIGNED_BEACON_BLOCK_MERGE_MAX: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
|
||||
BeaconBlock::Merge(BeaconBlockMerge::full(&MainnetEthSpec::default_spec())),
|
||||
Signature::empty(),
|
||||
)
|
||||
.as_ssz_bytes()
|
||||
.len();
|
||||
|
||||
pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize =
|
||||
VariableList::<Hash256, MaxRequestBlocks>::from(Vec::<Hash256>::new())
|
||||
.as_ssz_bytes()
|
||||
@@ -253,12 +267,18 @@ impl ProtocolId {
|
||||
Protocol::Goodbye => RpcLimits::new(0, 0), // Goodbye request has no response
|
||||
Protocol::BlocksByRange => RpcLimits::new(
|
||||
std::cmp::min(
|
||||
*SIGNED_BEACON_BLOCK_ALTAIR_MIN,
|
||||
*SIGNED_BEACON_BLOCK_BASE_MIN,
|
||||
std::cmp::min(
|
||||
*SIGNED_BEACON_BLOCK_ALTAIR_MIN,
|
||||
*SIGNED_BEACON_BLOCK_BASE_MIN,
|
||||
),
|
||||
*SIGNED_BEACON_BLOCK_MERGE_MIN,
|
||||
),
|
||||
std::cmp::max(
|
||||
*SIGNED_BEACON_BLOCK_ALTAIR_MAX,
|
||||
*SIGNED_BEACON_BLOCK_BASE_MAX,
|
||||
std::cmp::max(
|
||||
*SIGNED_BEACON_BLOCK_ALTAIR_MAX,
|
||||
*SIGNED_BEACON_BLOCK_BASE_MAX,
|
||||
),
|
||||
*SIGNED_BEACON_BLOCK_MERGE_MAX,
|
||||
),
|
||||
),
|
||||
Protocol::BlocksByRoot => RpcLimits::new(
|
||||
|
||||
Reference in New Issue
Block a user