Skip to content

feat(iota-core): add unit tests for the gas price feedback mechanism #7906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

roman1e2f5p8s
Copy link
Contributor

@roman1e2f5p8s roman1e2f5p8s commented Jul 21, 2025

Description of change

  • This PR adds unit tests to test the gas price feedback mechanism. The aim is to test all the components: the mechanism itself, calculations of suggested gas price and its propagation across multiple commits.
  • Instead of panic, the calculator will now suggest reference gas price (or max clearing gas price) if transaction duration exceeds max_execution_duration_per_commit.
  • Renamed congested_objects_gas_price_feedback_mechanism feature flag to congestion_control_gas_price_feedback_mechanism.

Links to any relevant issues

How the change has been tested

cargo simtest -p iota-core unit_tests gas_price_feedback_tests
  • Basic tests (linting, compilation, formatting, unit/integration tests)
  • Patch-specific tests (correctness, functionality coverage)
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

Release Notes

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Jul 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
iota-evm-bridge ❌ Failed (Inspect) Jul 25, 2025 3:08pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
apps-backend ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 3:08pm
apps-ui-kit ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 3:08pm
iota-multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 3:08pm
rebased-explorer ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 3:08pm
wallet-dashboard ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 3:08pm

@roman1e2f5p8s roman1e2f5p8s marked this pull request as ready for review July 21, 2025 13:21
@roman1e2f5p8s roman1e2f5p8s requested review from a team as code owners July 21, 2025 13:21
@roman1e2f5p8s roman1e2f5p8s marked this pull request as draft July 21, 2025 17:03
@roman1e2f5p8s roman1e2f5p8s marked this pull request as draft July 23, 2025 13:54
@roman1e2f5p8s roman1e2f5p8s changed the title feat(iota-core): add unit tests for the for gas price feedback mechanism feat(iota-core): add unit tests for the gas price feedback mechanism Jul 23, 2025
Copy link
Member

@thibault-martinez thibault-martinez left a comment

Choose a reason for hiding this comment

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

Approving dev-tools

Copy link
Contributor

@TheMrAI TheMrAI left a comment

Choose a reason for hiding this comment

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

vm-lang parst lgtm

Copy link
Contributor

@cyberphysic4l cyberphysic4l left a comment

Choose a reason for hiding this comment

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

Tests look good, just have one concern about the fact that the suggestion calculation can panic in the case that gas budget of a transaction exceeds the max_execution_duration_per_commit.

// one transaction cannot fit in a commit.
#[tokio::test]
#[should_panic] // because `max_execution_duration_per_commit` is set too low.
async fn max_execution_duration_per_commit_too_low_in_total_gas_budget_mode() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a fair test case, but do we actually have any safe guards against a certain transaction having gas budget greater than max_execution_duration_per_commit? It seems possible that it could happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for looking at the tests. No, it seems we do not have any safeguards against a certain transaction having gas budget greater than max_execution_duration_per_commit. Looking at the numbers in Sui for TotalGasBudgetWithCap mode, max_accumulated_txn_cost_per_object_in_mysticeti_commit was set 37_000_000, while max gas budget was 50K SUI, so seems it would be possible to send a transaction that would never fit. In IOTA, max gas budget is currently set to 50 IOTA, but we never has TotalGasBudget mode enabled. I think it would be just safer to return the maximum gas price there instead of panic, I will change that part. Thanks for spotting this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, @cyberphysic4l! I changed the logic for txs with durations exceeding max_execution_duration_per_commit.

@roman1e2f5p8s roman1e2f5p8s merged commit 402f3f2 into protocol-research/feat/gas-price-feedback Jul 28, 2025
36 of 39 checks passed
@roman1e2f5p8s roman1e2f5p8s deleted the protocol-research/feat/add-gas-price-feedback-unit-tests branch July 28, 2025 09:33
roman1e2f5p8s added a commit that referenced this pull request Jul 28, 2025
…7906)

- This PR adds unit tests to test the gas price feedback mechanism. The
aim is to test all the components: the mechanism itself, calculations of
suggested gas price and its propagation across multiple commits.
- Instead of panic, the calculator will now suggest reference gas price
(or max clearing gas price) if transaction duration exceeds
`max_execution_duration_per_commit`.
- Renamed `congested_objects_gas_price_feedback_mechanism` feature flag
to `congestion_control_gas_price_feedback_mechanism`.

