Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/polkadot-v1.1.0' into polkadot-v…
Browse files Browse the repository at this point in the history
…1.1.0

# Conflicts:
#	integration-tests/src/evm.rs
  • Loading branch information
dmoka committed Nov 21, 2023
2 parents 89f9658 + cd906ef commit 1243a00
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 148 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

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

30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,21 @@ parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch =
xcm-emulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }

# Frontier
fc-consensus = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-db = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-mapping-sync = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-rpc = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-rpc-core = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }

fp-evm = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fp-rpc = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fp-self-contained = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fp-storage = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }

pallet-ethereum = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
pallet-evm = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
pallet-evm-chain-id = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
pallet-evm-precompile-dispatch = { git = "https://github.com/PureStake/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-db = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-mapping-sync = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fc-rpc-core = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }

fp-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
fp-storage = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }

pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }
pallet-evm-precompile-dispatch = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.1.0", default-features = false }

# EVM from acala
module-evm-utility-macro = { path = "runtime/hydradx/src/evm/evm-utility/macro", default-features = false}
Expand Down
26 changes: 13 additions & 13 deletions integration-tests/src/dynamic_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn fees_should_initialize_lazily_to_min_value_when_first_trade_happens() {
//Arrange
init_omnipool();
init_oracle();
hydradx_run_to_block(10);
hydradx_run_to_block(12);

assert!(hydradx_runtime::DynamicFees::current_fees(HDX).is_none());

Expand All @@ -69,7 +69,7 @@ fn fees_should_initialize_lazily_to_min_value_when_first_trade_happens() {
FeeEntry {
asset_fee: asset_fee_params.min_fee,
protocol_fee: Permill::from_float(0.000788_f64),
timestamp: 10_u32
timestamp: 12_u32
}
);
});
Expand All @@ -83,7 +83,7 @@ fn fees_should_initialize_lazily_to_min_value_when_first_buy_happens() {
//Arrange
init_omnipool();
init_oracle();
hydradx_run_to_block(10);
hydradx_run_to_block(12);

assert!(hydradx_runtime::DynamicFees::current_fees(HDX).is_none());

Expand All @@ -105,7 +105,7 @@ fn fees_should_initialize_lazily_to_min_value_when_first_buy_happens() {
FeeEntry {
asset_fee: asset_fee_params.min_fee,
protocol_fee: Permill::from_float(0.000788_f64),
timestamp: 10_u32
timestamp: 12_u32
}
);
});
Expand Down Expand Up @@ -165,7 +165,7 @@ fn fees_should_change_when_sells_happen_in_different_blocks() {
//Arrange
init_omnipool();
init_oracle();
hydradx_run_to_block(10);
hydradx_run_to_block(12);

assert_ok!(hydradx_runtime::Omnipool::sell(
hydradx_runtime::RuntimeOrigin::signed(DAVE.into()),
Expand All @@ -178,7 +178,7 @@ fn fees_should_change_when_sells_happen_in_different_blocks() {
let old_fees = hydradx_runtime::DynamicFees::current_fees(HDX).unwrap();

//Act
hydradx_run_to_block(11);
hydradx_run_to_block(13);
assert_ok!(hydradx_runtime::Omnipool::sell(
hydradx_runtime::RuntimeOrigin::signed(DAVE.into()),
DOT,
Expand All @@ -195,7 +195,7 @@ fn fees_should_change_when_sells_happen_in_different_blocks() {
FeeEntry {
asset_fee: Permill::from_float(0.0025_f64),
protocol_fee: Permill::from_float(0.000926_f64),
timestamp: 11_u32
timestamp: 13_u32
}
);
});
Expand All @@ -209,7 +209,7 @@ fn fees_should_change_when_trades_happen_in_different_blocks() {
//Arrange
init_omnipool();
init_oracle();
hydradx_run_to_block(10);
hydradx_run_to_block(12);

assert_ok!(hydradx_runtime::Omnipool::sell(
hydradx_runtime::RuntimeOrigin::signed(DAVE.into()),
Expand All @@ -222,7 +222,7 @@ fn fees_should_change_when_trades_happen_in_different_blocks() {
let old_fees = hydradx_runtime::DynamicFees::current_fees(HDX).unwrap();

//Act
hydradx_run_to_block(11);
hydradx_run_to_block(13);
assert_ok!(hydradx_runtime::Omnipool::buy(
hydradx_runtime::RuntimeOrigin::signed(DAVE.into()),
DOT,
Expand All @@ -239,7 +239,7 @@ fn fees_should_change_when_trades_happen_in_different_blocks() {
FeeEntry {
asset_fee: Permill::from_float(0.0025_f64),
protocol_fee: Permill::from_float(0.000926_f64),
timestamp: 11_u32
timestamp: 13_u32
}
);
});
Expand All @@ -253,7 +253,7 @@ fn fees_should_change_only_one_when_trades_happen_in_the_same_block() {
//Arrange
init_omnipool();
init_oracle();
hydradx_run_to_block(10);
hydradx_run_to_block(12);

assert_ok!(hydradx_runtime::Omnipool::sell(
hydradx_runtime::RuntimeOrigin::signed(DAVE.into()),
Expand All @@ -267,7 +267,7 @@ fn fees_should_change_only_one_when_trades_happen_in_the_same_block() {
set_balance(DAVE.into(), HDX, 1_000 * UNITS as i128);

//Act & assert
hydradx_run_to_block(11);
hydradx_run_to_block(13);
assert_ok!(hydradx_runtime::Omnipool::buy(
hydradx_runtime::RuntimeOrigin::signed(DAVE.into()),
DOT,
Expand All @@ -283,7 +283,7 @@ fn fees_should_change_only_one_when_trades_happen_in_the_same_block() {
FeeEntry {
asset_fee: Permill::from_float(0.0025_f64),
protocol_fee: Permill::from_float(0.000926_f64),
timestamp: 11_u32
timestamp: 13_u32
}
);

Expand Down
8 changes: 3 additions & 5 deletions integration-tests/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ pub fn init_omnipol() {
const DISPATCH_ADDR: H160 = addr(1025);

fn gas_price() -> U256 {
U256::from(10_u128.pow(8))
U256::from(8 * 10_u128.pow(7))
}

fn create_dispatch_handle(data: Vec<u8>) -> MockHandle {
Expand Down Expand Up @@ -796,12 +796,10 @@ impl PrecompileHandle for MockHandle {
_proof_size: Option<u64>,
_storage_growth: Option<u64>,
) -> Result<(), ExitError> {
unimplemented!()
Ok(())
}

fn refund_external_cost(&mut self, _ref_time: Option<u64>, _proof_size: Option<u64>) {
unimplemented!()
}
fn refund_external_cost(&mut self, _ref_time: Option<u64>, _proof_size: Option<u64>) {}

fn remaining_gas(&self) -> u64 {
unimplemented!()
Expand Down
17 changes: 1 addition & 16 deletions integration-tests/src/non_native_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,13 @@ use frame_support::{
assert_ok,
dispatch::DispatchInfo,
sp_runtime::traits::SignedExtension,
traits::{OnFinalize, OnInitialize},
weights::Weight,
};
use hydradx_runtime::{Balances, Currencies, MultiTransactionPayment, RuntimeOrigin, Tokens};
use orml_traits::currency::MultiCurrency;
use primitives::Price;
use xcm_emulator::TestExt;

pub fn hydra_run_to_block(to: BlockNumber) {
while hydradx_runtime::System::block_number() < to {
let b = hydradx_runtime::System::block_number();

hydradx_runtime::System::on_finalize(b);
hydradx_runtime::MultiTransactionPayment::on_finalize(b);

hydradx_runtime::System::on_initialize(b + 1);
hydradx_runtime::MultiTransactionPayment::on_initialize(b + 1);

hydradx_runtime::System::set_block_number(b + 1);
}
}

#[test]
fn non_native_fee_payment_works_with_omnipool_spot_price() {
TestNet::reset();
Expand Down Expand Up @@ -61,7 +46,7 @@ fn non_native_fee_payment_works_with_omnipool_spot_price() {

init_omnipool();

hydra_run_to_block(2);
hydradx_run_to_block(2);

let call = hydradx_runtime::RuntimeCall::MultiTransactionPayment(
pallet_transaction_multi_payment::Call::set_currency { currency: DAI },
Expand Down
14 changes: 1 addition & 13 deletions integration-tests/src/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::polkadot_test_net::*;
use frame_support::{
assert_ok,
sp_runtime::{FixedU128, Permill},
traits::{tokens::fungibles::Mutate, OnFinalize, OnInitialize},
traits::tokens::fungibles::Mutate,
};
use hydradx_runtime::{EmaOracle, RuntimeOrigin};
use hydradx_traits::{
Expand All @@ -16,18 +16,6 @@ use pallet_ema_oracle::OracleError;
use primitives::constants::chain::OMNIPOOL_SOURCE;
use xcm_emulator::TestExt;

pub fn hydradx_run_to_next_block() {
let b = hydradx_runtime::System::block_number();

hydradx_runtime::System::on_finalize(b);
hydradx_runtime::EmaOracle::on_finalize(b);

hydradx_runtime::System::on_initialize(b + 1);
hydradx_runtime::EmaOracle::on_initialize(b + 1);

hydradx_runtime::System::set_block_number(b + 1);
}

const HDX: AssetId = CORE_ASSET_ID;

const SUPPORTED_PERIODS: &[OraclePeriod] = &[LastBlock, Short, TenMinutes];
Expand Down
Loading

0 comments on commit 1243a00

Please sign in to comment.