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

contracts: Make Origin information available #13708

Merged
merged 70 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7fe7728
contracts: allow root calls
juangirini Mar 24, 2023
8fda4a6
contracts: update ContractOrigin
juangirini Mar 24, 2023
f52ba84
contracts: test allow root calls
juangirini Mar 24, 2023
3705212
contracts: rustfmt
juangirini Mar 24, 2023
92a2322
contracts: resolve merge conflicts
juangirini Mar 24, 2023
e25d27b
contracts: test root caller traps
juangirini Mar 27, 2023
04f0b31
contracts: add Caller enum
juangirini Mar 27, 2023
b3a1ac7
contracts: improve some comments
juangirini Mar 28, 2023
0fc1c1d
contracts: improve some comments
juangirini Mar 28, 2023
e4aeec9
contracts: format code with +nightly
juangirini Mar 28, 2023
197efe9
Merge branch 'master' into jg/make-origin-available
juangirini Mar 28, 2023
f31b50d
contracts: fix failing tests
juangirini Mar 28, 2023
2936439
contracts: improve charte instantiate call when root origin
juangirini Mar 28, 2023
aa91b3b
contract: refactor common, call and instantiate inputs
juangirini Mar 28, 2023
99bfe7c
contracts: fix some failing test
juangirini Mar 28, 2023
4566e2c
contracts: trap caller when there is no account id
juangirini Mar 29, 2023
79317cb
Merge remote-tracking branch 'origin/master' into jg/make-origin-avai…
Mar 29, 2023
ed9550e
Update frame/contracts/src/lib.rs
juangirini Mar 30, 2023
1421819
Update frame/contracts/src/exec.rs
juangirini Mar 30, 2023
8fb4971
contracts: make `into_deposit` return zero when the origin is root
juangirini Mar 30, 2023
d954a09
Merge branch 'master' into jg/make-origin-available
juangirini Mar 30, 2023
0eaaebd
contracts: cargo fmt
juangirini Mar 30, 2023
05f00ac
contracts: charging and terminating tests refactored
juangirini Mar 30, 2023
7a8a058
contracts: merge master
juangirini Mar 31, 2023
2e16ef8
contracts: improved errors
juangirini Mar 31, 2023
308b2ff
contracts: refactor & merge ContractOrigin cand Caller enums
juangirini Mar 31, 2023
7b9979c
Merge remote-tracking branch 'origin/master' into jg/make-origin-avai…
Apr 3, 2023
da14bd0
Update frame/contracts/src/lib.rs
juangirini Apr 4, 2023
d36d70e
contracts: apply suggested pr changes
juangirini Apr 4, 2023
9f85d5f
contracts: merge master and resolve conflicts
juangirini Apr 5, 2023
bf55a33
contracts: rename Caller to Origin
juangirini Apr 5, 2023
5208f67
contracts: refactor run fn
juangirini Apr 12, 2023
e3e1a48
contracts: cr improvements
juangirini Apr 14, 2023
d756cf1
contracts: resolve master conflicts
juangirini Apr 17, 2023
6158374
contracts: allow root to use delegate call
juangirini Apr 17, 2023
86c38ab
contracts: add caller_is_root weight
juangirini Apr 17, 2023
baeb20e
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Apr 17, 2023
33531bf
contracts: add caller_is_root benchmarking
juangirini Apr 17, 2023
2e746b7
Merge branch 'master' of https://github.com/paritytech/substrate into…
Apr 17, 2023
e615c54
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Apr 17, 2023
54540dd
contracts: add caller_is_root benchmarking
juangirini Apr 18, 2023
837cb64
Merge branch 'master' of https://github.com/paritytech/substrate into…
Apr 18, 2023
f7bd9fe
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Apr 18, 2023
d03987d
contracts: add some minor improvements
juangirini Apr 19, 2023
af14ee6
contracts: make caller_is_root runtime fn unstable
juangirini Apr 19, 2023
e656220
Merge branch 'master' into jg/make-origin-available
juangirini Apr 20, 2023
c6cd8d9
contracts: fix failing wasm test
juangirini Apr 20, 2023
2357c5c
contracts: update benchmarking for origin_is_root
juangirini Apr 21, 2023
99a42b1
contracts: improve seal_caller_is_root benchmarking
juangirini Apr 24, 2023
3165558
Merge branch 'master' of https://github.com/paritytech/substrate into…
Apr 24, 2023
5dc6092
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Apr 24, 2023
1b85d3a
contracts: add small pr improvements
juangirini Apr 26, 2023
6865b75
Merge remote-tracking branch 'origin/master' into jg/make-origin-avai…
juangirini Apr 26, 2023
f224bfc
contracts: fix merge conflicts
juangirini Apr 26, 2023
086fa30
Merge remote-tracking branch 'origin/master' into jg/make-origin-avai…
juangirini Apr 26, 2023
87d42b9
contracts: fix broken tests after master merge
juangirini Apr 26, 2023
e8f4af2
contracts: acknowledge the default storage deposit limit
juangirini Apr 26, 2023
aecd9f7
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts
Apr 27, 2023
80b103f
contracts: move origin to CommonInput
juangirini Apr 26, 2023
28fba03
contracts: add some extra tests
juangirini Apr 27, 2023
0630f4a
contracts: move ensure origin logic inside invokable::run_guarded
juangirini Apr 28, 2023
0d36126
contracts: add minor improvements
juangirini May 1, 2023
5dc9796
contracts: merge master and fix conflicts
juangirini May 1, 2023
25235f6
contracts: fix caller_is_root benchmarking
juangirini May 1, 2023
a2e76f7
contracts: improve function description
juangirini May 2, 2023
32de518
Update frame/contracts/src/lib.rs
juangirini May 2, 2023
da9d6d8
Update frame/contracts/src/lib.rs
juangirini May 2, 2023
225c8d4
Update frame/contracts/src/wasm/runtime.rs
juangirini May 2, 2023
b3c8445
contracts: improve function description
juangirini May 2, 2023
fe39e1f
Merge remote-tracking branch 'origin/master' into jg/make-origin-avai…
May 2, 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
32 changes: 32 additions & 0 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,38 @@ benchmarks! {
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])

