Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
eef15f1
upgrade to wasmi 0.29
agryaznov May 3, 2023
dee28ff
prepare cleanup
agryaznov May 3, 2023
efeb0bd
sync ref_time w engine from the stack frame
agryaznov May 3, 2023
4fdd5c8
proc_macro: sync gas in host funcs
agryaznov May 4, 2023
cac61c6
clean benchmarks & schedule: w_base = w_i64const
agryaznov May 5, 2023
be0df3c
scale gas values btw engine and gas meter
agryaznov May 5, 2023
8a32757
(re)instrumentation & code_cache removed
agryaznov May 5, 2023
f8abec4
remove gas() host fn, continue clean-up
agryaznov May 8, 2023
22440ae
address review comments
agryaznov Jun 9, 2023
c94821d
Merge branch 'master' into ag-wasmeter
agryaznov Jun 9, 2023
2010ff7
move from CodeStorage&PrefabWasmModule to PristineCode&WasmBlob
agryaznov Jun 9, 2023
100cdcd
refactor: no reftime_limit&schedule passes, no CodeStorage
agryaznov Jun 9, 2023
85a0340
bugs fixing
agryaznov Jun 10, 2023
505f750
fix tests: expected deposit amount
agryaznov Jun 10, 2023
c25f634
fix prepare::tests
agryaznov Jun 10, 2023
7f46e7e
update tests and fix bugs
agryaznov Jun 10, 2023
7bf4fbe
update docs
agryaznov Jun 11, 2023
cc05e88
bump wasmi 0.30.0
agryaznov Jun 12, 2023
0e2b0ab
benchmarks updated, tests pass
agryaznov Jun 12, 2023
e6e3563
refactoring
agryaznov Jun 12, 2023
f4ffcf2
s/OwnerInfo/CodeInfo/g;
agryaznov Jun 12, 2023
a50b7cf
migration: draft, compiles
agryaznov Jun 12, 2023
c6b9f74
migration: draft, runs
agryaznov Jun 13, 2023
132e9ce
migration: draft, runs (fixing)
agryaznov Jun 13, 2023
9935e92
deposits repaid non pro rata
agryaznov Jun 13, 2023
0b9125a
deposits repaid pro rata
agryaznov Jun 13, 2023
08a15b7
better try-runtime output
agryaznov Jun 13, 2023
5f6c1ac
even better try-runtime output
agryaznov Jun 13, 2023
b1290f0
benchmark migration
agryaznov Jun 14, 2023
9ffca5d
Merge branch 'master' into ag-wasmeter
agryaznov Jun 14, 2023
94f8476
fix merge leftover
agryaznov Jun 14, 2023
ba67751
add forgotten fixtures, fix docs
agryaznov Jun 14, 2023
0ee3293
address review comments
agryaznov Jun 14, 2023
a45c538
ci fixes
agryaznov Jun 14, 2023
f24a267
cleanup
agryaznov Jun 15, 2023
e6c21f3
benchmarks::prepare to return DispatchError
agryaznov Jun 15, 2023
444a97b
Merge branch 'master' into ag-wasmeter
agryaznov Jun 15, 2023
d3f59b2
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Jun 15, 2023
f12927d
store memory limits to CodeInfo
agryaznov Jun 16, 2023
0a9b351
ci: roll back weights
agryaznov Jun 16, 2023
cff9da7
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 16, 2023
f0e24c5
".git/.scripts/commands/bench-vm/bench-vm.sh" pallet dev pallet_contr…
Jun 16, 2023
2e07393
drive-by: update Readme and pallet rustdoc
agryaznov Jun 16, 2023
f465ecf
Merge branch 'master' into ag-wasmeter
agryaznov Jun 17, 2023
94be691
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Jun 17, 2023
721d4b6
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Jun 17, 2023
e226c0e
use wasmi 0.29
agryaznov Jun 18, 2023
e57596f
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 18, 2023
d687f1c
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Jun 18, 2023
76a8c20
use wasmi 0.30 again
agryaznov Jun 20, 2023
fbc43ae
query memory limits from wasmi
agryaznov Jun 20, 2023
cd54ff2
save: scan_exports ported, compiles
agryaznov Jun 20, 2023
b548064
save (wip, not compiles)
agryaznov Jun 20, 2023
0b4bb91
query memory limits from wasmi
agryaznov Jun 20, 2023
b15d5a9
better migration types
agryaznov Jun 20, 2023
8eb8710
ci: pull weights from master
agryaznov Jun 20, 2023
dae3f32
Merge branch 'master' into ag-wasmeter
agryaznov Jun 21, 2023
f42db5d
refactoring
agryaznov Jun 21, 2023
b789e6b
".git/.scripts/commands/bench-vm/bench-vm.sh" pallet dev pallet_contr…
Jun 21, 2023
3cadbb1
Merge branch 'ag-wasmeter' into ag-wasmi-validation
agryaznov Jun 21, 2023
eba148b
scan_imports ported
agryaznov Jun 21, 2023
ca5938d
scan_export ported, other checks removed
agryaznov Jun 22, 2023
c2c3d9b
tests fixed
agryaznov Jun 22, 2023
56dc2df
drop wasmparser and parity-wasm dependencies
agryaznov Jun 23, 2023
086e219
typo fix
agryaznov Jun 27, 2023
2544972
addressing review comments
agryaznov Jun 27, 2023
387bec9
refactor
agryaznov Jun 27, 2023
8be0537
address review comments
agryaznov Jun 29, 2023
ffdb8d1
optimize migration
agryaznov Jun 30, 2023
eaf7a31
Merge branch 'master' into ag-wasmeter
agryaznov Jun 30, 2023
f4dad0f
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Jun 30, 2023
b5ad1de
another review round comments addressed
agryaznov Jun 30, 2023
0e0155f
ci fix one
agryaznov Jun 30, 2023
d139757
clippy fix
agryaznov Jun 30, 2023
670ff1a
ci fix two
agryaznov Jun 30, 2023
18236e1
Merge branch 'ag-wasmeter' into ag-wasmi-validation
agryaznov Jul 3, 2023
0f83c77
allow stored modules to have no memory imports
agryaznov Jul 3, 2023
ca111cf
Merge branch 'master' into ag-wasmi-validation
agryaznov Jul 3, 2023
bf52770
rollback: allow stored modules to have no memory imports
agryaznov Jul 3, 2023
824ef6d
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jul 3, 2023
b55dbcb
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Jul 3, 2023
39fb730
address review comments
agryaznov Jul 4, 2023
ac9d5c2
Merge branch 'ag-wasmi-validation'
agryaznov Jul 4, 2023
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
Prev Previous commit
Next Next commit
move from CodeStorage&PrefabWasmModule to PristineCode&WasmBlob
  • Loading branch information
