Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the multi-batching pallet #7

Merged
merged 24 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement review fixes, expiry
niksaak committed Apr 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 66c661c31e7f8766dd0a2b740b5d2141111522a8
4 changes: 2 additions & 2 deletions Cargo.lock

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

11 changes: 4 additions & 7 deletions pallets/multibatching/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-multibatching"
version = "1.0.0-dev"
version = "1.1.0-dev"
description = "Off-line multisignature atomic batching"
authors = ["Mykola Samardak <[email protected]>"]
edition = "2021"
@@ -21,15 +21,14 @@ frame-benchmarking = { workspace = true, default-features = false, optional = tr
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-std = { workspace = true, default-features = false }
sp-core = { workspace = true, default-features = false }
pallet-timestamp = { workspace = true, default-features = false }

# benchmarking dependencies
account = { workspace = true, optional = true }
sp-core = { workspace = true, default-features = false, optional = true }
sp-io = { workspace = true, default-features = false, optional = true }

#hex = { workspace = true, default-features = false } # TODO: for debugging, delete this later

[dev-dependencies]
pallet-balances = { workspace = true, default-features = false }
sp-runtime = { workspace = true, default-features = false }
account = { workspace = true }
sp-core = { workspace = true, default-features = false }
@@ -44,15 +43,13 @@ std = [
"frame-support/std",
"frame-system/std",
"scale-info/std",
"pallet-balances/std",
"sp-std/std",
"account?/std",
"sp-io?/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"account",
"sp-core",
"sp-io",
]
try-runtime = ["frame-support/try-runtime"]
27 changes: 24 additions & 3 deletions pallets/multibatching/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -11,6 +11,15 @@ use sp_io::{
};
use sp_std::vec::Vec;

impl<Moment> BenchmarkHelper<Moment> for ()
where
Moment: From<u64>
{
fn timestamp(value: u64) -> Moment {
value.into()
}
}

fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}
@@ -30,16 +39,18 @@ pub mod benchmarks {
use super::*;
use account::{AccountId20, EthereumSignature, EthereumSigner};
use parity_scale_codec::Encode;

use frame_support::sp_runtime::traits::IdentifyAccount;

use pallet_timestamp::Pallet as Timestamp;

#[benchmark]
fn batch(c: Linear<1, 128>, s: Linear<2, 10>) {
fn batch(c: Linear<1, 128>, s: Linear<1, 10>) {
let call_count = c as usize;
let signer_count = s as usize;

let domain: [u8; 32] = *b".myth.pallet-multibatching.bench";
let bias = [0u8; 32];
let expires_at = Timestamp::<T>::get() + T::BenchmarkHelper::timestamp(100_000);

let sender: AccountId20 = whitelisted_caller();

@@ -65,6 +76,7 @@ pub mod benchmarks {
domain,
sender: sender.into(),
bias,
expires_at,
calls: calls.clone(),
approvals: BoundedVec::new(),
}
@@ -85,12 +97,21 @@ pub mod benchmarks {
.ok()
.expect("Benchmark config must match runtime config for BoundedVec size");
}
approvals.sort_by_key(|a| a.from.clone());

Pallet::<T>::force_set_domain(RawOrigin::Root.into(), domain)
.expect("force_set_domain must succeed");

#[extrinsic_call]
_(RawOrigin::Signed(sender.clone()), domain, sender.clone().into(), bias, calls, approvals);
_(
RawOrigin::Signed(sender.clone()),
domain,
sender.clone().into(),
bias,
expires_at,
calls,
approvals,
);
}

#[benchmark]
Loading