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 Typo: Use 'Proof Size' Instead of 'Proof Time' #2132

Merged
merged 7 commits into from
Mar 6, 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
253 changes: 35 additions & 218 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cfg-if = { version = "1.0" }
contract-build = { version = "4.0.0-rc.3" }
darling = { version = "0.20.8" }
derive_more = { version = "0.99.17", default-features = false }
drink = { version = "=0.11.0" }
drink = { version = "=0.12.0", default-features = false, features = ["std"] }
either = { version = "1.5", default-features = false }
funty = { version = "2.0.0" }
heck = { version = "0.4.0" }
Expand Down Expand Up @@ -84,7 +84,7 @@ const_env = { version = "0.1"}

# Substrate dependencies
pallet-contracts = { version = "27.0.0", default-features = false }
pallet-contracts-uapi = { package = "pallet-contracts-uapi-next", version = "=6.0.1", default-features = false }
pallet-contracts-uapi = { package = "pallet-contracts-uapi-next", version = "=6.0.3", default-features = false }
sp-core = { version = "28.0.0", default-features = false }
sp-keyring = { version = "31.0.0", default-features = false }
sp-runtime = { version = "31.0.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ where
/// - If the called account is not a contract.
/// - If arguments passed to the called contract message are invalid.
/// - If the called contract execution has trapped.
/// - If the called contract ran out of gas, proof time, or storage deposit upon
/// - If the called contract ran out of gas, proof size, or storage deposit upon
/// execution.
/// - If the returned value failed to decode properly.
pub fn invoke_contract<E, Args, R>(
Expand Down
20 changes: 10 additions & 10 deletions crates/env/src/call/call_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ where
self.call_type.ref_time_limit
}

/// Returns the chosen proof time limit for the called contract execution.
/// Returns the chosen proof size limit for the called contract execution.
#[inline]
pub fn proof_time_limit(&self) -> u64 {
self.call_type.proof_time_limit
pub fn proof_size_limit(&self) -> u64 {
pgherveou marked this conversation as resolved.
Show resolved Hide resolved
self.call_type.proof_size_limit
}

/// Returns the chosen storage deposit limit for the called contract execution.
Expand Down Expand Up @@ -455,13 +455,13 @@ where
}

/// The default call type for cross-contract calls, for calling into the latest `call_v2`
/// host function. This adds the additional weight limit parameter `proof_time_limit` as
/// host function. This adds the additional weight limit parameter `proof_size_limit` as
/// well as `storage_deposit_limit`.
#[derive(Clone)]
pub struct Call<E: Environment> {
callee: E::AccountId,
ref_time_limit: u64,
proof_time_limit: u64,
proof_size_limit: u64,
storage_deposit_limit: Option<E::Balance>,
transferred_value: E::Balance,
}
Expand All @@ -472,7 +472,7 @@ impl<E: Environment> Call<E> {
Self {
callee,
ref_time_limit: Default::default(),
proof_time_limit: Default::default(),
proof_size_limit: Default::default(),
storage_deposit_limit: None,
transferred_value: E::Balance::zero(),
}
Expand Down Expand Up @@ -724,22 +724,22 @@ where
}
}