```console
cargo simtest -p iota-core unit_tests gas_price_feedback_tests
```

- [x] Basic tests (linting, compilation, formatting, unit/integration
tests)
- [x] Patch-specific tests (correctness, functionality coverage)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have checked that new and existing unit tests pass locally with
my changes

- [ ] Protocol:
- [ ] Nodes (Validators and Full nodes):
- [ ] Indexer:
- [ ] JSON-RPC:
- [ ] GraphQL:
- [ ] CLI:
- [ ] Rust SDK:
- [ ] REST API:
roman1e2f5p8s added a commit that referenced this pull request Jul 28, 2025
…7906)

- This PR adds unit tests to test the gas price feedback mechanism. The
aim is to test all the components: the mechanism itself, calculations of
suggested gas price and its propagation across multiple commits.
- Instead of panic, the calculator will now suggest reference gas price
(or max clearing gas price) if transaction duration exceeds
`max_execution_duration_per_commit`.
- Renamed `congested_objects_gas_price_feedback_mechanism` feature flag
to `congestion_control_gas_price_feedback_mechanism`.

```console
cargo simtest -p iota-core unit_tests gas_price_feedback_tests
```

- [x] Basic tests (linting, compilation, formatting, unit/integration
tests)
- [x] Patch-specific tests (correctness, functionality coverage)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have checked that new and existing unit tests pass locally with
my changes

- [ ] Protocol:
- [ ] Nodes (Validators and Full nodes):
- [ ] Indexer:
- [ ] JSON-RPC:
- [ ] GraphQL:
- [ ] CLI:
- [ ] Rust SDK:
- [ ] REST API:
roman1e2f5p8s added a commit that referenced this pull request Jul 28, 2025
…7906)

- This PR adds unit tests to test the gas price feedback mechanism. The
aim is to test all the components: the mechanism itself, calculations of
suggested gas price and its propagation across multiple commits.
- Instead of panic, the calculator will now suggest reference gas price
(or max clearing gas price) if transaction duration exceeds
`max_execution_duration_per_commit`.
- Renamed `congested_objects_gas_price_feedback_mechanism` feature flag
to `congestion_control_gas_price_feedback_mechanism`.

```console
cargo simtest -p iota-core unit_tests gas_price_feedback_tests
```

- [x] Basic tests (linting, compilation, formatting, unit/integration
tests)
- [x] Patch-specific tests (correctness, functionality coverage)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have checked that new and existing unit tests pass locally with
my changes

- [ ] Protocol:
- [ ] Nodes (Validators and Full nodes):
- [ ] Indexer:
- [ ] JSON-RPC:
- [ ] GraphQL:
- [ ] CLI:
- [ ] Rust SDK:
- [ ] REST API:

Signed-off-by: Roman Overko <roman.overko@iota.org>
roman1e2f5p8s added a commit that referenced this pull request Jul 28, 2025
…7906)

- This PR adds unit tests to test the gas price feedback mechanism. The
aim is to test all the components: the mechanism itself, calculations of
suggested gas price and its propagation across multiple commits.
- Instead of panic, the calculator will now suggest reference gas price
(or max clearing gas price) if transaction duration exceeds
`max_execution_duration_per_commit`.
- Renamed `congested_objects_gas_price_feedback_mechanism` feature flag
to `congestion_control_gas_price_feedback_mechanism`.

```console
cargo simtest -p iota-core unit_tests gas_price_feedback_tests
```

- [x] Basic tests (linting, compilation, formatting, unit/integration
tests)
- [x] Patch-specific tests (correctness, functionality coverage)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have checked that new and existing unit tests pass locally with
my changes

- [ ] Protocol:
- [ ] Nodes (Validators and Full nodes):
- [ ] Indexer:
- [ ] JSON-RPC:
- [ ] GraphQL:
- [ ] CLI:
- [ ] Rust SDK:
- [ ] REST API:

Signed-off-by: Roman Overko <roman.overko@iota.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants