diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9217a422908..c0117509e70 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -115,7 +115,7 @@ spellcheck: <<: *docker-env <<: *test-refs script: - - cargo spellcheck check --cfg=.config/spellcheck.toml --checkers hunspell -m 1 $(find . -type f -name '*.rs' ! -path "./target/*" ! -name 'codegen_runtime.rs' ! -name 'weights.rs') + - cargo spellcheck check --cfg=.config/spellcheck.toml --checkers hunspell -m 1 $(find . -type f -name '*.rs' ! -path "./target/*" ! -path "./bin/millau/runtime/src/weights/*" ! -name 'codegen_runtime.rs' ! -name 'weights.rs') check: stage: test @@ -190,8 +190,7 @@ benchmarks-test: <<: *docker-env <<: *nightly-test script: - - time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet --chain=dev --steps=2 --repeat=1 --pallet=RialtoMessages --extrinsic=* --execution=wasm --wasm-execution=Compiled --heap-pages=4096 - - time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet --chain=dev --steps=2 --repeat=1 --pallet=RialtoParachainMessages --extrinsic=* --execution=wasm --wasm-execution=Compiled --heap-pages=4096 + - time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet --chain=dev --steps=2 --repeat=1 --pallet=pallet_bridge_messages --extrinsic=* --execution=wasm --wasm-execution=Compiled --heap-pages=4096 - time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet --chain=dev --steps=2 --repeat=1 --pallet=pallet_bridge_grandpa --extrinsic=* --execution=wasm --wasm-execution=Compiled --heap-pages=4096 - time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet --chain=dev --steps=2 --repeat=1 --pallet=pallet_bridge_parachains --extrinsic=* --execution=wasm --wasm-execution=Compiled --heap-pages=4096 - time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet --chain=dev --steps=2 --repeat=1 --pallet=pallet_bridge_relayers --extrinsic=* --execution=wasm --wasm-execution=Compiled --heap-pages=4096 diff --git a/.maintain/millau-weight-template.hbs b/.maintain/bridge-weight-template.hbs similarity index 100% rename from .maintain/millau-weight-template.hbs rename to .maintain/bridge-weight-template.hbs diff --git a/Cargo.lock b/Cargo.lock index 4c126a2ef9d..a5202956796 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,9 +254,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "approx" @@ -1455,9 +1455,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.4" +version = "4.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" +checksum = "8a1f23fa97e1d1641371b51f35535cb26959b8e27ab50d167a8b996b5bada819" dependencies = [ "clap_builder", "clap_derive", @@ -1466,9 +1466,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.4" +version = "4.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" +checksum = "0fdc5d93c358224b4d6867ef1356d740de2303e9892edc06c5340daeccd96bab" dependencies = [ "anstream", "anstyle", @@ -1616,18 +1616,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7379abaacee0f14abf3204a7606118f0465785252169d186337bcb75030815a" +checksum = "2bc42ba2e232e5b20ff7dc299a812d53337dadce9a7e39a238e6a5cb82d2e57b" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b" +checksum = "253531aca9b6f56103c9420369db3263e784df39aa1c90685a1f69cfbba0623e" dependencies = [ "arrayvec 0.7.2", "bumpalo", @@ -1646,33 +1646,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bbb67da91ec721ed57cef2f7c5ef7728e1cd9bde9ffd3ef8601022e73e3239" +checksum = "72f2154365e2bff1b1b8537a7181591fdff50d8e27fa6e40d5c69c3bad0ca7c8" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418ecb2f36032f6665dc1a5e2060a143dbab41d83b784882e97710e890a7a16d" +checksum = "687e14e3f5775248930e0d5a84195abef8b829958e9794bf8d525104993612b4" [[package]] name = "cranelift-entity" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705" +checksum = "f42ea692c7b450ad18b8c9889661505d51c09ec4380cf1c2d278dbb2da22cae1" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b66bf9e916f57fbbd0f7703ec6286f4624866bf45000111627c70d272c8dda1" +checksum = "8483c2db6f45fe9ace984e5adc5d058102227e4c62e5aa2054e16b0275fd3a6e" dependencies = [ "cranelift-codegen", "log", @@ -1682,15 +1682,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649782a39ce99798dd6b4029e2bb318a2fbeaade1b4fa25330763c10c65bc358" +checksum = "e9793158837678902446c411741d87b43f57dadfb944f2440db4287cda8cbd59" [[package]] name = "cranelift-native" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "937e021e089c51f9749d09e7ad1c4f255c2f8686cb8c3df63a34b3ec9921bc41" +checksum = "72668c7755f2b880665cb422c8ad2d56db58a88b9bebfef0b73edc2277c13c49" dependencies = [ "cranelift-codegen", "libc", @@ -1699,9 +1699,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d850cf6775477747c9dfda9ae23355dd70512ffebc70cf82b85a5b111ae668b5" +checksum = "3852ce4b088b44ac4e29459573943009a70d1b192c8d77ef949b4e814f656fc1" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1884,7 +1884,7 @@ name = "cumulus-client-cli" version = "0.1.0" source = "git+https://github.com/paritytech/cumulus?branch=master#df9ed2455462e8c470a8a7ead44023b6eec79ed3" dependencies = [ - "clap 4.2.4", + "clap 4.2.5", "parity-scale-codec", "sc-chain-spec", "sc-cli", @@ -3298,7 +3298,7 @@ dependencies = [ "Inflector", "array-bytes 4.2.0", "chrono", - "clap 4.2.4", + "clap 4.2.5", "comfy-table", "frame-benchmarking", "frame-support", @@ -5688,7 +5688,7 @@ dependencies = [ name = "millau-bridge-node" version = "0.1.0" dependencies = [ - "clap 4.2.4", + "clap 4.2.5", "frame-benchmarking", "frame-benchmarking-cli", "jsonrpsee 0.16.2", @@ -6116,7 +6116,7 @@ name = "node-inspect" version = "0.9.0-dev" source = "git+https://github.com/paritytech/substrate?branch=master#a14236059c2d3da052fb08295082341aa7b87240" dependencies = [ - "clap 4.2.4", + "clap 4.2.5", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -7906,7 +7906,7 @@ name = "polkadot-cli" version = "0.9.39" source = "git+https://github.com/paritytech/polkadot?branch=master#ae96e09e6ad1810b8d04d4530c07173e604a763d" dependencies = [ - "clap 4.2.4", + "clap 4.2.5", "frame-benchmarking-cli", "futures", "log", @@ -9886,7 +9886,7 @@ dependencies = [ name = "rialto-bridge-node" version = "0.1.0" dependencies = [ - "clap 4.2.4", + "clap 4.2.5", "frame-benchmarking", "frame-benchmarking-cli", "frame-support", @@ -9913,7 +9913,7 @@ dependencies = [ name = "rialto-parachain-collator" version = "0.1.0" dependencies = [ - "clap 4.2.4", + "clap 4.2.5", "cumulus-client-cli", "cumulus-client-consensus-aura", "cumulus-client-consensus-common", @@ -10012,6 +10012,7 @@ dependencies = [ "sp-std 5.0.0", "sp-transaction-pool", "sp-version", + "static_assertions", "substrate-wasm-builder", "xcm", "xcm-builder", @@ -10575,7 +10576,7 @@ source = "git+https://github.com/paritytech/substrate?branch=master#a6cb6d0fb79c dependencies = [ "array-bytes 4.2.0", "chrono", - "clap 4.2.4", + "clap 4.2.5", "fdlimit", "futures", "libp2p", @@ -11437,7 +11438,7 @@ name = "sc-storage-monitor" version = "0.1.0" source = "git+https://github.com/paritytech/substrate?branch=master#a6cb6d0fb79c303c9af513e856abfb61fc6d8d74" dependencies = [ - "clap 4.2.4", + "clap 4.2.5", "fs4", "futures", "log", @@ -11670,9 +11671,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfdffd972d76b22f3d7f81c8be34b2296afd3a25e0a547bd9abe340a4dbbe97" +checksum = "dfdef77228a4c05dc94211441595746732131ad7f6530c6c18f045da7b7ab937" dependencies = [ "bitvec", "cfg-if 1.0.0", @@ -11684,9 +11685,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61fa974aea2d63dd18a4ec3a49d59af9f34178c73a4f56d2f18205628d00681e" +checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.56", @@ -13232,6 +13233,7 @@ dependencies = [ "relay-utils", "relay-westend-client", "relay-wococo-client", + "rialto-parachain-runtime", "rialto-runtime", "signal-hook", "signal-hook-async-std", @@ -13243,6 +13245,7 @@ dependencies = [ "substrate-relay-helper", "tempfile", "xcm", + "xcm-executor", ] [[package]] @@ -13736,9 +13739,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" dependencies = [ "autocfg", "bytes", @@ -13750,14 +13753,14 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2 1.0.56", "quote 1.0.26", @@ -14087,7 +14090,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=master#a6cb6d0fb79c303c9af513e856abfb61fc6d8d74" dependencies = [ "async-trait", - "clap 4.2.4", + "clap 4.2.5", "frame-remote-externalities", "hex", "log", @@ -14557,9 +14560,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e89f9819523447330ffd70367ef4a18d8c832e24e8150fe054d1d912841632" +checksum = "76a222f5fa1e14b2cefc286f1b68494d7a965f4bf57ec04c59bb62673d639af6" dependencies = [ "anyhow", "bincode", @@ -14585,18 +14588,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd3a5e46c198032da934469f3a6e48649d1f9142438e4fd4617b68a35644b8a" +checksum = "4407a7246e7d2f3d8fb1cf0c72fda8dbafdb6dd34d555ae8bea0e5ae031089cc" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "wasmtime-cache" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b389ae9b678b9c3851091a4804f4182d688d27aff7abc9aa37fa7be37d8ecffa" +checksum = "5ceb3adf61d654be0be67fffdce42447b0880481348785be5fe40b5dd7663a4c" dependencies = [ "anyhow", "base64 0.13.1", @@ -14614,9 +14617,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b2c92a08c0db6efffd88fdc97d7aa9c7c63b03edb0971dbca745469f820e8c" +checksum = "3c366bb8647e01fd08cb5589976284b00abfded5529b33d7e7f3f086c68304a4" dependencies = [ "anyhow", "cranelift-codegen", @@ -14635,9 +14638,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" +checksum = "47b8b50962eae38ee319f7b24900b7cf371f03eebdc17400c1dc8575fc10c9a7" dependencies = [ "anyhow", "cranelift-entity", @@ -14654,9 +14657,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" +checksum = "ffaed4f9a234ba5225d8e64eac7b4a5d13b994aeb37353cde2cbeb3febda9eaa" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -14678,9 +14681,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0245e8a9347017c7185a72e215218a802ff561545c242953c11ba00fccc930f" +checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" dependencies = [ "object 0.29.0", "once_cell", @@ -14689,9 +14692,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67d412e9340ab1c83867051d8d1d7c90aa8c9afc91da086088068e2734e25064" +checksum = "43a28ae1e648461bfdbb79db3efdaee1bca5b940872e4175390f465593a2e54c" dependencies = [ "cfg-if 1.0.0", "libc", @@ -14700,9 +14703,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d594e791b5fdd4dbaf8cf7ae62f2e4ff85018ce90f483ca6f42947688e48827d" +checksum = "e704b126e4252788ccfc3526d4d4511d4b23c521bf123e447ac726c14545217b" dependencies = [ "anyhow", "cc", @@ -14724,9 +14727,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6688d6f96d4dbc1f89fab626c56c1778936d122b5f4ae7a57c2eb42b8d982e2" +checksum = "83e5572c5727c1ee7e8f28717aaa8400e4d22dcbd714ea5457d85b5005206568" dependencies = [ "cranelift-entity", "serde", diff --git a/bin/millau/node/Cargo.toml b/bin/millau/node/Cargo.toml index 7eb7c79405b..fd2096df5fa 100644 --- a/bin/millau/node/Cargo.toml +++ b/bin/millau/node/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -clap = { version = "4.2.4", features = ["derive"] } +clap = { version = "4.2.5", features = ["derive"] } jsonrpsee = { version = "0.16.2", features = ["server"] } serde_json = "1.0.96" diff --git a/bin/millau/runtime/Cargo.toml b/bin/millau/runtime/Cargo.toml index e1a55ea6f24..4594c73fd92 100644 --- a/bin/millau/runtime/Cargo.toml +++ b/bin/millau/runtime/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] hex-literal = "0.4" codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge dependencies diff --git a/bin/millau/runtime/src/lib.rs b/bin/millau/runtime/src/lib.rs index dccd75a5b00..60732339cf1 100644 --- a/bin/millau/runtime/src/lib.rs +++ b/bin/millau/runtime/src/lib.rs @@ -30,6 +30,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod rialto_messages; pub mod rialto_parachain_messages; +pub mod weights; pub mod xcm_config; use bp_parachains::SingleParaStoredHeaderDataBuilder; @@ -442,7 +443,7 @@ pub type WithRialtoMessagesInstance = (); impl pallet_bridge_messages::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_messages::weights::BridgeWeight; + type WeightInfo = weights::RialtoMessagesWeightInfo; type ActiveOutboundLanes = RialtoActiveOutboundLanes; type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; @@ -472,7 +473,7 @@ pub type WithRialtoParachainMessagesInstance = pallet_bridge_messages::Instance1 impl pallet_bridge_messages::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_messages::weights::BridgeWeight; + type WeightInfo = weights::RialtoParachainMessagesWeightInfo; type ActiveOutboundLanes = RialtoParachainActiveOutboundLanes; type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; @@ -598,7 +599,7 @@ generate_bridge_reject_obsolete_headers_and_messages! { bp_runtime::generate_static_str_provider!(BridgeRefundRialtoPara2000Lane0Msgs); /// Signed extension that refunds relayers that are delivering messages from the Rialto parachain. -pub type PriorityBoostPerMessage = ConstU64<921_900_294>; +pub type PriorityBoostPerMessage = ConstU64<324_316_715>; pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages< Runtime, RefundableParachain, @@ -647,6 +648,17 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +#[cfg(feature = "runtime-benchmarks")] +mod benches { + frame_benchmarking::define_benchmarks!( + [pallet_bridge_messages, MessagesBench::] + [pallet_bridge_messages, MessagesBench::] + [pallet_bridge_grandpa, BridgeRialtoGrandpa] + [pallet_bridge_parachains, ParachainsBench::] + [pallet_bridge_relayers, RelayersBench::] + ); +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { @@ -954,7 +966,7 @@ impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use pallet_bridge_messages::benchmarking::Pallet as MessagesBench; @@ -962,22 +974,16 @@ impl_runtime_apis! { use pallet_bridge_relayers::benchmarking::Pallet as RelayersBench; let mut list = Vec::::new(); - - list_benchmark!(list, extra, RialtoParachainMessages, MessagesBench::); - list_benchmark!(list, extra, RialtoMessages, MessagesBench::); - list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeRialtoGrandpa); - list_benchmark!(list, extra, pallet_bridge_parachains, ParachainsBench::); - list_benchmark!(list, extra, pallet_bridge_relayers, RelayersBench::); + list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) } fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig, ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; let whitelist: Vec = vec![ // Block Number @@ -992,9 +998,6 @@ impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da946c154ffd9992e395af90b5b13cc6f295c77033fce8a9045824a6690bbf99c6db269502f0a8d1d2a008542d5690a0749").to_vec().into(), ]; - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - use bridge_runtime_common::messages_benchmarking::{ prepare_message_delivery_proof_from_grandpa_chain, prepare_message_delivery_proof_from_parachain, @@ -1108,39 +1111,27 @@ impl_runtime_apis! { } impl RelayersConfig for Runtime { - fn prepare_environment( + fn prepare_rewards_account( account_params: RewardsAccountParams, reward: Balance, ) { - use frame_support::traits::fungible::Mutate; let rewards_account = bp_relayers::PayRewardFromAccount::< Balances, AccountId >::rewards_account(account_params); - Balances::mint_into(&rewards_account, reward).unwrap(); + Self::deposit_account(rewards_account, reward); + } + + fn deposit_account(account: AccountId, balance: Balance) { + use frame_support::traits::fungible::Mutate; + Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap(); } } - add_benchmark!( - params, - batches, - RialtoParachainMessages, - MessagesBench:: - ); - add_benchmark!( - params, - batches, - RialtoMessages, - MessagesBench:: - ); - add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeRialtoGrandpa); - add_benchmark!( - params, - batches, - pallet_bridge_parachains, - ParachainsBench:: - ); - add_benchmark!(params, batches, pallet_bridge_relayers, RelayersBench::); + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + + add_benchmarks!(params, batches); Ok(batches) } diff --git a/bin/millau/runtime/src/rialto_messages.rs b/bin/millau/runtime/src/rialto_messages.rs index 573e3f5e68d..b71eb76d90a 100644 --- a/bin/millau/runtime/src/rialto_messages.rs +++ b/bin/millau/runtime/src/rialto_messages.rs @@ -26,6 +26,7 @@ use bridge_runtime_common::{ messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}, }; use frame_support::{parameter_types, weights::Weight, RuntimeDebug}; +use pallet_bridge_relayers::WeightInfoExt as _; use xcm::latest::prelude::*; use xcm_builder::HaulBlobExporter; @@ -135,6 +136,20 @@ impl XcmBlobHauler for ToRialtoXcmBlobHauler { } } +impl pallet_bridge_messages::WeightInfoExt for crate::weights::RialtoMessagesWeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_rialto::EXTRA_STORAGE_PROOF_SIZE + } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_proof_overhead_from_runtime() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_delivery_proof_overhead_from_runtime() + } +} + #[cfg(test)] mod tests { use super::*; @@ -155,6 +170,7 @@ mod tests { bp_rialto::EXTRA_STORAGE_PROOF_SIZE, bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + false, ); } diff --git a/bin/millau/runtime/src/rialto_parachain_messages.rs b/bin/millau/runtime/src/rialto_parachain_messages.rs index 041d3256f42..8d5216d96c9 100644 --- a/bin/millau/runtime/src/rialto_parachain_messages.rs +++ b/bin/millau/runtime/src/rialto_parachain_messages.rs @@ -28,6 +28,7 @@ use bridge_runtime_common::{ messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}, }; use frame_support::{parameter_types, weights::Weight, RuntimeDebug}; +use pallet_bridge_relayers::WeightInfoExt as _; use xcm::latest::prelude::*; use xcm_builder::HaulBlobExporter; @@ -136,6 +137,22 @@ impl XcmBlobHauler for ToRialtoParachainXcmBlobHauler { } } +impl pallet_bridge_messages::WeightInfoExt + for crate::weights::RialtoParachainMessagesWeightInfo +{ + fn expected_extra_storage_proof_size() -> u32 { + bp_rialto_parachain::EXTRA_STORAGE_PROOF_SIZE + } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_proof_overhead_from_runtime() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_delivery_proof_overhead_from_runtime() + } +} + #[cfg(test)] mod tests { use super::*; @@ -159,6 +176,7 @@ mod tests { bp_rialto_parachain::EXTRA_STORAGE_PROOF_SIZE, bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + true, ); } diff --git a/bin/millau/runtime/src/weights/mod.rs b/bin/millau/runtime/src/weights/mod.rs new file mode 100644 index 00000000000..801ff9b3c8f --- /dev/null +++ b/bin/millau/runtime/src/weights/mod.rs @@ -0,0 +1,21 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +mod pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance; +mod pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance; + +pub use pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance::WeightInfo as RialtoMessagesWeightInfo; +pub use pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance::WeightInfo as RialtoParachainMessagesWeightInfo; diff --git a/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance.rs b/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance.rs new file mode 100644 index 00000000000..b58402d2756 --- /dev/null +++ b/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance.rs @@ -0,0 +1,188 @@ + +//! Autogenerated weights for `pallet_bridge_messages` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/millau-bridge-node +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_bridge_messages +// --extrinsic=* +// --execution=wasm +// --wasm-execution=Compiled +// --heap-pages=4096 +// --output=./bin/millau/runtime/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_messages`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_messages::WeightInfo for WeightInfo { + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `490` + // Estimated: `57170` + // Minimum execution time: 51_189_000 picoseconds. + Weight::from_parts(52_881_000, 0) + .saturating_add(Weight::from_parts(0, 57170)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_two_messages_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `490` + // Estimated: `57170` + // Minimum execution time: 65_083_000 picoseconds. + Weight::from_parts(66_878_000, 0) + .saturating_add(Weight::from_parts(0, 57170)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Proof Size summary in bytes: + // Measured: `490` + // Estimated: `57170` + // Minimum execution time: 57_919_000 picoseconds. + Weight::from_parts(58_927_000, 0) + .saturating_add(Weight::from_parts(0, 57170)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_1_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `490` + // Estimated: `57170` + // Minimum execution time: 52_202_000 picoseconds. + Weight::from_parts(53_617_000, 0) + .saturating_add(Weight::from_parts(0, 57170)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_16_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `490` + // Estimated: `57170` + // Minimum execution time: 74_726_000 picoseconds. + Weight::from_parts(76_379_000, 0) + .saturating_add(Weight::from_parts(0, 57170)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + fn receive_delivery_proof_for_single_message() -> Weight { + // Proof Size summary in bytes: + // Measured: `515` + // Estimated: `9584` + // Minimum execution time: 45_156_000 picoseconds. + Weight::from_parts(46_535_000, 0) + .saturating_add(Weight::from_parts(0, 9584)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Proof Size summary in bytes: + // Measured: `532` + // Estimated: `9584` + // Minimum execution time: 44_104_000 picoseconds. + Weight::from_parts(45_602_000, 0) + .saturating_add(Weight::from_parts(0, 9584)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Proof Size summary in bytes: + // Measured: `532` + // Estimated: `12124` + // Minimum execution time: 46_880_000 picoseconds. + Weight::from_parts(48_472_000, 0) + .saturating_add(Weight::from_parts(0, 12124)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// The range of component `i` is `[128, 2048]`. + /// The range of component `i` is `[128, 2048]`. + fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `490` + // Estimated: `57170` + // Minimum execution time: 107_297_000 picoseconds. + Weight::from_parts(98_819_194, 0) + .saturating_add(Weight::from_parts(0, 57170)) + // Standard Error: 2_195 + .saturating_add(Weight::from_parts(448_268, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance.rs b/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance.rs new file mode 100644 index 00000000000..c71cb11fdc7 --- /dev/null +++ b/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance.rs @@ -0,0 +1,188 @@ + +//! Autogenerated weights for `pallet_bridge_messages` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/millau-bridge-node +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_bridge_messages +// --extrinsic=* +// --execution=wasm +// --wasm-execution=Compiled +// --heap-pages=4096 +// --output=./bin/millau/runtime/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_messages`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_messages::WeightInfo for WeightInfo { + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `56803` + // Minimum execution time: 49_949_000 picoseconds. + Weight::from_parts(51_439_000, 0) + .saturating_add(Weight::from_parts(0, 56803)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_two_messages_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `56803` + // Minimum execution time: 62_552_000 picoseconds. + Weight::from_parts(64_899_000, 0) + .saturating_add(Weight::from_parts(0, 56803)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `56803` + // Minimum execution time: 56_795_000 picoseconds. + Weight::from_parts(58_441_000, 0) + .saturating_add(Weight::from_parts(0, 56803)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_1_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `56803` + // Minimum execution time: 51_340_000 picoseconds. + Weight::from_parts(52_533_000, 0) + .saturating_add(Weight::from_parts(0, 56803)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_16_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `56803` + // Minimum execution time: 74_022_000 picoseconds. + Weight::from_parts(75_115_000, 0) + .saturating_add(Weight::from_parts(0, 56803)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + fn receive_delivery_proof_for_single_message() -> Weight { + // Proof Size summary in bytes: + // Measured: `453` + // Estimated: `9217` + // Minimum execution time: 43_296_000 picoseconds. + Weight::from_parts(45_022_000, 0) + .saturating_add(Weight::from_parts(0, 9217)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Proof Size summary in bytes: + // Measured: `470` + // Estimated: `9217` + // Minimum execution time: 42_618_000 picoseconds. + Weight::from_parts(43_972_000, 0) + .saturating_add(Weight::from_parts(0, 9217)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Proof Size summary in bytes: + // Measured: `470` + // Estimated: `11757` + // Minimum execution time: 45_954_000 picoseconds. + Weight::from_parts(46_892_000, 0) + .saturating_add(Weight::from_parts(0, 11757)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) + /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// The range of component `i` is `[128, 2048]`. + /// The range of component `i` is `[128, 2048]`. + fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `56803` + // Minimum execution time: 107_766_000 picoseconds. + Weight::from_parts(97_865_035, 0) + .saturating_add(Weight::from_parts(0, 56803)) + // Standard Error: 2_179 + .saturating_add(Weight::from_parts(447_749, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/bin/rialto-parachain/node/Cargo.toml b/bin/rialto-parachain/node/Cargo.toml index 38521d7aa0e..075e70c961b 100644 --- a/bin/rialto-parachain/node/Cargo.toml +++ b/bin/rialto-parachain/node/Cargo.toml @@ -17,7 +17,7 @@ default = [] runtime-benchmarks = ['rialto-parachain-runtime/runtime-benchmarks'] [dependencies] -clap = { version = "4.2.4", features = ["derive"] } +clap = { version = "4.2.5", features = ["derive"] } log = '0.4.17' codec = { package = 'parity-scale-codec', version = '3.1.5' } serde = { version = '1.0', features = ['derive'] } diff --git a/bin/rialto-parachain/runtime/Cargo.toml b/bin/rialto-parachain/runtime/Cargo.toml index 53f57e02619..d44f4b42af4 100644 --- a/bin/rialto-parachain/runtime/Cargo.toml +++ b/bin/rialto-parachain/runtime/Cargo.toml @@ -12,7 +12,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = 'parity-scale-codec', version = '3.1.5', default-features = false, features = ['derive']} hex-literal = "0.4" -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge depedencies @@ -76,6 +76,7 @@ pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "master" [dev-dependencies] bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] } +static_assertions = "1.1" [features] default = ['std'] diff --git a/bin/rialto-parachain/runtime/src/millau_messages.rs b/bin/rialto-parachain/runtime/src/millau_messages.rs index 9c00e6bad34..3c523ebfa12 100644 --- a/bin/rialto-parachain/runtime/src/millau_messages.rs +++ b/bin/rialto-parachain/runtime/src/millau_messages.rs @@ -134,3 +134,65 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler { XCM_LANE } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance}; + use bridge_runtime_common::{ + assert_complete_bridge_types, + integrity::{ + assert_complete_bridge_constants, check_message_lane_weights, + AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, + AssertCompleteBridgeConstants, + }, + }; + + #[test] + fn ensure_millau_message_lane_weights_are_correct() { + check_message_lane_weights::( + bp_millau::EXTRA_STORAGE_PROOF_SIZE, + bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + false, + ); + } + + #[test] + fn ensure_bridge_integrity() { + assert_complete_bridge_types!( + runtime: Runtime, + with_bridged_chain_grandpa_instance: MillauGrandpaInstance, + with_bridged_chain_messages_instance: WithMillauMessagesInstance, + bridge: WithMillauMessageBridge, + this_chain: bp_rialto_parachain::RialtoParachain, + bridged_chain: bp_millau::Millau, + ); + + assert_complete_bridge_constants::< + Runtime, + MillauGrandpaInstance, + WithMillauMessagesInstance, + WithMillauMessageBridge, + >(AssertCompleteBridgeConstants { + this_chain_constants: AssertChainConstants { + block_length: bp_rialto_parachain::BlockLength::get(), + block_weights: bp_rialto_parachain::BlockWeights::get(), + }, + messages_pallet_constants: AssertBridgeMessagesPalletConstants { + max_unrewarded_relayers_in_bridged_confirmation_tx: + bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + max_unconfirmed_messages_in_bridged_confirmation_tx: + bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + bridged_chain_id: bp_runtime::MILLAU_CHAIN_ID, + }, + pallet_names: AssertBridgePalletNames { + with_this_chain_messages_pallet_name: + bp_rialto_parachain::WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME, + with_bridged_chain_grandpa_pallet_name: bp_millau::WITH_MILLAU_GRANDPA_PALLET_NAME, + with_bridged_chain_messages_pallet_name: + bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME, + }, + }); + } +} diff --git a/bin/rialto/node/Cargo.toml b/bin/rialto/node/Cargo.toml index ffbb587dc1f..36eaa7021a0 100644 --- a/bin/rialto/node/Cargo.toml +++ b/bin/rialto/node/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -clap = { version = "4.2.4", features = ["derive"] } +clap = { version = "4.2.5", features = ["derive"] } serde_json = "1.0.96" # Bridge dependencies diff --git a/bin/rialto/runtime/Cargo.toml b/bin/rialto/runtime/Cargo.toml index 2b68e72d6f8..f687905ad63 100644 --- a/bin/rialto/runtime/Cargo.toml +++ b/bin/rialto/runtime/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge dependencies diff --git a/bin/rialto/runtime/src/millau_messages.rs b/bin/rialto/runtime/src/millau_messages.rs index 7c960639f2f..a7d1d19f0d8 100644 --- a/bin/rialto/runtime/src/millau_messages.rs +++ b/bin/rialto/runtime/src/millau_messages.rs @@ -149,11 +149,12 @@ mod tests { }; #[test] - fn ensure_rialto_message_lane_weights_are_correct() { + fn ensure_millau_message_lane_weights_are_correct() { check_message_lane_weights::( bp_millau::EXTRA_STORAGE_PROOF_SIZE, bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + false, ); } diff --git a/bin/runtime-common/Cargo.toml b/bin/runtime-common/Cargo.toml index 3db4ae9abca..039e323b9b7 100644 --- a/bin/runtime-common/Cargo.toml +++ b/bin/runtime-common/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } hash-db = { version = "0.16.0", default-features = false } log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } static_assertions = { version = "1.1", optional = true } # Bridge dependencies diff --git a/bin/runtime-common/src/integrity.rs b/bin/runtime-common/src/integrity.rs index 5820dd99b91..bf3d239eefd 100644 --- a/bin/runtime-common/src/integrity.rs +++ b/bin/runtime-common/src/integrity.rs @@ -24,8 +24,9 @@ use crate::{messages, messages::MessageBridge}; use bp_messages::{InboundLaneData, MessageNonce}; use bp_runtime::{Chain, ChainId}; use codec::Encode; -use frame_support::{storage::generator::StorageValue, traits::Get}; +use frame_support::{storage::generator::StorageValue, traits::Get, weights::Weight}; use frame_system::limits; +use pallet_bridge_messages::WeightInfoExt as _; use sp_runtime::traits::SignedExtension; /// Macro that ensures that the runtime configuration and chain primitives crate are sharing @@ -289,15 +290,25 @@ where } /// Check that the message lane weights are correct. -pub fn check_message_lane_weights( +pub fn check_message_lane_weights< + C: Chain, + T: frame_system::Config + pallet_bridge_messages::Config, +>( bridged_chain_extra_storage_proof_size: u32, this_chain_max_unrewarded_relayers: MessageNonce, this_chain_max_unconfirmed_messages: MessageNonce, + // whether `RefundBridgedParachainMessages` extension is deployed at runtime and is used for + // refunding this bridge transactions? + // + // in other words: pass true for all known production chains + runtime_includes_refund_extension: bool, ) { - type Weights = pallet_bridge_messages::weights::BridgeWeight; + type Weights = ::WeightInfo; + // check basic weight assumptions pallet_bridge_messages::ensure_weights_are_correct::>(); + // check that weights allow us to receive messages let max_incoming_message_proof_size = bridged_chain_extra_storage_proof_size .saturating_add(messages::target::maximal_incoming_message_size(C::max_extrinsic_size())); pallet_bridge_messages::ensure_able_to_receive_message::>( @@ -307,6 +318,7 @@ pub fn check_message_lane_weights( messages::target::maximal_incoming_message_dispatch_weight(C::max_extrinsic_weight()), ); + // check that weights allow us to receive delivery confirmations let max_incoming_inbound_lane_data_proof_size = InboundLaneData::<()>::encoded_size_hint_u32(this_chain_max_unrewarded_relayers as _); pallet_bridge_messages::ensure_able_to_receive_confirmation::>( @@ -316,6 +328,20 @@ pub fn check_message_lane_weights( this_chain_max_unrewarded_relayers, this_chain_max_unconfirmed_messages, ); + + // check that extra weights of delivery/confirmation transactions include the weight + // of `RefundBridgedParachainMessages` operations. This signed extension assumes the worst case + // (i.e. slashing if delivery transaction was invalid) and refunds some weight if + // assumption was wrong (i.e. if we did refund instead of slashing). This check + // ensures the extension will not refund weight when it doesn't need to (i.e. if pallet + // weights do not account weights of refund extension). + if runtime_includes_refund_extension { + assert_ne!(Weights::::receive_messages_proof_overhead_from_runtime(), Weight::zero()); + assert_ne!( + Weights::::receive_messages_delivery_proof_overhead_from_runtime(), + Weight::zero() + ); + } } /// Check that the `AdditionalSigned` type of a wrapped runtime is the same as the one of the diff --git a/bin/runtime-common/src/lib.rs b/bin/runtime-common/src/lib.rs index e8a2d2470fa..12b096492cd 100644 --- a/bin/runtime-common/src/lib.rs +++ b/bin/runtime-common/src/lib.rs @@ -159,7 +159,21 @@ pub enum CustomNetworkId { RialtoParachain, } +impl TryFrom for CustomNetworkId { + type Error = (); + + fn try_from(chain: bp_runtime::ChainId) -> Result { + Ok(match chain { + bp_runtime::MILLAU_CHAIN_ID => Self::Millau, + bp_runtime::RIALTO_CHAIN_ID => Self::Rialto, + bp_runtime::RIALTO_PARACHAIN_CHAIN_ID => Self::RialtoParachain, + _ => return Err(()), + }) + } +} + impl CustomNetworkId { + /// Converts self to XCM' network id. pub const fn as_network_id(&self) -> NetworkId { match *self { CustomNetworkId::Millau => NetworkId::Kusama, diff --git a/bin/runtime-common/src/refund_relayer_extension.rs b/bin/runtime-common/src/refund_relayer_extension.rs index 7d65263e9fd..00ea70aa04e 100644 --- a/bin/runtime-common/src/refund_relayer_extension.rs +++ b/bin/runtime-common/src/refund_relayer_extension.rs @@ -40,7 +40,9 @@ use pallet_bridge_parachains::{ BoundedBridgeGrandpaConfig, CallSubType as ParachainsCallSubType, Config as ParachainsConfig, RelayBlockNumber, SubmitParachainHeadsHelper, SubmitParachainHeadsInfo, }; -use pallet_bridge_relayers::{Config as RelayersConfig, Pallet as RelayersPallet}; +use pallet_bridge_relayers::{ + Config as RelayersConfig, Pallet as RelayersPallet, WeightInfoExt as _, +}; use pallet_transaction_payment::{Config as TransactionPaymentConfig, OnChargeTransaction}; use pallet_utility::{Call as UtilityCall, Config as UtilityConfig, Pallet as UtilityPallet}; use scale_info::TypeInfo; @@ -445,11 +447,19 @@ where // decrease post-dispatch weight/size using extra weight/size that we know now let post_info_len = len.saturating_sub(extra_size as usize); - let mut post_info = *post_info; - post_info.actual_weight = - Some(post_info.actual_weight.unwrap_or(info.weight).saturating_sub(extra_weight)); + let mut post_info_weight = + post_info.actual_weight.unwrap_or(info.weight).saturating_sub(extra_weight); + + // let's also replace the weight of slashing relayer with the weight of rewarding relayer + if call_info.is_receive_messages_proof_call() { + post_info_weight = post_info_weight.saturating_sub( + ::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(), + ); + } // compute the relayer refund + let mut post_info = *post_info; + post_info.actual_weight = Some(post_info_weight); let refund = Refund::compute_refund(info, &post_info, post_info_len, tip); // we can finally reward relayer @@ -1052,7 +1062,20 @@ mod tests { assert_eq!(post_dispatch_result, Ok(())); } - fn expected_reward() -> ThisChainBalance { + fn expected_delivery_reward() -> ThisChainBalance { + let mut post_dispatch_info = post_dispatch_info(); + let extra_weight = ::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(); + post_dispatch_info.actual_weight = + Some(dispatch_info().weight.saturating_sub(extra_weight)); + pallet_transaction_payment::Pallet::::compute_actual_fee( + 1024, + &dispatch_info(), + &post_dispatch_info, + Zero::zero(), + ) + } + + fn expected_confirmation_reward() -> ThisChainBalance { pallet_transaction_payment::Pallet::::compute_actual_fee( 1024, &dispatch_info(), @@ -1449,7 +1472,7 @@ mod tests { // without any size/weight refund: we expect regular reward let pre_dispatch_data = all_finality_pre_dispatch_data(); - let regular_reward = expected_reward(); + let regular_reward = expected_delivery_reward(); run_post_dispatch(Some(pre_dispatch_data), Ok(())); assert_eq!( RelayersPallet::::relayer_reward( @@ -1496,7 +1519,7 @@ mod tests { relayer_account_at_this_chain(), MsgProofsRewardsAccount::get() ), - Some(expected_reward()), + Some(expected_delivery_reward()), ); run_post_dispatch(Some(all_finality_confirmation_pre_dispatch_data()), Ok(())); @@ -1505,7 +1528,7 @@ mod tests { relayer_account_at_this_chain(), MsgDeliveryProofsRewardsAccount::get() ), - Some(expected_reward()), + Some(expected_confirmation_reward()), ); }); } @@ -1521,7 +1544,7 @@ mod tests { relayer_account_at_this_chain(), MsgProofsRewardsAccount::get() ), - Some(expected_reward()), + Some(expected_delivery_reward()), ); run_post_dispatch(Some(parachain_finality_confirmation_pre_dispatch_data()), Ok(())); @@ -1530,7 +1553,7 @@ mod tests { relayer_account_at_this_chain(), MsgDeliveryProofsRewardsAccount::get() ), - Some(expected_reward()), + Some(expected_confirmation_reward()), ); }); } @@ -1546,7 +1569,7 @@ mod tests { relayer_account_at_this_chain(), MsgProofsRewardsAccount::get() ), - Some(expected_reward()), + Some(expected_delivery_reward()), ); run_post_dispatch(Some(confirmation_pre_dispatch_data()), Ok(())); @@ -1555,7 +1578,7 @@ mod tests { relayer_account_at_this_chain(), MsgDeliveryProofsRewardsAccount::get() ), - Some(expected_reward()), + Some(expected_confirmation_reward()), ); }); } diff --git a/deployments/networks/dashboard/grafana/beefy-dashboard.json b/deployments/networks/dashboard/grafana/beefy-dashboard.json index 2e1e177641a..5cd74861a84 100644 --- a/deployments/networks/dashboard/grafana/beefy-dashboard.json +++ b/deployments/networks/dashboard/grafana/beefy-dashboard.json @@ -22,6 +22,7 @@ "fiscalYearStartMonth": 0, "gnetId": null, "graphTooltip": 0, + "id": 5, "links": [], "liveNow": false, "panels": [ @@ -220,29 +221,6 @@ "operator": { "type": "and" }, - "query": { - "params": [ - "A", - "5m", - "now" - ] - }, - "reducer": { - "params": [], - "type": "max" - }, - "type": "query" - }, - { - "evaluator": { - "params": [ - 0 - ], - "type": "gt" - }, - "operator": { - "type": "or" - }, "query": { "params": [ "B", @@ -371,19 +349,1046 @@ } }, { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "10m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "10m", + "frequency": "5m", + "handler": 1, + "name": "Equivocation votes detected alert", + "noDataState": "no_data", + "notifications": [] + }, "datasource": "Prometheus", - "fill": 1, - "fillGradient": 0, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, "gridPos": { - "h": 12, - "w": 18, + "h": 7, + "w": 6, "x": 0, "y": 14 }, + "id": 10, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_equivocation_votes", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "op": "gt", + "value": 0, + "visible": true + } + ], + "title": "Equivocation votes detected", + "type": "timeseries" + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "10m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "10m", + "frequency": "5m", + "handler": 1, + "name": "Invalid votes received alert", + "noDataState": "no_data", + "notifications": [] + }, + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 6, + "y": 14 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_invalid_votes", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "op": "gt", + "value": 0, + "visible": true + } + ], + "title": "Invalid votes received", + "type": "timeseries" + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "10m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "10m", + "frequency": "5m", + "handler": 1, + "name": "Dropped Buffered Justifications alert", + "noDataState": "no_data", + "notifications": [] + }, + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 12, + "y": 14 + }, + "id": 18, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_buffered_justifications_dropped", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "op": "gt", + "value": 0, + "visible": true + } + ], + "title": "Dropped Buffered Justifications", + "type": "timeseries" + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "10m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "10m", + "frequency": "5m", + "handler": 1, + "name": "OnDemand Justifications Engine alert", + "noDataState": "no_data", + "notifications": [] + }, + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 0, + "y": 21 + }, + "id": 26, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_on_demand_justification_invalid_proof", + "interval": "", + "legendFormat": "", + "refId": "A" + }, + { + "exemplar": true, + "expr": "substrate_beefy_on_demand_justification_good_proof", + "hide": false, + "interval": "", + "legendFormat": "", + "refId": "B" + }, + { + "exemplar": true, + "expr": "substrate_beefy_on_demand_justification_peer_error", + "hide": false, + "interval": "", + "legendFormat": "", + "refId": "C" + }, + { + "exemplar": true, + "expr": "beefy_on_demand_justification_peer_refused", + "hide": false, + "interval": "", + "legendFormat": "", + "refId": "D" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "op": "gt", + "value": 0, + "visible": true + } + ], + "title": "OnDemand Justifications Engine", + "type": "timeseries" + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "B", + "10m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "10m", + "frequency": "5m", + "handler": 1, + "name": "Incoming OnDemand Justifications alert", + "noDataState": "no_data", + "notifications": [] + }, + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 6, + "y": 21 + }, + "id": 24, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_successful_justification_responses", + "interval": "", + "legendFormat": "", + "refId": "A" + }, + { + "exemplar": true, + "expr": "substrate_beefy_failed_justification_responses", + "hide": false, + "interval": "", + "legendFormat": "", + "refId": "B" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "op": "gt", + "value": 0, + "visible": true + } + ], + "title": "Incoming OnDemand Justifications", + "type": "timeseries" + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 0 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "B", + "10m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "max" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "10m", + "frequency": "5m", + "handler": 1, + "name": "Block-import Justifications alert", + "noDataState": "no_data", + "notifications": [] + }, + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 12, + "y": 21 + }, + "id": 22, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_good_justification_imports", + "interval": "", + "legendFormat": "", + "refId": "A" + }, + { + "exemplar": true, + "expr": "substrate_beefy_bad_justification_imports", + "hide": false, + "interval": "", + "legendFormat": "", + "refId": "B" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "op": "gt", + "value": 0, + "visible": true + } + ], + "title": "Block-import Justifications", + "type": "timeseries" + }, + { + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 6, + "x": 0, + "y": 28 + }, + "id": 16, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_buffered_justifications", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Buffered Justifications", + "type": "timeseries" + }, + { + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 6, + "x": 6, + "y": 28 + }, + "id": 20, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_imported_justifications", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Imported Justifications", + "type": "timeseries" + }, + { + "datasource": "Prometheus", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 6, + "x": 12, + "y": 28 + }, + "id": 14, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "substrate_beefy_stale_votes", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Stale votes received", + "type": "timeseries" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 13, + "w": 18, + "x": 0, + "y": 41 + }, "hiddenSeries": false, "id": 6, "legend": { diff --git a/deployments/networks/millau.yml b/deployments/networks/millau.yml index d91c5d83286..24b263d82e5 100644 --- a/deployments/networks/millau.yml +++ b/deployments/networks/millau.yml @@ -11,7 +11,6 @@ services: image: ${MILLAU_BRIDGE_NODE_IMAGE:-paritytech/millau-bridge-node} entrypoint: - /home/user/millau-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/millau-node-bob/tcp/30333/p2p/12D3KooWM5LFR5ne4yTQ4sBSXJ75M4bDo2MAhAW2GhL3i8fe5aRb - --alice @@ -32,7 +31,6 @@ services: <<: *millau-bridge-node entrypoint: - /home/user/millau-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H - --bob @@ -51,7 +49,6 @@ services: <<: *millau-bridge-node entrypoint: - /home/user/millau-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H - --charlie @@ -69,7 +66,6 @@ services: <<: *millau-bridge-node entrypoint: - /home/user/millau-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H - --dave @@ -87,7 +83,6 @@ services: <<: *millau-bridge-node entrypoint: - /home/user/millau-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/millau-node-alice/tcp/30333/p2p/12D3KooWFqiV73ipQ1jpfVmCfLqBCp8G9PLH3zPkY9EhmdrSGA4H - --eve diff --git a/deployments/networks/rialto.yml b/deployments/networks/rialto.yml index ebd8393fcad..599b1c9a1b8 100644 --- a/deployments/networks/rialto.yml +++ b/deployments/networks/rialto.yml @@ -11,7 +11,6 @@ services: image: ${RIALTO_BRIDGE_NODE_IMAGE:-paritytech/rialto-bridge-node} entrypoint: - /home/user/rialto-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/rialto-node-bob/tcp/30333/p2p/12D3KooWSEpHJj29HEzgPFcRYVc5X3sEuP3KgiUoqJNCet51NiMX - --alice @@ -32,7 +31,6 @@ services: <<: *rialto-bridge-node entrypoint: - /home/user/rialto-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE - --bob @@ -51,7 +49,6 @@ services: <<: *rialto-bridge-node entrypoint: - /home/user/rialto-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE - --charlie @@ -69,7 +66,6 @@ services: <<: *rialto-bridge-node entrypoint: - /home/user/rialto-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE - --dave @@ -87,7 +83,6 @@ services: <<: *rialto-bridge-node entrypoint: - /home/user/rialto-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE - --eve @@ -105,7 +100,6 @@ services: <<: *rialto-bridge-node entrypoint: - /home/user/rialto-bridge-node - - --execution=Native - --chain=local - --bootnodes=/dns4/rialto-node-alice/tcp/30333/p2p/12D3KooWMF6JvV319a7kJn5pqkKbhR3fcM2cvK5vCbYZHeQhYzFE - --ferdie diff --git a/modules/beefy/Cargo.toml b/modules/beefy/Cargo.toml index 8aff2c169b4..4270b96e208 100644 --- a/modules/beefy/Cargo.toml +++ b/modules/beefy/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } log = { version = "0.4.14", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge Dependencies diff --git a/modules/grandpa/Cargo.toml b/modules/grandpa/Cargo.toml index 07d2593b914..9b97b518fc5 100644 --- a/modules/grandpa/Cargo.toml +++ b/modules/grandpa/Cargo.toml @@ -11,7 +11,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } finality-grandpa = { version = "0.16.2", default-features = false } log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge Dependencies diff --git a/modules/grandpa/src/weights.rs b/modules/grandpa/src/weights.rs index 089aee8b569..4b94f7adfe7 100644 --- a/modules/grandpa/src/weights.rs +++ b/modules/grandpa/src/weights.rs @@ -35,7 +35,7 @@ // --wasm-execution=Compiled // --heap-pages=4096 // --output=./modules/grandpa/src/weights.rs -// --template=./.maintain/millau-weight-template.hbs +// --template=./.maintain/bridge-weight-template.hbs #![allow(clippy::all)] #![allow(unused_parens)] diff --git a/modules/messages/Cargo.toml b/modules/messages/Cargo.toml index f733d62bf64..639ac9dc23c 100644 --- a/modules/messages/Cargo.toml +++ b/modules/messages/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } log = { version = "0.4.17", default-features = false } num-traits = { version = "0.2", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge dependencies diff --git a/modules/messages/src/lib.rs b/modules/messages/src/lib.rs index 8f4911b8d03..045015b7751 100644 --- a/modules/messages/src/lib.rs +++ b/modules/messages/src/lib.rs @@ -329,9 +329,10 @@ pub mod pallet { if let Some(updated_latest_confirmed_nonce) = updated_latest_confirmed_nonce { log::trace!( target: LOG_TARGET, - "Received lane {:?} state update: latest_confirmed_nonce={}", + "Received lane {:?} state update: latest_confirmed_nonce={}. Unrewarded relayers: {:?}", lane_id, updated_latest_confirmed_nonce, + UnrewardedRelayersState::from(&lane.storage().data()), ); } } diff --git a/modules/messages/src/mock.rs b/modules/messages/src/mock.rs index 3d78ab562d2..2e45d5b601f 100644 --- a/modules/messages/src/mock.rs +++ b/modules/messages/src/mock.rs @@ -26,8 +26,8 @@ use bp_messages::{ DeliveryPayments, DispatchMessage, DispatchMessageData, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain, }, - total_unrewarded_messages, DeliveredMessages, InboundLaneData, LaneId, Message, MessageKey, - MessageNonce, MessagePayload, OutboundLaneData, UnrewardedRelayer, UnrewardedRelayersState, + DeliveredMessages, InboundLaneData, LaneId, Message, MessageKey, MessageNonce, MessagePayload, + OutboundLaneData, UnrewardedRelayer, UnrewardedRelayersState, }; use bp_runtime::{messages::MessageDispatchResult, Size}; use codec::{Decode, Encode}; @@ -485,17 +485,7 @@ pub fn unrewarded_relayer( /// Returns unrewarded relayers state at given lane. pub fn inbound_unrewarded_relayers_state(lane: bp_messages::LaneId) -> UnrewardedRelayersState { let inbound_lane_data = crate::InboundLanes::::get(lane).0; - let last_delivered_nonce = inbound_lane_data.last_delivered_nonce(); - let relayers = inbound_lane_data.relayers; - UnrewardedRelayersState { - unrewarded_relayer_entries: relayers.len() as _, - messages_in_oldest_entry: relayers - .front() - .map(|entry| 1 + entry.messages.end - entry.messages.begin) - .unwrap_or(0), - total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX), - last_delivered_nonce, - } + UnrewardedRelayersState::from(&inbound_lane_data) } /// Return test externalities to use in tests. diff --git a/modules/messages/src/outbound_lane.rs b/modules/messages/src/outbound_lane.rs index 33a58a40400..3d0d4de966a 100644 --- a/modules/messages/src/outbound_lane.rs +++ b/modules/messages/src/outbound_lane.rs @@ -196,9 +196,6 @@ fn ensure_unrewarded_relayers_are_correct( // entry can't confirm messages larger than `inbound_lane_data.latest_received_nonce()` // (guaranteed by the `InboundLane::receive_message()`) if entry.messages.end > latest_received_nonce { - // technically this will be detected in the next loop iteration as - // `InvalidNumberOfDispatchResults` but to guarantee safety of loop operations below - // this is detected now return Err(ReceivalConfirmationResult::FailedToConfirmFutureMessages) } } diff --git a/modules/messages/src/weights.rs b/modules/messages/src/weights.rs index baaef317241..9880f1dd1ea 100644 --- a/modules/messages/src/weights.rs +++ b/modules/messages/src/weights.rs @@ -35,7 +35,7 @@ // --wasm-execution=Compiled // --heap-pages=4096 // --output=./modules/messages/src/weights.rs -// --template=./.maintain/millau-weight-template.hbs +// --template=./.maintain/bridge-weight-template.hbs #![allow(clippy::all)] #![allow(unused_parens)] diff --git a/modules/messages/src/weights_ext.rs b/modules/messages/src/weights_ext.rs index 090c03390ba..3aefd6be7ca 100644 --- a/modules/messages/src/weights_ext.rs +++ b/modules/messages/src/weights_ext.rs @@ -266,6 +266,27 @@ pub trait WeightInfoExt: WeightInfo { /// this value, we're going to charge relayer for that. fn expected_extra_storage_proof_size() -> u32; + // Our configuration assumes that the runtime has special signed extensions used to: + // + // 1) reject obsolete delivery and confirmation transactions; + // + // 2) refund transaction cost to relayer and register his rewards. + // + // The checks in (1) are trivial, so its computation weight may be ignored. And we only touch + // storage values that are read during the call. So we may ignore the weight of this check. + // + // However, during (2) we read and update storage values of other pallets + // (`pallet-bridge-relayers` and balances/assets pallet). So we need to add this weight to the + // weight of our call. Hence two following methods. + + /// Extra weight that is added to the `receive_messages_proof` call weight by signed extensions + /// that are declared at runtime level. + fn receive_messages_proof_overhead_from_runtime() -> Weight; + + /// Extra weight that is added to the `receive_messages_delivery_proof` call weight by signed + /// extensions that are declared at runtime level. + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight; + // Functions that are directly mapped to extrinsics weights. /// Weight of message delivery extrinsic. @@ -276,6 +297,8 @@ pub trait WeightInfoExt: WeightInfo { ) -> Weight { // basic components of extrinsic weight let transaction_overhead = Self::receive_messages_proof_overhead(); + let transaction_overhead_from_runtime = + Self::receive_messages_proof_overhead_from_runtime(); let outbound_state_delivery_weight = Self::receive_messages_proof_outbound_lane_state_overhead(); let messages_delivery_weight = @@ -292,6 +315,7 @@ pub trait WeightInfoExt: WeightInfo { ); transaction_overhead + .saturating_add(transaction_overhead_from_runtime) .saturating_add(outbound_state_delivery_weight) .saturating_add(messages_delivery_weight) .saturating_add(messages_dispatch_weight) @@ -305,6 +329,8 @@ pub trait WeightInfoExt: WeightInfo { ) -> Weight { // basic components of extrinsic weight let transaction_overhead = Self::receive_messages_delivery_proof_overhead(); + let transaction_overhead_from_runtime = + Self::receive_messages_delivery_proof_overhead_from_runtime(); let messages_overhead = Self::receive_messages_delivery_proof_messages_overhead(relayers_state.total_messages); let relayers_overhead = Self::receive_messages_delivery_proof_relayers_overhead( @@ -319,6 +345,7 @@ pub trait WeightInfoExt: WeightInfo { ); transaction_overhead + .saturating_add(transaction_overhead_from_runtime) .saturating_add(messages_overhead) .saturating_add(relayers_overhead) .saturating_add(proof_size_overhead) @@ -424,12 +451,28 @@ impl WeightInfoExt for () { fn expected_extra_storage_proof_size() -> u32 { EXTRA_STORAGE_PROOF_SIZE } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } } impl WeightInfoExt for crate::weights::BridgeWeight { fn expected_extra_storage_proof_size() -> u32 { EXTRA_STORAGE_PROOF_SIZE } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } } #[cfg(test)] diff --git a/modules/parachains/Cargo.toml b/modules/parachains/Cargo.toml index 39c3ba626aa..d8c89b79991 100644 --- a/modules/parachains/Cargo.toml +++ b/modules/parachains/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge Dependencies diff --git a/modules/parachains/src/weights.rs b/modules/parachains/src/weights.rs index 54a835cbc87..1e81dba72fe 100644 --- a/modules/parachains/src/weights.rs +++ b/modules/parachains/src/weights.rs @@ -35,7 +35,7 @@ // --wasm-execution=Compiled // --heap-pages=4096 // --output=./modules/parachains/src/weights.rs -// --template=./.maintain/millau-weight-template.hbs +// --template=./.maintain/bridge-weight-template.hbs #![allow(clippy::all)] #![allow(unused_parens)] diff --git a/modules/relayers/Cargo.toml b/modules/relayers/Cargo.toml index c654c60d02b..857d47cc65a 100644 --- a/modules/relayers/Cargo.toml +++ b/modules/relayers/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge dependencies diff --git a/modules/relayers/src/benchmarking.rs b/modules/relayers/src/benchmarking.rs index a762a5693c2..d66a11ff06d 100644 --- a/modules/relayers/src/benchmarking.rs +++ b/modules/relayers/src/benchmarking.rs @@ -24,6 +24,7 @@ use bp_messages::LaneId; use bp_relayers::RewardsAccountOwner; use frame_benchmarking::{benchmarks, whitelisted_caller}; use frame_system::RawOrigin; +use sp_runtime::traits::One; /// Reward amount that is (hopefully) is larger than existential deposit across all chains. const REWARD_AMOUNT: u32 = u32::MAX; @@ -34,7 +35,9 @@ pub struct Pallet(crate::Pallet); /// Trait that must be implemented by runtime. pub trait Config: crate::Config { /// Prepare environment for paying given reward for serving given lane. - fn prepare_environment(account_params: RewardsAccountParams, reward: Self::Reward); + fn prepare_rewards_account(account_params: RewardsAccountParams, reward: Self::Reward); + /// Give enough balance to given account. + fn deposit_account(account: Self::AccountId, balance: Self::Reward); } benchmarks! { @@ -46,7 +49,7 @@ benchmarks! { let relayer: T::AccountId = whitelisted_caller(); let reward = T::Reward::from(REWARD_AMOUNT); - T::prepare_environment(account_params, reward); + T::prepare_rewards_account(account_params, reward); RelayerRewards::::insert(&relayer, account_params, reward); }: _(RawOrigin::Signed(relayer), account_params) verify { @@ -55,5 +58,74 @@ benchmarks! { // also completed successfully } + // Benchmark `register` call. + register { + let relayer: T::AccountId = whitelisted_caller(); + let valid_till = frame_system::Pallet::::block_number() + .saturating_add(crate::Pallet::::required_registration_lease()) + .saturating_add(One::one()) + .saturating_add(One::one()); + + T::deposit_account(relayer.clone(), crate::Pallet::::required_stake()); + }: _(RawOrigin::Signed(relayer.clone()), valid_till) + verify { + assert!(crate::Pallet::::is_registration_active(&relayer)); + } + + // Benchmark `deregister` call. + deregister { + let relayer: T::AccountId = whitelisted_caller(); + let valid_till = frame_system::Pallet::::block_number() + .saturating_add(crate::Pallet::::required_registration_lease()) + .saturating_add(One::one()) + .saturating_add(One::one()); + T::deposit_account(relayer.clone(), crate::Pallet::::required_stake()); + crate::Pallet::::register(RawOrigin::Signed(relayer.clone()).into(), valid_till).unwrap(); + + frame_system::Pallet::::set_block_number(valid_till.saturating_add(One::one())); + }: _(RawOrigin::Signed(relayer.clone())) + verify { + assert!(!crate::Pallet::::is_registration_active(&relayer)); + } + + // Benchmark `slash_and_deregister` method of the pallet. We are adding this weight to + // the weight of message delivery call if `RefundBridgedParachainMessages` signed extension + // is deployed at runtime level. + slash_and_deregister { + // prepare and register relayer account + let relayer: T::AccountId = whitelisted_caller(); + let valid_till = frame_system::Pallet::::block_number() + .saturating_add(crate::Pallet::::required_registration_lease()) + .saturating_add(One::one()) + .saturating_add(One::one()); + T::deposit_account(relayer.clone(), crate::Pallet::::required_stake()); + crate::Pallet::::register(RawOrigin::Signed(relayer.clone()).into(), valid_till).unwrap(); + + // create slash destination account + let lane = LaneId([0, 0, 0, 0]); + let slash_destination = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); + T::prepare_rewards_account(slash_destination.clone(), Zero::zero()); + }: { + crate::Pallet::::slash_and_deregister(&relayer, slash_destination) + } + verify { + assert!(!crate::Pallet::::is_registration_active(&relayer)); + } + + // Benchmark `register_relayer_reward` method of the pallet. We are adding this weight to + // the weight of message delivery call if `RefundBridgedParachainMessages` signed extension + // is deployed at runtime level. + register_relayer_reward { + let lane = LaneId([0, 0, 0, 0]); + let relayer: T::AccountId = whitelisted_caller(); + let account_params = + RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); + }: { + crate::Pallet::::register_relayer_reward(account_params.clone(), &relayer, One::one()); + } + verify { + assert_eq!(RelayerRewards::::get(relayer, &account_params), Some(One::one())); + } + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime) } diff --git a/modules/relayers/src/lib.rs b/modules/relayers/src/lib.rs index 14e44d30f89..54b888cf29d 100644 --- a/modules/relayers/src/lib.rs +++ b/modules/relayers/src/lib.rs @@ -33,12 +33,14 @@ pub use pallet::*; pub use payment_adapter::DeliveryConfirmationPaymentsAdapter; pub use stake_adapter::StakeAndSlashNamed; pub use weights::WeightInfo; +pub use weights_ext::WeightInfoExt; pub mod benchmarking; mod mock; mod payment_adapter; mod stake_adapter; +mod weights_ext; pub mod weights; @@ -66,7 +68,7 @@ pub mod pallet { /// Stake and slash scheme. type StakeAndSlash: StakeAndSlash; /// Pallet call weights. - type WeightInfo: WeightInfo; + type WeightInfo: WeightInfoExt; } #[pallet::pallet] @@ -114,7 +116,7 @@ pub mod pallet { /// /// Registration allows relayer to get priority boost for its message delivery transactions. #[pallet::call_index(1)] - #[pallet::weight(Weight::zero())] // TODO: https://github.com/paritytech/parity-bridges-common/issues/2033 + #[pallet::weight(T::WeightInfo::register())] pub fn register(origin: OriginFor, valid_till: T::BlockNumber) -> DispatchResult { let relayer = ensure_signed(origin)?; @@ -159,6 +161,7 @@ pub mod pallet { } registration.stake = required_stake; + log::trace!(target: LOG_TARGET, "Successfully registered relayer: {:?}", relayer); Self::deposit_event(Event::::RegistrationUpdated { relayer: relayer.clone(), registration, @@ -175,7 +178,7 @@ pub mod pallet { /// After this call, message delivery transactions of the relayer won't get any priority /// boost. #[pallet::call_index(2)] - #[pallet::weight(Weight::zero())] // TODO: https://github.com/paritytech/parity-bridges-common/issues/2033 + #[pallet::weight(T::WeightInfo::deregister())] pub fn deregister(origin: OriginFor) -> DispatchResult { let relayer = ensure_signed(origin)?; @@ -196,6 +199,7 @@ pub mod pallet { Self::do_unreserve(&relayer, registration.stake)?; } + log::trace!(target: LOG_TARGET, "Successfully deregistered relayer: {:?}", relayer); Self::deposit_event(Event::::Deregistered { relayer: relayer.clone() }); *maybe_registration = None; @@ -326,7 +330,7 @@ pub mod pallet { } /// Return required registration lease. - fn required_registration_lease() -> T::BlockNumber { + pub(crate) fn required_registration_lease() -> T::BlockNumber { T::Reward { + pub(crate) fn required_stake() -> T::Reward { ::rewards_account( account_params, ); - Balances::mint_into(&rewards_account, reward).unwrap(); + Self::deposit_account(rewards_account, reward); + } + + fn deposit_account(account: Self::AccountId, balance: Self::Reward) { + Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap(); } } diff --git a/modules/relayers/src/weights.rs b/modules/relayers/src/weights.rs index 1f111aaf136..1bc195a5424 100644 --- a/modules/relayers/src/weights.rs +++ b/modules/relayers/src/weights.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for pallet_bridge_relayers //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-04-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -35,7 +35,7 @@ // --wasm-execution=Compiled // --heap-pages=4096 // --output=./modules/relayers/src/weights.rs -// --template=./.maintain/millau-weight-template.hbs +// --template=./.maintain/bridge-weight-template.hbs #![allow(clippy::all)] #![allow(unused_parens)] @@ -51,6 +51,10 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_bridge_relayers. pub trait WeightInfo { fn claim_rewards() -> Weight; + fn register() -> Weight; + fn deregister() -> Weight; + fn slash_and_deregister() -> Weight; + fn register_relayer_reward() -> Weight; } /// Weights for `pallet_bridge_relayers` that are generated using one of the Bridge testnets. @@ -63,19 +67,96 @@ impl WeightInfo for BridgeWeight { /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, /// mode: MaxEncodedLen) /// + /// Storage: Balances TotalIssuance (r:1 w:0) + /// + /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(8), added: 503, mode: + /// MaxEncodedLen) + /// /// Storage: System Account (r:1 w:1) /// - /// Proof: System Account (max_values: None, max_size: Some(96), added: 2571, mode: + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: /// MaxEncodedLen) fn claim_rewards() -> Weight { // Proof Size summary in bytes: - // Measured: `275` - // Estimated: `5111` - // Minimum execution time: 48_639 nanoseconds. - Weight::from_parts(49_600_000, 5111) + // Measured: `294` + // Estimated: `8592` + // Minimum execution time: 77_614 nanoseconds. + Weight::from_parts(79_987_000, 8592) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `87` + // Estimated: `7843` + // Minimum execution time: 39_590 nanoseconds. + Weight::from_parts(40_546_000, 7843) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `264` + // Estimated: `7843` + // Minimum execution time: 43_332 nanoseconds. + Weight::from_parts(45_087_000, 7843) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + /// + /// Storage: System Account (r:1 w:1) + /// + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: + /// MaxEncodedLen) + fn slash_and_deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `380` + // Estimated: `11412` + // Minimum execution time: 42_358 nanoseconds. + Weight::from_parts(43_539_000, 11412) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn register_relayer_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `12` + // Estimated: `3530` + // Minimum execution time: 6_338 nanoseconds. + Weight::from_parts(6_526_000, 3530) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } // For backwards compatibility and tests @@ -85,17 +166,94 @@ impl WeightInfo for () { /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, /// mode: MaxEncodedLen) /// + /// Storage: Balances TotalIssuance (r:1 w:0) + /// + /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(8), added: 503, mode: + /// MaxEncodedLen) + /// /// Storage: System Account (r:1 w:1) /// - /// Proof: System Account (max_values: None, max_size: Some(96), added: 2571, mode: + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: /// MaxEncodedLen) fn claim_rewards() -> Weight { // Proof Size summary in bytes: - // Measured: `275` - // Estimated: `5111` - // Minimum execution time: 48_639 nanoseconds. - Weight::from_parts(49_600_000, 5111) + // Measured: `294` + // Estimated: `8592` + // Minimum execution time: 77_614 nanoseconds. + Weight::from_parts(79_987_000, 8592) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `87` + // Estimated: `7843` + // Minimum execution time: 39_590 nanoseconds. + Weight::from_parts(40_546_000, 7843) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `264` + // Estimated: `7843` + // Minimum execution time: 43_332 nanoseconds. + Weight::from_parts(45_087_000, 7843) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + /// + /// Storage: System Account (r:1 w:1) + /// + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: + /// MaxEncodedLen) + fn slash_and_deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `380` + // Estimated: `11412` + // Minimum execution time: 42_358 nanoseconds. + Weight::from_parts(43_539_000, 11412) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn register_relayer_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `12` + // Estimated: `3530` + // Minimum execution time: 6_338 nanoseconds. + Weight::from_parts(6_526_000, 3530) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } } diff --git a/modules/relayers/src/weights_ext.rs b/modules/relayers/src/weights_ext.rs new file mode 100644 index 00000000000..d459b0686bd --- /dev/null +++ b/modules/relayers/src/weights_ext.rs @@ -0,0 +1,49 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Bridges Common is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Bridges Common. If not, see . + +//! Weight-related utilities. + +use crate::weights::WeightInfo; + +use frame_support::pallet_prelude::Weight; + +/// Extended weight info. +pub trait WeightInfoExt: WeightInfo { + /// Returns weight, that needs to be added to the pre-dispatch weight of message delivery call, + /// if `RefundBridgedParachainMessages` signed extension is deployed at runtime level. + fn receive_messages_proof_overhead_from_runtime() -> Weight { + Self::slash_and_deregister().max(Self::register_relayer_reward()) + } + + /// Returns weight, that needs to be added to the pre-dispatch weight of message delivery + /// confirmation call, if `RefundBridgedParachainMessages` signed extension is deployed at + /// runtime level. + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + Self::register_relayer_reward() + } + + /// Returns weight that we need to deduct from the message delivery call weight that has + /// completed successfully. + /// + /// Usually, the weight of `slash_and_deregister` is larger than the weight of the + /// `register_relayer_reward`. So if relayer has been rewarded, we want to deduct the difference + /// to get the actual post-dispatch weight. + fn extra_weight_of_successful_receive_messages_proof_call() -> Weight { + Self::slash_and_deregister().saturating_sub(Self::register_relayer_reward()) + } +} + +impl WeightInfoExt for T {} diff --git a/modules/shift-session-manager/Cargo.toml b/modules/shift-session-manager/Cargo.toml index 2d7dc272a6f..1a14f230c6b 100644 --- a/modules/shift-session-manager/Cargo.toml +++ b/modules/shift-session-manager/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Substrate Dependencies diff --git a/primitives/beefy/Cargo.toml b/primitives/beefy/Cargo.toml index 9039064fbf4..3316bc09d51 100644 --- a/primitives/beefy/Cargo.toml +++ b/primitives/beefy/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "bit-vec"] } -scale-info = { version = "2.5.0", default-features = false, features = ["bit-vec", "derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["bit-vec", "derive"] } serde = { version = "1.0", optional = true } # Bridge Dependencies diff --git a/primitives/chain-millau/Cargo.toml b/primitives/chain-millau/Cargo.toml index d1e2e0edd96..7c5c5e11345 100644 --- a/primitives/chain-millau/Cargo.toml +++ b/primitives/chain-millau/Cargo.toml @@ -13,7 +13,7 @@ hash256-std-hasher = { version = "0.15.2", default-features = false } impl-codec = { version = "0.6", default-features = false } impl-serde = { version = "0.4.0", optional = true } parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge Dependencies diff --git a/primitives/header-chain/Cargo.toml b/primitives/header-chain/Cargo.toml index 5b9f87614a8..e0349ebc9b9 100644 --- a/primitives/header-chain/Cargo.toml +++ b/primitives/header-chain/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } finality-grandpa = { version = "0.16.2", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge dependencies diff --git a/primitives/messages/Cargo.toml b/primitives/messages/Cargo.toml index 32d7c65ebcb..32a89f6cf78 100644 --- a/primitives/messages/Cargo.toml +++ b/primitives/messages/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "bit-vec"] } -scale-info = { version = "2.5.0", default-features = false, features = ["bit-vec", "derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["bit-vec", "derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge dependencies diff --git a/primitives/messages/src/lib.rs b/primitives/messages/src/lib.rs index 2828d5af006..e485aa2f801 100644 --- a/primitives/messages/src/lib.rs +++ b/primitives/messages/src/lib.rs @@ -316,6 +316,21 @@ pub struct UnrewardedRelayersState { pub last_delivered_nonce: MessageNonce, } +impl From<&InboundLaneData> for UnrewardedRelayersState { + fn from(lane: &InboundLaneData) -> UnrewardedRelayersState { + UnrewardedRelayersState { + unrewarded_relayer_entries: lane.relayers.len() as _, + messages_in_oldest_entry: lane + .relayers + .front() + .and_then(|entry| (entry.messages.begin..=entry.messages.end).checked_len()) + .unwrap_or(0), + total_messages: total_unrewarded_messages(&lane.relayers).unwrap_or(MessageNonce::MAX), + last_delivered_nonce: lane.last_delivered_nonce(), + } + } +} + /// Outbound lane data. #[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] pub struct OutboundLaneData { diff --git a/primitives/parachains/Cargo.toml b/primitives/parachains/Cargo.toml index e47b8c5e68c..426597a2508 100644 --- a/primitives/parachains/Cargo.toml +++ b/primitives/parachains/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } impl-trait-for-tuples = "0.2" -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } # Bridge dependencies diff --git a/primitives/polkadot-core/Cargo.toml b/primitives/polkadot-core/Cargo.toml index daae99ec71c..56c6de04d41 100644 --- a/primitives/polkadot-core/Cargo.toml +++ b/primitives/polkadot-core/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } parity-util-mem = { version = "0.12.0", optional = true } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge Dependencies diff --git a/primitives/relayers/Cargo.toml b/primitives/relayers/Cargo.toml index 8ac31258488..b84b0393adf 100644 --- a/primitives/relayers/Cargo.toml +++ b/primitives/relayers/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "bit-vec"] } -scale-info = { version = "2.5.0", default-features = false, features = ["bit-vec", "derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["bit-vec", "derive"] } # Bridge Dependencies diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 4d48ad61894..694ff4e1aa6 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "3.1.5", default-features = hash-db = { version = "0.16.0", default-features = false } impl-trait-for-tuples = "0.2.2" num-traits = { version = "0.2", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Substrate Dependencies diff --git a/relays/bin-substrate/Cargo.toml b/relays/bin-substrate/Cargo.toml index 7853b9cb599..0a315035042 100644 --- a/relays/bin-substrate/Cargo.toml +++ b/relays/bin-substrate/Cargo.toml @@ -49,6 +49,9 @@ relay-utils = { path = "../utils" } relay-westend-client = { path = "../client-westend" } relay-wococo-client = { path = "../client-wococo" } rialto-runtime = { path = "../../bin/rialto/runtime" } +# we are not using this runtime to craft callsour transactions, but we still need it +# to prepare large XCM messages +rialto-parachain-runtime = { path = "../../bin/rialto-parachain/runtime" } substrate-relay-helper = { path = "../lib-substrate-relay" } # Substrate Dependencies @@ -62,8 +65,8 @@ polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } -xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } - +xcm = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master" } [dev-dependencies] bp-test-utils = { path = "../../primitives/test-utils" } diff --git a/relays/bin-substrate/src/chains/millau.rs b/relays/bin-substrate/src/chains/millau.rs index 44416195c6a..4cee26255d3 100644 --- a/relays/bin-substrate/src/chains/millau.rs +++ b/relays/bin-substrate/src/chains/millau.rs @@ -18,10 +18,38 @@ use crate::cli::{encode_message::CliEncodeMessage, CliChain}; use bp_runtime::EncodedOrDecodedCall; +use bridge_runtime_common::CustomNetworkId; use relay_millau_client::Millau; use relay_substrate_client::SimpleRuntimeVersion; +use xcm_executor::traits::ExportXcm; impl CliEncodeMessage for Millau { + fn encode_wire_message( + target: xcm::v3::NetworkId, + at_target_xcm: xcm::v3::Xcm<()>, + ) -> anyhow::Result> { + anyhow::ensure!( + [ + CustomNetworkId::Rialto.as_network_id(), + CustomNetworkId::RialtoParachain.as_network_id() + ] + .contains(&target), + anyhow::format_err!("Unsupported target chain: {:?}", target) + ); + + Ok(millau_runtime::xcm_config::ToRialtoOrRialtoParachainSwitchExporter::validate( + target, + 0, + &mut Some(Self::dummy_universal_source()?), + &mut Some(target.into()), + &mut Some(at_target_xcm), + ) + .map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))? + .0 + .1 + .0) + } + fn encode_execute_xcm( message: xcm::VersionedXcm, ) -> anyhow::Result> { diff --git a/relays/bin-substrate/src/chains/rialto.rs b/relays/bin-substrate/src/chains/rialto.rs index 34a448ae4cb..30bc7eb13ca 100644 --- a/relays/bin-substrate/src/chains/rialto.rs +++ b/relays/bin-substrate/src/chains/rialto.rs @@ -18,10 +18,33 @@ use crate::cli::{encode_message::CliEncodeMessage, CliChain}; use bp_runtime::EncodedOrDecodedCall; +use bridge_runtime_common::CustomNetworkId; use relay_rialto_client::Rialto; use relay_substrate_client::SimpleRuntimeVersion; +use xcm_executor::traits::ExportXcm; impl CliEncodeMessage for Rialto { + fn encode_wire_message( + target: xcm::v3::NetworkId, + at_target_xcm: xcm::v3::Xcm<()>, + ) -> anyhow::Result> { + anyhow::ensure!( + target == CustomNetworkId::Millau.as_network_id(), + anyhow::format_err!("Unsupported target chain: {:?}", target) + ); + + Ok(rialto_runtime::millau_messages::ToMillauBlobExporter::validate( + target, + 0, + &mut Some(Self::dummy_universal_source()?), + &mut Some(target.into()), + &mut Some(at_target_xcm), + ) + .map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))? + .0 + .0) + } + fn encode_execute_xcm( message: xcm::VersionedXcm, ) -> anyhow::Result> { diff --git a/relays/bin-substrate/src/chains/rialto_parachain.rs b/relays/bin-substrate/src/chains/rialto_parachain.rs index 8ea2c1ffd43..872d96981d0 100644 --- a/relays/bin-substrate/src/chains/rialto_parachain.rs +++ b/relays/bin-substrate/src/chains/rialto_parachain.rs @@ -18,10 +18,33 @@ use crate::cli::{encode_message::CliEncodeMessage, CliChain}; use bp_runtime::EncodedOrDecodedCall; +use bridge_runtime_common::CustomNetworkId; use relay_rialto_parachain_client::RialtoParachain; use relay_substrate_client::SimpleRuntimeVersion; +use xcm_executor::traits::ExportXcm; impl CliEncodeMessage for RialtoParachain { + fn encode_wire_message( + target: xcm::v3::NetworkId, + at_target_xcm: xcm::v3::Xcm<()>, + ) -> anyhow::Result> { + anyhow::ensure!( + target == CustomNetworkId::Millau.as_network_id(), + anyhow::format_err!("Unsupported target chain: {:?}", target) + ); + + Ok(rialto_parachain_runtime::millau_messages::ToMillauBlobExporter::validate( + target, + 0, + &mut Some(Self::dummy_universal_source()?), + &mut Some(target.into()), + &mut Some(at_target_xcm), + ) + .map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))? + .0 + .0) + } + fn encode_execute_xcm( message: xcm::VersionedXcm, ) -> anyhow::Result> { diff --git a/relays/bin-substrate/src/cli/encode_message.rs b/relays/bin-substrate/src/cli/encode_message.rs index 9abf8b2df6d..646075e8326 100644 --- a/relays/bin-substrate/src/cli/encode_message.rs +++ b/relays/bin-substrate/src/cli/encode_message.rs @@ -16,10 +16,12 @@ use crate::cli::{ExplicitOrMaximal, HexBytes}; use bp_runtime::EncodedOrDecodedCall; +use bridge_runtime_common::CustomNetworkId; use codec::Encode; use frame_support::weights::Weight; use relay_substrate_client::Chain; use structopt::StructOpt; +use xcm::latest::prelude::*; /// All possible messages that may be delivered to generic Substrate chain. /// @@ -43,6 +45,22 @@ pub enum Message { pub type RawMessage = Vec; pub trait CliEncodeMessage: Chain { + /// Returns dummy `AccountId32` universal source given this network id. + fn dummy_universal_source() -> anyhow::Result { + use xcm::v3::prelude::*; + + let this_network = CustomNetworkId::try_from(Self::ID) + .map(|n| n.as_network_id()) + .map_err(|_| anyhow::format_err!("Unsupported chain: {:?}", Self::ID))?; + Ok(X2( + GlobalConsensus(this_network), + AccountId32 { network: Some(this_network), id: [0u8; 32] }, + )) + } + + /// Returns XCM blob that is passed to the `send_message` function of the messages pallet + /// and then is sent over the wire. + fn encode_wire_message(target: NetworkId, at_target_xcm: Xcm<()>) -> anyhow::Result>; /// Encode an `execute` XCM call of the XCM pallet. fn encode_execute_xcm( message: xcm::VersionedXcm, @@ -56,41 +74,52 @@ pub trait CliEncodeMessage: Chain { } /// Encode message payload passed through CLI flags. -pub(crate) fn encode_message( +pub(crate) fn encode_message( message: &Message, ) -> anyhow::Result { Ok(match message { Message::Raw { ref data } => data.0.clone(), Message::Sized { ref size } => { - let expected_xcm_size = match *size { + let destination = CustomNetworkId::try_from(Target::ID) + .map(|n| n.as_network_id()) + .map_err(|_| anyhow::format_err!("Unsupported target chain: {:?}", Target::ID))?; + let expected_size = match *size { ExplicitOrMaximal::Explicit(size) => size, ExplicitOrMaximal::Maximal => compute_maximal_message_size( Source::max_extrinsic_size(), Target::max_extrinsic_size(), ), - }; - - // there's no way to craft XCM of the given size - we'll be using `ExpectPallet` - // instruction, which has byte vector inside - let mut current_vec_size = expected_xcm_size; - let xcm = loop { - let xcm = xcm::VersionedXcm::<()>::V3( - vec![xcm::v3::Instruction::ExpectPallet { - index: 0, - name: vec![42; current_vec_size as usize], - module_name: vec![], - crate_major: 0, - min_crate_minor: 0, - }] - .into(), - ); - if xcm.encode().len() <= expected_xcm_size as usize { - break xcm - } - - current_vec_size -= 1; - }; - xcm.encode() + } as usize; + + let at_target_xcm = vec![ExpectPallet { + index: 0, + name: vec![42; expected_size], + module_name: vec![], + crate_major: 0, + min_crate_minor: 0, + }] + .into(); + let at_target_xcm_size = + Source::encode_wire_message(destination, at_target_xcm)?.encoded_size(); + let at_target_xcm_overhead = at_target_xcm_size.saturating_sub(expected_size); + let at_target_xcm = vec![ExpectPallet { + index: 0, + name: vec![42; expected_size.saturating_sub(at_target_xcm_overhead)], + module_name: vec![], + crate_major: 0, + min_crate_minor: 0, + }] + .into(); + + xcm::VersionedXcm::<()>::V3( + vec![ExportMessage { + network: destination, + destination: destination.into(), + xcm: at_target_xcm, + }] + .into(), + ) + .encode() }, }) } @@ -108,11 +137,7 @@ pub(crate) fn compute_maximal_message_size( bridge_runtime_common::messages::target::maximal_incoming_message_size( maximal_target_extrinsic_size, ); - if maximal_message_size > maximal_source_extrinsic_size { - maximal_source_extrinsic_size - } else { - maximal_message_size - } + std::cmp::min(maximal_message_size, maximal_source_extrinsic_size) } #[cfg(test)] @@ -123,13 +148,21 @@ mod tests { use relay_millau_client::Millau; use relay_rialto_client::Rialto; + fn approximate_message_size(xcm_msg_len: usize) -> usize { + xcm_msg_len + Source::dummy_universal_source().unwrap().encoded_size() + } + #[test] fn encode_explicit_size_message_works() { let msg = encode_message::(&Message::Sized { size: ExplicitOrMaximal::Explicit(100), }) .unwrap(); - assert_eq!(msg.len(), 100); + // since it isn't the returned XCM what is sent over the wire, we can only check if + // it is close to what we need + assert!( + (1f64 - (approximate_message_size::(msg.len()) as f64) / 100_f64).abs() < 0.1 + ); // check that it decodes to valid xcm let _ = decode_xcm::<()>(msg).unwrap(); } @@ -144,7 +177,12 @@ mod tests { let msg = encode_message::(&Message::Sized { size: ExplicitOrMaximal::Maximal }) .unwrap(); - assert_eq!(msg.len(), maximal_size as usize); + // since it isn't the returned XCM what is sent over the wire, we can only check if + // it is close to what we need + assert!( + (1f64 - approximate_message_size::(msg.len()) as f64 / maximal_size as f64) + .abs() < 0.1 + ); // check that it decodes to valid xcm let _ = decode_xcm::<()>(msg).unwrap(); } diff --git a/relays/client-bridge-hub-kusama/Cargo.toml b/relays/client-bridge-hub-kusama/Cargo.toml index 96650710f67..f6e2c853a10 100644 --- a/relays/client-bridge-hub-kusama/Cargo.toml +++ b/relays/client-bridge-hub-kusama/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } relay-substrate-client = { path = "../client-substrate" } # Bridge dependencies diff --git a/relays/client-bridge-hub-polkadot/Cargo.toml b/relays/client-bridge-hub-polkadot/Cargo.toml index 6126a8f2b3f..2b3ec0b6bad 100644 --- a/relays/client-bridge-hub-polkadot/Cargo.toml +++ b/relays/client-bridge-hub-polkadot/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } relay-substrate-client = { path = "../client-substrate" } # Bridge dependencies diff --git a/relays/client-bridge-hub-rococo/Cargo.toml b/relays/client-bridge-hub-rococo/Cargo.toml index 48df2e56cf0..5826a1321bc 100644 --- a/relays/client-bridge-hub-rococo/Cargo.toml +++ b/relays/client-bridge-hub-rococo/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } relay-substrate-client = { path = "../client-substrate" } # Bridge dependencies diff --git a/relays/client-bridge-hub-wococo/Cargo.toml b/relays/client-bridge-hub-wococo/Cargo.toml index d4578fcd488..72a25b001e5 100644 --- a/relays/client-bridge-hub-wococo/Cargo.toml +++ b/relays/client-bridge-hub-wococo/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } relay-substrate-client = { path = "../client-substrate" } # Bridge dependencies diff --git a/relays/client-rialto-parachain/Cargo.toml b/relays/client-rialto-parachain/Cargo.toml index b6d5c423336..789e0622cfc 100644 --- a/relays/client-rialto-parachain/Cargo.toml +++ b/relays/client-rialto-parachain/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5" } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } subxt = { version = "0.28.0", default-features = false, features = [] } # Bridge dependencies diff --git a/relays/client-substrate/Cargo.toml b/relays/client-substrate/Cargo.toml index 90904ab9be1..3dfeb9decbd 100644 --- a/relays/client-substrate/Cargo.toml +++ b/relays/client-substrate/Cargo.toml @@ -14,8 +14,8 @@ jsonrpsee = { version = "0.17", features = ["macros", "ws-client"] } log = "0.4.17" num-traits = "0.2" rand = "0.8" -scale-info = { version = "2.5.0", features = ["derive"] } -tokio = { version = "1.27", features = ["rt-multi-thread"] } +scale-info = { version = "2.6.0", features = ["derive"] } +tokio = { version = "1.28", features = ["rt-multi-thread"] } thiserror = "1.0.40" # Bridge dependencies diff --git a/relays/utils/Cargo.toml b/relays/utils/Cargo.toml index aa14e2ae2e3..78b7fd8fe97 100644 --- a/relays/utils/Cargo.toml +++ b/relays/utils/Cargo.toml @@ -20,7 +20,7 @@ num-traits = "0.2" serde_json = "1.0" sysinfo = "0.28" time = { version = "0.3", features = ["formatting", "local-offset", "std"] } -tokio = { version = "1.27", features = ["rt"] } +tokio = { version = "1.28", features = ["rt"] } thiserror = "1.0.40" # Bridge dependencies diff --git a/scripts/update-weights.sh b/scripts/update-weights.sh index 84ddf0cdaae..b5808042f48 100755 --- a/scripts/update-weights.sh +++ b/scripts/update-weights.sh @@ -6,17 +6,19 @@ set -eux +# default (test) weights that we'll bundle with our pallets + time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \ --chain=dev \ --steps=50 \ --repeat=20 \ - --pallet=RialtoMessages \ + --pallet=pallet_bridge_messages \ --extrinsic=* \ --execution=wasm \ --wasm-execution=Compiled \ --heap-pages=4096 \ --output=./modules/messages/src/weights.rs \ - --template=./.maintain/millau-weight-template.hbs + --template=./.maintain/bridge-weight-template.hbs time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \ --chain=dev \ @@ -28,7 +30,7 @@ time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- --wasm-execution=Compiled \ --heap-pages=4096 \ --output=./modules/grandpa/src/weights.rs \ - --template=./.maintain/millau-weight-template.hbs + --template=./.maintain/bridge-weight-template.hbs time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \ --chain=dev \ @@ -40,7 +42,7 @@ time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- --wasm-execution=Compiled \ --heap-pages=4096 \ --output=./modules/parachains/src/weights.rs \ - --template=./.maintain/millau-weight-template.hbs + --template=./.maintain/bridge-weight-template.hbs time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \ --chain=dev \ @@ -52,4 +54,19 @@ time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- --wasm-execution=Compiled \ --heap-pages=4096 \ --output=./modules/relayers/src/weights.rs \ - --template=./.maintain/millau-weight-template.hbs + --template=./.maintain/bridge-weight-template.hbs + +# weights for Millau runtime. We want to provide runtime weight overhead for messages calls, +# so we can't use "default" test weights directly - they'll be rejected by our integration tests. + +time cargo run --release -p millau-bridge-node --features=runtime-benchmarks -- benchmark pallet \ + --chain=dev \ + --steps=50 \ + --repeat=20 \ + --pallet=pallet_bridge_messages \ + --extrinsic=* \ + --execution=wasm \ + --wasm-execution=Compiled \ + --heap-pages=4096 \ + --output=./bin/millau/runtime/src/weights/ + diff --git a/tools/runtime-codegen/Cargo.lock b/tools/runtime-codegen/Cargo.lock index 8b103a9b944..f4c31636572 100644 --- a/tools/runtime-codegen/Cargo.lock +++ b/tools/runtime-codegen/Cargo.lock @@ -516,18 +516,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7379abaacee0f14abf3204a7606118f0465785252169d186337bcb75030815a" +checksum = "2bc42ba2e232e5b20ff7dc299a812d53337dadce9a7e39a238e6a5cb82d2e57b" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b" +checksum = "253531aca9b6f56103c9420369db3263e784df39aa1c90685a1f69cfbba0623e" dependencies = [ "arrayvec 0.7.2", "bumpalo", @@ -546,33 +546,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bbb67da91ec721ed57cef2f7c5ef7728e1cd9bde9ffd3ef8601022e73e3239" +checksum = "72f2154365e2bff1b1b8537a7181591fdff50d8e27fa6e40d5c69c3bad0ca7c8" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418ecb2f36032f6665dc1a5e2060a143dbab41d83b784882e97710e890a7a16d" +checksum = "687e14e3f5775248930e0d5a84195abef8b829958e9794bf8d525104993612b4" [[package]] name = "cranelift-entity" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705" +checksum = "f42ea692c7b450ad18b8c9889661505d51c09ec4380cf1c2d278dbb2da22cae1" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b66bf9e916f57fbbd0f7703ec6286f4624866bf45000111627c70d272c8dda1" +checksum = "8483c2db6f45fe9ace984e5adc5d058102227e4c62e5aa2054e16b0275fd3a6e" dependencies = [ "cranelift-codegen", "log", @@ -582,15 +582,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649782a39ce99798dd6b4029e2bb318a2fbeaade1b4fa25330763c10c65bc358" +checksum = "e9793158837678902446c411741d87b43f57dadfb944f2440db4287cda8cbd59" [[package]] name = "cranelift-native" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "937e021e089c51f9749d09e7ad1c4f255c2f8686cb8c3df63a34b3ec9921bc41" +checksum = "72668c7755f2b880665cb422c8ad2d56db58a88b9bebfef0b73edc2277c13c49" dependencies = [ "cranelift-codegen", "libc", @@ -599,9 +599,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d850cf6775477747c9dfda9ae23355dd70512ffebc70cf82b85a5b111ae668b5" +checksum = "3852ce4b088b44ac4e29459573943009a70d1b192c8d77ef949b4e814f656fc1" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -3989,7 +3989,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.6", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] @@ -4256,9 +4256,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e89f9819523447330ffd70367ef4a18d8c832e24e8150fe054d1d912841632" +checksum = "76a222f5fa1e14b2cefc286f1b68494d7a965f4bf57ec04c59bb62673d639af6" dependencies = [ "anyhow", "bincode", @@ -4284,18 +4284,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd3a5e46c198032da934469f3a6e48649d1f9142438e4fd4617b68a35644b8a" +checksum = "4407a7246e7d2f3d8fb1cf0c72fda8dbafdb6dd34d555ae8bea0e5ae031089cc" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b389ae9b678b9c3851091a4804f4182d688d27aff7abc9aa37fa7be37d8ecffa" +checksum = "5ceb3adf61d654be0be67fffdce42447b0880481348785be5fe40b5dd7663a4c" dependencies = [ "anyhow", "base64 0.13.1", @@ -4313,9 +4313,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b2c92a08c0db6efffd88fdc97d7aa9c7c63b03edb0971dbca745469f820e8c" +checksum = "3c366bb8647e01fd08cb5589976284b00abfded5529b33d7e7f3f086c68304a4" dependencies = [ "anyhow", "cranelift-codegen", @@ -4334,9 +4334,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" +checksum = "47b8b50962eae38ee319f7b24900b7cf371f03eebdc17400c1dc8575fc10c9a7" dependencies = [ "anyhow", "cranelift-entity", @@ -4353,9 +4353,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" +checksum = "ffaed4f9a234ba5225d8e64eac7b4a5d13b994aeb37353cde2cbeb3febda9eaa" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -4377,9 +4377,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0245e8a9347017c7185a72e215218a802ff561545c242953c11ba00fccc930f" +checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" dependencies = [ "object 0.29.0", "once_cell", @@ -4388,9 +4388,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67d412e9340ab1c83867051d8d1d7c90aa8c9afc91da086088068e2734e25064" +checksum = "43a28ae1e648461bfdbb79db3efdaee1bca5b940872e4175390f465593a2e54c" dependencies = [ "cfg-if", "libc", @@ -4399,9 +4399,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d594e791b5fdd4dbaf8cf7ae62f2e4ff85018ce90f483ca6f42947688e48827d" +checksum = "e704b126e4252788ccfc3526d4d4511d4b23c521bf123e447ac726c14545217b" dependencies = [ "anyhow", "cc", @@ -4423,9 +4423,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6688d6f96d4dbc1f89fab626c56c1778936d122b5f4ae7a57c2eb42b8d982e2" +checksum = "83e5572c5727c1ee7e8f28717aaa8400e4d22dcbd714ea5457d85b5005206568" dependencies = [ "cranelift-entity", "serde",