node-bench no-op block import (#5869)

* start to try and implement noop

* txs as input

* better comment

* Add transfer reaping

* rename to avoid filter matching

* Update base weights based on results

* fix priority

* fix logic on reaping transfer

* Update bin/node/bench/src/import.rs

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>

* Update bin/node/bench/src/main.rs

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>

* add back size type (in-progress)

* bring back size type with custom

* update comment

* nit

* block type then size

* Use `transfer_keep_alive`

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
Shawn Tabrizi
2020-05-03 15:33:11 +02:00
committed by GitHub
parent 51db82bdb9
commit f37927d37d
6 changed files with 99 additions and 63 deletions
+30 -11
View File
@@ -43,6 +43,7 @@ use node_runtime::{
constants::currency::DOLLARS,
UncheckedExtrinsic,
MinimumPeriod,
SystemCall,
BalancesCall,
AccountId,
Signature,
@@ -129,16 +130,18 @@ impl Clone for BenchDb {
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum BlockType {
/// Bunch of random transfers.
RandomTransfers(usize),
RandomTransfersKeepAlive(usize),
/// Bunch of random transfers that drain all of the source balance.
RandomTransfersReaping(usize),
/// Bunch of "no-op" calls.
Noop(usize),
}
impl BlockType {
/// Number of transactions for this block type.
pub fn transactions(&self) -> usize {
match self {
Self::RandomTransfers(v) | Self::RandomTransfersReaping(v) => *v,
Self::RandomTransfersKeepAlive(v) | Self::RandomTransfersReaping(v) | Self::Noop(v) => *v,
}
}
}
@@ -287,15 +290,31 @@ impl BenchDb {
let signed = self.keyring.sign(
CheckedExtrinsic {
signed: Some((sender, signed_extra(0, node_runtime::ExistentialDeposit::get() + 1))),
function: Call::Balances(
BalancesCall::transfer(
pallet_indices::address::Address::Id(receiver),
match block_type {
BlockType::RandomTransfers(_) => node_runtime::ExistentialDeposit::get() + 1,
BlockType::RandomTransfersReaping(_) => 100*DOLLARS - node_runtime::ExistentialDeposit::get() - 1,
}
)
),
function: match block_type {
BlockType::RandomTransfersKeepAlive(_) => {
Call::Balances(
BalancesCall::transfer_keep_alive(
pallet_indices::address::Address::Id(receiver),
node_runtime::ExistentialDeposit::get() + 1,
)
)
},
BlockType::RandomTransfersReaping(_) => {
Call::Balances(
BalancesCall::transfer(
pallet_indices::address::Address::Id(receiver),
// Transfer so that ending balance would be 1 less than existential deposit
// so that we kill the sender account.
100*DOLLARS - (node_runtime::ExistentialDeposit::get() - 1),
)
)
},
BlockType::Noop(_) => {
Call::System(
SystemCall::remark(Vec::new())
)
},
},
},
version,
genesis_hash,