## Description
Bumps fuel-rs to v0.64.0 to support fuel-core v0.28.0. No need to cut a
release for now, as we probably want to bump to v0.30.0. That is blocked
for now as sdk v0.65.0 is not released yet.
## Description
Fixes Clippy warnings after updating to the latest stable Rust toolchain
(1.79).
## 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.
## Description
This cleans up `DeclRef` references from `TypeInfo::Enum` and
`TypeInfo::Struct`, which both will allows us to long-term get rid of
the unnecessary and unperformant `DeclRef` abstraction. I'm touching
this to allow subsequent usage of `ResolvedDeclaration` in its place in
a future PR, so decided to go ahead and do this cleanup while at it.
## 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.
## Description
https://app.warp.dev/block/iedebqr2dgZIuM5N0ZNlkU
## 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.
## Description
fix some comments
## 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.
Signed-off-by: tsinghuacoder <tsinghuacoder@icloud.com>
## Description
This PR revamps how configurables are accessed when encoding v1 is used.
Any changes for configurables with encoding v0 should be treated as
bugs.
After encoding V1 was merged, every single time you accessed a
configurable, we would "decode it". Apart from obvious performance
problems, this also introduced semantic problems: two different
references, would not point to the same memory address, which is
something one would expect from sway syntax.
This was addressed in four steps:
1 - Configurable lowering to IR now comes with more data, The IR below
is for a simple `u8` configurable named `U8`.
```
U8 = config u8, abi_decode_in_place_50, 0x01, !15
```
1.1 - config name comes from the configurable itself (before it was
auto-named as `c0`, `c1` etc...);
1.2 - config type correctly follows the configurable type (after
encoding v1, it was always byte slice);
1.3 - there is a new decode function that will be called to initialize
this configurable (more details below);
1.4 - at last, we have the encoded bytes of the configurable value.
2 - This PR also splits `TyConfigurableDecl` from `TyConstantDecl`, and
`ConfigurabletExpression` from `ConfigurableExpressions`.
This is needed because we now compile `ConfigurableExpression` to a new
IR instruction called `get_config`, which is similar to `get_local`. So
a reference to a `configurable` will be compiled into:
```
v0 = get_config ptr bool, BOOL, !261
v1 = load v0
```
3 - Given that `config`s are not writeable, and there is no way to set
their value in IR, this is done when we lower IR to ASM, more
specifically we are using a new ASM section called "globals", which are
the writeable counterpart of the read-only data section.
The physical difference is that the read-only data section is appended
at the end of the final binary which puts all the data sections outside
of the writeable memory; To circumvent this and enable some globals to
be writeable, we need to allocate them in the stack (the only writeable
memory inside FuelVM). So, as soon as possible we allocate space for all
globals with `cfei`, but we do not initialize them in any way, shape or
form. We cannot expect their value to be zero!
In one of our tests, this is the allocation that is generated:
```
cfei i190 ; stack space for globals
```
After this, for each `config`, the following virtual ASM is appended to
the prologue (before the `__entry` fn).
```
addr $$arg0 data_0 ; ptr to ANOTHER_U8 default value
addi $$arg1 $zero i1 ; length of ANOTHER_U8 default value
addi $$arg2 $ssp i0 ; ptr to global ANOTHER_U8 stack address
mova $$reta .72
fncall .0 ; decode ANOTHER_U8
.72
```
There are two interesting parts here:
3.1 - There is a new `addr` virtual ASM opcode that returns the address
of an item in the data section, in this case, it is the `config` encoded
bytes.
3.2 - The address where the `config` lives in runtime is calculated at
compile time and it is represented as `addi $$arg2 $ssp i0`. In this
case, the first `config` is at `$ssp + 0`. The second one will packed
after the first, and so on. They are NOT aligned.
The final FuelVM bytecode is as packed as one could expect:
```
0x00000018 CFEI 0xbe ;; [145, 0, 0, 190] <- allocate globals at the stack
0x0000001c ADDI R58 R63 0x0 ;; [80, 235, 240, 0] <- initialize the first config
0x00000020 ADDI R57 $zero 0x1 ;; [80, 228, 0, 1]
0x00000024 ADDI R56 $ssp 0x0 ;; [80, 224, 64, 0]
0x00000028 SUB R62 $pc $is ;; [32, 248, 51, 0]
0x0000002c SRLI R62 R62 0x2 ;; [88, 251, 224, 2]
0x00000030 ADDI R62 R62 0x4 ;; [80, 251, 224, 4]
0x00000034 JMPF $zero 0x19b ;; [116, 0, 1, 155]
0x00000038 ADDI R58 R63 0x8 ;; [80, 235, 240, 8] <- initialize the second config
0x0000003c ADDI R57 $zero 0x3 ;; [80, 228, 0, 3]
0x00000040 ADDI R56 $ssp 0x1 ;; [80, 224, 64, 1]
0x00000044 SUB R62 $pc $is ;; [32, 248, 51, 0]
0x00000048 SRLI R62 R62 0x2 ;; [88, 251, 224, 2]
0x0000004c ADDI R62 R62 0x4 ;; [80, 251, 224, 4]
0x00000050 JMPF $zero 0x1d8
```
# Major code changes
1 - I had to split Constant and Configurable. This happened in both AST
and the typed tree.
2 - I completely removed `Configurable` and a possible IR value. As a
matter of fact, configurables do not exist in IR. We do have the concept
of `config`, which only exists in two forms: the `config` declaration,
and the `get_config` instruction.
3 - I moved the folder "programs" to inside "fuel" because they were not
being used for other targets. I have also move the abstraction of
targets away from them to the function
`compile_ir_context_to_finalized_asm`. So the lowering from IR to asm is
generic on the target as before, but the intermediary data are specific
to each target.
The only "leak" is `InstructionSet`, which still is a `enum` with a
variant for each target. I have changed this as this PR does not need
it. But I think would make sense for its parent structure
`FinalizedAsm`, to be target ignorant.
4 - I have also improved bytecode printing as shown above. Not we print
the FuelVM instruction, registers and arguments, together with the
binary in a more readable form. Together with absolute address.
5 - Up until now, all the compilation of `sway` to IR was done from the
entry function. Any code not reachable from here would not be in the
final binary. That was also true for how the suffix "_0", "_1" etc...
was inserted. They were chosen as these functions were being called.
This created a problem because the configurable initialization was not
necessarily also called in normal sway code. For this, I started to also
use the `config` decode fn field as entry functions. To avoid these two
generating colliding suffixes, I move the shared code into
`CompiledFunctionCache`. This "cache" is something that we should
revisit soon, but I left it untouched for now.
## Internal Debugging
We have some very hard to debug algorithms. I tend to leave some
commented code when I find a good place and a good "print" that helps to
debug these parts. For example:
```
// Uncomment to debug what this optimization is doing
```
We may want to find a better solution for this. Maybe a combination of
cargo feature and environment variable that prints these debugging
snippets.
I am fine with removing them for now, but I think they would be very
helpful, not only for debug, but also for snapshot tests in the future.
## Binary Size
Since the introduction of encoding v1 for configurable, the binary size
of
`test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts`
has exploded. Before it was around 5k, and skyrocketed to 14k. This PR
alleviates this a little bit, and brings it back to 10k.

