Relayer rewards improvements (#624)

* Document relayers fund existence and add root account.

* Introduce initialize method instead of assuming that relayer_fund_account is always required.

* cargo fmt --all

* Fix benchmarks.

* cargo fmt --all

* Fix docs for the relayer fund account.
This commit is contained in:
Tomasz Drwięga
2021-01-06 18:15:41 +01:00
committed by Bastian Köcher
parent a30b2cac20
commit 3f7107da10
6 changed files with 100 additions and 54 deletions
@@ -16,9 +16,7 @@
//! Message lane pallet benchmarking.
use crate::{
inbound_lane::InboundLaneStorage, inbound_lane_storage, outbound_lane, relayer_fund_account_id, Call, Instance,
};
use crate::{inbound_lane::InboundLaneStorage, inbound_lane_storage, outbound_lane, Call, Instance};
use bp_message_lane::{
source_chain::TargetHeaderChain, target_chain::SourceHeaderChain, InboundLaneData, LaneId, MessageData,
@@ -224,7 +222,7 @@ benchmarks_instance! {
//
// This is base benchmark for all other confirmations delivery benchmarks.
receive_delivery_proof_for_single_message {
let relayers_fund_id = relayer_fund_account_id::<T, I>();
let relayers_fund_id = crate::Module::<T, I>::relayer_fund_account_id();
let relayer_id: T::AccountId = account("relayer", 0, SEED);
let relayer_balance = T::account_balance(&relayer_id);
T::endow_account(&relayers_fund_id);
@@ -261,7 +259,7 @@ benchmarks_instance! {
// as `weight(receive_delivery_proof_for_two_messages_by_single_relayer)
// - weight(receive_delivery_proof_for_single_message)`.
receive_delivery_proof_for_two_messages_by_single_relayer {
let relayers_fund_id = relayer_fund_account_id::<T, I>();
let relayers_fund_id = crate::Module::<T, I>::relayer_fund_account_id();
let relayer_id: T::AccountId = account("relayer", 0, SEED);
let relayer_balance = T::account_balance(&relayer_id);
T::endow_account(&relayers_fund_id);
@@ -299,7 +297,7 @@ benchmarks_instance! {
// as `weight(receive_delivery_proof_for_two_messages_by_two_relayers)
// - weight(receive_delivery_proof_for_two_messages_by_single_relayer)`.
receive_delivery_proof_for_two_messages_by_two_relayers {
let relayers_fund_id = relayer_fund_account_id::<T, I>();
let relayers_fund_id = crate::Module::<T, I>::relayer_fund_account_id();
let relayer1_id: T::AccountId = account("relayer1", 1, SEED);
let relayer1_balance = T::account_balance(&relayer1_id);
let relayer2_id: T::AccountId = account("relayer2", 2, SEED);
@@ -431,7 +429,7 @@ benchmarks_instance! {
.try_into()
.expect("Value of MaxUnrewardedRelayerEntriesAtInboundLane is too large");
let relayers_fund_id = relayer_fund_account_id::<T, I>();
let relayers_fund_id = crate::Module::<T, I>::relayer_fund_account_id();
let relayer_id: T::AccountId = account("relayer", 0, SEED);
let relayer_balance = T::account_balance(&relayer_id);
T::endow_account(&relayers_fund_id);
@@ -470,7 +468,7 @@ benchmarks_instance! {
.try_into()
.expect("Value of MaxUnconfirmedMessagesAtInboundLane is too large ");
let relayers_fund_id = relayer_fund_account_id::<T, I>();
let relayers_fund_id = crate::Module::<T, I>::relayer_fund_account_id();
let confirmation_relayer_id = account("relayer", 0, SEED);
let relayers: BTreeMap<T::AccountId, T::OutboundMessageFee> = (1..=i)
.map(|j| {