mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 06:48:01 +00:00
5e5341da9b
Printing the `Schedule` is a useful debugging tool and general sanity
check. It is much more easy to interpret than the raw weights.
The printing relied on using `println` and hence was only available from
the native runtime. This is no longer available. This is why in this PR
we switch to using `log` which works from Wasm.
I made sure that the `WeightDebug` is only derived when
`runtime-benchmarks` is set so that we don't increase the size of the
binary.
Some other changes were necessary to make this actually work inside the
runtime. For example, I needed to remove `format!` and usage of floats.
Please note that this removed the decimal from the number because
truncating the fraction without using floats would not be easy and would
require custom code. I think the precision here is sufficient.
This is how the output looks like now:
```
Schedule {
limits: Limits {
event_topics: 4,
globals: 256,
locals: 1024,
parameters: 128,
memory_pages: 16,
table_size: 4096,
br_table_size: 256,
subject_len: 32,
payload_len: 16384,
runtime_memory: 134217728,
},
instruction_weights: InstructionWeights {
base: 2565,
_phantom: PhantomData<kitchensink_runtime::Runtime>,
},
host_fn_weights: HostFnWeights {
caller: 322 ns, 6 bytes,
is_contract: 28 µs, 2684 bytes,
code_hash: 29 µs, 2688 bytes,
own_code_hash: 400 ns, 6 bytes,
caller_is_origin: 176 ns, 3 bytes,
caller_is_root: 158 ns, 3 bytes,
address: 315 ns, 6 bytes,
gas_left: 355 ns, 6 bytes,
balance: 1 µs, 6 bytes,
value_transferred: 314 ns, 6 bytes,
minimum_balance: 318 ns, 6 bytes,
block_number: 313 ns, 6 bytes,
now: 325 ns, 6 bytes,
weight_to_fee: 1 µs, 14 bytes,
input: 263 ns, 6 bytes,
input_per_byte: 989 ps, 0 bytes,
r#return: 0 ps, 45 bytes,
return_per_byte: 320 ps, 0 bytes,
terminate: 1 ms, 5266 bytes,
random: 1 µs, 10 bytes,
deposit_event: 1 µs, 10 bytes,
deposit_event_per_topic: 127 µs, 2508 bytes,
deposit_event_per_byte: 501 ps, 0 bytes,
debug_message: 226 ns, 7 bytes,
debug_message_per_byte: 1 ns, 0 bytes,
set_storage: 131 µs, 293 bytes,
set_storage_per_new_byte: 576 ps, 0 bytes,
set_storage_per_old_byte: 184 ps, 1 bytes,
set_code_hash: 297 µs, 3090 bytes,
clear_storage: 131 µs, 289 bytes,
clear_storage_per_byte: 92 ps, 1 bytes,
contains_storage: 29 µs, 289 bytes,
contains_storage_per_byte: 213 ps, 1 bytes,
get_storage: 29 µs, 297 bytes,
get_storage_per_byte: 980 ps, 1 bytes,
take_storage: 131 µs, 297 bytes,
take_storage_per_byte: 921 ps, 1 bytes,
transfer: 156 µs, 2520 bytes,
call: 484 µs, 2721 bytes,
delegate_call: 406 µs, 2637 bytes,
call_transfer_surcharge: 607 µs, 5227 bytes,
call_per_cloned_byte: 970 ps, 0 bytes,
instantiate: 1 ms, 2731 bytes,
instantiate_transfer_surcharge: 131 µs, 2549 bytes,
instantiate_per_input_byte: 1 ns, 0 bytes,
instantiate_per_salt_byte: 1 ns, 0 bytes,
hash_sha2_256: 377 ns, 8 bytes,
hash_sha2_256_per_byte: 1 ns, 0 bytes,
hash_keccak_256: 767 ns, 8 bytes,
hash_keccak_256_per_byte: 3 ns, 0 bytes,
hash_blake2_256: 443 ns, 8 bytes,
hash_blake2_256_per_byte: 1 ns, 0 bytes,
hash_blake2_128: 440 ns, 8 bytes,
hash_blake2_128_per_byte: 1 ns, 0 bytes,
ecdsa_recover: 45 µs, 77 bytes,
ecdsa_to_eth_address: 11 µs, 42 bytes,
sr25519_verify: 41 µs, 112 bytes,
sr25519_verify_per_byte: 5 ns, 1 bytes,
reentrance_count: 174 ns, 3 bytes,
account_reentrance_count: 248 ns, 40 bytes,
instantiation_nonce: 154 ns, 3 bytes,
add_delegate_dependency: 131 µs, 2606 bytes,
remove_delegate_dependency: 130 µs, 2568 bytes,
},
}
###############################################
Lazy deletion weight per key: Weight(ref_time: 126109302, proof_size: 70)
Lazy deletion keys per block: 15859
```
135 lines
4.3 KiB
TOML
135 lines
4.3 KiB
TOML
[package]
|
|
name = "pallet-contracts"
|
|
version = "27.0.0"
|
|
authors.workspace = true
|
|
edition.workspace = true
|
|
build = "build.rs"
|
|
license = "Apache-2.0"
|
|
homepage = "https://substrate.io"
|
|
repository.workspace = true
|
|
description = "FRAME pallet for WASM contracts"
|
|
readme = "README.md"
|
|
include = ["CHANGELOG.md", "README.md", "benchmarks/**", "build.rs", "src/**/*"]
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.docs.rs]
|
|
targets = ["x86_64-unknown-linux-gnu"]
|
|
|
|
[dependencies]
|
|
bitflags = "1.3"
|
|
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
|
|
"derive",
|
|
"max-encoded-len",
|
|
] }
|
|
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
|
log = { version = "0.4", default-features = false }
|
|
serde = { version = "1", optional = true, features = ["derive"] }
|
|
smallvec = { version = "1", default-features = false, features = [
|
|
"const_generics",
|
|
] }
|
|
wasmi = { version = "0.31", default-features = false }
|
|
impl-trait-for-tuples = "0.2"
|
|
|
|
# Only used in benchmarking to generate contract code
|
|
wasm-instrument = { version = "0.4", optional = true, default-features = false }
|
|
rand = { version = "0.8", optional = true, default-features = false }
|
|
rand_pcg = { version = "0.3", optional = true }
|
|
|
|
# Substrate Dependencies
|
|
environmental = { version = "1.1.4", default-features = false }
|
|
frame-benchmarking = { path = "../benchmarking", default-features = false, optional = true }
|
|
frame-support = { path = "../support", default-features = false }
|
|
frame-system = { path = "../system", default-features = false }
|
|
pallet-balances = { path = "../balances", default-features = false, optional = true }
|
|
pallet-contracts-uapi = { path = "uapi" }
|
|
pallet-contracts-proc-macro = { path = "proc-macro" }
|
|
sp-api = { path = "../../primitives/api", default-features = false }
|
|
sp-core = { path = "../../primitives/core", default-features = false }
|
|
sp-io = { path = "../../primitives/io", default-features = false }
|
|
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
|
sp-std = { path = "../../primitives/std", default-features = false }
|
|
|
|
xcm = { package = "staging-xcm", path = "../../../polkadot/xcm", default-features = false }
|
|
xcm-builder = { package = "staging-xcm-builder", path = "../../../polkadot/xcm/xcm-builder", default-features = false }
|
|
|
|
[dev-dependencies]
|
|
array-bytes = "6.1"
|
|
assert_matches = "1"
|
|
env_logger = "0.9"
|
|
pretty_assertions = "1"
|
|
wat = "1"
|
|
pallet-contracts-fixtures = { path = "./fixtures" }
|
|
|
|
# Polkadot Dependencies
|
|
xcm-builder = { package = "staging-xcm-builder", path = "../../../polkadot/xcm/xcm-builder" }
|
|
|
|
# Substrate Dependencies
|
|
pallet-balances = { path = "../balances" }
|
|
pallet-timestamp = { path = "../timestamp" }
|
|
pallet-message-queue = { path = "../message-queue" }
|
|
pallet-insecure-randomness-collective-flip = { path = "../insecure-randomness-collective-flip" }
|
|
pallet-utility = { path = "../utility" }
|
|
pallet-assets = { path = "../assets" }
|
|
pallet-proxy = { path = "../proxy" }
|
|
sp-keystore = { path = "../../primitives/keystore" }
|
|
sp-tracing = { path = "../../primitives/tracing" }
|
|
|
|
[features]
|
|
default = ["std"]
|
|
std = [
|
|
"codec/std",
|
|
"environmental/std",
|
|
"frame-benchmarking?/std",
|
|
"frame-support/std",
|
|
"frame-system/std",
|
|
"log/std",
|
|
"pallet-balances?/std",
|
|
"pallet-insecure-randomness-collective-flip/std",
|
|
"pallet-proxy/std",
|
|
"pallet-timestamp/std",
|
|
"pallet-utility/std",
|
|
"rand?/std",
|
|
"scale-info/std",
|
|
"serde",
|
|
"sp-api/std",
|
|
"sp-core/std",
|
|
"sp-io/std",
|
|
"sp-keystore/std",
|
|
"sp-runtime/std",
|
|
"sp-std/std",
|
|
"wasm-instrument?/std",
|
|
"wasmi/std",
|
|
"xcm-builder/std",
|
|
"xcm/std",
|
|
]
|
|
runtime-benchmarks = [
|
|
"frame-benchmarking/runtime-benchmarks",
|
|
"frame-support/runtime-benchmarks",
|
|
"frame-system/runtime-benchmarks",
|
|
"pallet-assets/runtime-benchmarks",
|
|
"pallet-balances/runtime-benchmarks",
|
|
"pallet-message-queue/runtime-benchmarks",
|
|
"pallet-proxy/runtime-benchmarks",
|
|
"pallet-timestamp/runtime-benchmarks",
|
|
"pallet-utility/runtime-benchmarks",
|
|
"rand",
|
|
"rand_pcg",
|
|
"sp-runtime/runtime-benchmarks",
|
|
"wasm-instrument",
|
|
"xcm-builder/runtime-benchmarks",
|
|
]
|
|
try-runtime = [
|
|
"frame-support/try-runtime",
|
|
"frame-system/try-runtime",
|
|
"pallet-assets/try-runtime",
|
|
"pallet-balances/try-runtime",
|
|
"pallet-insecure-randomness-collective-flip/try-runtime",
|
|
"pallet-message-queue/try-runtime",
|
|
"pallet-proxy/try-runtime",
|
|
"pallet-timestamp/try-runtime",
|
|
"pallet-utility/try-runtime",
|
|
"sp-runtime/try-runtime",
|
|
]
|