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

seal: Add automated weights for contract API calls #7017

Merged
34 commits merged into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
407920b
seal: Add capability to put uninstrumented code (for benchmarks)
athei Jul 31, 2020
343f0fb
seal: Cap the the data length for deposited events
athei Aug 19, 2020
1235f26
seal: Fix error reporting in the case out of bound sandbox access
athei Aug 27, 2020
ec69d05
seal: Refactor existing benchmarks
athei Aug 3, 2020
b1a1133
seal: Convert benchmark file to tabs
athei Aug 5, 2020
dfa6076
seal: Add benchmarks for functions called by contracts
athei Aug 10, 2020
2cbe472
seal: Create a default schedule from benchmark generated WeightInfo
athei Aug 31, 2020
1e065cf
seal: Make use of WeightInfo in extrinsic weight annotations
athei Sep 1, 2020
c680745
seal: Replace the old schedule by the benchmark generated one
athei Sep 1, 2020
0132ede
Merge branch 'master' into at-seal-api-benchmarks
athei Sep 23, 2020
ca7742d
Review: Fix copy paste typo in schedule construction
athei Sep 23, 2020
cdec9ae
Review: Fix stale docs
athei Sep 23, 2020
0a2bd2a
Fix whitespace errors
athei Sep 23, 2020
771bf8a
Review: Use checked_div in order to be more defensive
athei Sep 23, 2020
a326fac
Merge branch 'master' into at-seal-api-benchmarks
athei Sep 24, 2020
d76bcde
Review: Rename no_charge to already_charged
athei Sep 24, 2020
b3aa6ac
Review: Whitelist caller of extrinsics
athei Sep 24, 2020
678f155
Review: Remove trailing whitespace
athei Sep 24, 2020
190144e
Review: Remove confusing "self::" syntax
athei Sep 24, 2020
dd2edeb
Review: Add docs for the benchmark prepration submodule
athei Sep 24, 2020
4e65609
Review: Move code generation functions to own module
athei Sep 24, 2020
687c2a5
Review: Refactor and document benchmark helper functions
athei Sep 24, 2020
b42e400
Remove additional empty line
athei Sep 24, 2020
56b8d31
Added missing comment on caller_funding
athei Sep 24, 2020
a7d3da1
Update frame/contracts/src/benchmarking/code.rs
athei Sep 24, 2020
09766bb
Fix missing sp_std::prelude import in code.rs
athei Sep 25, 2020
c54fa98
Merge branch 'master' into at-seal-api-benchmarks
athei Sep 25, 2020
9d1c66b
Merge remote-tracking branch 'origin/master' into at-seal-api-benchmarks
shawntabrizi Oct 6, 2020
e565433
cargo run --release --features runtime-benchmarks --manifest-path bin…
shawntabrizi Oct 6, 2020
036a8ba
Use weights from the benchmark machine for the substrate node
athei Oct 6, 2020
2c154dd
Remove prefixes from Schedule members
athei Oct 7, 2020
6f2f333
Data lengths in the WeightInfo Trait are specified in kilobytes
athei Oct 7, 2020
51a8c38
Rename ApiWeights to HostFunctionWeights
athei Oct 8, 2020
94a08b5
Merge branch 'master' into at-seal-api-benchmarks
athei Oct 8, 2020
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
15 changes: 11 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ impl pallet_contracts::Trait for Runtime {
type MaxDepth = pallet_contracts::DefaultMaxDepth;
type MaxValueSize = pallet_contracts::DefaultMaxValueSize;
type WeightPrice = pallet_transaction_payment::Module<Self>;
type WeightInfo = ();
}

impl pallet_sudo::Trait for Runtime {
Expand Down Expand Up @@ -881,7 +882,7 @@ construct_runtime!(
FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
Expand Down
8 changes: 1 addition & 7 deletions frame/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ sp-io = { version = "2.0.0-rc6", default-features = false, path = "../../primiti
sp-std = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/std" }
sp-sandbox = { version = "0.8.0-rc6", default-features = false, path = "../../primitives/sandbox" }
wasmi-validation = { version = "0.3.0", default-features = false }
wat = { version = "1.0", optional = true, default-features = false }

[dev-dependencies]
assert_matches = "1.3.0"
hex-literal = "0.3.1"
pallet-balances = { version = "2.0.0-rc6", path = "../balances" }
pallet-timestamp = { version = "2.0.0-rc6", path = "../timestamp" }
pallet-randomness-collective-flip = { version = "2.0.0-rc6", path = "../randomness-collective-flip" }
paste = "1.0"
pretty_assertions = "0.6.1"
wat = "1.0"

Expand All @@ -57,10 +57,4 @@ std = [
]
runtime-benchmarks = [
"frame-benchmarking",
"wat",
# We are linking the wat crate which uses std and therefore brings with it the
# std panic handler. Therefore we need to disable out own panic handlers. Mind that
# we still override the std memory allocator.
"sp-io/disable_panic_handler",
"sp-io/disable_oom",
]
4 changes: 0 additions & 4 deletions frame/contracts/fixtures/benchmarks/dummy.wat

This file was deleted.

4 changes: 2 additions & 2 deletions frame/contracts/fixtures/caller_contract.wat
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
(call $seal_instantiate
(i32.const 24) ;; Pointer to the code hash.
(i32.const 32) ;; Length of the code hash.
(i64.const 187500000) ;; Just enough to pay for the instantiate
(i64.const 1) ;; Supply too little gas
(i32.const 0) ;; Pointer to the buffer with value to transfer
(i32.const 8) ;; Length of the buffer with value to transfer.
(i32.const 8) ;; Pointer to input data buffer address
Expand Down Expand Up @@ -206,7 +206,7 @@
(call $seal_call
(i32.const 16) ;; Pointer to "callee" address.
(i32.const 8) ;; Length of "callee" address.
(i64.const 117500000) ;; Just enough to make the call
(i64.const 1) ;; Supply too little gas
(i32.const 0) ;; Pointer to the buffer with value to transfer
(i32.const 8) ;; Length of the buffer with value to transfer.
(i32.const 8) ;; Pointer to input data buffer address
Expand Down
39 changes: 39 additions & 0 deletions frame/contracts/fixtures/event_size.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(module
(import "seal0" "seal_deposit_event" (func $seal_deposit_event (param i32 i32 i32 i32)))
(import "seal0" "seal_input" (func $seal_input (param i32 i32)))
(import "env" "memory" (memory 16 16))

;; [0, 4) size of the input buffer
(data (i32.const 0) "\04")

(func $assert (param i32)
(block $ok
(br_if $ok
(get_local 0)
)
(unreachable)
)
)

(func (export "call")
(call $seal_input (i32.const 4) (i32.const 0))

;; assert input size == 4
(call $assert
(i32.eq
(i32.load (i32.const 0))
(i32.const 4)
)
)

;; place a garbage value in storage, the size of which is specified by the call input.
(call $seal_deposit_event
(i32.const 0) ;; topics_ptr
athei marked this conversation as resolved.
Show resolved Hide resolved
(i32.const 0) ;; topics_len
(i32.const 0) ;; data_ptr
(i32.load (i32.const 4)) ;; data_len
)
)

(func (export "deploy"))
)
Loading