Skip to content

Commit 84fcbe8

Browse files
authored
Synchronize with polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce (#2675)
* Use `polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce` * Switch `delegate_call` to `call` for some precompiles * Adapt to changes in `pallet-revive` API * Adjust to removal of `DepositLimit` * Adapt to changes in `pallet-revive` API * Update changelog * Temporarily use `cargo-contract` branch * Adapt `CallTrace` to changes in `pallet-revive` * Use `contract-build/master` * Adapt `CallTrace` to changes in `pallet-revive` * Fix failing tests * Fix parameter * Fix tests
1 parent f95007e commit 84fcbe8

File tree

27 files changed

+833
-359
lines changed

27 files changed

+833
-359
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578)
1717
- Stabilize `is_contract` - [#2654](https://github.com/use-ink/ink/pull/2654)
1818
- Extract `sandbox` from `ink_e2e` into a new `ink_sandbox` crate - [#2659](https://github.com/use-ink/ink/pull/2659)
19+
- Synchronize with `polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce`[2675](https://github.com/use-ink/ink/pull/2675)
1920

2021
### Fixed
2122
- Fix decoding of `HostFn::minimum_balance` return value - [#2656](https://github.com/use-ink/ink/pull/2656)

Cargo.lock

Lines changed: 486 additions & 125 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ scale-info = { version = "2.11", default-features = false }
6464
schemars = { version = "0.8" }
6565
secp256k1 = { version = "0.30.0" }
6666
serde = { version = "1.0.215", default-features = false }
67-
serde_json = { version = "1.0.137" }
67+
serde_json = { version = "1.0.145" }
6868
sha2 = { version = "0.10" }
6969
sha3 = { version = "0.10" }
7070
static_assertions = { version = "1.1" }

crates/e2e/src/backend.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use ink_env::{
1717
call::utils::DecodeMessageResult,
1818
};
1919
use ink_primitives::{
20-
DepositLimit,
2120
H160,
2221
abi::AbiEncodeWith,
2322
};
@@ -242,8 +241,8 @@ pub trait ContractsBackend<E: Environment> {
242241

243242
#[async_trait]
244243
pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
245-
/// Executes a bare `call` for the contract at `account_id`. This function does not
246-
/// perform a dry-run, and the user is expected to provide the gas limit.
244+
/// Executes a bare `call` for the contract at `account_id`. This function does
245+
/// _not_ perform a dry-run, and the user is expected to provide the gas limit.
247246
///
248247
/// Use it when you want to have a more precise control over submitting extrinsic.
249248
///
@@ -259,7 +258,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
259258
message: &CallBuilderFinal<E, Args, RetType, Abi>,
260259
value: E::Balance,
261260
gas_limit: Weight,
262-
storage_deposit_limit: DepositLimit<E::Balance>,
261+
storage_deposit_limit: E::Balance,
263262
) -> Result<(Self::EventLog, Option<CallTrace>), Self::Error>
264263
where
265264
CallBuilderFinal<E, Args, RetType, Abi>: Clone;
@@ -282,7 +281,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
282281
caller: &Keypair,
283282
message: &CallBuilderFinal<E, Args, RetType, Abi>,
284283
value: E::Balance,
285-
storage_deposit_limit: DepositLimit<E::Balance>,
284+
storage_deposit_limit: Option<E::Balance>,
286285
) -> Result<CallDryRunResult<E, RetType, Abi>, Self::Error>
287286
where
288287
CallBuilderFinal<E, Args, RetType, Abi>: Clone;
@@ -304,7 +303,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
304303
dest: H160,
305304
input_data: Vec<u8>,
306305
value: E::Balance,
307-
storage_deposit_limit: DepositLimit<E::Balance>,
306+
storage_deposit_limit: Option<E::Balance>,
308307
signer: &Keypair,
309308
) -> Result<CallDryRunResult<E, RetType, Abi>, Self::Error>;
310309

@@ -318,7 +317,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
318317
input_data: Vec<u8>,
319318
value: E::Balance,
320319
gas_limit: Weight,
321-
storage_deposit_limit: DepositLimit<E::Balance>,
320+
storage_deposit_limit: E::Balance,
322321
signer: &Keypair,
323322
) -> Result<(Self::EventLog, Option<CallTrace>), Self::Error>;
324323

@@ -368,7 +367,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
368367
constructor: &mut CreateBuilderPartial<E, Contract, Args, R, Abi>,
369368
value: E::Balance,
370369
gas_limit: Weight,
371-
storage_deposit_limit: DepositLimit<E::Balance>,
370+
storage_deposit_limit: E::Balance,
372371
) -> Result<BareInstantiationResult<E, Self::EventLog>, Self::Error>;
373372

