Skip to content

Commit c76e065

Browse files
NODE-80 branch restructure (#127)
* NODE-179, feat: init pallet storages * NODE-179, feat: init pallet extrinsics * NODE-179, chore: add locktime * NODE-179, feat: finalize fee rate * NODE-179, feature: impl coin selections * NODE-179, feat: check blaze activation state * NODE-179, feature: impl `remove_outbound_messages` for legacy mode * NODE-80: implement benchmarking (#121) * NODE-80, feature: impl benchmarking.rs & mock.rs * NODE-80, fix: benchmark * NODE-80, fix: benchmark * NODE-80, chore: update weights * fix: zero out proof size in weights * chore: resolve --------- Co-authored-by: dnjscksdn98 <[email protected]>
1 parent ddd9497 commit c76e065

File tree

46 files changed

+3500
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3500
-315
lines changed

Cargo.lock

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/common/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sc-service = { workspace = true }
2626
substrate-prometheus-endpoint = { workspace = true }
2727

2828
# benchmarking dependencies
29-
frame-benchmarking = { workspace = true, features = ["std"] }
29+
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }
3030

3131
# substrate primitives dependencies
3232
sp-core = { workspace = true, features = ["std"] }
@@ -55,4 +55,4 @@ bp-core = { workspace = true }
5555

5656
[features]
5757
default = []
58-
runtime-benchmarks = []
58+
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]

node/core/Cargo.toml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,17 @@ sc-service = { workspace = true }
2828
sc-consensus-grandpa = { workspace = true }
2929

3030
# benchmarking dependencies
31-
frame-benchmarking = { workspace = true, features = ["std"] }
3231
frame-benchmarking-cli = { workspace = true }
3332

3433
# Bifrost runtimes
3534
bifrost-dev-runtime = { workspace = true, features = ["std", "evm-tracing"] }
3635
bifrost-testnet-runtime = { workspace = true, features = [
37-
"std",
38-
"evm-tracing",
36+
"std",
37+
"evm-tracing",
3938
] }
4039
bifrost-mainnet-runtime = { workspace = true, features = [
41-
"std",
42-
"evm-tracing",
40+
"std",
41+
"evm-tracing",
4342
] }
4443

4544
# Bifrost node specs
@@ -53,4 +52,12 @@ substrate-build-script-utils = { workspace = true }
5352

5453
[features]
5554
default = []
56-
runtime-benchmarks = []
55+
runtime-benchmarks = [
56+
"bifrost-dev-runtime/runtime-benchmarks",
57+
"bifrost-testnet-runtime/runtime-benchmarks",
58+
"bifrost-mainnet-runtime/runtime-benchmarks",
59+
"bifrost-dev-node/runtime-benchmarks",
60+
"bifrost-testnet-node/runtime-benchmarks",
61+
"bifrost-mainnet-node/runtime-benchmarks",
62+
"sc-service/runtime-benchmarks",
63+
]

node/core/src/command.rs

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use crate::cli::{Cli, Subcommand};
22

3-
use bifrost_common_node::cli_opt::{BackendType, BackendTypeConfig, RpcConfig};
3+
use bifrost_common_node::{
4+
cli_opt::{BackendType, BackendTypeConfig, RpcConfig},
5+
service::HostFunctions,
6+
};
47

58
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
69

@@ -294,9 +297,9 @@ pub fn run() -> sc_cli::Result<()> {
294297
);
295298
}
296299

