Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MMD-1309 10-to-1 - Off-chain workers #238

Draft
wants to merge 37 commits into
base: luke/rewards-allowance-new
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a849024
comment out println
ltfschoen Oct 22, 2021
a58164f
refactor dependencies
ltfschoen Oct 22, 2021
2ce1c14
wip
ltfschoen Oct 26, 2021
a7bb57c
wip
ltfschoen Nov 5, 2021
f3c2e33
wip - unable to use serde_json
ltfschoen Nov 5, 2021
dba8e71
wip
ltfschoen Nov 6, 2021
edd9734
Update pallets/mining/rewards-allowance/src/lib.rs
ltfschoen Nov 8, 2021
88500f3
wip
ltfschoen Nov 8, 2021
df24da1
wip - api response acct_id stored as Vec<u8> string to represent publ…
ltfschoen Nov 9, 2021
f7c362e
wip - adding mpower from API works. fixing tests
ltfschoen Nov 9, 2021
e52f252
try to fix tests. remove block number and date received from SetMPowe…
ltfschoen Nov 10, 2021
9ad33cd
fix mock using offchain_workers
ltfschoen Nov 11, 2021
75631cc
wip - move from on_initialize into offchain_worker and refactor
ltfschoen Nov 15, 2021
3653ab2
wip
ltfschoen Nov 15, 2021
ca94095
convert AccountId to Vec<u8> for storing accounts
ltfschoen Nov 24, 2021
32ac4b9
interpolate the start of current date into the api http request url p…
ltfschoen Nov 24, 2021
1deca20
wip
ltfschoen Nov 25, 2021
d4d5d6e
add extrinsic change_mpower_of_account_for_date. change to ensure_roo…
ltfschoen Nov 25, 2021
86cab12
only storage mpower for account for date from api if that account/dat…
ltfschoen Nov 25, 2021
be9828c
wip
ltfschoen Nov 26, 2021
15eafe9
convert Vec<u8> to T::AccountId
ltfschoen Nov 26, 2021
b732e51
wip - fix challenge period
ltfschoen Dec 2, 2021
18f919a
wip
ltfschoen Dec 2, 2021
28e6955
fix
ltfschoen Dec 2, 2021
d4280c8
wip
ltfschoen Dec 2, 2021
3076eda
wip
ltfschoen Dec 9, 2021
d99afd4
wip
ltfschoen Dec 9, 2021
cce66c0
fix linting from past couple of commits
ltfschoen Dec 9, 2021
b75288c
wip - fix so not early exit if RewardsEligibleMinersForDate not exist
ltfschoen Dec 9, 2021
c0c8a04
wip - remove ignored tests, restore some more tests that work again now
ltfschoen Dec 9, 2021
0fbd3ec
all tests working again using off-chain workers now
ltfschoen Dec 10, 2021
1171540
change to min. mpower of 1
ltfschoen Dec 10, 2021
49c8908
wip
ltfschoen Dec 14, 2021
897494a
wip
ltfschoen Dec 20, 2021
7b8c7e0
wip
ltfschoen Dec 20, 2021
eadb462
wip
ltfschoen Dec 20, 2021
1e9585f
wip
ltfschoen Jan 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 46 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 52 additions & 16 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ fn testnet_genesis(
rewards_allowance_dhx_daily: FIVE_THOUSAND, // 5000 DHX
rewards_allowance_dhx_for_date_remaining: Default::default(),
rewards_allowance_dhx_for_date_remaining_distributed: Default::default(),
rewards_allowance_dhx_for_miner_for_date_remaining_distributed: Default::default(),
rewards_multiplier_paused: false,
rewards_multiplier_reset: false,
rewards_multiplier_default_change: 10u32,
Expand All @@ -933,20 +934,37 @@ fn testnet_genesis(
rewards_multiplier_current_period_days_remaining: Default::default(),
rewards_multiplier_operation: 1u8,
registered_dhx_miners: vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
// get_account_id_from_seed::<sr25519::Public>("Alice"),
// get_account_id_from_seed::<sr25519::Public>("Bob"),
// get_account_id_from_seed::<sr25519::Public>("Charlie"),
// Alice
vec![212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125],
// Bob
vec![142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144, 156, 178, 38, 170, 71, 148, 242, 106, 72],
],
rewards_eligible_miners_for_date: Default::default(),
rewards_aggregated_dhx_for_all_miners_for_date: Default::default(),
rewards_accumulated_dhx_for_miner_for_date: Default::default(),
min_bonded_dhx_daily: TEN, // 10 DHX
min_bonded_dhx_daily_default: TEN, // 10 DHX
min_mpower_daily: 5u128,
min_mpower_daily_default: 5u128,
cooling_off_period_days: 7u32,
cooling_off_period_days_remaining: vec![
min_mpower_daily: 1u128,
min_mpower_daily_default: 1u128,
challenge_period_days: 7u64,
cooling_down_period_days: 7u32,
cooling_down_period_days_remaining: vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
// get_account_id_from_seed::<sr25519::Public>("Alice").encode(),
// Alice
vec![212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125],
(
0,
7u32,
0u32,
),
),
(
// Bob
vec![142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144, 156, 178, 38, 170, 71, 148, 242, 106, 72],
(
0,
7u32,
Expand Down Expand Up @@ -1051,6 +1069,7 @@ fn mainnet_genesis(
rewards_allowance_dhx_daily: FIVE_THOUSAND, // 5000 DHX
rewards_allowance_dhx_for_date_remaining: Default::default(),
rewards_allowance_dhx_for_date_remaining_distributed: Default::default(),
rewards_allowance_dhx_for_miner_for_date_remaining_distributed: Default::default(),
rewards_multiplier_paused: false,
rewards_multiplier_reset: false,
rewards_multiplier_default_change: 10u32,
Expand All @@ -1062,20 +1081,37 @@ fn mainnet_genesis(
rewards_multiplier_current_period_days_remaining: Default::default(),
rewards_multiplier_operation: 1u8,
registered_dhx_miners: vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
// get_account_id_from_seed::<sr25519::Public>("Alice"),
// get_account_id_from_seed::<sr25519::Public>("Bob"),
// get_account_id_from_seed::<sr25519::Public>("Charlie"),
// Alice
vec![212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125],
// Bob
vec![142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144, 156, 178, 38, 170, 71, 148, 242, 106, 72],
],
rewards_eligible_miners_for_date: Default::default(),
rewards_aggregated_dhx_for_all_miners_for_date: Default::default(),
rewards_accumulated_dhx_for_miner_for_date: Default::default(),
min_bonded_dhx_daily: TEN, // 10 DHX
min_bonded_dhx_daily_default: TEN, // 10 DHX
min_mpower_daily: 5u128,
min_mpower_daily_default: 5u128,
cooling_off_period_days: 7u32,
cooling_off_period_days_remaining: vec![
min_mpower_daily: 1u128,
min_mpower_daily_default: 1u128,
challenge_period_days: 7u64,
cooling_down_period_days: 7u32,
cooling_down_period_days_remaining: vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
// get_account_id_from_seed::<sr25519::Public>("Alice").encode(),
// Alice
vec![212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125],
(
0,
7u32,
0u32,
),
),
(
// Bob
vec![142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144, 156, 178, 38, 170, 71, 148, 242, 106, 72],
(
0,
7u32,
Expand Down
12 changes: 10 additions & 2 deletions pallets/mining/rewards-allowance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ targets = ['x86_64-unknown-linux-gnu']
default = ['std']
std = [
'chrono/std',
'hex/std',
# 'hex-literal/std',
'lite-json/std',
'log/std',
'serde/std',
# 'serde/std',
'rand/std',
'substrate-fixed/std',
'codec/std',
Expand All @@ -34,6 +37,7 @@ std = [
'sp-consensus-aura/std',
'sp-core/std',
'sp-io/std',
'sp-keystore/std',
'sp-runtime/std',
'sp-std/std',
'module-primitives/std',
Expand All @@ -42,8 +46,11 @@ std = [
[dependencies]
static_assertions = '1.1.0'
chrono = { version = '0.4.19', default_features = false }
hex = { version = '0.4.3', default_features = false, features = ['alloc'] }
hex-literal = { version = '0.3.1', default_features = false }
lite-json = { version = "0.1", default-features = false }
log = { version = '0.4.14', default-features = false }
serde = { version = '1.0.126', features = ['derive'] }
# serde = { version = '1.0.126', default-features = false, features = ['derive'] }
rand = { version = '0.8.4', default-features = false }
substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", version = '0.5.6' }
codec = { version = '2.2.0', package = 'parity-scale-codec', default-features = false, features = ['derive', 'max-encoded-len'] }
Expand All @@ -65,6 +72,7 @@ pallet-treasury = { git = 'https://github.com/DataHighway-DHX/substrate', rev =
sp-consensus-aura = { git = 'https://github.com/DataHighway-DHX/substrate', rev = 'f5dc02a8a491c149fba05a2a5a51c80ce1b3cead', default-features = false }
sp-core = { git = 'https://github.com/DataHighway-DHX/substrate', rev = 'f5dc02a8a491c149fba05a2a5a51c80ce1b3cead', default-features = false }
sp-io = { git = 'https://github.com/DataHighway-DHX/substrate', rev = 'f5dc02a8a491c149fba05a2a5a51c80ce1b3cead', default-features = false }
sp-keystore = { git = 'https://github.com/DataHighway-DHX/substrate', rev = 'f5dc02a8a491c149fba05a2a5a51c80ce1b3cead', default-features = false, optional = true }
sp-runtime = { git = 'https://github.com/DataHighway-DHX/substrate', rev = 'f5dc02a8a491c149fba05a2a5a51c80ce1b3cead', default-features = false }
sp-std = { git = 'https://github.com/DataHighway-DHX/substrate', rev = 'f5dc02a8a491c149fba05a2a5a51c80ce1b3cead', default-features = false }
module-primitives = { version = '3.0.6', default-features = false, path = '../../primitives' }
Expand Down