Skip to content

Commit

Permalink
Merge pull request #1923 from skalenetwork/bug/1922-block-by-number-e…
Browse files Browse the repository at this point in the history
…rror

1922 fix block by number error
  • Loading branch information
DmytroNazarenko authored Jun 14, 2024
2 parents a0d0c55 + 473e118 commit 348ef4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ Json::Value Eth::eth_getBlockByNumber( string const& _blockNumber, bool _include
BlockNumber bn = ( h == LatestBlock || h == PendingBlock ) ? client()->number() : h;

u256 baseFeePerGas;
if ( EIP1559TransactionsPatch::isEnabledWhen( client()->blockInfo( bn - 1 ).timestamp() ) )
if ( bn > 0 &&
EIP1559TransactionsPatch::isEnabledWhen( client()->blockInfo( bn - 1 ).timestamp() ) )
try {
baseFeePerGas = client()->gasBidPrice( bn - 1 );
} catch ( std::invalid_argument& _e ) {
Expand Down
2 changes: 2 additions & 0 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3134,6 +3134,8 @@ BOOST_AUTO_TEST_CASE( eip1559Transactions ) {
BOOST_REQUIRE( result["accessList"].isArray() );
BOOST_REQUIRE( result["maxPriorityFeePerGas"] == "0x4a817c800" );
BOOST_REQUIRE( result["maxFeePerGas"] == "0x4a817c800" );

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

BOOST_AUTO_TEST_CASE( eip2930RpcMethods ) {
Expand Down

0 comments on commit 348ef4b

Please sign in to comment.