Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
463866e
Update `polkadot-sdk` hash to `c40b36c3a7c208f9a6837b80812473af3d9ba7f7`
cmichi Aug 12, 2025
fb0bc7a
Cast to new argument type (`U256`)
cmichi Aug 12, 2025
db42f23
Use pre-compile for `Blake2x256`
cmichi Aug 5, 2025
89019ab
Fixes around storage deposit limit
cmichi Aug 13, 2025
559f4dd
Treat contract revert as error
cmichi Aug 13, 2025
7d11a98
Add clarification comment
cmichi Aug 13, 2025
3db7173
Fix comment
cmichi Aug 13, 2025
c157fbf
Apply `cargo fmt`
cmichi Aug 13, 2025
c7dcaff
Update changelog
cmichi Aug 13, 2025
897c183
Fix imports
cmichi Aug 13, 2025
0800756
Fix reimports
cmichi Aug 14, 2025
0a49448
Update to synced `cargo-contract` branch
cmichi Aug 22, 2025
d41c880
Merge remote-tracking branch 'origin/master' into cmichi-sync-with-la…
cmichi Aug 22, 2025
4cae7a8
Apply `cargo fmt`
cmichi Aug 22, 2025
40fffcb
Fix CI
cmichi Aug 22, 2025
9a1a1ec
Fix CI
cmichi Aug 22, 2025
3c9a283
Use `cargo-contract` `master` again
cmichi Aug 22, 2025
fef84eb
Convert value correctly between `Balance` and `U256`
cmichi Aug 22, 2025
3cae7b4
Make `clippy` happy
cmichi Aug 22, 2025
2a97efc
Fix types
cmichi Aug 22, 2025
47e1e32
Improve balance conversion code
cmichi Aug 23, 2025
8059800
Minor code cleanup
cmichi Aug 23, 2025
0418c58
Use `saturating_mul`
cmichi Aug 25, 2025
cfff5d5
Implement basic Solidity encoding for selector + `bytes`
cmichi Aug 25, 2025
078e641
Fix CI
cmichi Aug 25, 2025
a05d71b
Fix encoding to Solidity `bytes`
cmichi Aug 26, 2025
eef1bc7
Fix calling `hashBlake256` pre-compile function
cmichi Aug 26, 2025
39a783c
Test for the actual hash appearing
cmichi Aug 26, 2025
95219e7
Make assert less greedy
cmichi Aug 26, 2025
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[Unreleased]

### Changed
- Synchronized with `polkadot-sdk/c40b36c3a7c208f9a6837b80812473af3d9ba7f7` ‒ [2589](https://github.com/use-ink/ink/pull/2589)

### Fixed
- E2E: Fixes around correct handling of storage deposit limit ‒ [#2589](https://github.com/use-ink/ink/pull/2589)

## Version 6.0.0-alpha.1

### Added
- Support ABI `cfg` flag in codegen - [#2501](https://github.com/use-ink/ink/pull/2501)
- Generate Solidity ABI compatibility metadata - [#2510](https://github.com/use-ink/ink/pull/2510)
Expand Down
915 changes: 465 additions & 450 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ const_env = { version = "0.1" }

# Substrate dependencies
frame-metadata = { version = "23.0.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }

pallet-revive = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false, features = ["unstable-hostfn"] }
pallet-revive = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false, features = ["unstable-hostfn"] }

sp-externalities = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false, features = ["disable_target_static_assertions"] }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false }
sp-externalities = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false, features = ["disable_target_static_assertions"] }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false }

# PolkaVM dependencies
polkavm-derive = { version = "0.26.0", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ sp-weights = { workspace = true }
regex = "1.11.1"
itertools = "0.14.0"

sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "cb629d46ebf00aa65624013a61f9c69ebf02b0b4", default-features = false, features = ["disable_target_static_assertions"] }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "c40b36c3a7c208f9a6837b80812473af3d9ba7f7", default-features = false, features = ["disable_target_static_assertions"] }

