diff --git a/aleph-client/Cargo.lock b/aleph-client/Cargo.lock index 9d18828332..34b679cfc2 100644 --- a/aleph-client/Cargo.lock +++ b/aleph-client/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.11.0" +version = "2.12.0" dependencies = [ "anyhow", "async-trait", diff --git a/aleph-client/Cargo.toml b/aleph-client/Cargo.toml index aa89266191..95f31e96e0 100644 --- a/aleph-client/Cargo.toml +++ b/aleph-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph_client" -version = "2.11.0" +version = "2.12.0" edition = "2021" license = "Apache 2.0" diff --git a/aleph-client/src/contract/mod.rs b/aleph-client/src/contract/mod.rs index 077fa4eaf9..242f49f7db 100644 --- a/aleph-client/src/contract/mod.rs +++ b/aleph-client/src/contract/mod.rs @@ -59,23 +59,43 @@ use crate::{ AccountId, Balance, ConnectionApi, SignedConnectionApi, TxStatus, }; +/// Default gas limit, which allows up to 25% of block time (62.5% of the actual block capacity). +pub const DEFAULT_MAX_GAS: u64 = 250_000_000_000u64; +/// Default proof size limit, which allows up to 25% of block time (62.5% of the actual block +/// capacity). +pub const DEFAULT_MAX_PROOF_SIZE: u64 = 250_000_000_000u64; + /// Represents a contract instantiated on the chain. pub struct ContractInstance { address: AccountId, transcoder: ContractMessageTranscoder, + max_gas_override: Option, + max_proof_size_override: Option, } impl ContractInstance { - const MAX_GAS: u64 = 10000000000u64; - /// Creates a new contract instance under `address` with metadata read from `metadata_path`. pub fn new(address: AccountId, metadata_path: &str) -> Result { Ok(Self { address, transcoder: ContractMessageTranscoder::load(metadata_path)?, + max_gas_override: None, + max_proof_size_override: None, }) } + /// From now on, the contract instance will use `limit_override` as the gas limit for all + /// contract calls. If `limit_override` is `None`, then [DEFAULT_MAX_GAS] will be used. + pub fn override_gas_limit(&mut self, limit_override: Option) { + self.max_gas_override = limit_override; + } + + /// From now on, the contract instance will use `limit_override` as the proof size limit for all + /// contract calls. If `limit_override` is `None`, then [DEFAULT_MAX_PROOF_SIZE] will be used. + pub fn override_proof_size_limit(&mut self, limit_override: Option) { + self.max_proof_size_override = limit_override; + } + /// The address of this contract instance. pub fn address(&self) -> &AccountId { &self.address @@ -168,8 +188,10 @@ impl ContractInstance { self.address.clone(), value, Weight { - ref_time: Self::MAX_GAS, - proof_size: Self::MAX_GAS, + ref_time: self.max_gas_override.unwrap_or(DEFAULT_MAX_GAS), + proof_size: self + .max_proof_size_override + .unwrap_or(DEFAULT_MAX_PROOF_SIZE), }, None, data, diff --git a/benches/payout-stakers/Cargo.lock b/benches/payout-stakers/Cargo.lock index c989b6e7f8..ff4de412e7 100644 --- a/benches/payout-stakers/Cargo.lock +++ b/benches/payout-stakers/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.11.0" +version = "2.12.0" dependencies = [ "anyhow", "async-trait", diff --git a/bin/cliain/Cargo.lock b/bin/cliain/Cargo.lock index 2b31f33e68..36f550dc83 100644 --- a/bin/cliain/Cargo.lock +++ b/bin/cliain/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.11.0" +version = "2.12.0" dependencies = [ "anyhow", "async-trait", diff --git a/e2e-tests/Cargo.lock b/e2e-tests/Cargo.lock index 8c7d5f5cb3..65e4f412e7 100644 --- a/e2e-tests/Cargo.lock +++ b/e2e-tests/Cargo.lock @@ -78,7 +78,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.11.0" +version = "2.12.0" dependencies = [ "anyhow", "async-trait", diff --git a/flooder/Cargo.lock b/flooder/Cargo.lock index 305eb625fa..1a7a86ab31 100644 --- a/flooder/Cargo.lock +++ b/flooder/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aleph_client" -version = "2.11.0" +version = "2.12.0" dependencies = [ "anyhow", "async-trait",