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

Exception stack log when processing transaction message #6178

Closed
fyyhtx opened this issue Feb 13, 2025 · 2 comments
Closed

Exception stack log when processing transaction message #6178

fyyhtx opened this issue Feb 13, 2025 · 2 comments
Labels

Comments

@fyyhtx
Copy link
Contributor

fyyhtx commented Feb 13, 2025

Software Versions

OS: Linux
JVM: Oracle Corporation 1.8.0_161 AMD64
Git: a8ad2a169e58946b5b8de6ecf7b7ef5b8db05aff
Version: 4.7.5
Code: 18306

Expected behaviour

The P2P module handles exceptions normally when processing transaction messages.

Actual behaviour

The mainnet fullnode I was running printed the following exception stack log:

java.lang.IndexOutOfBoundsException: Index: 0
at org.tron.protos.Protocol$Transaction$raw.getContract(Protocol.java:37837)
at org.tron.core.net.messagehandler.TransactionsMsgHandler.processMessage(TransactionsMsgHandler.java:74)
at org.tron.core.net.P2pEventHandlerImpl.processMessage(P2pEventHandlerImpl.java:201)
at org.tron.core.net.P2pEventHandlerImpl.onMessage(P2pEventHandlerImpl.java:141)
at org.tron.p2p.connection.ChannelManager.handMessage(ChannelManager.java:261)
at org.tron.p2p.connection.ChannelManager.processMessage(ChannelManager.java:207)
at org.tron.p2p.connection.socket.MessageHandler.decode(MessageHandler.java:51)
at org.tron.p2p.stats.TrafficStats$TrafficStatHandler.channelRead(TrafficStats.java:36)

After analyzing the code, we found that the location of the exception log output is the TransactionsMsgHandler class that processes transaction messages. By default, each transaction carried by the transaction message in the processing logic contains at least 1 contract. Suppose the transaction received from the peer does not carry a contract. In that case, an IndexOutOfBoundsException exception will be reported when processing this transaction, and the connection with the peer will be disconnected.

Frequency

The exception stack appears occasionally.

Steps to reproduce the behaviour

Send transaction P2P messages without contracts to the node.

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

@jwrct
Copy link
Contributor

jwrct commented Feb 13, 2025

After reviewing the code, I found that when processing transaction messages, the contract is indeed obtained directly for processing without checking whether the transaction carries a contract. Before obtaining the transaction contract, verification logic should be added to determine whether the transaction carries the contract.

@vivian1912
Copy link
Contributor

@fyyhtx Thanks for your contribution to java-tron. This issue has already been fixed and will be included in the next release of java-tron. Please refer to #6181.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

3 participants