Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pin forc-deploy to use 100kb blob size by default #6616

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/book/src/forc/plugins/forc_client/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ If an `address` is present, `forc` calls into that contract to update its `targe

## Large Contracts

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.
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.

## Deploying Scripts and Predicates

Expand All @@ -200,4 +200,4 @@ The loader files contain the bytecode necessary to load and execute your script

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.
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`).
28 changes: 5 additions & 23 deletions forc-plugins/forc-client/src/op/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use sway_core::{asm_generation::ProgramABI, language::parsed::TreeType};
/// Default maximum contract size allowed for a single contract. If the target
/// contract size is bigger than this amount, forc-deploy will automatically
/// starts dividing the contract and deploy them in chunks automatically.
/// The value is in bytes.
/// The value is in bytes
const MAX_CONTRACT_SIZE: usize = 100_000;

/// Represents a deployed instance of a forc package.
Expand Down Expand Up @@ -198,15 +198,10 @@ async fn deploy_chunked(
None => "".to_string(),
};

let chunk_size = chain_info
.consensus_parameters
.contract_params()
.contract_max_size() as usize;

let blobs = compiled
.bytecode
.bytes
.chunks(chunk_size)
.chunks(MAX_CONTRACT_SIZE)
.map(|chunk| Blob::new(chunk.to_vec()))
.collect();

Expand Down Expand Up @@ -613,26 +608,13 @@ pub async fn deploy_contracts(

let node_url = validate_and_get_node_url(command, contracts_to_deploy).await?;
let provider = Provider::connect(node_url.clone()).await?;
let max_contract_size = provider
.chain_info()
.await
.ok()
.and_then(|chain_info| {
chain_info
.consensus_parameters
.contract_params()
.contract_max_size()
.try_into()
.ok()
})
.unwrap_or(MAX_CONTRACT_SIZE);

// Confirmation step. Summarize the transaction(s) for the deployment.
let account = confirm_transaction_details(
contracts_to_deploy,
command,
node_url.clone(),
max_contract_size,
MAX_CONTRACT_SIZE,
)
.await?;

Expand All @@ -652,7 +634,7 @@ pub async fn deploy_contracts(
}
};
let bytecode_size = pkg.bytecode.bytes.len();
let deployed_contract_id = if bytecode_size > max_contract_size {
let deployed_contract_id = if bytecode_size > MAX_CONTRACT_SIZE {
// Deploy chunked
let node_url = get_node_url(&command.node, &pkg.descriptor.manifest_file.network)?;
let provider = Provider::connect(node_url).await?;
Expand Down Expand Up @@ -717,7 +699,7 @@ pub async fn deploy_contracts(
let deployed_contract = DeployedContract {
id: deployed_contract_id,
proxy: proxy_id,
chunked: bytecode_size > max_contract_size,
chunked: bytecode_size > MAX_CONTRACT_SIZE,
};
deployed_contracts.push(deployed_contract);
}
Expand Down
Loading