## 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.
## Description
Closes https://github.com/FuelLabs/sway/issues/5968
Adds a new "Primitive" type in the sidebar and to the search bar. The
descriptions are hard coded since there is nowhere to parse the
documentation from. The list of primitives is also hardcoded, so we will
need to update forc-doc if/when new primitives are added to the
language.
Primitives will be documented show up in the side bar for any package
that has implementations for a primitive. This is why it currently shows
up for both std and core.
Side bar nav:

Search bar:

## 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)
- [ ] 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.
---------
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
Updates the error message to be more helpful when `forc build` is run
and the Forc.toml contains an invalid reference (i.e. bad git
branch/tag/rev). Also updates `forc-fmt` to use `println_error` for
consistent error display with the rest of forc.
## Description
Fixes some comments and panic messages grammatically.
Signed-off-by: cuishuang <imcusg@gmail.com>
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
Co-authored-by: Kaya Gökalp <kaya.gokalp@fuel.sh>
Without function deduplication, the heuristic that we have for inlining
"if a function is called only once, inline it" isn't good enough because
identical functions, after they're combined into one will have multiple
callers, which wouldn't be so without fndedup.
---------
Co-authored-by: Sophie <sophiedankel@gmail.com>
## Description
Closes https://github.com/FuelLabs/sway/issues/6018
Makes trait & inherent implementations show up for enums now:

