-
Notifications
You must be signed in to change notification settings - Fork 492
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
fix: Update transaction validation logic in ethclient #1409
Conversation
Hi, thanks for raising this PR. The issues seems correct that it will happen when there's only 1 transaction which is a state-sync (system) transaction and nothing else. But, IMO, we shouldn't get rid of the error. Let me see if there's some way to find out if it's a state-sync tx or not. |
Hi @Leekyungun, can you update the PR to handle this specific condition explicitly instead of removing this check? Basically, system transactions are directly applied on state and hence the Also, could you raise the PR against |
Good idea! |
I've added exception handling and updated the target branch to develop. Initially, I considered declaring the address "0x0000000000000000000000000000000000000000" as a constant and replacing its occurrences, but I was concerned that future updates in Ethereum might cause conflicts. Please provide feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Leekyungun, thanks for the PR, just small suggestions and would wait for final review from @manav2401 😄
Thanks for the review, it seems like the code has improved because of it. |
Hey, the PR looks good, wait for the final review from @manav2401 😄 |
@Leekyungun thanks for updating the PR. I think it can be done in a simple way without introducing new functions. if head.TxHash == types.EmptyTxsHash && len(body.Transactions) > 0 {
tx := body.Transactions[0]
zeroAddress := common.HexToAddress("0x0000000000000000000000000000000000000000")
if *tx.From != zeroAddress || *tx.tx.To() != zeroAddress {
return nil, errors.New("server returned non-empty transaction list but block header indicates no transactions")
}
} Moreover, you can define Also, to answer your question, state sync transactions are always added at the end and there's exactly one of them. You can assume this for your implementation. Thanks. |
Just to be safe, if tx.From and tx.tx.To() are both nil, it would cause a panic. How about adding a nil check? |
@Leekyungun it works. thanks! |
I updated the implementation. Thank you! |
@Leekyungun current logic is fine. Few minor nits and then it's good to go. |
Completed! |
hey @Leekyungun I messed something up locally and accidentally force pushed something to your branch. Can you create a fresh PR the changes required. Also, while you're at it, you can do the change I did here. Apologies for this. Thanks! |
It's OK! Please review it |
Description
This PR resolves an issue where blocks containing system transactions could not be retrieved properly using
getBlock
.For such blocks, the
transactionsRoot
is set toEmptyTxsHash
, but theTransactions
list contains one transaction, which leads to a mismatch and prevents block information from being retrieved.The validation logic has been updated to handle these cases correctly.
Example block with system transaction: https://amoy.polygonscan.com/block/16653120
Changes
Breaking changes
No breaking changes have been introduced in this PR.
Nodes audience
This PR affects all nodes and does not include changes limited to a subset of nodes.
Checklist
Cross repository changes
Testing
Manual tests
transactionsRoot
asEmptyTxsHash
but includingTransactions
).Additional comments
See the example block for context:
https://amoy.polygonscan.com/block/16653120