297-
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, ()>(Some(
298-
config.chain_spec,
299-
))
300+
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, HostFunctions>(
301+
Some(config.chain_spec),
302+
)
300303
},
301304
BenchmarkCmd::Block(cmd) => {
302305
let PartialComponents { client, .. } =
@@ -310,12 +313,32 @@ pub fn run() -> sc_cli::Result<()> {
310313
),
311314
#[cfg(feature = "runtime-benchmarks")]
312315
BenchmarkCmd::Storage(cmd) => {
313-
let PartialComponents { client, backend, .. } =
314-
service::new_partial(&config)?;
315-
let db = backend.expose_db();
316-
let storage = backend.expose_storage();
316+
let chain_spec = &config.chain_spec;
317317

318-
cmd.run(config, client, db, storage)
318+
match chain_spec {
319+
_spec if chain_spec.is_dev() => {
320+
use bifrost_dev_node::service;
321+
let params = service::new_partial(&config, &rpc_config)?;
322+
let db = params.backend.expose_db();
323+
let storage = params.backend.expose_storage();
324+
cmd.run(config, params.client, db, storage)
325+
},
326+
_spec if chain_spec.is_mainnet() => {
327+
use bifrost_mainnet_node::service;
328+
let params = service::new_partial(&config, &rpc_config)?;
329+
let db = params.backend.expose_db();
330+
let storage = params.backend.expose_storage();
331+
cmd.run(config, params.client, db, storage)
332+
},
333+
_spec if chain_spec.is_testnet() => {
334+
use bifrost_testnet_node::service;
335+
let params = service::new_partial(&config, &rpc_config)?;
336+
let db = params.backend.expose_db();
337+
let storage = params.backend.expose_storage();
338+
cmd.run(config, params.client, db, storage)
339+
},
340+
_ => panic!("Invalid chain spec"),
341+
}
319342
},
320343
BenchmarkCmd::Machine(cmd) => {
321344
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())

node/dev/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pallet-ethereum = { workspace = true, features = [
7070
] }
7171

7272
# benchmarking dependencies
73-
frame-benchmarking = { workspace = true, features = ["std"] }
73+
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }
7474

7575
# Local Dependencies
7676
bp-core = { workspace = true }
@@ -80,4 +80,7 @@ bifrost-common-node = { workspace = true }
8080

8181
[features]
8282
default = []
83-
runtime-benchmarks = ["bifrost-dev-runtime/runtime-benchmarks"]
83+
runtime-benchmarks = [
84+
"bifrost-dev-runtime/runtime-benchmarks",
85+
"frame-benchmarking/runtime-benchmarks",
86+
]

node/mainnet/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pallet-ethereum = { workspace = true, features = [
6969
] }
7070

7171
# benchmarking dependencies
72-
frame-benchmarking = { workspace = true, features = ["std"] }
72+
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }
7373

7474
# Local Dependencies
7575
bp-core = { workspace = true }
@@ -82,4 +82,7 @@ bifrost-common-node = { workspace = true }
8282

8383
[features]
8484
default = []
85-
runtime-benchmarks = ["bifrost-mainnet-runtime/runtime-benchmarks"]
85+
runtime-benchmarks = [
86+
"bifrost-mainnet-runtime/runtime-benchmarks",
87+
"frame-benchmarking/runtime-benchmarks",
88+
]

node/testnet/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pallet-ethereum = { workspace = true, features = [
6969
] }
7070

7171
# benchmarking dependencies
72-
frame-benchmarking = { workspace = true, features = ["std"] }
72+
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }
7373

7474
# Local Dependencies
7575
bp-core = { workspace = true }
@@ -82,4 +82,7 @@ bifrost-common-node = { workspace = true }
8282

8383
[features]
8484
default = []
85-
runtime-benchmarks = ["bifrost-testnet-runtime/runtime-benchmarks"]
85+
runtime-benchmarks = [
86+
"bifrost-testnet-runtime/runtime-benchmarks",
87+
"frame-benchmarking/runtime-benchmarks",
88+
]

