Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@ jobs:
run: cargo run --locked --release -p forc -- build --release --locked --path ./test/src/sdk-harness --experimental str_array_no_padding --output-directory ./test/src/sdk-harness/out
- name: Run All SDK Tests - ['str_array_no_padding' enabled] (Release)
run: cargo test --locked --release --manifest-path ./test/src/sdk-harness/Cargo.toml -- --nocapture
- name: Build All Test Projects - ['aligned_and_dynamic_storage' enabled] (Debug)
run: cargo run --locked --release -p forc -- build --locked --path ./test/src/sdk-harness --experimental aligned_and_dynamic_storage --output-directory ./test/src/sdk-harness/out
- name: Run All SDK Tests - ['aligned_and_dynamic_storage' enabled] (Debug)
run: cargo test --locked --release --manifest-path ./test/src/sdk-harness/Cargo.toml -- --skip can_get_predicate_address --nocapture
- name: Build All Test Projects - ['aligned_and_dynamic_storage' enabled] (Release)
run: cargo run --locked --release -p forc -- build --release --locked --path ./test/src/sdk-harness --experimental aligned_and_dynamic_storage --output-directory ./test/src/sdk-harness/out
- name: Run All SDK Tests - ['aligned_and_dynamic_storage' enabled] (Release)
run: cargo test --locked --release --manifest-path ./test/src/sdk-harness/Cargo.toml -- --nocapture

forc-run-benchmarks:
runs-on: warp-ubuntu-latest-x64-4x
Expand Down Expand Up @@ -546,6 +554,10 @@ jobs:
run: forc test --path sway-lib-std --experimental str_array_no_padding
- name: Run Std Unit Tests - ['str_array_no_padding' enabled] (Release)
run: forc test --release --path sway-lib-std --experimental str_array_no_padding
- name: Run Std Unit Tests - ['aligned_and_dynamic_storage' enabled] (Debug)
run: forc test --path sway-lib-std --experimental aligned_and_dynamic_storage
- name: Run Std Unit Tests - ['aligned_and_dynamic_storage' enabled] (Release)
run: forc test --release --path sway-lib-std --experimental aligned_and_dynamic_storage
- name: Run In Language Unit Tests (Debug)
run: forc test --error-on-warnings --path test/src/in_language_tests
- name: Run In Language Unit Tests (Release)
Expand All @@ -558,6 +570,10 @@ jobs:
run: forc test --error-on-warnings --path test/src/in_language_tests --experimental str_array_no_padding
- name: Run In Language Unit Tests - ['str_array_no_padding' enabled] (Release)
run: forc test --error-on-warnings --release --path test/src/in_language_tests --experimental str_array_no_padding
- name: Run In Language Unit Tests - ['aligned_and_dynamic_storage' enabled] (Debug)
run: forc test --error-on-warnings --path test/src/in_language_tests --experimental aligned_and_dynamic_storage
- name: Run In Language Unit Tests - ['aligned_and_dynamic_storage' enabled] (Release)
run: forc test --error-on-warnings --release --path test/src/in_language_tests --experimental aligned_and_dynamic_storage

forc-pkg-fuels-deps-check:
runs-on: ubuntu-latest
Expand Down
58 changes: 20 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ fuel-core-storage = { version = "0.47", default-features = false }
fuel-core-types = { version = "0.47", default-features = false }

# Dependencies from the `fuels-rs` repository:

fuels = "0.76"
fuels-core = "0.76"
fuels-accounts = "0.76"
Expand Down Expand Up @@ -244,3 +243,18 @@ 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" }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Git branch patches in Cargo.toml must not be merged

High Severity

The [patch.crates-io] section pins dependencies to unreleased git branches (fuel-core on dento/dynamic-storage, fuels-rs on ironcev/clonable-isuseraccountvariables, fuel-vm on main). If merged, the main branch would depend on development branches in external repos that could be force-pushed, deleted, or contain unstable code, breaking reproducible builds and potentially introducing regressions.

Fix in Cursor Fix in Web

14 changes: 13 additions & 1 deletion docs/book/src/reference/compiler_intrinsics.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,26 @@ __addr_of<T>(val: T) -> raw_ptr

---

**Without `aligned_and_dynamic_storage` experimental feature enabled**

