Skip to content

Commit

Permalink
#1994 fix max priority fee check
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Sep 17, 2024
1 parent b723683 commit 27b20a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libethcore/TransactionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void TransactionBase::fillFromBytesType2(
m_nonce = rlp[1].toInt< u256 >();
m_maxPriorityFeePerGas = rlp[2].toInt< u256 >();
m_maxFeePerGas = rlp[3].toInt< u256 >();
if ( m_maxPriorityFeePerGas > m_maxPriorityFeePerGas )
if ( m_maxPriorityFeePerGas > m_maxFeePerGas )
BOOST_THROW_EXCEPTION( InvalidTransactionFormat() << errinfo_comment(
"maxFeePerGas cannot be less than maxPriorityFeePerGas (The "
"total must be the larger of the two)" ) );
Expand Down
14 changes: 7 additions & 7 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ BOOST_AUTO_TEST_CASE( eip1559Transactions ) {
BOOST_REQUIRE( fixture.rpcClient->eth_getBalance( "0x5EdF1e852fdD1B0Bc47C0307EF755C76f4B9c251", "latest" ) == "0x16345785d8a0000" );

// try sending type2 txn before patchTimestmap
BOOST_REQUIRE_THROW( fixture.rpcClient->eth_sendRawTransaction( "0x02f8c98197808504a817c8008504a817c800827530947d36af85a184e220a656525fcbb9a63b9ab3c12b0180f85bf85994de0b295669a9fd93d5f28d9ec85e40f4cb697baef842a00000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000780a0f1a407dfc1a9f782001d89f617e9b3a2f295378533784fb39960dea60beea2d0a05ac3da2946554ba3d5721850f4f89ee7a0c38e4acab7130908e7904d13174388" ), jsonrpc::JsonRpcException ); // INVALID_PARAMS
BOOST_REQUIRE_THROW( fixture.rpcClient->eth_sendRawTransaction( "0x02f8c98197808504a817c7ff8504a817c800827530947d36af85a184e220a656525fcbb9a63b9ab3c12b0180f85bf85994de0b295669a9fd93d5f28d9ec85e40f4cb697baef842a00000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000701a057ca0065a334006c3801ca7ff27e098e9fa9af7715b678061bbc0be884159248a0115e29d7c3463db9c0346fa90e1deffa2cbf201a5082e5a56549b606482282de" ), jsonrpc::JsonRpcException ); // INVALID_PARAMS
sleep( 10 );

// force 1 block to update timestamp
Expand All @@ -3226,7 +3226,7 @@ BOOST_AUTO_TEST_CASE( eip1559Transactions ) {

// send 1 WEI from 0x5EdF1e852fdD1B0Bc47C0307EF755C76f4B9c251 to 0x7D36aF85A184E220A656525fcBb9A63B9ab3C12b
// encoded type 2 txn
txHash = fixture.rpcClient->eth_sendRawTransaction( "0x02f8c98197808504a817c8018504a817c800827530947d36af85a184e220a656525fcbb9a63b9ab3c12b0180f85bf85994de0b295669a9fd93d5f28d9ec85e40f4cb697baef842a00000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000701a005bd1eedc509a8e94cfcfc84d0b5fd53a0888a475274cbeee321047da5d139f8a00e7f0dd8b5277766d447ea51b7d8f571dc8bb57ff95c068c58f5b6fe9089dde8" );
txHash = fixture.rpcClient->eth_sendRawTransaction( "0x02f8c98197808504a817c7ff8504a817c800827530947d36af85a184e220a656525fcbb9a63b9ab3c12b0180f85bf85994de0b295669a9fd93d5f28d9ec85e40f4cb697baef842a00000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000701a057ca0065a334006c3801ca7ff27e098e9fa9af7715b678061bbc0be884159248a0115e29d7c3463db9c0346fa90e1deffa2cbf201a5082e5a56549b606482282de" );
auto pendingTransactions = fixture.rpcClient->eth_pendingTransactions();
BOOST_REQUIRE( pendingTransactions.isArray() && pendingTransactions.size() == 1);
BOOST_REQUIRE( pendingTransactions[0]["type"] == "0x2" );
Expand All @@ -3235,8 +3235,8 @@ BOOST_AUTO_TEST_CASE( eip1559Transactions ) {
dev::eth::mineTransaction( *( fixture.client ), 1 );

// compare with txn hash from geth
BOOST_REQUIRE( txHash == "0xde30b1c26b89e20f6426a87b9427381f9e79e2bb80f992a6f2e1b4dccfa345de" );
BOOST_REQUIRE( dev::toHexPrefixed( fixture.client->transactions( 4 )[0].toBytes() ) == "0x02f8c98197808504a817c8018504a817c800827530947d36af85a184e220a656525fcbb9a63b9ab3c12b0180f85bf85994de0b295669a9fd93d5f28d9ec85e40f4cb697baef842a00000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000701a005bd1eedc509a8e94cfcfc84d0b5fd53a0888a475274cbeee321047da5d139f8a00e7f0dd8b5277766d447ea51b7d8f571dc8bb57ff95c068c58f5b6fe9089dde8" );
BOOST_REQUIRE( txHash == "0xe2ebd326b66b93d38a49d36f505b02fb6b0c38efc412a1b5284fe187469dc7d5" );
BOOST_REQUIRE( dev::toHexPrefixed( fixture.client->transactions( 4 )[0].toBytes() ) == "0x02f8c98197808504a817c7ff8504a817c800827530947d36af85a184e220a656525fcbb9a63b9ab3c12b0180f85bf85994de0b295669a9fd93d5f28d9ec85e40f4cb697baef842a00000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000701a057ca0065a334006c3801ca7ff27e098e9fa9af7715b678061bbc0be884159248a0115e29d7c3463db9c0346fa90e1deffa2cbf201a5082e5a56549b606482282de" );

BOOST_REQUIRE( fixture.rpcClient->eth_getBalance( "0x7D36aF85A184E220A656525fcBb9A63B9ab3C12b", "latest" ) == "0x1" );

Expand Down Expand Up @@ -3268,23 +3268,23 @@ BOOST_AUTO_TEST_CASE( eip1559Transactions ) {
BOOST_REQUIRE( result["accessList"].isArray() );
BOOST_REQUIRE( result.isMember( "maxPriorityFeePerGas" ) && result["maxPriorityFeePerGas"].isString() );
BOOST_REQUIRE( result.isMember( "maxFeePerGas" ) && result["maxFeePerGas"].isString() );
BOOST_REQUIRE( result["maxPriorityFeePerGas"] == "0x4a817c801" );
BOOST_REQUIRE( result["maxPriorityFeePerGas"] == "0x4a817c7ff" );
BOOST_REQUIRE( result["maxFeePerGas"] == "0x4a817c800" );

result = fixture.rpcClient->eth_getTransactionByBlockHashAndIndex( blockHash, "0x0" );
BOOST_REQUIRE( result["hash"].asString() == txHash );
BOOST_REQUIRE( result["type"] == "0x2" );
BOOST_REQUIRE( result["yParity"].asString() == result["v"].asString() );
BOOST_REQUIRE( result["accessList"].isArray() );
BOOST_REQUIRE( result["maxPriorityFeePerGas"] == "0x4a817c801" );
BOOST_REQUIRE( result["maxPriorityFeePerGas"] == "0x4a817c7ff" );
BOOST_REQUIRE( result["maxFeePerGas"] == "0x4a817c800" );

result = fixture.rpcClient->eth_getTransactionByBlockNumberAndIndex( "0x4", "0x0" );
BOOST_REQUIRE( result["hash"].asString() == txHash );
BOOST_REQUIRE( result["type"] == "0x2" );
BOOST_REQUIRE( result["yParity"].asString() == result["v"].asString() );
BOOST_REQUIRE( result["accessList"].isArray() );
BOOST_REQUIRE( result["maxPriorityFeePerGas"] == "0x4a817c801" );
BOOST_REQUIRE( result["maxPriorityFeePerGas"] == "0x4a817c7ff" );
BOOST_REQUIRE( result["maxFeePerGas"] == "0x4a817c800" );

BOOST_REQUIRE_NO_THROW( fixture.rpcClient->eth_getBlockByNumber( "0x0", false ) );
Expand Down

0 comments on commit 27b20a4

Please sign in to comment.