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

WIP: Testing whole integration flow for precompile #1576

Closed
wants to merge 16 commits into from
Closed
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[submodule "runtime/integration-tests/submodules/liquidity-pools"]
path = runtime/integration-tests/submodules/liquidity-pools
url = [email protected]:centrifuge/liquidity-pools.git
branch = origin/feat/forwarder
[submodule "runtime/integration-tests/submodules/axelar-cgp-solidity"]
path = runtime/integration-tests/submodules/axelar-cgp-solidity
url = [email protected]:axelarnetwork/axelar-cgp-solidity.git
branch = origin/releases/4.3.x
82 changes: 68 additions & 14 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,12 @@ where
exit_status: ExitError::Other("account bytes mismatch for domain".into()),
})?;

match pallet_liquidity_pools_gateway::Pallet::<T>::process_msg(
pallet_liquidity_pools_gateway::Pallet::<T>::process_msg(
pallet_liquidity_pools_gateway::GatewayOrigin::Domain(domain_address).into(),
msg,
)
.map(|_| ())
.map_err(TryDispatchError::Substrate)
{
Err(e) => Err(e.into()),
Ok(()) => Ok(()),
}
.map_err(Into::into)
}

// Mimics:
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repository = "https://github.com/centrifuge/centrifuge-chain"
[dependencies]
serde = { version = "1.0.119" }
smallvec = "1.6.1"
hex-literal = { version = "0.3.4", default-features = false }

# Substrate dependencies
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
Expand Down Expand Up @@ -76,7 +77,6 @@ sp-io = { git = "https://github.com/paritytech/substrate", default-features = fa

[dev-dependencies]
cfg-mocks = { path = "../../libs/mocks", features = ["runtime-benchmarks", "std"] }
hex-literal = "0.3.4"
pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }

Expand Down
8 changes: 8 additions & 0 deletions runtime/common/src/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
// GNU General Public License for more details.

use frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND;
use hex_literal::hex;
use pallet_ethereum::{Transaction, TransactionAction};
use sp_runtime::Permill;

pub mod precompile;

/// `pallet_evm::AccountCodes` must be populated for precompiles as
/// otherwise `OPCODE::EXTCODESIZE` will make the EVM error upon calling an
/// precompile.
///
/// The following bytes represent: `PUSH1 00`, `PUSH1 00`, `REVERT`.
pub const PRECOMPILE_CODE_STORAGE: [u8; 5] = hex!("60006000fd");

// From Moonbeam:
//
// Current approximation of the gas per second consumption considering
Expand Down
4 changes: 2 additions & 2 deletions runtime/common/src/evm/precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ where
// H160 cannot be used in a match statement due to its hand-rolled
// PartialEq implementation. This just gives a nice name to the
// internal array of bytes that an H160 wraps.
type Addr = [u8; 20];
pub type Addr = [u8; 20];

// This is a reimplementation of the upstream u64->H160 conversion
// function, made `const` to make our precompile address `const`s a
// bit cleaner. It can be removed when upstream has a const conversion
// function.
const fn addr(a: u64) -> Addr {
pub const fn addr(a: u64) -> Addr {
let b = a.to_be_bytes();
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
Expand Down
8 changes: 6 additions & 2 deletions runtime/development/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
// GNU General Public License for more details.

use cfg_primitives::{AccountId, Balance, PoolId, TrancheId};
use cfg_types::{domain_address::Domain, fixed_point::Quantity};
use frame_support::parameter_types;
use cfg_traits::liquidity_pools::InboundQueue;
use cfg_types::{
domain_address::{Domain, DomainAddress},
fixed_point::Quantity,
};
use frame_support::{dispatch::DispatchResult, parameter_types};
use frame_system::EnsureRoot;
use runtime_common::gateway::GatewayAccountProvider;

Expand Down
15 changes: 8 additions & 7 deletions runtime/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["Centrifuge <[email protected]>"]
edition = "2021"
license = "LGPL-3.0"
build = "build.rs"
homepage = "https://centrifuge.io/"
repository = "https://github.com/centrifuge/centrifuge-chain"

Expand All @@ -14,6 +15,7 @@ lazy_static = "1.4.0"
serde = { version = "1.0.119" }
tokio = { version = "1.15", features = ["macros"] }
tracing-subscriber = "0.2"
serde_json = "1.0.107"

# Substrate
## Substrate-Frame
Expand All @@ -34,7 +36,7 @@ sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" , features = ["full_crypto", "default"]}
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
Expand Down Expand Up @@ -80,16 +82,16 @@ cfg-traits = { path = "../../libs/traits" }
development-runtime = { path = "../development" }
runtime-common = { path = "../common" }

[dev-dependencies]
getrandom = { version = "0.2", features = ["js"] }
hex = { version = "0.4.3", default_features = false }
hex = { version = "0.4.3" }

cfg-traits = { path = "../../libs/traits" }
cfg-types = { path = "../../libs/types" }
cfg-utils = { path = "../../libs/utils" }

ethabi = { version = "16.0", default-features = false }
ethereum = { version = "0.14.0", default-features = false }
ethabi = { version = "16.0" }
ethabi-contract = { version = "16.0" }
ethabi-derive = { version = "16.0" }
ethereum = { version = "0.14.0" }

pallet-ethereum = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
pallet-evm = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }
Expand All @@ -112,7 +114,6 @@ pallet-rewards = { path = "../../pallets/rewards" }

pallet-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-xcm-transactor = { git = "https://github.com/PureStake/moonbeam", default-features = false, rev = "00b3e3d97806e889b02e1bcb4b69e65433dd805d" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = true, branch = "release-v0.9.38" }

Expand Down
Loading