```sway
__state_load_word(key: b256) -> u64
```

**Description:** Reads and returns a single word from storage at key `key`.
**Description:** Reads and returns a single word from storage at key `key`. If the storage slot at key `key` is not set, zero is returned.

**Constraints:** None.

**With `aligned_and_dynamic_storage` experimental feature enabled**

```sway
__state_load_word(key: b256, offset: u64) -> u64
```

**Description:** Reads and returns a single word from storage at key `key` and offset `offset`. If the storage slot at key `key` is not set, zero is returned.

**Constraints:** `offset` must be a valid word offset inside of the storage slot boundaries. E.g., if the storage slot contains four words, the lowest offset is zero, and the highest is three.

---

```sway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ fn imm(instruction: Instruction) -> Option<String> {
Instruction::WQML(op) => imm06_to_string(op.imm06()),
Instruction::WDDV(op) => imm06_to_string(op.imm06()),
Instruction::WQDV(op) => imm06_to_string(op.imm06()),
Instruction::SRW(op) => imm06_to_string(op.imm06()),
_ => None,
}
}
2 changes: 1 addition & 1 deletion sway-ast/src/expr/op_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ define_op_codes!(
Srw,
SrwOpcode,
"srw",
(ret: reg, is_set: reg, state_addr: reg)
(ret: reg, is_set: reg, state_addr: reg, offset: imm)
),
(
Srwq,
Expand Down
9 changes: 9 additions & 0 deletions sway-core/src/asm_generation/finalized_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ fn print_instruction(op: &Instruction) {
Instruction::SRWQ(x) => f("SRWQ", x.unpack()),
Instruction::SWW(x) => f("SWW", x.unpack()),
Instruction::SWWQ(x) => f("SWWQ", x.unpack()),
Instruction::SCLR(x) => f("SCLR", x.unpack()),
Instruction::SRDD(x) => f("SRDD", x.unpack()),
Instruction::SRDI(x) => f("SRDI", x.unpack()),
Instruction::SWRD(x) => f("SWRD", x.unpack()),
Instruction::SWRI(x) => f("SWRI", x.unpack()),
Instruction::SUPD(x) => f("SUPD", x.unpack()),
Instruction::SUPI(x) => f("SUPI", x.unpack()),
Instruction::SPLD(x) => f("SPLD", x.unpack()),
Instruction::SPCP(x) => f("SPCP", x.unpack()),
Instruction::TR(x) => f("TR", x.unpack()),
Instruction::TRO(x) => f("TRO", x.unpack()),
Instruction::ECK1(x) => f("ECK1", x.unpack()),
Expand Down
23 changes: 9 additions & 14 deletions sway-core/src/asm_generation/fuel/fuel_asm_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> {
number_of_slots,
StateAccessType::Read,
),
FuelVmInstruction::StateLoadWord(key) => {
self.compile_state_load_word(instr_val, key)
FuelVmInstruction::StateLoadWord { key, offset } => {
self.compile_state_load_word(instr_val, key, offset)
}
FuelVmInstruction::StateStoreQuadWord {
stored_val,
Expand Down Expand Up @@ -2191,26 +2191,21 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> {
&mut self,
instr_val: &Value,
key: &Value,
offset: &u64,
) -> Result<(), CompileError> {
let owning_span = self.md_mgr.val_to_span(self.context, *instr_val);

// XXX not required after we have FuelVM specific verifier.
if !key
.get_type(self.context)
.is_none_or(|key_ty| key_ty.is_ptr(self.context))
{
return Err(CompileError::Internal(
"Key value for state load word is not a pointer.",
owning_span.unwrap_or_else(Span::dummy),
));
}

let key_reg = self.value_to_register(key)?;
let was_slot_set_reg = self.reg_seqr.next();
let load_reg = self.reg_seqr.next();

self.cur_bytecode.push(Op {
opcode: Either::Left(VirtualOp::SRW(load_reg.clone(), was_slot_set_reg, key_reg)),
opcode: Either::Left(VirtualOp::SRW(
load_reg.clone(),
was_slot_set_reg,
key_reg,
VirtualImmediate06::new(*offset),
)),
comment: "read single word from contract state".into(),
owning_span,
});
Expand Down
Loading
Loading