Skip to content

Add gas validation fuzz and edge-case tests for dry-run and dev-inspect#25692

Merged
akmysti merged 2 commits intoMystenLabs:mainfrom
akmysti:gas_test_main
Mar 6, 2026
Merged

Add gas validation fuzz and edge-case tests for dry-run and dev-inspect#25692
akmysti merged 2 commits intoMystenLabs:mainfrom
akmysti:gas_test_main

Conversation

@akmysti
Copy link
Copy Markdown
Collaborator

@akmysti akmysti commented Mar 3, 2026

Extend the transaction-fuzzer crate to test gas data handling across all four execution modes: normal (validator), dry-run (fullnode), dev-inspect with skip_checks=true, and dev-inspect with skip_checks=false. This exercises the gas validation paths fixed in #25361 where (1) gas price was accessed unchecked causing panics and (2) non-gas-coin objects as gas in dev-inspect caused crashes.

Changes to executor.rs:

  • Add new_fullnode() constructor that uses a keypair not in the committee, enabling dry-run and dev-inspect APIs
  • Add dry_run_transaction() wrapping AuthorityState::dry_exec_transaction
  • Add dev_inspect_transaction() wrapping AuthorityState::dev_inspect_transaction_block

Changes to lib.rs:

  • Add GasDataGenConfig::sender_owned_only() which forces all gas coins to AddressOwner(sender), needed for dev-inspect with skip_checks=true where ownership validation is bypassed and non-sender-owned gas objects would panic during execution
  • Add run_proptest_with_fullnode() helper and refactor existing run_proptest() to share logic via run_proptest_with_executor()

Changes to gas_data_tests.rs:

  • Add 3 new proptest fuzz tests: dry-run, dev-inspect with skip_checks, and dev-inspect without skip_checks
  • Add 6 deterministic edge-case tests covering: valid gas data, gas_price=0, gas_price < RGP, gas_budget=0, gas_budget > max, and insufficient balance — each verified across all four execution modes
  • Add helpers for constructing gas coins, gas data, and running all modes in a single test

The gas tests cover 4 execution modes across 2 testing strategies:

Randomly generate gas data (price, budget, balance, number of gas objects, ownership) and verify no panics across execution modes:

  • test_gas_data_owned_or_immut: sender-owned or immutable gas, normal execution
  • test_gas_data_any_owner: any owner type, normal execution
  • test_gas_data_dry_run_fuzz: sender-owned or immutable gas, dry-run
  • test_gas_data_dev_inspect_skip_checks_fuzz: sender-owned only, dev-inspect (skip_checks=true)
  • test_gas_data_dev_inspect_no_skip_fuzz: sender-owned or immutable gas, dev-inspect (skip_checks=false)

The skip_checks fuzz uses sender_owned_only() because when ownership validation is bypassed, immutable/shared gas objects panic in temporary_store.rs when the system tries to modify them.

Each test runs through all 4 modes (normal, dry-run, dev-inspect with and without skip_checks) and asserts the expected error:

  • test_valid_gas_data_all_modes: valid price/budget/balance, all modes succeed
  • test_gas_price_zero: gas_price=0, expects "Gas price 0 under min"
  • test_gas_price_below_rgp: gas_price=rgp-1, expects "Gas price ... under min"
  • test_gas_budget_zero: gas_budget=0, expects "Gas budget 0 is below min"
  • test_gas_budget_exceeds_max: gas_budget > max_tx_gas, expects "Gas budget ... is above max"
  • test_gas_balance_insufficient: balance=1, expects "balance of ... is lower than the needed"

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • Indexing Framework:

Description

Describe the changes or additions included in this PR.

Test plan

How did you test the new or updated feature?


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • Indexing Framework:

Extend the transaction-fuzzer crate to test gas data handling across all
four execution modes: normal (validator), dry-run (fullnode), dev-inspect
with skip_checks=true, and dev-inspect with skip_checks=false. This
exercises the gas validation paths fixed in MystenLabs#25361 where (1) gas price
was accessed unchecked causing panics and (2) non-gas-coin objects as
gas in dev-inspect caused crashes.