# todo Pin until https://github.com/jhpratt/deranged/issues/18 is resolved
deranged = { version = "=0.4.0", default-features = false }
Expand Down
7 changes: 4 additions & 3 deletions crates/e2e/sandbox/src/api/revive_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
balance_to_evm_value,
AccountIdFor,
ContractExecResultFor,
ContractResultInstantiate,
Expand Down Expand Up @@ -178,7 +179,7 @@ where
self.execute_with(|| {
pallet_revive::Pallet::<Self::T>::bare_instantiate(
origin,
value,
balance_to_evm_value::<BalanceOf<Self::T>>(value),
gas_limit,
storage_deposit_limit,
Code::Upload(contract_bytes),
Expand All @@ -203,7 +204,7 @@ where
self.execute_with(|| {
pallet_revive::Pallet::<Self::T>::bare_instantiate(
origin,
value,
balance_to_evm_value::<BalanceOf<Self::T>>(value),
gas_limit,
storage_deposit_limit,
Code::Existing(code_hash),
Expand Down Expand Up @@ -243,7 +244,7 @@ where
pallet_revive::Pallet::<Self::T>::bare_call(
origin,
address,
value,
balance_to_evm_value::<BalanceOf<Self::T>>(value),
gas_limit,
storage_deposit_limit,
data,
Expand Down
19 changes: 19 additions & 0 deletions crates/e2e/sandbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use frame_system::{
},
EventRecord,
};
use ink_primitives::U256;
pub use macros::{
BlockBuilder,
DefaultSandbox,
Expand Down Expand Up @@ -147,3 +148,21 @@ pub trait Sandbox {
/// Restore the storage from the given snapshot.
fn restore_snapshot(&mut self, snapshot: Snapshot);
}

/// Converts from the generic `Balance` type to the Ethereum native `U256`.
///
/// # Developer Note
///
/// `pallet-revive` uses both types, hence we have to convert in between them
/// for certain functions. Notice that precision loss might occur when converting
/// the other way (from `U256` to `Balance`).
///
/// See <https://github.com/paritytech/polkadot-sdk/pull/9101> for more details.
pub fn balance_to_evm_value<Balance>(value: Balance) -> U256
where
Balance: Into<U256>,
{
let native_to_eth_ratio: U256 = 100_000_000.into();
let evm_value: U256 = value.into();
native_to_eth_ratio.saturating_mul(evm_value)
}
15 changes: 8 additions & 7 deletions crates/e2e/src/backend_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use sp_weights::Weight;

use super::{
balance_to_deposit_limit,
balance_to_deposit_limit_dry_run,
InstantiateDryRunResult,
Keypair,
};
Expand Down Expand Up @@ -56,7 +57,7 @@ where
value: E::Balance,
extra_gas_portion: Option<u64>,
gas_limit: Option<Weight>,
storage_deposit_limit: E::Balance,
storage_deposit_limit: Option<E::Balance>,
}

impl<'a, E, Args, RetType, B, Abi> CallBuilder<'a, E, Args, RetType, B, Abi>
Expand All @@ -83,7 +84,7 @@ where
value: 0u32.into(),
extra_gas_portion: None,
gas_limit: None,
storage_deposit_limit: 0u32.into(),
storage_deposit_limit: None,
}
}

Expand Down Expand Up @@ -130,7 +131,7 @@ where
&mut self,
storage_deposit_limit: E::Balance,
) -> &mut Self {
self.storage_deposit_limit = storage_deposit_limit;
self.storage_deposit_limit = Some(storage_deposit_limit);
self
}

Expand All @@ -151,7 +152,7 @@ where
self.caller,
self.message,
self.value,
balance_to_deposit_limit::<E>(self.storage_deposit_limit),
balance_to_deposit_limit_dry_run::<E>(self.storage_deposit_limit),
)
.await?;

Expand Down Expand Up @@ -192,7 +193,7 @@ where
self.caller,
self.message,
self.value,
balance_to_deposit_limit::<E>(self.storage_deposit_limit),
balance_to_deposit_limit_dry_run::<E>(self.storage_deposit_limit),
)
.await
}
Expand Down Expand Up @@ -330,9 +331,9 @@ where
self.constructor,
self.value,
gas_limit,
balance_to_deposit_limit::<E>(
balance_to_deposit_limit::<E>(Some(
dry_run.contract_result.storage_deposit.charge_or_zero(),
),
)),
)
.await?;

