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

Commit f49b178

Browse files
juangirinipgherveouagryaznov
authored
contracts: Make Origin information available (#13708)
* contracts: allow root calls * contracts: update ContractOrigin * contracts: test allow root calls * contracts: rustfmt * contracts: test root caller traps * contracts: add Caller enum * contracts: improve some comments * contracts: improve some comments * contracts: format code with +nightly * contracts: fix failing tests * contracts: improve charte instantiate call when root origin * contract: refactor common, call and instantiate inputs * contracts: fix some failing test * contracts: trap caller when there is no account id * Update frame/contracts/src/lib.rs Co-authored-by: PG Herveou <pgherveou@gmail.com> * Update frame/contracts/src/exec.rs Co-authored-by: PG Herveou <pgherveou@gmail.com> * contracts: make `into_deposit` return zero when the origin is root * contracts: cargo fmt * contracts: charging and terminating tests refactored * contracts: improved errors * contracts: refactor & merge ContractOrigin cand Caller enums * Update frame/contracts/src/lib.rs Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * contracts: apply suggested pr changes * contracts: rename Caller to Origin * contracts: refactor run fn * contracts: cr improvements * contracts: allow root to use delegate call * contracts: add caller_is_root weight * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * contracts: add caller_is_root benchmarking * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * contracts: add caller_is_root benchmarking * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * contracts: add some minor improvements * contracts: make caller_is_root runtime fn unstable * contracts: fix failing wasm test * contracts: update benchmarking for origin_is_root * contracts: improve seal_caller_is_root benchmarking * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * contracts: add small pr improvements * contracts: fix broken tests after master merge * contracts: acknowledge the default storage deposit limit * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * contracts: move origin to CommonInput * contracts: add some extra tests * contracts: move ensure origin logic inside invokable::run_guarded * contracts: add minor improvements * contracts: fix caller_is_root benchmarking * contracts: improve function description * Update frame/contracts/src/lib.rs Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * Update frame/contracts/src/lib.rs Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * Update frame/contracts/src/wasm/runtime.rs Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * contracts: improve function description --------- Co-authored-by: parity-processbot <> Co-authored-by: PG Herveou <pgherveou@gmail.com> Co-authored-by: Sasha Gryaznov <hi@agryaznov.com>
1 parent cb5be45 commit f49b178

File tree

10 files changed

+1841
-1240
lines changed

10 files changed

+1841
-1240
lines changed

frame/contracts/src/benchmarking/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,28 @@ benchmarks! {
534534
let origin = RawOrigin::Signed(instance.caller.clone());
535535
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
536536

537+
#[pov_mode = Measured]
538+
seal_caller_is_root {
539+
let r in 0 .. API_BENCHMARK_RUNS;
540+
541+
let code = WasmModule::<T>::from(ModuleDefinition {
542+
memory: Some(ImportedMemory::max::<T>()),
543+
imported_functions: vec![ImportedFunction {
544+
module: "seal0",
545+
name: "caller_is_root",
546+
params: vec![],
547+
return_type: Some(ValueType::I32),
548+
}],
549+
call_body: Some(body::repeated(r, &[
550+
Instruction::Call(0),
551+
Instruction::Drop,
552+
])),
553+
.. Default::default()
554+
});
555+
let instance = Contract::<T>::new(code, vec![])?;
556+
let origin = RawOrigin::Root;
557+
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
558+
537559
#[pov_mode = Measured]
538560
seal_address {
539561
let r in 0 .. API_BENCHMARK_RUNS;

0 commit comments

Comments
 (0)