Skip to content

Commit 8d5c562

Browse files
authored
Merge branch 'master' into xunilrj/array-iterator
2 parents da56bd3 + 567b5b8 commit 8d5c562

File tree

13 files changed

+443
-16
lines changed

13 files changed

+443
-16
lines changed

.github/workflows/gh-pages.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,20 @@ jobs:
5555
- name: Build Sway std library
5656
run: forc doc --path ./sway-lib-std
5757

58+
- name: Move assets into std directory
59+
run: |
60+
mv ./sway-lib-std/out/doc/static.files ./sway-lib-std/out/doc/std/
61+
mv ./sway-lib-std/out/doc/search.js ./sway-lib-std/out/doc/std/
62+
# Fix relative paths in HTML files
63+
find ./sway-lib-std/out/doc/std -name "*.html" -type f -exec sed -i 's|../static\.files/|static.files/|g' {} \;
64+
find ./sway-lib-std/out/doc/std -name "*.html" -type f -exec sed -i 's|../search\.js|search.js|g' {} \;
65+
5866
- name: Deploy master std
5967
uses: peaceiris/actions-gh-pages@v3
6068
with:
6169
github_token: ${{ secrets.GITHUB_TOKEN }}
6270
publish_dir: ./sway-lib-std/out/doc/std
63-
destination_dir: master
71+
destination_dir: master/std
6472
if: github.ref == 'refs/heads/master'
6573

