Skip to content
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

Nonce as Non-Replayable Submission Token #209

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

hayesgm
Copy link
Contributor

@hayesgm hayesgm commented Sep 11, 2024

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.

@hayesgm hayesgm force-pushed the hayesgm/nonce-as-non-replayable-token branch from 2a9db50 to 67a2f63 Compare September 11, 2024 19:30
Copy link
Collaborator

@fluffywaffles fluffywaffles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, one suggestion on your missing revert that may or may not help


assertEq(counter.number(), 1);

// Not sure why this revert isn't showing up-- it's reverting, nonetheless.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is crazy but is it because you didn't do new bytes[](0) (inline in the call to execute on 264) above the expectRevert?

I mean... the constructor execution succeeds, so I wonder if the expect revert accidentally targets this nested call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, doesn't make it work. Though that change is probably for the better for clarity, so I moved that construction to a var above anyway, thanks.

@hayesgm hayesgm mentioned this pull request Sep 11, 2024
@hayesgm hayesgm force-pushed the hayesgm/nonce-as-non-replayable-token branch 2 times, most recently from dacc7de to c28c310 Compare September 11, 2024 19:43
Copy link
Collaborator

@kevincheng96 kevincheng96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Good change that improves consistency

test/quark-core/Noncer.t.sol Show resolved Hide resolved
test/quark-core/QuarkWallet.t.sol Show resolved Hide resolved
test/quark-core/QuarkWallet.t.sol Show resolved Hide resolved
@hayesgm hayesgm force-pushed the hayesgm/nonce-as-non-replayable-token branch from c28c310 to 6037dc0 Compare September 11, 2024 20:54
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
@hayesgm hayesgm force-pushed the hayesgm/nonce-as-non-replayable-token branch from 6037dc0 to 4c11215 Compare September 11, 2024 20:56
@hayesgm hayesgm merged commit 9e310d6 into hayesgm/get-nonce Sep 11, 2024
2 of 4 checks passed
@hayesgm hayesgm deleted the hayesgm/nonce-as-non-replayable-token branch September 11, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants