@@ -572,13 +572,13 @@ pub mod pallet {
572572
573573 /// Storage of the minimum DHX that must be bonded by each registered DHX miner each day
574574 /// to be eligible for rewards
575- /// \[amount_dhx, sender \]
576- SetMinBondedDHXDailyStored ( BalanceOf < T > , T :: AccountId ) ,
575+ /// \[amount_dhx\]
576+ SetMinBondedDHXDailyStored ( BalanceOf < T > ) ,
577577
578578 /// Storage of the minimum mPower that must be held by each registered DHX miner each day
579579 /// to be eligible for rewards
580- /// \[amount_mpower, sender \]
581- SetMinMPowerDailyStored ( u128 , T :: AccountId ) ,
580+ /// \[amount_mpower\]
581+ SetMinMPowerDailyStored ( u128 ) ,
582582
583583 /// Storage of the default cooling off period in days
584584 /// \[cooling_off_period_days\]
@@ -589,14 +589,14 @@ pub mod pallet {
589589 SetBondedDHXOfAccountForDateStored ( Date , BalanceOf < T > , T :: AccountId ) ,
590590
591591 /// Storage of the default daily reward allowance in DHX by an origin account.
592- /// \[amount_dhx, sender \]
593- SetRewardsAllowanceDHXDailyStored ( BalanceOf < T > , T :: AccountId ) ,
592+ /// \[amount_dhx\]
593+ SetRewardsAllowanceDHXDailyStored ( BalanceOf < T > ) ,
594594
595595 /// Change the stored reward allowance in DHX for a specific date by an origin account, and
596596 /// where change is 0 for an decrease or any other value like 1 for an increase to the remaining
597597 /// rewards allowance.
598- /// \[date, change_amount_dhx, sender, change\]
599- ChangedRewardsAllowanceDHXForDateRemainingStored ( Date , BalanceOf < T > , T :: AccountId , u8 ) ,
598+ /// \[date, change_amount_dhx, change\]
599+ ChangedRewardsAllowanceDHXForDateRemainingStored ( Date , BalanceOf < T > , u8 ) ,
600600
601601 /// Transferred a proportion of the daily DHX rewards allowance to a DHX Miner on a given date
602602 /// \[date, miner_reward, remaining_rewards_allowance_today, miner_account_id\]
@@ -612,16 +612,16 @@ pub mod pallet {
612612 ChangedMinBondedDHXDailyUsingNewRewardsMultiplier ( Date , BalanceOf < T > , u32 , u8 , u32 ) ,
613613
614614 /// Storage of a new reward operation (1u8: addition) by an origin account.
615- /// \[operation, sender \]
616- SetRewardsMultiplierOperationStored ( u8 , T :: AccountId ) ,
615+ /// \[operation\]
616+ SetRewardsMultiplierOperationStored ( u8 ) ,
617617
618618 /// Storage of a new reward multiplier default period in days (i.e. 90 for 3 months) by an origin account.
619- /// \[days, sender \]
620- SetRewardsMultiplierDefaultPeriodDaysStored ( u32 , T :: AccountId ) ,
619+ /// \[days\]
620+ SetRewardsMultiplierDefaultPeriodDaysStored ( u32 ) ,
621621
622622 /// Storage of a new reward multiplier next period in days (i.e. 90 for 3 months) by an origin account.
623- /// \[days, sender \]
624- SetRewardsMultiplierNextPeriodDaysStored ( u32 , T :: AccountId ) ,
623+ /// \[days\]
624+ SetRewardsMultiplierNextPeriodDaysStored ( u32 ) ,
625625
626626 /// Storage of new rewards multiplier paused status
627627 /// \[new_status]
@@ -2067,39 +2067,40 @@ pub mod pallet {
20672067 Ok ( ( ) )
20682068 }
20692069
2070+ // only modifiable by governance as root rather than just any user
20702071 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
20712072 pub fn set_min_bonded_dhx_daily ( origin : OriginFor < T > , min_bonded_dhx_daily : BalanceOf < T > ) -> DispatchResult {
2072- let _sender: T :: AccountId = ensure_signed ( origin) ?;
2073+ let _sender = ensure_root ( origin) ?;
20732074
20742075 <MinBondedDHXDaily < T > >:: put ( & min_bonded_dhx_daily. clone ( ) ) ;
20752076 log:: info!( "set_min_bonded_dhx_daily: {:?}" , & min_bonded_dhx_daily) ;
20762077
20772078 Self :: deposit_event ( Event :: SetMinBondedDHXDailyStored (
20782079 min_bonded_dhx_daily. clone ( ) ,
2079- _sender. clone ( ) ,
20802080 ) ) ;
20812081
20822082 Ok ( ( ) )
20832083 }
20842084
2085+ // only modifiable by governance as root rather than just any user
20852086 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
20862087 pub fn set_min_mpower_daily ( origin : OriginFor < T > , min_mpower_daily : u128 ) -> DispatchResult {
2087- let _sender: T :: AccountId = ensure_signed ( origin) ?;
2088+ let _sender = ensure_root ( origin) ?;
20882089
20892090 <MinMPowerDaily < T > >:: put ( & min_mpower_daily. clone ( ) ) ;
20902091 log:: info!( "set_min_mpower_daily: {:?}" , & min_mpower_daily) ;
20912092
20922093 Self :: deposit_event ( Event :: SetMinMPowerDailyStored (
20932094 min_mpower_daily. clone ( ) ,
2094- _sender. clone ( ) ,
20952095 ) ) ;
20962096
20972097 Ok ( ( ) )
20982098 }
20992099
2100+ // only modifiable by governance as root rather than just any user
21002101 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
21012102 pub fn set_cooling_off_period_days ( origin : OriginFor < T > , cooling_off_period_days : u32 ) -> DispatchResult {
2102- let _sender: T :: AccountId = ensure_signed ( origin) ?;
2103+ let _sender = ensure_root ( origin) ?;
21032104
21042105 <CoolingOffPeriodDays < T > >:: put ( & cooling_off_period_days. clone ( ) ) ;
21052106 log:: info!( "cooling_off_period_days: {:?}" , & cooling_off_period_days) ;
@@ -2111,19 +2112,17 @@ pub mod pallet {
21112112 Ok ( ( ) )
21122113 }
21132114
2114- // TODO: we need to change this in future so it is only modifiable by governance,
2115- // rather than just any user
2115+ // only modifiable by governance as root rather than just any user
21162116 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
21172117 pub fn set_rewards_allowance_dhx_daily ( origin : OriginFor < T > , rewards_allowance : BalanceOf < T > ) -> DispatchResult {
2118- let _who = ensure_signed ( origin) ?;
2118+ let _who = ensure_root ( origin) ?;
21192119 // Update storage
21202120 <RewardsAllowanceDHXDaily < T > >:: put ( & rewards_allowance. clone ( ) ) ;
21212121 log:: info!( "set_rewards_allowance_dhx_daily - rewards_allowance: {:?}" , & rewards_allowance) ;
21222122
21232123 // Emit an event.
21242124 Self :: deposit_event ( Event :: SetRewardsAllowanceDHXDailyStored (
21252125 rewards_allowance. clone ( ) ,
2126- _who. clone ( )
21272126 ) ) ;
21282127
21292128 // Return a successful DispatchResultWithPostInfo
@@ -2134,7 +2133,7 @@ pub mod pallet {
21342133 // https://docs.google.com/spreadsheets/d/1W2AzOH9Cs9oCR8UYfYCbpmd9X7hp-USbYXL7AuwMY_Q/edit#gid=970997021
21352134 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
21362135 pub fn set_rewards_allowance_dhx_for_date_remaining ( origin : OriginFor < T > , rewards_allowance : BalanceOf < T > , timestamp : u64 ) -> DispatchResult {
2137- let _who = ensure_signed ( origin) ?;
2136+ let _who = ensure_root ( origin) ?;
21382137
21392138 // Note: we do not need the following as we're not using the current timestamp, rather the function parameter.
21402139 // let current_date = <pallet_timestamp::Pallet<T>>::get();
@@ -2154,7 +2153,6 @@ pub mod pallet {
21542153 Self :: deposit_event ( Event :: ChangedRewardsAllowanceDHXForDateRemainingStored (
21552154 start_of_requested_date_millis. clone ( ) ,
21562155 rewards_allowance. clone ( ) ,
2157- _who. clone ( ) ,
21582156 1u8 , // increment
21592157 ) ) ;
21602158
@@ -2163,10 +2161,11 @@ pub mod pallet {
21632161 }
21642162
21652163 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
2164+ // only modifiable by governance as root rather than just any user
21662165 // parameter `change: u8` value may be 0 or 1 (or any other value) to represent that we want to make a
21672166 // corresponding decrease or increase to the remaining dhx rewards allowance for a given date.
21682167 pub fn change_rewards_allowance_dhx_for_date_remaining ( origin : OriginFor < T > , daily_rewards : BalanceOf < T > , timestamp : u64 , change : u8 ) -> DispatchResult {
2169- let _who = ensure_signed ( origin) ?;
2168+ let _who = ensure_root ( origin) ?;
21702169
21712170 let start_of_requested_date_millis = Self :: convert_u64_in_milliseconds_to_start_of_date ( timestamp. clone ( ) ) ?;
21722171
@@ -2216,62 +2215,85 @@ pub mod pallet {
22162215 Self :: deposit_event ( Event :: ChangedRewardsAllowanceDHXForDateRemainingStored (
22172216 start_of_requested_date_millis. clone ( ) ,
22182217 new_remaining_allowance_as_balance. clone ( ) ,
2219- _who. clone ( ) ,
22202218 change. clone ( ) ,
22212219 ) ) ;
22222220
22232221 // Return a successful DispatchResultWithPostInfo
22242222 Ok ( ( ) )
22252223 }
22262224
2225+ // only modifiable by governance as root rather than just any user
22272226 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
22282227 pub fn set_rewards_multiplier_operation ( origin : OriginFor < T > , operation : u8 ) -> DispatchResult {
2229- let _who = ensure_signed ( origin) ?;
2228+ let _who = ensure_root ( origin) ?;
22302229 <RewardsMultiplierOperation < T > >:: put ( & operation. clone ( ) ) ;
22312230 log:: info!( "set_rewards_multiplier_operation - operation: {:?}" , & operation) ;
22322231
22332232 // Emit an event.
22342233 Self :: deposit_event ( Event :: SetRewardsMultiplierOperationStored (
22352234 operation. clone ( ) ,
2236- _who. clone ( )
22372235 ) ) ;
22382236
22392237 // Return a successful DispatchResultWithPostInfo
22402238 Ok ( ( ) )
22412239 }
22422240
2241+ // only modifiable by governance as root rather than just any user
22432242 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
22442243 pub fn set_rewards_multiplier_default_period_days ( origin : OriginFor < T > , days : u32 ) -> DispatchResult {
2245- let _who = ensure_signed ( origin) ?;
2244+ let _who = ensure_root ( origin) ?;
22462245 <RewardsMultiplierDefaultPeriodDays < T > >:: put ( & days. clone ( ) ) ;
22472246 log:: info!( "set_rewards_multiplier_default_period_days - days: {:?}" , & days) ;
22482247
22492248 // Emit an event.
22502249 Self :: deposit_event ( Event :: SetRewardsMultiplierDefaultPeriodDaysStored (
22512250 days. clone ( ) ,
2252- _who. clone ( )
22532251 ) ) ;
22542252
22552253 // Return a successful DispatchResultWithPostInfo
22562254 Ok ( ( ) )
22572255 }
22582256
2257+ // only modifiable by governance as root rather than just any user
22592258 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
22602259 pub fn set_rewards_multiplier_next_period_days ( origin : OriginFor < T > , days : u32 ) -> DispatchResult {
2261- let _who = ensure_signed ( origin) ?;
2260+ let _who = ensure_root ( origin) ?;
22622261 <RewardsMultiplierNextPeriodDays < T > >:: put ( & days. clone ( ) ) ;
22632262 log:: info!( "set_rewards_multiplier_next_period_days - days: {:?}" , & days) ;
22642263
22652264 // Emit an event.
22662265 Self :: deposit_event ( Event :: SetRewardsMultiplierNextPeriodDaysStored (
22672266 days. clone ( ) ,
2268- _who. clone ( )
22692267 ) ) ;
22702268
22712269 // Return a successful DispatchResultWithPostInfo
22722270 Ok ( ( ) )
22732271 }
22742272
2273+ // extrinsic that governance may choose to call to set the mpower of an account for a date
2274+ // if it needs to be corrected in future before they claim
2275+ #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . writes( 1 ) ) ]
2276+ pub fn change_mpower_of_account_for_date ( origin : OriginFor < T > , account_id : Vec < u8 > , start_of_requested_date_millis : Date , mpower : u128 ) -> DispatchResult {
2277+ let _who = ensure_root ( origin) ?;
2278+
2279+ let mpower_current_u128 = mpower. clone ( ) ;
2280+
2281+ log:: info!( "change_mpower_of_account_for_date {:?} {:?} {:?}" ,
2282+ account_id. clone( ) ,
2283+ start_of_requested_date_millis. clone( ) ,
2284+ mpower_current_u128. clone( ) ,
2285+ ) ;
2286+
2287+ Self :: set_mpower_of_account_for_date (
2288+ account_id. clone ( ) ,
2289+ start_of_requested_date_millis. clone ( ) ,
2290+ mpower_current_u128. clone ( ) ,
2291+ ) ;
2292+
2293+ // Return a successful DispatchResultWithPostInfo
2294+ Ok ( ( ) )
2295+ }
2296+
22752297 // Off-chain workers
22762298
22772299 /// Submit new mPower data on-chain via unsigned transaction.
@@ -2561,9 +2583,6 @@ pub mod pallet {
25612583 Ok ( bonded_dhx_current_u128. clone ( ) )
25622584 }
25632585
2564- // TODO - this is an internal function, do we want to create an extrinsic too that
2565- // governance may choose to call to set the mpower of an account for a date if it needs to be corrected in future
2566- // before they claim?
25672586 pub fn set_mpower_of_account_for_date ( account_id : Vec < u8 > , start_of_requested_date_millis : Date , mpower : u128 ) -> Result < u128 , DispatchError > {
25682587 let mpower_current_u128 = mpower. clone ( ) ;
25692588
0 commit comments