374373
async fn raw_instantiate(
@@ -378,7 +377,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
378377
constructor: Vec<u8>,
379378
value: E::Balance,
380379
gas_limit: Weight,
381-
storage_deposit_limit: DepositLimit<E::Balance>,
380+
storage_deposit_limit: E::Balance,
382381
) -> Result<BareInstantiationResult<E, Self::EventLog>, Self::Error>;
383382

384383
async fn raw_instantiate_dry_run<Abi: Sync + Clone>(
@@ -387,7 +386,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
387386
caller: &Keypair,
388387
constructor: Vec<u8>,
389388
value: E::Balance,
390-
storage_deposit_limit: DepositLimit<E::Balance>,
389+
storage_deposit_limit: Option<E::Balance>,
391390
) -> Result<InstantiateDryRunResult<E, Abi>, Self::Error>;
392391

393392
async fn exec_instantiate(
@@ -417,7 +416,7 @@ pub trait BuilderClient<E: Environment>: ContractsBackend<E> {
417416
caller: &Keypair,
418417
constructor: &mut CreateBuilderPartial<E, Contract, Args, R, Abi>,
419418
value: E::Balance,
420-
storage_deposit_limit: DepositLimit<E::Balance>,
419+
storage_deposit_limit: Option<E::Balance>,
421420
) -> Result<InstantiateDryRunResult<E, Abi>, Self::Error>;
422421

423422
/// Checks if `caller` was already mapped in `pallet-revive`. If not, it will do so

crates/e2e/src/backend_calls.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@ use ink_env::{
1818
Environment,
1919
call::utils::DecodeMessageResult,
2020
};
21-
use ink_primitives::{
22-
DepositLimit,
23-
abi::AbiEncodeWith,
24-
};
21+
use ink_primitives::abi::AbiEncodeWith;
2522
use sp_weights::Weight;
2623

2724
use super::{
2825
InstantiateDryRunResult,
2926
Keypair,
30-
balance_to_deposit_limit,
31-
balance_to_deposit_limit_dry_run,
3227
};
3328
use crate::{
3429
CallBuilderFinal,
@@ -152,7 +147,7 @@ where
152147
self.caller,
153148
self.message,
154149
self.value,
155-
balance_to_deposit_limit_dry_run::<E>(self.storage_deposit_limit),
150+
self.storage_deposit_limit,
156151
)
157152
.await?;
158153

@@ -171,8 +166,7 @@ where
171166
self.message,
172167
self.value,
173168
gas_limit,
174-
// todo: the `bare_call` converts this value back, this is unnecessary work
175-
DepositLimit::Balance(dry_run.exec_result.storage_deposit.charge_or_zero()),
169+
dry_run.exec_result.storage_deposit.charge_or_zero(),
176170
)
177171
.await?;
178172

@@ -193,7 +187,7 @@ where
193187
self.caller,
194188
self.message,
195189
self.value,
196-
balance_to_deposit_limit_dry_run::<E>(self.storage_deposit_limit),
190+
self.storage_deposit_limit,
197191
)
198192
.await
199193
}
@@ -214,7 +208,7 @@ where
214208
value: E::Balance,
215209
extra_gas_portion: Option<u64>,
216210
gas_limit: Option<Weight>,
217-
storage_deposit_limit: DepositLimit<E::Balance>,
211+
storage_deposit_limit: Option<E::Balance>,
218212
}
219213

220214
impl<'a, E, Contract, Args, R, B, Abi>
@@ -244,7 +238,7 @@ where
244238
value: 0u32.into(),
245239
extra_gas_portion: None,
246240
gas_limit: None,
247-
storage_deposit_limit: DepositLimit::UnsafeOnlyForDryRun,
241+
storage_deposit_limit: None,
248242
}
249243
}
250244

@@ -287,9 +281,11 @@ where
287281
}
288282

