generated from SubstrateDevAcademy/v1-exercise-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime.rs
3946 lines (3946 loc) · 197 KB
/
runtime.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#![feature(prelude_import)]
#![recursion_limit = "256"]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
pub const WASM_BINARY: Option<&[u8]> = None;
pub const WASM_BINARY_BLOATY: Option<&[u8]> = None;
use sp_std::prelude::*;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, MultiSignature,
transaction_validity::{TransactionValidity, TransactionSource},
};
use sp_runtime::traits::{
BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, Saturating,
};
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use pallet_grandpa::fg_primitives;
use sp_version::RuntimeVersion;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use pallet_timestamp::Call as TimestampCall;
pub use pallet_balances::Call as BalancesCall;
pub use sp_runtime::{Permill, Perbill};
pub use frame_support::{
construct_runtime, parameter_types, StorageValue,
traits::{KeyOwnerProofSystem, Randomness},
weights::{
Weight, IdentityFee,
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
},
};
/// Import the template pallet.
pub use pallet_template;
/// An index to a block.
pub type BlockNumber = u32;
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = MultiSignature;
/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
/// never know...
pub type AccountIndex = u32;
/// Balance of an account.
pub type Balance = u128;
/// Index of a transaction in the chain.
pub type Index = u32;
/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;
/// Digest item type.
pub type DigestItem = generic::DigestItem<Hash>;
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
/// to even the core data structures.
pub mod opaque {
use super::*;
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Opaque block type.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Opaque block identifier type.
pub type BlockId = generic::BlockId<Block>;
pub struct SessionKeys {
pub aura: <Aura as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
pub grandpa: <Grandpa as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::default::Default for SessionKeys {
#[inline]
fn default() -> SessionKeys {
SessionKeys {
aura: ::core::default::Default::default(),
grandpa: ::core::default::Default::default(),
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for SessionKeys {
#[inline]
fn clone(&self) -> SessionKeys {
match *self {
SessionKeys {
aura: ref __self_0_0,
grandpa: ref __self_0_1,
} => SessionKeys {
aura: ::core::clone::Clone::clone(&(*__self_0_0)),
grandpa: ::core::clone::Clone::clone(&(*__self_0_1)),
},
}
}
}
impl ::core::marker::StructuralPartialEq for SessionKeys {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for SessionKeys {
#[inline]
fn eq(&self, other: &SessionKeys) -> bool {
match *other {
SessionKeys {
aura: ref __self_1_0,
grandpa: ref __self_1_1,
} => match *self {
SessionKeys {
aura: ref __self_0_0,
grandpa: ref __self_0_1,
} => (*__self_0_0) == (*__self_1_0) && (*__self_0_1) == (*__self_1_1),
},
}
}
#[inline]
fn ne(&self, other: &SessionKeys) -> bool {
match *other {
SessionKeys {
aura: ref __self_1_0,
grandpa: ref __self_1_1,
} => match *self {
SessionKeys {
aura: ref __self_0_0,
grandpa: ref __self_0_1,
} => (*__self_0_0) != (*__self_1_0) || (*__self_0_1) != (*__self_1_1),
},
}
}
}
impl ::core::marker::StructuralEq for SessionKeys {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for SessionKeys {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{
let _: ::core::cmp::AssertParamIsEq<
<Aura as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
>;
let _: ::core::cmp::AssertParamIsEq<
<Grandpa as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
>;
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for SessionKeys {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {
dest.push(&self.aura);
dest.push(&self.grandpa);
}
}
impl _parity_scale_codec::EncodeLike for SessionKeys {}
};
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for SessionKeys {
fn decode<DecIn: _parity_scale_codec::Input>(
input: &mut DecIn,
) -> core::result::Result<Self, _parity_scale_codec::Error> {
Ok(SessionKeys {
aura: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field SessionKeys.aura".into()),
Ok(a) => a,
}
},
grandpa: {
let res = _parity_scale_codec::Decode::decode(input);
match res {
Err(_) => return Err("Error decoding field SessionKeys.grandpa".into()),
Ok(a) => a,
}
},
})
}
}
};
impl core::fmt::Debug for SessionKeys {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_struct("SessionKeys")
.field("aura", &self.aura)
.field("grandpa", &self.grandpa)
.finish()
}
}
#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _: () = {
#[allow(rust_2018_idioms, clippy::useless_attribute)]
extern crate serde as _serde;
#[automatically_derived]
impl _serde::Serialize for SessionKeys {
fn serialize<__S>(
&self,
__serializer: __S,
) -> _serde::export::Result<__S::Ok, __S::Error>
where
__S: _serde::Serializer,
{
let mut __serde_state = match _serde::Serializer::serialize_struct(
__serializer,
"SessionKeys",
false as usize + 1 + 1,
) {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
match _serde::ser::SerializeStruct::serialize_field(
&mut __serde_state,
"aura",
&self.aura,
) {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
match _serde::ser::SerializeStruct::serialize_field(
&mut __serde_state,
"grandpa",
&self.grandpa,
) {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
_serde::ser::SerializeStruct::end(__serde_state)
}
}
};
#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _: () = {
#[allow(rust_2018_idioms, clippy::useless_attribute)]
extern crate serde as _serde;
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for SessionKeys {
fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<Self, __D::Error>
where
__D: _serde::Deserializer<'de>,
{
#[allow(non_camel_case_types)]
enum __Field {
__field0,
__field1,
__ignore,
}
struct __FieldVisitor;
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
type Value = __Field;
fn expecting(
&self,
__formatter: &mut _serde::export::Formatter,
) -> _serde::export::fmt::Result {
_serde::export::Formatter::write_str(__formatter, "field identifier")
}
fn visit_u64<__E>(
self,
__value: u64,
) -> _serde::export::Result<Self::Value, __E>
where
__E: _serde::de::Error,
{
match __value {
0u64 => _serde::export::Ok(__Field::__field0),
1u64 => _serde::export::Ok(__Field::__field1),
_ => _serde::export::Err(_serde::de::Error::invalid_value(
_serde::de::Unexpected::Unsigned(__value),
&"field index 0 <= i < 2",
)),
}
}
fn visit_str<__E>(
self,
__value: &str,
) -> _serde::export::Result<Self::Value, __E>
where
__E: _serde::de::Error,
{
match __value {
"aura" => _serde::export::Ok(__Field::__field0),
"grandpa" => _serde::export::Ok(__Field::__field1),
_ => _serde::export::Ok(__Field::__ignore),
}
}
fn visit_bytes<__E>(
self,
__value: &[u8],
) -> _serde::export::Result<Self::Value, __E>
where
__E: _serde::de::Error,
{
match __value {
b"aura" => _serde::export::Ok(__Field::__field0),
b"grandpa" => _serde::export::Ok(__Field::__field1),
_ => _serde::export::Ok(__Field::__ignore),
}
}
}
impl<'de> _serde::Deserialize<'de> for __Field {
#[inline]
fn deserialize<__D>(
__deserializer: __D,
) -> _serde::export::Result<Self, __D::Error>
where
__D: _serde::Deserializer<'de>,
{
_serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor)
}
}
struct __Visitor<'de> {
marker: _serde::export::PhantomData<SessionKeys>,
lifetime: _serde::export::PhantomData<&'de ()>,
}
impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
type Value = SessionKeys;
fn expecting(
&self,
__formatter: &mut _serde::export::Formatter,
) -> _serde::export::fmt::Result {
_serde::export::Formatter::write_str(__formatter, "struct SessionKeys")
}
#[inline]
fn visit_seq<__A>(
self,
mut __seq: __A,
) -> _serde::export::Result<Self::Value, __A::Error>
where
__A: _serde::de::SeqAccess<'de>,
{
let __field0 = match match _serde::de::SeqAccess::next_element::<
<Aura as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
>(&mut __seq)
{
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
} {
_serde::export::Some(__value) => __value,
_serde::export::None => {
return _serde::export::Err(_serde::de::Error::invalid_length(
0usize,
&"struct SessionKeys with 2 elements",
));
}
};
let __field1 = match match _serde::de::SeqAccess::next_element::<
<Grandpa as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
>(&mut __seq)
{
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
} {
_serde::export::Some(__value) => __value,
_serde::export::None => {
return _serde::export::Err(_serde::de::Error::invalid_length(
1usize,
&"struct SessionKeys with 2 elements",
));
}
};
_serde::export::Ok(SessionKeys {
aura: __field0,
grandpa: __field1,
})
}
#[inline]
fn visit_map<__A>(
self,
mut __map: __A,
) -> _serde::export::Result<Self::Value, __A::Error>
where
__A: _serde::de::MapAccess<'de>,
{
let mut __field0: _serde::export::Option<
<Aura as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
> = _serde::export::None;
let mut __field1: _serde::export::Option<
<Grandpa as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
> = _serde::export::None;
while let _serde::export::Some(__key) =
match _serde::de::MapAccess::next_key::<__Field>(&mut __map) {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
}
{
match __key {
__Field::__field0 => {
if _serde::export::Option::is_some(&__field0) {
return _serde::export::Err(
<__A::Error as _serde::de::Error>::duplicate_field(
"aura",
),
);
}
__field0 = _serde::export::Some(
match _serde::de::MapAccess::next_value::<
<Aura as ::sp_runtime::BoundToRuntimeAppPublic>::Public,
>(&mut __map)
{
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
},
);
}
__Field::__field1 => {
if _serde::export::Option::is_some(&__field1) {
return _serde::export::Err(
<__A::Error as _serde::de::Error>::duplicate_field(
"grandpa",
),
);
}
__field1 = _serde :: export :: Some ( match _serde :: de :: MapAccess :: next_value :: < < Grandpa as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public > ( & mut __map ) { _serde :: export :: Ok ( __val ) => __val , _serde :: export :: Err ( __err ) => { return _serde :: export :: Err ( __err ) ; } } ) ;
}
_ => {
let _ = match _serde::de::MapAccess::next_value::<
_serde::de::IgnoredAny,
>(&mut __map)
{
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
};
}
}
}
let __field0 = match __field0 {
_serde::export::Some(__field0) => __field0,
_serde::export::None => {
match _serde::private::de::missing_field("aura") {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
}
}
};
let __field1 = match __field1 {
_serde::export::Some(__field1) => __field1,
_serde::export::None => {
match _serde::private::de::missing_field("grandpa") {
_serde::export::Ok(__val) => __val,
_serde::export::Err(__err) => {
return _serde::export::Err(__err);
}
}
}
};
_serde::export::Ok(SessionKeys {
aura: __field0,
grandpa: __field1,
})
}
}
const FIELDS: &'static [&'static str] = &["aura", "grandpa"];
_serde::Deserializer::deserialize_struct(
__deserializer,
"SessionKeys",
FIELDS,
__Visitor {
marker: _serde::export::PhantomData::<SessionKeys>,
lifetime: _serde::export::PhantomData,
},
)
}
}
};
impl SessionKeys {
/// Generate a set of keys with optionally using the given seed.
///
/// The generated key pairs are stored in the keystore.
///
/// Returns the concatenated SCALE encoded public keys.
pub fn generate(
seed: Option<::sp_runtime::sp_std::vec::Vec<u8>>,
) -> ::sp_runtime::sp_std::vec::Vec<u8> {
let keys = Self { aura : < < Aura as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: generate_pair ( seed . clone ( ) ) , grandpa : < < Grandpa as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: generate_pair ( seed . clone ( ) ) , } ;
::sp_runtime::codec::Encode::encode(&keys)
}
/// Converts `Self` into a `Vec` of `(raw public key, KeyTypeId)`.
pub fn into_raw_public_keys(
self,
) -> ::sp_runtime::sp_std::vec::Vec<(
::sp_runtime::sp_std::vec::Vec<u8>,
::sp_runtime::KeyTypeId,
)> {
let mut keys = Vec::new();
keys . push ( ( :: sp_runtime :: RuntimeAppPublic :: to_raw_vec ( & self . aura ) , < < Aura as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: ID ) ) ;
keys . push ( ( :: sp_runtime :: RuntimeAppPublic :: to_raw_vec ( & self . grandpa ) , < < Grandpa as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: ID ) ) ;
keys
}
/// Decode `Self` from the given `encoded` slice and convert `Self` into the raw public
/// keys (see [`Self::into_raw_public_keys`]).
///
/// Returns `None` when the decoding failed, otherwise `Some(_)`.
pub fn decode_into_raw_public_keys(
encoded: &[u8],
) -> Option<
::sp_runtime::sp_std::vec::Vec<(
::sp_runtime::sp_std::vec::Vec<u8>,
::sp_runtime::KeyTypeId,
)>,
> {
<Self as ::sp_runtime::codec::Decode>::decode(&mut &encoded[..])
.ok()
.map(|s| s.into_raw_public_keys())
}
}
impl ::sp_runtime::traits::OpaqueKeys for SessionKeys {
type KeyTypeIdProviders = (Aura, Grandpa);
fn key_ids() -> &'static [::sp_runtime::KeyTypeId] {
& [ < < Aura as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: ID , < < Grandpa as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: ID ]
}
fn get_raw(&self, i: ::sp_runtime::KeyTypeId) -> &[u8] {
match i { i if i == < < Aura as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: ID => self . aura . as_ref ( ) , i if i == < < Grandpa as :: sp_runtime :: BoundToRuntimeAppPublic > :: Public as :: sp_runtime :: RuntimeAppPublic > :: ID => self . grandpa . as_ref ( ) , _ => & [ ] , }
}
}
}
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: { ::sp_runtime::RuntimeString::Borrowed("node-template") },
impl_name: { ::sp_runtime::RuntimeString::Borrowed("node-template") },
authoring_version: 1,
spec_version: 1,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
pub const MILLISECS_PER_BLOCK: u64 = 2000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion {
runtime_version: VERSION,
can_author_with: Default::default(),
}
}
pub struct BlockHashCount;
impl BlockHashCount {
/// Returns the value of this parameter type.
pub const fn get() -> BlockNumber {
2400
}
}
impl<I: From<BlockNumber>> ::frame_support::traits::Get<I> for BlockHashCount {
fn get() -> I {
I::from(2400)
}
}
/// We allow for 2 seconds of compute with a 6 second average block time.
pub struct MaximumBlockWeight;
impl MaximumBlockWeight {
/// Returns the value of this parameter type.
pub const fn get() -> Weight {
2 * WEIGHT_PER_SECOND
}
}
impl<I: From<Weight>> ::frame_support::traits::Get<I> for MaximumBlockWeight {
fn get() -> I {
I::from(2 * WEIGHT_PER_SECOND)
}
}
pub struct AvailableBlockRatio;
impl AvailableBlockRatio {
/// Returns the value of this parameter type.
pub const fn get() -> Perbill {
Perbill::from_percent(75)
}
}
impl<I: From<Perbill>> ::frame_support::traits::Get<I> for AvailableBlockRatio {
fn get() -> I {
I::from(Perbill::from_percent(75))
}
}
/// Assume 10% of weight for average on_initialize calls.
pub struct MaximumExtrinsicWeight;
impl MaximumExtrinsicWeight {
/// Returns the value of this parameter type.
pub fn get() -> Weight {
AvailableBlockRatio::get().saturating_sub(Perbill::from_percent(10))
* MaximumBlockWeight::get()
}
}
impl<I: From<Weight>> ::frame_support::traits::Get<I> for MaximumExtrinsicWeight {
fn get() -> I {
I::from(
AvailableBlockRatio::get().saturating_sub(Perbill::from_percent(10))
* MaximumBlockWeight::get(),
)
}
}
pub struct MaximumBlockLength;
impl MaximumBlockLength {
/// Returns the value of this parameter type.
pub const fn get() -> u32 {
5 * 1024 * 1024
}
}
impl<I: From<u32>> ::frame_support::traits::Get<I> for MaximumBlockLength {
fn get() -> I {
I::from(5 * 1024 * 1024)
}
}
pub struct Version;
impl Version {
/// Returns the value of this parameter type.
pub const fn get() -> RuntimeVersion {
VERSION
}
}
impl<I: From<RuntimeVersion>> ::frame_support::traits::Get<I> for Version {
fn get() -> I {
I::from(VERSION)
}
}
impl frame_system::Trait for Runtime {
/// The basic call filter to use in dispatchable.
type BaseCallFilter = ();
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
type Call = Call;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = IdentityLookup<AccountId>;
/// The index type for storing how many extrinsics an account has signed.
type Index = Index;
/// The index type for blocks.
type BlockNumber = BlockNumber;
/// The type for hashing blocks and tries.
type Hash = Hash;
/// The hashing algorithm used.
type Hashing = BlakeTwo256;
/// The header type.
type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// The ubiquitous event type.
type Event = Event;
/// The ubiquitous origin type.
type Origin = Origin;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
type BlockHashCount = BlockHashCount;
/// Maximum weight of each block.
type MaximumBlockWeight = MaximumBlockWeight;
/// The weight of database operations that the runtime can invoke.
type DbWeight = RocksDbWeight;
/// The weight of the overhead invoked on the block import process, independent of the
/// extrinsics included in that block.
type BlockExecutionWeight = BlockExecutionWeight;
/// The base weight of any extrinsic processed by the runtime, independent of the
/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
/// The maximum weight that a single extrinsic of `Normal` dispatch class can have,
/// idependent of the logic of that extrinsics. (Roughly max block weight - average on
/// initialize cost).
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
type MaximumBlockLength = MaximumBlockLength;
/// Portion of the block weight that is available to all normal transactions.
type AvailableBlockRatio = AvailableBlockRatio;
/// Version of the runtime.
type Version = Version;
/// Converts a module to the index of the module in `construct_runtime!`.
///
/// This type is being generated by `construct_runtime!`.
type PalletInfo = PalletInfo;
/// What to do if a new account is created.
type OnNewAccount = ();
/// What to do if an account is fully reaped from the system.
type OnKilledAccount = ();
/// The data to be stored in an account.
type AccountData = pallet_balances::AccountData<Balance>;
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = ();
}
impl pallet_aura::Trait for Runtime {
type AuthorityId = AuraId;
}
impl pallet_grandpa::Trait for Runtime {
type Event = Event;
type Call = Call;
type KeyOwnerProofSystem = ();
type KeyOwnerProof =
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
KeyTypeId,
GrandpaId,
)>>::IdentificationTuple;
type HandleEquivocation = ();
type WeightInfo = ();
}
pub struct MinimumPeriod;
impl MinimumPeriod {
/// Returns the value of this parameter type.
pub const fn get() -> u64 {
SLOT_DURATION / 2
}
}
impl<I: From<u64>> ::frame_support::traits::Get<I> for MinimumPeriod {
fn get() -> I {
I::from(SLOT_DURATION / 2)
}
}
impl pallet_timestamp::Trait for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}
pub struct ExistentialDeposit;
impl ExistentialDeposit {
/// Returns the value of this parameter type.
pub const fn get() -> u128 {
500
}
}
impl<I: From<u128>> ::frame_support::traits::Get<I> for ExistentialDeposit {
fn get() -> I {
I::from(500)
}
}
pub struct MaxLocks;
impl MaxLocks {
/// Returns the value of this parameter type.
pub const fn get() -> u32 {
50
}
}
impl<I: From<u32>> ::frame_support::traits::Get<I> for MaxLocks {
fn get() -> I {
I::from(50)
}
}
impl pallet_balances::Trait for Runtime {
type MaxLocks = MaxLocks;
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
pub struct TransactionByteFee;
impl TransactionByteFee {
/// Returns the value of this parameter type.
pub const fn get() -> Balance {
1
}
}
impl<I: From<Balance>> ::frame_support::traits::Get<I> for TransactionByteFee {
fn get() -> I {
I::from(1)
}
}
impl pallet_transaction_payment::Trait for Runtime {
type Currency = Balances;
type OnTransactionPayment = ();
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
}
impl pallet_sudo::Trait for Runtime {
type Event = Event;
type Call = Call;
}
/// Configure the template pallet in pallets/template.
impl pallet_template::Trait for Runtime {
type Event = Event;
}
impl pallet_kitties::Trait for Runtime {}
#[doc(hidden)]
mod sp_api_hidden_includes_construct_runtime {
pub extern crate frame_support as hidden_include;
}
pub struct Runtime;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Runtime {
#[inline]
fn clone(&self) -> Runtime {
{
*self
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::marker::Copy for Runtime {}
impl ::core::marker::StructuralPartialEq for Runtime {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for Runtime {
#[inline]
fn eq(&self, other: &Runtime) -> bool {
match *other {
Runtime => match *self {
Runtime => true,
},
}
}
}
impl ::core::marker::StructuralEq for Runtime {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::Eq for Runtime {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{}
}
}
impl core::fmt::Debug for Runtime {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
fmt.debug_tuple("Runtime").finish()
}
}
impl self :: sp_api_hidden_includes_construct_runtime :: hidden_include :: sp_runtime :: traits :: GetNodeBlockType for Runtime { type NodeBlock = opaque :: Block ; }
impl self :: sp_api_hidden_includes_construct_runtime :: hidden_include :: sp_runtime :: traits :: GetRuntimeBlockType for Runtime { type RuntimeBlock = Block ; }
#[allow(non_camel_case_types)]
pub enum Event {
#[codec(index = "0")]
frame_system(frame_system::Event<Runtime>),
#[codec(index = "4")]
pallet_grandpa(pallet_grandpa::Event),
#[codec(index = "5")]
pallet_balances(pallet_balances::Event<Runtime>),
#[codec(index = "7")]
pallet_sudo(pallet_sudo::Event<Runtime>),
#[codec(index = "8")]
pallet_template(pallet_template::Event<Runtime>),
}
#[automatically_derived]
#[allow(unused_qualifications)]
#[allow(non_camel_case_types)]
impl ::core::clone::Clone for Event {
#[inline]
fn clone(&self) -> Event {
match (&*self,) {
(&Event::frame_system(ref __self_0),) => {
Event::frame_system(::core::clone::Clone::clone(&(*__self_0)))
}
(&Event::pallet_grandpa(ref __self_0),) => {
Event::pallet_grandpa(::core::clone::Clone::clone(&(*__self_0)))
}
(&Event::pallet_balances(ref __self_0),) => {
Event::pallet_balances(::core::clone::Clone::clone(&(*__self_0)))
}
(&Event::pallet_sudo(ref __self_0),) => {
Event::pallet_sudo(::core::clone::Clone::clone(&(*__self_0)))
}
(&Event::pallet_template(ref __self_0),) => {
Event::pallet_template(::core::clone::Clone::clone(&(*__self_0)))
}
}
}
}
#[allow(non_camel_case_types)]
impl ::core::marker::StructuralPartialEq for Event {}
#[automatically_derived]
#[allow(unused_qualifications)]
#[allow(non_camel_case_types)]
impl ::core::cmp::PartialEq for Event {
#[inline]
fn eq(&self, other: &Event) -> bool {
{
let __self_vi = unsafe { ::core::intrinsics::discriminant_value(&*self) };
let __arg_1_vi = unsafe { ::core::intrinsics::discriminant_value(&*other) };
if true && __self_vi == __arg_1_vi {
match (&*self, &*other) {
(&Event::frame_system(ref __self_0), &Event::frame_system(ref __arg_1_0)) => {
(*__self_0) == (*__arg_1_0)
}
(
&Event::pallet_grandpa(ref __self_0),
&Event::pallet_grandpa(ref __arg_1_0),
) => (*__self_0) == (*__arg_1_0),
(
&Event::pallet_balances(ref __self_0),
&Event::pallet_balances(ref __arg_1_0),
) => (*__self_0) == (*__arg_1_0),
(&Event::pallet_sudo(ref __self_0), &Event::pallet_sudo(ref __arg_1_0)) => {
(*__self_0) == (*__arg_1_0)
}
(
&Event::pallet_template(ref __self_0),
&Event::pallet_template(ref __arg_1_0),
) => (*__self_0) == (*__arg_1_0),
_ => unsafe { ::core::intrinsics::unreachable() },
}
} else {
false
}
}
}
#[inline]
fn ne(&self, other: &Event) -> bool {
{
let __self_vi = unsafe { ::core::intrinsics::discriminant_value(&*self) };
let __arg_1_vi = unsafe { ::core::intrinsics::discriminant_value(&*other) };
if true && __self_vi == __arg_1_vi {
match (&*self, &*other) {
(&Event::frame_system(ref __self_0), &Event::frame_system(ref __arg_1_0)) => {
(*__self_0) != (*__arg_1_0)
}
(
&Event::pallet_grandpa(ref __self_0),
&Event::pallet_grandpa(ref __arg_1_0),
) => (*__self_0) != (*__arg_1_0),
(
&Event::pallet_balances(ref __self_0),
&Event::pallet_balances(ref __arg_1_0),
) => (*__self_0) != (*__arg_1_0),
(&Event::pallet_sudo(ref __self_0), &Event::pallet_sudo(ref __arg_1_0)) => {
(*__self_0) != (*__arg_1_0)
}
(
&Event::pallet_template(ref __self_0),
&Event::pallet_template(ref __arg_1_0),
) => (*__self_0) != (*__arg_1_0),
_ => unsafe { ::core::intrinsics::unreachable() },
}
} else {
true
}
}
}
}
#[allow(non_camel_case_types)]
impl ::core::marker::StructuralEq for Event {}
#[automatically_derived]
#[allow(unused_qualifications)]
#[allow(non_camel_case_types)]
impl ::core::cmp::Eq for Event {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
{
let _: ::core::cmp::AssertParamIsEq<frame_system::Event<Runtime>>;
let _: ::core::cmp::AssertParamIsEq<pallet_grandpa::Event>;
let _: ::core::cmp::AssertParamIsEq<pallet_balances::Event<Runtime>>;
let _: ::core::cmp::AssertParamIsEq<pallet_sudo::Event<Runtime>>;
let _: ::core::cmp::AssertParamIsEq<pallet_template::Event<Runtime>>;
}
}
}
const _: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for Event {
fn encode_to<EncOut: _parity_scale_codec::Output>(&self, dest: &mut EncOut) {
match *self {
Event::frame_system(ref aa) => {
dest.push_byte(0u8 as u8);
dest.push(aa);
}
Event::pallet_grandpa(ref aa) => {
dest.push_byte(4u8 as u8);
dest.push(aa);
}
Event::pallet_balances(ref aa) => {
dest.push_byte(5u8 as u8);
dest.push(aa);
}
Event::pallet_sudo(ref aa) => {
dest.push_byte(7u8 as u8);
dest.push(aa);
}
Event::pallet_template(ref aa) => {
dest.push_byte(8u8 as u8);
dest.push(aa);