agryaznov committed Jun 9, 2023
commit 2010ff7c729daeeb96bb449deac4cc1c37bfcc7f
12 changes: 7 additions & 5 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,12 @@ pub trait Executable<T: Config>: Sized {
ext: &mut E,
function: &ExportedFunction,
input_data: Vec<u8>,
schedule: &Schedule<T>,
reftime_limit: u64,
) -> ExecResult;

/// The code hash of the executable.
fn code_hash(&self) -> &CodeHash<T>;
fn code_hash(&self) -> CodeHash<T>;

/// Size of the conract code in bytes.
fn code_len(&self) -> u32;
Expand Down Expand Up @@ -765,11 +766,11 @@ where
FrameArgs::Instantiate { sender, nonce, executable, salt, input_data } => {
let account_id = Contracts::<T>::contract_address(
&sender,
executable.code_hash(),
&executable.code_hash(),
input_data,
salt,
);
let contract = ContractInfo::new(&account_id, nonce, *executable.code_hash())?;
let contract = ContractInfo::new(&account_id, nonce, executable.code_hash())?;
(
account_id,
contract,
Expand Down Expand Up @@ -851,7 +852,7 @@ where
let frame = self.top_frame();
let entry_point = frame.entry_point;
let delegated_code_hash =
if frame.delegate_caller.is_some() { Some(*executable.code_hash()) } else { None };
if frame.delegate_caller.is_some() { Some(executable.code_hash()) } else { None };
let do_transaction = || {
// We need to charge the storage deposit before the initial transfer so that
// it can create the account in case the initial transfer is < ed.
Expand All @@ -873,11 +874,12 @@ where
// Take the ref_time part of the gas_left from the current frame.
let frame = self.top_frame();
let reftime_left = frame.nested_gas.gas_left().ref_time();
let schedule = &self.schedule().clone();

// Call into the Wasm blob.
// We pass `reftime_left` into the execution engine to initialize its gas metering.
let output = executable
.execute(self, &entry_point, input_data, reftime_left)
.execute(self, &entry_point, input_data, schedule, reftime_left)
.map_err(|e| ExecError { error: e.error, origin: ErrorOrigin::Callee })?;

// Sync this frame's gas meter with the engine's one.
Expand Down
15 changes: 5 additions & 10 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ use crate::{
exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Key, Stack as ExecStack},
gas::GasMeter,
storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueueManager},
wasm::{OwnerInfo, PrefabWasmModule, TryInstantiate, WasmBlob},
wasm::{OwnerInfo, TryInstantiate, WasmBlob},
weights::WeightInfo,
};
use codec::{Codec, Decode, Encode, HasCompact};
Expand Down Expand Up @@ -929,12 +929,6 @@ pub mod pallet {
#[pallet::storage]
pub(crate) type PristineCode<T: Config> = StorageMap<_, Identity, CodeHash<T>, CodeVec<T>>;

/// A mapping between an original code hash and Wasm code, ready for execution.
/// TODO: delete
#[pallet::storage]
pub(crate) type CodeStorage<T: Config> =
StorageMap<_, Identity, CodeHash<T>, PrefabWasmModule<T>>;

/// A mapping between an original code hash and its owner information.
#[pallet::storage]
pub(crate) type OwnerInfoOf<T: Config> = StorageMap<_, Identity, CodeHash<T>, OwnerInfo<T>>;
Expand Down Expand Up @@ -1217,7 +1211,7 @@ impl<T: Config> Invokable<T> for InstantiateInput<T> {
let origin = contract_origin.account_id()?;
let (extra_deposit, executable) = match &self.code {
Code::Upload(binary) => {
let (executable, owner_info) = WasmBlob::from_code(
let executable = WasmBlob::from_code(
binary.clone(),
&schedule,
origin.clone(),
Expand All @@ -1231,6 +1225,7 @@ impl<T: Config> Invokable<T> for InstantiateInput<T> {
.map(|buffer| buffer.try_extend(&mut msg.bytes()));
err
})?;
let owner_info = executable.owner_info.clone();
// The open deposit will be charged during execution when the
// uploaded module does not already exist. This deposit is not part of the
// storage meter because it is not transferred to the contract but
Expand Down Expand Up @@ -1422,11 +1417,11 @@ impl<T: Config> Pallet<T> {
let module =
WasmBlob::from_code(code, &schedule, origin, determinism, TryInstantiate::Instantiate)
.map_err(|(err, _)| err)?;
let deposit = module.open_deposit();
let deposit = module.open_deposit(module.owner_info.clone());
if let Some(storage_deposit_limit) = storage_deposit_limit {
ensure!(storage_deposit_limit >= deposit, <Error<T>>::StorageDepositLimitExhausted);
}
let result = CodeUploadReturnValue { code_hash: *module.code_hash(), deposit };
let result = CodeUploadReturnValue { code_hash: module.code_hash(), deposit };
module.store()?;
Ok(result)
}
Expand Down
Loading