/// Sets the `proof_time_limit` part of the weight limit for the current
/// Sets the `proof_size_limit` part of the weight limit for the current
/// cross-contract call.
///
/// `proof_time` refers to the amount of storage in bytes that a transaction
/// `proof_size` refers to the amount of storage in bytes that a transaction
/// is allowed to read. You can find more info
/// [here](https://use.ink/basics/cross-contract-calling/).
///
/// **Note**
///
/// This limit is only relevant for parachains, not for standalone chains which do not
/// require sending a Proof-of-validity to the relay chain.
pub fn proof_time_limit(self, proof_time_limit: Gas) -> Self {
pub fn proof_size_limit(self, proof_size_limit: Gas) -> Self {
let call_type = self.call_type.value();
CallBuilder {
call_type: Set(Call {
proof_time_limit,
proof_size_limit,
..call_type
}),
..self
Expand Down
16 changes: 8 additions & 8 deletions crates/env/src/call/create_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ where
E: Environment,
{
ref_time_limit: u64,
proof_time_limit: u64,
proof_size_limit: u64,
storage_deposit_limit: Option<E::Balance>,
}

Expand Down Expand Up @@ -250,11 +250,11 @@ where
self.limits.ref_time_limit
}

/// Gets the `proof_time_limit` part of the weight limit for the contract
/// Gets the `proof_size_limit` part of the weight limit for the contract
/// instantiation.
#[inline]
pub fn proof_time_limit(&self) -> u64 {
self.limits.proof_time_limit
pub fn proof_size_limit(&self) -> u64 {
self.limits.proof_size_limit
}

/// Gets the `storage_deposit_limit` for the contract instantiation.
Expand Down Expand Up @@ -519,7 +519,7 @@ where
code_hash: Default::default(),
limits: Set(LimitParamsV2 {
ref_time_limit: 0,
proof_time_limit: 0,
proof_size_limit: 0,
storage_deposit_limit: None,
}),
endowment: Default::default(),
Expand Down Expand Up @@ -636,13 +636,13 @@ where
}
}

/// Sets the `proof_time_limit` part of the weight limit for the contract
/// Sets the `proof_size_limit` part of the weight limit for the contract
/// instantiation.
#[inline]
pub fn proof_time_limit(self, proof_time_limit: u64) -> Self {
pub fn proof_size_limit(self, proof_size_limit: u64) -> Self {
CreateBuilder {
limits: Set(LimitParamsV2 {
proof_time_limit,
proof_size_limit,
..self.limits.value()
}),
..self
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/engine/off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl TypedEnvBackend for EnvInstance {
{
let _code_hash = params.code_hash();
let _ref_time_limit = params.ref_time_limit();
let _proof_time_limit = params.proof_time_limit();
let _proof_size_limit = params.proof_size_limit();
let _storage_deposit_limit = params.storage_deposit_limit();
let _endowment = params.endowment();
let _input = params.exec_input();
Expand Down
8 changes: 4 additions & 4 deletions crates/env/src/engine/on_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ impl TypedEnvBackend for EnvInstance {
{
let mut scope = self.scoped_buffer();
let ref_time_limit = params.ref_time_limit();
let proof_time_limit = params.proof_time_limit();
let proof_size_limit = params.proof_size_limit();
let storage_deposit_limit = params
.storage_deposit_limit()
.map(|limit| &*scope.take_encoded(limit));
Expand All @@ -499,7 +499,7 @@ impl TypedEnvBackend for EnvInstance {
*flags,
enc_callee,
ref_time_limit,
proof_time_limit,
proof_size_limit,
storage_deposit_limit,
enc_transferred_value,
enc_input,
Expand Down Expand Up @@ -563,7 +563,7 @@ impl TypedEnvBackend for EnvInstance {
{
let mut scoped = self.scoped_buffer();
let ref_time_limit = params.ref_time_limit();
let proof_time_limit = params.proof_time_limit();
let proof_size_limit = params.proof_size_limit();
let storage_deposit_limit = params
.storage_deposit_limit()
.map(|limit| &*scoped.take_encoded(limit));
Expand All @@ -577,7 +577,7 @@ impl TypedEnvBackend for EnvInstance {
let instantiate_result = ext::instantiate_v2(
enc_code_hash,
ref_time_limit,
proof_time_limit,
proof_size_limit,
storage_deposit_limit,
enc_endowment,
enc_input,
Expand Down
4 changes: 2 additions & 2 deletions crates/ink/src/env_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ where
/// let create_params = build_create::<OtherContractRef>()
/// .code_hash(Hash::from([0x42; 32]))
/// .ref_time_limit(500_000_000)
/// .proof_time_limit(100_000)
/// .proof_size_limit(100_000)
/// .storage_deposit_limit(500_000_000_000)
/// .endowment(25)
/// .exec_input(
Expand Down Expand Up @@ -707,7 +707,7 @@ where
/// let call_params = build_call::<DefaultEnvironment>()
/// .call(AccountId::from([0x42; 32]))
/// .ref_time_limit(500_000_000)
/// .proof_time_limit(100_000)
/// .proof_size_limit(100_000)
/// .storage_deposit_limit(1_000_000_000)
/// .exec_input(
/// ExecutionInput::new(Selector::new([0xCA, 0xFE, 0xBA, 0xBE]))
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/cross-contract-calls/e2e_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ async fn instantiate_v2_with_insufficient_storage_deposit_limit<Client: E2EBacke
.expect("other_contract upload failed");

const REF_TIME_LIMIT: u64 = 500_000_000;
const PROOF_TIME_LIMIT: u64 = 100_000;
const PROOF_SIZE_LIMIT: u64 = 100_000;
const STORAGE_DEPOSIT_LIMIT: u128 = 100_000_000_000;

let mut constructor = CrossContractCallsRef::new_v2_with_limits(
other_contract_code.code_hash,
REF_TIME_LIMIT,
PROOF_TIME_LIMIT,
PROOF_SIZE_LIMIT,
STORAGE_DEPOSIT_LIMIT,
);
let contract = client
Expand Down Expand Up @@ -87,13 +87,13 @@ async fn instantiate_v2_with_sufficient_limits<Client: E2EBackend>(
.expect("other_contract upload failed");

const REF_TIME_LIMIT: u64 = 500_000_000;
const PROOF_TIME_LIMIT: u64 = 100_000;
const PROOF_SIZE_LIMIT: u64 = 100_000;
const STORAGE_DEPOSIT_LIMIT: u128 = 500_000_000_000;

let mut constructor = CrossContractCallsRef::new_v2_with_limits(
other_contract_code.code_hash,
REF_TIME_LIMIT,
PROOF_TIME_LIMIT,
PROOF_SIZE_LIMIT,
STORAGE_DEPOSIT_LIMIT,
);
let contract = client
Expand Down Expand Up @@ -147,13 +147,13 @@ async fn flip_and_get_v2<Client: E2EBackend>(mut client: Client) -> E2EResult<()
let mut call_builder = contract.call_builder::<CrossContractCalls>();

const REF_TIME_LIMIT: u64 = 500_000_000;
const PROOF_TIME_LIMIT: u64 = 100_000;
const PROOF_SIZE_LIMIT: u64 = 100_000;
const STORAGE_DEPOSIT_LIMIT: u128 = 1_000_000_000;

// when
let call = call_builder.flip_and_get_invoke_v2_with_limits(
REF_TIME_LIMIT,
PROOF_TIME_LIMIT,
PROOF_SIZE_LIMIT,
STORAGE_DEPOSIT_LIMIT,
);
let result = client
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/cross-contract-calls/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ mod cross_contract_calls {
pub fn new_v2_with_limits(
other_contract_code_hash: Hash,
ref_time_limit: u64,
proof_time_limit: u64,
proof_size_limit: u64,
storage_deposit_limit: Balance,
) -> Self {
let other_contract = OtherContractRef::new(true)
.code_hash(other_contract_code_hash)
.endowment(0)
.salt_bytes([0xDE, 0xAD, 0xBE, 0xEF])
.ref_time_limit(ref_time_limit)
.proof_time_limit(proof_time_limit)
.proof_size_limit(proof_size_limit)
.storage_deposit_limit(storage_deposit_limit)
.instantiate();

Expand Down Expand Up @@ -82,22 +82,22 @@ mod cross_contract_calls {
pub fn flip_and_get_invoke_v2_with_limits(
&mut self,
ref_time_limit: u64,
proof_time_limit: u64,
proof_size_limit: u64,
storage_deposit_limit: Balance,
) -> bool {
let call_builder = self.other_contract.call_mut();

call_builder
.flip()
.ref_time_limit(ref_time_limit)
.proof_time_limit(proof_time_limit)
.proof_size_limit(proof_size_limit)
.storage_deposit_limit(storage_deposit_limit)
.invoke();

call_builder
.get()
.ref_time_limit(ref_time_limit)
.proof_time_limit(proof_time_limit)
.proof_size_limit(proof_size_limit)
.storage_deposit_limit(storage_deposit_limit)
.invoke()
}
Expand Down