pallets/bfc-offences/src/pallet/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub mod pallet {
146146
impl<T: Config> Pallet<T> {
147147
#[pallet::call_index(0)]
148148
#[pallet::weight(
149-
<T as Config>::WeightInfo::set_offence_expiration()
149+
(<T as Config>::WeightInfo::set_offence_expiration(), DispatchClass::Operational,)
150150
)]
151151
/// Set a new offence expiration for all validators. It must be specified in sessions.
152152
pub fn set_offence_expiration(
@@ -164,7 +164,7 @@ pub mod pallet {
164164

165165
#[pallet::call_index(1)]
166166
#[pallet::weight(
167-
<T as Config>::WeightInfo::set_max_offence_count()
167+
(<T as Config>::WeightInfo::set_max_offence_count(), DispatchClass::Operational,)
168168
)]
169169
/// Set a new maximum offence count for all validators.
170170
pub fn set_max_offence_count(
@@ -213,7 +213,7 @@ pub mod pallet {
213213

214214
#[pallet::call_index(2)]
215215
#[pallet::weight(
216-
<T as Config>::WeightInfo::set_offence_activation()
216+
(<T as Config>::WeightInfo::set_offence_activation(), DispatchClass::Operational,)
217217
)]
218218
/// Set the activation of validator offence management.
219219
pub fn set_offence_activation(
@@ -229,7 +229,7 @@ pub mod pallet {
229229

230230
#[pallet::call_index(3)]
231231
#[pallet::weight(
232-
<T as Config>::WeightInfo::set_slash_activation()
232+
(<T as Config>::WeightInfo::set_slash_activation(), DispatchClass::Operational,)
233233
)]
234234
/// Set the activation of validator slashing.
235235
pub fn set_slash_activation(

pallets/bfc-offences/src/weights.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,31 @@ pub trait WeightInfo {
1919
pub struct SubstrateWeight<T>(PhantomData<T>);
2020
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
2121
fn set_offence_expiration() -> Weight {
22-
Weight::from_parts(18_178_000, 0)
23-
.saturating_add(T::DbWeight::get().reads(6 as u64))
24-
.saturating_add(T::DbWeight::get().writes(4 as u64))
22+
T::DbWeight::get().reads(1).saturating_add(T::DbWeight::get().writes(1))
2523
}
2624
fn set_max_offence_count() -> Weight {
27-
Weight::from_parts(18_178_000, 0)
28-
.saturating_add(T::DbWeight::get().reads(6 as u64))
29-
.saturating_add(T::DbWeight::get().writes(4 as u64))
25+
T::DbWeight::get().reads(1).saturating_add(T::DbWeight::get().writes(1))
3026
}
3127
fn set_offence_activation() -> Weight {
32-
Weight::from_parts(18_178_000, 0)
33-
.saturating_add(T::DbWeight::get().reads(6 as u64))
34-
.saturating_add(T::DbWeight::get().writes(4 as u64))
28+
T::DbWeight::get().reads(1).saturating_add(T::DbWeight::get().writes(1))
3529
}
3630
fn set_slash_activation() -> Weight {
37-
Weight::from_parts(18_178_000, 0)
38-
.saturating_add(T::DbWeight::get().reads(6 as u64))
39-
.saturating_add(T::DbWeight::get().writes(4 as u64))
31+
T::DbWeight::get().reads(1).saturating_add(T::DbWeight::get().writes(1))
4032
}
4133
}
4234

4335
// For backwards compatibility and tests
4436
impl WeightInfo for () {
4537
fn set_offence_expiration() -> Weight {
46-
Weight::from_parts(18_178_000, 0)
47-
.saturating_add(RocksDbWeight::get().reads(6 as u64))
48-
.saturating_add(RocksDbWeight::get().writes(4 as u64))
38+
RocksDbWeight::get().reads(1).saturating_add(RocksDbWeight::get().writes(1))
4939
}
5040
fn set_max_offence_count() -> Weight {
51-
Weight::from_parts(18_178_000, 0)
52-
.saturating_add(RocksDbWeight::get().reads(6 as u64))
53-
.saturating_add(RocksDbWeight::get().writes(4 as u64))
41+
RocksDbWeight::get().reads(1).saturating_add(RocksDbWeight::get().writes(1))
5442
}
5543
fn set_offence_activation() -> Weight {
56-
Weight::from_parts(18_178_000, 0)
57-
.saturating_add(RocksDbWeight::get().reads(6 as u64))
58-
.saturating_add(RocksDbWeight::get().writes(4 as u64))
44+
RocksDbWeight::get().reads(1).saturating_add(RocksDbWeight::get().writes(1))
5945
}
6046
fn set_slash_activation() -> Weight {
61-
Weight::from_parts(18_178_000, 0)
62-
.saturating_add(RocksDbWeight::get().reads(6 as u64))
63-
.saturating_add(RocksDbWeight::get().writes(4 as u64))
47+
RocksDbWeight::get().reads(1).saturating_add(RocksDbWeight::get().writes(1))
6448
}
6549
}

pallets/bfc-utility/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ sp-std = { workspace = true }
2323
[features]
2424
default = ["std"]
2525
std = [
26-
"impl-serde/std",
27-
"scale-info/std",
28-
"parity-scale-codec/std",
29-
"frame-support/std",
30-
"frame-system/std",
31-
"sp-runtime/std",
32-
"sp-std/std",
26+
"impl-serde/std",
27+
"scale-info/std",
28+
"parity-scale-codec/std",
29+
"frame-support/std",
30+
"frame-system/std",
31+
"sp-runtime/std",
32+
"sp-std/std",
3333
]
3434
try-runtime = ["frame-support/try-runtime"]

0 commit comments

Comments
 (0)