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

Mainnet Runtime version: 358 #961

Merged
merged 49 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
951538a
Added simulator
zktony May 6, 2024
bc016cf
Add cargo 2021 edition
Gauthamastro May 6, 2024
cc8e376
Fixed formating
zktony May 8, 2024
7e1bb49
Fixed replace errors
zktony May 8, 2024
8a4abd7
cargo fmt
Gauthamastro May 9, 2024
3e3a053
rename simulator
Gauthamastro May 9, 2024
af0dfed
suppress clippy warnings
Gauthamastro May 9, 2024
703f44b
Merge branch 'refs/heads/Develop' into ksr/integrate-simulator
Gauthamastro May 9, 2024
07680ef
suppress clippy warnings
Gauthamastro May 9, 2024
e5dc323
Merge remote-tracking branch 'origin/ksr/integrate-simulator' into ks…
Gauthamastro May 9, 2024
1d0f422
fix cargo test
Gauthamastro May 9, 2024
94b0f4b
rename simulator crate
Gauthamastro May 9, 2024
ec1a610
cargo fmt
Gauthamastro May 9, 2024
8f669e1
Added simulator (#953)
Gauthamastro May 9, 2024
f97bfd7
Removing Old withdraw
Gauthamastro May 12, 2024
3eae0ec
Remove old withdraw fields
Gauthamastro May 12, 2024
1d55f79
Remove new keyword from Withdrawal type
Gauthamastro May 12, 2024
3a8a820
Added Logic for direct deposit, and sending PDEX to other parachains
Gauthamastro May 12, 2024
2196369
Add cross-chain withdrawal support.
Gauthamastro May 13, 2024
53e70fc
cargo fmt
Gauthamastro May 13, 2024
c42474a
Added log to find about index overflow
zktony May 13, 2024
b701e2d
Make pay with tokens true
Gauthamastro May 13, 2024
8be686c
Add ID for withdrawal
Gauthamastro May 13, 2024
3dbfc81
fix benchmarking
Gauthamastro May 13, 2024
b8ce3e8
fix cargo test
Gauthamastro May 13, 2024
9a29c8f
cargo fmt
Gauthamastro May 13, 2024
a401ab4
Pass the id from engine to thea
Gauthamastro May 14, 2024
e45c98b
Move CrossChainWithdraw trait to traits module
Gauthamastro May 14, 2024
bfc1c4b
Relay the Deposit ids via Ingress message
Gauthamastro May 14, 2024
3a79a67
cargo fmt
Gauthamastro May 14, 2024
9f27667
Added log to find about index overflow (#958)
Gauthamastro May 14, 2024
794b546
make it no-std
Gauthamastro May 14, 2024
13b9ca4
increment spec 352
Gauthamastro May 14, 2024
6a53ed9
Detect XCM direct deposit
Gauthamastro May 14, 2024
f46fe47
fix tests and benchmarks
Gauthamastro May 14, 2024
09bd718
fix tests
Gauthamastro May 14, 2024
d05f1a0
fix tests
Gauthamastro May 15, 2024
f5dff60
Add extra data to event
Gauthamastro May 16, 2024
57aa653
update docs on LMPConfig for market depth
Gauthamastro May 17, 2024
e6398c0
fix tests
Gauthamastro May 17, 2024
6046b3a
Direct Deposit/Withdrawal (#959)
Gauthamastro May 20, 2024
87fe13b
Make the incoming comparison using set instead of vec
Gauthamastro May 20, 2024
1fb8bc4
cargo fmt
Gauthamastro May 20, 2024
ad9ac48
Make the incoming comparison using set instead of vec (#960)
zktony May 22, 2024
7f61c7d
clear lmp storage
Gauthamastro May 22, 2024
aaddc02
fix snapshot process
Gauthamastro May 22, 2024
d97d068
cargo fmt
Gauthamastro May 22, 2024
7f9c81e
Fix tests
Gauthamastro May 22, 2024
f915583
cargo fmt
Gauthamastro May 22, 2024
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
300 changes: 187 additions & 113 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 2 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,10 @@ members = [
"pallets/xcm-helper",
"misc/load-testing",
"misc/crowdloan-verifier",
"polkadex-xcm-simulator",
]
exclude = ["scripts/check-off-on-deviation"]
default-members = [
"client",
"nodes/mainnet",
"nodes/parachain",
"runtimes/mainnet",
"runtimes/parachain",
"pallets/pdex-migration",
"pallets/pdex-migration",
"pallets/ocex",
"pallets/ocex/rpc",
"pallets/liquidity-mining",
"pallets/ocex/rpc/runtime-api",
"pallets/rewards",
"primitives/orderbook",
"primitives/polkadex",
"primitives/thea",
"primitives/bls",
"pallets/thea",
"pallets/thea-executor",
"pallets/rewards/rpc",
"pallets/rewards/rpc/runtime-api",
"rpc/swap",
]


[workspace.dependencies]
log = { version = "0.4.8", default-features = false }
Expand Down Expand Up @@ -133,7 +112,6 @@ pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
#pallet-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-statement = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion check-all-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ cargo build --features try-runtime || exit
cargo build --features runtime-benchmarks || exit
./target/debug/polkadex-node benchmark pallet --pallet "*" --extrinsic "*" --steps 2 --repeat 1 || exit
cargo clippy -- -D warnings || exit
RUSTFLAGS="-D warnings" cargo test || exit
RUSTFLAGS="-D warnings" cargo test --workspace || exit
1 change: 1 addition & 0 deletions pallets/liquidity-mining/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ impl ocex::Config for Test {
type CrowdSourceLiqudityMining = LiqudityMining;
type OBWithdrawalLimit = OBWithdrawalLimit;
type WeightInfo = ocex::weights::WeightInfo<Test>;
type CrossChainGadget = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions pallets/ocex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sp-io = { workspace = true }
pallet-lmp = { path = "../liquidity-mining", default-features = false }
lazy_static = "1.4.0"
sequential-test = "0.2.4"
hex = "0.4.3"

[features]
default = ["std"]
Expand Down
14 changes: 6 additions & 8 deletions pallets/ocex/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,9 @@ benchmarks! {
let proxy = account::<T::AccountId>("proxy", x, 0);
Ocex::<T>::register_main_account(RawOrigin::Signed(user.clone()).into(), proxy)?;
let call = Call::<T>::deposit { asset, amount };
let id = H160::zero();
}: { call.dispatch_bypass_filter(RawOrigin::Signed(user.clone()).into())? }
verify {
assert_last_event::<T>(Event::DepositSuccessful {
user,
asset,
amount
}.into());
}


remove_proxy_account {
let x in 1 .. 255; // should not overflow u8
Expand Down Expand Up @@ -285,12 +280,13 @@ benchmarks! {
let mut vec_withdrawals = Vec::with_capacity(1);
let fees = Decimal::new(100, 5);
vec_withdrawals.push(Withdrawal {
id: Default::default(),
amount: Decimal::new(x.into(), 0),
stid:0,
asset,
main_account: main.clone(),
fees,
});
destination: None,});
let mut wm = sp_std::collections::btree_map::BTreeMap::new();
wm.insert(main.clone(), vec_withdrawals.clone());
<Withdrawals<T>>::insert(x as u64, wm);
Expand Down Expand Up @@ -580,11 +576,13 @@ fn get_dummy_snapshot<T: Config>() -> SnapshotSummary<T::AccountId> {
);
for _ in 0..50 {
withdrawals.push(Withdrawal {
id: Default::default(),
main_account: T::AccountId::decode(&mut &[0u8; 32][..]).unwrap(),
amount: Decimal::one(),
asset: AssetId::Polkadex,
fees: Decimal::one(),
stid: 1,
destination: None,
});
}
SnapshotSummary {
Expand Down
78 changes: 13 additions & 65 deletions pallets/ocex/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use rust_decimal::Decimal;
use sequential_test::sequential;
use sp_core::crypto::AccountId32;
use sp_core::sr25519::Signature;
use sp_core::{Pair, H256};
use sp_core::{Pair, H160, H256};
use sp_runtime::offchain::storage::StorageValueRef;
use std::collections::BTreeMap;

Expand Down Expand Up @@ -84,66 +84,6 @@ fn test_run_on_chain_validation_trades_happy_path() {
});
}

#[test]
#[sequential]
fn test_lmp_complete_flow() {
new_test_ext().execute_with(|| {
set_lmp_config();
push_trade_user_actions(1, 1, 4768084);
assert_ok!(OCEX::run_on_chain_validation(1));
let snapshot_id: u64 = 1;
let mut key = LAST_PROCESSED_SNAPSHOT.to_vec();
key.append(&mut snapshot_id.encode());
let summay_ref = StorageValueRef::persistent(&key);
match summay_ref
.get::<(SnapshotSummary<AccountId32>, crate::sr25519::AuthoritySignature, u16)>()
{
Ok(Some((summary, signature, index))) => {
println!("Summary {:?}", summary);
assert_eq!(summary.snapshot_id, 1);
assert_eq!(summary.state_change_id, 1);
assert_eq!(summary.last_processed_blk, 4768084);
assert_ok!(OCEX::submit_snapshot(RuntimeOrigin::none(), summary, Vec::new()));
},
_ => panic!("Snapshot not found"),
};
OCEX::start_new_epoch(2);
push_trade_user_actions(2, 1, 4768085);
let s_info = StorageValueRef::persistent(&WORKER_STATUS);
s_info.set(&false);
assert_ok!(OCEX::run_on_chain_validation(2));
let snapshot_id: u64 = 2;
let mut key = LAST_PROCESSED_SNAPSHOT.to_vec();
key.append(&mut snapshot_id.encode());
let summay_ref = StorageValueRef::persistent(&key);
match summay_ref
.get::<(SnapshotSummary<AccountId32>, crate::sr25519::AuthoritySignature, u16)>()
{
Ok(Some((summary, signature, index))) => {
println!("Summary {:?}", summary);
assert_eq!(summary.snapshot_id, 2);
assert_eq!(summary.state_change_id, 2);
assert_eq!(summary.last_processed_blk, 4768085);
assert_ok!(OCEX::submit_snapshot(RuntimeOrigin::none(), summary, Vec::new()));
},
_ => panic!("Snapshot not found"),
};
OCEX::start_new_epoch(3);
let (maker_account, taker_account) = get_maker_and_taker_account();
let trading_pair = TradingPair { base: AssetId::Polkadex, quote: AssetId::Asset(1) };
assert_ok!(OCEX::claim_lmp_rewards(
RuntimeOrigin::signed(maker_account.clone()),
1,
trading_pair
));
assert_ok!(OCEX::claim_lmp_rewards(
RuntimeOrigin::signed(taker_account.clone()),
1,
trading_pair
));
})
}

#[test]
#[sequential]
fn test_on_chain_validation_with_auction() {
Expand Down Expand Up @@ -321,10 +261,18 @@ fn push_trade_user_actions(stid: u64, snapshot_id: u64, block_no: u64) {
fn get_block_import(block_no: u64) -> u64 {
let block_no = block_no;
let (maker_account, taker_account) = get_maker_and_taker_account();
let maker_ingress_message =
IngressMessages::Deposit(maker_account, AssetId::Asset(1), Decimal::from(100));
let taker_ingress_message =
IngressMessages::Deposit(taker_account, AssetId::Polkadex, Decimal::from(100));
let maker_ingress_message = IngressMessages::Deposit(
H160::zero(),
maker_account,
AssetId::Asset(1),
Decimal::from(100),
);
let taker_ingress_message = IngressMessages::Deposit(
H160::zero(),
taker_account,
AssetId::Polkadex,
Decimal::from(100),
);
<IngressMessagesStorage<Test>>::insert(
block_no,
vec![maker_ingress_message, taker_ingress_message],
Expand Down
Loading
Loading