Skip to content

Commit

Permalink
runtime changes to compile, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Aug 12, 2024
1 parent d0f4b4e commit 162ce97
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
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.

4 changes: 4 additions & 0 deletions runtime/centrifuge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ orml-xtokens = { workspace = true }
pallet-anchors = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-axelar-router = { workspace = true }
pallet-balances = { workspace = true }
pallet-base-fee = { workspace = true }
pallet-block-rewards = { workspace = true }
Expand Down Expand Up @@ -208,6 +209,7 @@ std = [
"pallet-anchors/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-axelar-router/std",
"pallet-balances/std",
"pallet-base-fee/std",
"pallet-block-rewards/std",
Expand Down Expand Up @@ -294,6 +296,7 @@ runtime-benchmarks = [
"orml-tokens/runtime-benchmarks",
"orml-xtokens/runtime-benchmarks",
"pallet-anchors/runtime-benchmarks",
"pallet-axelar-router/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-block-rewards/runtime-benchmarks",
"pallet-bridge/runtime-benchmarks",
Expand Down Expand Up @@ -375,6 +378,7 @@ try-runtime = [
"pallet-anchors/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-axelar-router/try-runtime",
"pallet-balances/try-runtime",
"pallet-base-fee/try-runtime",
"pallet-block-rewards/try-runtime",
Expand Down
10 changes: 7 additions & 3 deletions runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ use runtime_common::{
},
permissions::{IsUnfrozenTrancheInvestor, PoolAdminCheck},
rewards::SingleCurrencyMovement,
routing::{EvmAccountCodeChecker, RouterDispatcher, RouterId},
transfer_filter::{PreLpTransfer, PreNativeTransfer},
xcm::AccountIdToLocation,
xcm_transactor, AllowanceDeposit, CurrencyED,
Expand Down Expand Up @@ -1983,10 +1984,13 @@ impl pallet_ethereum::Config for Runtime {

impl pallet_ethereum_transaction::Config for Runtime {}

impl axelar_gateway_precompile::Config for Runtime {
impl pallet_axelar_router::Config for Runtime {
type AdminOrigin = EnsureAccountOrRootOr<LpAdminAccount, TwoThirdOfCouncil>;
type EvmAccountCodeChecker = EvmAccountCodeChecker<Runtime>;
type Middleware = RouterId;
type Receiver = LiquidityPoolsGateway;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type Transactor = EthereumTransaction;
}

/// Block type as expected by this runtime.
Expand Down Expand Up @@ -2111,7 +2115,7 @@ construct_runtime!(
BaseFee: pallet_base_fee::{Pallet, Call, Config<T>, Storage, Event} = 162,
Ethereum: pallet_ethereum::{Pallet, Config<T>, Call, Storage, Event, Origin} = 163,
EthereumTransaction: pallet_ethereum_transaction::{Pallet, Storage} = 164,
LiquidityPoolsAxelarGateway: axelar_gateway_precompile::{Pallet, Call, Storage, Event<T>} = 165,
AxelarRouter: pallet_axelar_router::{Pallet, Call, Storage, Event<T>} = 165,

// Synced pallets across all runtimes - Range: 180-240
// WHY: * integrations like fireblocks will need to know the index in the enum
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/evm/precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub type RuntimePrecompilesAt<R, Symbol> = (
// Centrifuge specific precompiles:
PrecompileAt<
AddressU64<LP_AXELAR_GATEWAY>,
axelar_gateway_precompile::Pallet<R>,
pallet_axelar_router::Pallet<R>,
CallableByContract,
>,
);
Expand Down
12 changes: 9 additions & 3 deletions runtime/common/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ pub enum RouterId {
Axelar(AxelarId),
}

impl From<AxelarId> for RouterId {
fn from(axelar_id: AxelarId) -> Self {
RouterId::Axelar(axelar_id)
}
}

impl From<RouterId> for Domain {
fn from(router_id: RouterId) -> Domain {
fn from(router_id: RouterId) -> Self {
match router_id {
RouterId::Axelar(AxelarId::Evm(chain_id)) => Domain::EVM(chain_id),
}
Expand All @@ -39,7 +45,7 @@ impl RouterSupport<Domain> for RouterId {
}

/// This type choose the correct router implementation given a router id
struct RouterDispatcher<Routers>(PhantomData<Routers>);
pub struct RouterDispatcher<Routers>(PhantomData<Routers>);
impl<Routers> MessageSender for RouterDispatcher<Routers>
where
Routers: pallet_axelar_router::Config,
Expand All @@ -60,7 +66,7 @@ where
}
}

struct EvmAccountCodeChecker<Runtime>(PhantomData<Runtime>);
pub struct EvmAccountCodeChecker<Runtime>(PhantomData<Runtime>);
impl<Runtime: pallet_evm::Config> PreConditions<(H160, H256)> for EvmAccountCodeChecker<Runtime> {
type Result = bool;

Expand Down

0 comments on commit 162ce97

Please sign in to comment.