Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

contracts: Refactor trait Ext::*_storage_transparent functions #13600

Merged
merged 7 commits into from
Mar 17, 2023
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
6 changes: 1 addition & 5 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,7 @@ fn deploying_wasm_contract_should_work() {
t.execute_with(|| {
// Verify that the contract does exist by querying some of its storage items
// It does not matter that the storage item itself does not exist.
assert!(&pallet_contracts::Pallet::<Runtime>::get_storage(
addr,
pallet_contracts::StorageKey::<Runtime>::default().to_vec()
athei marked this conversation as resolved.
Show resolved Hide resolved
)
.is_ok());
assert!(&pallet_contracts::Pallet::<Runtime>::get_storage(addr, vec![]).is_ok());
});
}

Expand Down
28 changes: 14 additions & 14 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use self::{
sandbox::Sandbox,
};
use crate::{
exec::{AccountIdOf, FixSizedKey, VarSizedKey},
exec::{AccountIdOf, Key},
wasm::CallFlags,
Pallet as Contracts, *,
};
Expand Down Expand Up @@ -135,10 +135,10 @@ where
}

/// Store the supplied storage items into this contracts storage.
fn store(&self, items: &Vec<(FixSizedKey, Vec<u8>)>) -> Result<(), &'static str> {
fn store(&self, items: &Vec<([u8; 32], Vec<u8>)>) -> Result<(), &'static str> {
let info = self.info()?;
for item in items {
info.write(&item.0 as &FixSizedKey, Some(item.1.clone()), None, false)
info.write(&Key::Fix(item.0), Some(item.1.clone()), None, false)
.map_err(|_| "Failed to write storage to restoration dest")?;
}
<ContractInfoOf<T>>::insert(&self.account_id, info);
Expand Down Expand Up @@ -1044,7 +1044,7 @@ benchmarks! {
let info = instance.info()?;
for key in keys {
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![]),
None,
false,
Expand Down Expand Up @@ -1088,7 +1088,7 @@ benchmarks! {
let instance = Contract::<T>::new(code, vec![])?;
let info = instance.info()?;
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![]),
None,
false,
Expand Down Expand Up @@ -1131,7 +1131,7 @@ benchmarks! {
let instance = Contract::<T>::new(code, vec![])?;
let info = instance.info()?;
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; n as usize]),
None,
false,
Expand Down Expand Up @@ -1180,7 +1180,7 @@ benchmarks! {
let info = instance.info()?;
for key in keys {
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![]),
None,
false,
Expand Down Expand Up @@ -1223,7 +1223,7 @@ benchmarks! {
let instance = Contract::<T>::new(code, vec![])?;
let info = instance.info()?;
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; n as usize]),
None,
false,
Expand Down Expand Up @@ -1276,7 +1276,7 @@ benchmarks! {
let info = instance.info()?;
for key in keys {
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![]),
None,
false,
Expand Down Expand Up @@ -1325,7 +1325,7 @@ benchmarks! {
let instance = Contract::<T>::new(code, vec![])?;
let info = instance.info()?;
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; n as usize]),
None,
false,
Expand Down Expand Up @@ -1373,7 +1373,7 @@ benchmarks! {
let info = instance.info()?;
for key in keys {
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![]),
None,
false,
Expand Down Expand Up @@ -1416,7 +1416,7 @@ benchmarks! {
let instance = Contract::<T>::new(code, vec![])?;
let info = instance.info()?;
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; n as usize]),
None,
false,
Expand Down Expand Up @@ -1469,7 +1469,7 @@ benchmarks! {
let info = instance.info()?;
for key in keys {
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![]),
None,
false,
Expand Down Expand Up @@ -1518,7 +1518,7 @@ benchmarks! {
let instance = Contract::<T>::new(code, vec![])?;
let info = instance.info()?;
info.write(
&VarSizedKey::<T>::try_from(key).map_err(|e| "Key has wrong length")?,
&Key::<T>::try_from_var(key).map_err(|e| "Key has wrong length")?,
Some(vec![42u8; n as usize]),
None,
false,
Expand Down
Loading