Skip to content

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

Merged
akmysti merged 1 commit intoMystenLabs:bella-ciaofrom
akmysti:gas_test
Mar 3, 2026
Merged

Add gas validation fuzz and edge-case tests for dry-run and dev-inspect#25541
akmysti merged 1 commit intoMystenLabs:bella-ciaofrom
akmysti:gas_test

Conversation

@akmysti
Copy link
Copy Markdown
Collaborator

@akmysti akmysti commented Feb 19, 2026

Description

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

Test plan

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

Proptest Fuzz Tests (5 total)

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.

Deterministic Edge Case Tests (6 total)

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"

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:

@akmysti akmysti temporarily deployed to sui-typescript-aws-kms-test-env February 19, 2026 20:59 — with GitHub Actions Inactive
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 19, 2026

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

Project Deployment Actions Updated (UTC)
sui-docs Ready Ready Preview, Comment Feb 19, 2026 9:03pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multisig-toolkit Ignored Ignored Preview Feb 19, 2026 9:03pm
sui-kiosk Ignored Ignored Preview Feb 19, 2026 9:03pm

Request Review

@akmysti akmysti changed the title Gas testing Add gas validation fuzz and edge-case tests for dry-run and dev-inspect Feb 19, 2026
Copy link
Copy Markdown
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

This looks good to me. A couple suggestions for future testing directions, but nothing needed for this PR. @dariorussi wants to take another look over as well though too.

.map(|_| ())
}

pub fn dev_inspect_transaction(
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.

This is great. Could you also add a similar method for calling into simulate_transaction as well (https://github.com/MystenLabs/sui/blob/main/crates/sui-core/src/authority.rs#L2390).

Not needed for this PR, but would be good to have in a followup PR.

.map(|o| match o {
Owner::ObjectOwner(_) | Owner::AddressOwner(_) if owned_by_sender => {
.map(|o| {
if force_all_sender_owned {
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.

Not for this PR (but for a followup PR): we should add the ability to generate transactions with address balance gas payments as well.

let kind = make_transfer_sui_pt();
let tx_data = TransactionData::new_with_gas_data(kind, sender, gas_data);

let result = executor.dry_run_transaction(tx_data);
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.

Question: Is this test purely testing for panic freedom? Or should we be doing something with the result here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, for fuzz testing this is what I had in mind. The results may or maynot be valid as long as we dont panic somewhere in between.

let kind = make_transfer_sui_pt();
let gas_refs: Vec<ObjectRef> = gas_data.payment.clone();

let result = executor.dev_inspect_transaction(
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.

Similar question here.

/// Valid gas data succeeds in all execution modes.
#[test]
#[cfg_attr(msim, ignore)]
fn test_valid_gas_data_all_modes() {
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.

Not needed for this PR, but extending these to be proptests, and using prop_oneof! to make sure the specific edge cases are covered would be great.

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.

this is looking good. I took another look after looking at that with Tim and no issue.
We can clean this up and get it in and do the other work that was described in the comment (simulate_transaction and account balance)

@akmysti akmysti merged commit fb106f9 into MystenLabs:bella-ciao Mar 3, 2026
56 of 60 checks passed
@akmysti akmysti deleted the gas_test branch March 3, 2026 18:16
tzakian pushed a commit that referenced this pull request Mar 3, 2026
…ev-inspect" (#25688)

Reverts #25541 will put in on main as per Dario.
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