#[pov_mode = Measured]
seal_caller_is_root {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@athei @agryaznov I am not too familiarised with benchmarking, so not sure if this is the right approach. This is pretty much a copy-pasta from seal_caller_is_origin with a few adaptations

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified by using WasmModule::getter. Look at the seal_address benchmark.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to use WasmModule::getter but it wouldn't work as the getter function would requires that "The imported function is expected to have the "getter signature" of (out_ptr: u32, len_ptr: u32) -> ()."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. Getters copy to memory not return on stack. Forgot about that. So you need to roll this back.

let r in 0 .. API_BENCHMARK_RUNS;

let code = WasmModule::<T>::from(ModuleDefinition {
memory: Some(ImportedMemory::max::<T>()),
imported_functions: vec![ImportedFunction {
module: "seal0",
name: "seal_caller_is_root",
params: vec![],
return_type: Some(ValueType::I32),
}],
call_body: Some(body::repeated(r, &[
Instruction::Call(0),
Instruction::Drop,
])),
.. Default::default()
});
let instance = Contract::<T>::new(code, vec![])?;
let origins = vec![
RawOrigin::Signed(instance.caller.clone()),
RawOrigin::Root,
];
let limits = vec![
None,
Some(BalanceOf::<T>::max_value().into()),
];
let o = r % 2;
let origin = origins[o as usize].clone();
let limit = limits[o as usize].clone();
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, limit, vec![])

#[pov_mode = Measured]
seal_address {
let r in 0 .. API_BENCHMARK_RUNS;
Expand Down
Loading