-
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
Switch to isReplayable #205
Conversation
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.
LGTM
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.
I think we already discussed isReplayable
in #quark
, and I'm in favor. I do see the compelling case that we need it in the signature to give users control over whether replays are allowed. I like it as a boolean; I think there was some discussion about using maxReplays
and it doubling as an extra(neous) stop condition for computing the current replay count, and I don't care for that idea, but I also wouldn't want to die on that hill.
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.
16d4a98
to
4f02f25
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.
looks good, just a few notes
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.
Look great overall! No blocking issues, other than to re-run the formatter and generate a new gas snapshot.
EDIT: Well, actually, this comment I think is worth discussing.
Previously in `QuarkNonceManager`, we used `submissionToken=EXHAUSTED` for non-replayable submissions and `submissionToken=nonce` for the first play of replayable submissions. Overall, this behavior was inconsistent (though otherwise fine) and generally unobservable. With the addition of `getActiveSubmissionToken`, this behavior became obervable and showed its inconsistencies. This patch changes the defined behavior making it where we submit `submissionToken=nonce` for the first play or a single-use or replayable quark operation, but still retain the behavior that `submissions[nonce]=EXHAUSTED` for non-replayables. This ends up as a reduction in the overall code complexity. The only true behavior this changes is that we must (and should) ban `nonce=bytes32(0)` (and for the sake of consistency also `nonce=bytes32(uint_max)`). This is because we would be submitting with `submissionToken=FREE` for that nonce and overall it isn't worth the risk of allowing that (since it wouldn't, but _could_ lead to unlimited replays if other code isn't implemented correctly). Overall, I think this change is a net benefit in reduction of code complexity and better understandability from the end-user's perspective. Patches: * Add a test where we check what values a user can submit for submission tokens * Addressed some #205 comments
Previously in `QuarkNonceManager`, we used `submissionToken=EXHAUSTED` for non-replayable submissions and `submissionToken=nonce` for the first play of replayable submissions. Overall, this behavior was inconsistent (though otherwise fine) and generally unobservable. With the addition of `getActiveSubmissionToken`, this behavior became obervable and showed its inconsistencies. This patch changes the defined behavior making it where we submit `submissionToken=nonce` for the first play or a single-use or replayable quark operation, but still retain the behavior that `submissions[nonce]=EXHAUSTED` for non-replayables. This ends up as a reduction in the overall code complexity. The only true behavior this changes is that we must (and should) ban `nonce=bytes32(0)` (and for the sake of consistency also `nonce=bytes32(uint_max)`). This is because we would be submitting with `submissionToken=FREE` for that nonce and overall it isn't worth the risk of allowing that (since it wouldn't, but _could_ lead to unlimited replays if other code isn't implemented correctly). Overall, I think this change is a net benefit in reduction of code complexity and better understandability from the end-user's perspective. Patches: * Add a test where we check what values a user can submit for submission tokens * Addressed some #205 comments
Previously in `QuarkNonceManager`, we used `submissionToken=EXHAUSTED` for non-replayable submissions and `submissionToken=nonce` for the first play of replayable submissions. Overall, this behavior was inconsistent (though otherwise fine) and generally unobservable. With the addition of `getActiveSubmissionToken`, this behavior became obervable and showed its inconsistencies. This patch changes the defined behavior making it where we submit `submissionToken=nonce` for the first play or a single-use or replayable quark operation, but still retain the behavior that `submissions[nonce]=EXHAUSTED` for non-replayables. This ends up as a reduction in the overall code complexity. The only true behavior this changes is that we must (and should) ban `nonce=bytes32(0)` (and for the sake of consistency also `nonce=bytes32(uint_max)`). This is because we would be submitting with `submissionToken=FREE` for that nonce and overall it isn't worth the risk of allowing that (since it wouldn't, but _could_ lead to unlimited replays if other code isn't implemented correctly). Overall, I think this change is a net benefit in reduction of code complexity and better understandability from the end-user's perspective. Patches: * Add a test where we check what values a user can submit for submission tokens * Addressed some #205 comments
Previously in `QuarkNonceManager`, we used `submissionToken=EXHAUSTED` for non-replayable submissions and `submissionToken=nonce` for the first play of replayable submissions. Overall, this behavior was inconsistent (though otherwise fine) and generally unobservable. With the addition of `getActiveSubmissionToken`, this behavior became obervable and showed its inconsistencies. This patch changes the defined behavior making it where we submit `submissionToken=nonce` for the first play or a single-use or replayable quark operation, but still retain the behavior that `submissions[nonce]=EXHAUSTED` for non-replayables. This ends up as a reduction in the overall code complexity. The only true behavior this changes is that we must (and should) ban `nonce=bytes32(0)` (and for the sake of consistency also `nonce=bytes32(uint_max)`). This is because we would be submitting with `submissionToken=FREE` for that nonce and overall it isn't worth the risk of allowing that (since it wouldn't, but _could_ lead to unlimited replays if other code isn't implemented correctly). Overall, I think this change is a net benefit in reduction of code complexity and better understandability from the end-user's perspective. Patches: * Add a test where we check what values a user can submit for submission tokens * Addressed some #205 comments
This patch adds support for setting the active nonce and submission token in temporary storage so scripts can read it and get the current nonce, submission token, and if they so choose, N. This is useful for certain scripts.
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
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
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
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
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 bebytes32(uint256(-1))
, but when it is replayable, the first play must beop.nonce
. If the user doesn't signisReplayable
, then we'd need to enforce that the first play isreplayToken = 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.