-
Notifications
You must be signed in to change notification settings - Fork 5
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
bug: transaction replay #9
Comments
Closely related to this: A block is invalid if we've already seen a transaction. Txs can only be processed once. There are two ways to implement this:
|
In bitcoin this is just called the UXTO set. We have a set of unspent tx outputs. It's quite big to store this in memory. |
Funnily enough this doesn't need to occur in block validation. Already the block validation logic is designed purely from the perspective of a sequencer - ie. solving the hashcash nakamoto puzzle means you get to be the proposer. The transactions don't necessarily need to be valid, they are literally just committing to a sequence, there is no state root in the block header. So technically speaking, this is logic for the state machine If we implement it in the state machine, all it needs to do is keep a cache of seen transactions / nonces to prevent reuse. I don't like the nonce idea because technically if you broadcast a tx with nonce 20 and your latest nonce is 19, and then a reorg happens and your latest nonce is now 10, someone could rebroadcast your nonce 20 tx. So for example - the state machine ingests each tx, keeps a cache of "seen tx ids". I think a good anti-replay mechanism is to embed the latest [block, timestamp] into it, so it prevents reorging a tx according to a block and allows txs to come. This is what Solana does. |
Transaction validity is defined with respect to two models:
|
No description provided.
The text was updated successfully, but these errors were encountered: