feat(gas-keys): gas-key nonce routing for DelegateV2 (2/3)#15884
feat(gas-keys): gas-key nonce routing for DelegateV2 (2/3)#15884darioush wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Enables end-to-end execution of Action::DelegateV2 for gas-key meta transactions by routing delegate nonces through per-nonce_index gas-key nonce storage (behind ProtocolFeature::GasKeys) and adding tests to cover the new behavior across validation and execution.
Changes:
- Execute
Action::DelegateV2in the runtime and apply delegate actions via a shared inner path that supports optionalDelegateActionExtension. - Update delegate action key validation to (a) forbid gas keys for “plain” delegates, and (b) for gas-key delegates, range-check
nonce_indexand persist the nonce in per-index gas-key storage. - Add unit + test-loop coverage for gas-key
DelegateV2meta-transaction execution, nonce advancement behavior, and pre-feature rejection.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test-loop-tests/src/tests/gas_keys.rs | Adds an end-to-end test-loop meta-transaction using DelegateV2 + gas-key nonce index, asserting nonce routing and replay rejection. |
| runtime/runtime/src/lib.rs | Switches Action::DelegateV2 from “graceful failure” to actual execution via apply_delegate_action_v2. |
| runtime/runtime/src/actions.rs | Implements apply_delegate_action_v2 and extends delegate nonce validation/persistence to support gas-key per-index nonces via DelegateActionExtension. |
| runtime/runtime/src/action_validation.rs | Accepts DelegateV2 in action validation, gating gas-key extension on ProtocolFeature::GasKeys, and adds a regression test for pre-feature rejection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## darioush/gas-keys/delegate-v2-core-types #15884 +/- ##
============================================================================
+ Coverage 69.89% 69.95% +0.05%
============================================================================
Files 945 945
Lines 202448 202736 +288
Branches 202448 202736 +288
============================================================================
+ Hits 141503 141820 +317
+ Misses 56180 56149 -31
- Partials 4765 4767 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
67e0a4c to
cc524e6
Compare
b3b6201 to
9c68ba6
Compare
9c68ba6 to
9305229
Compare
…ions (1/3) (near#15904) First of a 3-PR stack adding gas-key support to meta transactions via a new `Action::DelegateV2`. Replaces the extension-based stack (near#15883, near#15884, near#15885) with the versioned design suggested in review there. Adds the wire types and the nesting guard, but no execution yet: validation rejects `DelegateV2` (`UnsupportedProtocolFeature`) and the apply path fails it gracefully. Execution lands in the next PR in the stack. Design: - `DelegateActionV2` mirrors `TransactionV1`: its `nonce: TransactionNonce` selects either the access key nonce or one of a gas key's parallel nonces by index. - `VersionedDelegateActionPayload` (wire enum, currently just `V2`) is the signed payload of `VersionedSignedDelegateAction`. Future versions add a variant here instead of a new `Action` variant, so the delegate nesting guard stays frozen, and the variant byte is covered by the signature so versions cannot be confused. - `DelegateV2` signs under its own NEP-461 discriminant (NEP-611, gas keys), making V1 and V2 signing domains disjoint by construction. - `VersionedDelegateActionRef`/`VersionedSignedDelegateActionRef` are borrowing wrappers for code handling V1 and V2 uniformly (the `VersionedActionReceipt` pattern). - A dedicated `ProtocolFeature::DelegateV2` (protocol version 85) gates the action independently of `ProtocolFeature::GasKeys`, so it can be pulled from the release on its own if needed. Includes `ActionView::DelegateV2`, cost/fee handling, and trivial match arms across the workspace. Protocol schema and openapi specs (1.2.11) are regenerated.
Second of the 3-PR stack (builds on #15883, original non-splitted: #15877)
Flips
DelegateV2from "rejected at validation" to fully executed:validate_delegate_action_keynow threadsOption<&DelegateActionExtension>and routes aGasKey { nonce_index }through the per-index gas key nonce storage (gated onProtocolFeature::GasKeys, range-checked, relayer prepays). A missing in-range nonce row is treated asStorageInconsistentStaterather than defaulting to 0, matching the transaction path.Tests: unit coverage for
validate_delegate_action_key(full-access / function-call permissions, invalid nonce index, pre-feature rejection) and an end-to-end test-loop meta transaction (relayer wraps the gas-key-signedDelegateV2, inner action executes, only the chosen nonce index advances, replay fails).