mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: support time-based forking (#985)
This commit is contained in:
@ -21,7 +21,7 @@ use reth_primitives::{Chain, ForkId, PeerId, H256, U256};
|
||||
/// .total_difficulty(U256::from(100))
|
||||
/// .blockhash(H256::from(MAINNET_GENESIS))
|
||||
/// .genesis(H256::from(MAINNET_GENESIS))
|
||||
/// .forkid(Hardfork::Latest.fork_id(&MAINNET).unwrap())
|
||||
/// .forkid(Hardfork::London.fork_id(&MAINNET).unwrap())
|
||||
/// .build();
|
||||
///
|
||||
/// assert_eq!(
|
||||
@ -32,7 +32,7 @@ use reth_primitives::{Chain, ForkId, PeerId, H256, U256};
|
||||
/// total_difficulty: U256::from(100),
|
||||
/// blockhash: H256::from(MAINNET_GENESIS),
|
||||
/// genesis: H256::from(MAINNET_GENESIS),
|
||||
/// forkid: Hardfork::Latest.fork_id(&MAINNET).unwrap(),
|
||||
/// forkid: Hardfork::London.fork_id(&MAINNET).unwrap(),
|
||||
/// }
|
||||
/// );
|
||||
/// ```
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Types for broadcasting new data.
|
||||
use reth_codecs::derive_arbitrary;
|
||||
use reth_primitives::{Header, TransactionSigned, H256, U128};
|
||||
use reth_primitives::{BlockNumber, Header, TransactionSigned, H256, U128};
|
||||
use reth_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
@ -47,7 +47,7 @@ pub struct BlockHashNumber {
|
||||
/// The block hash
|
||||
pub hash: H256,
|
||||
/// The block number
|
||||
pub number: u64,
|
||||
pub number: BlockNumber,
|
||||
}
|
||||
|
||||
impl From<Vec<BlockHashNumber>> for NewBlockHashes {
|
||||
|
||||
@ -50,10 +50,8 @@ impl From<Genesis> for Status {
|
||||
let mut chainspec = ChainSpec::from(genesis);
|
||||
let mut header = Header::from(chainspec.genesis().clone());
|
||||
|
||||
let hardforks = chainspec.hardforks();
|
||||
|
||||
// set initial base fee depending on eip-1559
|
||||
if Some(&0u64) == hardforks.get(&Hardfork::London) {
|
||||
if Some(0u64) == chainspec.fork_block(Hardfork::London) {
|
||||
header.base_fee_per_gas = Some(EIP1559_INITIAL_BASE_FEE);
|
||||
}
|
||||
|
||||
@ -64,7 +62,7 @@ impl From<Genesis> for Status {
|
||||
chainspec.genesis_hash = sealed_header.hash();
|
||||
|
||||
// we need to calculate the fork id AFTER re-setting the genesis hash
|
||||
let forkid = chainspec.fork_id(0);
|
||||
let forkid = chainspec.fork_id(0.into());
|
||||
|
||||
Status {
|
||||
version: EthVersion::Eth67 as u8,
|
||||
@ -97,7 +95,7 @@ impl Status {
|
||||
.chain(spec.chain)
|
||||
.genesis(spec.genesis_hash())
|
||||
.blockhash(head.hash)
|
||||
.forkid(spec.fork_id(head.number))
|
||||
.forkid(spec.fork_id(head.number.into()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user