Skip to content

Add dynamic_storage experimental feature and offset to srw opcode#7565

Merged
ironcev merged 23 commits into
masterfrom
ironcev/dynamic-storage-srw
Apr 9, 2026
Merged

Add dynamic_storage experimental feature and offset to srw opcode#7565
ironcev merged 23 commits into
masterfrom
ironcev/dynamic-storage-srw

Conversation

@ironcev

@ironcev ironcev commented Feb 25, 2026

Copy link
Copy Markdown
Member

Description

This PR is the first step in implementing #7560.

The PR:

  • bumps fuel-vm dependencies to v0.66.
  • bumps fuel-core dependencies to v0.48.
  • bumps fuels-rs dependencies to v0.77.
  • adds the dynamic_storage experimental feature.
  • extends the srw opcode with an immediate offset.
  • extends the __state_load_word intrinsic with the offset.
  • extends the state_load_word IR operation with the offset.
  • updates gas_costs_values.json to use the latest V7 gas costs defined in fuel-core repository chainspec/local-testnet/chain_config.json

Additionally, the PR:

Breaking changes

Defining opcodes via the define_op_codes macros does not allow for customization based on feature flags. Also, opcodes are modeled as enums in code generation. Changing the whole mechanics of opcode definition just to support two different srw opcodes does not pay off, especially because we do not expect srw to be used in real-life code.

Thus, supporting only srw res is_set slot imm6 will be a breaking change not hidden behind a feature flag.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@ironcev ironcev self-assigned this Feb 25, 2026
@cursor

cursor Bot commented Feb 25, 2026

Copy link
Copy Markdown

PR Summary

High Risk
High risk because it changes core storage read semantics/ABI (srw now requires an immediate offset) and bumps multiple Fuel VM/core dependencies, which can impact codegen, gas accounting, and runtime behavior across the toolchain.

Overview
Adds a new experimental feature flag, dynamic_storage, and wires it through CI and tests to run the suite with the feature enabled.

Introduces an offset immediate to the srw opcode and propagates it through parsing/AST/ASM codegen, IR (state_load_word now carries { key, offset }), verification (enforcing imm size limits), and debug/printing paths; __state_load_word gains a second offset: u64 argument when dynamic_storage is enabled (defaulting to 0 otherwise).

Updates dependency versions (notably fuel-vm 0.66, fuel-core 0.48, fuels 0.77) and refreshes forc-test/gas_costs_values.json to the new V7 schedule; adds a dedicated CompileError::IntrinsicArgNotConstant and adjusts snapshots/new tests for the new opcode/intrinsic signatures.

Reviewed by Cursor Bugbot for commit e3c9bf0. Bugbot is set up for automated code reviews on this repo. Configure here.

@ironcev ironcev added compiler General compiler. Should eventually become more specific as the issue is triaged compiler: ir IRgen and sway-ir including optimization passes compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser compiler: codegen Everything to do with IR->ASM, register allocation, etc. compiler: ui Mostly compiler messages breaking May cause existing user code to break. Requires a minor or major release. labels Feb 25, 2026
@ironcev

ironcev commented Feb 25, 2026

Copy link
Copy Markdown
Member Author

👍

Comment thread sway-ir/src/optimize/fn_dedup.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Feb 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 25 untouched benchmarks


Comparing ironcev/dynamic-storage-srw (e3c9bf0) with master (076d438)

Open in CodSpeed

@ironcev ironcev temporarily deployed to fuel-sway-bot March 6, 2026 05:37 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Git branch patches in Cargo.toml must not be merged
    • Removed the accidental [patch.crates-io] git-branch overrides from Cargo.toml so dependencies resolve from published crates.io versions again.

Create PR

Or push these changes by commenting:

@cursor push 4fbc4cdd14
Preview (4fbc4cdd14)
diff --git a/Cargo.toml b/Cargo.toml
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -242,19 +242,4 @@
 vte = "0.13"
 walkdir = "2.3"
 whoami = "1.5"
-wiremock = "0.6"
-
-[patch.crates-io]
-fuel-core-client = { git = "https://github.com/FuelLabs/fuel-core", branch = "dento/dynamic-storage" }
-fuel-core-storage = { git = "https://github.com/FuelLabs/fuel-core", branch = "dento/dynamic-storage" }
-fuel-core-types = { git = "https://github.com/FuelLabs/fuel-core", branch = "dento/dynamic-storage" }
-
-fuel-asm = { git = "https://github.com/FuelLabs/fuel-vm" }
-fuel-crypto = { git = "https://github.com/FuelLabs/fuel-vm" }
-fuel-types = { git = "https://github.com/FuelLabs/fuel-vm" }
-fuel-tx = { git = "https://github.com/FuelLabs/fuel-vm" }
-fuel-vm = { git = "https://github.com/FuelLabs/fuel-vm" }
-
-fuels = { git = "https://github.com/FuelLabs/fuels-rs", branch = "ironcev/clonable-isuseraccountvariables" }
-fuels-core = { git = "https://github.com/FuelLabs/fuels-rs", branch = "ironcev/clonable-isuseraccountvariables" }
-fuels-accounts = { git = "https://github.com/FuelLabs/fuels-rs", branch = "ironcev/clonable-isuseraccountvariables" }
\ No newline at end of file
+wiremock = "0.6"
\ No newline at end of file
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread Cargo.toml Outdated
@ironcev ironcev temporarily deployed to fuel-sway-bot March 8, 2026 08:05 — with GitHub Actions Inactive
@ironcev ironcev temporarily deployed to fuel-sway-bot March 9, 2026 08:03 — with GitHub Actions Inactive
@ironcev ironcev temporarily deployed to fuel-sway-bot April 8, 2026 10:40 — with GitHub Actions Inactive
@ironcev ironcev temporarily deployed to fuel-sway-bot April 8, 2026 10:56 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f9afd39. Configure here.

@ironcev ironcev changed the title Add aligned_and_dynamic_storage feature and imm6 arg to srw opcode Add dynamic_storage experimental feature and offset to srw opcode Apr 9, 2026
@ironcev ironcev temporarily deployed to fuel-sway-bot April 9, 2026 13:15 — with GitHub Actions Inactive
@ironcev ironcev temporarily deployed to fuel-sway-bot April 9, 2026 13:41 — with GitHub Actions Inactive
@ironcev ironcev temporarily deployed to fuel-sway-bot April 9, 2026 13:45 — with GitHub Actions Inactive
@ironcev ironcev marked this pull request as ready for review April 9, 2026 14:25
@ironcev ironcev requested review from a team as code owners April 9, 2026 14:25
@ironcev ironcev enabled auto-merge (squash) April 9, 2026 14:25
@ironcev ironcev requested review from Dentosal April 9, 2026 14:26
@ironcev ironcev merged commit a8780a5 into master Apr 9, 2026
47 checks passed
@ironcev ironcev deleted the ironcev/dynamic-storage-srw branch April 9, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking May cause existing user code to break. Requires a minor or major release. compiler: codegen Everything to do with IR->ASM, register allocation, etc. compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: ir IRgen and sway-ir including optimization passes compiler: parser Everything to do with the parser compiler: ui Mostly compiler messages compiler General compiler. Should eventually become more specific as the issue is triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing error message when using non-const tx_field_id in __gtf

2 participants