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

Merge master #16

Merged
merged 57 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
641e7dd
Claims - Initial commit
green-jay Feb 5, 2021
5130045
Add initial implementation of the storage migration
pmensik Feb 6, 2021
0b8d8a3
Signature adjustments
green-jay Feb 7, 2021
59bae86
Add mock + tests
green-jay Feb 9, 2021
5d4d0e3
Transactional result, formatting, separate structs
green-jay Feb 10, 2021
5df5f51
store initial claims data
Roznovjak Feb 10, 2021
c682cab
Add multicurrency support + test
green-jay Feb 11, 2021
22a1470
Add benchmarking
green-jay Feb 12, 2021
9f7474b
Additional tests, fix utilities version
green-jay Feb 15, 2021
ee545b0
Update claims_data.rs
jak-pan Feb 15, 2021
5285fc5
Update chain_spec.rs
jak-pan Feb 15, 2021
ad887d0
Update chain_spec.rs
jak-pan Feb 15, 2021
ef6e1bc
Refactor to more generic names
green-jay Feb 16, 2021
7fb676e
add migration test
Roznovjak Feb 16, 2021
4eb6c30
always run workflow
mrq1911 Feb 18, 2021
d83d168
Merge master
jak-pan Feb 18, 2021
368aa75
fix clippy error
jak-pan Feb 18, 2021
d368b0d
fix clippy error
Roznovjak Feb 19, 2021
1272e0a
WIP - Multicurrency to Currency
green-jay Feb 23, 2021
f1d1fb3
Fix migration balance conversion
green-jay Feb 24, 2021
c3d160c
Fix formatting
green-jay Feb 24, 2021
39ab12b
cosmetics
green-jay Feb 24, 2021
3a55d71
migration test uses own test data
Roznovjak Feb 27, 2021
1ba072d
Merge branch 'master' into feature/claims
mrq1911 Mar 1, 2021
f5099dd
additional tests and update process_claim method
Roznovjak Mar 1, 2021
47dbcf0
additional tests
green-jay Mar 2, 2021
4d7979b
refactor: moved eth recover impl to signature representation
enthusiastmartin Mar 2, 2021
0ab65dd
refactor: split validation and claiming of a claim
enthusiastmartin Mar 2, 2021
819a9e1
feat: added signedextension for claim validity check
enthusiastmartin Mar 2, 2021
3363564
tests: added tests for claim signed ext
enthusiastmartin Mar 2, 2021
2291d7a
Merge pull request #123 from galacticcouncil/feat/claim_spam
green-jay Mar 2, 2021
d2f0570
PR prep
green-jay Mar 2, 2021
10bce61
add test seed to chain spec
green-jay Mar 2, 2021
d4927f9
add missing priv keys to test claims
Roznovjak Mar 2, 2021
c3541a0
tidy imports
green-jay Mar 2, 2021
dee0ef4
Merge branch 'master' into feature/claims
green-jay Mar 3, 2021
caec436
update claim amounts in tests
Roznovjak Mar 3, 2021
68248ed
Merge branch 'master' into feature/claims
mrq1911 Mar 5, 2021
2d7412c
added on runtime uprade - check of current storage version
enthusiastmartin Mar 6, 2021
a3a2451
comment out the storage of new version for now
enthusiastmartin Mar 6, 2021
028c4ab
fix migration trigger
mrq1911 Mar 6, 2021
775e6f3
bumped version to 3.0.0
mrq1911 Mar 6, 2021
4e42074
kill old storage key
mrq1911 Mar 6, 2021
22842d1
put empty set
mrq1911 Mar 6, 2021
ffee851
compare older version
mrq1911 Mar 6, 2021
95cd83d
actual claim data
jak-pan Mar 6, 2021
df97ce7
removed redundant import
mrq1911 Mar 7, 2021
ac45b0f
Merge pull request #130 from galacticcouncil/payment_migration
mrq1911 Mar 7, 2021
b999dd5
Merge branch 'master' into feature/claims
mrq1911 Mar 7, 2021
40da0a9
claims migration based on pallet version
mrq1911 Mar 7, 2021
99fdd12
Merge pull request #132 from galacticcouncil/claims_pallet_version
mrq1911 Mar 7, 2021
d0e89c2
Merge pull request #98 from galacticcouncil/feature/claims
jak-pan Mar 7, 2021
f198409
ci:add upload wasm runtime
mrq1911 Mar 7, 2021
24d0c7b
ci: add upload wasm runtime
mrq1911 Mar 7, 2021
9f292a4
Merge pull request #133 from galacticcouncil/ci-upload-wasm
mrq1911 Mar 7, 2021
de6af89
fix: benchmarking build fix
enthusiastmartin Mar 8, 2021
d75140f
Merge pull request #136 from galacticcouncil/fix/claim_benchmark
enthusiastmartin Mar 9, 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
8 changes: 7 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ jobs:
run: cd node && cargo test --release --features runtime-benchmarks -p pallet-exchange-benchmarking -p pallet-amm -p pallet-multi-payment-benchmarking
- name: Build release
run: time cargo build --release --verbose
- name: Upload release
- name: Upload release binary
uses: actions/upload-artifact@v2
with:
name: hydra-dx
path: target/release/hydra-dx
- name: Upload release wasm
uses: actions/upload-artifact@v2
with:
name: hydra_dx_runtime.wasm
path: target/release/wbuild/hydra-dx-runtime/hydra_dx_runtime.compact.wasm

