Skip to content

feat: MMD-720 Supernode as proxy for reward requests on behalf of their miners #137

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

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c32da02
wip
ltfschoen Mar 6, 2021
042544e
restore nonsense
ltfschoen Mar 6, 2021
ea5e0ca
wip ensure
ltfschoen Mar 6, 2021
b15cd84
finish ensures
ltfschoen Mar 6, 2021
c13e2d3
lint
ltfschoen Mar 6, 2021
ab47d3a
add treasury tx to supernode requestor
ltfschoen Mar 7, 2021
e5698ee
configure pallet_members so only Sudo may modify endpoints
ltfschoen Mar 8, 2021
1646b42
add membership pallet
ltfschoen Mar 8, 2021
8240fac
temporarily remove submitting data to try compile
ltfschoen Mar 9, 2021
af995b1
wip
ltfschoen Mar 9, 2021
7abe376
wip
ltfschoen Mar 9, 2021
a5c0f85
add reason for using loose coupling
ltfschoen Mar 9, 2021
2a40ae1
remove supernode membership
ltfschoen Mar 10, 2021
73eecfa
add vec-set as membership-supernodes from substrate recipes loose
ltfschoen Mar 10, 2021
5639b56
wip with errors
ltfschoen Mar 10, 2021
f14cbb0
fix version
ltfschoen Mar 10, 2021
dcdc40b
finished loosely coupled member_supernodes
ltfschoen Mar 10, 2021
b5e2431
lint
ltfschoen Mar 10, 2021
a6dff2a
modify vec-set membership-supernodes pallet to accept and accountid t…
ltfschoen Mar 10, 2021
3abcae1
wip
ltfschoen Mar 10, 2021
e945964
compiles
ltfschoen Mar 11, 2021
74d9787
try serialize
ltfschoen Mar 11, 2021
87d810b
disable json serialise as not working
ltfschoen Mar 11, 2021
0d04a99
temporarily comment tests for eligibility proxy until update to Subst…
ltfschoen Mar 11, 2021
3010a34
restore code from prev. commit
ltfschoen Mar 11, 2021
8eb3efc
fix use of treasury in tests using TenToFourteen
ltfschoen Mar 11, 2021
7d06ad7
add tests for requesting rewards for members of supernode membership
ltfschoen Mar 11, 2021
d03d462
make it so only the root origin may call add_member and remove_member…
ltfschoen Mar 12, 2021
8617914
lint
ltfschoen Mar 12, 2021
b68cd5d
try to test that member supernode received treasury funds using last_…
ltfschoen Mar 12, 2021
4cb208a
restore tests without checking events but still don't pass
ltfschoen Mar 12, 2021
850c052
disable ensure_root as can't make any memberSupernodes calls even wi…
ltfschoen Mar 12, 2021
845f16e
creates when call proxy_eligibility_claim function all at once
ltfschoen Mar 12, 2021
e4d5754
wip - need update to Substrate 3 for treasury instantiable support
ltfschoen Mar 13, 2021
760e7fa
error trait Wraps not implemented for AccountId
ltfschoen Mar 15, 2021
2f444bb
only allow Sudo to add/remove members of memberSupernodes
ltfschoen Mar 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ substrate-module-new <module-name> <author>
* Answer:
* Try using a different web browser. Brave may not work, however Chrome might. Try running Polkadot.js app locally instead. See https://stackoverflow.com/questions/45572440/how-to-access-an-insecure-websocket-from-a-secure-website

* Question: Why is loose coupling important?
* Answer: Because sometimes things just won't work [see example here](https://matrix.to/#/!HzySYSaIhtyWrwiwEV:matrix.org/$161531016088601OZAjp:matrix.parity.io?via=matrix.parity.io&via=matrix.org&via=corepaper.org)
* Substrate Seminar example https://youtu.be/VVU3Io2dACY?t=4425

## Technical Support <a id="chapter-c00ab7"></a>

* [Discord Chat](https://discord.gg/UuZN2tE)
Expand Down
65 changes: 65 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [
'pallets/roaming/roaming-billing-policies',
'pallets/roaming/roaming-charging-policies',
'pallets/roaming/roaming-packet-bundles',
'pallets/membership/supernodes',
'pallets/mining/config/token',
'pallets/mining/config/hardware',
'pallets/mining/rates/token',
Expand All @@ -29,5 +30,6 @@ members = [
'pallets/mining/eligibility/hardware',
'pallets/mining/claims/token',
'pallets/mining/claims/hardware',
'pallets/treasury/dao',
'runtime',
]
166 changes: 166 additions & 0 deletions chain_spec_dev.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions custom_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@
"hardware_block_audited": "Moment",
"hardware_auditor_account_id": "u64"
},
"MiningEligibilityProxy": "[u8; 16]",
"MiningEligibilityProxyIndex": "u64",
"MiningEligibilityProxyResult": {
"proxy_claim_requestor_account_id": "u64",
"proxy_claim_total_reward_amount": "u32",
"proxy_claim_rewardees_data": "Vec<RewardeeData>",
"proxy_claim_block_redeemed": "u64"
},
"RewardeeData": {
"proxy_claim_rewardee_account_id": "u64",
"proxy_claim_reward_amount": "u32",
"proxy_claim_start_block": "u64",
"proxy_claim_interval_blocks": "u64"
},
"MiningClaimsToken": "[u8; 16]",
"MiningClaimsTokenIndex": "u64",
"MiningClaimsTokenClaimAmount": "u64",
Expand Down
54 changes: 41 additions & 13 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,31 @@ impl Alternative {
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
// DHX DAO Unlocked Reserves Balance
// Given a Treasury ModuleId in runtime parameter_types of
// `py/trsry`, we convert that to its associated address
// using Module ID" to Address" at https://www.shawntabrizi.com/substrate-js-utilities/,
// which generates 5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z,
// and find its corresponding hex value by pasting the address into
// "AccountId to Hex" at that same link to return
// 6d6f646c70792f74727372790000000000000000000000000000000000000000.
// This is pallet_treasury's account_id.
//
// FIXME - unfortunately we can't get this to work without updating to
// Substrate 3 since earlier versions didn't allow instantiable
// support for treasury module
// https://github.com/paritytech/substrate/pull/7058/files
hex!["6d6f646c70792f74727372790000000000000000000000000000000000000000"].into(),
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>("Dave"),
// Required otherwise get error when compiling
// `Stash does not have enough balance to bond`
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
],
true,
)
Expand Down Expand Up @@ -156,8 +177,8 @@ impl Alternative {
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
// DHX DAO Unlocked Reserves Balance
// 5FmxcuFwGK7kPmQCB3zhk3HtxxJUyb3WjxosF8jvnkrVRLUG
hex!["a42b7518d62a942344fec55d414f1654bf3fd325dbfa32a3c30534d5976acb21"].into(),
// 5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z
hex!["6d6f646c70792f74727372790000000000000000000000000000000000000000"].into(),
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
Expand Down Expand Up @@ -211,8 +232,8 @@ impl Alternative {
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
// Endow this account with the DHX DAO Unlocked Reserves Balance
// 5FmxcuFwGK7kPmQCB3zhk3HtxxJUyb3WjxosF8jvnkrVRLUG
hex!["a42b7518d62a942344fec55d414f1654bf3fd325dbfa32a3c30534d5976acb21"].into(),
// 5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z
hex!["6d6f646c70792f74727372790000000000000000000000000000000000000000"].into(),
// Endow these accounts with a balance so they may bond as authorities
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
Expand Down Expand Up @@ -360,15 +381,22 @@ fn dev_genesis(
indices: endowed_accounts.iter().enumerate().map(|(index, x)| (index as u32, (*x).clone())).collect(),
}),
pallet_balances: Some(BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|x|
// Insert Public key (hex) of the account without the 0x prefix below
if x == UncheckedFrom::unchecked_from(hex!("a42b7518d62a942344fec55d414f1654bf3fd325dbfa32a3c30534d5976acb21").into()) {
(x, INITIAL_DHX_DAO_TREASURY_UNLOCKED_RESERVES_BALANCE)
} else {
(x, INITIAL_BALANCE)
}
)
.collect(),
balances: endowed_accounts
.iter()
.cloned()
.map(|x| {
// Insert Public key (hex) of the account without the 0x prefix below
if x == UncheckedFrom::unchecked_from(
hex!("6d6f646c70792f74727372790000000000000000000000000000000000000000").into(),
) {
println!("endowed_account treasury {:?}", x.clone());
return (x, INITIAL_DHX_DAO_TREASURY_UNLOCKED_RESERVES_BALANCE);
} else {
println!("endowed_account {:?}", x.clone());
return (x, INITIAL_BALANCE);
}
})
.collect(),
}),
pallet_session: Some(SessionConfig {
keys: initial_authorities
Expand Down
2 changes: 1 addition & 1 deletion pallets/exchange-rate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std = [
]

[dependencies]
codec = { version = '1.2.0', package = 'parity-scale-codec', default-features = false, features = ['derive'] }
codec = { version = '1.3.0', package = 'parity-scale-codec', default-features = false, features = ['derive'] }
safe-mix = { version = '1.0.0', default-features = false }
frame-support = { version = '2.0.0', default_features = false }
frame-system = { version = '2.0.0', default_features = false }
Expand Down
2 changes: 1 addition & 1 deletion pallets/lockdrop/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
web3 = "0.13.0"
codec = { version = '1.2.0', package = 'parity-scale-codec', default-features = false, features = ['derive'] }
codec = { version = '1.3.0', package = 'parity-scale-codec', default-features = false, features = ['derive'] }
safe-mix = { version = '1.0.0', default-features = false }
frame-support = { version = '2.0.0', default_features = false }
frame-system = { version = '2.0.0', default_features = false }
Expand Down
42 changes: 42 additions & 0 deletions pallets/membership/supernodes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
name = "membership-supernodes"
version = "2.0.0"
edition = "2018"
repository = 'https://github.com/substrate-developer-hub/recipes'
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
description = "Fork of Substrate Recipe pallet vec-set. A pallet that implements a storage Set on top of a Vec"
license = "GPL-3.0-or-later"

[package.metadata.substrate]
categories = [
"pallet",
"tutorial",
"recipe",
]
compatibility_version = "2.0.0"

[dependencies]
codec = { version = '1.3.0', package = 'parity-scale-codec', default-features = false, features = ['derive'] }

# Substrate packages
frame-support = { version = '2.0.0', default-features = false }
frame-system = { version = '2.0.0', default-features = false }
sp-runtime = { version = '2.0.0', default-features = false }
sp-std = { version = '2.0.0', default-features = false }

# local packages
account-set = { path = '../../../traits/account-set', default-features = false }

[dev-dependencies]
sp-core = { version = '2.0.0', default-features = false }
sp-io = { version = '2.0.0', default-features = false }

[features]
default = ['std']
std = [
'account-set/std',
'codec/std',
'frame-support/std',
'frame-system/std',
'sp-runtime/std',
]
Loading