-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Manage durable nonce stored value in runtime #7684
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7684 +/- ##
========================================
+ Coverage 81.7% 81.7% +<.1%
========================================
Files 241 241
Lines 50750 50871 +121
========================================
+ Hits 41502 41609 +107
- Misses 9248 9262 +14 |
Dropped the removal of instruction nonce advance to regain advancing explicitly with non-durable-nonce TX (fixes CLI integration tests). Probably a good safe guard to keep around in any case. Now I'm considering only doing the runtime advance on |
I think I've lost the trail of this. I thought the fix was going to be pay fee + verify the Nonce instruction worked (do both of these during load()). If the Nonce can't advance, don't collect fee, report load failure. There'd be no store-side changes needed. |
The fee theft opportunity presents itself if any instruction in the transaction fails. We have to advance the nonce, or not charge fees. Not charging fees opens us up to DoS, so always advancing the nonce seems like the surest path |
I think we're on the same page there. I'd hoped that running the Nonce instruction or checking that the Nonce instruction would succeed would be part of load() like, do it here: https://github.com/solana-labs/solana/pull/7684/files#diff-0104dfa96426a3a49428815872a0356eR154 |
The Lemme see how gross executing the instruction is |
This might not actually be too bad! 🤞 |
b768694
to
cc1225a
Compare
@rob-solana Sorry, didn't see your edit
I initially put the nonce ix pre-execution in the caller, since we had more of the stuff needed to call I don't think this'll work purely load-side, though. The problem is the initial TX failing |
cc1225a
to
21fa214
Compare
Ok, I think you're right. I think what you have will work. |
Thanks! |
* Bank: Return nonce pubkey/account from `check_tx_durable_nonce` * Forward account with HashAgeKind::DurableNonce * Add durable nonce helper for HashAgeKind * Add nonce util for advancing stored nonce in runtime * Advance nonce in runtime * Store rolled back nonce account on TX InstructionError * nonce: Add test for replayed InstErr fee theft (cherry picked from commit 9754fc7) # Conflicts: # runtime/src/accounts.rs
* Bank: Return nonce pubkey/account from `check_tx_durable_nonce` * Forward account with HashAgeKind::DurableNonce * Add durable nonce helper for HashAgeKind * Add nonce util for advancing stored nonce in runtime * Advance nonce in runtime * Store rolled back nonce account on TX InstructionError * nonce: Add test for replayed InstErr fee theft
Problem
As per #7443, managing the stored durable nonce value in a program instruction leaves executions resulting in
InstructionError
open to continuous replay and fee theft until the stored nonce is successfully advanced.Summary of Changes
Store nonce account of durable nonce TXs that fail with
InstructionError
Check nonce premature-usage in runtime
Advance nonce in runtime
Fixes #7443