Skip to content

NEP-611: Pending Transaction Queue#611

Merged
gagdiez merged 48 commits into
masterfrom
robin/611
Apr 7, 2026
Merged

NEP-611: Pending Transaction Queue#611
gagdiez merged 48 commits into
masterfrom
robin/611

Conversation

@robin-near

@robin-near robin-near commented May 30, 2025

Copy link
Copy Markdown
Contributor

In the near future of the Near blockchain, we foresee that via the SPICE project, transaction and receipt execution will become decoupled from the blockchain itself; they will no longer run in lockstep. Instead, transactions will be included in the blocks first, and then execution will follow later.

This inherently introduces a problem that we must accept transactions before we know whether they are valid. Today, when a chunk producer produces a chunk containing a transaction, it can verify using the current shard state that the transaction has a valid signature, has enough balance, and a valid nonce. But as execution becomes asynchronous, we no longer have the current shard state to verify the
transactions against.

This NEP proposes a mechanism called the Pending Transaction Queue to solve this problem.

@birchmd birchmd 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.

Thanks for bringing this up! It is good to think about how to prevent possible DoS attacks under SPICE.

Comment thread neps/nep-0611.md Outdated
#### Access Key Parallelism Restriction
We now restrict the ability to send multiple parallel pending transactions with Access Keys.

Specifically, for any given account $A$ with any number of access keys, the total number of access key transactions in the pending transaction queue whose sender is $A$ cannot exceed $P_{\mathrm {max}}$, a

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.

Is this enough to prevent the attack described above? Instead of having one account they send many transactions to, it could be many accounts they send only a few transactions to each.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The idea is that the amount of block space the attacker consumes vs amount of gas the attacker has to pay, i.e. the "waste amplification factor", is unbounded in the attack mentioned in the NEP, but only O(1) with a maximum parallelism. It's then still possible to attack, but the attack would cost a proportional amount of gas - just cheaper than it is today - which isn't a very great incentive to mount the attack (given that the attack is only a DoS).

Comment thread neps/nep-0611.md
github-merge-queue Bot pushed a commit to near/nearcore that referenced this pull request Jun 10, 2025
See near/NEPs#611

This PR adds the GasKey trie key. In subsequent PRs we will introduce a
new transaction type to accept gas key transactions, and to implement
the gas key actions.
ssavenko-near pushed a commit to near/nearcore that referenced this pull request Jun 13, 2025
See near/NEPs#611

This PR adds the GasKey trie key. In subsequent PRs we will introduce a
new transaction type to accept gas key transactions, and to implement
the gas key actions.
@trechriron trechriron temporarily deployed to robin/611 - nomicon PR #611 July 16, 2025 13:06 — with Render Destroyed
@gagdiez

gagdiez commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

Hi @robin-near (or anyone who is interested in championing this NEP forward) – we are cleaning the NEP backlog and noticed that this PR still has some incomplete sections: particularly, it has a "TODO: Other things". Therefore, we are labeling this PR as "Needs author revision."

Please ping the @near/nep-moderators once you are ready for us to review it. We typically close NEPs that are inactive for more than two months, so please let us know if you need more time.

@gagdiez gagdiez added S-draft/needs-author-revision A NEP in the DRAFT stage that needs an author revision. WG-protocol Protocol Standards Work Group should be accountable labels Jul 16, 2025
@gagdiez gagdiez moved this from NEW to DRAFT in NEPs Jul 16, 2025
@garikbesson

Copy link
Copy Markdown
Contributor

Because there has been no activity from the author for more than 3 months, I'm marking the proposal as RETRACTED. Please feel free to open it again if you'd like to continue working on it.

