1
- // Copyright 2018-2020 Parity Technologies (UK) Ltd.
2
- // This file is part of Substrate.
3
-
4
- // Substrate is free software: you can redistribute it and/or modify
5
- // it under the terms of the GNU General Public License as published by
6
- // the Free Software Foundation, either version 3 of the License, or
7
- // (at your option) any later version.
8
-
9
- // Substrate is distributed in the hope that it will be useful,
10
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- // GNU General Public License for more details.
13
-
14
- // You should have received a copy of the GNU General Public License
15
- // along with Substrate. If not, see <http://www.gnu.org/licenses/>.
16
-
17
- //! The Substrate runtime. This can be compiled with ``#[no_std]`, ready for Wasm.
1
+ //! The Darwinia runtime. This can be compiled with ``#[no_std]`, ready for Wasm.
18
2
19
3
#![ cfg_attr( not( feature = "std" ) , no_std) ]
20
4
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
@@ -37,7 +21,7 @@ pub use pallet_staking::StakerStatus;
37
21
use constants:: { currency:: * , supply:: * , time:: * } ;
38
22
use frame_support:: {
39
23
construct_runtime, parameter_types,
40
- traits:: { Currency , OnUnbalanced , Randomness , SplitTwoWays } ,
24
+ traits:: { Currency , Randomness , SplitTwoWays } ,
41
25
weights:: Weight ,
42
26
} ;
43
27
use frame_system:: offchain:: TransactionSubmitter ;
@@ -49,15 +33,15 @@ use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
49
33
use sp_api:: impl_runtime_apis;
50
34
use sp_authority_discovery:: AuthorityId as AuthorityDiscoveryId ;
51
35
use sp_core:: {
52
- u32_trait:: { _1, _3, _4} ,
36
+ u32_trait:: { _1, _2 , _3, _4} ,
53
37
OpaqueMetadata ,
54
38
} ;
55
39
use sp_inherents:: { CheckInherentsResult , InherentData } ;
56
40
use sp_runtime:: {
57
41
create_runtime_str, generic, impl_opaque_keys,
58
42
traits:: { self , BlakeTwo256 , Block as BlockT , NumberFor , OpaqueKeys , SaturatedConversion , StaticLookup } ,
59
43
transaction_validity:: TransactionValidity ,
60
- ApplyExtrinsicResult , Perbill ,
44
+ ApplyExtrinsicResult , Perbill , Permill ,
61
45
} ;
62
46
use sp_staking:: SessionIndex ;
63
47
use sp_std:: vec:: Vec ;
@@ -81,8 +65,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
81
65
// and set impl_version to equal spec_version. If only runtime
82
66
// implementation changes and behavior does not, then leave spec_version as
83
67
// is and increment impl_version.
84
- spec_version : 85 ,
85
- impl_version : 85 ,
68
+ spec_version : 86 ,
69
+ impl_version : 86 ,
86
70
apis : RUNTIME_API_VERSIONS ,
87
71
} ;
88
72
@@ -102,18 +86,11 @@ pub type DealWithFees = SplitTwoWays<
102
86
NegativeImbalance ,
103
87
_4 ,
104
88
// Treasury, // 4 parts (80%) goes to the treasury.
105
- MockTreasury ,
89
+ Treasury ,
106
90
_1 ,
107
91
Author , // 1 part (20%) goes to the block author.
108
92
> ;
109
93
110
- pub struct MockTreasury ;
111
- impl OnUnbalanced < NegativeImbalance > for MockTreasury {
112
- fn on_nonzero_unbalanced ( amount : NegativeImbalance ) {
113
- Balances :: resolve_creating ( & Sudo :: key ( ) , amount) ;
114
- }
115
- }
116
-
117
94
parameter_types ! {
118
95
pub const BlockHashCount : BlockNumber = 250 ;
119
96
pub const MaximumBlockWeight : Weight = 1_000_000_000 ;
@@ -268,25 +245,6 @@ impl pallet_collective::Trait<CouncilCollective> for Runtime {
268
245
// type MembershipChanged = TechnicalCommittee;
269
246
//}
270
247
271
- //parameter_types! {
272
- // pub const ProposalBond: Permill = Permill::from_percent(5);
273
- // pub const ProposalBondMinimum: Balance = 1 * COIN;
274
- // pub const SpendPeriod: BlockNumber = 1 * DAYS;
275
- // pub const Burn: Permill = Permill::from_percent(50);
276
- //}
277
- //
278
- //impl pallet_treasury::Trait for Runtime {
279
- // type Currency = Balances;
280
- // type ApproveOrigin = pallet_collective::EnsureMembers<_4, AccountId, CouncilCollective>;
281
- // type RejectOrigin = pallet_collective::EnsureMembers<_2, AccountId, CouncilCollective>;
282
- // type Event = Event;
283
- // type ProposalRejection = ();
284
- // type ProposalBond = ProposalBond;
285
- // type ProposalBondMinimum = ProposalBondMinimum;
286
- // type SpendPeriod = SpendPeriod;
287
- // type Burn = Burn;
288
- //}
289
-
290
248
parameter_types ! {
291
249
pub const ContractTransferFee : Balance = 1 * MILLI ;
292
250
pub const ContractCreationFee : Balance = 1 * MILLI ;
@@ -381,7 +339,7 @@ impl pallet_nicks::Trait for Runtime {
381
339
type Event = Event ;
382
340
type Currency = Balances ;
383
341
type ReservationFee = ReservationFee ;
384
- type Slashed = MockTreasury ;
342
+ type Slashed = Treasury ;
385
343
type ForceOrigin = pallet_collective:: EnsureMember < AccountId , CouncilCollective > ;
386
344
type MinLength = MinLength ;
387
345
type MaxLength = MaxLength ;
@@ -421,12 +379,43 @@ impl frame_system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for
421
379
}
422
380
}
423
381
382
+ impl pallet_eth_backing:: Trait for Runtime {
383
+ type Event = Event ;
384
+ type Time = Timestamp ;
385
+ type DetermineAccountId = pallet_eth_backing:: AccountIdDeterminator < Runtime > ;
386
+ type EthRelay = EthRelay ;
387
+ type OnDepositRedeem = Staking ;
388
+ type Ring = Balances ;
389
+ type RingReward = ( ) ;
390
+ type Kton = Kton ;
391
+ type KtonReward = ( ) ;
392
+ }
393
+
394
+ parameter_types ! {
395
+ pub const EthMainet : u64 = 0 ;
396
+ pub const EthRopsten : u64 = 1 ;
397
+ }
398
+
399
+ impl pallet_eth_relay:: Trait for Runtime {
400
+ type Event = Event ;
401
+ type EthNetwork = EthRopsten ;
402
+ }
403
+
424
404
parameter_types ! {
425
405
pub const ExistentialDeposit : Balance = 1 * COIN ;
426
406
pub const TransferFee : Balance = 1 * MILLI ;
427
407
pub const CreationFee : Balance = 1 * MILLI ;
428
408
}
429
409
410
+ impl pallet_kton:: Trait for Runtime {
411
+ type Balance = Balance ;
412
+ type Event = Event ;
413
+ type RingCurrency = Balances ;
414
+ type TransferPayment = Balances ;
415
+ type ExistentialDeposit = ExistentialDeposit ;
416
+ type TransferFee = TransferFee ;
417
+ }
418
+
430
419
impl pallet_ring:: Trait for Runtime {
431
420
type Balance = Balance ;
432
421
type OnFreeBalanceZero = ( ( Staking , Contracts ) , Session ) ;
@@ -438,14 +427,6 @@ impl pallet_ring::Trait for Runtime {
438
427
type TransferFee = TransferFee ;
439
428
type CreationFee = CreationFee ;
440
429
}
441
- impl pallet_kton:: Trait for Runtime {
442
- type Balance = Balance ;
443
- type Event = Event ;
444
- type RingCurrency = Balances ;
445
- type TransferPayment = Balances ;
446
- type ExistentialDeposit = ExistentialDeposit ;
447
- type TransferFee = TransferFee ;
448
- }
449
430
450
431
parameter_types ! {
451
432
pub const SessionsPerEra : SessionIndex = SESSIONS_PER_ERA ;
@@ -469,37 +450,39 @@ impl pallet_staking::Trait for Runtime {
469
450
type SlashCancelOrigin = pallet_collective:: EnsureProportionAtLeast < _3 , _4 , AccountId , CouncilCollective > ;
470
451
type SessionInterface = Self ;
471
452
type RingCurrency = Balances ;
472
- type RingRewardRemainder = ( ) ;
473
- type RingSlash = ( ) ;
453
+ type RingRewardRemainder = Treasury ;
454
+ // send the slashed funds to the treasury.
455
+ type RingSlash = Treasury ;
456
+ // rewards are minted from the void
474
457
type RingReward = ( ) ;
475
458
type KtonCurrency = Kton ;
476
- type KtonSlash = ( ) ;
459
+ // send the slashed funds to the treasury.
460
+ type KtonSlash = Treasury ;
461
+ // rewards are minted from the void
477
462
type KtonReward = ( ) ;
478
463
type Cap = Cap ;
479
464
type TotalPower = TotalPower ;
480
465
type GenesisTime = GenesisTime ;
481
466
}
482
467
483
468
parameter_types ! {
484
- pub const EthMainet : u64 = 0 ;
485
- pub const EthRopsten : u64 = 1 ;
469
+ pub const ProposalBond : Permill = Permill :: from_percent( 5 ) ;
470
+ pub const ProposalBondMinimum : Balance = 1 * COIN ;
471
+ pub const SpendPeriod : BlockNumber = 1 * DAYS ;
472
+ pub const Burn : Permill = Permill :: from_percent( 50 ) ;
486
473
}
487
474
488
- impl pallet_eth_relay:: Trait for Runtime {
489
- type Event = Event ;
490
- type EthNetwork = EthRopsten ;
491
- }
492
-
493
- impl pallet_eth_backing:: Trait for Runtime {
475
+ impl pallet_treasury:: Trait for Runtime {
476
+ type RingCurrency = Balances ;
477
+ type KtonCurrency = Kton ;
478
+ type ApproveOrigin = pallet_collective:: EnsureMembers < _4 , AccountId , CouncilCollective > ;
479
+ type RejectOrigin = pallet_collective:: EnsureMembers < _2 , AccountId , CouncilCollective > ;
494
480
type Event = Event ;
495
- type Time = Timestamp ;
496
- type DetermineAccountId = pallet_eth_backing:: AccountIdDeterminator < Runtime > ;
497
- type EthRelay = EthRelay ;
498
- type OnDepositRedeem = Staking ;
499
- type Ring = Balances ;
500
- type RingReward = ( ) ;
501
- type Kton = Kton ;
502
- type KtonReward = ( ) ;
481
+ type ProposalRejection = ( ) ;
482
+ type ProposalBond = ProposalBond ;
483
+ type ProposalBondMinimum = ProposalBondMinimum ;
484
+ type SpendPeriod = SpendPeriod ;
485
+ type Burn = Burn ;
503
486
}
504
487
505
488
construct_runtime ! (
@@ -521,7 +504,6 @@ construct_runtime!(
521
504
// TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
522
505
FinalityTracker : pallet_finality_tracker:: { Module , Call , Inherent } ,
523
506
Grandpa : pallet_grandpa:: { Module , Call , Storage , Config , Event } ,
524
- // Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
525
507
Contracts : pallet_contracts,
526
508
Sudo : pallet_sudo,
527
509
ImOnline : pallet_im_online:: { Module , Call , Storage , Event <T >, ValidateUnsigned , Config <T >} ,
@@ -530,11 +512,12 @@ construct_runtime!(
530
512
RandomnessCollectiveFlip : pallet_randomness_collective_flip:: { Module , Call , Storage } ,
531
513
Nicks : pallet_nicks:: { Module , Call , Storage , Event <T >} ,
532
514
533
- Balances : pallet_ring,
515
+ EthBacking : pallet_eth_backing,
516
+ EthRelay : pallet_eth_relay,
534
517
Kton : pallet_kton,
518
+ Balances : pallet_ring,
535
519
Staking : pallet_staking,
536
- EthRelay : pallet_eth_relay,
537
- EthBacking : pallet_eth_backing,
520
+ Treasury : pallet_treasury:: { Module , Call , Storage , Config , Event <T >} ,
538
521
}
539
522
) ;
540
523
0 commit comments