And makes the sidebar include links to the impls:

## 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: Joshua Batty <joshpbatty@gmail.com>
## Description
Bumps:
1. fuels-rs v0.62.0
2. forc-wallet to v0.7.1
3. fuels-abi-types to v0.5.0
In the process I had to adjust forc-run to use new encoding api from the
sdk as well.
## Description
This PR:
- implements detailed control over printing of IR:
- initial IR
- IR after choosen optimization steps, with option to print only the
steps that have actually modified the IR
- final IR
- improves printed IRs by removing the confusing empty modules printed
for every external library dependency.
- harmonizes names and descriptions of the optimization passes. The
proposed convention is documented in the
_sway-ir/src/optimize/README.md_ file.
- harmonizes help comments of the shared compiler options (consistent
separation between option title and additional info, wording, etc.)
## Demo
```
'Print initial and final IR together with IR after each optimization step.
--ir all
'Print initial and final IR together with IR after each optimization step that has modified the IR.
--ir all modified
'Print only the final IR.
--ir final
'Print the IR after every "dce", "sroa", and "inline" optimization step.
--ir dce sroa inline
'Print the IR after every "dce", "sroa", and "inline" optimization step that has modified the IR.
--ir dce sroa inline modified
```
## Breaking Changes
### CLI
Instead of the existing `--ir` option without parameters we now have the
same CLI option but with parameters. The existing `--ir` is equivalent
to the new `--ir final`.
### Build Profile
Instead of the existing `print-ir` of type bool, we now have the same
`print-ir` build profile option with parameters. E.g.:
```
print-ir = { initial = true, final = false, modified = true, passes = ["dce", "sroa"]}
```
## Checklist
- [ ] 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.
## Description
Closes https://github.com/FuelLabs/sway/issues/5957
Also tweaked the CSS to make:
- the subheaders inside of implementations smaller than the impl header
- the colors a little less stark
- the impl toggle blocks open by default (same as crates.io)
Discovered two issues, relating to enums and the sidebar, which I'll
solve separately: https://github.com/FuelLabs/sway/issues/6018