Expand Down
3 changes: 2 additions & 1 deletion crates/e2e/src/contract_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ fn build_contracts(
contract_manifests: &[(PathBuf, Vec<String>)],
target_dir: PathBuf,
) -> Vec<PathBuf> {
#[allow(clippy::type_complexity)]
static CONTRACT_BUILD_JOBS: OnceLock<
Mutex<HashMap<(PathBuf, Vec<String>), PathBuf>>,
> = OnceLock::new();
Expand Down Expand Up @@ -191,7 +192,7 @@ fn build_contracts(

fn add_features_to_filename(
contract_binary_path: PathBuf,
features: &Vec<String>,
features: &[String],
) -> PathBuf {
// add features to file name
let mut path_with_features = contract_binary_path.clone();
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/src/contract_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl<E: Environment, Abi> From<ContractInstantiateResultFor<E>>
impl<E: Environment, Abi> InstantiateDryRunResult<E, Abi> {
/// Returns true if the dry-run execution resulted in an error.
pub fn is_err(&self) -> bool {
self.contract_result.result.is_err()
self.contract_result.result.is_err() || self.did_revert()
}

/// Returns the [`InstantiateReturnValue`] resulting from the dry-run message call.
Expand Down
40 changes: 33 additions & 7 deletions crates/e2e/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,44 @@ where
<<Contract as ContractCallBuilder>::Type<Abi> as FromAddr>::from_addr(acc_id)
}

/// Transforms `Option<<E as Environment>::Balance>>` into `DepositLimit`.
///
/// This function must only be used for dry-runs, a `None` will
/// become an unrestricted deposit limit (`DepositLimit::UnsafeOnlyForDryRun`).
fn balance_to_deposit_limit_dry_run<E: Environment>(
b: Option<<E as Environment>::Balance>,
) -> DepositLimit<<E as Environment>::Balance> {
match b {
Some(v) => DepositLimit::Balance(v),
None => DepositLimit::UnsafeOnlyForDryRun,
}
}

/// Transforms `Option<<E as Environment>::Balance>>` into `DepositLimit`.
/// This function must be used for submitting extrinsics on-chain.
///
/// Panics if `limit` is `None`. Make sure to execute a dry-run
/// beforehand and use the `storage_deposit_limit` result of it here.
fn balance_to_deposit_limit<E: Environment>(
b: <E as Environment>::Balance,
limit: Option<<E as Environment>::Balance>,
) -> DepositLimit<<E as Environment>::Balance> {
DepositLimit::Balance(b)
match limit {
Some(val) => DepositLimit::Balance(val),
None => panic!("Deposit limit must be specified for on-chain submissions."),
}
}

/// Transforms `DepositLimit<<E as Environment>::Balance>` into `<E as
/// Environment>::Balance>`.
///
/// Panics if `limit` is unrestricted (`DepositLimit::UnsafeOnlyForDryRun`).
fn deposit_limit_to_balance<E: Environment>(
l: DepositLimit<<E as Environment>::Balance>,
limit: DepositLimit<<E as Environment>::Balance>,
) -> <E as Environment>::Balance {
match l {
DepositLimit::Balance(l) => l,
// todo
DepositLimit::UnsafeOnlyForDryRun => panic!("`Unchecked` is not supported"),
match limit {
DepositLimit::Balance(val) => val,
DepositLimit::UnsafeOnlyForDryRun => {
panic!("Unrestricted deposit limit not allowed for balance conversion!")
}
}
}
1 change: 1 addition & 0 deletions crates/e2e/src/sandbox_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ where
/// Exposes preset sandbox configurations to be used in tests.
pub mod preset {
/*
// todo
pub mod mock_network {
use ink_sandbox::{
frame_system,
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/src/subxt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ where
dest,
exec_input,
value,
deposit_limit_to_balance::<E>(storage_deposit_limit),
storage_deposit_limit,
caller,
)
.await;
Expand Down
Loading
Loading