@@ -27,9 +27,11 @@ use bp_messages::{
27
27
UnrewardedRelayersState ,
28
28
} ;
29
29
use bp_runtime:: StorageProofSize ;
30
+ use codec:: Decode ;
30
31
use frame_benchmarking:: { account, benchmarks_instance_pallet} ;
31
32
use frame_support:: weights:: Weight ;
32
33
use frame_system:: RawOrigin ;
34
+ use sp_runtime:: traits:: TrailingZeroInput ;
33
35
use sp_std:: { ops:: RangeInclusive , prelude:: * } ;
34
36
35
37
const SEED : u32 = 0 ;
@@ -64,15 +66,26 @@ pub struct MessageDeliveryProofParams<ThisChainAccountId> {
64
66
/// Trait that must be implemented by runtime.
65
67
pub trait Config < I : ' static > : crate :: Config < I > {
66
68
/// Lane id to use in benchmarks.
69
+ ///
70
+ /// By default, lane 00000000 is used.
67
71
fn bench_lane_id ( ) -> LaneId {
68
- Default :: default ( )
72
+ LaneId ( [ 0 , 0 , 0 , 0 ] )
69
73
}
74
+
70
75
/// Return id of relayer account at the bridged chain.
71
- fn bridged_relayer_id ( ) -> Self :: InboundRelayer ;
72
- /// Returns true if given relayer has been rewarded for some of its actions.
73
- fn is_relayer_rewarded ( relayer : & Self :: AccountId ) -> bool ;
74
- /// Create given account and give it enough balance for test purposes.
75
- fn endow_account ( account : & Self :: AccountId ) ;
76
+ ///
77
+ /// By default, zero account is returned.
78
+ fn bridged_relayer_id ( ) -> Self :: InboundRelayer {
79
+ Self :: InboundRelayer :: decode ( & mut TrailingZeroInput :: zeroes ( ) ) . unwrap ( )
80
+ }
81
+
82
+ /// Create given account and give it enough balance for test purposes. Used to create
83
+ /// relayer account at the target chain. Is strictly necessary when your rewards scheme
84
+ /// assumes that the relayer account must exist.
85
+ ///
86
+ /// Does nothing by default.
87
+ fn endow_account ( _account : & Self :: AccountId ) { }
88
+
76
89
/// Prepare messages proof to receive by the module.
77
90
fn prepare_message_proof (
78
91
params : MessageProofParams ,
@@ -81,8 +94,20 @@ pub trait Config<I: 'static>: crate::Config<I> {
81
94
fn prepare_message_delivery_proof (
82
95
params : MessageDeliveryProofParams < Self :: AccountId > ,
83
96
) -> <Self :: TargetHeaderChain as TargetHeaderChain < Self :: OutboundPayload , Self :: AccountId > >:: MessagesDeliveryProof ;
97
+
84
98
/// Returns true if message has been dispatched (either successfully or not).
85
- fn is_message_dispatched ( nonce : MessageNonce ) -> bool ;
99
+ ///
100
+ /// We assume that messages have near-zero dispatch weight, so most of times it
101
+ /// is hard to determine whether messages has been dispatched or not. For example,
102
+ /// XCM message can be a call that leaves entry in `frame_system::Events` vector,
103
+ /// but not all XCM messages do that and we don't want to include weight of this
104
+ /// action to the base weight of message delivery. Hence, the default `true` return
105
+ /// value.
106
+ fn is_message_dispatched ( _nonce : MessageNonce ) -> bool {
107
+ true
108
+ }
109
+ /// Returns true if given relayer has been rewarded for some of its actions.
110
+ fn is_relayer_rewarded ( relayer : & Self :: AccountId ) -> bool ;
86
111
}
87
112
88
113
benchmarks_instance_pallet ! {
0 commit comments