## Description
This PR fix predicate entry function decoding arguments.
## 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.
## Description
Fixes#5633
Added functionality to create and manage a lock file containing the
process ID (pid) of the running instance of the software. This mechanism
prevents multiple instances of the software from running simultaneously
by checking the existence and content of the lock file. If the lock file
exists and contains a valid pid, the struct will error gracefully to
avoid conflicts. If the lock file is missing or contains an invalid pid,
the struct will proceed by removing the file. This ensures that only one
instance of the software can run at a time and it avoids stale locking
to prevent future instances
## 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
This PR implements the new encoding for contracts/scripts/predicates.
https://github.com/FuelLabs/sway/issues/5512 and
https://github.com/FuelLabs/sway/issues/5513
### Contract Calls
When the new encoding is turned on using `--experimental-new-encoding`,
contract calls like the example below will be "desugarized" differently
now.
```sway
let base_asset_id = BASE_ASSET_ID;
let other_contract_id = ContractId::from(0xa38576787f8900d66e6620548b6da8142b8bb4d129b2338609acd121ca126c10);
let test_contract = abi(ContextTesting, other_contract_id.into());
let returned_contract_id = test_contract.get_id { gas: gas, coins: 0, asset_id: BASE_ASSET_ID.value}(1, 2, 3);
```
and will be transformed to
```sway
let base_asset_id = BASE_ASSET_ID;
let other_contract_id = ContractId::from(0xa38576787f8900d66e6620548b6da8142b8bb4d129b2338609acd121ca126c10);
let test_contract = abi(ContextTesting, other_contract_id.into());
let returned_contract_id = contract_call::<ContractId, _>(other_contract_id.into(), "get_id", (1, 2, 3), coins, asset_id, gas);
```
And the important part is the `contract_call` function in the std
library. This function does all the encoding as necessary and delegates
the actual call to an intrinsic function `__contract_call`. Allowing the
protocol to evolve entirely in Sway.
```sway
pub fn contract_call<T, TArgs>(contract_id: b256, method_name: str, args: TArgs, coins: u64, asset_id: b256, gas: u64) -> T
where
TArgs: AbiEncode
{
let first_parameter = encode(method_name);
let second_parameter = encode(args);
let params = encode(
(
contract_id,
asm(a: first_parameter.ptr()) { a: u64 },
asm(a: second_parameter.ptr()) { a: u64 },
)
);
__contract_call::<T>(params.ptr(), coins, asset_id, gas)
}
```
### Contracts
On the other side, when the flag `--expiremental-new-encoding` is turned
on, the contract specification like the one below is being transformed
into all the decoding and encoding necessary.
The mains points are:
- The compiler generates a function called `__entry` that decodes the
method name and its arguments. The method is selected with a bunch of
`if`s at the moment, because we don´t have `match` for string slices.
Then we `decode` the arguments using the correct type, which is a tuple
with all the function arguments, and expand this tuple calling the
function;
- All the contract functions are converted to global functions prefixed
with `__contract_method`;
- Results are encoded and returned using the intrinsic call `__retd`.
Example:
```sway
abi SomeContract {
fn some_function(a: u64) -> u64;
}
impl SomeContract for Contract {
fn some_function(a: u64) -> u64 {
1
}
}
```
will be transformed into
```sway
fn __entry() {
let method_name = decode_first_parameter();
if method_name == "some_function" {
let args = decode_second_parameter::<(u64,)>();
let result = __contract_method_some_function(args.0);
__retd(encode(result));
}
__revert(0);
}
```
### Scripts and Predicates
The protocol to call scripts and predicates will also change and will be
very similar to contracts. See more above. Now when the flag is turned
on, the `main` function will not be entry point anymore. The compiler
will actually generate an `__entry` function that will decode arguments
and encode the result, like contracts.
For example:
```sway
fn main(a: u64) -> u64 {
1
}
```
will be transformed into
```sway
fn __entry() {
let args = decode_script_data::<(u64,)();
let result = main(args.0);
__retd(encode(result));
}
fn main(a: u64) -> u64 {
1
}
```
## Tests
To facilitate testing this PR introduces three changes to our test
harness:
1 - A new parameter can be called to update test output files (abi and
storage json). This facilitates when we only want to copy and paste
these output files to their respective oracles. Brings the framework
closer to a snapshot one.
```
> cargo r -p test --release -- --update-output-files
```
2 - Depending on the configuration at `test.toml` multiple executions of
the same test will be scheduled. At the moment, tests that depend on the
encoding will run with the `--experimental-new-encoding` flag
automatically. For example:
```
Testing should_pass/language/main_args/main_args_copy_copy ... ok
Testing should_pass/language/main_args/main_args_copy_copy (New Encoding) ... ok
```
3 - A new `script_data_new_encoding` was created because we want to
support and run tests with the two encoding for a time. This is also
what flags tests to run with the flag on automatically.
## 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
Implements `--version` for forc-debug, so that fuelup can show the
version.
## 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.
## Description
## 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: Joshua Batty <joshpbatty@gmail.com>
## Description
Closes https://github.com/FuelLabs/sway/issues/5637
## 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.
## Description
This test is failing on PRs. Disabling for now while I investigate the
root cause.
## 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.
## Description
Related https://github.com/FuelLabs/sway-vscode-plugin/pull/166
Adds a [DAP](https://microsoft.github.io/debug-adapter-protocol//)
server as a new forc plugin, `forc-debug`. This enables a UI debugging
experience in IDEs such as VSCode.
For now, only debugging forc tests is supported. Users can:
- set breakpoints inside of forc tests
- step through the test, one VM instruction at a time, or continue to
the next breakpoint
- debug through multiple tests sequentially
- see the VM register values in the IDE while debugging
- see the current VM opcode, its inputs, and/or immediate value when
when the VM is stopped
### Screenshots
24e2016c-d96c-4ef6-931f-8a4ce4f1386b
5f0fed49-b278-4074-a1a1-d37de00776f8

### Local testing
1. Install `forc-debug`
2. Copy this sample launch.json in the VSCode workspace with sway code
to debug:
```json
{
"version": "0.2.0",
"configurations": [
{
"type": "sway",
"request": "launch",
"name": "Debug Sway",
"program": "${file}"
}]
}
```
3. Follow [the
steps](https://github.com/FuelLabs/sway-vscode-plugin/blob/master/docs/testing.md)
for testing the VSCode extension
### Limitations
- Breakpoints only work inside of the project/workspace being debugged
- Stack trace support is limited
- Not every line has source maps. Once debugging, "verified" breakpoints
will show red and "unverified" (no source maps) will be greyed out.
- Watch/repl expressions are not yet supported
- Step into/out of is not supported
- If you click "step over" many times in rapid succession, the server
takes a while to catch up.
Closes https://github.com/FuelLabs/sway/issues/5394
## 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).
- [ ] 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: Vaivaswatha Nagaraj <vaivaswatha.nagaraj@fuel.sh>
Co-authored-by: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: João Matos <joao@tritao.eu>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: Igor Rončević <ironcev@hotmail.com>
Co-authored-by: Sudhakar Verma <10460978+sudhackar@users.noreply.github.com>
Co-authored-by: Marcos Henrich <marcoshenrich@gmail.com>
Co-authored-by: jjcnn <38888011+jjcnn@users.noreply.github.com>
## Description
We now parse the `!` as a TypeInfo::Never, and remove the usage of empty
enums as Never type in our code.
This commit removes completely the DeterministicallyAborts and
TypeCheckUnificationContext.
The DeterministicallyAborts can be removed because the Never TypeInfo is
now propagated using the type checker. Code blocks that return, break,
continue, or call an expression that returns Never, are marked as Never.
Partially fixes#5562.
## 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
Closes https://github.com/FuelLabs/sway/issues/5607
Solves part [1] of https://github.com/FuelLabs/sway/issues/5607 by
making "release" the default build plan for forc-deploy. It can still be
overridden, i.e. for the test harness.
Other changes:
- removed the `--release` and `--error-on-warnings` options from
forc-deploy, since those aren't needed.
- refactored `BuildProfile` into its own file and added a test, since I
noticed some of the options weren't deserializing
## 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).
- [ ] 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
Add macro to test argument parsing rather than testing the external
command through building and spawning a separated process. This is an
improved version of #5519
## 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
This PR does 3 optimizations. The timings below are measured against the
LSP benchmarking project.
1. Disable running DCA & control flow analysis, for did_change events
`39.544ms`
2. Disable running collect_types_metadata for did_change events
`3.522ms`
3. Only write the diagnostics res to self.diagnostics.write() on
did_open & did_save `21.135ms`
I also had to increase the frequency that we are calling GC to every 3rd
keystroke as during stress tests I was occasionally getting stack
overflows otherwise.
related to #5445
## 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).
- [ ] 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 introduces a new `ParsedDeclEngine` which acts as the storage
place for parsed declarations. This is basically a clone of `DeclEngine`
but only used for untyped parsed declarations.
Declarations stored in this new engine are referenced by a
`ParsedDeclId` which again is analogous to our existing `DeclId`.
The rationale for introducing this is to be able to reference parsed
declarations during a multi-stage semantic analysis / type-checking
process. A cross-referencing mechanism between untyped/typed AST
declarations will still need to be implemented.
Just to note, `rustc` provides a similar architecture with their
`NodeId` / `DefId`, which provide a similar role to our `ParsedDeclId` /
`DeclId`, except we only support storing top-level AST entities, whereas
the system in Rust from what I understand can also be used to reference
individual expressions.
## 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
This PR is a continuation of https://github.com/FuelLabs/sway/pull/5306.
- I am fixing some code reviews issues that were raised in the other PR;
- I am incorporating the encoding version inside the JSON ABI as:
```json
{
"configurables": [],
"encoding": "1", <- look here
"functions": [
{
"attributes": null,
"inputs": [],
"name": "main",
"output": {
"name": "",
"type": 13,
"typeArguments": null
}
}
],
```
This field is a string to allow any kind of versioning we choose.
- This PR has also improved testing and making more explicit how each
type is being encoded.
## Dependencies
- [x] https://github.com/FuelLabs/fuel-abi-types/pull/17
## 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
Add recover-public-key to forc-crypto
This function is ported from
https://github.com/FuelLabs/forc-wallet/pull/152
This PR depends on #5388
## 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.
Fixes#5436
## Description
Replace chained `filter` and then `map` calls for a single `filter_map`
calls and other minor optimizations
## 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
Bumps repo to 0.49.0, made this a major one after some thought as we
longer support beta-4 as tooling with this release.
Also ran `cargo update` as this is a breaking change
---------
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
related to #5463
Fixes std dependency on released std for forc-doc, forc-fmt and forc-tx
test projects used in cli tests which breaks release structure.
## Description
This PR changes the output of `__log` to encoded values (see
https://github.com/FuelLabs/sway/issues/4769). A quick example of what
that means is
```sway
struct S {
a: u64,
b: u32,
c: u16,
d: u8,
e: Vec<u64>,
f: str,
g: u256
}
let mut e = Vec::new();
e.push(1);
e.push(2);
e.push(3);
__log(S{
a: 1,
b: 2,
c: 3,
d: 4,
e,
f: "sway",
g: u256::max()
});
```
will output
```
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 115, 119, 97, 121, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
s.a s.b s.c s.d s.e.len() s.e[0] s.e[1] s.e[2] s.f.len() s.f[0] s.f[1] s.f[2] s.f[3] s.g
```
This works in two steps:
1 - `__log(s)` is desugared into `__log(encode(s))`;
2 - call `encode`. Its impl can be found at
https://github.com/FuelLabs/sway/pull/5306/files#diff-ee5cebc963e841e8af05f3986de17dd266ee6e9b49dbe089a5eb64764f3b802eR307
It simply creates an append-only buffer and call `abi_encode` from a
special trait named `AbiEncode`.
To be encodable, a type must implement `AbiEncode`. In the example
above, `S` is auto-implemented by the compiler because all its fields
are `AbiEncode`. But we can also have custom impl like `Vec` here:
https://github.com/FuelLabs/sway/pull/5306/files#diff-b5d9688741fea479477f26ca44cd1d1ecbd2f003f3875292abb23df7fad85c58
All this is behind a compiler flag:
```
> forc build -h
Compile the current or target project
USAGE:
forc build [OPTIONS]
OPTIONS:
...
--experimental-new-encoding
Experimental flags for the "new encoding" feature
```
The same flag is available for the `e2e` tests:
```
> cargo r -p test --release -- should_pass/language/logging --verbose --experimental-new-encoding
```
## Limitations
1 - Now that __log demands a `fn` called `encode`, when something is
compiled with `implicit-std: false`, the intrinsic function `__log` does
not work out-of-box anymore. A function called `encode` must "visible"
and the worst part is that it needs to be functional to log anything.
2 - Arrays, string arrays and tuples will have limited implementations.
Currently up to five items.
## 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: Joshua Batty <joshpbatty@gmail.com>
## Description
It seems like we accidentally depend on released version of std in
forc-client deployment cli tests (more specifically the test folder
https://github.com/FuelLabs/sway/tree/master/forc-plugins/forc-client/tests).
This PR fixes it to point local version of std so that release PRs such
as #5452 won't get blocked.
## Description
Fixes#5398, #5374
Add examples to our `--help` cli. The examples are defined through the a
macro `forc::cli_examples { }` and each of these examples is part of the
the test suite of the crate. This is done to ensure the documentation is
always up to date or updated whenever the tests are not passing.
## 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: Braqzen <103777923+Braqzen@users.noreply.github.com>
## Description
closes#5432
Bumps used forc-wallet version to 0.4.1 and used sdk versions to 0.54.0
so that we can actually start deploying to beta-5. As we need to be
using forc-client 0.22 which requires us to go to 0.54.0 of sdk. To do
so we need the wallet to use it as well.
---------
Co-authored-by: Cesar Rodas <cesar@rodasm.com.py>
This PR configures the spell-check added to the docs workflow in the
github-actions repo: https://github.com/FuelLabs/github-actions/pull/23
The files checked are configured in `.spellcheck.yml`. This is also
where you can configure what types of elements are ignored.
Right now it ignores:
- All code blocks that have a language (and will check code blocks that
do not have a language)
- Anything in between backticks
- Words in `spell-check-custom-words.txt` (case sensitive, only exact
match)
- Numbers, even if they are attached to a word
- Links in markdown link format
#### Handling errors:
If the test fails:
- look up the word in the question to verify it is a real word and is
correctly spelled
- If it is a file name or is code, use backticks to ignore the word.
- If it is a real word that is spelled correctly, or an acronym that is
either common or is defined already, add it to
`spell-check-custom-words.txt`.
- If needed, rewrite the sentence. Ex: DON'T use "`lock`ing" and add
"ing" to the custom words list. Instead, rewrite the sentence as
"locking with the `lock` method".
- If it otherwise should be ignored, you can configure the pipeline in
`.spellcheck.yml`.
---------
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
## Description
Closes https://github.com/FuelLabs/fuel-debugger/issues/15
Moves https://github.com/FuelLabs/fuel-debugger into a forc plugin.
## 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: Hannes Karppila <hannes.karppila@gmail.com>
## Description
closes#5372
Thanks for the idea @Voxelot , we seem to be getting nice performance
wins across all our benchmarks with this change!
| Benchmark | Avg Duration Before (ms or s) | Avg Duration After (ms or
s) | Speed Increase (%) |
|--------------------------|-------------------------------|------------------------------|--------------------|
| compile | 5.53213 s | 4.64997 s | 15.931 |
| traverse | 170.646 ms | 162.067 ms | 5.0397 |
| did_change_with_caching | 15.332 s | 15.4923 s | -1.04545 |
| semantic_tokens | 20.766 ms | 15.981 ms | 23.053 |
| document_symbol | 7.9145 ms | 5.99825 ms | 24.2205 |
| completion | 49.685 ms | 48.5775 ms | 2.22975 |
| hover | 7.42155 ms | 6.23545 ms | 15.952 |
| highlight | 113.75 ms | 108.503 ms | 4.6195 |
| goto_definition | 7.99853 ms | 6.53863 ms | 18.3765 |
| inlay_hints | 10.6885 ms | 8.99667 ms | 15.814 |
| prepare_rename | 7.9312 ms | 6.38533 ms | 19.4985 |
| rename | 119.68 ms | 113.803 ms | 4.9071 |
| code_action | 60.1105 ms | 55.44 ms | 7.7762 |
| code_lens | 0.365733 ms | 0.2341 ms | 35.989 |
| on_enter | 0.604733 ms | 0.3105 ms | 48.676 |
| format | 51.57 ms | 44.6735 ms | 13.3765 |
| tokens_for_file | 10.3933 ms | 8.85676 ms | 14.723 |
| idents_at_position | 3.81803 ms | 3.1588 ms | 17.261 |
| tokens_at_position | 42.2257 ms | 40.9237 ms | 3.0873 |
| token_at_position | 7.67043 ms | 6.2267 ms | 18.811 |
| parent_decl_at_position | 42.87 ms | 40.8167 ms | 4.7931 |
## Description
co-developed with: @IGI-111 and @xgreenx
This PR adds support for transaction policies.
What was done:
- bump `fuel-vm` to `0.43.1`
- bump `fuels-rs` to `0.53.0`
- update the `std-lib` to handle new `GTF` codes and the transaction
policies
- update all test
BREAKING CHANGE:
- removed `TxParameters` in favor of `TxPolicies`
- changed `gtf` opcodes
- removed `Mint` from `forc-tx` and cli
## 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.
- [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: green <xgreenx9999@gmail.com>
Co-authored-by: Elvis <elvisdedic@outlook.com>
Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: xunilrj <xunilrj@hotmail.com>
Co-authored-by: Vaivaswatha Nagaraj <vaivaswatha.nagaraj@fuel.sh>
Co-authored-by: Kaya Gökalp <kaya.gokalp@fuel.sh>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
## Description
`ConcurrentSlab` now stores and returns an Arc, and on `get` it only
clones an Arc which is much cheaper than cloning the whole values.
The type engine is still cloning every TypeInfo we should be able to
also avoid that and get further improvements in speed.
With these changes core + std-lib compilation improved from around 3
secs to 1.5 secs.
`cargo run --bin test --release` is running in around 8min versus 16min
in master.
## 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.
- [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/2010
Notes:
- I couldn't use `from_reader` to deserialize the file contents due to
this issue: https://github.com/FuelLabs/fuel-vm/pull/643
## 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).
- [ ] 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
Closes https://github.com/FuelLabs/sway/issues/3480
A simple search bar for forc-doc. It uses a case-insensitive search of
item names, across the library and all of its dependencies. Names in the
search results are highlighted similar to docs.rs.

## 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).
- [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.
---------
Co-authored-by: Chris O'Brien <obrchr96@gmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
Fixes#5059
While doing this I also updated `forc-fmt` to have a better error
message being printed to the stdout
Before:
```bash
error: Formatting skipped due to error.
error: Failed to compile /Users/cr-fuel/projects/fuel/sway/sway-lib-std/src/hash.sw
```
Now:
```bash
error: Formatting skipped due to error.
error: Failed to compile /Users/cr-fuel/projects/fuel/sway/sway-lib-std/src/hash.sw
Cannot format raw hashbang attribute,
If this is intended to be a doc comment try using the `//!` syntax instead
```
## 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
Fixes#4318
Supported algorithms:
* [x] keccak256
* [x] sha256
* [ ] ~ecrecover~ (this will be added later)
* [x] bech32-to-hex
* [x] hex-to-bech32
* [x] new-key / parse-secret (from
https://github.com/FuelLabs/fuel-core/blob/master/bin/keygen/src/keygen.rs)
## 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
This PR just moves the dir helpers that were in `forc-util` to
`sway-utils`. I need access to these methods in an upcoming PR and
having them in `forc-util` introduces a mind field of circular
dependencies.
Ref #4705
What this does:
- Adds go-to definition functionality for external traits implemented
for some local type, eg `impl Foo for Bar` where `Foo` is a dependency
type
- Adds `no_deps` to `RenderPlan`, when this flag is passed dependencies
aren't built, so we also shouldn't produce links to docs that won't be
there
- Adds a test harness that uses the Sway -> HTML compiler
First part of the video shows the output when built with `--no-deps`
which does not build dependency docs (in this instance `core`), and thus
produces no links to those dependencies. Second shows without the flag.
[Screencast from 2023-10-20
01-54-57.webm](fb3a1275-19fa-47ad-a4d3-551211383226)
---------
Co-authored-by: Chris O'Brien <obrchr96@gmail.com>
## Description
Adds support for checking if using fully qualified call paths is
necessary on associated types disambiguation.
Adds support for specifying fully qualified paths of associated types
used in type ascriptions.
Adds support for specifying fully qualified path when calling methods of
associated types and when using associated consts of associated types.
## 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).
- [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
Fixes#4877
## Tasks
- [x] Make a simple example with a trait and an impl for it compile
- [x] Fix typechecking for empty enums
- [x] Fix typechecking for trait impl methods
- [x] Fix typechecking for impl self blocks
- [x] Fix the case of non-implemented supertraits
- [x] Fix typechecking of generic traits
- [x] Fix typechecking of generic impl self blocks
- [x] Resolve ambiguity between term/path-level `Self` and the
type-level `Self` type parameter (related PR #4459):
- [x] enums
- [x] structs (deferred as issue #5164)
- [x] Fix `Self` for type constraints
- [x] Fix looping during insertion of trait constraints for generic
tuples (inserted `occurs_check` to prevent unification of a generic `A`
with a tuple `(A, A)`;
- [x] Fix exponential growth of the traits map (around 30 tests out of
more than 680 are failing now); related PR: #5004
- [x] Fix `Self` type for blanket implementations
- [x] Fix `Self` for associated consts
- [x] Fix name resolution issues for some tests with traits (like
`should_pass/language/eq_intrinsic`); blocking issues:
- #5018
- #5036
- [x] Fix `should_fail/generic_traits` test
- [x] Fix `should_pass/language/where_clause_impls` test
- [x] Fix `should_pass/language/name_resolution_inside_intrinsics` test
- [x] Remove some commented out code in `impl_trait.rs`
- [x] Comment new code
- [x] **Disable** `should_pass/language/associated_type_container` test
- [x] **Disable** `should_pass/language/associated_type_method` test
- [x] **Disable**
`should_pass/language/associated_type_and_associated_const` test
- [x] **Disable** `should_pass/language/associated_type_iterator` test
## 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: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: IGI-111 <igi-111@protonmail.com>
## Description
Implements associated types parsing.
Adds associated types to trait map.
Modifies resolve_symbol to handle associated types.
Support was added for type ascription, methods parameters, method return
types, and function parameters.
It is still missing fully qualified paths, and checking associated types
name conflicts.
It is also missing updating the documentation.
Closes#4487Closes#610
## 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).
- [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>