You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/src/forc/plugins/forc_client/index.md
+70-7Lines changed: 70 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,11 @@ forc-deploy saves the details of each deployment in the `out/deployments` folder
148
148
149
149
## Proxy Contracts
150
150
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`:
152
156
153
157
```TOML
154
158
[project]
@@ -162,11 +166,41 @@ implicit-std = false
162
166
enabled = true
163
167
```
164
168
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:
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
168
202
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:
170
204
171
205
```TOML
172
206
[project]
@@ -181,11 +215,40 @@ enabled = true
181
215
address = "0xd8c4b07a0d1be57b228f4c18ba7bca0c8655eb6e9d695f14080f2cf4fc7cd946"# example proxy contract address
182
216
```
183
217
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)
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
185
248
186
249
## Large Contracts
187
250
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.
189
252
190
253
## Deploying Scripts and Predicates
191
254
@@ -206,4 +269,4 @@ The loader files contain the bytecode necessary to load and execute your script
206
269
207
270
This new deployment method allows for more efficient storage and execution of scripts and predicates on the Fuel network.
208
271
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`).
`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