@github-project-automation github-project-automation Bot moved this from NEW❗ to Shipped 🚀 in DevRel Sep 22, 2025
@garikbesson garikbesson added the S-retracted A NEP that was retracted by the author or had no activity for over two months. label Sep 22, 2025
@garikbesson garikbesson moved this from DRAFT to RETRACTED in NEPs Sep 22, 2025
@darioush darioush reopened this Nov 21, 2025
@github-project-automation github-project-automation Bot moved this from Shipped 🚀 to NEW❗ in DevRel Nov 21, 2025
github-merge-queue Bot pushed a commit to near/nearcore that referenced this pull request Feb 24, 2026
Gas keys ([NEP-611](near/NEPs#611)) allow access
keys to carry a NEAR balance dedicated to paying for gas, separate from
the account's main balance. This PR implements Rosetta Construction API
support for `TransferToGasKey` and `WithdrawFromGasKey` actions,
enabling bidirectional conversion between NEAR actions and Rosetta
operations.

- New operations: `InitiateTransferToGasKey`, `TransferToGasKey`,
`InitiateWithdrawFromGasKey`, `WithdrawFromGasKey`
- Each gas key action maps to a pair of Rosetta operations (initiate +
main), following the existing pattern used by `Transfer`, `AddKey`, etc.
- `TransferToGasKey` is non-SIR-compatible (sender != receiver),
`WithdrawFromGasKey` is SIR-compatible
- Roundtrip bijection test updated to cover both new action types
github-merge-queue Bot pushed a commit to near/nearcore that referenced this pull request Feb 24, 2026
Gas keys ([NEP-611](near/NEPs#611)) allow access
keys to carry a NEAR balance dedicated to paying for gas, separate from
the account's main balance. This PR implements Rosetta Construction API
support for `TransferToGasKey` and `WithdrawFromGasKey` actions,
enabling bidirectional conversion between NEAR actions and Rosetta
operations.

- New operations: `InitiateTransferToGasKey`, `TransferToGasKey`,
`InitiateWithdrawFromGasKey`, `WithdrawFromGasKey`
- Each gas key action maps to a pair of Rosetta operations (initiate +
main), following the existing pattern used by `Transfer`, `AddKey`, etc.
- `TransferToGasKey` is non-SIR-compatible (sender != receiver),
`WithdrawFromGasKey` is SIR-compatible
- Roundtrip bijection test updated to cover both new action types
github-merge-queue Bot pushed a commit to near/nearcore that referenced this pull request Feb 24, 2026
Gas keys ([NEP-611](near/NEPs#611)) allow access
keys to carry a NEAR balance dedicated to paying for gas, separate from
the account's main balance. This PR implements Rosetta Construction API
support for `TransferToGasKey` and `WithdrawFromGasKey` actions,
enabling bidirectional conversion between NEAR actions and Rosetta
operations.

- New operations: `InitiateTransferToGasKey`, `TransferToGasKey`,
`InitiateWithdrawFromGasKey`, `WithdrawFromGasKey`
- Each gas key action maps to a pair of Rosetta operations (initiate +
main), following the existing pattern used by `Transfer`, `AddKey`, etc.
- `TransferToGasKey` is non-SIR-compatible (sender != receiver),
`WithdrawFromGasKey` is SIR-compatible
- Roundtrip bijection test updated to cover both new action types
github-merge-queue Bot pushed a commit to near/nearcore that referenced this pull request Feb 24, 2026
Gas keys ([NEP-611](near/NEPs#611)) allow access
keys to carry a NEAR balance dedicated to paying for gas, separate from
the account's main balance. This PR adds Rosetta Data API support for
tracking gas key balances, building on the action encoding from #15100.

At a high level, uses `StateChangesRequestView::AllAccessKeyChanges` to
get changes to gas key balances, including when they are deleted. Then,
adding a new `SubAccount` type, which represents the aggregate gas key
balance for an account on the Rosetta side.

- Add `SubAccount::GasKey` for querying aggregate gas key balance via
`/account/balance`.
- Track per-key gas key balance changes by observing access key state
changes in each block
- Attribute balance diffs to their causal receipt/transaction with
`transfer_fee_type` metadata: `GasPrepayment` for
`TransactionProcessing`,`GasRefund` for system predecessor
- Handle key deletion by emitting a `GasKeyBalanceBurnt` operation for
the remaining balance
- Add test covering transfer-in, refund, gas usage, key deletion, and
gas prepayment scenarios
github-merge-queue Bot pushed a commit to near/nearcore that referenced this pull request Feb 24, 2026
Gas keys ([NEP-611](near/NEPs#611)) allow access
keys to carry a NEAR balance dedicated to paying for gas, separate from
the account's main balance. This PR adds Rosetta Data API support for
tracking gas key balances, building on the action encoding from #15100.

At a high level, uses `StateChangesRequestView::AllAccessKeyChanges` to
get changes to gas key balances, including when they are deleted. Then,
adding a new `SubAccount` type, which represents the aggregate gas key
balance for an account on the Rosetta side.

- Add `SubAccount::GasKey` for querying aggregate gas key balance via
`/account/balance`.
- Track per-key gas key balance changes by observing access key state
changes in each block
- Attribute balance diffs to their causal receipt/transaction with
`transfer_fee_type` metadata: `GasPrepayment` for
`TransactionProcessing`,`GasRefund` for system predecessor
- Handle key deletion by emitting a `GasKeyBalanceBurnt` operation for
the remaining balance
- Add test covering transfer-in, refund, gas usage, key deletion, and
gas prepayment scenarios
github-merge-queue Bot pushed a commit to near/nearcore that referenced this pull request Feb 24, 2026
Gas keys ([NEP-611](near/NEPs#611)) allow access
keys to carry a NEAR balance dedicated to paying for gas, separate from
the account's main balance. This PR adds Rosetta Data API support for
tracking gas key balances, building on the action encoding from #15100.

At a high level, uses `StateChangesRequestView::AllAccessKeyChanges` to
get changes to gas key balances, including when they are deleted. Then,
adding a new `SubAccount` type, which represents the aggregate gas key
balance for an account on the Rosetta side.

- Add `SubAccount::GasKey` for querying aggregate gas key balance via
`/account/balance`.
- Track per-key gas key balance changes by observing access key state
changes in each block
- Attribute balance diffs to their causal receipt/transaction with
`transfer_fee_type` metadata: `GasPrepayment` for
`TransactionProcessing`,`GasRefund` for system predecessor
- Handle key deletion by emitting a `GasKeyBalanceBurnt` operation for
the remaining balance
- Add test covering transfer-in, refund, gas usage, key deletion, and
gas prepayment scenarios
@gagdiez

gagdiez commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Hi everyone! seeing that some members of the WG voted, and by the request of @walnut-the-cat, we are moving forward to meet and vote this NEP

@robin-near, @jakmeier, @matejpavlovic, @darioush if you could share your availability here we will try to find some time that works for everyone

@robin-near / @darioush would be awesome if one of you could present a high level explanation of the NEP. No need to have a full presentation, just 1 - 3 slides, enough overview for people to understand the gist of it.

Thank you everyone!

@gagdiez gagdiez changed the title Draft NEP for pending transaction queue. NEP-611: Pending Transaction Queue Feb 26, 2026
@gagdiez gagdiez added S-voting/needs-wg-voting-indication A NEP in the VOTING stage that needs the working group voting indication. and removed S-review/needs-sme-review A NEP in the REVIEW stage is waiting for Subject Matter Expert review. labels Feb 26, 2026
@darioush

Copy link
Copy Markdown
Contributor

@gagdiez Thanks for setting up the scheduling. I would be happy to present a few slides.

@gagdiez

gagdiez commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

As the moderator, I would like to thank @robin-near for submitting this NEP-Category, and for the @near/wg-protocol working group members for your review. We are scheduling a Protocol Working group meeting tomorrow, where this NEP can enter the final voting stage.

Anyone can discuss the technical details by adding your comments to this discussion. And join the call to learn about the final decision and how to get more involved.

cc @jakmeier @walnut-the-cat @darioush @birchmd

Meeting Info
📅 Date: Tuesday, March 3, 6pm UTC
✏️ Register

@gagdiez

gagdiez commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Thank you to everyone who attended the Protocol Working Group meeting! The working group members reviewed the NEP and reached the following consensus:

Status: Approved

Meeting Recording: https://youtu.be/oJgyyT37mxw

@darioush thank you for authoring this NEP!

Next Steps:

  • @darioush To finish tiding up the NEP - if there is anything left to be done
  • @near/nep-moderators To approve and merge the NEP

@gagdiez gagdiez added S-approved A NEP that was approved by a working group. and removed S-voting/needs-wg-voting-indication A NEP in the VOTING stage that needs the working group voting indication. labels Mar 5, 2026
@gagdiez gagdiez merged commit 7ea639f into master Apr 7, 2026
2 of 3 checks passed
@gagdiez gagdiez deleted the robin/611 branch April 7, 2026 08:15
@github-project-automation github-project-automation Bot moved this from NEW❗ to Shipped 🚀 in DevRel Apr 7, 2026
@walnut-the-cat walnut-the-cat moved this from REVIEW to APPROVED NEPs in NEPs May 5, 2026
pull Bot pushed a commit to See887777/nearcore that referenced this pull request Jun 3, 2026
# Gas Keys ([NEP-611](near/NEPs#611))
Gas keys are a new type of access key that carries a pre-funded NEAR
balance and multiple independent nonce sequences. When a transaction is
signed with a gas key, gas costs are deducted from the gas key's balance
rather than the signer's account balance (deposits like NEAR transfers
still come from the account).

## Why do we need gas keys?
- Enabling SPICE without a DoS vector. The SPICE project (Separation of
Execution from Consensus) decouples transaction execution from block
production: transactions are included in blocks first, and executed
asynchronously later. This means chunk producers can no longer verify
account balances at inclusion time. An attacker could drain an account's
balance in one transaction, then flood the chain with many transactions
signed by that account. All would be accepted (since execution hasn't
caught up), consuming block space for free when they inevitably fail.
Gas keys close this gap by requiring gas to be pre-committed in the key
itself, so chunk producers can verify gas availability without access to
the latest state.

- Parallel transaction submission. Today, programmatic users who submit
many transactions in parallel must manage multiple access keys (each
with its own nonce sequence). A gas key supports up to 1,024 independent
nonce slots via a single key, removing that complexity.

# Context

- NEP (if exists): near/NEPs#611
- Implementation: 
 - near#14868
 - near#14869
 - near#14883
 - near#14891
 - near#14892
 - near#14911
 - near#14924
 - near#14925
 - near#14930
 - near#14933
 - near#14969
 - near#14985
 - near#15033
 - near#15034
 - near#15067
 - near#15068
 - near#15100
 - near#15101
 - near#15186

# Testing and QA
- unit tests
- test-loop:
https://github.com/near/nearcore/blob/master/test-loop-tests/src/tests/gas_keys.rs
- forknet (automated): near#15207
- forknet (manual testing, planned)

# Checklist
- [x] Link to nightly nayduck run:
https://nayduck.nearone.org/#/run/4756
- [x] Update CHANGELOG.md to include this protocol feature in the
`Unreleased` section.
darioush added a commit to near/nearcore that referenced this pull request Jun 22, 2026
Adds a 2.13.0 changelog entry for the new `DelegateV2` meta-transaction
action (`ProtocolFeature::DelegateV2`, protocol version 85), which lets
gas keys ([NEP-611](near/NEPs#611)) sign relayed
meta transactions.
([#15904](#15904),
[#15905](#15905),
[#15906](#15906))

Sorry I forgot this as part of the feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-approved A NEP that was approved by a working group. WG-protocol Protocol Standards Work Group should be accountable

Projects

Status: Shipped 🚀
Status: APPROVED NEPs

Development

Successfully merging this pull request may close these issues.