test(mirror): add gas key test case to offline mirror test#15207
Conversation
818657f to
2d0b0d8
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #15207 +/- ##
==========================================
- Coverage 69.86% 69.83% -0.03%
==========================================
Files 944 945 +1
Lines 201933 202848 +915
Branches 201933 202848 +915
==========================================
+ Hits 141082 141661 +579
- Misses 56101 56422 +321
- Partials 4750 4765 +15
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:
|
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive test coverage for gas key functionality to the mirror offline test suite. Gas keys are a new access key type that allows for V1 transactions with multiple nonce indexes per key. The changes add support for serializing gas key-related transactions and actions, as well as RPC query helpers for gas key state.
Changes:
- Added
GasKeyTestto validate gas key operations (add, fund, withdraw) and V1 transaction replay across fork boundaries - Implemented Borsh schema definitions for gas key types including
GasKeyInfo,GasKeyFullAccessPermission,TransactionV1, andTransactionNonce - Added transaction helper functions for gas key operations and V1 transaction signing with nonce indexes
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pytest/tools/mirror/offline_test.py | Adds GasKeyTest class with comprehensive test coverage for gas key lifecycle and V1 transfers |
| pytest/tools/mirror/mirror_utils.py | Adds helper functions for sending gas key transactions and querying gas key state via RPC |
| pytest/lib/transaction.py | Adds action creators for gas key operations and V1 transaction serialization with gas key nonces |
| pytest/lib/messages/tx.py | Adds Borsh schema entries for TransactionV1, TransactionNonce, GasKeyNonceData, and gas key actions |
| pytest/lib/messages/crypto.py | Adds Borsh schema entries for GasKeyInfo and gas key permission types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ctx.next_nonce(), ctx.bhash) | ||
| return [] | ||
|
|
||
| def on_post_fork_block(self, ctx): |
There was a problem hiding this comment.
nit. I know that this is testing the integration between mirror and gas key transactions, but do you think that we get extra value if we add negative tests to this? Such as invalid transactions.
There was a problem hiding this comment.
I think we can leave negative tests to a future PR.
d21230a to
dcd40f4
Compare
# 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.
ba1da22 to
bae81f0
Compare
mirror: defer txs whose target nonce is unknown instead of dropping them, resolve them by re-querying the live target (robust across restarts), and finish on height_popped >= --stop-height. fork-network: force static shard layout. Adds the fork-network offline test + gas-key pytest borsh schemas.
bae81f0 to
573edf1
Compare
GasKeyTesttooffline_test.pycovering gas key add, fund, withdraw, and V1 transfers across fork boundarytransaction.py