add shanghai fork version and epoch

This commit is contained in:
realbigsean
2022-02-19 11:42:11 -07:00
parent 7125f0e3c6
commit 4cdf1b546d
18 changed files with 121 additions and 68 deletions

View File

@@ -297,7 +297,7 @@ pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> Gos
// according to: https://github.com/ethereum/consensus-specs/blob/dev/specs/merge/p2p-interface.md#the-gossip-domain-gossipsub
// the derivation of the message-id remains the same in the merge
//TODO(sean): figure this out
ForkName::Altair | ForkName::Merge | ForkName::Dank => {
ForkName::Altair | ForkName::Merge | ForkName::Shanghai => {
let topic_len_bytes = topic_bytes.len().to_le_bytes();
let mut vec = Vec::with_capacity(
prefix.len() + topic_len_bytes.len() + topic_bytes.len() + message.data.len(),

View File

@@ -17,7 +17,7 @@ use std::sync::Arc;
use tokio_util::codec::{Decoder, Encoder};
use types::{
EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair,
SignedBeaconBlockBase, SignedBeaconBlockDank, SignedBeaconBlockMerge,
SignedBeaconBlockBase, SignedBeaconBlockMerge, SignedBeaconBlockShanghai,
};
use unsigned_varint::codec::Uvi;
@@ -407,7 +407,9 @@ fn context_bytes<T: EthSpec>(
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::Dank { .. } => fork_context.to_context_bytes(ForkName::Dank),
SignedBeaconBlock::Shanghai { .. } => {
fork_context.to_context_bytes(ForkName::Shanghai)
}
SignedBeaconBlock::Merge { .. } => {
// Merge context being `None` implies that "merge never happened".
fork_context.to_context_bytes(ForkName::Merge)
@@ -587,8 +589,10 @@ fn handle_v2_response<T: EthSpec>(
decoded_buffer,
)?),
)))),
ForkName::Dank => Ok(Some(RPCResponse::BlocksByRange(Box::new(
SignedBeaconBlock::Dank(SignedBeaconBlockDank::from_ssz_bytes(decoded_buffer)?),
ForkName::Shanghai => Ok(Some(RPCResponse::BlocksByRange(Box::new(
SignedBeaconBlock::Shanghai(SignedBeaconBlockShanghai::from_ssz_bytes(
decoded_buffer,
)?),
)))),
},
Protocol::BlocksByRoot => match fork_name {
@@ -605,8 +609,10 @@ fn handle_v2_response<T: EthSpec>(
decoded_buffer,
)?),
)))),
ForkName::Dank => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
SignedBeaconBlock::Dank(SignedBeaconBlockDank::from_ssz_bytes(decoded_buffer)?),
ForkName::Shanghai => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
SignedBeaconBlock::Shanghai(SignedBeaconBlockShanghai::from_ssz_bytes(
decoded_buffer,
)?),
)))),
},
_ => Err(RPCError::ErrorResponse(

View File

@@ -11,8 +11,8 @@ use std::sync::Arc;
use types::{
Attestation, AttesterSlashing, EthSpec, ForkContext, ForkName, ProposerSlashing,
SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase,
SignedBeaconBlockDank, SignedBeaconBlockMerge, SignedContributionAndProof, SignedVoluntaryExit,
SubnetId, SyncCommitteeMessage, SyncSubnetId,
SignedBeaconBlockMerge, SignedBeaconBlockShanghai, SignedContributionAndProof,
SignedVoluntaryExit, SubnetId, SyncCommitteeMessage, SyncSubnetId,
};
#[derive(Debug, Clone, PartialEq)]
@@ -167,8 +167,8 @@ impl<T: EthSpec> PubsubMessage<T> {
SignedBeaconBlockMerge::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?,
),
Some(ForkName::Dank) => SignedBeaconBlock::<T>::Dank(
SignedBeaconBlockDank::from_ssz_bytes(data)
Some(ForkName::Shanghai) => SignedBeaconBlock::<T>::Shanghai(
SignedBeaconBlockShanghai::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?,
),
None => {