-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Replayables with Token #204
Conversation
353e187
to
5c5bd45
Compare
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.
The current approach looks good 👍
16d4a98
to
5c5bd45
Compare
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.
Overall this looks good to me 👍
Already noted, but we will want to spend some time thinking a little more thoroughly about testing.
9c58f8c
to
d1e8420
Compare
This code leads out the core changes for replayables with token. This was meant to be a WIP that just showed off the core features (it still is), but to get it to compile, I ended up converting most of the current tests to the new framework (e.g. mostly converting them to pick a semi-random nonce versus `nextNonce`, and checking `getNonceToken` as opposed to `getNextNonce`). Overall, the changes to the non-test code are very straight-forward. Most notable should be the changes to `QuarkStateManager` (adding new nonce and replay token code), and adding a new function to QuarkWallet `verifySigAndExecuteReplayableQuarkOperation`. Note: I didn't spend much time working on the outer interface for this, and I need to consider how this works best with multi-quark operations, but I wanted to get the outline first so we could discuss. There are also failing test cases and absent test cases, but again, more of a discussion point than a final product here. Patches: * Fix current tests
This patch mostly renames `QuarkStateManager` to `QuarkNonceManager`. Additionally, we start to use the term `submissionToken`, since it can cover first plays or replays both as "submissions". We choose the term `FREE` for the 0-token and `EXHAUSTED` for non-replayable tokens. Overall, this should provide a clearer and more consistent naming throughout the changeset.
d1e8420
to
2940fe0
Compare
2940fe0
to
fbc1a3b
Compare
This patch fixes some items in regards to a user signing `isReplayable`. Specifically, when a user signs an operation, they need to specify if the quark operation is replayable or not. When not, the state manager nonce _must be_ `bytes32(uint256(-1))`, but when it is replayable, the first play _must be_ `op.nonce`. If the user doesn't sign `isReplayable`, then we'd need to enforce that the first play is `replayToken = op.nonce`, which is bad since it that script could (if a bad nonce is chosen) end up replayable, which is an attack vector for a semi-bad client decision. Thus, we add this check to the user's signature and all things should be good in the world. Also, we start to fix a bit of verbiage to make things a bit nicer. Techncially, while it's missing about 200 new tests, this should be a complete implementation. Whitespace changes for fmt check Fix two minor comments Minor gas improvements
fbc1a3b
to
b00f3f6
Compare
We now cache the old transient slot values (e.g. for `activeNonce`, `callback`, etc) in order to restore them after calling the Quark script. This also adds a new test to test batched submission for a contract with callbacks to check its behavior. --------- Co-authored-by: kevincheng96 <[email protected]>
Merging this into the |
This code leads out the core changes for replayables with token. This was meant to be a WIP that just showed off the core features (it still is), but to get it to compile, I ended up converting most of the current tests to the new framework (e.g. mostly converting them to pick a semi-random nonce versus
nextNonce
, and checkinggetNonceToken
as opposed togetNextNonce
). Overall, the changes to the non-test code are very straight-forward. Most notable should be the changes toQuarkStateManager
(adding new nonce and replay token code), and adding a new function to QuarkWalletverifySigAndExecuteReplayableQuarkOperation
.Note: I didn't spend much time working on the outer interface for this, and I need to consider how this works best with multi-quark operations, but I wanted to get the outline first so we could discuss. There are also failing test cases and absent test cases, but again, more of a discussion point than a final product here.