6674
- name: Deploy master book
@@ -125,7 +133,7 @@ jobs:
125133
uses: peaceiris/actions-gh-pages@v3
126134
with:
127135
github_token: ${{ secrets.GITHUB_TOKEN }}
128-
publish_dir: ./sway-lib-std/out/doc/std
136+
publish_dir: ./sway-lib-std/out/doc
129137
destination_dir: ${{ steps.branch_name.outputs.BRANCH_NAME }}/std
130138
if: startsWith(github.ref, 'refs/tags')
131139

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,35 @@ Confirm the Sway toolchain built successfully:
5050
cargo run --bin forc -- --help
5151
```
5252

53+
## All other scripts/commands
54+
55+
For all other scripts and commands use https://github.com/casey/just:
56+
57+
```
58+
> just --list
59+
Available recipes:
60+
[automation]
61+
update-contract-ids
62+
update-fuel-dependencies
63+
64+
[benchmark]
65+
benchmark
66+
benchmark-tests
67+
collect-gas-usage
68+
69+
[build]
70+
build-highlightjs
71+
build-prism
72+
generate-sway-lib-std
73+
74+
[ci]
75+
ci-check
76+
install-ci-check
77+
78+
[test]
79+
test-forc-fmt-check-panic
80+
```
81+
5382
## Contributing to Sway
5483

5584
We welcome contributions to Sway!

docs/book/spell-check-custom-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ http
9090
https
9191
halfword
9292
js
93+
kB
9394
localhost
9495
mainnet
9596
mempool

docs/book/src/forc/plugins/forc_client/index.md

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ forc-deploy saves the details of each deployment in the `out/deployments` folder
148148

149149
## Proxy Contracts
150150

151-
`forc-deploy` supports deploying proxy contracts automatically if it is enabled in the `Forc.toml` of the contract.
151+
`forc-deploy` supports deploying proxy contracts automatically if it is enabled in the `Forc.toml` of the contract. This feature enables upgradeable contracts by deploying a proxy that forwards calls to an implementation contract, allowing you to upgrade the implementation without changing the proxy address.
152+
153+
### Configuration
154+
155+
To enable proxy deployment, add a `[proxy]` table to your `Forc.toml`:
152156

153157
```TOML
154158
[project]
@@ -162,11 +166,41 @@ implicit-std = false
162166
enabled = true
163167
```
164168

165-
If there is no `address` field present under the proxy table, like the example above, `forc` will automatically create a proxy contract based on the [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) implementation from [sway-standards](https://github.com/FuelLabs/sway-standards). After generating and deploying the proxy contract, the target is set to the current contract, and the owner of the proxy is set to the account that is signing the transaction for deployment.
169+
The proxy configuration supports two fields:
170+
171+
- `enabled` (boolean, required): Whether to deploy a proxy contract
172+
- `address` (string, optional): Address of an existing proxy contract to update
173+
174+
### Fresh Proxy Deployment
175+
176+
If there is no `address` field present under the proxy table, like the example above, `forc` will automatically create a proxy contract based on the [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) implementation from [sway-standards](https://github.com/FuelLabs/sway-standards). The deployment process:
177+
178+
1. **Deploy Implementation Contract**: Your contract is deployed as the implementation
179+
2. **Generate Proxy Contract**: A standard SRC-14 proxy contract is generated
180+
3. **Deploy Proxy Contract**: The proxy is deployed with your implementation as the target
181+
4. **Initialize Proxy**: The proxy is initialized with the deploying account as the owner
182+
5. **Update Manifest**: The proxy address is automatically added to your `Forc.toml`
183+
184+
After deployment, you'll see output similar to:
185+
186+
```console
187+
Deploying contract test_contract chunks
188+
Finished deploying test_contract 0x440b...925
189+
Finished deploying proxy contract for test_contract 0x19d4...f7
190+
Initialized proxy contract for test_contract
191+
```
192+
193+
The `Forc.toml` will be automatically updated with the proxy address:
194+
195+
```TOML
196+
[proxy]
197+
enabled = true
198+
address = "0x19d465200575ebd085300242002efcda38db99e22449a5c1346588efe9ced7f7"
199+
```
166200

167-
This means that if you simply enable proxy in the `Forc.toml`, forc will automatically deploy a proxy contract for you and you do not need to do anything manually aside from signing the deployment transactions for the proxy contract. After deploying the proxy contract, the address is added into the `address` field of the proxy table.
201+
### Updating Existing Proxy
168202

169-
If you want to update the target of an [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) compliant proxy contract rather than deploying a new one, simply add its `address` in the `address` field, like the following example:
203+
If you want to update the target of an existing [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) compliant proxy contract, specify its address in the `address` field:
170204

171205
```TOML
172206
[project]
@@ -181,11 +215,40 @@ enabled = true
181215
address = "0xd8c4b07a0d1be57b228f4c18ba7bca0c8655eb6e9d695f14080f2cf4fc7cd946" # example proxy contract address
182216
```
183217

184-
If an `address` is present, `forc` calls into that contract to update its `target` instead of deploying a new contract. Since a new proxy deployment adds its own `address` into the `Forc.toml` automatically, you can simply enable the proxy once and after the initial deployment, `forc` will keep updating the target accordingly for each new deployment of the same contract.
218+
When an `address` is present, `forc` will:
219+
220+
1. Deploy the new implementation contract
221+
2. Call the existing proxy's `set_proxy_target` method to update the target
222+
3. The proxy address remains the same, providing seamless upgrades
223+
224+
### Transaction Details
225+
226+
When deploying with proxy enabled, you'll see multiple transactions in the confirmation:
227+
228+
- One transaction to deploy the implementation contract
229+
- One additional transaction to deploy the proxy (for fresh deployments) or update the target (for existing proxies)
230+
231+
Example output:
232+
233+
```console
234+
Confirming transactions [deploy test_contract + deploy proxy]
235+
Network: https://testnet.fuel.network
236+
```
237+
238+
### Storage Slots
239+
240+
The proxy contract includes both its own storage slots and preserves the storage slots from your implementation contract, ensuring that contract state is properly maintained across upgrades.
241+
242+
### Important Notes
243+
244+
- The proxy owner (initially set to the deploying account) has exclusive rights to update the proxy target
245+
- Once a proxy is deployed, the address in your `Forc.toml` allows for automatic target updates on subsequent deployments
246+
- Proxy contracts work with both regular and [chunked contracts](#large-contracts) (contracts over 100<!-- markdownlint-disable-line MD032 -->kB)
247+
- The implementation uses the SRC-14 standard for maximum compatibility with the Fuel ecosystem
185248

186249
## Large Contracts
187250

188-
For contracts over the maximum contract size limit (currently `100kB`) defined by the network, `forc-deploy` will split the contract into chunks and deploy the contract with multiple transactions using the Rust SDK's [loader contract](https://github.com/FuelLabs/fuels-rs/blob/master/docs/src/deploying/large_contracts.md) functionality. Chunks that have already been deployed will be reused on subsequent deployments.
251+
For contracts over the maximum contract size limit (currently `100<!-- markdownlint-disable-line -->kB`) defined by the network, `forc-deploy` will split the contract into chunks and deploy the contract with multiple transactions using the Rust SDK's [loader contract](https://github.com/FuelLabs/fuels-rs/blob/master/docs/src/deploying/large_contracts.md) functionality. Chunks that have already been deployed will be reused on subsequent deployments.
189252

190253
## Deploying Scripts and Predicates
191254

@@ -206,4 +269,4 @@ The loader files contain the bytecode necessary to load and execute your script
206269

207270
This new deployment method allows for more efficient storage and execution of scripts and predicates on the Fuel network.
208271

209-
Note: Contracts are still deployed directly, not as blobs given that the contract size is under the maximum contract size limit defined by network (currently `100kB`).
272+
Note: Contracts are still deployed directly, not as blobs given that the contract size is under the maximum contract size limit defined by network (currently `100<!-- markdownlint-disable-line -->kB`).

forc-plugins/forc-client/src/cmd/call.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,17 @@ pub struct Command {
403403
pub gas: Option<Gas>,
404404

405405
/// The external contract addresses to use for the call
406-
/// If none are provided, the call will automatically populate external contracts by making a dry-run calls
407-
/// to the node, and extract the contract addresses based on the revert reason
408-
#[clap(long, alias = "contracts", help_heading = "CONTRACT")]
409-
pub external_contracts: Option<Vec<ContractId>>,
406+
/// If none are provided, the call will automatically populate external contracts by making dry-run calls
407+
/// to the node, and extract the contract addresses based on the revert reason.
408+
/// Use an empty string '' to explicitly specify no external contracts.
409+
/// Multiple contract IDs can be provided separated by commas.
410+
#[clap(
411+
long,
412+
alias = "contracts",
413+
value_delimiter = ',',
414+
help_heading = "CONTRACT"
415+
)]
416+
pub external_contracts: Option<Vec<String>>,
410417

411418
/// Output format for the call result
412419
#[clap(long, short = 'o', default_value = "default", help_heading = "OUTPUT")]

forc-plugins/forc-client/src/op/call/call_function.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use fuels_core::{
3131
ContractId,
3232
},
3333
};
34-
use std::collections::HashMap;
34+
use std::{collections::HashMap, str::FromStr};
3535

3636
/// Calls a contract function with the given parameters
3737
pub async fn call_function(
@@ -115,9 +115,23 @@ pub async fn call_function(
115115

116116
// Get external contracts (either provided or auto-detected)
117117
let external_contracts = match external_contracts {
118-
Some(external_contracts) => external_contracts,
118+
Some(contracts) if contracts.first().is_some_and(|s| s.is_empty()) => vec![],
119+
Some(contracts) => {
120+
// Parse each contract ID
121+
contracts
122+
.into_iter()
123+
.filter(|s| !s.is_empty())
124+
.map(|s| {
125+
ContractId::from_str(s.strip_prefix("0x").unwrap_or(&s))
126+
.map_err(|e| anyhow!("Invalid contract ID '{}': {}", s, e))
127+
})
128+
.collect::<Result<Vec<_>>>()?
129+
}
119130
None => {
120131
// Automatically retrieve missing contract addresses from the call
132+
forc_tracing::println_warning(
133+
"Automatically retrieving missing contract addresses for the call",
134+
);
121135
let external_contracts = determine_missing_contracts(
122136
&call,
123137
wallet.provider(),

justfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[group('ci')]
2+
[confirm("Do you want to install cargo-sort, cargo-generate and cargo-udeps from crates.io?")]
3+
install-ci-check:
4+
cargo install cargo-sort
5+
cargo install cargo-generate
6+
cargo install cargo-udeps
7+
8+
[group('ci')]
9+
ci-check:
10+
bash ./ci_checks.sh
11+
12+
[group('automation')]
13+
[confirm("Do you want to bump all fuel maintained dependencies?")]
14+
update-fuel-dependencies:
15+
bash ./update_fuel_dependencies.sh
16+
17+
[group('automation')]
18+
[confirm("Do you want to automatically update contractIds in this repo?")]
19+
update-contract-ids:
20+
bash ./test/update-contract-ids.sh
21+
22+
[group('benchmark')]
23+
benchmark:
24+
bash ./benchmark.sh
25+
26+
[group('benchmark')]
27+
benchmark-tests:
28+
bash ./test/bench.sh
29+
30+
[group('benchmark')]
31+
collect-gas-usage:
32+
cargo r -p test --release -- --verbose --forc-test-only | ./scripts/compare-gas-usage/extract-gas-usage.sh
33+
34+
[group('build')]
35+
build-prism:
36+
cd ./scripts/prism && ./build.sh
37+
38+
[group('build')]
39+
build-highlightjs:
40+
cd ./scripts/highlightjs && ./build.sh
41+
42+
[group('build')]
43+
generate-sway-lib-std:
44+
cd ./sway-lib-std && ./generate.sh
45+
46+
[group('test')]
47+
test-forc-fmt-check-panic:
48+
cd ./scripts/formatter && ./forc-fmt-check-panic.sh

scripts/bisect-forc/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
`bisect-forc.sh` will automatically run `forc bisect` searching for a different behaviour between two commits.
2+
3+
The script accepts three arguments:
4+
5+
```
6+
bisect-forc.sh sway_project test 30s
7+
```
8+
1 - First argument is the sway project that will be compiled over and over until a different behavior is found;
9+
2 - The second argument is which forc subcommand will be used. It defaults to `build`.
10+
11+
So, `forc` will be run as:
12+
13+
```
14+
> forc <SECONDARGUMENT> --path <FIRSTARGUMENT>
15+
```
16+
17+
3 - The third argument is a sleep that is taken between compilations to avoid notebooks enter into thermal throttle mode, or that weaker machines become unusable. Default to zero.

0 commit comments

Comments
 (0)