contracts: Improve contract address derivation (#12883)

* Add prefix to address derivation

* Extend benchmark

* Fix node test

* ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts

* Adapt to new benchmark

* Update dispatchable benchmarks

* ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts

* Use benchmark results

* Apply suggestions from code review

Co-authored-by: Sasha Gryaznov <hi@agryaznov.com>

* Don't use T::AdressGenerator directly

* Rename constructor_args to input_data

Co-authored-by: command-bot <>
Co-authored-by: Sasha Gryaznov <hi@agryaznov.com>
This commit is contained in:
Alexander Theißen
2022-12-22 15:52:48 +01:00
committed by GitHub
parent af15848be0
commit 4083b5358a
18 changed files with 1559 additions and 1479 deletions
+4 -10
View File
@@ -36,7 +36,7 @@ use crate::{
};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::dispatch::{DispatchError, DispatchResult};
use sp_core::{crypto::UncheckedFrom, Get};
use sp_core::Get;
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;
#[cfg(test)]
@@ -140,10 +140,7 @@ impl ExportedFunction {
}
}
impl<T: Config> PrefabWasmModule<T>
where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
impl<T: Config> PrefabWasmModule<T> {
/// Create the module by checking and instrumenting `original_code`.
///
/// This does **not** store the module. For this one need to either call [`Self::store`]
@@ -263,10 +260,7 @@ impl<T: Config> OwnerInfo<T> {
}
}
impl<T: Config> Executable<T> for PrefabWasmModule<T>
where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
impl<T: Config> Executable<T> for PrefabWasmModule<T> {
fn from_storage(
code_hash: CodeHash<T>,
schedule: &Schedule<T>,
@@ -476,7 +470,7 @@ mod tests {
salt: salt.to_vec(),
});
Ok((
Contracts::<Test>::contract_address(&ALICE, &code_hash, salt),
Contracts::<Test>::contract_address(&ALICE, &code_hash, &data, salt),
ExecReturnValue { flags: ReturnFlags::empty(), data: Vec::new() },
))
}