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

LPv2: Add PalletAxelarRoutet #1955

Closed
wants to merge 1 commit into from
Closed

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Aug 9, 2024

Description

  • Add a new pallet called pallet-axelar-router, which is the union of the current axelar-gateway-precompile and routers/axelar_evm.
  • Added some simplification to the gateway (comment below)

Currently compiling as cargo check -p pallet-axelar-router

@lemunozm lemunozm added I8-enhancement An additional feature. I6-refactoring Code needs refactoring. labels Aug 9, 2024
@lemunozm lemunozm self-assigned this Aug 9, 2024

#[pallet::weight(Pallet::<T>::weight_for_set_method())]
#[pallet::call_index(2)]
pub fn set_outbound_config(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router is configured here by chain_id instead of domain because a router can never be a Centrifuge domain. The gateway will no longer configure routers, will only handle the routers id.

exit_status: ExitError::Other("payload conversion".into()),
})?;

T::Gateway::receive(origin, msg).map_err(|e| TryDispatchError::Substrate(e).into())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably here we should add a router_id parameter or append to the origin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, atm I have a T::Hash for inbound routers but we can change to whatever.

Comment on lines +322 to +323
let source_address_bytes =
cfg_utils::decode_var_source::<EXPECTED_SOURCE_ADDRESS_SIZE>(
Copy link
Contributor Author

@lemunozm lemunozm Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've simplified this by removing the SourceConverter type from the original axelar precompile pallet.

I did so, because the EXPECTED_SOURCE_ADDRESS_SIZE is 20, which means that we always parse a 20bytes address. Makes sense because we should not expect a Centrifuge address coming from Evm.

@lemunozm lemunozm requested review from cdamian and wischli August 9, 2024 17:36
Comment on lines +53 to +82
/// The behavior of an entity that can send messages
pub trait MessageSender {
/// The originator of the message to be sent
type Origin;

///The destination of the message
type Destination;

/// Sends a message for origin to destination
fn send(
origin: Self::Origin,
destination: Self::Destination,
message: Vec<u8>,
) -> DispatchResultWithPostInfo;
}

/// The behavior of an entity that can receive messages
pub trait MessageReceiver {
/// The maximum lenght for a message the implementor is able to receive.
type MaxEncodedLen: Get<u32>;

/// The originator of the message to be sent
type Origin;

/// Sends a message for origin to destination
fn receive(
origin: Self::Origin,
message: BoundedVec<u8, Self::MaxEncodedLen>,
) -> DispatchResult;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cosmin, this will be the new interface. Basically, the routers are no longer instances. They are pallet, but each pallet can have different configurations in they want.

I'm not fully sure yet, but my intention is that the Self::Origin will be a tuple (RouterId, Domain) or similar. Still thinking about this, but somehow though the receive()/send() method you could determine the router.

Hopefully, it will require few changes in the gateway.

Also the router storage and configuration could be removed from the gateway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the router storage and configuration could be removed from the gateway.

OK, but then we need a way to somehow still "add" the routers to the gateway. Maybe add a tuple of all the available router pallets to the gateway config or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the way would be by adding a list of router ids

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And from the gateway perspective, only router ids exist

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but then how would the gateway call router X to send an outbound message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send(router_id, domain, message) something like that

@lemunozm
Copy link
Contributor Author

lemunozm commented Aug 9, 2024

Regarding this implementation, I'm still not sure if the whole axelar should be inside this new router pallet, because Axelar is supposed to be connected to other chains, so maybe the precompile logic itself is shared among different routers.

@lemunozm
Copy link
Contributor Author

Close in favor of: #1956

@lemunozm lemunozm closed this Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I6-refactoring Code needs refactoring. I8-enhancement An additional feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants