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

External operator slashes info pallet #727

Merged
merged 100 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
5811024
Add pallet_external_validators, remove ValidatorManager
tmpolaczyk Oct 15, 2024
8fa98f0
Rename extrinsics and add tests
tmpolaczyk Oct 17, 2024
86cb5cd
Fix tests
tmpolaczyk Oct 17, 2024
1c36e24
Merge remote-tracking branch 'origin/master' into tomasz-external-val…
tmpolaczyk Oct 17, 2024
57f2949
Fix benchmarks
tmpolaczyk Oct 17, 2024
81381cd
typescript-api
tmpolaczyk Oct 17, 2024
777c053
first version stored
girazoki Oct 17, 2024
b7b4e51
Add traits
tmpolaczyk Oct 18, 2024
b3d8c5b
Merge remote-tracking branch 'origin/master' into tomasz-external-val…
tmpolaczyk Oct 18, 2024
2cacc6f
slowly add stuff
girazoki Oct 21, 2024
abec023
Merge remote-tracking branch 'origin/master' into tomasz-external-val…
tmpolaczyk Oct 21, 2024
06ac945
Some PR comments
tmpolaczyk Oct 21, 2024
6edc6f4
Change era every n sessions
tmpolaczyk Oct 21, 2024
a37ed40
confirmed and unconfirmed, tests
girazoki Oct 21, 2024
c50e037
rename pallet
girazoki Oct 22, 2024
8cb16f1
Merge remote-tracking branch 'origin/master' into girazoki-validator-…
girazoki Oct 22, 2024
71ae9d1
WIP integration test and hooks
tmpolaczyk Oct 22, 2024
5f5c819
Merge remote-tracking branch 'origin/master' into tomasz-external-val…
tmpolaczyk Oct 22, 2024
018c31b
good tests for once
girazoki Oct 22, 2024
61c3fc9
Benchmark new extrinsics
tmpolaczyk Oct 22, 2024
08965a8
Migrate queued keys instead of current validators
tmpolaczyk Oct 22, 2024
bc61273
typescript-api
tmpolaczyk Oct 22, 2024
b6ceaea
Merge remote-tracking branch 'origin/tomasz-external-validators' into…
girazoki Oct 22, 2024
e2fe742
Add era index to hook
tmpolaczyk Oct 22, 2024
99791ec
impl for tuples
tmpolaczyk Oct 22, 2024
7cde793
Make tests pass
tmpolaczyk Oct 22, 2024
5f5a636
Merge remote-tracking branch 'origin/tomasz-external-validators' into…
girazoki Oct 22, 2024
cd86a84
adapt
girazoki Oct 22, 2024
011c349
continue progress
girazoki Oct 22, 2024
f465490
remove comments
girazoki Oct 22, 2024
09cfcec
Add integration tests
tmpolaczyk Oct 23, 2024
d7289a0
fixes but pallet incorporated to runtime
girazoki Oct 23, 2024
e1985a3
added sessionINterface
girazoki Oct 23, 2024
0d53f5b
add offence handler
girazoki Oct 23, 2024
c6cf701
current era and active era
tmpolaczyk Oct 23, 2024
a49f749
typescript-api
tmpolaczyk Oct 23, 2024
4aea0e4
fixes
girazoki Oct 23, 2024
8ea6a16
Merge remote-tracking branch 'origin/tomasz-external-validators' into…
girazoki Oct 23, 2024
b2bcfff
add invulnerables
girazoki Oct 24, 2024
1187bc4
Add one typescript test
tmpolaczyk Oct 24, 2024
af502be
a few more fixes
girazoki Oct 24, 2024
74fc857
more tests
girazoki Oct 24, 2024
9614ac8
console log
tmpolaczyk Oct 24, 2024
ae3de1e
benchmarks
girazoki Oct 24, 2024
cd08e17
benchmarks generated
girazoki Oct 24, 2024
286cbff
a little bit of cleanup
girazoki Oct 25, 2024
f13e3c8
a bit more cleanup
girazoki Oct 25, 2024
d39fd27
zepter
girazoki Oct 25, 2024
1548075
toml-maid
girazoki Oct 25, 2024
adc79c2
Merge remote-tracking branch 'origin/master' into tomasz-external-val…
tmpolaczyk Oct 25, 2024
0b257a5
refactor tests
girazoki Oct 25, 2024
6591098
run_to_block not working
tmpolaczyk Oct 25, 2024
28c8365
a few fixes2
girazoki Oct 25, 2024
3375e5d
Unit tests still not working
tmpolaczyk Oct 28, 2024
40fdf84
Fix unit tests
tmpolaczyk Oct 28, 2024
86f16ec
test babe slashes
girazoki Oct 28, 2024
83d9e5d
slashes tests ts
girazoki Oct 29, 2024
aaadb2c
Start era 0 in session 0
tmpolaczyk Oct 29, 2024
8cd3a41
Merge remote-tracking branch 'origin/master' into tomasz-external-val…
tmpolaczyk Oct 29, 2024
b70b8fc
more slashing tests
girazoki Oct 29, 2024
26b45eb
one more test
girazoki Oct 29, 2024
12646cf
Rewrite pallet logic, copy it from pallet_staking
tmpolaczyk Oct 29, 2024
f7a57e5
Test hook calls
tmpolaczyk Oct 29, 2024
f50bc78
testing finished
girazoki Oct 29, 2024
4f5ef3c
typescript-api
tmpolaczyk Oct 29, 2024
eae263f
Add era session start to trait
tmpolaczyk Oct 29, 2024
eddb050
Merge remote-tracking branch 'origin/tomasz-external-validators' into…
girazoki Oct 29, 2024
b41acd5
test cleanup
girazoki Oct 30, 2024
8955fa3
fmt and typescript api
girazoki Oct 30, 2024
1b2ff17
a few fixes here and there
girazoki Oct 30, 2024
6d7e6b9
change a few things
girazoki Oct 30, 2024
50f8237
pr comments
tmpolaczyk Oct 30, 2024
916efa5
wip
girazoki Oct 30, 2024
485ce85
typescript-api
tmpolaczyk Oct 30, 2024
55cdaaa
Merge remote-tracking branch 'origin/master' into tomasz-external-val…
tmpolaczyk Oct 30, 2024
5cdac08
typescript-api
tmpolaczyk Oct 30, 2024
fdd3cc8
new tests
girazoki Oct 30, 2024
dd0eb78
typescript api
girazoki Oct 30, 2024
65c1f33
try now
girazoki Oct 30, 2024
2b9e475
Test migration
tmpolaczyk Oct 31, 2024
d7571f2
fix last test
girazoki Oct 31, 2024
1b68221
clippy
girazoki Oct 31, 2024
4a04af9
slashes formatting
girazoki Oct 31, 2024
7aaffcc
Merge remote-tracking branch 'origin/tomasz-external-validators' into…
girazoki Oct 31, 2024
ec357a7
ts api
girazoki Oct 31, 2024
efc69f1
api
girazoki Oct 31, 2024
7d28482
Merge remote-tracking branch 'origin/tomasz-external-validators' into…
girazoki Oct 31, 2024
415151d
fix clippy
girazoki Oct 31, 2024
6a6b2f2
Merge remote-tracking branch 'origin/master' into girazoki-validator-…
girazoki Nov 4, 2024
0d169a5
typescript api new
girazoki Nov 4, 2024
c56ac45
wip
girazoki Nov 4, 2024
c83087f
fmt
girazoki Nov 4, 2024
86d0a13
first pr review fixes
girazoki Nov 4, 2024
ed0c169
more pr feedback
girazoki Nov 4, 2024
6f8b593
more fmt and pr fixes
girazoki Nov 4, 2024
ddc30d8
remove weight
girazoki Nov 4, 2024
9c1ab40
add doc
girazoki Nov 4, 2024
5a151f0
Merge branch 'master' into girazoki-validator-era-info-pallet
girazoki Nov 4, 2024
ca32055
add correct typescript api
girazoki Nov 4, 2024
616e5d3
Merge branch 'master' into girazoki-validator-era-info-pallet
girazoki Nov 5, 2024
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
22 changes: 22 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pallet-collator-assignment-runtime-api = { path = "pallets/collator-assignment/r
pallet-configuration = { path = "pallets/configuration", default-features = false }
pallet-data-preservers = { path = "pallets/data-preservers", default-features = false }
pallet-data-preservers-runtime-api = { path = "pallets/data-preservers/runtime-api", default-features = false }
pallet-external-validator-slashes = { path = "pallets/external-validator-slashes", default-features = false }
pallet-external-validators = { path = "pallets/external-validators", default-features = false }
pallet-inflation-rewards = { path = "pallets/inflation-rewards", default-features = false }
pallet-initializer = { path = "pallets/initializer", default-features = false }
Expand Down Expand Up @@ -325,6 +326,7 @@ fc-storage = { git = "https://github.com/moondance-labs/frontier", branch = "tan

# General (wasm)
bounded-collections = { version = "0.1.8", default-features = false }
finality-grandpa = { version = "0.16.2", default-features = false }
hex-literal = { version = "0.3.4" }
impl-trait-for-tuples = "0.2.2"
impls = "1.0.3"
Expand Down
68 changes: 68 additions & 0 deletions pallets/external-validator-slashes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[package]
name = "pallet-external-validator-slashes"
authors = { workspace = true }
description = "External validator info slashes"
edition = "2021"
license = "GPL-3.0-only"
version = "0.1.0"

[package.metadata.docs.rs]
targets = [ "x86_64-unknown-linux-gnu" ]

[lints]
workspace = true

[dependencies]
frame-benchmarking = { workspace = true, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
pallet-session = { workspace = true }
pallet-staking = { workspace = true }
parity-scale-codec = { workspace = true, features = [ "derive", "max-encoded-len" ] }
scale-info = { workspace = true }
sp-runtime = { workspace = true }
sp-staking = { workspace = true }
sp-std = { workspace = true }
tp-traits = { workspace = true }

[dev-dependencies]
sp-core = { workspace = true }
sp-io = { workspace = true }

[features]
default = [ "std" ]
std = [
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-session/std",
"pallet-staking/std",
"parity-scale-codec/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
"tp-traits/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"scale-info/std",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
"tp-traits/runtime-benchmarks",
]

try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-session/try-runtime",
"pallet-staking/try-runtime",
"sp-runtime/try-runtime",
]
95 changes: 95 additions & 0 deletions pallets/external-validator-slashes/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright (C) Moondance Labs Ltd.
// This file is part of Tanssi.

// Tanssi 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.

// Tanssi 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 Tanssi. If not, see <http://www.gnu.org/licenses/>

//! Benchmarking setup for pallet-external-validator-slashes

use super::*;

#[allow(unused)]
use crate::Pallet as ExternalValidatorSlashes;
use {
frame_benchmarking::{v2::*, BenchmarkError},
frame_system::RawOrigin,
pallet_session::{self as session},
sp_runtime::traits::TrailingZeroInput,
sp_std::prelude::*,
};

const MAX_SLASHES: u32 = 1000;

#[allow(clippy::multiple_bound_locations)]
#[benchmarks(where T: session::Config)]
mod benchmarks {
use super::*;

#[benchmark]
fn cancel_deferred_slash(s: Linear<1, MAX_SLASHES>) -> Result<(), BenchmarkError> {
let mut existing_slashes = Vec::new();
let era = T::EraIndexProvider::active_era().index;
let dummy = || T::AccountId::decode(&mut TrailingZeroInput::zeroes()).unwrap();
for _ in 0..MAX_SLASHES {
existing_slashes.push(Slash::<T::AccountId, T::SlashId>::default_from(dummy()));
}
Slashes::<T>::insert(
era.saturating_add(T::SlashDeferDuration::get())
.saturating_add(One::one()),
&existing_slashes,
);
let slash_indices: Vec<u32> = (0..s).collect();

#[extrinsic_call]
_(
RawOrigin::Root,
era.saturating_add(T::SlashDeferDuration::get())
.saturating_add(One::one()),
slash_indices,
);

assert_eq!(
Slashes::<T>::get(
&era.saturating_add(T::SlashDeferDuration::get())
.saturating_add(One::one())
)
.len(),
(MAX_SLASHES - s) as usize
);
Ok(())
}

#[benchmark]
fn force_inject_slash() -> Result<(), BenchmarkError> {
let era = T::EraIndexProvider::active_era().index;
let dummy = || T::AccountId::decode(&mut TrailingZeroInput::zeroes()).unwrap();
#[extrinsic_call]
_(RawOrigin::Root, era, dummy(), Perbill::from_percent(50));

assert_eq!(
Slashes::<T>::get(
&era.saturating_add(T::SlashDeferDuration::get())
.saturating_add(One::one())
)
.len(),
1_usize
);
Ok(())
}

impl_benchmark_test_suite!(
ExternalValidatorSlashes,
crate::mock::new_test_ext(),
crate::mock::Test,
);
}
Loading
Loading