mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix: use proper base fee in auto seal (#2691)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -122,6 +122,13 @@ where
|
|||||||
// the pipeline
|
// the pipeline
|
||||||
this.insert_task = Some(Box::pin(async move {
|
this.insert_task = Some(Box::pin(async move {
|
||||||
let mut storage = storage.write().await;
|
let mut storage = storage.write().await;
|
||||||
|
|
||||||
|
// check previous block for base fee
|
||||||
|
let base_fee_per_gas = storage
|
||||||
|
.headers
|
||||||
|
.get(&storage.best_block)
|
||||||
|
.and_then(|parent| parent.next_block_base_fee());
|
||||||
|
|
||||||
let mut header = Header {
|
let mut header = Header {
|
||||||
parent_hash: storage.best_hash,
|
parent_hash: storage.best_hash,
|
||||||
ommers_hash: EMPTY_OMMER_ROOT,
|
ommers_hash: EMPTY_OMMER_ROOT,
|
||||||
@ -141,7 +148,7 @@ where
|
|||||||
.as_secs(),
|
.as_secs(),
|
||||||
mix_hash: Default::default(),
|
mix_hash: Default::default(),
|
||||||
nonce: 0,
|
nonce: 0,
|
||||||
base_fee_per_gas: None,
|
base_fee_per_gas,
|
||||||
extra_data: Default::default(),
|
extra_data: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -231,15 +238,17 @@ where
|
|||||||
|
|
||||||
// seal the block
|
// seal the block
|
||||||
let block = Block {
|
let block = Block {
|
||||||
header,
|
header: header.clone(),
|
||||||
body: transactions,
|
body: transactions,
|
||||||
ommers: vec![],
|
ommers: vec![],
|
||||||
withdrawals: None,
|
withdrawals: None,
|
||||||
};
|
};
|
||||||
let sealed_block = block.seal_slow();
|
let sealed_block = block.seal_slow();
|
||||||
|
|
||||||
let sealed_block_with_senders =
|
let sealed_block_with_senders =
|
||||||
SealedBlockWithSenders::new(sealed_block, senders)
|
SealedBlockWithSenders::new(sealed_block, senders)
|
||||||
.expect("senders are valid");
|
.expect("senders are valid");
|
||||||
|
|
||||||
debug!(target: "consensus::auto", header=?sealed_block_with_senders.hash(), "sending block notification");
|
debug!(target: "consensus::auto", header=?sealed_block_with_senders.hash(), "sending block notification");
|
||||||
|
|
||||||
let chain =
|
let chain =
|
||||||
|
|||||||
@ -148,8 +148,7 @@ impl ChainSpec {
|
|||||||
/// Get the header for the genesis block.
|
/// Get the header for the genesis block.
|
||||||
pub fn genesis_header(&self) -> Header {
|
pub fn genesis_header(&self) -> Header {
|
||||||
// If London is activated at genesis, we set the initial base fee as per EIP-1559.
|
// If London is activated at genesis, we set the initial base fee as per EIP-1559.
|
||||||
let base_fee_per_gas =
|
let base_fee_per_gas = self.initial_base_fee();
|
||||||
(self.fork(Hardfork::London).active_at_block(0)).then_some(EIP1559_INITIAL_BASE_FEE);
|
|
||||||
|
|
||||||
// If shanghai is activated, initialize the header with an empty withdrawals hash, and
|
// If shanghai is activated, initialize the header with an empty withdrawals hash, and
|
||||||
// empty withdrawals list.
|
// empty withdrawals list.
|
||||||
@ -172,6 +171,12 @@ impl ChainSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the initial base fee of the genesis block.
|
||||||
|
pub fn initial_base_fee(&self) -> Option<u64> {
|
||||||
|
// If London is activated at genesis, we set the initial base fee as per EIP-1559.
|
||||||
|
(self.fork(Hardfork::London).active_at_block(0)).then_some(EIP1559_INITIAL_BASE_FEE)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the hash of the genesis block.
|
/// Get the hash of the genesis block.
|
||||||
pub fn genesis_hash(&self) -> H256 {
|
pub fn genesis_hash(&self) -> H256 {
|
||||||
if let Some(hash) = self.genesis_hash {
|
if let Some(hash) = self.genesis_hash {
|
||||||
|
|||||||
Reference in New Issue
Block a user