Skip to content

Commit

Permalink
Merge branch 'master' into aleks-container-chains-disabled-offchain-w…
Browse files Browse the repository at this point in the history
…orkers-check
  • Loading branch information
chexware authored Nov 6, 2024
2 parents 401e514 + 15fa648 commit e1645da
Show file tree
Hide file tree
Showing 31 changed files with 3,724 additions and 846 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/e2e-test-bridge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Bridge e2e test

on:
workflow_run:
workflows: [CI]
branches: [master]
types: [completed]

jobs:
e2e-bridge-test:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check g++
id: setup_g_plusplus
run: |
g++ --version
- name: Check protoc
id: check_proto_c
run: |
protoc --version
- name: Check jq
id: check_jq
run: |
jq --version
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '^1.22.0'
- name: Check go
id: check_go
run: |
go version
- name: Run Mage
uses: magefile/mage-action@v3
with:
install-only: true
- name: Check mage
id: check_mage
run: |
mage --version
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Check forge
id: check_forge
run: |
forge --version
- name: Pnpm
uses: pnpm/[email protected]
with:
version: 9
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Install yarn
run: |-
curl -fsSL --create-dirs -o $HOME/bin/yarn \
https://github.com/yarnpkg/yarn/releases/download/v1.22.22/yarn-1.22.22.js
chmod +x $HOME/bin/yarn
echo "$HOME/bin" >> $GITHUB_PATH
- name: Check yarn
id: check_yarn
run: |
yarn --version
- name: Check date
id: check_date
run: |
date --version
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 @@ -326,6 +327,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

0 comments on commit e1645da

Please sign in to comment.