289283
/// Specify the max amount of funds that can be charged for storage.
284+
///
285+
/// *Important*: `None` means charging the maximum!
290286
pub fn storage_deposit_limit(
291287
&mut self,
292-
storage_deposit_limit: DepositLimit<E::Balance>,
288+
storage_deposit_limit: Option<E::Balance>,
293289
) -> &mut Self {
294290
self.storage_deposit_limit = storage_deposit_limit;
295291
self
@@ -331,9 +327,7 @@ where
331327
self.constructor,
332328
self.value,
333329
gas_limit,
334-
balance_to_deposit_limit::<E>(Some(
335-
dry_run.contract_result.storage_deposit.charge_or_zero(),
336-
)),
330+
dry_run.contract_result.storage_deposit.charge_or_zero(),
337331
)
338332
.await?;
339333

crates/e2e/src/lib.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ use ink_env::{
9797
};
9898
use ink_primitives::{
9999
Address,
100-
DepositLimit,
101100
H256,
102101
types::AccountIdMapper,
103102
};
@@ -207,45 +206,3 @@ where
207206
{
208207
<<Contract as ContractCallBuilder>::Type<Abi> as FromAddr>::from_addr(acc_id)
209208
}
210-
211-
/// Transforms `Option<<E as Environment>::Balance>>` into `DepositLimit`.
212-
///
213-
/// This function must only be used for dry-runs, a `None` will
214-
/// become an unrestricted deposit limit (`DepositLimit::UnsafeOnlyForDryRun`).
215-
fn balance_to_deposit_limit_dry_run<E: Environment>(
216-
b: Option<<E as Environment>::Balance>,
217-
) -> DepositLimit<<E as Environment>::Balance> {
218-
match b {
219-
Some(v) => DepositLimit::Balance(v),
220-
None => DepositLimit::UnsafeOnlyForDryRun,
221-
}
222-
}
223-
224-
/// Transforms `Option<<E as Environment>::Balance>>` into `DepositLimit`.
225-
/// This function must be used for submitting extrinsics on-chain.
226-
///
227-
/// Panics if `limit` is `None`. Make sure to execute a dry-run
228-
/// beforehand and use the `storage_deposit_limit` result of it here.
229-
fn balance_to_deposit_limit<E: Environment>(
230-
limit: Option<<E as Environment>::Balance>,
231-
) -> DepositLimit<<E as Environment>::Balance> {
232-
match limit {
233-
Some(val) => DepositLimit::Balance(val),
234-
None => panic!("Deposit limit must be specified for on-chain submissions."),
235-
}
236-
}
237-
238-
/// Transforms `DepositLimit<<E as Environment>::Balance>` into `<E as
239-
/// Environment>::Balance>`.
240-
///
241-
/// Panics if `limit` is unrestricted (`DepositLimit::UnsafeOnlyForDryRun`).
242-
fn deposit_limit_to_balance<E: Environment>(
243-
limit: DepositLimit<<E as Environment>::Balance>,
244-
) -> <E as Environment>::Balance {
245-
match limit {
246-
DepositLimit::Balance(val) => val,
247-
DepositLimit::UnsafeOnlyForDryRun => {
248-
panic!("Unrestricted deposit limit not allowed for balance conversion!")
249-
}
250-
}
251-
}

