Skip to content

Commit

Permalink
Merge branch 'develop' into bug/1963-wrong-max-fee-per-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev authored Sep 10, 2024
2 parents 48055a7 + fbe0107 commit 519ff02
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libethereum/ClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ std::pair< bool, ExecutionResult > ClientBase::estimateGasStep( int64_t _gas, Bl
t.forceChainId( chainId() );
t.ignoreExternalGas();
EnvInfo const env( _pendingBlock.info(), bc().lastBlockHashes(),
_pendingBlock.previousInfo().timestamp(), 0, _gas );
// Make a copy of state!! It will be deleted after step!
_pendingBlock.previousInfo().timestamp(), 0, _gas, bc().chainParams().chainID );
// Make a copy of the state, it will be deleted after this step
State tempState = _latestBlock.mutableState();
tempState.addBalance( _from, ( u256 )( t.gas() * t.gasPrice() + t.value() ) );
ExecutionResult executionResult =
Expand Down
34 changes: 34 additions & 0 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,40 @@ BOOST_AUTO_TEST_CASE( eth_estimateGas ) {
BOOST_CHECK_EQUAL( response3, "0x1db20" );
}

BOOST_AUTO_TEST_CASE( eth_estimateGas_chainId ) {
std::string _config = c_genesisConfigString;
Json::Value ret;
Json::Reader().parse( _config, ret );

// Set chainID = 65535
ret["params"]["chainID"] = "0xffff";

Json::FastWriter fastWriter;
std::string config = fastWriter.write( ret );
JsonRpcFixture fixture( config );

// pragma solidity ^0.8.13;

// contract Counter {
// error BlockNumber(uint256 blockNumber);

// constructor() {
// revert BlockNumber(block.chainid);
// }
// }

Json::Value testRevert;
testRevert["data"] = "0x6080604052348015600f57600080fd5b50604051633013bad360e21b815246600482015260240160405180910390fdfe";

try {
fixture.rpcClient->eth_estimateGas( testRevert, "latest" );
} catch ( jsonrpc::JsonRpcException& ex) {
BOOST_CHECK_EQUAL(ex.GetCode(), 3);
BOOST_CHECK_EQUAL(ex.GetData().asString(), "0xc04eeb4c000000000000000000000000000000000000000000000000000000000000ffff");
BOOST_CHECK_EQUAL(ex.GetMessage(), "EVM revert instruction without description message");
}
}

BOOST_AUTO_TEST_CASE( eth_sendRawTransaction_gasLimitExceeded ) {
JsonRpcFixture fixture;
auto senderAddress = fixture.coinbase.address();
Expand Down

0 comments on commit 519ff02

Please sign in to comment.