Skip to content

Commit

Permalink
feat: add blob deployments for scripts and predicates (#6607)
Browse files Browse the repository at this point in the history
## Description

This PR adds support for deploying executables, namely predicates and
scripts. Before this PR executing `forc-deploy` on a script or predicate
was an hard error. With this PR we are enabling the deployment of them
via converting them to a loader which loads the original bytecode
deployed as a blob.

The loader binaries are serialized to disk under `out` folder for both
predicates and scripts. For predicates we also save the root of the
loader additionally. Every output related to generated `loader` is
suffixed with `-loader` so that it can be distinguished easily.

---------

Co-authored-by: Joshua Batty <[email protected]>
Co-authored-by: Sophie Dankel <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2024
1 parent d399580 commit 347c834
Show file tree
Hide file tree
Showing 20 changed files with 1,447 additions and 304 deletions.
98 changes: 49 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,24 @@ fuel-abi-types = "0.7"
# Although ALL verions are "X.Y", we need the complete semver for
# fuel-core-client as the GitHub Actions workflow parses this value to pull down
# the correct tarball
fuel-core-client = { version = "0.36.0", default-features = false }
fuel-core-types = { version = "0.36", default-features = false }
fuel-core-client = { version = "0.37.0", default-features = false }
fuel-core-types = { version = "0.37", default-features = false }

# Dependencies from the `fuels-rs` repository:

fuels = "0.66"
fuels-core = "0.66"
fuels-accounts = "0.66"

# Dependencies from the `fuel-vm` repository:
fuel-asm = "0.57"
fuel-crypto = "0.57"
fuel-types = "0.57"
fuel-tx = "0.57"
fuel-vm = "0.57"
fuel-asm = "0.58"
fuel-crypto = "0.58"
fuel-types = "0.58"
fuel-tx = "0.58"
fuel-vm = "0.58"

# Dependencies from the `forc-wallet` repository:
forc-wallet = "0.9"
forc-wallet = "0.10"

#
# External dependencies
Expand Down
23 changes: 22 additions & 1 deletion docs/book/src/forc/plugins/forc_client/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,25 @@ If an `address` is present, `forc` calls into that contract to update its `targe

## Large Contracts

For contracts over 100KB, `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.
For contracts over the maximum contract size limit 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.

## Deploying Scripts and Predicates

`forc deploy` now supports deploying scripts and predicates in addition to contracts. These are deployed as blobs with generated loaders for efficiency.

Scripts and predicates are deployed automatically when you run `forc deploy` on a project that contains them. The deployment process differs slightly from contract deployment:

1. For scripts and predicates, the bytecode is uploaded as a blob.
2. A loader is generated that can load and execute the blob.
3. The loader bytecode is saved in the project's output directory.

After deployment, you'll find new files in your project's output directory:

- For scripts: `<script_name>-loader.bin`
- For predicates: `<predicate_name>-loader.bin` and `<predicate_name>-loader-root`

The loader files contain the bytecode necessary to load and execute your script or predicate from the deployed blob.

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

Note: Contracts are still deployed directly, not as blobs given that the contract size is under the maximum contract size limit defined by network.
Loading

0 comments on commit 347c834

Please sign in to comment.