@@ -8,31 +8,28 @@ pub mod parlia;
88use self :: fork_choice_graph:: ForkChoiceGraph ;
99pub use self :: { base:: * , beacon:: * , blockchain:: * , clique:: * , parlia:: * } ;
1010use crate :: {
11- consensus:: vote:: VotePool ,
1211 crypto:: signer:: ECDSASigner ,
1312 kv:: { mdbx:: * , tables, MdbxWithDirHandle } ,
1413 models:: * ,
14+ p2p:: node:: Node ,
1515 state:: { IntraBlockState , StateReader } ,
16- BlockReader , HeaderReader ,
16+ BlockReader , Buffer , HeaderReader ,
1717} ;
1818use anyhow:: { anyhow, bail} ;
19- use arrayvec:: ArrayVec ;
2019use derive_more:: { Display , From } ;
21- use ethnum:: u256;
2220use fastrlp:: DecodeError ;
2321use mdbx:: { EnvironmentKind , TransactionKind } ;
2422use milagro_bls:: AmclError ;
2523use parking_lot:: Mutex ;
2624use std:: {
2725 collections:: BTreeSet ,
28- fmt:: { Debug , Display , Formatter } ,
26+ fmt:: { Debug , Display } ,
2927 net:: { Ipv4Addr , SocketAddr , SocketAddrV4 } ,
3028 sync:: Arc ,
3129 time:: SystemTimeError ,
3230} ;
3331use tokio:: sync:: watch;
3432use tracing:: * ;
35- use crate :: p2p:: node:: Node ;
3633
3734#[ derive( Debug ) ]
3835pub enum FinalizationChange {
@@ -85,6 +82,15 @@ impl ConsensusNewBlockState {
8582 _ => ConsensusNewBlockState :: Stateless ,
8683 } )
8784 }
85+ pub ( crate ) fn handle_with_txn < E : EnvironmentKind > (
86+ chain_spec : & ChainSpec ,
87+ header : & BlockHeader ,
88+ tx : & MdbxTransaction < ' _ , RW , E > ,
89+ ) -> anyhow:: Result < ConsensusNewBlockState > {
90+ let mut state = Buffer :: new ( tx, None ) ;
91+ let mut state = IntraBlockState :: new ( & mut state) ;
92+ ConsensusNewBlockState :: handle ( chain_spec, header, & mut state)
93+ }
8894}
8995
9096#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
@@ -678,21 +684,19 @@ impl Default for InitialParams {
678684pub fn pre_validate_transaction (
679685 txn : & Message ,
680686 canonical_chain_id : ChainId ,
681- _base_fee_per_gas : Option < U256 > ,
687+ base_fee_per_gas : Option < U256 > ,
682688) -> Result < ( ) , ValidationError > {
683689 if let Some ( chain_id) = txn. chain_id ( ) {
684690 if chain_id != canonical_chain_id {
685691 return Err ( ValidationError :: WrongChainId ) ;
686692 }
687693 }
688694
689- // TODO need pass in system transaction
690- // info!("tx {:?} base fee {:?}, tx {} max1 {} max2 {}", txn.hash(), base_fee_per_gas, txn.max_fee_per_gas(), txn.max_priority_fee_per_gas(), txn.max_fee_per_gas());
691- // if let Some(base_fee_per_gas) = base_fee_per_gas {
692- // if txn.max_fee_per_gas() < base_fee_per_gas {
693- // return Err(ValidationError::MaxFeeLessThanBase);
694- // }
695- // }
695+ if let Some ( base_fee_per_gas) = base_fee_per_gas {
696+ if txn. max_fee_per_gas ( ) < base_fee_per_gas {
697+ return Err ( ValidationError :: MaxFeeLessThanBase ) ;
698+ }
699+ }
696700
697701 // https://github.com/ethereum/EIPs/pull/3594
698702 if txn. max_priority_fee_per_gas ( ) > txn. max_fee_per_gas ( ) {
0 commit comments