Commit graph

525 commits

Author SHA1 Message Date
IGI-111
3efc60e22b
Bump to v0.43.0 (#4897) 2023-08-02 22:57:10 +02:00
IGI-111
f48268ea5e
More error handling refactoring (#4895)
## Description
This changes addresses the issues introduced in #4878

The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros
are introduced.

All instances of introducing `ErrorEmitted` as a literal value have now
been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to be
moved to `sway-types` to avoid circular dependencies introduced by this
change.

This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.

Fixes #4885
Fixes #4886

## 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.
2023-08-01 16:12:53 +01:00
IGI-111
f5f8566e8c
Refactor compiler error handling (#4878)
## Description

Change error handling to use `Handler` instead of the macro based
`CompileResult`.

Fix #2734

## 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.
2023-07-29 15:19:59 +00:00
Kaya Gökalp
3b66f8e424
chore: bump to v0.42.1 (#4767)
## Description
release: v0.42.1 version.
2023-07-07 10:55:59 +00:00
Kaya Gökalp
c4e4ef7e4a
chore: bump to v0.42.0 (#4755)
## Description
Also runs `cargo update` in order to update deps to their latest patch
release as this is a breaking release.
2023-07-06 11:26:02 +00:00
IGI-111
e08fab1852
Bump to v0.41.0 (#4720) 2023-06-29 19:26:23 +01:00
Mitchell Mackert
00982e477e
Add flag to reverse errors (#4142)
Adds the ability to reverse errors and warnings in either the command line or via a BuildProfile.

closes #3860
2023-06-22 01:46:34 +03:00
mitchmindtree
96c6103541
feature(forc-pkg): Support IPFS-sourced dependencies (#4299)
## Description
Closes #3926.

(edited by @kayagokalp to reflect latest status of the PR)

This PR adds IPFS support for forc-pkg. To do so, forc relies on
existing ipfs local node without embedding a node to forc itself. If
local system does not have an ipfs node running, a public gateway
(https://ipfs.io) is used as a fallback mechanism and packages are
fetched through that.

## Some Context and Future Work

For our package registry stuff to work properly we will eventually need
to host an IPFS node to make sure that our published packages are pinned
by at least one node in the network. That is the case as long as we
don't have a way to incentivize people pinning the packages they
published. What will happen is that a package will be published by a
developer and after we detect the published package our own IPFS node
will pin it to make sure it is always accessible.

Also some benchmarks are done for public gateway during development. It
looks like for initial fetch operations from public gateway spends some
time looking for the package pinned by the IPFS node simulating our
incoming fuel IPFS node which is explained above. It is manageable but
fetching from the fuel IPFS node is instant as it already got the
package pinned. We can consider falling back to our own node's gateway
api rather than a public one to smooth the process.

Finally maybe we can explore embedded ipfs node option as a follow-up,
due to the status of IPFS with Rust, it is not very obvious (maybe not
event possible atm) how to be able to be fully compatible with kubo, for
fetching/publishing our packages. But this is still an open question
worth exploring.

## Testing

### To test with a local node:

1. You can install kubo, you can follow the instructions in their
website while installing https://docs.ipfs.tech/install/command-line/
2. Run the `ipfs daemon` service with `ipfs daemon`
3. Add an ipfs source, I have a package already pinned by my IPFS node
that you can use:
```toml
[dependencies]
test_lib = { ipfs = "QmfZ3uH7dFEDkYN5RQfyu4m7L8uk8kGiLkNwzHqsrormSj" }
```
4. Run `forc build`

### To test public gateway fallback:

1. Either do this before starting `ipfs daemon` or stop your local
daemon with `ipfs shutdown`.
Add an ipfs source, I have a package already pinned by my IPFS node that
you can use:
```toml
[dependencies]
test_lib = { ipfs = "QmfZ3uH7dFEDkYN5RQfyu4m7L8uk8kGiLkNwzHqsrormSj" }
```
2. Run `forc build`


---------

Co-authored-by: kayagokalp <kaya.gokalp@fuel.sh>
2023-06-19 23:35:44 +00:00
Kaya Gökalp
26581f5937
chore: make fuel-tx optional to forc-util (#4668)
## Description
closes #4667.

To be more WASM friendly and increase reuseability of `forc-util` this
PR hides fuel-tx related utilities under `fuel-tx` flag.
2023-06-16 16:41:12 +00:00
IGI-111
d5464e07a8
Simplify the lifetimes around engines (#4629)
## Description
Inspired by #4588

## 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.
2023-06-05 14:03:59 +01:00
IGI-111
d026ddb8c2
Bump to v0.40.1 (#4614) 2023-05-31 15:13:02 +00:00
Kaya Gökalp
164c7c8bea
release: bump to v0.40.0 (#4601)
## Description

Waiting for:
- #4525.

@Dhaiwat10 was waiting for a release with the linked PR merged.

@IGI-111 I had the PR ready, leaving it up to you when to merge & cut
the release. Made this a major bump as we had a breaking change merged
(#4574).

## 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: IGI-111 <igi-111@protonmail.com>
2023-05-31 10:21:28 +00:00
João Matos
5e4ba2b641
Benchmark / performance tracking (#4564)
## Description

Adds an initial benchmarking setup to CI, where a collection of
libraries from https://github.com/FuelLabs/sway-libs are compiled,
performance metrics generated and later pushed into a new repo:
https://github.com/FuelLabs/sway-performance-data

Closes https://github.com/FuelLabs/sway/issues/318.

## 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.
2023-05-29 21:01:01 +10:00
IGI-111
161ae35714
Stabilize module privacy (#4574)
## Description

Set experimental module privacy rules as the default and remove the
experimental flag.
Closes #4506 

## 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.
2023-05-25 11:25:08 +02:00
IGI-111
e3065657c9
Bump to v0.39.1 (#4585) 2023-05-24 13:22:42 +00:00
Kaya Gökalp
2f0ee52ea4
feat: implement forc-test filter (#4566)
## Description
closes #3268.

This PR adds filtering capability to `forc-test` based on test names. Tests are executed if their name contains the given filter phrase.
2023-05-24 12:14:13 +00:00
João Matos
dc67807a22
Refactor existing code to use engines and add a new query engine. (#4575)
## Description

As title says, this refactor existing code to pass the engines type to
more places, and adds a new query engine while at it.

The query engine in this form still does not do anything at all, but
will be populated next with the necessary bits for its purpose.

## 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.
2023-05-23 12:17:11 +00:00
IGI-111
7a095280e7
Bump to 0.39.0 (#4568) 2023-05-17 15:48:16 +02:00
IGI-111
1ecc5e79d6
Implement module privacy rules (#4474)
## Description

This change mainly adds checks to enforce the new module privacy rules
and supporting changes for it.

Changes include updating std and core to use
public modules, updating the parser to allow the use of the `pub mod`
syntax and adding an error type for private modules.

This change is implemented behind a `--experimental-private-modules`
experimental flag and not enabled by default.

It implements part of https://github.com/FuelLabs/sway/issues/4446, the
`pub use` syntax is yet to be implemented.

## 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>
2023-04-28 10:30:53 +01:00
mitchmindtree
2d16d70ab9
Re-publish 0.37.2 as 0.38.0 due to breaking changes (#4494)
See here for context:
https://github.com/FuelLabs/sway/pull/4492#issuecomment-1520949069

This follows a re-release of 0.37.1 as 0.37.3:
https://github.com/FuelLabs/sway/releases/tag/v0.37.3

The outcome of all this is that ideally, users previously on 0.37.1 will
now pull 0.37.3 next time they run `cargo update` and will not encounter
any breakage. Those ready to update can point to 0.38.0 after this is
published.

Also runs `cargo update` in order to update deps to their latest patch
release.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2023-04-25 03:53:15 +00:00
Kaya Gökalp
dc6af91393
Bump to v0.37.2 (#4492) 2023-04-24 22:19:25 +02:00
Mohammad Fawaz
1db8385158
Replace old storage API with the new one explained in the StorageKey RFC (#4464)
## Description
Implement https://github.com/FuelLabs/sway-rfcs/pull/23

Closes https://github.com/FuelLabs/sway/issues/3419 (technically via the
RFC)
Closes https://github.com/FuelLabs/sway/issues/3202
Closes https://github.com/FuelLabs/sway/issues/3043
Closes https://github.com/FuelLabs/sway/issues/2639
Closes https://github.com/FuelLabs/sway/issues/2465
Closes https://github.com/FuelLabs/sway/issues/4304

This is a big one but mostly removes stuff. It's hard to review but the
summary of changes below should be sufficient. Most of the changes here
are things that I just had to do to make CI pass.

- Removed the `--experimental-storage` flag and made its
[behavior](https://github.com/FuelLabs/sway/pull/4297) the default. Also
removed everything that was required for the previous storage APIs in
favour of the new ones.
- Break down the `std::storage` into multiple submodules:
 - `storage_key` implements the API for `std::core::StorageKey`
- `storage_api` implements the free functions `read` (previously `get`),
`write` (previously `store`), and `clear`.
- 4 more modules for the dynamic storage types which now use the new
`StorageKey` API.
- `#[storage(write)]` now allows reading from storage as well. This is
needed because the way we pack structs in storage now requires that we
sometimes read from storage first if we were to write a portion of a
slot.
- Removed the "storage only types" checks and the corresponding tests.
- Removed the `__get_storage_key` intrinsic and the `get_storage_key` IR
instruction and all corresponding tests. Also removed the `state_index`
metadata as it is no longer required.
- Added tests and example to showcase nested storage maps and nested
storage vectors.

## 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>
2023-04-21 07:36:40 -04:00
Kaya Gökalp
ebdbbfe2dd
feat: exit with 101 from forc-test if there are failing tests (#4463)
## Description
closes #4462.

With this PR we exit from `forc test` with 101 exit status, if there are
failing unit tests. If `forc test` execution itself fails we exit with
1. This is useful especially in CIs as the return status can be checked
to better understand what is happening.

## 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).
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2023-04-19 22:48:37 +00:00
Kaya Gökalp
375d31f5c7
refactor: better error formatting for ForcResult (#4460)
## Description
closes #4461.

We introduced `ForcResult` in #4455. While implementing it I took a look
at the cargo's design and saw that they also have `CargoCliResult` which
did not make a lot of sense then but it looks like without that piece we
cannot format the error nicely because of rust's orphan rule. This PR
introduces `ForcCliResult` which enables us to return nice and clean
errors.
2023-04-19 00:34:15 +00:00
Kaya Gökalp
5e7ad6eca7
refactor: Introduce ForcResult and ForcError to propagate return code with error message (#4455)
## Description
closes #4420.

This PR introduces `ForcResult` and `ForcError` which enables us to
return with custom exit code via propagating the desired exit code
alongside the error message. Using `ForcResult` we can exit with
different return code for different cases. Cargo uses similar approach
for similar purposes.
2023-04-17 23:59:53 +00:00
Kaya Gökalp
31f145c9cd
feat: forc contract-id print contract name before printing id for workspaces (#4440)
## Description
closes #4439.
2023-04-14 10:38:40 +00:00
Mohammad Fawaz
83e5479462
Bump to v0.37.1 (#4435) 2023-04-13 12:28:13 -04:00
Mohammad Fawaz
9685fab224
Experimental: StorageKey feature (#4297)
## Description
This PR introduces `StorageHandle` to the `core` as an **experimental**
feature. `StorageHandle` is a descriptor of a location in storage
containing two fields:
1. A key pointing to a storage slot `s`.
2. An offset pointing to a particular word in `s` or in its subsequent
slots. This offset is new and is not described in the RFC. I will
rectify that shortly.
The standard library introduces helper methods `read`, `try_read`, and
`write` to `StorageHandle` that allow reading from and writing to the
location pointed to by the handle. `try_read` returns an `Option`
wrapping the data while `read` automatically internally unwraps the data
and could panic.

The summary of this change is as follows:
* New struct `core::experimental::storage::StorageHandle`
* New storage library `std::experimental::storage::*` that should
eventually replace `std::storage::*`. This new library mirrors the old
one to the extent possible and introduces the helper methods for
`StorageHandle`. Other data structures such as `StorageVec` and
`StorageBytes` will be introduced in a separate PR.
* Add an experimental flag `--experimental-storage` to `forc` that
enables all the required code in the compiler to support `StorageHandle`
as described in the https://github.com/FuelLabs/sway-rfcs/pull/23.
* Type checking phases assumes the existence of `StorageHandle` and
monomorphizes it as needed.
* Storage accesses now always return `StorageHandle` and storage
reassignment are no longer relevant.
* IR gen handles storage accesses by "filling" the key and the offset in
an aggregate representing the `StorageHandle`. The key and the offset
are statically determined based on the index of the storage variable in
the `storage` block and the field accessed, if applicable.
  * Storage initializers are now handled based on the new model
* The new approach packs struct fields by default but does not pack
across storage variables. This offers the most amount of flexibility.
This is a deviation from the RFC which I will update shortly.
* To implement `StorageMap` and other dynamic storage data structures,
we now write `impl StorageHandle<StorageMap<K, V>>` instead of `impl
StorageMap<K, V>` directly. Also, note that the `get` method now returns
a `StorageHandle` instead of the actual data. To get the actual data,
`read()` or `try_read()` should be called on the resulting handle. This
is needed for multiple reasons including proper support for nested
dynamic storage types. Rust also does the same, in a way (where `get`
actually returns ` &` which happens to coerce to the real data in
certain places).
* I added various tests but they're not comprehensive. Some tests on my
list:
  * Extensive tests for storage maps in structs (which now work!)
* Extensive tests for storage accesses with various types and struct
layouts

I still need to figure out how to do nested dynamic storage types with
this approach. The stuff I have in `map_in_map_access` in
`test_projects/experimental_storage/src/main.sw` is just an attempt but
not ergonomic at all of course.

## 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).
- [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.
2023-04-13 00:24:09 +00:00
Kaya Gökalp
1e63c1551a
feat: disallow nested packages (#4407)
## Description

closes #4072 

Disallows package structure such as the following:

```console
proj1
├── proj2
│   ├── Forc.lock
│   ├── Forc.toml
│   ├── out
│   └── src
├── Forc.lock
├── Forc.toml
├── out
│   └── debug
└── src
    └── main.sw
```
2023-04-13 00:03:26 +00:00
Kaya Gökalp
999557cd2b
fix: forc-test exits with non-zero status code if there are failing tests (#4417) 2023-04-12 08:12:35 +00:00
Mohammad Fawaz
607ac50176
Bump to v0.37.0 (#4401) 2023-04-05 20:01:56 -04:00
Kaya Gökalp
91ed9817bf
feat: parallel unit test runners (#4395)
## Description
closes #3953

This PR adds parallel test runners to improve our test execution times
by utilizing the fact that each test is actually completely separate
from each other. Also a flag `--test-threads` added to `forc-test` to
manually control number of thread used for execution.

Simple benchmarks taken from my local system with m1 max can be seen in
below: (
*Each config is executed 10 times)*
| Num Threads      | Average Time |
| ----------- | ----------- |
| 1      | 1.019   ms  |
| 2   | 938 ms        |
| 4   | 883 ms        |


As it can be seen speed-ups aren't great as this includes building as
well which is done with single thread. So I tested just building with
tests enabled on the same project (which is sway-lib-std btw) which
takes 810ms (again averaged 10 times). So after I normalize the results
above with this data
| Num Threads      | Average Time |
| ----------- | ----------- |
| 1      | 209    ms |
| 2   | 128 ms       |
| 4   | 73 ms         |

Speed-ups are more visible with more complex tests with increased number
of tests.
2023-04-05 22:57:07 +00:00
Mohammad Fawaz
92818a4d5e
Bump to v0.36.1 (#4397) 2023-04-05 10:04:12 -04:00
Marcos Henrich
08e1c2faaa
Adds urls to graph.visualize generated dot file. (#4310)
## Description

graph.visualize now can include urls that are clickable in generated svg
files.
To set this up we can call forc with the argument
`--dca-graph-url-format`.
For vscode we would use: `--dca-graph-url-format
'vscode://file/{path}:{line}:{col}'`

This commit also changes forc `--dca-graph` to receive a path.
We still can output to std by using `--dca-graph ''`.

Also adds edge labels.
Also changes entry node shape to be different, a double octagon instead
of an ellipse.

## 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.
2023-04-05 08:56:30 -04:00
Mohammad Fawaz
77f575ab79
Bump to v0.36.0 (#4388)
Also ran `cargo update` because this is a breaking release.

Pending:
- [x] https://github.com/FuelLabs/sway/pull/4391
- [x] https://github.com/FuelLabs/sway/pull/4390
- [x] https://github.com/FuelLabs/sway/pull/4385
2023-04-04 22:25:46 -04:00
Kaya Gökalp
8e30dc2a5b
feat: add forc contract-id and forc predicate-id commands (#4338)
## Description
Adds `forc contract-id` and `forc predicate-id` commands for contract id and predicate root detection.

closes #3444.
2023-04-04 02:19:41 +00:00
Kaya Gökalp
123c9e7c11
feat: Introduce git SSH support to forc (#4287)
## Description
closes #1636.

This PR introduces ssh authentication support for git sources. I also
started to maintain `git2_auth` which I aim to make a feature complete
authentication handler for git2-rs that supports non ssh-agent
interaction as well. That would take a lot more time so I pulled the
ssh-agent support and injected into `forc-pkg`. As I find out useful
things while experimenting on `git2_auth`, will update our
authentication handler with those as well.

1. We can now use dependencies in git ssh format 
Example:
```TOML
std = { git = "git@github.com:FuelLabs/sway.git" } 
```
2. We can also point to private repos

Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
2023-03-30 18:07:27 +11:00
JC
169ad0b145
Cleanup TOMLs (#4312)
Moves following `Cargo.toml` fields to workspace `Cargo.toml` so we
don't have to keep repeating ourselves:

- edition
- authors
- homepage
- license
- repository
2023-03-20 16:22:12 +00:00
bing
032cd3b3b7
refactor: deprecate ConfigTimeConstants (#4298)
## Description

Closes #3681 

I meant to tackle #3077 first, but tackling #3681 first cleans up a lot
of the code needed to make #3077 easier.

This PR is mostly cleanup:
- Completely removes usage of `ConfigTimeConstant` everywhere (in
forc-pkg, sway-core, sway-type)
- **(BREAKING)** Completely removes support for `[constants]` table in
the manifest, which was using the `ConfigTimeConstant` struct. This
change is breaking for app devs ([open
issue](https://github.com/FuelLabs/sway-applications/issues/375)) and
from a [quick
search](https://github.com/FuelLabs/sway-applications/search?l=TOML&q=%5Bconstants%5D)
on our sway-applications repo, there's a number of manifests still using
the old version of configuration time constants.

Consequentially, the above change also allowed us to cut down on other
constructs like `ConstInjectMap` within forc-pkg, since the only thing
we need to inject now are const CONTRACT_IDs - this cuts down quite a
bit of now-redundant code.

- As a result of the removal of `ConfigTimeConstant`, a few tests using
that feature were also deleted.
- Also updated the `configurable` example to be known as
`configurable_constants` instead of `config_time_constant`.


**This PR does not:**
- Fix the manual creation of `CONTRACT_ID` const. To create the const,
we still undergo manual parsing and type-checking and finally inserting
into a `SymbolMap` manually. This will be handled in a separate PR to
tackle #3077

Other than removal of a lot of code to do with CTC, the main change here
that allows contract dependencies to still work here is instead of
relying on the `ConstInjectMap` which we used to inject both constants
and contract dependencies, there is now only a single contract ID value
that we require (this is abstracted as `ContractIdConst`) to inject into
the contract for tests.

## 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).
- [ ] 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.
2023-03-17 01:15:55 +00:00
mitchmindtree
3d5698efda
refactor(forc-pkg): Attempt to simplify build/compile fns by introducing dedicated types (#4209)
## Description

This introduces the `CompiledPackage` and `CompiledContractDependency`
types in order to more accurately model the inputs and outputs of the
`compile` function.

We also move the `name` and `target` fields from `BuiltPackage` into the
`PackageDescriptor`, construct the descriptor earlier in the build
process, and use the descriptor to consolidate more of the `compile`
function arguments.

I started on refactoring some of the ABI generation related code, but
realised that this might involve a more dedicated effort and opened
#4208.

## 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.
2023-03-10 15:01:37 +00:00
IGI-111
0eaa3a6da9
Standardized module structure (#4232)
## Description

Implement RFC 0006, fix #4191.

Remove the `dep` reseved keyword in favor of `mod`.

Change path resolution for submodules to use an adjascent file at the
root and a folder named after the current module in other cases.

Remove the need for an argument to `library`, the LSP now points to
empty spans at the top of module files.

The library names are now determined by the file name, or the package
name at the top level.

## 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.
2023-03-09 19:14:52 +11:00
Mohammad Fawaz
49eae2dd93
Bump to v0.35.5 (#4242) 2023-03-08 13:12:24 -05:00
Mohammad Fawaz
3770dd8c21
bump to v0.35.4 (#4230) 2023-03-07 14:38:24 +00:00
Marcos Henrich
40cf1c2770
Implements json abi with call paths for structs and enums. (#4137)
## Description

Reference to external dependency struct now looks like: `"type": "struct
abi_with_tuples::Person",`
`"type": "enum std::option::Option",`

Struct reference in root module still looks like:
`"type": "struct MyStruct",`

Struct reference in sub modules looks like:
`"type": "struct dep_1::MyStruct1",`

` forc build` will not generate json ABI with call path by default to do
so we have to use the flag `--json-abi-with-callpaths`, one example is:

```cargo run --bin forc build --json-abi-with-callpaths --path `pwd`/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_same_name_types/```

This will generate `test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_same_name_types/out/debug/abi_with_same_name_types-abi.json` with call paths for structs and enums.

This is related to:
https://github.com/FuelLabs/fuel-specs/issues/450
https://github.com/FuelLabs/fuels-rs/issues/791

## 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.
2023-03-02 18:55:51 +00:00
Kaya Gökalp
64f7340470
feat: display gas used for unit tests (#4178)
## Description
closes #2411.

This PR adds used gas information to the output of `forc test`. An
example run can be seen below:

<img width="534" alt="Screen Shot 2023-02-24 at 4 47 29 PM"
src="https://user-images.githubusercontent.com/20915464/221198624-a3bdb264-2182-4b9d-9497-7d8cfe84132b.png">

This is done automatically without any flags. I felt like this should be
the default way but open to suggestions if you feel like it should be
behind a flag like `--gas-usage`.

Also by accessing `TestResult` structs new used gas field, we can add
this information into vscode plugin just like #513. We do not have a
line by line gas cast information just yet but we could show the whole
test's used gas info next to the run button or something in vscode.
Thoughts @JoshuaBatty @sdankel

Please let me know if anyone has any requests around the flag and the
way we are printing the used gas. Maybe @nfurfaro could have some ideas
as the prime user of `forc-test` 😄
## 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.
2023-02-28 10:16:29 +11:00
Vaivaswatha N
8e797a1365
Add forc build flag to treat warnings as errors (#4177)
Closes #3190

## 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.
- [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.
2023-02-24 05:15:13 +00:00
mitchmindtree
9346bf4fa6
refactor(forc-pkg): Abstract out source-related items from pkg (#4168)
## Description

In anticipation of the upcoming ipfs support (#3926), this PR refactors
`forc-pkg` to more clearly separate out the "source" abstraction from
the rest of the pkg-handling logic.

We do so by creating a common interface for sources in the form of
traits for pinning and fetching. This should allow for adding in the
upcoming ipfs implementation (or future alternative source kind) in a
manner that doesn't further complicate the rest of package handling.

There is still room for further refactor of `pkg.rs`, but this should do
enough to clear the way for ipfs support and closes #3927.

## 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>
2023-02-24 08:44:37 +11:00
Mohammad Fawaz
5d2b10bd83
Bump to v0.35.3 (#4135)
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: João Matos <joao@tritao.eu>
2023-02-21 16:42:15 -05:00
Mohammad Fawaz
f05ecaf2de
Bump to v0.35.2 (#4123) 2023-02-17 15:08:34 -08:00
Kaya Gökalp
812608ca13
feat: Upon test failure, output revert code with human-readable label and associated logs (#3999)
## Description

closes #3952.

This PR adds:

1. Revert code for failing tests
2. Known error signals for failing tests
3. Logs for failing tests


## 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).
- [ ] 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.
2023-02-17 10:23:08 +00:00