-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
check transaction before broadcasting / accepting #3046
base: testnet3
Are you sure you want to change the base?
Conversation
Oops, edited the code but forgot to git add, will change later |
e9922f9
to
5446641
Compare
There is the concern that it is possible the user broadcasts 2 or more transactions, whereby the first transaction makes the second (and later) transactions valid. But the verifier will not know this without speculative execution in advance. |
This check is also present in the inbound method for |
Great point, we did add that check in as a preemptive safeguard. I agree it wouldn't be a significant feature change to include this one too. Do you know if there are any major performance implications we should be aware of with this PR? |
Actually I did think about if one can just spam invalid transactions, but didn't actually try to profile the check function. It does seems a little expensive as the "basic" check did try to thoroughly verify many things included in the transaction. Without the check though, the spammer will be spamming all connected nodes instead. But admittedly losing a public API endpoint would be worse. Probably I need to generate some fake data to test if this could have severe performance implications. |
I just realized we have https://github.com/AleoHQ/snarkOS/pull/2942 so we don't need to specifically worry about attacks as you can still DDoS other endpoints, especially I did test the check function and it took 50~100ms on my server to verify a valid transaction and similar transactions with a bad execution proofs. The timing variation seems to come from storage accesses to verify duplicated IDs. I currently don't have resources to actually test if flooding would take down a node, but from the time above, heuristically it's indeed possible even with legitimate traffic (think a large amount of valid transactions during a event of some project). That said, that amount of traffic could disable other nodes processing |
Motivation
Check if the transaction is valid before broadcasting. Prevents users accidentally generating invalid transactions then wonder where did they go after it got rejected by other nodes.
This check was there before Sep 2022. Not sure why it was removed.
Test Plan
(If you changed any code, please provide clear instructions on how you verified your changes work.)
My invalid tx could be rejected.
Related PRs
(Link any related PRs here)