crates/e2e/src/subxt_client.rs

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use super::{
2525
CreateBuilderPartial,
2626
constructor_exec_input,
2727
},
28-
deposit_limit_to_balance,
2928
events::{
3029
CodeStoredEvent,
3130
EventWithTopics,
@@ -69,10 +68,7 @@ use ink_env::{
6968
},
7069
},
7170
};
72-
use ink_primitives::{
73-
DepositLimit,
74-
abi::AbiEncodeWith,
75-
};
71+
use ink_primitives::abi::AbiEncodeWith;
7672
use ink_revive_types::evm::CallTrace;
7773
use jsonrpsee::core::async_trait;
7874
use scale::{
@@ -530,7 +526,7 @@ where
530526
constructor: &mut CreateBuilderPartial<E, Contract, Args, R, Abi>,
531527
value: E::Balance,
532528
gas_limit: Weight,
533-
storage_deposit_limit: DepositLimit<E::Balance>,
529+
storage_deposit_limit: E::Balance,
534530
) -> Result<BareInstantiationResult<E, Self::EventLog>, Self::Error> {
535531
let data = constructor_exec_input(constructor.clone());
536532
let ret = self
@@ -546,9 +542,8 @@ where
546542
constructor: Vec<u8>,
547543
value: E::Balance,
548544
gas_limit: Weight,
549-
storage_deposit_limit: DepositLimit<E::Balance>,
545+
storage_deposit_limit: E::Balance,
550546
) -> Result<BareInstantiationResult<E, Self::EventLog>, Self::Error> {
551-
let storage_deposit_limit = deposit_limit_to_balance::<E>(storage_deposit_limit);
552547
let (events, trace) = self
553548
.api
554549
.instantiate_with_code(
@@ -618,15 +613,8 @@ where
618613
storage_deposit_limit: E::Balance,
619614
) -> Result<BareInstantiationResult<E, Self::EventLog>, Self::Error> {
620615
let code = self.contracts.load_code(contract_name);
621-
self.raw_instantiate(
622-
code,
623-
signer,
624-
data,
625-
value,
626-
gas_limit,
627-
DepositLimit::Balance(storage_deposit_limit),
628-
)
629-
.await
616+
self.raw_instantiate(code, signer, data, value, gas_limit, storage_deposit_limit)
617+
.await
630618
}
631619

632620
/// Important: For an uncomplicated UX of the E2E testing environment we
@@ -644,7 +632,7 @@ where
644632
caller: &Keypair,
645633
constructor: &mut CreateBuilderPartial<E, Contract, Args, R, Abi>,
646634
value: E::Balance,
647-
storage_deposit_limit: DepositLimit<E::Balance>,
635+
storage_deposit_limit: Option<E::Balance>,
648636
) -> Result<InstantiateDryRunResult<E, Abi>, Self::Error> {
649637
let code = self.contracts.load_code(contract_name);
650638
let data = constructor_exec_input(constructor.clone());
@@ -662,7 +650,7 @@ where
662650
caller: &Keypair,
663651
data: Vec<u8>,
664652
value: E::Balance,
665-
storage_deposit_limit: DepositLimit<E::Balance>,
653+
storage_deposit_limit: Option<E::Balance>,
666654
) -> Result<InstantiateDryRunResult<E, Abi>, Self::Error> {
667655
// There's a side effect here!
668656
let _ = self.map_account(caller).await;
@@ -749,7 +737,7 @@ where
749737
message: &CallBuilderFinal<E, Args, RetType, Abi>,
750738
value: E::Balance,
751739
gas_limit: Weight,
752-
storage_deposit_limit: DepositLimit<E::Balance>,
740+
storage_deposit_limit: E::Balance,
753741
) -> Result<(Self::EventLog, Option<CallTrace>), Self::Error>
754742
where
755743
CallBuilderFinal<E, Args, RetType, Abi>: Clone,
@@ -774,7 +762,7 @@ where
774762
input_data: Vec<u8>,
775763
value: E::Balance,
776764
gas_limit: Weight,
777-
storage_deposit_limit: DepositLimit<E::Balance>,
765+
storage_deposit_limit: E::Balance,
778766
signer: &Keypair,
779767
) -> Result<(Self::EventLog, Option<CallTrace>), Self::Error> {
780768
let (tx_events, trace) = self
@@ -783,7 +771,7 @@ where
783771
dest,
784772
value,
785773
gas_limit.into(),
786-
deposit_limit_to_balance::<E>(storage_deposit_limit),
774+
storage_deposit_limit,
787775
input_data,
788776
signer,
789777
)
@@ -801,7 +789,7 @@ where
801789
.map_err(|e| Error::Decoding(e.to_string()))?;
802790
log_error(&format!(
803791
"Attempt to stringify returned data: {:?}",
804-
String::from_utf8_lossy(&trace.clone().unwrap().output[..])
792+
String::from_utf8_lossy(&trace.clone().unwrap().output.0[..])
805793
));
806794
log_error(&format!(
807795
"extrinsic for `raw_call` failed: {dispatch_error} {trace:?}"
@@ -828,7 +816,7 @@ where
828816
caller: &Keypair,
829817
message: &CallBuilderFinal<E, Args, RetType, Abi>,
830818
value: E::Balance,
831-
storage_deposit_limit: DepositLimit<E::Balance>,
819+
storage_deposit_limit: Option<E::Balance>,
832820
) -> Result<CallDryRunResult<E, RetType, Abi>, Self::Error>
833821
where
834822
CallBuilderFinal<E, Args, RetType, Abi>: Clone,
@@ -872,7 +860,7 @@ where
872860
dest: H160,
873861
input_data: Vec<u8>,
874862
value: E::Balance,
875-
storage_deposit_limit: DepositLimit<E::Balance>,
863+
storage_deposit_limit: Option<E::Balance>,
876864
signer: &Keypair,
877865
) -> Result<CallDryRunResult<E, RetType, Abi>, Self::Error> {
878866
let (exec_result, trace) = self

0 commit comments

Comments
 (0)