test: lock in permit nonce consumption when the inner call reverts - #1516
Open
acyberduck wants to merge 1 commit into
Open
test: lock in permit nonce consumption when the inner call reverts#1516acyberduck wants to merge 1 commit into
acyberduck wants to merge 1 commit into
Conversation
Composes the existing revert and replay coverage on the signed dispatch_permit path into one end-to-end lock, so a future change that rolls the nonce back on revert fails on the replay it would enable. Bumps runtime-integration-tests to 1.107.2 for the version check.
|
Crate versions that have been updated:
Runtime version has not been increased. |
|
Quick benchmark at commit e3987b9 has been executed successfully. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following up on the Discord conversation about the Call-Permit path: I offered to add a small regression test that locks in "nonce consumed on revert", and this is it. No production code is touched.
What this pins
do_dispatch_permit_signedinpallets/transaction-multi-payment/src/lib.rsmaps a reverting inner call toOk(post_info)rather thanErr, with this comment:The new test,
permit_nonce_is_consumed_when_inner_call_reverts_and_replay_is_rejected, exercises that end to end on the signed path:min_buy_amount) and the extrinsic still returnsOkEvmPermitInvalid, before any executionWhy add it when coverage already exists
While writing it I found both halves already covered, and I would rather say so than oversell this:
signed_dispatch_permit_should_commit_and_consume_nonce_when_inner_call_revertspins the nonce bump on revertsigned_dispatch_permit_should_fail_when_replayed_with_same_noncepins that a spent nonce is refused, but on a permit that succeededWhat is not pinned anywhere is the composition, which is the property the comment is actually about. On the revert path the inner call had no effect, so a replay that got through would execute a call the signer authorized exactly once. Points 4 and 5 above are the part no existing test asserts. If you read this as redundant, I am happy for it to be closed; it seemed better to have the replay lock asserted directly than inferred from two separate tests.
Batch variant
I looked at a two-permit batch variant (first leg reverts, second executes, first leg's replay refused) and left it out. The shared
build_permit_for_callhelper signs at nonce zero, so a second permit in the same batch would need a nonce parameter threaded through that helper and every existing call site. That is more churn than a regression test justifies.Verification
cargo test -p runtime-integration-tests evm_permit::gives 43 passed, 0 failedleft: 1, right: 0)do_dispatch_permit_signedto returnErr(e.error.into())on revert, which is the rollback the comment warns about, turns this test red. Reverted afterwardscargo fmt --all -- --checkis cleanNotes
integration-tests/src/evm_permit.rs, in the existingsponsored_paymastermodule, reusing itspaymaster_account,build_permit_for_callandassert_dispatch_permit_not_pausedhelpers. The pallet's own mock has no EVM, so this cannot live in the pallet's test module.runtime-integration-testsbumped to 1.107.2 to satisfy the crate version check.Happy to rename the test, trim the comment, or drop the version bump if you handle that separately.