## 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: Joshua Batty <joshpbatty@gmail.com>
## Description
Changes the target of `--testnet` flag to testnet instead of devnet.
Also fixes some missing from end point url conversions for target
resolving.
---------
Co-authored-by: Sophie <sophiedankel@gmail.com>
## Description
Update clap and deps to latest version
## 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.
## Description
Estimation is hard to test as it is dependent on the network
configuration but this is nearly the same thing we have been doing for
scripts.
1. `--testnet` points to devnet.
2. For the new `max_fee` requirement, adds an estimation phase with dry
runing the transaction
3. Various consts are pointed to relevant devnet endpoints.
Most visible outcome is that `forc-deploy --testnet` can deploy to
devnet without any other flags etc.
---------
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
## Description
This PR simplifies and gives more control ove printing the ASM. It's a
first step in harmonizing printing options for ASM and IR, where the
goal is to be able to print arbitrary optimization passes in IR.
This PR:
- replaces two existing, verbose and unintuitive to discover, ASM
printing CLI options with a single `--asm`, same as the single `--ir`
option.
- improves printed ASM by removing the confusing empty programs printed
for every external library dependency.
- harmonizes printed virtual and allocated abstract ASM to have the
same-looking comments and structure.
Additionally, the PR fixes the bug in the
`PassManager::insert_after_each` helper function, where passes were not
inserted within groups. This is a preparation step for the changes
needed for improving the `--ir` CLI option.
## Demo
```
--asm all 'Prints virtual, allocated, and final ASM.
--asm final 'Prints only the final ASM.
--asm allocated final 'Prints the allocated and the final ASM.
```
## Breaking Changes
### CLI
Instead of existing `--intermediate-asm` and `--finalized-asm` options
we now have a single `--asm` CLI option with parameters. The existing
options should be replaced:
| Current | New |
| - | - |
|`--intermediate-asm`|`--asm abstract`|
|`--finalized-asm`|`--asm final`|
|`--intermediate-asm --finalized-asm`|`--asm all`|
### Build Profile
Instead of existing `print-intermediate-asm` and `print-finalized-asm`
options we now have a single `print-asm` CLI option with parameters.
E.g.:
```
print-asm = { virtual = true, allocated = true, final = true }
```
## Checklist
- [ ] 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)
- [ ] 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.
## Description
This PR uses `AbiEncode` on configurables. We can imagine that
```sway
configurable {
SOMETHING: u64 = 1
}
fn main() -> u64 {
SOMETHING
}
```
will be desugared into
```sway
configurable {
SOMETHING: slice = encode(1)
}
fn main() -> u64 {
abi_decode(SOMETHING)
}
```
To allow this, now the whole `encode` function and all trait impls run
inside `const_eval`. To make this work, three new intrinsic were
implemented: `EncodeBufferEmpty`, `EncodeBufferAppend`, and
`EncodeBufferAsRawSlice`.
`EncodeBufferEmpty` creates an empty "encoding buffer", which is
composed of a pointer to the buffer, the buffer capacity, and how many
bytes were written already.
`EncodeBufferAppend` appends any primitive data types to the buffer.
This intrinsic does not mutate its argument, it returns a new "encoding
buffer". If no reallocation is needed, the pointer and the capacity stay
the same.
`EncodeBufferAsRawSlice` returns a slice with is composed of the buffer
pointer and its length (not the capacity).
### Errors
Some constant expressions cannot live inside the data section because
their encoding depends on some instance value, for example: string
slices, Vecs, Sttrings, Bytes etc... For these we now we return an error
in these cases, like
```
error
--> /home/xunilrj/github/sway/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/src/main.sw:33:5
|
31 |
32 | C6: str[4] = __to_str_array("fuel"),
33 | C6_2: str = "fuel as str",
| ^^^^ This code cannot be evaluated to a configurable because its size is not always limited.
34 | C7: [u64; 4] = [1, 2, 3, 4],
35 |
|
____
```
## Future TODOs
This PR adds two more tasks to
https://github.com/FuelLabs/sway/issues/5727:
- Enable sdk-harness tests that were ignore. SDK needs to update
configurable encoding.
- Correctly error when a type with custom impl for AbiEncode is used in
configurables
- avoid decoding on each use
## 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>
## Description
Base asset ids are dynamic for the newer fuel-core versions. This PR
adds capability to query that and use it for forc-client transactions.
Also adds a flag `max-fee` which is required to be set for newer
versions of fuel-core.
## Description
Bumps fuel-core to v0.26.0, for some reason sway-core was failing and
needed a blanket implementation for `Vec<T: PartialEqWithEngines>`
## Description
Just some cleaning up to make it easier to have a dedicated tests folder
with specific sway project fixtures. Similar to how sway-lsp is set up.
## 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.
## Description
Adds a CI check for typos and fixes all* typos in code, comments, and
docs.
*found by [typos-cli](https://github.com/crate-ci/typos)
`typos` doesn't catch everything, but it seems to work better than
codespell and cargo-spellcheck (fewer false positives).
## 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.
## Description
This PR fixes a bunch of issues we had in generating access to the data
section. It also fixes#5876.
Reverts #5918.
---------
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
This PR cleans up the `ty::TyDecl` struct by removing fields for
duplicated data that we already have access through the engines. Have
not measured the true impact of this, but should have a noticeable
performance and especially memory improvement.
## 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] 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: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
There's still a ton more to do but going to open this to get merged to
avoid conflicts. We can possibly add in some of these rules into CI in a
future 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.
## Description
This PR sets the "new encoding" (from now on will be called "encoding
v1") as the default. We can still disable it using `no_encoding_v1`,
which switches back to "encoding v0".
Actions that needs to be done after this being merged will exist in
https://github.com/FuelLabs/sway/issues/5727
New features
- ABI Super traits;
- AbiEncode buffer dynamic sizing;
Bugs Fixed
- `ContractCall` intrinsic interaction effect was not set correctly;
Fixing warnings and error messages
- Better error message when core-lib is not available for
scripts/contracts/predicates;
- Better error message when main inputs/outputs are unknown or error
types;
- Better error message when main inputs/outputs do not implement
AbiEncode/AbiDecode;
- Don't warn impurity attributes on the "__entry" fn;
- Don't warn CEI on the "__entry" fn. Our CEI analysis, currently, does
not recognize `Never`. This means it does not realize it is impossible
to call two contract functions;
Test Disabled (needs to be enabled again in the future)
- should_pass/language/name_resolution_after_monomorphization
- should_pass/language/shadowing/shadowed_glob_imports
- should_pass/language/name_resolution_inside_intrinsics
- sdk-harness/external_proxy test is not working. I am assuming it is
the LDC bug that is already fixed on version 0.25. What is happening is
that the literal "double_value" has the correct length, but some random
data. Which makes the method selector fails. Only after we call LDC. The
proxy contract is working.
Test generating more warnings than before
- should_pass/dca/contract/superabi_contract_calls
What happens here is that when we implement a trait for `Contract`, we
actually generate two functions: one prefixed `__contract_entry` that is
called by the method selector; and another one normal, that can be
called freely. So, if the trait method is never called manually, it is
marked as dead.
- should_pass/dca/contract/abi_fn_params
I actually think the new warning is correct and nothing here needs to be
done.
Test with fewer warnings than before
- should_pass/dca/unused_fields
auto-impl is making all fields being used. so no dead code warnings are
being generated. We need to fix this.
Changes to std-lib
- Functions that return data about call context changed the semantic.
`first_param` and `second_param` return the value as the VM sees them.
We now have `called_method` and `called_args`. This means that we can
change the protocol later and still keep these four functions always
working and with meaningful names.
-
- predicate_data also was updated to use encoding v1 protocol.
ICE
- increase_buffer_if_needed implementation is a little bit strange
because does not work as a method inside `Buffer`. For some reason, it
is generating an ICE. I need to create an issue so we can fix, and
improve the implementation here.
- `Buffer` used by AbiEncode needs a `push_bytes` so we can be more
efficient when encoding Bytes and others.
## 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.
## Description
This PR prepares existing code that deals with (mutable) access to
namespace modules to work with an upcoming PR that introduces a module
ID for optimization purposes.
It also refactors the ABI code to pass engines around, which is
necessary for the same PR.
## 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: Joshua Batty <joshpbatty@gmail.com>
## Description
This fixes https://github.com/FuelLabs/sway/issues/5474
This is the first part of #5612, which will be split into several
smaller PRs
## 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] 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.
## Description
Typo fix. It should say beta-5
## Checklist
- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](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: phiberdev <phiberdev@users.noreply.github.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
## 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] 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.
Signed-off-by: thirdkeyword <fliterdashen@gmail.com>
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
This PR adds support to express line number mapping from assembly to
source using DWARF object files. Since there are offset details that are
specific to the Fuel ISA, I'm using the existing `SourceMap` that's
already being built, rather than generating directly from the
instructions.
An important point to note is that DWARF uses line-col to express
positions rather than an absolute offset-from-start format. To avoid
computing line-col from absolute positions (which requires re-reading
the source files), I'm changing the source position format everywhere to
line-col. This also simplifies our code at many places (for example, in
`forc-debug`). The only exception is the `addr2line` tool, where the use
of absolute positions is in a function that seemed quite complex to me
to attempt changes. So I have, temporarily, added code to compute
absolute positions from line-col information and then reuse the existing
functions. This is inefficient, but I think that's _okay_ since it's a
standalone tool and the whole thing runs just once for every command
invocation.
The DWARF information is written to a file specified by the `-g` flag
and can be verified using `llvm-dwarfdump --debug-line ./test.obj`. If
the argument to the `-g` flag is a filename that ends with `.json`, then
the existing JSON format is written out, otherwise it's a DWARF object
in an ELF container.
---------
Co-authored-by: Joao Matos <joao@tritao.eu>
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>