Changes to executor.rs:
- Add `new_fullnode()` constructor that uses a keypair not in the
  committee, enabling dry-run and dev-inspect APIs
- Add `dry_run_transaction()` wrapping `AuthorityState::dry_exec_transaction`
- Add `dev_inspect_transaction()` wrapping
  `AuthorityState::dev_inspect_transaction_block`

Changes to lib.rs:
- Add `GasDataGenConfig::sender_owned_only()` which forces all gas coins
  to `AddressOwner(sender)`, needed for dev-inspect with skip_checks=true
  where ownership validation is bypassed and non-sender-owned gas objects
  would panic during execution
- Add `run_proptest_with_fullnode()` helper and refactor existing
  `run_proptest()` to share logic via `run_proptest_with_executor()`

Changes to gas_data_tests.rs:
- Add 3 new proptest fuzz tests: dry-run, dev-inspect with skip_checks,
  and dev-inspect without skip_checks
- Add 6 deterministic edge-case tests covering: valid gas data,
  gas_price=0, gas_price < RGP, gas_budget=0, gas_budget > max, and
  insufficient balance — each verified across all four execution modes
- Add helpers for constructing gas coins, gas data, and running all
  modes in a single test

The gas tests cover 4 execution modes across 2 testing strategies:

Randomly generate gas data (price, budget, balance, number of gas
objects, ownership) and verify no panics across execution modes:

- `test_gas_data_owned_or_immut`: sender-owned or immutable gas, normal execution
- `test_gas_data_any_owner`: any owner type, normal execution
- `test_gas_data_dry_run_fuzz`: sender-owned or immutable gas, dry-run
- `test_gas_data_dev_inspect_skip_checks_fuzz`: sender-owned only, dev-inspect (skip_checks=true)
- `test_gas_data_dev_inspect_no_skip_fuzz`: sender-owned or immutable gas, dev-inspect (skip_checks=false)

The skip_checks fuzz uses `sender_owned_only()` because when ownership
validation is bypassed, immutable/shared gas objects panic in
`temporary_store.rs` when the system tries to modify them.

Each test runs through all 4 modes (normal, dry-run, dev-inspect with
and without skip_checks) and asserts the expected error:

- `test_valid_gas_data_all_modes`: valid price/budget/balance, all modes succeed
- `test_gas_price_zero`: gas_price=0, expects "Gas price 0 under min"
- `test_gas_price_below_rgp`: gas_price=rgp-1, expects "Gas price ... under min"
- `test_gas_budget_zero`: gas_budget=0, expects "Gas budget 0 is below min"
- `test_gas_budget_exceeds_max`: gas_budget > max_tx_gas, expects "Gas budget ... is above max"
- `test_gas_balance_insufficient`: balance=1, expects "balance of ... is lower than the needed"

---

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

- [ ] Protocol:
- [ ] Nodes (Validators and Full nodes):
- [ ] gRPC:
- [ ] JSON-RPC:
- [ ] GraphQL:
- [ ] CLI:
- [ ] Rust SDK:
- [ ] Indexing Framework:
@akmysti akmysti temporarily deployed to sui-typescript-aws-kms-test-env March 3, 2026 23:27 — with GitHub Actions Inactive
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sui-docs Ready Ready Preview, Comment Mar 4, 2026 11:42pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multisig-toolkit Ignored Ignored Preview Mar 4, 2026 11:42pm
sui-kiosk Ignored Ignored Preview Mar 4, 2026 11:42pm

Request Review

@akmysti akmysti requested review from dariorussi and tzakian March 3, 2026 23:28
Copy link
Copy Markdown
Contributor

@dariorussi dariorussi left a comment

Choose a reason for hiding this comment

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

thanks! let's fix the formatting issue and it should be good to go

@akmysti akmysti temporarily deployed to sui-typescript-aws-kms-test-env March 4, 2026 23:40 — with GitHub Actions Inactive
@akmysti akmysti merged commit 03a8010 into MystenLabs:main Mar 6, 2026
55 checks passed
@akmysti akmysti deleted the gas_test_main branch March 6, 2026 21:26
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.

2 participants