32 changes: 30 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ targets = ['x86_64-unknown-linux-gnu']
substrate-build-script-utils = '2.0.1'

[dependencies]
hex-literal = "0.3.1"
jsonrpc-core = '15.0.0'
serde_json = "1.0.61"
structopt = '0.3.8'
Expand All @@ -33,6 +32,7 @@ primitives = {path = '../primitives', version = '2.0.0'}
frame-benchmarking = '2.0.0'
frame-benchmarking-cli = {version = '2.0.0', optional = true}
futures = '0.3.4'
hex-literal = "0.3.1"
pallet-im-online = "2.0.0"
pallet-staking = '2.0.0'
pallet-transaction-payment-rpc = '2.0.0'
Expand All @@ -53,6 +53,7 @@ sc-network = '0.8.0'
sc-rpc = '2.0.0'
sc-rpc-api = '0.8.0'
sc-service = '0.8.0'
sc-telemetry = '2.0.0'
sc-transaction-pool = '2.0.0'
sp-api = '2.0.0'
sp-authority-discovery = '2.0.0'
Expand All @@ -66,7 +67,6 @@ sp-inherents = '2.0.0'
sp-keystore = '0.8.0'
sp-runtime = '2.0.0'
sp-transaction-pool = '2.0.0'
sc-telemetry = '2.0.0'
substrate-frame-rpc-system = '2.0.0'

[features]
Expand Down
51 changes: 47 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![allow(clippy::or_fun_call)]

use hex_literal::hex;
use hydra_dx_runtime::constants::currency::{Balance, DOLLARS};
use hydra_dx_runtime::constants::currency::{Balance, DOLLARS, HDX};
use hydra_dx_runtime::opaque::SessionKeys;
use hydra_dx_runtime::pallet_claims::EthereumAddress;
use hydra_dx_runtime::{
AccountId, AssetRegistryConfig, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, CouncilConfig,
AccountId, AssetRegistryConfig, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ClaimsConfig, CouncilConfig,
ElectionsConfig, FaucetConfig, GenesisConfig, GrandpaConfig, ImOnlineConfig, Perbill, SessionConfig, Signature,
StakerStatus, StakingConfig, SudoConfig, SystemConfig, TokensConfig, CORE_ASSET_ID, WASM_BINARY,
};
Expand All @@ -16,10 +16,10 @@ use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
use sp_finality_grandpa::AuthorityId as GrandpaId;
use sp_runtime::traits::{IdentifyAccount, Verify};

use hex_literal::hex;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;

// The URL for the telemetry server.
const TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

Expand Down Expand Up @@ -367,6 +367,9 @@ fn testnet_genesis(
}),
pallet_elections_phragmen: Some(ElectionsConfig { members: vec![] }),
pallet_collective_Instance1: Some(CouncilConfig::default()),
pallet_claims: Some(ClaimsConfig {
claims: create_testnet_claims(),
}),
}
}

Expand Down Expand Up @@ -468,5 +471,45 @@ fn lerna_genesis(
}),
pallet_elections_phragmen: Some(ElectionsConfig { members: vec![] }),
pallet_collective_Instance1: Some(CouncilConfig::default()),
pallet_claims: Some(ClaimsConfig { claims: vec![] }),
}
}

