@@ -40,16 +40,20 @@ pub mod rialto_poa;
40
40
41
41
use crate :: millau_messages:: { ToMillauMessagePayload , WithMillauMessageBridge } ;
42
42
43
- use bridge_runtime_common:: messages:: { source:: estimate_message_dispatch_and_delivery_fee, MessageBridge } ;
43
+ use bridge_runtime_common:: messages:: {
44
+ source:: estimate_message_dispatch_and_delivery_fee, MessageBridge ,
45
+ } ;
44
46
use codec:: Decode ;
45
- use pallet_grandpa:: { fg_primitives, AuthorityId as GrandpaId , AuthorityList as GrandpaAuthorityList } ;
47
+ use pallet_grandpa:: {
48
+ fg_primitives, AuthorityId as GrandpaId , AuthorityList as GrandpaAuthorityList ,
49
+ } ;
46
50
use pallet_transaction_payment:: { FeeDetails , RuntimeDispatchInfo } ;
47
51
use sp_api:: impl_runtime_apis;
48
52
use sp_consensus_aura:: sr25519:: AuthorityId as AuraId ;
49
53
use sp_core:: { crypto:: KeyTypeId , OpaqueMetadata } ;
50
- use sp_runtime:: traits:: { Block as BlockT , IdentityLookup , NumberFor , OpaqueKeys } ;
51
54
use sp_runtime:: {
52
55
create_runtime_str, generic, impl_opaque_keys,
56
+ traits:: { Block as BlockT , IdentityLookup , NumberFor , OpaqueKeys } ,
53
57
transaction_validity:: { TransactionSource , TransactionValidity } ,
54
58
ApplyExtrinsicResult , MultiSignature , MultiSigner ,
55
59
} ;
@@ -146,10 +150,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
146
150
/// The version information used to identify this runtime when compiled natively.
147
151
#[ cfg( feature = "std" ) ]
148
152
pub fn native_version ( ) -> NativeVersion {
149
- NativeVersion {
150
- runtime_version : VERSION ,
151
- can_author_with : Default :: default ( ) ,
152
- }
153
+ NativeVersion { runtime_version : VERSION , can_author_with : Default :: default ( ) }
153
154
}
154
155
155
156
parameter_types ! {
@@ -278,10 +279,15 @@ impl bp_currency_exchange::DepositInto for DepositInto {
278
279
type Recipient = AccountId ;
279
280
type Amount = Balance ;
280
281
281
- fn deposit_into ( recipient : Self :: Recipient , amount : Self :: Amount ) -> bp_currency_exchange:: Result < ( ) > {
282
+ fn deposit_into (
283
+ recipient : Self :: Recipient ,
284
+ amount : Self :: Amount ,
285
+ ) -> bp_currency_exchange:: Result < ( ) > {
282
286
// let balances module make all checks for us (it won't allow depositing lower than existential
283
287
// deposit, balance overflow, ...)
284
- let deposited = <pallet_balances:: Pallet < Runtime > as Currency < AccountId > >:: deposit_creating ( & recipient, amount) ;
288
+ let deposited = <pallet_balances:: Pallet < Runtime > as Currency < AccountId > >:: deposit_creating (
289
+ & recipient, amount,
290
+ ) ;
285
291
286
292
// I'm dropping deposited here explicitly to illustrate the fact that it'll update `TotalIssuance`
287
293
// on drop
@@ -302,7 +308,7 @@ impl bp_currency_exchange::DepositInto for DepositInto {
302
308
) ;
303
309
304
310
Ok ( ( ) )
305
- }
311
+ } ,
306
312
_ if deposited_amount == 0 => {
307
313
log:: error!(
308
314
target: "runtime" ,
@@ -312,7 +318,7 @@ impl bp_currency_exchange::DepositInto for DepositInto {
312
318
) ;
313
319
314
320
Err ( bp_currency_exchange:: Error :: DepositFailed )
315
- }
321
+ } ,
316
322
_ => {
317
323
log:: error!(
318
324
target: "runtime" ,
@@ -324,7 +330,7 @@ impl bp_currency_exchange::DepositInto for DepositInto {
324
330
325
331
// we can't return DepositFailed error here, because storage changes were made
326
332
Err ( bp_currency_exchange:: Error :: DepositPartiallyFailed )
327
- }
333
+ } ,
328
334
}
329
335
}
330
336
}
@@ -333,9 +339,12 @@ impl pallet_grandpa::Config for Runtime {
333
339
type Event = Event ;
334
340
type Call = Call ;
335
341
type KeyOwnerProofSystem = ( ) ;
336
- type KeyOwnerProof = <Self :: KeyOwnerProofSystem as KeyOwnerProofSystem < ( KeyTypeId , GrandpaId ) > >:: Proof ;
337
- type KeyOwnerIdentification =
338
- <Self :: KeyOwnerProofSystem as KeyOwnerProofSystem < ( KeyTypeId , GrandpaId ) > >:: IdentificationTuple ;
342
+ type KeyOwnerProof =
343
+ <Self :: KeyOwnerProofSystem as KeyOwnerProofSystem < ( KeyTypeId , GrandpaId ) > >:: Proof ;
344
+ type KeyOwnerIdentification = <Self :: KeyOwnerProofSystem as KeyOwnerProofSystem < (
345
+ KeyTypeId ,
346
+ GrandpaId ,
347
+ ) > >:: IdentificationTuple ;
339
348
type HandleEquivocation = ( ) ;
340
349
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
341
350
type WeightInfo = ( ) ;
@@ -485,12 +494,13 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
485
494
486
495
type TargetHeaderChain = crate :: millau_messages:: Millau ;
487
496
type LaneMessageVerifier = crate :: millau_messages:: ToMillauMessageVerifier ;
488
- type MessageDeliveryAndDispatchPayment = pallet_bridge_messages:: instant_payments:: InstantCurrencyPayments <
489
- Runtime ,
490
- pallet_balances:: Pallet < Runtime > ,
491
- GetDeliveryConfirmationTransactionFee ,
492
- RootAccountForPayments ,
493
- > ;
497
+ type MessageDeliveryAndDispatchPayment =
498
+ pallet_bridge_messages:: instant_payments:: InstantCurrencyPayments <
499
+ Runtime ,
500
+ pallet_balances:: Pallet < Runtime > ,
501
+ GetDeliveryConfirmationTransactionFee ,
502
+ RootAccountForPayments ,
503
+ > ;
494
504
type OnDeliveryConfirmed = ( ) ;
495
505
496
506
type SourceHeaderChain = crate :: millau_messages:: Millau ;
@@ -550,8 +560,13 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signatu
550
560
/// Extrinsic type that has already been checked.
551
561
pub type CheckedExtrinsic = generic:: CheckedExtrinsic < AccountId , Call , SignedExtra > ;
552
562
/// Executive: handles dispatch to the various modules.
553
- pub type Executive =
554
- frame_executive:: Executive < Runtime , Block , frame_system:: ChainContext < Runtime > , Runtime , AllPallets > ;
563
+ pub type Executive = frame_executive:: Executive <
564
+ Runtime ,
565
+ Block ,
566
+ frame_system:: ChainContext < Runtime > ,
567
+ Runtime ,
568
+ AllPallets ,
569
+ > ;
555
570
556
571
impl_runtime_apis ! {
557
572
impl sp_api:: Core <Block > for Runtime {
@@ -802,10 +817,36 @@ impl_runtime_apis! {
802
817
803
818
#[ cfg( feature = "runtime-benchmarks" ) ]
804
819
impl frame_benchmarking:: Benchmark <Block > for Runtime {
820
+ fn benchmark_metadata( extra: bool ) -> (
821
+ Vec <frame_benchmarking:: BenchmarkList >,
822
+ Vec <frame_support:: traits:: StorageInfo >,
823
+ ) {
824
+ use frame_benchmarking:: { list_benchmark, Benchmarking , BenchmarkList } ;
825
+ use frame_support:: traits:: StorageInfoTrait ;
826
+
827
+ list_benchmark!(
828
+ list,
829
+ extra,
830
+ pallet_bridge_currency_exchange,
831
+ BridgeCurrencyExchangeBench :: <Runtime , KovanCurrencyExchange >
832
+ ) ;
833
+ list_benchmark!(
834
+ list,
835
+ extra,
836
+ pallet_bridge_messages,
837
+ MessagesBench :: <Runtime , WithMillauMessagesInstance >
838
+ ) ;
839
+ list_benchmark!( list, extra, pallet_bridge_grandpa, BridgeMillauGrandpa ) ;
840
+
841
+ let storage_info = AllPalletsWithSystem :: storage_info( ) ;
842
+
843
+ return ( list, storage_info)
844
+ }
845
+
805
846
fn dispatch_benchmark(
806
847
config: frame_benchmarking:: BenchmarkConfig ,
807
848
) -> Result <
808
- ( Vec <frame_benchmarking:: BenchmarkBatch >, Vec <frame_support :: traits :: StorageInfo > ) ,
849
+ Vec <frame_benchmarking:: BenchmarkBatch >,
809
850
sp_runtime:: RuntimeString ,
810
851
> {
811
852
use frame_benchmarking:: { Benchmarking , BenchmarkBatch , add_benchmark, TrackedStorageKey } ;
@@ -1051,8 +1092,7 @@ impl_runtime_apis! {
1051
1092
add_benchmark!( params, batches, pallet_bridge_grandpa, BridgeMillauGrandpa ) ;
1052
1093
1053
1094
if batches. is_empty( ) { return Err ( "Benchmark not found for this pallet." . into( ) ) }
1054
- let storage_info = AllPalletsWithSystem :: storage_info( ) ;
1055
- Ok ( ( batches, storage_info) )
1095
+ Ok ( batches)
1056
1096
}
1057
1097
}
1058
1098
}
@@ -1088,7 +1128,8 @@ mod tests {
1088
1128
use bridge_runtime_common:: messages;
1089
1129
1090
1130
fn run_deposit_into_test ( test : impl Fn ( AccountId ) -> Balance ) {
1091
- let mut ext: sp_io:: TestExternalities = SystemConfig :: default ( ) . build_storage :: < Runtime > ( ) . unwrap ( ) . into ( ) ;
1131
+ let mut ext: sp_io:: TestExternalities =
1132
+ SystemConfig :: default ( ) . build_storage :: < Runtime > ( ) . unwrap ( ) . into ( ) ;
1092
1133
ext. execute_with ( || {
1093
1134
// initially issuance is zero
1094
1135
assert_eq ! (
@@ -1100,7 +1141,10 @@ mod tests {
1100
1141
let account: AccountId = [ 1u8 ; 32 ] . into ( ) ;
1101
1142
let initial_amount = ExistentialDeposit :: get ( ) ;
1102
1143
let deposited =
1103
- <pallet_balances:: Pallet < Runtime > as Currency < AccountId > >:: deposit_creating ( & account, initial_amount) ;
1144
+ <pallet_balances:: Pallet < Runtime > as Currency < AccountId > >:: deposit_creating (
1145
+ & account,
1146
+ initial_amount,
1147
+ ) ;
1104
1148
drop ( deposited) ;
1105
1149
assert_eq ! (
1106
1150
<pallet_balances:: Pallet <Runtime > as Currency <AccountId >>:: total_issuance( ) ,
@@ -1140,15 +1184,18 @@ mod tests {
1140
1184
bp_rialto:: max_extrinsic_size ( ) ,
1141
1185
bp_rialto:: max_extrinsic_weight ( ) ,
1142
1186
max_incoming_message_proof_size,
1143
- messages:: target:: maximal_incoming_message_dispatch_weight ( bp_rialto:: max_extrinsic_weight ( ) ) ,
1187
+ messages:: target:: maximal_incoming_message_dispatch_weight (
1188
+ bp_rialto:: max_extrinsic_weight ( ) ,
1189
+ ) ,
1144
1190
) ;
1145
1191
1146
- let max_incoming_inbound_lane_data_proof_size = bp_messages:: InboundLaneData :: < ( ) > :: encoded_size_hint (
1147
- bp_rialto:: MAXIMAL_ENCODED_ACCOUNT_ID_SIZE ,
1148
- bp_millau:: MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE as _ ,
1149
- bp_millau:: MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE as _ ,
1150
- )
1151
- . unwrap_or ( u32:: MAX ) ;
1192
+ let max_incoming_inbound_lane_data_proof_size =
1193
+ bp_messages:: InboundLaneData :: < ( ) > :: encoded_size_hint (
1194
+ bp_rialto:: MAXIMAL_ENCODED_ACCOUNT_ID_SIZE ,
1195
+ bp_millau:: MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE as _ ,
1196
+ bp_millau:: MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE as _ ,
1197
+ )
1198
+ . unwrap_or ( u32:: MAX ) ;
1152
1199
pallet_bridge_messages:: ensure_able_to_receive_confirmation :: < Weights > (
1153
1200
bp_rialto:: max_extrinsic_size ( ) ,
1154
1201
bp_rialto:: max_extrinsic_weight ( ) ,
@@ -1162,15 +1209,19 @@ mod tests {
1162
1209
fn deposit_into_existing_account_works ( ) {
1163
1210
run_deposit_into_test ( |existing_account| {
1164
1211
let initial_amount =
1165
- <pallet_balances:: Pallet < Runtime > as Currency < AccountId > >:: free_balance ( & existing_account) ;
1212
+ <pallet_balances:: Pallet < Runtime > as Currency < AccountId > >:: free_balance (
1213
+ & existing_account,
1214
+ ) ;
1166
1215
let additional_amount = 10_000 ;
1167
1216
<Runtime as pallet_bridge_currency_exchange:: Config < KovanCurrencyExchange > >:: DepositInto :: deposit_into (
1168
1217
existing_account. clone ( ) ,
1169
1218
additional_amount,
1170
1219
)
1171
1220
. unwrap ( ) ;
1172
1221
assert_eq ! (
1173
- <pallet_balances:: Pallet <Runtime > as Currency <AccountId >>:: free_balance( & existing_account) ,
1222
+ <pallet_balances:: Pallet <Runtime > as Currency <AccountId >>:: free_balance(
1223
+ & existing_account
1224
+ ) ,
1174
1225
initial_amount + additional_amount,
1175
1226
) ;
1176
1227
additional_amount
@@ -1189,7 +1240,9 @@ mod tests {
1189
1240
)
1190
1241
. unwrap ( ) ;
1191
1242
assert_eq ! (
1192
- <pallet_balances:: Pallet <Runtime > as Currency <AccountId >>:: free_balance( & new_account) ,
1243
+ <pallet_balances:: Pallet <Runtime > as Currency <AccountId >>:: free_balance(
1244
+ & new_account
1245
+ ) ,
1193
1246
initial_amount + additional_amount,
1194
1247
) ;
1195
1248
additional_amount
0 commit comments