Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
5b16e2e
upgrade dependencies and partially fix build
Roznovjak Dec 16, 2024
e0b2c25
use associated type in registry::Inspect
Roznovjak Dec 16, 2024
5a0cf93
additional changes with associated type in registry::Inspect
Roznovjak Dec 16, 2024
0b505d1
Revert "additional changes with associated type in registry::Inspect"
Roznovjak Dec 17, 2024
19ad0c8
Revert "use associated type in registry::Inspect"
Roznovjak Dec 17, 2024
43b927e
update polkadot-sdk dependencies in lock
Roznovjak Dec 23, 2024
b0ba467
fix build
Roznovjak Dec 27, 2024
75feac7
fix tests
Roznovjak Dec 27, 2024
d8d608a
formatting
Roznovjak Dec 27, 2024
721c0cd
satisfy clippy
Roznovjak Dec 27, 2024
bd0da79
satisfy clippy
Roznovjak Dec 27, 2024
13c1afc
Merge branch 'master' into polkadot-stable2409
Roznovjak Dec 30, 2024
5fbafb2
satisfy clippy
Roznovjak Dec 30, 2024
02ab05b
formatting
Roznovjak Jan 2, 2025
a4cebbc
fix some integration tests
Roznovjak Jan 2, 2025
3e03131
fix integration tests
Roznovjak Jan 3, 2025
cc93aa4
formatting
Roznovjak Jan 3, 2025
0557cd0
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 6, 2025
f043713
add migration for xcmp queue pallet
Roznovjak Jan 7, 2025
2c6dd99
change consensus hook
Roznovjak Jan 7, 2025
99c36b3
formatting
Roznovjak Jan 7, 2025
1c3699b
add migration for AccountCodesMetadata
Roznovjak Jan 8, 2025
153c4b7
rebenchmarking
Roznovjak Jan 9, 2025
89aa12e
rebenchmark router
Roznovjak Jan 9, 2025
4df0864
rebenchmark dca and otc-settlements
Roznovjak Jan 9, 2025
476aff0
fix integration tests mock
Roznovjak Jan 13, 2025
960eb0e
formatting
Roznovjak Jan 13, 2025
98ac246
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 13, 2025
b9c0dad
formatting
Roznovjak Jan 13, 2025
f94de7f
satisfy clippy
Roznovjak Jan 14, 2025
4edf6b0
add benchmarking feature in adapters
Roznovjak Jan 14, 2025
b9dffbc
Revert "add benchmarking feature in adapters"
Roznovjak Jan 14, 2025
d0b4ace
add missing benchmarking feature
Roznovjak Jan 15, 2025
67b97b0
implement quote_exchange_price
Roznovjak Jan 16, 2025
bb621ff
formatting
Roznovjak Jan 16, 2025
13f1119
satisfy clippy
Roznovjak Jan 16, 2025
c159d8d
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 16, 2025
c57b2c6
rebenchmarking
Roznovjak Jan 17, 2025
872bc63
rebenchmark router pallet
Roznovjak Jan 17, 2025
3433a14
rebenchmark dca and otc-settlements
Roznovjak Jan 17, 2025
7b974bf
bump crate versions
Roznovjak Jan 17, 2025
322e314
revert change in evm integration tests
Roznovjak Jan 20, 2025
8875c58
formatting
Roznovjak Jan 20, 2025
20bb86d
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 20, 2025
8c1b9b2
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 20, 2025
0213f01
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 20, 2025
6cdbfe4
fix cargo lock file
Roznovjak Jan 21, 2025
f4386ff
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 22, 2025
6cacc60
bump crate versions
Roznovjak Jan 22, 2025
a359468
remove duplicate imports
Roznovjak Jan 22, 2025
0c2e2fc
Merge branch 'master' into polkadot-stable2409
Roznovjak Jan 23, 2025
59c7e17
Merge branch 'master' into polkadot-stable2409
Roznovjak Feb 1, 2025
fad3891
resolve comments from the review
Roznovjak Feb 3, 2025
aee1d0e
formatting
Roznovjak Feb 3, 2025
7408a0e
bump runtime version
Roznovjak Feb 3, 2025
b82bdc7
Merge branch 'master' into polkadot-stable2409
Roznovjak Feb 7, 2025
f6e7cd9
fix errors in weight files
Roznovjak Feb 7, 2025
e66e8dd
rebenchmark some pallets
Roznovjak Feb 7, 2025
82f7c58
Merge branch 'master' into polkadot-stable2409
Roznovjak Feb 10, 2025
fd92cc4
fix benchmarking build
Roznovjak Feb 10, 2025
4b485d9
rebenchmark lbp
Roznovjak Feb 10, 2025
2c21310
rebenchmark router
Roznovjak Feb 10, 2025
b331d46
rebenchmark dca and omnipool
Roznovjak Feb 10, 2025
85fbdc1
bump crate versions
Roznovjak Feb 10, 2025
75d1be5
fix integration tests
Roznovjak Feb 10, 2025
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,202 changes: 1,992 additions & 2,210 deletions Cargo.lock

Large diffs are not rendered by default.

1,007 changes: 503 additions & 504 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ format:
.PHONY: try-runtime
try-runtime:
$(cargo) build --release --features try-runtime
try-runtime --runtime ./target/release/wbuild/hydradx-runtime/hydradx_runtime.wasm on-runtime-upgrade --blocktime 12000 --checks all live --uri wss://archive.rpc.hydration.cloud
try-runtime --runtime ./target/release/wbuild/hydradx-runtime/hydradx_runtime.wasm on-runtime-upgrade --checks all live --uri wss://archive.rpc.hydration.cloud

.PHONY: build-docs
build-docs:
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.33.0"
version = "1.33.1"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
Binary file modified integration-tests/evm-snapshot/SNAPSHOT
Binary file not shown.
44 changes: 15 additions & 29 deletions integration-tests/src/contracts.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
use crate::evm::dai_ethereum_address;
use crate::polkadot_test_net::Hydra;
use crate::polkadot_test_net::TestNet;
use crate::polkadot_test_net::ALICE;
use crate::polkadot_test_net::BOB;
use crate::polkadot_test_net::UNITS;
use crate::polkadot_test_net::WETH;
use crate::utils::contracts::deploy_contract;
use crate::utils::contracts::deploy_contract_code;
use crate::utils::contracts::get_contract_bytecode;
use fp_evm::ExitReason::Succeed;
use fp_evm::ExitSucceed::Stopped;
use fp_evm::FeeCalculator;
use crate::polkadot_test_net::{Hydra, TestNet, ALICE, BOB, UNITS, WETH};
use crate::utils::contracts::{deploy_contract, deploy_contract_code, get_contract_bytecode};
use fp_evm::{ExitReason::Succeed, ExitSucceed::Stopped, FeeCalculator};
use frame_support::assert_ok;
use hex_literal::hex;
use hydradx_runtime::evm::precompiles::handle::EvmDataWriter;
use hydradx_runtime::evm::precompiles::Bytes;
use hydradx_runtime::evm::Executor;
use hydradx_runtime::AccountId;
use hydradx_runtime::EVMAccounts;
use hydradx_runtime::Runtime;
use hydradx_runtime::RuntimeEvent;
use hydradx_runtime::System;
use hydradx_traits::evm::CallContext;
use hydradx_traits::evm::EvmAddress;
use hydradx_traits::evm::InspectEvmAccounts;
use hydradx_traits::evm::EVM;
use hydradx_runtime::{
evm::{
precompiles::{handle::EvmDataWriter, Bytes},
Executor,
},
AccountId, EVMAccounts, Runtime, RuntimeEvent, System,
};
use hydradx_traits::evm::{CallContext, EvmAddress, InspectEvmAccounts, EVM};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use pretty_assertions::assert_eq;
use sp_core::H256;
use sp_core::{RuntimeDebug, U256};
use sp_core::{RuntimeDebug, H256, U256};
use test_utils::expect_events;
use xcm_emulator::Network;
use xcm_emulator::TestExt;
use xcm_emulator::{Network, TestExt};

pub fn deployer() -> EvmAddress {
EVMAccounts::evm_address(&Into::<AccountId>::into(ALICE))
Expand Down Expand Up @@ -107,7 +92,7 @@ fn contract_check_fails_on_precompile_without_code() {
TestNet::reset();
Hydra::execute_with(|| {
let checker = deploy_contract("ContractCheck", deployer());
pallet_evm::AccountCodes::<Runtime>::remove(dai_ethereum_address());
pallet_evm::Pallet::<Runtime>::remove_account(&dai_ethereum_address());
assert_eq!(is_contract(checker, dai_ethereum_address()), false);
});
}
Expand All @@ -117,6 +102,7 @@ fn contract_check_succeeds_on_precompile_with_invalid_code() {
TestNet::reset();
Hydra::execute_with(|| {
let checker = deploy_contract("ContractCheck", deployer());
// The code is invalid, but we intentionally set account codes of registered assets to 0.
pallet_evm::AccountCodes::<Runtime>::insert(dai_ethereum_address(), &hex!["00"][..]);
assert_eq!(is_contract(checker, dai_ethereum_address()), true);
});
Expand Down
5 changes: 1 addition & 4 deletions integration-tests/src/cross_chain_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ fn rococo_should_receive_asset_when_sent_from_hydra() {
});

Rococo::execute_with(|| {
assert_eq!(
hydradx_runtime::Balances::free_balance(AccountId::from(BOB)),
2_999_989_606_492 // 3 * HDX - fee
);
assert!(hydradx_runtime::Balances::free_balance(AccountId::from(BOB)) < 3 * UNITS);
});
}

Expand Down
12 changes: 6 additions & 6 deletions integration-tests/src/dca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ mod omnipool {

assert_balance!(ALICE.into(), DAI, ALICE_INITIAL_DAI_BALANCE + amount_out);
assert_balance!(ALICE.into(), HDX, ALICE_INITIAL_NATIVE_BALANCE - dca_budget);
assert_reserved_balance!(&ALICE.into(), HDX, 858874258006303);
assert_reserved_balance!(&ALICE.into(), HDX, 858858384008414);
});
}

Expand Down Expand Up @@ -339,7 +339,7 @@ mod omnipool {

assert_balance!(ALICE.into(), DAI, ALICE_INITIAL_DAI_BALANCE + amount_out);
assert_balance!(ALICE.into(), HDX, ALICE_INITIAL_NATIVE_BALANCE - dca_budget);
assert_reserved_balance!(&ALICE.into(), HDX, 858874258006303);
assert_reserved_balance!(&ALICE.into(), HDX, 858858384008414);
});
}

Expand Down Expand Up @@ -440,7 +440,7 @@ mod omnipool {
//Assert
assert_balance!(ALICE.into(), DAI, ALICE_INITIAL_DAI_BALANCE + amount_out);
assert_balance!(ALICE.into(), LRNA, alice_init_hub_balance - dca_budget);
assert_reserved_balance!(&ALICE.into(), LRNA, 2429472200972701);
assert_reserved_balance!(&ALICE.into(), LRNA, 2429464263973749);

let treasury_balance = Currencies::free_balance(LRNA, &Treasury::account_id());
assert!(treasury_balance > 0);
Expand Down Expand Up @@ -469,7 +469,7 @@ mod omnipool {
set_relaychain_block_number(12);

//Assert
assert_reserved_balance!(&ALICE.into(), HDX, 858874258006303);
assert_reserved_balance!(&ALICE.into(), HDX, 858858384008414);

assert_balance!(ALICE.into(), DAI, ALICE_INITIAL_DAI_BALANCE + amount_out);
});
Expand Down Expand Up @@ -552,7 +552,7 @@ mod omnipool {
set_relaychain_block_number(12);

//Assert
assert_reserved_balance!(&ALICE.into(), LRNA, 929472200972701);
assert_reserved_balance!(&ALICE.into(), LRNA, 929464263973749);
assert_balance!(ALICE.into(), DAI, 2100000000000000);
});

Expand Down Expand Up @@ -1543,7 +1543,7 @@ mod omnipool {

assert_balance!(ALICE.into(), DAI, 2142642852904326);
assert_balance!(ALICE.into(), LRNA, alice_init_hub_balance - dca_budget);
assert_reserved_balance!(&ALICE.into(), LRNA, 2399569558403200);
assert_reserved_balance!(&ALICE.into(), LRNA, 2399561886966227);
});
}

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ mod account_conversion {
DISPATCH_ADDR, // to
data, // data
U256::from(0u64),
U256::from(52000u64),
U256::from(53000u64),
None,
None,
None,
Expand Down Expand Up @@ -1599,7 +1599,7 @@ fn compare_fee_in_eth_between_evm_and_native_omnipool_calls() {
fee_currency,
));

// give alice evm addr seom weth to sell in omnipool
// give alice evm addr some DOT to sell in omnipool
assert_ok!(hydradx_runtime::Currencies::update_balance(
hydradx_runtime::RuntimeOrigin::root(),
ALICE.into(),
Expand Down
67 changes: 33 additions & 34 deletions integration-tests/src/exchange_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@

use crate::assert_operation_stack;
use crate::polkadot_test_net::*;
use frame_support::dispatch::GetDispatchInfo;
use frame_support::storage::with_transaction;
use frame_support::traits::fungible::Balanced;
use frame_support::traits::tokens::Precision;
use frame_support::weights::Weight;
use frame_support::{assert_ok, pallet_prelude::*};
use hydradx_runtime::AssetRegistry;
use hydradx_runtime::Router;
use hydradx_runtime::RuntimeOrigin;
use hydradx_traits::AssetKind;
use hydradx_traits::Create;
use frame_support::{
assert_ok,
dispatch::GetDispatchInfo,
pallet_prelude::*,
storage::with_transaction,
traits::{fungible::Balanced, tokens::Precision},
weights::Weight,
};
use hydradx_runtime::{AssetRegistry, Omnipool, Router, RuntimeOrigin};
use hydradx_traits::{AssetKind, Create};
use orml_traits::currency::MultiCurrency;
use pallet_broadcast::types::ExecutionType;
use polkadot_xcm::opaque::v3::{Junction, Junctions::X2, MultiLocation};
use polkadot_xcm::{v4::prelude::*, VersionedXcm};
use pretty_assertions::assert_eq;
use primitives::constants::chain::CORE_ASSET_ID;
use primitives::AccountId;
use sp_runtime::traits::{Convert, Zero};
use sp_runtime::DispatchResult;
use sp_runtime::{FixedU128, Permill, TransactionOutcome};
use rococo_runtime::xcm_config::BaseXcmWeight;
use sp_runtime::{
traits::{Convert, Zero},
DispatchResult, FixedU128, Permill, TransactionOutcome,
};
use sp_std::sync::Arc;
use xcm_builder::FixedWeightBounds;
use xcm_emulator::TestExt;
use xcm_executor::traits::WeightBounds;

pub const SELL: bool = true;
pub const BUY: bool = false;
Expand Down Expand Up @@ -53,15 +56,15 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() {
let token_price = FixedU128::from_float(1.0);
assert_ok!(hydradx_runtime::Tokens::deposit(ACA, &omnipool_account, 3000 * UNITS));

assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
ACA,
token_price,
Permill::from_percent(100),
AccountId::from(BOB),
));
use hydradx_traits::pools::SpotPriceProvider;
price = hydradx_runtime::Omnipool::spot_price(CORE_ASSET_ID, ACA);
price = Omnipool::spot_price(CORE_ASSET_ID, ACA);

TransactionOutcome::Commit(DispatchResult::Ok(()))
});
Expand Down Expand Up @@ -182,12 +185,12 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_buy() {
add_currency_price(ACA, FixedU128::from(1));

init_omnipool();
let omnipool_account = hydradx_runtime::Omnipool::protocol_account();
let omnipool_account = Omnipool::protocol_account();

let token_price = FixedU128::from_float(1.0);
assert_ok!(hydradx_runtime::Tokens::deposit(ACA, &omnipool_account, 3000 * UNITS));

assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
ACA,
token_price,
Expand Down Expand Up @@ -272,21 +275,21 @@ fn transfer_and_swap_should_work_with_4_hops() {
add_currency_price(GLMR, FixedU128::from(1));

init_omnipool();
let omnipool_account = hydradx_runtime::Omnipool::protocol_account();
let omnipool_account = Omnipool::protocol_account();

let token_price = FixedU128::from_float(1.0);
assert_ok!(hydradx_runtime::Tokens::deposit(GLMR, &omnipool_account, 3000 * UNITS));
assert_ok!(hydradx_runtime::Tokens::deposit(IBTC, &omnipool_account, 3000 * UNITS));

assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
GLMR,
token_price,
Permill::from_percent(100),
AccountId::from(BOB),
));

assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
IBTC,
token_price,
Expand Down Expand Up @@ -411,7 +414,7 @@ pub mod zeitgeist_use_cases {
crate::exchange_asset::add_currency_price(crate::exchange_asset::ZTG, FixedU128::from(1));

init_omnipool();
let omnipool_account = hydradx_runtime::Omnipool::protocol_account();
let omnipool_account = Omnipool::protocol_account();

let token_price = FixedU128::from_float(1.0);
assert_ok!(hydradx_runtime::Tokens::deposit(
Expand All @@ -420,7 +423,7 @@ pub mod zeitgeist_use_cases {
1000000 * UNITS
));

assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
ZTG,
token_price,
Expand Down Expand Up @@ -589,7 +592,7 @@ pub mod zeitgeist_use_cases {
crate::exchange_asset::add_currency_price(crate::exchange_asset::ZTG, FixedU128::from(1));

init_omnipool();
let omnipool_account = hydradx_runtime::Omnipool::protocol_account();
let omnipool_account = Omnipool::protocol_account();

let token_price = FixedU128::from_float(1.0);
assert_ok!(hydradx_runtime::Tokens::deposit(ZTG, &omnipool_account, 100000 * UNITS));
Expand All @@ -598,15 +601,15 @@ pub mod zeitgeist_use_cases {
&omnipool_account,
100000 * UNITS
));
assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
IBTC,
token_price,
Permill::from_percent(100),
AccountId::from(BOB),
));

assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
ZTG,
token_price,
Expand Down Expand Up @@ -815,7 +818,7 @@ pub mod zeitgeist_use_cases {
crate::exchange_asset::add_currency_price(crate::exchange_asset::GLMR, FixedU128::from(1));

init_omnipool();
let omnipool_account = hydradx_runtime::Omnipool::protocol_account();
let omnipool_account = Omnipool::protocol_account();

let token_price = FixedU128::from_float(1.0);
assert_ok!(hydradx_runtime::Tokens::deposit(
Expand All @@ -828,15 +831,15 @@ pub mod zeitgeist_use_cases {
&omnipool_account,
100000 * UNITS
));
assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
IBTC,
token_price,
Permill::from_percent(100),
AccountId::from(BOB),
));

assert_ok!(hydradx_runtime::Omnipool::add_token(
assert_ok!(Omnipool::add_token(
hydradx_runtime::RuntimeOrigin::root(),
GLMR,
token_price,
Expand Down Expand Up @@ -1190,10 +1193,6 @@ fn half(asset: &Asset) -> Asset {
id: asset.clone().id,
}
}
use pallet_broadcast::types::ExecutionType;
use rococo_runtime::xcm_config::BaseXcmWeight;
use xcm_builder::FixedWeightBounds;
use xcm_executor::traits::WeightBounds;

fn craft_transfer_and_swap_xcm_with_4_hops<RC: Decode + GetDispatchInfo>(
give_asset: Asset,
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/liquidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use orml_traits::currency::MultiCurrency;
use sp_core::{H256, U256};
use sp_runtime::{traits::CheckedConversion, SaturatedConversion};

// ./target/release/scraper save-storage --pallet EVM AssetRegistry Timestamp Omnipool Tokens --uri wss://rpc.nice.hydration.cloud:443
const PATH_TO_SNAPSHOT: &str = "evm-snapshot/SNAPSHOT";

#[module_evm_utility_macro::generate_function_selector]
Expand Down
Loading
Loading