diff --git a/docs/book/src/forc/plugins/forc_client/index.md b/docs/book/src/forc/plugins/forc_client/index.md index 454cbc9f622..13800088b96 100644 --- a/docs/book/src/forc/plugins/forc_client/index.md +++ b/docs/book/src/forc/plugins/forc_client/index.md @@ -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 @@ -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`). diff --git a/forc-plugins/forc-client/src/op/deploy.rs b/forc-plugins/forc-client/src/op/deploy.rs index ddaf6a8c54d..798fd788826 100644 --- a/forc-plugins/forc-client/src/op/deploy.rs +++ b/forc-plugins/forc-client/src/op/deploy.rs @@ -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. @@ -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(); @@ -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?; @@ -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?; @@ -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); }