sway/forc
Daniel Frederico Lins Leite 6cc563d763
Some checks are pending
Codspeed Benchmarks / benchmarks (push) Waiting to run
CI / verifications-complete (push) Blocked by required conditions
CI / check-dependency-version-formats (push) Waiting to run
CI / check-forc-manifest-version (push) Waiting to run
CI / get-fuel-core-version (push) Waiting to run
CI / build-sway-lib-std (push) Waiting to run
CI / build-sway-examples (push) Waiting to run
CI / build-reference-examples (push) Waiting to run
CI / forc-fmt-check-sway-lib-std (push) Waiting to run
CI / forc-fmt-check-sway-examples (push) Waiting to run
CI / forc-fmt-check-panic (push) Waiting to run
CI / check-sdk-harness-test-suite-compatibility (push) Waiting to run
CI / build-mdbook (push) Waiting to run
CI / build-forc-doc-sway-lib-std (push) Waiting to run
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
CI / Build and test various forc tools (push) Blocked by required conditions
CI / cargo-unused-deps-check (push) Waiting to run
CI / notify-slack-on-failure (push) Blocked by required conditions
CI / pre-publish-check (push) Waiting to run
CI / publish (push) Blocked by required conditions
CI / build-forc-test-project (push) Waiting to run
CI / cargo-build-workspace (push) Waiting to run
CI / cargo-clippy (push) Waiting to run
CI / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-fmt-check (push) Waiting to run
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / cargo-test-lib-std (push) Waiting to run
CI / forc-run-benchmarks (push) Waiting to run
CI / forc-unit-tests (push) Waiting to run
CI / forc-pkg-fuels-deps-check (push) Waiting to run
github pages / deploy (push) Waiting to run
Trivial fns allowing control if a type is trivially encoded/decoded (#7501)
## Description

Continuation of https://github.com/FuelLabs/sway/pull/7488.

This PR introduces the option for each type to control its own
`is_trivial`.

Primitive data types have direct implementation (only decoding bool is
false, as we need to guarantee its value is zero or one).

Structs, tuples, arrays etc... are trivial if their runtime
representation and "inner types" allow for trivial encoding or decoding.

Enums are more complicated as we need to control that the enum tag is
valid; they are not trivial.

String arrays are not trivially encoded/decoded for backwards
compatibility with "encoding v0" that needs padding in some cases.

Some tests are showing a small regression (6 gas), which comes from the
introduced "if" not being optimised away. I want to solve this in
another PR, where the "if" condition will come from a const, and IR
generation will guarantee that only one branch will ever be emitted.

## Snapshot "echo"

Small QOL of snapshot was introduced with the "echo" command. It just
prints the message directly, wrapping on 80 chars. The idea is to
explain what the snapshot is trying to test.

## Checklist

- [x] I have linked to any relevant issues.
- [x] 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] 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.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Add per-type trivial encode/decode flags and use raw_ptr fast paths in
ABI (encode/decode) with supporting changes to codec, String/Vec, and
tests.
> 
> - **std/codec**:
> - Introduce `AbiEncode::is_encode_trivial` and
`AbiDecode::is_decode_trivial`; add helpers
`is_encode_trivial/is_decode_trivial`.
> - Switch `encode`/`abi_decode` to branch on triviality; add
`decode_from_raw_ptr` and raw-ptr-based `decode_*` helpers.
> - Make `BufferReader` parameter accessors return `raw_ptr`; minor
refactors to use raw ptr copies.
> - Implement triviality for primitives, arrays/tuples (conditional),
`str[strN]` non-trivial, enums non-trivial.
> - **std/string & std/vec**: implement trivial encode/decode markers
(non-trivial) and adapt codec impls.
> - **Tests/fixtures**:
> - Update snapshots (IR/ASM/bytecode/gas), JSON ABI offsets,
contract/predicate IDs, and logging expectations to match new encoding
paths.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
dddd944aba. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-12-17 10:43:44 +11:00
..
src Optionally remove test gas limit in forc test (#7495) 2025-12-02 15:36:41 +13:00
tests Trivial fns allowing control if a type is trivially encoded/decoded (#7501) 2025-12-17 10:43:44 +11:00
Cargo.toml Revert feat: introduce fuel-telemetry macros (#7295) (#7451) 2025-10-09 19:27:37 +11:00
README.md add docs CI, rename docs README to index (#4874) 2023-08-09 10:51:10 -06:00

Forc

Forc stands for Fuel Orchestrator. Forc provides a variety of tools and commands for developers working with the Fuel ecosystem, such as scaffolding a new project, formatting, running scripts, deploying contracts, testing contracts, and more. If you're coming from a Rust background, forc is similar to cargo.

Find out everything you need to know about Forc under its chapter in the Sway book.