Skip to content

feat(gas-keys): rosetta, mirror, prefetch support for DelegateV2 (3/3)#15885

Closed
darioush wants to merge 1 commit into
darioush/gas-keys/delegate-v2-core-execfrom
darioush/gas-keys/delegate-v2-others
Closed

feat(gas-keys): rosetta, mirror, prefetch support for DelegateV2 (3/3)#15885
darioush wants to merge 1 commit into
darioush/gas-keys/delegate-v2-core-execfrom
darioush/gas-keys/delegate-v2-others

Conversation

@darioush

@darioush darioush commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Last of the 3-PR stack (builds on #15884, original non-splitted: #15877). Non-consensus subsystem support for DelegateV2.

  • Rosetta: round-trips the DelegateActionExtension through a new OperationMetadata::delegate_action_extension field, so Action -> Operations -> Action stays a bijection for DelegateV2. Adds test_delegate_v2_actions_bijection.
  • Mirror: remaps and re-signs DelegateV2 in genesis.rs instead of cloning it through.
  • Prefetch: prefetches the per-index gas key nonce row that DelegateV2 validation reads.

Copilot AI review requested due to automatic review settings June 9, 2026 19:09
@darioush darioush requested a review from a team as a code owner June 9, 2026 19:09
@darioush darioush requested review from Wiezzel and removed request for a team June 9, 2026 19:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR completes non-consensus subsystem support for DelegateV2 across Rosetta, mirror, and runtime prefetching, aiming to preserve DelegateV2 fidelity (including extensions like gas-key nonce index) through conversions and to avoid missing trie reads during validation.

Changes:

  • Rosetta: round-trip DelegateV2 extensions by adding OperationMetadata::delegate_action_extension, refactoring delegate op emission, and adding a bijection test for DelegateV2.
  • Mirror: remap and re-sign DelegateV2 actions during genesis mapping instead of cloning them through unchanged.
  • Runtime prefetch: prefetch the per-index gas-key nonce row required by DelegateV2 validation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/mirror/src/genesis.rs Adds DelegateV2 handling by remapping inner delegate action and re-signing with the mapped key.
runtime/runtime/src/prefetch.rs Prefetches access key + gas-key nonce row for DelegateV2 (gas key extension).
chain/rosetta-rpc/src/models.rs Extends OperationMetadata to carry DelegateV2 extension for round-tripping.
chain/rosetta-rpc/src/adapters/validated_operations/delegate_action.rs Plumbs the optional delegate extension through validated delegate-action operations.
chain/rosetta-rpc/src/adapters/mod.rs Refactors delegate op generation and reconstructs Delegate vs DelegateV2 based on presence of extension; adds bijection test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread runtime/runtime/src/prefetch.rs
Comment thread chain/rosetta-rpc/src/models.rs
@darioush darioush marked this pull request as draft June 9, 2026 19:14
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.04094% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.95%. Comparing base (1a4c979) to head (1da4185).

Files with missing lines Patch % Lines
tools/mirror/src/genesis.rs 59.37% 13 Missing ⚠️
runtime/runtime/src/prefetch.rs 0.00% 12 Missing ⚠️
chain/rosetta-rpc/src/adapters/mod.rs 96.74% 4 Missing ⚠️
Additional details and impacted files
@@                             Coverage Diff                             @@
##           darioush/gas-keys/delegate-v2-core-exec   #15885      +/-   ##
===========================================================================
- Coverage                                    69.95%   69.95%   -0.01%     
===========================================================================
  Files                                          945      945              
  Lines                                       202736   202827      +91     
  Branches                                    202736   202827      +91     
===========================================================================
+ Hits                                        141820   141881      +61     
- Misses                                       56149    56182      +33     
+ Partials                                      4767     4764       -3     
Flag Coverage Δ
pytests-nightly 1.11% <0.00%> (-0.01%) ⬇️
unittests 69.68% <83.04%> (-0.01%) ⬇️
unittests-nightly 69.64% <83.04%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-core-exec branch from 3531361 to 5c94756 Compare June 9, 2026 19:24
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-others branch from 6494ae5 to cee91a1 Compare June 9, 2026 19:25
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-core-exec branch from 93d9a32 to b3b6201 Compare June 9, 2026 19:34
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-others branch from cee91a1 to 85c4f84 Compare June 9, 2026 19:34
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-core-exec branch from b3b6201 to 9c68ba6 Compare June 9, 2026 19:36
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-others branch from 85c4f84 to 6c5c0ac Compare June 9, 2026 19:36
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-core-exec branch from 9c68ba6 to 9305229 Compare June 9, 2026 19:45
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-others branch 2 times, most recently from 5435ac4 to 815e070 Compare June 9, 2026 19:53
@darioush darioush changed the title feat(gas-keys): DelegateV2 support in rosetta, mirror, prefetch feat(gas-keys): DelegateV2 support in rosetta, mirror, prefetch (3/3) Jun 9, 2026
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-others branch from 815e070 to ac99e5e Compare June 9, 2026 19:58
@darioush darioush changed the title feat(gas-keys): DelegateV2 support in rosetta, mirror, prefetch (3/3) feat(gas-keys): rosetta, mirror, prefetch support for DelegateV2 (3/3) Jun 9, 2026
@darioush darioush force-pushed the darioush/gas-keys/delegate-v2-others branch from ac99e5e to 1da4185 Compare June 9, 2026 20:15
@darioush darioush removed the request for review from Wiezzel June 9, 2026 20:18
@darioush darioush assigned pugachAG and unassigned pugachAG Jun 9, 2026
@darioush darioush requested a review from pugachAG June 9, 2026 20:19
@darioush darioush marked this pull request as ready for review June 9, 2026 20:24
@darioush darioush marked this pull request as draft June 12, 2026 03:18
@darioush darioush closed this Jun 12, 2026
pull Bot pushed a commit to Superoldman96/nearcore that referenced this pull request Jun 12, 2026
…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.
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