mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-07-14 17:10:34 +03:00
error if constraint / variable limit is exceeded for deployment on current network
This commit is contained in:
parent
2f32657828
commit
acb8f46655
@ -285,4 +285,18 @@ create_messages!(
|
||||
msg: "Failed to get a network.".to_string(),
|
||||
help: Some(format!("Either make sure you have a `.env` file in current project directory with a `NETWORK` variable set, or set the `--network` flag when invoking the CLI command.\n Example: `NETWORK=testnet` or `leo {command} --network testnet`.")),
|
||||
}
|
||||
|
||||
@backtraced
|
||||
constraint_limit_exceeded {
|
||||
args: (program: impl Display, limit: u64, network: impl Display),
|
||||
msg: format!("Program `{program}` exceeds the constraint limit {limit} for deployment on network {network}."),
|
||||
help: Some("Reduce the number of constraints in the program by reducing the number of instructions in transition functions.".to_string()),
|
||||
}
|
||||
|
||||
@backtraced
|
||||
variable_limit_exceeded {
|
||||
args: (program: impl Display, limit: u64, network: impl Display),
|
||||
msg: format!("Program `{program}` exceeds the variable limit {limit} for deployment on network {network}."),
|
||||
help: Some("Reduce the number of variables in the program by reducing the number of instructions in transition functions.".to_string()),
|
||||
}
|
||||
);
|
||||
|
@ -120,6 +120,15 @@ fn handle_deploy<A: Aleo<Network = N, BaseField = N::Field>, N: Network>(
|
||||
|
||||
// Generate the deployment
|
||||
let deployment = package.deploy::<A>(None)?;
|
||||
|
||||
// Check if the number of variables and constraints are within the limits.
|
||||
if deployment.num_combined_variables()? > N::MAX_DEPLOYMENT_VARIABLES {
|
||||
return Err(CliError::variable_limit_exceeded(name, N::MAX_DEPLOYMENT_VARIABLES, network).into());
|
||||
}
|
||||
if deployment.num_combined_constraints()? > N::MAX_DEPLOYMENT_CONSTRAINTS {
|
||||
return Err(CliError::constraint_limit_exceeded(name, N::MAX_DEPLOYMENT_CONSTRAINTS, network).into());
|
||||
}
|
||||
|
||||
let deployment_id = deployment.to_deployment_id()?;
|
||||
|
||||
let store = ConsensusStore::<N, ConsensusMemory<N>>::open(StorageMode::Production)?;
|
||||
|
Loading…
Reference in New Issue
Block a user