Skip to content

Commit

Permalink
IS-900 Better checks for invalid transactions in Eth.cpp (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimalit committed Feb 12, 2024
1 parent da9bf68 commit 9515aad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ void GappedTransactionIndexCache::ensureCached( BlockNumber _bn,
_readLock.unlock();
_writeLock.lock();


unsigned realBn = _bn;
if ( _bn == LatestBlock )
realBn = client.number();
else if ( _bn == PendingBlock )
realBn = client.number() + 1;

if ( real2gappedCache.size() > cacheSize ) {
throw std::runtime_error( "real2gappedCache.size() > cacheSize" );
}
Expand All @@ -92,7 +99,7 @@ void GappedTransactionIndexCache::ensureCached( BlockNumber _bn,
pair< h256, unsigned > loc = client.transactionLocation( th );

// ignore transactions with 0 gas usage OR different location!
if ( diff == 0 || client.numberFromHash( loc.first ) != _bn || loc.second != realIndex )
if ( diff == 0 || client.numberFromHash( loc.first ) != realBn || loc.second != realIndex )
continue;

// cache it
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ struct JsonRpcFixture : public TestOutputHelperFixture {
rpcServer.reset( new FullServer( ethFace , new rpc::Net( chainParams ),
new rpc::Web3( /*web3->clientVersion()*/ ), // TODO Add real version?
new rpc::AdminEth( *client, *gasPricer, keyManager, *sessionManager.get() ),
/*new rpc::AdminNet(*web3, *sessionManager), */ new rpc::Debug( *client ),
/*new rpc::AdminNet(*web3, *sessionManager), */ new rpc::Debug( *client, nullptr, "", true),
new rpc::Test( *client ) ) );

//
Expand Down

0 comments on commit 9515aad

Please sign in to comment.