mirror of
https://github.com/FuelLabs/sway.git
synced 2025-12-23 10:11:56 +00:00
3580 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0953baa930 | update tests | ||
|
|
362f339efd | update tests | ||
|
|
afac530f9d | update tests | ||
|
|
775a6c09d9 | more trivial types | ||
|
|
3b9044078a | update tests | ||
|
|
a74a88637f | update tests | ||
|
|
aa5cb90a94 | update tests | ||
|
|
7d2a9d4e9b | more trivial types | ||
|
|
5bcfa37cbb | more trivial types | ||
|
|
472c31b1f9 | update tests | ||
|
|
60aee61103 | update tests | ||
|
|
69e5e684d9 | fmt and clippy issues | ||
|
|
6fb7f86b6d | auto-impl for is_trivial | ||
|
|
94350b181e | update tests | ||
|
|
bd8abfd7c2 | update tests | ||
|
|
c691d63f32 | update tests | ||
|
|
25fa2e2517 | update snapshot tests | ||
|
|
9eb4cdcd02 | fix entry generation | ||
|
|
975beda918 | fmt and clippy issues | ||
|
|
c763ad6262 | fix entry generation | ||
|
|
d093b2aca1 | std formatting | ||
|
|
826af66de8 | using new fns | ||
|
|
b5681ba580 | fix tests | ||
|
|
3c0c312016 | trivial fns allowing control ifa type is trivially encoded/decoded | ||
|
|
b4fa78d60a
|
Trait coherence: disallow inherent impls on external types (#7385)
Some checks are pending
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 / 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 / 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 / forc-pkg-fuels-deps-check (push) Waiting to run
github pages / deploy (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-forc-test-project (push) Waiting to run
CI / cargo-run-e2e-test (push) Blocked by required conditions
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
This improves the trait coherence checks for impl self case, and polishes a bit of the wording on the existing diagnostics. We now enforce package-level check in impl-self type checking, which means we now reject inherent impls for external nominal types (struct/enum). There is still is a specialized whitelist for `StorageKey` so current code that uses this pattern keeps working. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] 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. - [x] 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
4a44a36718
|
Enable references tests and adjust them for zero sized unit type (#7513)
Some checks are pending
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 / 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 (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description This PR enables `language/references` and `stdlib` tests that were disabled because of the #6898. It also adjusts the `language/references` tests to the change introduced in #7509, which changes unit to be a zero-sized type. ## Checklist - [x] 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). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
3f3fa379d0
|
Enable const generics as true by default (#7512)
Some checks are pending
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 / 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 (push) Blocked by required conditions
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / cargo-test-lib-std (push) Waiting to run
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (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
## Description The final step before closing https://github.com/FuelLabs/sway/issues/6860. The `const_generics` feature flag will be fully removed in a separate PR. ## 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). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] 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](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Igor Rončević <ironcev@hotmail.com> |
||
|
|
44ff0f4f8b
|
Convert const generics todos to ice (#7511)
## Description This PR is the last of https://github.com/FuelLabs/sway/issues/6860 before we switch const generics on by default. It is transforming all `todo` to ICE. The vast majority here is probably unreachable, and if not, we can implement them as we find how to trigger them. ## 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). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] 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](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. |
||
|
|
5e179b304e
|
Fix size of ZSTs (#7509)
Some checks failed
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
CI / build-reference-examples (push) Has been cancelled
CI / forc-fmt-check-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-examples (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
## Description This PR will improve https://github.com/FuelLabs/sway/pull/7501 by fixing the size of `()`, which affects enums with all variants as `unit`. With units occupying one byte, their runtime memory representation ends up being different from their encoding representation, which avoids trivial encode/decode optimisation of some types. Another benefit of this PR is that we do not need to generate anything for `store` of zero bytes. Unfortunately, we cannot remove the `load` instruction, as registers will be uninitialized on their first usage. For that, we simply emit a `MOVI`, zeroing the register. I cannot think of a case where this change is a problem. We never promised any specific value for ZST, so zero seems a good candidate. A new test was created to facilitate checking of types sizes, layouts and whether they can be trivially encoded/decoded or not. Especially because this PR is changing the layout of types. <img width="1629" height="799" alt="image" src="https://github.com/user-attachments/assets/608c8094-55d3-44e1-8827-420a3249690a" /> In theory, this change will affect storage. But in reality, it is highly unlikely that `unit` was being used directly on types being stored. The only use case would be enums, but enums were not changed, as they were already being treated differently. ## 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
c3e5ea7436
|
Forbid const generics log (#7510)
Some checks are pending
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 / 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 (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description Continuation of https://github.com/FuelLabs/sway/pull/7494. ## Checklist - [x] 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). - [ ] 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
dc81a4063d
|
Forbid types with const generics on configurables (#7494)
Some checks failed
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
CI / build-reference-examples (push) Has been cancelled
CI / forc-fmt-check-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-examples (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
## Description
This PR is continuation of https://github.com/FuelLabs/sway/pull/7483.
## 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).
- [x] I have requested a review from the relevant team or maintainers.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Blocks types with const generics in configurables and ABI method
args/returns via new `TypeId::has_const_generics`, and adds tests to
enforce errors.
>
> - **Type system**:
> - Add `TypeId::has_const_generics(engines)` to detect const generics
in nested types (`sway-core/src/type_system/id.rs`).
> - **Compiler/semantics**:
> - Enforce no const generics in configurables via
`TyConfigurableDecl::forbid_const_generics()` and invoke during type
check (`semantic_analysis/.../configurable.rs`, `.../declaration.rs`).
> - Enforce no const generics in ABI method parameters/returns using
`TypeId::has_const_generics` and remove ad-hoc checker
(`language/ty/declaration/abi.rs`).
> - **Tests**:
> - Extend `should_fail/unsupported_const_generics` to cover
configurables and ABI cases; update snapshot (`test/.../stdout.snap`).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
|
||
|
|
8103f0d02f
|
Migrate forc-tracing and forc-crypto to forc monorepo (#7507)
Some checks are pending
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 / 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 (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Summary This PR completes the sway-side of migrating `forc-tracing` and `forc-crypto` to the new [forc monorepo](https://github.com/FuelLabs/forc), as outlined in [RFC #49](https://github.com/FuelLabs/sway-rfcs/pull/49). The corresponding forc repo PR: https://github.com/FuelLabs/forc/pull/119 ### Changes - Remove `forc-tracing` crate from workspace (now uses crates.io `0.71.1`) - Remove `forc-crypto` crate from workspace - Update CI to no longer build/package `forc-crypto` binary (it's now built from forc repo) - Update gh-pages workflow to install `forc-crypto` from forc repo for documentation generation ### Distribution Going forward, `forc-crypto` will be built and distributed from the forc repo by: - sway-nightly-binaries - fuelup - fuel.nix ### Documentation For now, documentation for all tooling will continue to live in this repo. The `gh-pages` workflow now pulls `forc-crypto` from the forc repo rather than building it locally, so docs generation continues to work as before. |
||
|
|
c73137d717
|
Optionally remove test gas limit in forc test (#7495)
Some checks failed
CI / check-dependency-version-formats (push) Has been cancelled
CI / check-forc-manifest-version (push) Has been cancelled
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-examples (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
## Description This PR adds `--no-gas-limit` CLI option to `forc test`. The option increases tx gas limit in `forc test` to `u64::MAX`, essentially removing it. The motivation for the change was the need to benchmark heavy gas consuming algorithms. E.g., a brute force prime factorization of the number 9223372021822390277 took 21_474_836_627 gas units. The new `TestGasLimit` enum provides a `Limit(limit)` variant which is currently unused, but added for future extensions, if we want to limit the test gas to a particular value. ## 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). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
ec51769132
|
Introduce alloc intrinsic to avoid using asm (#7499)
Some checks failed
CI / check-forc-manifest-version (push) Has been cancelled
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
CI / build-reference-examples (push) Has been cancelled
CI / forc-fmt-check-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-examples (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
Improvement chart: https://github.com/FuelLabs/sway/pull/7499#issuecomment-3574549744 --------- Co-authored-by: Igor Rončević <ironcev@hotmail.com> |
||
|
|
936e752176
|
feat: forc-call abi backtracing (#7502)
## Description
This PR introduces panic/error traces to the forc call trace output.
This functionality is built on top of the existing abi-backtracing
introduced in the following:
-
https://github.com/FuelLabs/sway-rfcs/blob/master/rfcs/0016-abi-backtracing.md
- https://github.com/FuelLabs/sway/pull/7224
- https://github.com/FuelLabs/sway/pull/7277
- https://github.com/FuelLabs/fuel-abi-types/pull/36
- https://github.com/FuelLabs/fuel-abi-types/pull/40/files
Supplying verbosity level greater than 1 (i.e. `-vv` or `-v=2`) will
display the panic/error traces when using `forc-call`.
If the called function panics, the panic message and the full backtrace
will be displayed in the trace output.
## Example
<details>
<summary>Example contract code</summary>
```sway
contract;
abi AbiErrorDemo {
#[storage(write)]
fn write_non_zero(value: u64);
#[storage(read)]
fn read_value() -> u64;
}
storage {
value: u64 = 0,
}
#[error_type]
pub enum PanicError {
#[error(m = "The provided value must be greater than zero.")]
ZeroValue: (),
}
impl AbiErrorDemo for Contract {
#[storage(write)]
fn write_non_zero(value: u64) {
set_non_zero_value(value);
}
#[storage(read)]
fn read_value() -> u64 {
storage.value.read()
}
}
#[trace(always)]
#[storage(write)]
fn set_non_zero_value(value: u64) {
ensure_non_zero(value);
storage.value.write(value);
}
#[trace(always)]
fn ensure_non_zero(value: u64) {
ensure_non_zero_impl(value);
}
#[trace(always)]
fn ensure_non_zero_impl(value: u64) {
if value == 0 {
panic PanicError::ZeroValue;
}
}
```
</details>
Example Call:
```sh
cargo run -p forc-client --bin forc-call -- \
--abi out/debug/abi_errors-abi.json \
babdc125da45eac42309e60d3aea63a53843f5ff2438d1a88bf8c788e8348c58 \
write_non_zero "0" -vv
```
Example Output:
<img width="857" height="340" alt="Screenshot 2025-11-24 at 8 36 00 PM"
src="https://github.com/user-attachments/assets/9a14053e-9318-4543-a01a-0d794e30dff2"
/>
## 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] 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](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]
> Adds ABI-aware revert decoding to forc-call, displaying panic
messages, values, and backtraces in verbose traces and surfacing revert
errors early.
>
> - **forc-client (call/trace)**:
> - Add ABI-aware revert decoding (`RevertInfoSummary`) and integrate
into `TraceEvent::Revert`; render panic message, value, location, and
backtrace in `display_transaction_trace`.
> - New helpers: `decode_revert_info` and `first_revert_info` to extract
revert details from receipts and trace.
> - `call_function`: generate receipts once, include in interpreter,
display detailed info on verbosity, and return an error early when a
revert is detected; parse outputs after.
> - Minor: reference `trace::display_transaction_trace` directly; extend
tests to cover revert detail rendering.
> - **forc-util**:
> - Add `revert_info_from_receipts` to build `RevertInfo` (revert code,
panic metadata) from receipts using optional ABI.
> - **forc-test**:
> - Replace `revert_code()` with `revert_info()` using new utility;
filter by actual revert code; simplify API.
> - **Docs**:
> - Add "Seeing revert information and backtraces" section with example
usage/output for `forc call -vv`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
|
||
|
|
0682209578
|
Deterministic printing of IR values (#7490)
Some checks failed
CI / forc-fmt-check-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-examples (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
Codspeed Benchmarks / benchmarks (push) Has been cancelled
CI / check-dependency-version-formats (push) Has been cancelled
CI / check-forc-manifest-version (push) Has been cancelled
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
Closes #4517
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> IR printer now generates deterministic value IDs; tests and IR harness
updated to match new naming and ensure stable round-trips.
>
> - **IR Printer**:
> - Deterministic value naming via stable keys (`v{:?}` from
`value.0.data()`); added `slotmap::Key` import.
> - **Tests/Fixtures**:
> - Switch FileCheck regex to `VAL=v\d+v\d+` and update expectations
across IR tests/snapshots to new value IDs.
> - Tweak const-folding tests to expect `const ...` lines without
temporary names.
> - **IR Test Harness**:
> - Update default regex definitions; verify determinism by
parsing/printing twice and comparing outputs.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
|
||
|
|
54e016971e
|
docs: fix a/an grammar errors in documentation (#7491)
Some checks failed
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
Codspeed Benchmarks / benchmarks (push) Has been cancelled
CI / check-dependency-version-formats (push) Has been cancelled
CI / check-forc-manifest-version (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
**Description**:
This PR fixes minor grammar errors found in the documentation:
**Documentation fixes:**
- Fixed "an the" → "the" in storage-vec documentation
- Fixed "an ContractId" → "a ContractId" (ContractId starts with
consonant sound)
- Fixed "an Contract" → "a Contract"
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Fixes incorrect articles in docs ("an"→"a" and "an the"→"the") across
asset mint, ContractId, and StorageVec pages.
>
> - **Documentation**:
> - Correct article usage in:
> - `docs/reference/src/documentation/operations/asset/mint/contract.md`
("a Contract").
> -
`docs/reference/src/documentation/operations/namespace/contract-id.md`
("a ContractId").
> -
`docs/reference/src/documentation/operations/storage/libraries/storage-vec.md`
("the" instead of "an the").
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
|
||
|
|
d7d5099eae
|
feat: add support for patching registry dependencies (#7469)
Some checks are pending
CI / check-forc-manifest-version (push) Waiting to run
CI / verifications-complete (push) Blocked by required conditions
CI / check-dependency-version-formats (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 / 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 (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Overview
Implements support for patching registry dependencies (from forc.pub)
using the `[patch]` table in `Forc.toml`. Previously, only Git
dependencies could be patched, which created a workflow gap when
packages like `std` migrated from Git to the registry.
## Motivation
When `std` and other core packages moved to forc.pub registry,
developers lost the ability to:
- Test local changes to standard library code
- Use unreleased features from development branches
- Debug issues with instrumented versions of dependencies
This PR restores that capability by extending the existing patch system
to support registry packages.
## Implementation
### Key Features
1. **Registry Patching**: Use `[patch.'forc.pub']` to override registry
dependencies
2. **Multiple Source Types**: Patch with local path or Git repository
3. **Namespace Support**: Built-in support for namespaced packages
(implementation-ready for future use)
4. **Priority System**: Namespace-specific patches override generic
patches
## Usage
### Basic Usage
```toml
[dependencies]
std = "0.70.1"
[patch.'forc.pub']
std = { path = "../sway/sway-lib-std" }
```
### Patch with Git Branch
```toml
[dependencies]
std = "0.70.1"
[patch.'forc.pub']
std = { git = "https://github.com/fuellabs/sway", branch = "my-feature" }
```
### Workspace-Level Patches
```toml
[workspace]
members = ["contract-a", "contract-b"]
[patch.'forc.pub']
std = { path = "../custom-std" }
```
## Documentation
Updated user documentation in:
- `docs/book/src/forc/manifest_reference.md` - Complete patch section
rewrite with examples
- `docs/book/src/forc/workspaces.md` - Added registry patching examples
- Inline code documentation with TOML syntax notes
## Breaking Changes
None. This is a purely additive change. All existing Git patches
continue to work exactly as before.
## Notes
- **TOML Syntax**: Quotes are required: `[patch.'forc.pub']` not
`[patch.forc.pub]`
- **Source Matching**: Registry patches only apply to registry
dependencies
- **Namespace Support**: Implementation includes namespace support
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds support to patch registry dependencies using `[patch.'forc.pub']`
(with namespaced overrides and fallback), keeps Git patching intact, and
updates docs with examples.
>
> - **Core (forc-pkg)**:
> - Extend `Source::dep_patch` to handle registry sources: checks
`[patch.'forc.pub/<namespace>']` first, then `[patch.'forc.pub']`; Git
patching unchanged.
> - Add `reg::REGISTRY_PATCH_KEY` constant (`"forc.pub"`).
> - **Tests**:
> - Add unit tests covering flat/domain namespaces, namespace priority
vs. generic fallback, Git patch compatibility, and no-op cases.
> - **Docs**:
> - Update `docs/book/src/forc/manifest_reference.md` with registry
patching examples, notes on quoting keys, and clarifications.
> - Update `docs/book/src/forc/workspaces.md` with Git and registry
patching examples for workspaces.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
|
||
|
|
8930fe8d5c
|
Bump to 0.70.2 (#7498)
Some checks are pending
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 / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-fmt-check (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 / 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 / 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-run-e2e-test (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description
This PR bumps `forc` and `std` to v0.70.2.
## 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] 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).
- [x] I have requested a review from the relevant team or maintainers.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Bumps Sway/Forc workspace and plugins to v0.70.2 and updates the
gh-pages workflow to use Rust 1.90.0.
>
> - **Release/version bumps**:
> - Set workspace `version` to `0.70.2` in `Cargo.toml`.
> - Update internal crates/plugins (`forc*`, `sway*`, `sway-ir*`)
dependency versions to `0.70.2`.
> - Bump `sway-lib-std/Forc.toml` `version` to `0.70.2`.
> - Refresh `Cargo.lock` with corresponding `0.70.2` crate versions.
> - **CI**:
> - `.github/workflows/gh-pages.yml`: Rust toolchain `1.86.0` →
`1.90.0`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
|
||
|
|
78aa952535
|
Trivially encoded types (#7488)
Some checks are pending
CI / forc-fmt-check-sway-examples (push) Waiting to run
CI / build-sway-examples (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 / 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 / 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 (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description
This PR will slice https://github.com/FuelLabs/sway/pull/7419 into
multiple PRS, being the first one.
To start optimising encoding/decoding we will introduce the concept of
"trivially encoded/decoded types". A type is trivially encoded or
decoded if the encoding memory representation is the same as the runtime
memory representation.
PR #7419 introduced an intrinsic that would return a `bool` if both
representations match. For this PR I decided to expose these memory
representations directly. For that we have two new intrinsics:
`__runtime_mem_id` and `__encoding_mem_id`.
I am not 100% sure if they are going to be useful in other scenarios,
but given that the optimiser is able to optimise them away, I think
exposing them like this is better than what #7419 does.
These `ids` are opaque numbers that do not convey anything about the
type or their representation. They can only be compared for equality,
and when a type does not have an encoding representation the intrinsic
returns zero.
With this in mind, the `encode` function now checks if a type is
"trivially encoded" or not. If it is, we just allocate and memcopy its
bytes. As this function should not return an aliased pointer.
On top of that, we also have an `encode_and_return` function that avoids
creating tuples and other stuff, given that the optimiser still
generates some `mem_copy`s in these cases.
A simple example of the benefit is the test `main_args_empty`, where the
binary size went from 96 bytes to 64 bytes.
Before
```
script {
pub entry fn __entry() -> __ptr slice, !3 {
local mut slice __aggr_memcpy_0
local { u64, u64 } __anon_0
local slice __ret_value
entry():
v0 = get_local __ptr slice, __ret_value
v1 = call main_0(), !6
v2 = get_local __ptr { u64, u64 }, __anon_0, !7
v3 = const u64 0
v4 = get_elem_ptr v2, __ptr u64, v3, !7
v5 = const u64 0, !8
store v5 to v4, !7
v6 = const u64 1
v7 = get_elem_ptr v2, __ptr u64, v6, !7
v8 = const u64 0, !9
store v8 to v7, !7
v9 = asm(s: v2) -> __ptr slice s {
}
v10 = get_local __ptr slice, __aggr_memcpy_0
mem_copy_val v10, v9
mem_copy_val v0, v10
ret __ptr slice v0
}
entry_orig fn main_0() -> (), !13 {
entry():
v0 = const unit ()
ret () v0
}
}
;; ASM: Final program
;; Program kind: Script
.program:
move $$tmp $pc
jmpf $zero i4
DATA_SECTION_OFFSET[0..32]
DATA_SECTION_OFFSET[32..64]
CONFIGURABLES_OFFSET[0..32]
CONFIGURABLES_OFFSET[32..64]
lw $$ds $$tmp i1
add $$ds $$ds $$tmp
cfei i0 ; allocate stack space for globals
move $$locbase $sp ; save locals base register for function __entry
cfei i48 ; allocate 48 bytes for locals and 0 slots for call arguments
addi $r0 $$locbase i32 ; get offset to local __ptr slice
jal $$reta $pc i9 ; [call]: call main_0
addi $r1 $$locbase i16 ; get offset to local __ptr { u64, u64 }
sw $$locbase $zero i2 ; store word
sw $$locbase $zero i3 ; store word
mcpi $$locbase $r1 i16 ; copy memory
mcpi $r0 $$locbase i16 ; copy memory
lw $r1 $r0 i1 ; load size of returned slice
lw $r0 $r0 i0 ; load pointer to returned slice
retd $r0 $r1
pshh i524288 ; save registers 40..64
move $$locbase $sp ; save locals base register for function main_0
poph i524288 ; restore registers 40..64
jal $zero $$reta i0 ; return from call
.data:
```
After
```
script {
pub entry fn __entry() -> __ptr never, !3 {
entry():
v0 = call main_0(), !6
v1 = const u64 0, !7
v2 = const u64 0, !8
retd v1 v2, !9
}
entry_orig fn main_0() -> (), !13 {
entry():
v0 = const unit ()
ret () v0
}
}
;; ASM: Final program
;; Program kind: Script
.program:
move $$tmp $pc
jmpf $zero i4
DATA_SECTION_OFFSET[0..32]
DATA_SECTION_OFFSET[32..64]
CONFIGURABLES_OFFSET[0..32]
CONFIGURABLES_OFFSET[32..64]
lw $$ds $$tmp i1
add $$ds $$ds $$tmp
cfei i0 ; allocate stack space for globals
move $$locbase $sp ; save locals base register for function __entry
jal $$reta $pc i2 ; [call]: call main_0
retd $zero $zero
pshh i524288 ; save registers 40..64
move $$locbase $sp ; save locals base register for function main_0
poph i524288 ; restore registers 40..64
jal $zero $$reta i0 ; return from call
.data:
```
Next PR will introduce this concept into the `AbiEncode` trait, allowing
the type itself to control if it wants to be trivially encoded or not.
# Missing optimizations
If we look at the test `main_args_various_types`, after the `main` is
called we see that IR is still not optimal.
```
v37 = get_local __ptr { u64 }, __ret_val1
v38 = call main_19(v36, v37)
v39 = get_local __ptr { u64 }, _result, !58 <- not needed
mem_copy_val v39, v37 <- not needed
v40 = get_local __ptr { u64 }, _result, !59 <- not needed
v41 = get_local __ptr { u64 }, item_, !62 <- not needed
mem_copy_val v41, v40 <- not needed
v42 = get_local __ptr { u64 }, item_, !64 <- not needed
v43 = const u64 8
retd v42 v43, !66
```
Ideally, IR would be
```
v37 = get_local __ptr { u64 }, __ret_val1
v38 = call main_19(v36, v37)
v39 = const u64 8
retd v37 v39, !66
```
## Gas Usage Diff
| Test | Before | After | Percentage |
| ---- | -----: | ----: | ---------: |
| should_fail/arith_overflow/u16_add_overflow (test.toml) | 44 | 43 |
2.27% |
| should_fail/arith_overflow/u16_mul_overflow (test.toml) | 45 | 44 |
2.22% |
| should_fail/arith_overflow/u16_sub_underflow (test.toml) | 23 | 22 |
4.35% |
| should_fail/arith_overflow/u32_add_overflow (test.toml) | 44 | 43 |
2.27% |
| should_fail/arith_overflow/u32_mul_overflow (test.toml) | 45 | 44 |
2.22% |
| should_fail/arith_overflow/u32_sub_underflow (test.toml) | 23 | 22 |
4.35% |
| should_fail/arith_overflow/u64_add_overflow (test.toml) | 17 | 15 |
11.76% |
| should_fail/arith_overflow/u64_mul_overflow (test.toml) | 18 | 16 |
11.11% |
| should_fail/arith_overflow/u64_sub_underflow (test.toml) | 16 | 14 |
12.50% |
| should_fail/arith_overflow/u8_add_overflow (test.toml) | 38 | 36 |
5.26% |
| should_fail/arith_overflow/u8_mul_overflow (test.toml) | 39 | 37 |
5.13% |
| should_fail/arith_overflow/u8_sub_underflow (test.toml) | 17 | 15 |
11.76% |
| should_fail/vec_set_index_out_of_bounds (test.toml) | 182 | 179 |
1.65% |
| should_fail/vec_swap_param1_out_of_bounds (test.toml) | 237 | 234 |
1.27% |
| should_fail/vec_swap_param2_out_of_bounds (test.toml) | 241 | 238 |
1.24% |
| should_pass/blanket_impl (test.toml) | 142 | 51 | 64.08% |
| should_pass/blanket_impl_u16 (test.toml) | 142 | 51 | 64.08% |
| should_pass/break_in_non_statement_positions (test.toml) | 142 | 51 |
64.08% |
| should_pass/conditional_compilation/run (test.toml) | 142 | 51 |
64.08% |
| should_pass/continue_in_non_statement_positions (test.toml) | 1226 |
1135 | 7.42% |
| should_pass/empty_fields_in_storage_struct
(test.toml)::test_read_write_bytes | 11204 | 10275 | 8.29% |
| should_pass/empty_fields_in_storage_struct
(test.toml)::test_read_write_map | 7865 | 7107 | 9.64% |
| should_pass/empty_fields_in_storage_struct
(test.toml)::test_read_write_vec | 11474 | 10125 | 11.76% |
| should_pass/forc/dependency_package_field (test.toml) | 137 | 46 |
66.42% |
| should_pass/language/abort_control_flow_good (test.toml) | 29 | 27 |
6.90% |
| should_pass/language/addrof_intrinsic (test.toml) | 609 | 595 | 2.30%
|
| should_pass/language/aliased_imports (test.toml) | 144 | 53 | 63.19% |
| should_pass/language/args_on_stack (test.toml) | 5037 | 4946 | 1.81% |
| should_pass/language/array/array_basics (test.toml) | 478 | 387 |
19.04% |
| should_pass/language/array/array_generics (test.toml) | 146 | 55 |
62.33% |
| should_pass/language/asm_expr_basic (test.toml) | 163 | 135 | 17.18% |
| should_pass/language/associated_const_abi (test.toml)::test | 4546 |
4096 | 9.90% |
| should_pass/language/associated_const_abi_multiple (test.toml)::test |
1510 | 1360 | 9.93% |
| should_pass/language/associated_const_impl (test.toml) | 143 | 115 |
19.58% |
| should_pass/language/associated_const_impl_local_same_name (test.toml)
| 143 | 115 | 19.58% |
| should_pass/language/associated_const_impl_self (test.toml) | 166 |
138 | 16.87% |
| should_pass/language/associated_const_in_decls_of_other_constants
(test.toml)::test | 529 | 452 | 14.56% |
| should_pass/language/associated_const_trait_impl_method (test.toml) |
143 | 115 | 19.58% |
| should_pass/language/associated_const_trait_method (test.toml) | 143 |
115 | 19.58% |
| should_pass/language/associated_type_and_associated_const (test.toml)
| 143 | 115 | 19.58% |
| should_pass/language/associated_type_ascription (test.toml) | 143 |
115 | 19.58% |
| should_pass/language/associated_type_container (test.toml) | 602 | 560
| 6.98% |
| should_pass/language/associated_type_container_in_library (test.toml)
| 602 | 560 | 6.98% |
| should_pass/language/associated_type_fully_qualified (test.toml) | 195
| 152 | 22.05% |
| should_pass/language/associated_type_iterator (test.toml) | 620 | 578
| 6.77% |
| should_pass/language/associated_type_method (test.toml) | 143 | 115 |
19.58% |
| should_pass/language/associated_type_parameter (test.toml) | 143 | 115
| 19.58% |
| should_pass/language/b256_bad_jumps (test.toml) | 137 | 46 | 66.42% |
| should_pass/language/b256_bitwise_ops (test.toml) | 1503 | 1412 |
6.05% |
| should_pass/language/b256_ops (test.toml) | 1314 | 1223 | 6.93% |
| should_pass/language/basic_func_decl (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/binary_and_hex_literals (test.toml) | 136 | 45 |
66.91% |
| should_pass/language/binop_intrinsics (test.toml) | 142 | 51 | 64.08%
|
| should_pass/language/bitwise_not (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/blanket_trait (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/bool_and_or (test.toml) | 142 | 51 | 64.08% |
| should_pass/language/break_and_continue (test.toml) | 1098 | 1007 |
8.29% |
| should_pass/language/builtin_type_method_call (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/chained_if_let (test.toml) | 166 | 75 | 54.82% |
| should_pass/language/complex_ir_cfg (test.toml) | 158 | 142 | 10.13% |
| should_pass/language/configurable_consts (test.toml) | 2520 | 2506 |
0.56% |
| should_pass/language/configurable_tests (test.toml)::t | 2805 | 2553 |
8.98% |
| should_pass/language/const_decl_and_use_in_library (test.toml) | 142 |
51 | 64.08% |
| should_pass/language/const_decl_in_library (test.toml) | 148 | 57 |
61.49% |
| should_pass/language/const_generics (test.toml) | 318 | 305 | 4.09% |
| should_pass/language/const_inits (test.toml) | 481 | 390 | 18.92% |
| should_pass/language/contract_caller_dynamic_address (test.toml) | 379
| 301 | 20.58% |
| should_pass/language/contract_ret_intrinsic (test.toml)::test | 1464 |
1314 | 10.25% |
| should_pass/language/dereferenced_projection_reassignment (test.toml)
| 238 | 124 | 47.90% |
| should_pass/language/diverging_exprs (test.toml) | 291 | 200 | 31.27%
|
| should_pass/language/dummy_method_issue (test.toml) | 134 | 120 |
10.45% |
| should_pass/language/empty_method_initializer (test.toml) | 242 | 151
| 37.60% |
| should_pass/language/enum_destructuring (test.toml) | 156 | 65 |
58.33% |
| should_pass/language/enum_if_let (test.toml) | 221 | 130 | 41.18% |
| should_pass/language/enum_if_let_large_type (test.toml) | 201 | 110 |
45.27% |
| should_pass/language/enum_in_fn_decl (test.toml) | 157 | 66 | 57.96% |
| should_pass/language/enum_init_fn_call (test.toml) | 185 | 94 | 49.19%
|
| should_pass/language/enum_instantiation (test.toml) | 660 | 569 |
13.79% |
| should_pass/language/enum_padding (test.toml) | 518 | 487 | 5.98% |
| should_pass/language/enum_type_inference (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/enum_variant_imports (test.toml) | 161 | 70 |
56.52% |
| should_pass/language/eq_and_neq (test.toml) | 675 | 584 | 13.48% |
| should_pass/language/eq_intrinsic (test.toml) | 142 | 51 | 64.08% |
| should_pass/language/far_jumps/many_blobs (test.toml) | 3670216 |
3670125 | 0.00% |
| should_pass/language/far_jumps/single_blob (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/for_loops (test.toml) | 7882 | 7791 | 1.15% |
| should_pass/language/funcs_with_generic_types (test.toml) | 136 | 45 |
66.91% |
| should_pass/language/function_return_type_unification (test.toml) |
148 | 120 | 18.92% |
| should_pass/language/generic_functions (test.toml) | 136 | 45 | 66.91%
|
| should_pass/language/generic_impl_self (test.toml) | 740 | 712 | 3.78%
|
| should_pass/language/generic_impl_self_where (test.toml) | 790 | 699 |
11.52% |
| should_pass/language/generic_inside_generic (test.toml) | 163 | 72 |
55.83% |
| should_pass/language/generic_result_method (test.toml) | 330 | 239 |
27.58% |
| should_pass/language/generic_struct (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/generic_struct_instantiation (test.toml) | 137 |
46 | 66.42% |
| should_pass/language/generic_structs (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/generic_trait_constraints (test.toml) | 187 | 62
| 66.84% |
| should_pass/language/generic_traits (test.toml) | 415 | 324 | 21.93% |
| should_pass/language/generic_transpose (test.toml) | 215 | 124 |
42.33% |
| should_pass/language/generic_tuple_trait (test.toml) | 174 | 83 |
52.30% |
| should_pass/language/generic_type_inference (test.toml) | 1349 | 1335
| 1.04% |
| should_pass/language/generic_where_in_impl_self (test.toml) | 201 |
110 | 45.27% |
| should_pass/language/generic_where_in_impl_self2 (test.toml) | 201 |
110 | 45.27% |
| should_pass/language/gtf_intrinsic (test.toml) | 286 | 195 | 31.82% |
| should_pass/language/if_elseif_enum (test.toml) | 388 | 360 | 7.22% |
| should_pass/language/if_implicit_unit (test.toml) | 55 | 41 | 25.45% |
| should_pass/language/if_let_no_side_effects (test.toml) | 154 | 63 |
59.09% |
| should_pass/language/impl_self_method (test.toml) | 148 | 120 | 18.92%
|
| should_pass/language/impl_self_method_order (test.toml) | 148 | 120 |
18.92% |
| should_pass/language/implicit_casting (test.toml) | 142 | 51 | 64.08%
|
| should_pass/language/implicit_return (test.toml) | 142 | 51 | 64.08% |
| should_pass/language/import_method_from_other_file (test.toml) | 155 |
64 | 58.71% |
| should_pass/language/import_star_name_clash (test.toml) | 1039 | 948 |
8.76% |
| should_pass/language/import_trailing_comma (test.toml) | 143 | 52 |
63.64% |
| should_pass/language/import_with_different_callpaths (test.toml) | 793
| 779 | 1.77% |
| should_pass/language/impure_ifs (test.toml) | 429 | 338 | 21.21% |
| should_pass/language/inline_if_expr_const (test.toml) | 55 | 41 |
25.45% |
| should_pass/language/insert_element_reg_reuse (test.toml) | 1794 |
1703 | 5.07% |
| should_pass/language/integer_type_inference (test.toml) | 547 | 533 |
2.56% |
| should_pass/language/intrinsics/dbg (test.toml) | 1193 | 1102 | 7.63%
|
| should_pass/language/intrinsics/dbg_release (test.toml) | 9785 | 9694
| 0.93% |
| should_pass/language/intrinsics/transmute (test.toml) | 402 | 388 |
3.48% |
| should_pass/language/is_prime (test.toml) | 1047 | 956 | 8.69% |
| should_pass/language/is_reference_type (test.toml) | 136 | 45 | 66.91%
|
| should_pass/language/left_to_right_func_args_evaluation (test.toml) |
149 | 58 | 61.07% |
| should_pass/language/local_impl_for_ord (test.toml) | 136 | 45 |
66.91% |
| should_pass/language/logging (test.toml) | 2126 | 1790 | 15.80% |
| should_pass/language/main_args/main_args_empty (test.encoding_v1.toml)
| 142 | 41 | 71.13% |
| should_pass/language/main_args/main_args_empty (test.toml) | 19 | 18 |
5.26% |
| should_pass/language/main_args/main_args_generics (test.toml) | 504 |
472 | 6.35% |
| should_pass/language/main_args/main_args_one_u64 (test.toml) | 163 |
63 | 61.35% |
| should_pass/language/main_args/main_args_ref (test.toml) | 172 | 72 |
58.14% |
| should_pass/language/main_args/main_args_ref_copy (test.toml) | 181 |
81 | 55.25% |
| should_pass/language/main_args/main_args_ref_ref (test.toml) | 226 |
125 | 44.69% |
| should_pass/language/main_args/main_args_two_u64 (test.toml) | 172 |
72 | 58.14% |
| should_pass/language/main_args/main_args_various_types (test.toml) |
1283 | 1130 | 11.93% |
| should_pass/language/main_returns_unit (test.toml) | 55 | 41 | 25.45%
|
| should_pass/language/many_stack_variables (test.toml) | 151 | 60 |
60.26% |
| should_pass/language/match_expressions_all (test.toml) | 3699 | 3685 |
0.38% |
| should_pass/language/match_expressions_constants (test.toml) | 377 |
263 | 30.24% |
| should_pass/language/match_expressions_empty_enums (test.toml) | 142 |
51 | 64.08% |
| should_pass/language/match_expressions_enums (test.toml) | 2019 | 1928
| 4.51% |
| should_pass/language/match_expressions_explicit_rets (test.toml) | 136
| 45 | 66.91% |
| should_pass/language/match_expressions_inside_generic_functions
(test.toml) | 170 | 79 | 53.53% |
| should_pass/language/match_expressions_mismatched (test.toml) | 154 |
63 | 59.09% |
| should_pass/language/match_expressions_nested (test.toml) | 649 | 621
| 4.31% |
| should_pass/language/match_expressions_rest (test.toml) | 777 | 686 |
11.71% |
| should_pass/language/match_expressions_simple (test.toml) | 156 | 65 |
58.33% |
| should_pass/language/match_expressions_structs (test.toml) | 151 | 60
| 60.26% |
| should_pass/language/match_expressions_with_self (test.toml) | 163 |
72 | 55.83% |
| should_pass/language/memcpy (test.toml) | 266 | 175 | 34.21% |
| should_pass/language/method_indirect_inference (test.toml) | 218 | 127
| 41.74% |
| should_pass/language/method_nested_type_args (test.toml) | 55 | 41 |
25.45% |
| should_pass/language/method_on_empty_struct (test.toml) | 137 | 46 |
66.42% |
| should_pass/language/method_on_primitives (test.toml) | 99 | 85 |
14.14% |
| should_pass/language/method_unambiguous (test.toml) | 186 | 95 |
48.92% |
| should_pass/language/modulo_uint_test (test.toml) | 136 | 45 | 66.91%
|
| should_pass/language/multi_impl_self (test.toml) | 142 | 51 | 64.08% |
| should_pass/language/multi_item_import (test.toml) | 136 | 45 | 66.91%
|
| should_pass/language/mutable_and_initd (test.toml) | 157 | 66 | 57.96%
|
| should_pass/language/mutable_arrays (test.toml) | 142 | 51 | 64.08% |
| should_pass/language/mutable_arrays_enum (test.toml) | 153 | 62 |
59.48% |
| should_pass/language/mutable_arrays_multiple_nested (test.toml) | 137
| 46 | 66.42% |
| should_pass/language/mutable_arrays_nested (test.toml) | 137 | 46 |
66.42% |
| should_pass/language/mutable_arrays_struct (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/mutable_arrays_swap (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/name_resolution_after_monomorphization
(test.toml) | 148 | 57 | 61.49% |
| should_pass/language/nested_generics (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/nested_struct_destructuring (test.toml) | 137 |
46 | 66.42% |
| should_pass/language/nested_structs (test.toml) | 279 | 188 | 32.62% |
| should_pass/language/nested_while_and_if (test.toml) | 194 | 103 |
46.91% |
| should_pass/language/new_allocator_test (test.toml) | 204 | 113 |
44.61% |
| should_pass/language/non_literal_const_decl (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/numeric_constants (test.toml) | 170 | 45 | 73.53%
|
| should_pass/language/numeric_type_propagation (test.toml) | 170 | 45 |
73.53% |
| should_pass/language/op_precedence (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/ops (test.toml) | 155 | 64 | 58.71% |
| should_pass/language/out_of_order_decl (test.toml) | 136 | 45 | 66.91%
|
| should_pass/language/overlapped_trait_impls (test.toml) | 276 | 185 |
32.97% |
| should_pass/language/prelude_access (test.toml) | 55 | 41 | 25.45% |
| should_pass/language/prelude_access2 (test.toml) | 55 | 41 | 25.45% |
| should_pass/language/primitive_type_argument (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/pusha_popa_multiple_defreg
(test.toml)::incorrect_pusha_popa | 451 | 409 | 9.31% |
| should_pass/language/raw_identifiers (test.error_type.toml)::test |
903 | 738 | 18.27% |
| should_pass/language/raw_identifiers (test.toml)::test | 903 | 738 |
18.27% |
| should_pass/language/raw_ptr/vec_ret (test.toml) | 637 | 605 | 5.02% |
| should_pass/language/reassignment_operators (test.toml) | 137 | 46 |
66.42% |
| should_pass/language/reassignment_rhs_lhs_evaluation_order (test.toml)
| 202 | 89 | 55.94% |
| should_pass/language/redundant_return (test.toml) | 137 | 46 | 66.42%
|
| should_pass/language/reexport/aliases (test.toml) | 301 | 210 | 30.23%
|
| should_pass/language/reexport/multiple_imports_of_same_reexport
(test.toml) | 329 | 238 | 27.66% |
| should_pass/language/reexport/reexport_paths (test.toml) | 277 | 165 |
40.43% |
| should_pass/language/reexport/shadowing_in_reexporting_module
(test.toml) | 368 | 277 | 24.73% |
| should_pass/language/reexport/simple_glob_import (test.toml) | 216 |
125 | 42.13% |
| should_pass/language/reexport/simple_item_import (test.toml) | 216 |
125 | 42.13% |
| should_pass/language/reexport/visibility (test.toml) | 216 | 125 |
42.13% |
| should_pass/language/ref_mutable_arrays (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/ref_mutable_arrays_inline (test.toml) | 142 | 51
| 64.08% |
| should_pass/language/ref_mutable_fn_args_bool (test.toml) | 136 | 45 |
66.91% |
| should_pass/language/ref_mutable_fn_args_call (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/ref_mutable_fn_args_struct (test.toml) | 142 | 51
| 64.08% |
| should_pass/language/ref_mutable_fn_args_struct_assign (test.toml) |
142 | 51 | 64.08% |
| should_pass/language/ref_mutable_fn_args_u32 (test.toml) | 148 | 120 |
18.92% |
| should_pass/language/references/dereferencing_control_flow_expressions
(test.toml) | 652 | 540 | 17.18% |
| should_pass/language/references/impl_reference_types (test.toml) |
2084 | 1902 | 8.73% |
| should_pass/language/references/mutability_of_references (test.toml) |
233 | 142 | 39.06% |
| should_pass/language/references/mutability_of_references_memcpy_bug
(test.toml)::test | 1023 | 680 | 33.53% |
|
should_pass/language/references/reassigning_via_references_in_aggregates
(test.toml) | 2435 | 2297 | 5.67% |
| should_pass/language/references/references_and_type_aliases
(test.toml) | 222 | 131 | 40.99% |
| should_pass/language/references/references_in_aggregates (test.toml) |
3010 | 2919 | 3.02% |
| should_pass/language/references/references_in_asm_blocks (test.toml) |
800 | 709 | 11.38% |
| should_pass/language/references/referencing_control_flow_expressions
(test.toml) | 841 | 750 | 10.82% |
| should_pass/language/references/referencing_function_parameters
(test.toml) | 2292 | 2201 | 3.97% |
| should_pass/language/references/referencing_function_parameters_simple
(test.toml)::test_arg_addr | 1268 | 464 | 63.41% |
| should_pass/language/references/referencing_parts_of_aggregates
(test.toml) | 2124 | 2033 | 4.28% |
| should_pass/language/references/referencing_references (test.toml) |
417 | 326 | 21.82% |
| should_pass/language/references/type_unification_of_references
(test.toml) | 539 | 448 | 16.88% |
| should_pass/language/ret_small_string (test.toml) | 169 | 138 | 18.34%
|
| should_pass/language/ret_string_in_struct (test.toml) | 185 | 153 |
17.30% |
| should_pass/language/retd_b256 (test.toml) | 188 | 74 | 60.64% |
| should_pass/language/retd_small_array (test.toml) | 196 | 164 | 16.33%
|
| should_pass/language/retd_struct (test.toml) | 362 | 331 | 8.56% |
| should_pass/language/retd_zero_len_array (test.toml) | 107 | 75 |
29.91% |
| should_pass/language/revert_in_first_if_branch (test.toml) | 28 | 25 |
10.71% |
| should_pass/language/same_const_name (test.toml) | 55 | 41 | 25.45% |
| should_pass/language/self_impl_reassignment (test.toml) | 276 | 185 |
32.97% |
| should_pass/language/shadowing/shadowed_glob_imports (test.toml) | 178
| 87 | 51.12% |
| should_pass/language/shadowing/shadowed_prelude_imports (test.toml) |
146 | 55 | 62.33% |
| should_pass/language/size_of (test.toml) | 137 | 46 | 66.42% |
| should_pass/language/slice/slice_intrinsics (test.toml) | 123848 |
104394 | 15.71% |
| should_pass/language/slice/slice_script (test.toml) | 231 | 200 |
13.42% |
| should_pass/language/storage_slot_sized
(test.toml)::test_store_something | 7736 | 4706 | 39.17% |
| should_pass/language/string_slice/string_slice_features (test.toml) |
163 | 72 | 55.83% |
| should_pass/language/string_slice/string_slice_script (test.toml) |
264 | 232 | 12.12% |
| should_pass/language/struct_destructuring (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/struct_field_access (test.toml) | 142 | 51 |
64.08% |
| should_pass/language/struct_field_reassignment (test.toml) | 137 | 46
| 66.42% |
| should_pass/language/struct_instantiation (test.toml) | 524 | 433 |
17.37% |
| should_pass/language/supertraits (test.toml) | 1146 | 1055 | 7.94% |
| should_pass/language/supertraits_with_trait_methods (test.toml) | 151
| 60 | 60.26% |
| should_pass/language/totalord (test.toml) | 783 | 658 | 15.96% |
| should_pass/language/trait_constraint_param_order (test.toml) | 136 |
45 | 66.91% |
| should_pass/language/trait_generic_override (test.toml) | 136 | 45 |
66.91% |
| should_pass/language/trait_import_with_star (test.toml) | 55 | 41 |
25.45% |
| should_pass/language/trait_inference (test.toml) | 182 | 57 | 68.68% |
| should_pass/language/trait_method_ascription_disambiguate (test.toml)
| 136 | 45 | 66.91% |
| should_pass/language/trait_method_generic_qualified (test.toml) | 136
| 45 | 66.91% |
| should_pass/language/trait_method_qualified (test.toml) | 136 | 45 |
66.91% |
| should_pass/language/trait_nested (test.toml) | 189 | 64 | 66.14% |
| should_pass/language/tuple_access (test.toml) | 176 | 85 | 51.70% |
| should_pass/language/tuple_desugaring (test.toml) | 155 | 127 | 18.06%
|
| should_pass/language/tuple_field_reassignment (test.toml) | 168 | 77 |
54.17% |
| should_pass/language/tuple_in_struct (test.toml) | 199 | 108 | 45.73%
|
| should_pass/language/tuple_indexing (test.toml) | 143 | 115 | 19.58% |
| should_pass/language/tuple_single_element (test.toml) | 149 | 58 |
61.07% |
| should_pass/language/tuple_trait (test.toml) | 152 | 61 | 59.87% |
| should_pass/language/tuple_types (test.toml) | 148 | 120 | 18.92% |
| should_pass/language/type_alias (test.toml) | 1064 | 1050 | 1.32% |
| should_pass/language/type_inference_propagation_of_type_constraints
(test.toml) | 268 | 237 | 11.57% |
| should_pass/language/typeinfo_custom_callpath (test.toml) | 67 | 53 |
20.90% |
| should_pass/language/typeinfo_custom_callpath2 (test.toml) | 67 | 53 |
20.90% |
| should_pass/language/typeinfo_custom_callpath_with_import (test.toml)
| 69 | 55 | 20.29% |
| should_pass/language/u256/u256_abi (test.toml) | 392 | 164 | 58.16% |
| should_pass/language/unary_not_basic (test.toml) | 136 | 45 | 66.91% |
| should_pass/language/unary_not_basic_2 (test.toml) | 136 | 45 | 66.91%
|
| should_pass/language/unify_never (test.toml) | 142 | 51 | 64.08% |
| should_pass/language/unit_type_variants (test.toml) | 224 | 53 |
76.34% |
| should_pass/language/use_absolute_path (test.toml) | 137 | 46 | 66.42%
|
| should_pass/language/use_full_path_names (test.toml) | 143 | 115 |
19.58% |
| should_pass/language/where_clause_enums (test.toml) | 280 | 189 |
32.50% |
| should_pass/language/where_clause_functions (test.toml) | 453 | 362 |
20.09% |
| should_pass/language/where_clause_generic_traits (test.toml) | 55 | 41
| 25.45% |
| should_pass/language/where_clause_generic_tuple (test.toml) | 142 | 51
| 64.08% |
| should_pass/language/where_clause_impls (test.toml) | 158 | 67 |
57.59% |
| should_pass/language/where_clause_methods (test.toml) | 541 | 450 |
16.82% |
| should_pass/language/where_clause_structs (test.toml) | 254 | 163 |
35.83% |
| should_pass/language/where_clause_traits (test.toml) | 136 | 45 |
66.91% |
| should_pass/language/while_loops (test.toml) | 389 | 298 | 23.39% |
| should_pass/language/zero_field_types (test.toml) | 142 | 51 | 64.08%
|
| should_pass/return_in_non_statement_positions (test.toml) | 142 | 51 |
64.08% |
| should_pass/return_into (test.toml) | 412 | 321 | 22.09% |
| should_pass/stdlib/address_test (test.toml) | 1175 | 1084 | 7.74% |
| should_pass/stdlib/alloc_test (test.toml) | 265 | 174 | 34.34% |
| should_pass/stdlib/assert_eq (test.toml) | 1108 | 983 | 11.28% |
| should_pass/stdlib/assert_eq_revert (test.toml) | 303 | 152 | 49.83% |
| should_pass/stdlib/assert_ne (test.toml) | 1045 | 921 | 11.87% |
| should_pass/stdlib/assert_ne_revert (test.toml) | 302 | 151 | 50.00% |
| should_pass/stdlib/assert_test (test.toml) | 136 | 45 | 66.91% |
| should_pass/stdlib/asset_id_into_bytes (test.toml) | 173 | 82 | 52.60%
|
| should_pass/stdlib/b512_struct_alignment (test.toml) | 202 | 111 |
45.05% |
| should_pass/stdlib/b512_test (test.toml) | 996 | 905 | 9.14% |
| should_pass/stdlib/block_height (test.toml) | 149 | 58 | 61.07% |
| should_pass/stdlib/chess (test.toml) | 231 | 140 | 39.39% |
| should_pass/stdlib/contract_id_test (test.toml) | 174 | 83 | 52.30% |
| should_pass/stdlib/contract_id_type (test.toml) | 169 | 78 | 53.85% |
| should_pass/stdlib/eq_generic (test.toml) | 154 | 140 | 9.09% |
| should_pass/stdlib/ge_test (test.toml) | 136 | 45 | 66.91% |
| should_pass/stdlib/generic_empty_struct_with_constraint (test.toml) |
55 | 41 | 25.45% |
| should_pass/stdlib/identity_eq (test.toml) | 1274 | 1183 | 7.14% |
| should_pass/stdlib/if_type_revert (test.toml) | 26 | 24 | 7.69% |
| should_pass/stdlib/intrinsics (test.toml) | 136 | 45 | 66.91% |
| should_pass/stdlib/iterator (test.toml) | 984 | 859 | 12.70% |
| should_pass/stdlib/option_eq (test.toml) | 5291 | 5200 | 1.72% |
| should_pass/stdlib/raw_ptr (test.toml) | 4316 | 4225 | 2.11% |
| should_pass/stdlib/raw_slice (test.toml) | 424 | 392 | 7.55% |
| should_pass/stdlib/require (test.toml) | 182 | 165 | 9.34% |
| should_pass/stdlib/storage_vec_insert (test.toml)::test_test_function
| 2903 | 2754 | 5.13% |
| should_pass/stdlib/u128_div_test (test.toml) | 34133 | 34042 | 0.27% |
| should_pass/stdlib/u128_log_test (test.toml) | 11809 | 11718 | 0.77% |
| should_pass/stdlib/u128_mul_test (test.toml) | 453 | 362 | 20.09% |
| should_pass/stdlib/u128_root_test (test.toml) | 7634 | 7543 | 1.19% |
| should_pass/stdlib/u128_test (test.toml) | 2177 | 2086 | 4.18% |
| should_pass/stdlib/vec (test.toml) | 65253 | 65162 | 0.14% |
| should_pass/stdlib/vec_swap (test.toml) | 14862 | 14771 | 0.61% |
| should_pass/storage_element_key_modification
(test.toml)::test_storage_key_address | 943 | 863 | 8.48% |
| should_pass/storage_element_key_modification
(test.toml)::test_storage_key_modification | 465 | 385 | 17.20% |
| should_pass/storage_slot_key_calculation (test.toml)::test | 2785 |
2708 | 2.76% |
| should_pass/superabi_contract_calls (test.toml)::tests | 1310 | 1004 |
23.36% |
| should_pass/superabi_supertrait_same_methods (test.toml)::tests | 634
| 483 | 23.82% |
| should_pass/test_abis/abi_impl_methods_callable (test.toml)::tests |
599 | 449 | 25.04% |
| should_pass/test_abis/contract_abi-auto_impl (test.toml)::tests | 599
| 449 | 25.04% |
| should_pass/test_contracts/basic_storage
(test.toml)::collect_basic_storage_contract_gas_usages | 37164 | 35842 |
3.56% |
| should_pass/test_contracts/increment_contract
(test.toml)::collect_incrementor_contract_gas_usages | 2006 | 1628 |
18.84% |
| should_pass/test_contracts/return_struct
(test.toml)::collect_my_contract_gas_usages | 1076 | 1000 | 7.06% |
| should_pass/test_contracts/storage_access_contract
(test.toml)::collect_storage_access_contract_gas_usages | 49894 | 44857
| 10.10% |
| should_pass/test_contracts/storage_enum_contract
(test.toml)::collect_storage_enum_contract_gas_usages | 22372 | 22213 |
0.71% |
| should_pass/unit_tests/aggr_indexing (test.toml)::test1 | 4192 | 2082
| 50.33% |
| should_pass/unit_tests/contract-multi-contract-calls
(test.toml)::test_contract_2_call | 631 | 480 | 23.93% |
| should_pass/unit_tests/contract-multi-contract-calls
(test.toml)::test_contract_call | 634 | 483 | 23.82% |
| should_pass/unit_tests/contract-multi-contract-calls
(test.toml)::test_contract_multi_call | 1246 | 944 | 24.24% |
| should_pass/unit_tests/contract_multi_test (test.toml)::test_bar | 175
| 68 | 61.14% |
| should_pass/unit_tests/contract_multi_test (test.toml)::test_fail |
635 | 484 | 23.78% |
| should_pass/unit_tests/contract_multi_test (test.toml)::test_success |
633 | 482 | 23.85% |
| should_pass/unit_tests/contract_with_nested_libs (test.toml)::log_test
| 180 | 184 | -2.22% |
| should_pass/unit_tests/contract_with_nested_libs
(test.toml)::log_test_inner | 180 | 184 | -2.22% |
| should_pass/unit_tests/contract_with_nested_libs
(test.toml)::log_test_inner2 | 173 | 67 | 61.27% |
| should_pass/unit_tests/lib_log_decode
(test.toml)::math_u16_overflow_mul | 214 | 218 | -1.87% |
| should_pass/unit_tests/lib_log_decode
(test.toml)::math_u32_overflow_mul | 214 | 218 | -1.87% |
| should_pass/unit_tests/lib_log_decode (test.toml)::test_fn | 362 | 146
| 59.67% |
| should_pass/unit_tests/lib_multi_test (test.toml)::test_gt | 156 | 82
| 47.44% |
| should_pass/unit_tests/lib_multi_test (test.toml)::test_local | 156 |
82 | 47.44% |
| should_pass/unit_tests/nested_libs (test.toml)::log_test | 179 | 183 |
-2.23% |
| should_pass/unit_tests/nested_libs (test.toml)::log_test_inner | 179 |
183 | -2.23% |
| should_pass/unit_tests/nested_libs (test.toml)::log_test_inner2 | 172
| 66 | 61.63% |
| should_pass/unit_tests/regalloc_spill (test.toml) | 181 | 90 | 50.28%
|
| should_pass/unit_tests/script-contract-calls
(test.toml)::test_contract_call | 563 | 448 | 20.43% |
| should_pass/unit_tests/script_log_decode (test.toml)::test_fn | 294 |
146 | 50.34% |
| should_pass/unit_tests/script_with_nested_libs (test.toml)::log_test |
179 | 183 | -2.23% |
| should_pass/unit_tests/script_with_nested_libs
(test.toml)::log_test_inner | 179 | 183 | -2.23% |
| should_pass/unit_tests/script_with_nested_libs
(test.toml)::log_test_inner2 | 172 | 66 | 61.63% |
| should_pass/unit_tests/workspace_test (test.toml)::test_bar | 175 | 68
| 61.14% |
| should_pass/unit_tests/workspace_test (test.toml)::test_fail | 635 |
484 | 23.78% |
| should_pass/unit_tests/workspace_test (test.toml)::test_gt | 156 | 82
| 47.44% |
| should_pass/unit_tests/workspace_test (test.toml)::test_local | 156 |
82 | 47.44% |
| should_pass/unit_tests/workspace_test (test.toml)::test_success | 634
| 483 | 23.82% |
| | Improvements | Regressions |
| - | -: | -: |
| Count | 346 | 8 |
| Average | 34.98% | -2.14% |
| Median | 28.79% | -2.23% |
| Max | 76.34% | -2.23% |
| Min | 0.14% | -1.87% |
| Test | Before | After | Percentage |
| ---- | -----: | ----: | ---------: |
| assert_inline_tests::assert_assert_eq | 1576 | 1529 | 2.98% |
| assert_inline_tests::assert_assert_ne | 1630 | 1585 | 2.76% |
| assert_inline_tests::revert_assert_assert_eq | 1480 | 1117 | 24.53% |
| assert_inline_tests::revert_assert_assert_ne | 1488 | 1115 | 25.07% |
| asset_id_contract_tests::asset_id_default | 10994 | 10696 | 2.71% |
| bytes_inline_tests::bytes_append | 5789 | 5787 | 0.03% |
| bytes_inline_tests::bytes_split_at_twice | 1321 | 1319 | 0.15% |
| codec_implemented_tests::test_logging | 51837 | 23126 | 55.39% |
| contract_id_contract_tests::contract_id_this | 10787 | 10488 | 2.77% |
| crypto_ed25519_inline_tests::ed25519_codec | 6125 | 640 | 89.55% |
| crypto_secp256k1_inline_tests::secp256k1_codec | 6125 | 640 | 89.55% |
| crypto_secp256r1_inline_tests::secp256r1_codec | 6125 | 640 | 89.55% |
| crypto_signature_inline_tests::signature_as_ed25519 | 6840 | 6841 |
-0.01% |
| crypto_signature_inline_tests::signature_as_secp256r1 | 6836 | 6837 |
-0.01% |
| crypto_signature_inline_tests::signature_codec | 7748 | 654 | 91.56% |
| crypto_signature_inline_tests::signature_verify | 43208 | 43205 |
0.01% |
| hash_inline_tests::hash_address | 7223 | 7211 | 0.17% |
| hash_inline_tests::hash_asset_id | 7223 | 7211 | 0.17% |
| hash_inline_tests::hash_b256 | 7171 | 7159 | 0.17% |
| hash_inline_tests::hash_call_params | 6930 | 6924 | 0.09% |
| hash_inline_tests::hash_contract_id | 7223 | 7211 | 0.17% |
| hash_inline_tests::hash_evm_address | 7407 | 7395 | 0.16% |
| hash_inline_tests::hash_identity | 17767 | 17743 | 0.14% |
| hash_inline_tests::hash_point2d | 9311 | 9305 | 0.06% |
| hash_inline_tests::hash_signature | 20238 | 20220 | 0.09% |
| hash_inline_tests::hash_str | 10508 | 10505 | 0.03% |
| hash_inline_tests::hash_tuple_4 | 8499 | 8497 | 0.02% |
| hash_inline_tests::hash_u128 | 5160 | 5154 | 0.12% |
| hash_inline_tests::hash_user_defined_type | 42799 | 42787 | 0.03% |
| storage_vec_iter_tests::empty_vec_next_returns_none | 50784 | 50644 |
0.28% |
| storage_vec_iter_tests::storage_vec_field_for_loop_iteration | 1574940
| 1573470 | 0.09% |
| storage_vec_iter_tests::storage_vec_field_nested_for_loop_iteration |
11570183 | 11559644 | 0.09% |
| storage_vec_iter_tests::vec_with_elements_for_loop_iteration |
24015966 | 24011576 | 0.02% |
| storage_vec_iter_tests::vec_with_elements_next_returns_element |
24016001 | 24011606 | 0.02% |
| u128_inline_tests::parity_u128_log_with_ruint | 1851450 | 1850539 |
0.05% |
| u128_inline_tests::revert_u128_zero_root | 232 | 230 | 0.86% |
| u128_inline_tests::revert_u128_zero_root_overflow_disabled | 238 | 236
| 0.84% |
| u128_inline_tests::u128_log | 24393 | 24391 | 0.01% |
| u128_inline_tests::u128_pow | 8902 | 8900 | 0.02% |
| u128_inline_tests::u128_root | 13907 | 13872 | 0.25% |
| u128_inline_tests::u128_zero_root_unsafe_math | 452 | 450 | 0.44% |
| | Improvements | Regressions |
| - | -: | -: |
| Count | 39 | 2 |
| Average | 12.33% | -0.01% |
| Median | 0.17% | -0.01% |
| Max | 91.56% | -0.01% |
| Min | 0.01% | -0.01% |
## 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)
- [ ] 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).
- [x] I have requested a review from the relevant team or maintainers.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduce `__runtime_mem_id`/`__encoding_mem_id` intrinsics and use
them to trivially encode/return values, updating ABI entry to `never`,
improving gas/binary size, and adjusting docs, IR, and tests.
>
> - **Core/Compiler**:
> - Add intrinsics `__runtime_mem_id<T>() -> u64` and
`__encoding_mem_id<T>() -> u64` (AST, semantic, IR gen, const-eval).
> - Implement memory-representation modeling and ID hashing
(`get_memory_representation`, `get_memory_id`,
`get_encoding_representation`/`id`).
> - Update ABI entry generation to return `never` and use direct `retd`.
> - Extend IR parser/types with `never`.
> - **Std Library (`codec.sw`)**:
> - `encode<T>`: detect trivially-encodable types (matching IDs) and
`memcpy` bytes; otherwise fallback to normal encoding.
> - Add `encode_and_return<T>() -> !` using `__contract_ret` for fast
returns.
> - **Docs**:
> - Document `__transmute`, `__runtime_mem_id`, and `__encoding_mem_id`
in the Sway book; include constraints/semantics.
> - **Tests/Fixtures**:
> - Update many snapshots, gas/bytecode expectations, raw log
PCs/pointers, and release flags.
> - Refresh expected contract IDs in require-deployment tests.
> - Notable size/gas reductions across numerous tests; `main_args_empty`
shrinks (e.g., 96→64 B) and many gas wins.
> - **Misc**:
> - Minor utilities (e.g., const-generic length literal extraction) and
effect tracking for new intrinsics.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
|
||
|
|
fb10b2fcb1
|
Forbid const generics on abis (#7483)
Some checks failed
CI / forc-unit-tests (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
CI / build-reference-examples (push) Has been cancelled
Codspeed Benchmarks / benchmarks (push) Has been cancelled
CI / check-dependency-version-formats (push) Has been cancelled
CI / check-forc-manifest-version (push) Has been cancelled
CI / get-fuel-core-version (push) Has been cancelled
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
## Description
This PR forbids "const generics" on `abi`s. The reason is that to
correctly support it, we will need to introduce changes to the ABI json.
This will be reserved to the future.
## Checklist
- [ ] 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).
- [x] I have requested a review from the relevant team or maintainers.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is
generating a summary for commit
|
||
|
|
886becbca0
|
Add a new memcpy propagation pass (#7443)
Some checks failed
CI / cargo-fmt-check (push) Has been cancelled
Codspeed Benchmarks / benchmarks (push) Has been cancelled
CI / check-dependency-version-formats (push) Has been cancelled
CI / check-forc-manifest-version (push) Has been cancelled
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
CI / build-reference-examples (push) Has been cancelled
CI / forc-fmt-check-sway-lib-std (push) Has been cancelled
CI / forc-fmt-check-sway-examples (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
## Description For the Sway code in #7344, the IR after #7381 and after this PR is shown here: <details> <summary> After #7381, before this PR </summary> ``` fn wrapper_1(__ret_value: __ptr { b256 }) -> (), !17 { local { u64, ( () | { b256 } ) } __matched_value_4 local { u64, ( () | { b256 } ) } __ret_val local { u64, ( () | { b256 } ) } self_ entry(__ret_value: __ptr { b256 }): v0 = get_local __ptr { u64, ( () | { b256 } ) }, __ret_val v1 = call return_option_5(v0) v2 = get_local __ptr { u64, ( () | { b256 } ) }, self_, !20 mem_copy_val v2, v0 v3 = get_local __ptr { u64, ( () | { b256 } ) }, self_, !23 v4 = get_local __ptr { u64, ( () | { b256 } ) }, __matched_value_4, !25 mem_copy_val v4, v3 v5 = get_local __ptr { u64, ( () | { b256 } ) }, self_ v6 = const u64 0 v7 = get_elem_ptr v5, __ptr u64, v6 v8 = load v7, !20 v9 = const u64 1, !22 v10 = cmp eq v8 v9, !28 cbr v10, unwrap_2_block0(), unwrap_2_block1(), !29 unwrap_2_block0(): v11 = get_local __ptr { u64, ( () | { b256 } ) }, __matched_value_4, !30 v12 = const u64 1 v13 = const u64 1 v14 = get_elem_ptr v11, __ptr { b256 }, v12, v13, !20 mem_copy_val __ret_value, v14 v15 = const unit () ret () v15 unwrap_2_block1(): v16 = const u64 0, !31 revert v16, !36 } fn return_option_5(__ret_value: __ptr { u64, ( () | { b256 } ) }) -> (), !39 { local { u64, ( () | { b256 } ) } __anon_0 entry(__ret_value: __ptr { u64, ( () | { b256 } ) }): v0 = get_local __ptr { u64, ( () | { b256 } ) }, __anon_0, !40 v1 = const u64 0 v2 = get_elem_ptr v0, __ptr u64, v1, !40 v3 = const u64 0, !40 store v3 to v2, !40 mem_copy_val __ret_value, v0 v4 = const unit () ret () v4 } ``` </details> <details> <summary> After this PR </summary> ``` fn wrapper_1(__ret_value: __ptr { b256 }) -> (), !17 { local { u64, ( () | { b256 } ) } __matched_value_4 entry(__ret_value: __ptr { b256 }): v0 = get_local __ptr { u64, ( () | { b256 } ) }, __matched_value_4 v1 = call return_option_5(v0) v2 = get_local __ptr { u64, ( () | { b256 } ) }, __matched_value_4 v3 = const u64 0 v4 = get_elem_ptr v2, __ptr u64, v3 v5 = load v4, !20 v6 = const u64 1, !22 v7 = cmp eq v5 v6, !25 cbr v7, unwrap_2_block0(), unwrap_2_block1(), !26 unwrap_2_block0(): v8 = get_local __ptr { u64, ( () | { b256 } ) }, __matched_value_4, !27 v9 = const u64 1 v10 = const u64 1 v11 = get_elem_ptr v8, __ptr { b256 }, v9, v10, !20 mem_copy_val __ret_value, v11 v12 = const unit () ret () v12 unwrap_2_block1(): v13 = const u64 0, !28 revert v13, !33 } fn return_option_5(__ret_value: __ptr { u64, ( () | { b256 } ) }) -> (), !36 { entry(__ret_value: __ptr { u64, ( () | { b256 } ) }): v0 = const u64 0 v1 = get_elem_ptr __ret_value, __ptr u64, v0, !37 v2 = const u64 0, !37 store v2 to v1, !37 v3 = const unit () ret () v3 } ``` </details> `wrapper_1`, which had 3 `memcpy`s now has 1, and `return_option_5` which had one, now has none. Closes #7344. |
||
|
|
6b26e50f09
|
Update to latest fuels-rs dependency (#7468)
Some checks failed
CI / forc-fmt-check-panic (push) Has been cancelled
CI / check-sdk-harness-test-suite-compatibility (push) Has been cancelled
CI / build-mdbook (push) Has been cancelled
CI / build-forc-doc-sway-lib-std (push) Has been cancelled
Codspeed Benchmarks / benchmarks (push) Has been cancelled
CI / check-dependency-version-formats (push) Has been cancelled
CI / check-forc-manifest-version (push) Has been cancelled
CI / get-fuel-core-version (push) Has been cancelled
CI / build-sway-lib-std (push) Has been cancelled
CI / build-sway-examples (push) Has been cancelled
CI / pre-publish-check (push) Has been cancelled
github pages / deploy (push) Has been cancelled
CI / build-forc-test-project (push) Has been cancelled
CI / cargo-build-workspace (push) Has been cancelled
CI / cargo-toml-fmt-check (push) Has been cancelled
CI / cargo-fmt-check (push) Has been cancelled
CI / cargo-test-lib-std (push) Has been cancelled
CI / forc-run-benchmarks (push) Has been cancelled
CI / forc-unit-tests (push) Has been cancelled
CI / forc-pkg-fuels-deps-check (push) Has been cancelled
CI / Build and test various forc tools (push) Has been cancelled
CI / cargo-unused-deps-check (push) Has been cancelled
CI / cargo-clippy (push) Has been cancelled
CI / verifications-complete (push) Has been cancelled
CI / publish (push) Has been cancelled
CI / Build and upload forc binaries to release (push) Has been cancelled
CI / notify-slack-on-failure (push) Has been cancelled
CI / cargo-run-e2e-test (push) Has been cancelled
CI / cargo-run-e2e-test-release (push) Has been cancelled
CI / publish-sway-lib-std (push) Has been cancelled
## Description Update to latest `fuels-rs` dependency. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] 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. - [x] 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). - [x] I have requested a review from the relevant team or maintainers. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Upgrade to latest Fuel/fuels versions and refactor code/tests to new APIs (IDs, receipts, storage, wallet, node owner). > > - **Dependencies**: > - Bump `fuel-core` to `0.47.x`, `fuel-{vm,tx,types,asm,crypto}` to `0.65`, and `fuels{,-core,-accounts}` to `0.76`; update `fuel-core-*` crates across workspace and SDK harness. > - **Core/API migrations**: > - Use `Contract::id(..)` associated function (replaces instance method); update contract ID calculations in `forc-pkg`, `forc-client` deploy, and `forc-test`. > - Adjust receipts handling to `Arc<Vec<_>>` and convert as needed; update parsing/printing of `Receipt::LogData`/`ReturnData` to new byte accessors. > - Update `ContractsStateData` construction and storage conversions in VM trace storage. > - Refactor wallet account collection/types and secret key conversion in tx utils. > - Switch `forc-node` coin owner to `Owner` enum; update logging and tests. > - **Tests**: > - Adapt E2E and client tests to new receipt/data APIs and predicate fee assertions; update SDK harness deps and context tests (ContractIdExt import). > - **Misc**: > - Update workspace `Cargo.toml` and `test/src/sdk-harness/Cargo.toml`; extend `.typos.toml` ignores/excludes. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d0541bd2ec806d10743310573edde8c85364b4ff. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> |
||
|
|
c04c1b33b2
|
Remove unchecked new methods from VirtualImmediate* (#7484)
Some checks are pending
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 / verifications-complete (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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (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 (push) Blocked by required conditions
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
Closes #7334 |
||
|
|
0e71b18885
|
Add relative jump instructions to asm blocks (#7485)
Some checks are pending
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 / 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 (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description This PR adds relative FuelVM jump instructions `jmpb`, `jmpf`, `jnzb`, `jnzf`, `jneb`, `jnef`, as well as `jal` to `asm` blocks. This is done for completeness (other jump instructions are already available in `asm`) but most of all to be able to experiment with optimizations by creating non-restricted, manually defined code in `asm` within Sway programs. Note that for this kind of experimenting, it is necessary to comment out the emitting of the `CompileError::DisallowedControlFlowInstruction` in `sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs`, because control flow instructions are not allowed in the `asm`. ## 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). - [ ] 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
990a84093a
|
Add event support via #[event] and #[indexed] attributes (#7158)
Some checks are pending
CI / pre-publish-check (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 / 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 (push) Blocked by required conditions
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
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 / publish (push) Blocked by required conditions
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
This PR adds two new attributes: `#[event]` and `#[indexed]`.
The `#[event]` attribute marks a struct or enum as an event that can be
emitted by a contract.
The `#[indexed]` attribute can be applied to fields within structs that
are attributed with `#[event]`. This is particularly useful for event
structs, allowing for efficient filtering and searching of emitted
events based on the values of these fields.
When using this attribute, the indexed fields must be applied
sequentially to the initial set of fields in a struct.
This attribute can only be applied to fields whose type is an exact size
ABI type. The exact size ABI types include:
- `bool`
- `u8`, `u16`, `u32`, `u64`, `u256`
- `numeric`
- `b256`
- `str[N]`
- Tuples containing only exact size types
- Structs containing only exact size types
- Arrays of exact size types with a literal length
- Type aliases to exact size types
Additionally it causes the event types to be included in the JSON ABI
representation for the contract and emits an `offset` for indexed
fields.
```sway
#[event]
struct MyEventStruct {
#[indexed]
id: u64,
sender: Identity,
}
```
|
||
|
|
0316a50dd5
|
Coins analysis for const generics (#7473)
## Description This PR continue https://github.com/FuelLabs/sway/pull/7391. First, it removes some easy `todo!()` around `ParsedDeclId`. It seems only `fn` or `struct` are using those. But I decided to implement them anyway to keep the code uniform. We may be able to simplify this, I think. Second, it implements coin analysis for const generics. Unfortunately, the analysis runs on the `fn` declaration and not on the materialised version. So even calling a function with `0` generates the error. ## Checklist - [x] 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). - [ ] 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
90c8ed2569
|
Reduce storage API byte allocation (#7430)
## Description Legacy functionality from the storage API now allocates more memory than required for the read and write functions. This allocation has been reduced to the correct amounts. Reduces unnecessary byte allocation by 8x. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] 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. - [x] 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). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Igor Rončević <ironcev@hotmail.com> |
||
|
|
bfbe49010b
|
Optimize slot_calculator for bytecode size and gas usage (#7481)
Some checks are pending
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 / 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 (push) Blocked by required conditions
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
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description This PR optimizes `std::storage_api::slot_calculator` for bytecode size and gas usage by: - skipping calling it if the value fits the slot and the offset is zero, - replacing `match` on a boolean value with `if`. This removes the trailing `else` branch which is present in the desugared `match` expression. - avoiding expensive `.as_u256()` calls and `u256` arithmetic when adding a `u64` to `u256`. ## Performance gains ### Comparing 'e2e-gas-usages': | Test | Before | After | Percentage | |------|-------:|------:|-----------:| | should_pass/empty_fields_in_storage_struct (test.toml)::test_read_write_bytes | 17533 | 16705 | 4.72% | | should_pass/empty_fields_in_storage_struct (test.toml)::test_read_write_map | 13986 | 13526 | 3.29% | | should_pass/empty_fields_in_storage_struct (test.toml)::test_read_write_vec | 29288 | 28187 | 3.76% | | should_pass/language/storage_slot_sized (test.toml)::test_store_something | 10982 | 10247 | 6.69% | | should_pass/stdlib/storage_vec_insert (test.toml)::test_test_function | 3831 | 3102 | 19.03% | | should_pass/test_contracts/basic_storage (test.toml)::collect_basic_storage_contract_gas_usages | 47557 | 42427 | 10.79% | | should_pass/test_contracts/increment_contract (test.toml)::collect_incrementor_contract_gas_usages | 2792 | 2517 | 9.85% | | should_pass/test_contracts/storage_access_contract (test.toml)::collect_storage_access_contract_gas_usages | 162131 | 157884 | 2.62% | | should_pass/test_contracts/storage_enum_contract (test.toml)::collect_storage_enum_contract_gas_usages | 31466 | 23060 | 26.71% | ### Comparing 'e2e-bytecode-sizes': | Test | Before | After | Percentage | |------|-------:|------:|-----------:| | should_pass/empty_fields_in_storage_struct (test.toml) | 11784 | 11616 | 1.43% | | should_pass/language/fallback_only (test.toml) | 1904 | 1552 | 18.49% | | should_pass/language/generics_in_contract (test.toml) | 2336 | 2112 | 9.59% | | should_pass/language/storage_slot_sized (test.toml) | 4864 | 4608 | 5.26% | | should_pass/static_analysis/cei_pattern_violation (test.toml) | 1472 | 1248 | 15.22% | | should_pass/static_analysis/cei_pattern_violation_in_codeblocks_other_than_in_functions (test.toml) | 1704 | 1488 | 12.68% | | should_pass/static_analysis/cei_pattern_violation_in_func_app-1 (test.toml) | 1696 | 1472 | 13.21% | | should_pass/static_analysis/cei_pattern_violation_in_func_app-2 (test.toml) | 1696 | 1472 | 13.21% | | should_pass/static_analysis/cei_pattern_violation_in_func_app-3 (test.toml) | 1696 | 1472 | 13.21% | | should_pass/static_analysis/cei_pattern_violation_in_if_statement-1 (test.toml) | 1720 | 1496 | 13.02% | | should_pass/static_analysis/cei_pattern_violation_in_if_statement-2 (test.toml) | 1696 | 1472 | 13.21% | | should_pass/static_analysis/cei_pattern_violation_in_intrinsic_call (test.toml) | 1696 | 1472 | 13.21% | | should_pass/static_analysis/cei_pattern_violation_in_match_statement-1 (test.toml) | 2200 | 1984 | 9.82% | | should_pass/static_analysis/cei_pattern_violation_in_standalone_function (test.toml) | 1472 | 1248 | 15.22% | | should_pass/static_analysis/cei_pattern_violation_in_struct (test.toml) | 1720 | 1504 | 12.56% | | should_pass/static_analysis/cei_pattern_violation_in_tuple (test.toml) | 1720 | 1504 | 12.56% | | should_pass/static_analysis/cei_pattern_violation_in_while_loop-1 (test.toml) | 1696 | 1472 | 13.21% | | should_pass/static_analysis/cei_pattern_violation_in_while_loop-2 (test.toml) | 1704 | 1480 | 13.15% | | should_pass/static_analysis/cei_pattern_violation_in_while_loop-3 (test.toml) | 1696 | 1472 | 13.21% | | should_pass/static_analysis/cei_pattern_violation_in_while_loop-4 (test.toml) | 1704 | 1480 | 13.15% | | should_pass/static_analysis/cei_pattern_violation_more_complex_logic (test.toml) | 12928 | 12552 | 2.91% | | should_pass/static_analysis/cei_pattern_violation_storage_map_and_vec (test.toml) | 4752 | 4584 | 3.54% | | should_pass/static_analysis/cei_pattern_violation_storage_struct_read (test.toml) | 1720 | 1504 | 12.56% | | should_pass/static_analysis/cei_pattern_violation_storage_var_read (test.toml) | 2072 | 1856 | 10.42% | | should_pass/static_analysis/cei_pattern_violation_storage_var_update (test.toml) | 1608 | 1392 | 13.43% | | should_pass/stdlib/storage_vec_insert (test.toml) | 3264 | 3096 | 5.15% | | should_pass/storage_into (test.toml) | 1688 | 1472 | 12.80% | | should_pass/supertraits_for_abis_ownable (test.toml) | 3440 | 2920 | 15.12% | | should_pass/test_contracts/basic_storage (test.toml) | 29288 | 28184 | 3.77% | | should_pass/test_contracts/increment_contract (test.toml) | 2848 | 2680 | 5.90% | | should_pass/test_contracts/storage_access_contract (test.toml) | 24160 | 23336 | 3.41% | | should_pass/test_contracts/storage_enum_contract (test.toml) | 13440 | 12952 | 3.63% | | should_pass/test_contracts/storage_namespace (test.toml) | 28376 | 27296 | 3.81% | ### Comparing 'in-language-gas-usages': | Test | Before | After | Percentage | |------|-------:|------:|-----------:| | storage_vec_iter_tests::empty_vec_next_returns_none | 55456 | 52550 | 5.24% | | storage_vec_iter_tests::storage_vec_field_for_loop_iteration | 1619781 | 1584251 | 2.19% | | storage_vec_iter_tests::storage_vec_field_nested_for_loop_iteration | 11924960 | 11630896 | 2.47% | | storage_vec_iter_tests::vec_with_elements_for_loop_iteration | 24591048 | 24107244 | 1.97% | | storage_vec_iter_tests::vec_with_elements_next_returns_element | 24586261 | 24104972 | 1.96% | ## 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). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] 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). - [x] I have requested a review from the relevant team or maintainers. |
||
|
|
6bca1885f9
|
Improve method selector on contracts (#7458)
Some checks are pending
CI / forc-unit-tests (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 / 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 (push) Blocked by required conditions
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-pkg-fuels-deps-check (push) Waiting to run
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 / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
## Description This PR continues the optimisation of contract calls on top of https://github.com/FuelLabs/sway/pull/7455. Now the contract method selector is optimised. Ideally, the method selection would just be a `match` and we would let the compiler generate the best code. But we are not there yet. So, for now, we are going to first test the called method length. And based on its length we are going to check the whole string. Something like: ```sway if called_method.len() == 5 { if called_method == "abcde" { ... } if called_method == "fghij" { ... } } if called_method.len() == 10 { if called_method == "..." { .... } } ``` This alone reduces gas a lot. To understand why `match_expressions_all` gas usage is much worse see below. | Test | Before | After | Percentage | |------|--------|-------|------------| | should_pass/empty_fields_in_storage_struct (test.toml)::test_read_write_bytes | 17533 | 12080 | 31.10% | | should_pass/empty_fields_in_storage_struct (test.toml)::test_read_write_map | 13986 | 8502 | 39.21% | | should_pass/empty_fields_in_storage_struct (test.toml)::test_read_write_vec | 29288 | 12797 | 56.31% | | should_pass/language/associated_const_abi (test.toml)::test | 7817 | 4547 | 41.83% | | should_pass/language/associated_const_abi_multiple (test.toml)::test | 2097 | 1511 | 27.94% | | should_pass/language/associated_const_in_decls_of_other_constants (test.toml)::test | 709 | 537 | 24.26% | | should_pass/language/contract_ret_intrinsic (test.toml)::test | 1809 | 1465 | 19.02% | | should_pass/language/match_expressions_all (test.toml) | 764 | 3708 | -385.34% | | should_pass/language/pusha_popa_multiple_defreg (test.toml)::incorrect_pusha_popa | 624 | 451 | 27.72% | | should_pass/language/raw_identifiers (test.error_type.toml)::test | 1075 | 903 | 16.00% | | should_pass/language/raw_identifiers (test.toml)::test | 1075 | 903 | 16.00% | | should_pass/language/references/mutability_of_references_memcpy_bug (test.toml)::test | 1203 | 1031 | 14.30% | | should_pass/language/slice/slice_contract (test.toml)::test_success | 1145 | 920 | 19.65% | | should_pass/language/string_slice/string_slice_contract (test.toml)::test_success | 1322 | 1079 | 18.38% | | should_pass/stdlib/storage_vec_insert (test.toml)::test_test_function | 3831 | 3669 | 4.23% | | should_pass/storage_element_key_modification (test.toml)::test_storage_key_address | 1138 | 943 | 17.14% | | should_pass/storage_element_key_modification (test.toml)::test_storage_key_modification | 757 | 465 | 38.57% | | should_pass/storage_slot_key_calculation (test.toml)::test | 2979 | 2785 | 6.51% | | should_pass/superabi_contract_calls (test.toml)::tests | 1812 | 1310 | 27.70% | | should_pass/superabi_supertrait_external_call (test.toml) | 95 | 76 | 20.00% | | should_pass/superabi_supertrait_same_methods (test.toml)::tests | 936 | 634 | 32.26% | | should_pass/test_abis/abi_impl_methods_callable (test.toml)::tests | 772 | 599 | 22.41% | | should_pass/test_abis/contract_abi-auto_impl (test.toml)::tests | 772 | 599 | 22.41% | | should_pass/unit_tests/aggr_indexing (test.toml)::test1 | 5443 | 4282 | 21.33% | | should_pass/unit_tests/contract-multi-contract-calls (test.toml)::test_contract_2_call | 804 | 631 | 21.52% | | should_pass/unit_tests/contract-multi-contract-calls (test.toml)::test_contract_call | 807 | 634 | 21.44% | | should_pass/unit_tests/contract-multi-contract-calls (test.toml)::test_contract_multi_call | 1592 | 1246 | 21.73% | | should_pass/unit_tests/contract_multi_test (test.toml)::test_fail | 808 | 635 | 21.41% | | should_pass/unit_tests/contract_multi_test (test.toml)::test_success | 806 | 633 | 21.46% | | should_pass/unit_tests/script-contract-calls (test.toml)::test_contract_call | 736 | 563 | 23.51% | | should_pass/unit_tests/workspace_test (test.toml)::test_fail | 808 | 635 | 21.41% | | should_pass/unit_tests/workspace_test (test.toml)::test_success | 807 | 634 | 21.44% | # Radix Trie This PR also turns off the radix trie optimisation at `sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/typed_match_expression.rs`. I am not 100% sure of its correctness and heuristics. We need a better way to decide when not to use it. One of the examples where the generated code is worse is when all strings are very similar. For example: `get_a` , `get_b`. The generated trie will first test its length. Both have length 5. Not much was gained. Then it tests if for `get_`, which makes sense as it is the common substring. And the last step will test for `a` or `b`. The issue is that all branches and jumps of the last step are not worthy to test just one character. Is probably cheaper to just test the whole string for each option. In the end, we need a better heuristic to determine when to use this optimisation. ## 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. --------- Co-authored-by: Joshua Batty <joshpbatty@gmail.com> |