This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hyperdrive outgoing * set weights from mix of calculation and benchmarking * address reviews * docs
- Loading branch information
Showing
19 changed files
with
2,391 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
[package] | ||
name = "pallet-acurast-hyperdrive-mmr" | ||
authors = ["Papers AG", "Parity Technologies <admin@parity.io>"] | ||
description = "Acurast Hyperdrive is a building block allowing for general bidirectional message passing" | ||
version = "0.0.1" | ||
license = "MIT" | ||
homepage = "https://docs.acurast.com/" | ||
edition = "2021" | ||
publish = false | ||
repository = "https://github.com/acurast/acurast-core" | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] | ||
|
||
[dependencies] | ||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ | ||
"derive", | ||
] } | ||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } | ||
|
||
# Acurast | ||
pallet-acurast = { path = "../acurast", default-features = false } | ||
pallet-acurast-marketplace = { path = "../marketplace", default-features = false} | ||
acurast-common = { path = "../acurast/common", default-features = false } | ||
mmr-lib = { package = "ckb-merkle-mountain-range", version = "0.5.2", default-features = false } | ||
|
||
# SDKs | ||
tezos-core = { git = "https://github.com/airgap-it/tezos-rust-sdk", default-features = false, branch = "feat/nostd" } | ||
tezos-michelson = { git = "https://github.com/airgap-it/tezos-rust-sdk", default-features = false, branch = "feat/nostd" } | ||
derive_more = { version = "0.99.17", default-features = false } | ||
strum = { version = "0.24.1", default-features = false } | ||
strum_macros = { version = "0.24.1", default-features = false } | ||
once_cell = { version = "1.17.1", default-features = false } | ||
|
||
# Benchmarks | ||
hex-literal = { version = "0.3", optional = true } | ||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true, default-features = false } | ||
|
||
# Substrate | ||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } | ||
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } | ||
scale-info = { version = "2.2.0", default-features = false, features = [ | ||
"derive", | ||
] } | ||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } | ||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } | ||
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } | ||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } | ||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } | ||
|
||
|
||
serde = { version = "1.0.136", features = ["derive"], optional = true } | ||
thiserror = "1.0" | ||
log = { version = "0.4.17", default-features = false } | ||
|
||
[dev-dependencies] | ||
hex-literal = "0.3" | ||
|
||
array-bytes = "4.1" | ||
env_logger = "0.9" | ||
itertools = "0.10.3" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"codec/std", | ||
"frame-benchmarking/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"acurast-common/std", | ||
"pallet-acurast/std", | ||
"pallet-acurast-marketplace/std", | ||
"scale-info/std", | ||
"sp-core/std", | ||
"sp-io/std", | ||
"sp-api/std", | ||
"sp-runtime/std", | ||
"sp-std/std", | ||
"strum/std", | ||
"tezos-core/std", | ||
"tezos-michelson/std", | ||
"mmr-lib/std", | ||
"serde", | ||
"log/std", | ||
] | ||
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] | ||
try-runtime = ["frame-support/try-runtime"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Benchmarks for the MMR pallet. | ||
#![cfg(feature = "runtime-benchmarks")] | ||
|
||
use frame_benchmarking::benchmarks_instance_pallet; | ||
|
||
use crate::stub::action; | ||
use crate::*; | ||
|
||
benchmarks_instance_pallet! { | ||
send_message { | ||
let x in 1 .. 1_000; | ||
|
||
let leaves = x as NodeIndex; | ||
for i in 0..leaves { | ||
_ = Pallet::<T, I>::send_message(action(i as u128)); | ||
} | ||
}: { | ||
// insert last leave as the benchmarked one | ||
_ = Pallet::<T, I>::send_message(action(leaves as u128)); | ||
} verify { | ||
assert_eq!(crate::NumberOfLeaves::<T, I>::get(), leaves+1); | ||
} | ||
|
||
impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::mock::Test); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Default weights for the MMR Pallet | ||
//! This file was not auto-generated. | ||
use crate::NodeIndex; | ||
use frame_support::weights::{ | ||
constants::{RocksDbWeight as DbWeight, WEIGHT_REF_TIME_PER_NANOS}, | ||
Weight, | ||
}; | ||
|
||
pub trait WeightInfo { | ||
fn check_snapshot() -> Weight { | ||
let maximum_blocks_before_snapshot_reached = DbWeight::get().reads(1); | ||
maximum_blocks_before_snapshot_reached | ||
} | ||
fn create_snapshot() -> Weight { | ||
// maximum_blocks_before_snapshot_reached | ||
let check_weight = Self::check_snapshot(); | ||
let message_numbers = DbWeight::get().reads_writes(1, 1); | ||
let next_snapshot_number = DbWeight::get().reads_writes(1, 1); | ||
let snapshot_root_hash = DbWeight::get().writes(1); | ||
let snapshot_meta = DbWeight::get().reads_writes(1, 1); | ||
check_weight | ||
.saturating_add(message_numbers) | ||
.saturating_add(next_snapshot_number) | ||
.saturating_add(snapshot_root_hash) | ||
.saturating_add(snapshot_meta) | ||
} | ||
fn send_message() -> Weight; | ||
fn send_message_actual_weight(peaks: NodeIndex) -> Weight { | ||
// Reading the parent hash. | ||
let leaf_weight = DbWeight::get().reads(1); | ||
// Blake2 hash cost. | ||
let hash_weight = Weight::from_ref_time(2u64 * WEIGHT_REF_TIME_PER_NANOS); | ||
// No-op hook. | ||
let hook_weight = Weight::zero(); | ||
|
||
leaf_weight | ||
.saturating_add(hash_weight) | ||
.saturating_add(hook_weight) | ||
.saturating_add(DbWeight::get().reads_writes(2 + peaks, 2 + peaks)) | ||
} | ||
} |
Oops, something went wrong.