fn create_testnet_claims() -> Vec<(EthereumAddress, Balance)> {
let mut claims = Vec::<(EthereumAddress, Balance)>::new();

// Alice's claim
// Signature: 0xbcae7d4f96f71cf974c173ae936a1a79083af7f76232efbf8a568b7f990eceed73c2465bba769de959b7f6ac5690162b61eb90949901464d0fa158a83022a0741c
// Message: "I hereby claim all my HDX tokens to wallet:d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
let claim_address_1 = (
// Test seed: "image stomach entry drink rice hen abstract moment nature broken gadget flash"
// private key (m/44'/60'/0'/0/0) : 0xdd75dd5f4a9e964d1c4cc929768947859a98ae2c08100744878a4b6b6d853cc0
EthereumAddress(hex!["8202C0aF5962B750123CE1A9B12e1C30A4973557"]),
HDX / 1_000,
);

// Bob's claim
// Signature: 0x60f3d2541b0ff09982f70844a7f645f4681cbbad2f138fee18404c932bd02cb738d577d53ce94cf067bae87a0b6fa1ec532ceea78d71f4e81a9c27193649c6291b
// Message: "I hereby claim all my HDX tokens to wallet:8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"
let claim_address_2 = (
// Test seed: "image stomach entry drink rice hen abstract moment nature broken gadget flash"
// private key (m/44'/60'/0'/0/1) : 0x9b5ef380c0a59008df32ba71ab3c7645950f986fc3f43fd4f9dffc8b2b4e7a5d
EthereumAddress(hex!["8aF7764663644989671A71Abe9738a3cF295f384"]),
HDX,
);

// Charlie's claim
// Signature: 0x52485aece74eb503fb998f0ca08bcc283fa731613db213af4e7fe153faed3de97ea0873d3889622b41d2d989a9e2a0bef160cff1ba8845875d4bc15431136a811c
// Message: "I hereby claim all my HDX tokens to wallet:90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22"
let claim_address_3 = (
// Test seed: "image stomach entry drink rice hen abstract moment nature broken gadget flash"
// private key (m/44'/60'/0'/0/2) : 0x653a29ac0c93de0e9f7d7ea2d60338e68f407b18d16d6ff84db996076424f8fa
EthereumAddress(hex!["C19A2970A13ac19898c47d59Cbd0278D428EBC7c"]),
1_000 * HDX,
);

claims.push(claim_address_1);
claims.push(claim_address_2);
claims.push(claim_address_3);
claims
}
65 changes: 65 additions & 0 deletions pallets/claims/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[package]
authors = ['GalacticCouncil']
description = 'HydraDX Claims Module'
edition = '2018'
homepage = 'https://github.com/galacticcouncil/hack.hydradx-node'
license = 'Unlicense'
name = 'pallet-claims'
repository = 'https://github.com/galacticcouncil/hack.hydradx-node'
version = '2.0.0'

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

# alias "parity-scale-code" to "codec"
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '1.3.4'

[dependencies]
# Substrate dependencies
frame-support = { default-features = false, version = '2.0.0' }
frame-system = { default-features = false, version = '2.0.0' }
frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
rustc-hex = { version = '2.1.0', default-features = false }
serde = { optional = true, version = '1.0.101', features = ['derive'] }
sp-io = { default-features = false, version = '2.0.0' }
sp-runtime = { default-features = false, version = '2.0.0' }
sp-std = { default-features = false, version = '2.0.0' }
hex = {default-features = false, version = "0.4.2"}
hex-literal = '0.3.1'
lazy_static = {features = ['spin_no_std'], version = "1.4.0"}

# Local dependencies
primitives = {path = '../../primitives', default-features = false, version = '2.0.0'}

# ORML dependencies
orml-traits = { default-features = false, version = '0.3.3-dev' }
orml-tokens = { default-features = false, version = '0.3.3-dev' }
orml-utilities = { default-features = false, version = '0.3.3-dev' }

[dev-dependencies]
sp-core = { default-features = false, version = '2.0.0' }
hex-literal = '0.3.1'
pallet-balances = { version = "2.0.0" }

[features]
default = ['std']
std = [
'codec/std',
'frame-support/std',
'frame-system/std',
'orml-traits/std',
'orml-tokens/std',
'orml-utilities/std',
'primitives/std',
'rustc-hex/std',
'serde/std',
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
38 changes: 38 additions & 0 deletions pallets/claims/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;

use codec::Decode;
use frame_benchmarking::benchmarks;
use frame_system::RawOrigin;
use hex_literal::hex;

benchmarks! {
_ {}

claim {
let alice_id = hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"];
let caller = T::AccountId::decode(&mut &alice_id[..]).unwrap_or_default();
let eth_address = EthereumAddress(hex!["8202c0af5962b750123ce1a9b12e1c30a4973557"]);
let signature = hex!["ef9816023122208983c11e596446874df3d400d2f9e380a831206d0e91bfb96d54db352fbd62d3cfa8d8674cf63e6a32052ef3cab038e1e7398eac3d048ed5181c"];
Claims::<T>::insert(eth_address, T::CurrencyBalance::from(1_000_000_000_000_000_000_u128));
}: _(RawOrigin::Signed(caller.clone()), EcdsaSignature(signature))
verify {
assert_eq!(T::Currency::free_balance(&caller), T::CurrencyBalance::from(2_152_921_504_606_846_975_u128).into());
}
}

#[cfg(test)]
mod tests {
use super::mock::Test;
use super::*;
use crate::tests::new_test_ext;
use frame_support::assert_ok;

#[test]
fn test_benchmarks() {
new_test_ext().execute_with(|| {
assert_ok!(test_benchmark_claim::<Test>());
});
}
}
Loading