Skip to content

Commit

Permalink
#1994 use maxFeePerGasPatch
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Jan 8, 2025
1 parent a571b80 commit 3f1e2a5
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 16 deletions.
2 changes: 2 additions & 0 deletions libethereum/BlockChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,8 @@ VerifiedBlockRef BlockChain::verifyBlock( bytesConstRef _block,
CheckTransaction::None,
false,
EIP1559TransactionsPatch::isEnabledWhen(
this->info( numberHash( h.number() - 1 ) ).timestamp() ),
MaxFeePerGasPatch::isEnabledWhen(
this->info( numberHash( h.number() - 1 ) ).timestamp() ) );
Ethash::verifyTransaction( chainParams(), _ir, t,
this->info( numberHash( h.number() - 1 ) ).timestamp(), h,
Expand Down
10 changes: 10 additions & 0 deletions libethereum/ClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ Transaction ClientBase::transaction( h256 _transactionHash ) const {
auto tl = bc().transactionLocation( _transactionHash );
return Transaction( bc().transaction( _transactionHash ), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen(
blockInfo( numberFromHash( tl.first ) - 1 ).timestamp() ),
MaxFeePerGasPatch::isEnabledWhen(
blockInfo( numberFromHash( tl.first ) - 1 ).timestamp() ) );
}

Expand All @@ -398,6 +400,8 @@ Transaction ClientBase::transaction( h256 _blockHash, unsigned _i ) const {
// allow invalid
return Transaction( b[1][_i].data(), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen(
blockInfo( numberFromHash( _blockHash ) - 1 ).timestamp() ),
MaxFeePerGasPatch::isEnabledWhen(
blockInfo( numberFromHash( _blockHash ) - 1 ).timestamp() ) );
else
return Transaction();
Expand All @@ -407,6 +411,8 @@ LocalisedTransaction ClientBase::localisedTransaction( h256 const& _blockHash, u
// allow invalid
Transaction t = Transaction( bc().transaction( _blockHash, _i ), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen(
blockInfo( numberFromHash( _blockHash ) - 1 ).timestamp() ),
MaxFeePerGasPatch::isEnabledWhen(
blockInfo( numberFromHash( _blockHash ) - 1 ).timestamp() ) );
return LocalisedTransaction( t, _blockHash, _i, numberFromHash( _blockHash ) );
}
Expand All @@ -422,6 +428,8 @@ LocalisedTransactionReceipt ClientBase::localisedTransactionReceipt(
Transaction t =
Transaction( bc().transaction( tl.first, tl.second ), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen(
blockInfo( numberFromHash( tl.first ) - 1 ).timestamp() ),
MaxFeePerGasPatch::isEnabledWhen(
blockInfo( numberFromHash( tl.first ) - 1 ).timestamp() ) );
TransactionReceipt tr = bc().transactionReceipt( tl.first, tl.second );
u256 gasUsed = tr.cumulativeGasUsed();
Expand Down Expand Up @@ -457,6 +465,8 @@ Transactions ClientBase::transactions( h256 _blockHash ) const {
auto txRlp = b[1][i];
res.emplace_back( bytesRefFromTransactionRlp( txRlp ), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen(
blockInfo( numberFromHash( _blockHash ) - 1 ).timestamp() ),
MaxFeePerGasPatch::isEnabledWhen(
blockInfo( numberFromHash( _blockHash ) - 1 ).timestamp() ) );
}
return res;
Expand Down
6 changes: 4 additions & 2 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ h256 SkaleHost::receiveTransaction( std::string _rlp ) {
}

Transaction transaction( jsToBytes( _rlp, OnFailed::Throw ), CheckTransaction::None, false,
EIP1559TransactionsPatch::isEnabledInWorkingBlock() );
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
MaxFeePerGasPatch::isEnabledInWorkingBlock() );
h256 sha = transaction.sha3();

//
Expand Down Expand Up @@ -672,7 +673,8 @@ void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _appro
// ).detach();
} else {
Transaction t( data, CheckTransaction::Everything, true,
EIP1559TransactionsPatch::isEnabledInWorkingBlock() );
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
MaxFeePerGasPatch::isEnabledInWorkingBlock() );
t.checkOutExternalGas(
m_client.chainParams(), latestInfo.timestamp(), m_client.number() );
out_txns.push_back( t );
Expand Down
15 changes: 8 additions & 7 deletions libethereum/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,14 @@ Transaction::Transaction( const u256& _value, const u256& _gasPrice, const u256&
const bytes& _data, const u256& _nonce )
: TransactionBase( _value, _gasPrice, _gas, _data, _nonce ) {}

Transaction::Transaction(
bytesConstRef _rlpData, CheckTransaction _checkSig, bool _allowInvalid, bool _eip1559Enabled )
: TransactionBase( _rlpData, _checkSig, _allowInvalid, _eip1559Enabled ) {}

Transaction::Transaction(
const bytes& _rlp, CheckTransaction _checkSig, bool _allowInvalid, bool _eip1559Enabled )
: Transaction( &_rlp, _checkSig, _allowInvalid, _eip1559Enabled ) {}
Transaction::Transaction( bytesConstRef _rlpData, CheckTransaction _checkSig, bool _allowInvalid,
bool _eip1559Enabled, bool _maxFeePerGasPatchEnabled )
: TransactionBase(
_rlpData, _checkSig, _allowInvalid, _eip1559Enabled, _maxFeePerGasPatchEnabled ) {}

Transaction::Transaction( const bytes& _rlp, CheckTransaction _checkSig, bool _allowInvalid,
bool _eip1559Enabled, bool _maxFeePerGasPatchEnabled )
: Transaction( &_rlp, _checkSig, _allowInvalid, _eip1559Enabled, _maxFeePerGasPatchEnabled ) {}

bool Transaction::hasExternalGas() const {
if ( !m_externalGasIsChecked ) {
Expand Down
5 changes: 3 additions & 2 deletions libethereum/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ class Transaction : public TransactionBase {

/// Constructs a transaction from the given RLP.
explicit Transaction( bytesConstRef _rlp, CheckTransaction _checkSig,
bool _allowInvalid = false, bool _eip1559Enabled = false );
bool _allowInvalid = false, bool _eip1559Enabled = false,
bool _maxFeePerGasPatchEnabled = false );

/// Constructs a transaction from the given RLP.
explicit Transaction( bytes const& _rlp, CheckTransaction _checkSig, bool _allowInvalid = false,
bool _eip1559Enabled = false );
bool _eip1559Enabled = false, bool _maxFeePerGasPatchEnabled = false );

Transaction( Transaction const& ) = default;

Expand Down
8 changes: 5 additions & 3 deletions libethereum/TransactionQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ ImportResult TransactionQueue::import(
bytesConstRef _transactionRLP, IfDropped _ik, bool _isFuture ) {
try {
Transaction t = Transaction( _transactionRLP, CheckTransaction::Everything, false,
EIP1559TransactionsPatch::isEnabledInWorkingBlock() );
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
MaxFeePerGasPatch::isEnabledInWorkingBlock() );
return import( t, _ik, _isFuture );
} catch ( Exception const& ) {
return ImportResult::Malformed;
Expand Down Expand Up @@ -527,8 +528,9 @@ void TransactionQueue::verifierBody() {

try {
Transaction t( work.transaction, CheckTransaction::Cheap, false,
EIP1559TransactionsPatch::isEnabledInWorkingBlock() ); // Signature will be
// checked later
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
MaxFeePerGasPatch::isEnabledInWorkingBlock() ); // Signature will be
// checked later
ImportResult ir = import( t );
m_onImport( ir, t.sha3(), work.nodeId );
} catch ( ... ) {
Expand Down
6 changes: 4 additions & 2 deletions libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ Json::Value Eth::setSchainExitTime( Json::Value const& /*_transaction*/ ) {
Json::Value Eth::eth_inspectTransaction( std::string const& _rlp ) {
try {
return toJson( Transaction( jsToBytes( _rlp, OnFailed::Throw ),
CheckTransaction::Everything, EIP1559TransactionsPatch::isEnabledInWorkingBlock() ) );
CheckTransaction::Everything, EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
MaxFeePerGasPatch::isEnabledInWorkingBlock() ) );
} catch ( ... ) {
BOOST_THROW_EXCEPTION( JsonRpcException( Errors::ERROR_RPC_INVALID_PARAMS ) );
}
Expand All @@ -427,7 +428,8 @@ string Eth::eth_sendRawTransaction( std::string const& _rlp ) {
// Don't need to check the transaction signature (CheckTransaction::None) since it
// will be checked as a part of transaction import
Transaction t( jsToBytes( _rlp, OnFailed::Throw ), CheckTransaction::None, false,
EIP1559TransactionsPatch::isEnabledInWorkingBlock() );
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
MaxFeePerGasPatch::isEnabledInWorkingBlock() );
return toJS( client()->importTransaction( t ) );
}

Expand Down

0 comments on commit 3f1e2a5

Please sign in to comment.