Skip to content

NEP-611: Pending Transaction Queue#611

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

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

Conversation

@robin-near
Copy link
Copy Markdown
Contributor

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

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.

Copy link
Copy Markdown
Contributor

@birchmd birchmd left a comment

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.

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).

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
Copy link
Copy Markdown
Contributor

gagdiez commented Jul 16, 2025

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 10, 2026
This is 3 out of 3 PRs for charging gas keys for failed transactions.
See near/NEPs#611 for details. For reviewer's
reference, all changes together:
#15031

- When a gas key transaction fails because the account can't cover the
deposit, gas is still charged from the gas key balance. This prevents
SPICE spam where an attacker drains their account between submission and
execution to get free transactions.
- Adds `TxVerdict::DepositFailed` variant: the verifier returns this
when gas key balance is sufficient but the account can't cover the
deposit
- Adds `NotEnoughBalanceForDeposit` error variant
- `test_gas_key_tx_deposit_insufficient_charges_gas` (apply-level),
`test_gas_key_tx_deposit_failed_for_{account_balance, storage_stake}`
(verifier-level)
- Will fix protocol schema and openapi.json after review.
github-merge-queue bot pushed a commit to near/nearcore that referenced this pull request Feb 10, 2026
This is 3 out of 3 PRs for charging gas keys for failed transactions.
See near/NEPs#611 for details. For reviewer's
reference, all changes together:
#15031

- When a gas key transaction fails because the account can't cover the
deposit, gas is still charged from the gas key balance. This prevents
SPICE spam where an attacker drains their account between submission and
execution to get free transactions.
- Adds `TxVerdict::DepositFailed` variant: the verifier returns this
when gas key balance is sufficient but the account can't cover the
deposit
- Adds `NotEnoughBalanceForDeposit` error variant
- `test_gas_key_tx_deposit_insufficient_charges_gas` (apply-level),
`test_gas_key_tx_deposit_failed_for_{account_balance, storage_stake}`
(verifier-level)
- Will fix protocol schema and openapi.json after review.
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
Copy link
Copy Markdown
Contributor

gagdiez commented Feb 26, 2026

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
Copy link
Copy Markdown
Contributor

gagdiez commented Mar 2, 2026

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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gagdiez
Copy link
Copy Markdown
Contributor

gagdiez commented Mar 5, 2026

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
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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
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: REVIEW

Development

Successfully merging this pull request may close these issues.