Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when making a JSON/RPC call too early that requires the transaction pool to be initialized #6863

Closed
matthew1001 opened this issue Apr 2, 2024 · 4 comments · Fixed by #6890
Assignees
Labels
bug Something isn't working P2 High (ex: Degrading performance issues, unexpected behavior of core features (DevP2P, syncing, etc)) RPC

Comments

@matthew1001
Copy link
Contributor

matthew1001 commented Apr 2, 2024

Description

I start a new Besu node and before it has synced I submit a new transaction. This requires the nonce for the sender to be determined, which hits the following NPE because the transaction pool hasn't been initialized yet:

java.lang.NullPointerException: Cannot invoke "org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions.getNextNonceForSender(org.hyperledger.besu.datatypes.Address)" because "this.pendingTransactions" is null
        at org.hyperledger.besu.ethereum.eth.transactions.TransactionPool.getNextNonceForSender(TransactionPool.java:539)
        at org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetTransactionCount.pendingResult(EthGetTransactionCount.java:60)
        at org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterOrBlockHashMethod.handleParamTypes(AbstractBlockParameterOrBlockHashMethod.java:100)
        at org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.AbstractBlockParameterOrBlockHashMethod.response(AbstractBlockParameterOrBlockHashMethod.java:151)
        at org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor.process(BaseJsonRpcProcessor.java:44)
        at org.hyperledger.besu.ethereum.api.jsonrpc.execution.TracedJsonRpcProcessor.process(TracedJsonRpcProcessor.java:41)
        at org.hyperledger.besu.ethereum.api.jsonrpc.execution.TimedJsonRpcProcessor.process(TimedJsonRpcProcessor.java:45)
        at org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor.execute(JsonRpcExecutor.java:92)
        at org.hyperledger.besu.ethereum.api.handlers.AbstractJsonRpcExecutor.executeRequest(AbstractJsonRpcExecutor.java:87)
        at org.hyperledger.besu.ethereum.api.handlers.JsonRpcObjectExecutor.execute(JsonRpcObjectExecutor.java:57)
        at org.hyperledger.besu.ethereum.api.handlers.JsonRpcExecutorHandler.lambda$handler$0(JsonRpcExecutorHandler.java:57)
        at java.base/java.util.Optional.ifPresentOrElse(Optional.java:196)
        at org.hyperledger.besu.ethereum.api.handlers.JsonRpcExecutorHandler.lambda$handler$2(JsonRpcExecutorHandler.java:54)
        at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:190)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:276)
        at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:209)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)
^C2024-04-02 16:40:43.003+01:00 | BesuCommand-Shutdown-Hook |

Steps to Reproduce (Bug)

  1. Run besu --genesis-file=genesis.json --profile=enterprise --data-storage-format=FOREST --data-path=./data --rpc-http-enabled
  2. Before the node has synced and started mining blocks, submit a new transaction

Expected behavior:
No NPE. I think the correct behaviour is either a) a suitable error code being returned to the JSON/RPC call or b) the transaction pool accepting the transaction and it being mined when the node has synced.

Actual behavior:
NPE shown above

Frequency:
Always

Versions (Add all that apply)

  • Software version: besu/v24.4-develop-cf5e3dae98/osx-aarch_64/openjdk-java-17
@matthew1001 matthew1001 added the bug Something isn't working label Apr 2, 2024
@matthew1001
Copy link
Contributor Author

I think this may be related to #6302 @fab-10 ?

@fab-10
Copy link
Contributor

fab-10 commented Apr 3, 2024

yes i think so, it should return an error response saying the txpool is disabled and not throwing an exception, so it is definitely a bug

@jframe jframe added RPC P2 High (ex: Degrading performance issues, unexpected behavior of core features (DevP2P, syncing, etc)) labels Apr 3, 2024
@Gabriel-Trintinalia
Copy link
Contributor

Gabriel-Trintinalia commented Apr 4, 2024

@fab-10 do you think initiating pendingTransactions with new DisabledPendingTransactions would be enough here?

@fab-10
Copy link
Contributor

fab-10 commented Apr 5, 2024

yes, it works, and while verifying you suggestion, I just made the fix and added some tests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 High (ex: Degrading performance issues, unexpected behavior of core features (DevP2P, syncing, etc)) RPC
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants