Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ test-ts: build-mandala-internal-release

.PHONY: test-benchmarking
test-benchmarking:
cargo test --features bench --package module-evm
cargo bench --features bench --package module-evm --package runtime-common
cargo test --features runtime-benchmarks --features with-all-runtime --features --all benchmarking

.PHONY: test-all
Expand Down
3 changes: 3 additions & 0 deletions modules/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module-evm-utility = { path = "../evm-utility", default-features = false }
primitives = { package = "acala-primitives", path = "../../primitives", default-features = false }
module-idle-scheduler = { path = "../idle-scheduler", default-features = false, optional = true }
module-transaction-payment = { path = "../../modules/transaction-payment", default-features = false }
module-dex = { path = "../dex", default-features = false, optional = true }

xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.22", default-features = false }

Expand Down Expand Up @@ -79,6 +80,7 @@ std = [
"orml-tokens/std",
"module-idle-scheduler/std",
"module-transaction-payment/std",
"module-dex/std",
"xcm-builder/std"
]
with-ethereum-compatibility = []
Expand All @@ -95,6 +97,7 @@ bench = [
"serde_json",
"hex",
"module-idle-scheduler",
"module-dex",
"xcm-builder/runtime-benchmarks"
]
evm-tests = [
Expand Down
39 changes: 36 additions & 3 deletions modules/evm/src/bench/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ use frame_support::{
ConsensusEngineId, PalletId,
};
use frame_system::EnsureSignedBy;
use module_support::{mocks::MockAddressMapping, Price, PriceProvider};
use orml_traits::parameter_type_with_key;
use module_support::mocks::MockErc20InfoMapping;
use module_support::{mocks::MockAddressMapping, DEXIncentives, Price, PriceProvider};
use orml_traits::{parameter_type_with_key, MultiReservableCurrency};
pub use primitives::{
define_combined_task, Address, Amount, Block, BlockNumber, CurrencyId, Header, Multiplier, ReserveIdentifier,
Signature, TokenSymbol,
Expand Down Expand Up @@ -246,7 +247,7 @@ impl module_transaction_payment::Config for Runtime {
type AlternativeFeeSwapDeposit = ExistenceRequirement;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
type DEX = ();
type DEX = Dex;
type MaxSwapSlippageCompareToOracle = MaxSwapSlippageCompareToOracle;
type TradingPathLimit = TradingPathLimit;
type PriceSource = MockPriceSource;
Expand All @@ -259,6 +260,37 @@ impl module_transaction_payment::Config for Runtime {
type DefaultFeeTokens = DefaultFeeTokens;
}

pub struct MockDEXIncentives;
impl DEXIncentives<AccountId32, CurrencyId, Balance> for MockDEXIncentives {
fn do_deposit_dex_share(who: &AccountId32, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult {
Tokens::reserve(lp_currency_id, who, amount)
}

fn do_withdraw_dex_share(who: &AccountId32, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult {
let _ = Tokens::unreserve(lp_currency_id, who, amount);
Ok(())
}
}

parameter_types! {
pub const GetExchangeFee: (u32, u32) = (1, 100);
pub const DEXPalletId: PalletId = PalletId(*b"aca/dexm");
}

impl module_dex::Config for Runtime {
type Event = Event;
type Currency = Tokens;
type GetExchangeFee = GetExchangeFee;
type TradingPathLimit = TradingPathLimit;
type PalletId = DEXPalletId;
type Erc20InfoMapping = MockErc20InfoMapping;
type WeightInfo = ();
type DEXIncentives = MockDEXIncentives;
type ListingOrigin = EnsureSignedBy<ListingOrigin, AccountId32>;
type ExtendedProvisioningBlocks = ConstU32<0>;
type OnLiquidityPoolUpdated = ();
}

pub type SignedExtra = (frame_system::CheckWeight<Runtime>,);
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;

Expand All @@ -269,6 +301,7 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
Dex: module_dex::{Pallet, Call, Storage, Event<T>},
EVM: evm_mod::{Pallet, Config<T>, Call, Storage, Event<T>},
Tokens: orml_tokens::{Pallet, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Expand Down
2 changes: 1 addition & 1 deletion orml
12 changes: 12 additions & 0 deletions runtime/common/src/bench/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use module_evm::{precompiles::Precompile, Context};
use module_support::AddressMapping;
use orml_bencher::{benches, Bencher};
use orml_traits::DataFeeder;
use primitives::currency::{AssetMetadata, TokenInfo};
use sp_core::{H160, H256};

fn whitelist_keys(b: &mut Bencher, caller: Option<H160>) {
Expand Down Expand Up @@ -84,6 +85,17 @@ fn oracle_get_price(b: &mut Bencher) {
let price = Price::from(30_000);
assert_ok!(Oracle::feed_value(ALICE, RENBTC, price));

assert_ok!(AssetRegistry::register_native_asset(
Origin::signed(CouncilAccount::get()),
RENBTC,
sp_std::boxed::Box::new(AssetMetadata {
name: RENBTC.name().unwrap().into(),
symbol: RENBTC.symbol().unwrap().into(),
decimals: RENBTC.decimals().unwrap(),
minimal_balance: 0
})
));

// getPrice(address) -> 0x41976e09
// RENBTC
let input = hex! {"
Expand Down
4 changes: 2 additions & 2 deletions runtime/common/src/precompile/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ parameter_types! {
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub ActiveSubAccountsIndexList: Vec<u16> = vec![0, 1, 2];
pub const BondingDuration: EraIndex = 28;
pub static MintThreshold: Balance = 0;
pub static RedeemThreshold: Balance = 0;
pub const MintThreshold: Balance = 0;
pub const RedeemThreshold: Balance = 0;
}

impl module_homa::Config for Test {
Expand Down