Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Add ethereum transact call dispatch #105

Closed
wants to merge 10 commits into from

Conversation

boundless-forest
Copy link
Member

@boundless-forest boundless-forest commented Jun 2, 2022

This is an early draft pull request in development. Because of the cycle dep problem, the concrete tests have to be done on darwinia-common side.

@wuminzhe
Copy link
Collaborator

wuminzhe commented Jun 6, 2022

I suggest renaming EthereumCallDispatch trait to CallDispatch. the CallDispatch is used to dispatch different calls.

@@ -297,6 +311,39 @@ impl<T: Config<I>, I: 'static> MessageDispatch<T::AccountId, T::BridgeMessageId>
return dispatch_result
}

// Dispatch Ethereum call earlier before pay
match T::EthereumCallDispatcher::dispatch(&call, &origin_account) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like this is a patch here.
maybe, generalize the EthereumCallDispatch to CallDispatch.

or, something like:
replace
let origin = RawOrigin::Signed(origin_account).into();
with
let origin = T::OriginBuilder.getOrigin(call, origin_account);

Copy link
Member Author

@boundless-forest boundless-forest Jun 6, 2022

Choose a reason for hiding this comment

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

generalize the EthereumCallDispatch to CallDispatch.

It seems like a rename issue. For dispatch calls besides the Ethereum pallet, we use the original call dispatch in this pallet. The dispatcher I added is only used for the Ethereum pallet dispatch call, so I think EthereumCallDispatch is more suitable here.

For the second way:
We also need the necessary validation before dispatch, it inserts too much if we put the validate logic in this pallet.

Copy link
Collaborator

@wuminzhe wuminzhe Jun 7, 2022

Choose a reason for hiding this comment

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

why I want to rename the trait to CallDispatch. for example, another chain has a special dispatch with a custom origin, like PalletNew's new_call(NewOrigin), it need a impl CallDispatch for NewCallDispatcher. So, if the trait name is EthereumCallDispatch , it will be impl EthereumCallDispatch for NewCallDispatcher.

is this trait be used only in Ethereum pallet?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, this one is only used by the Ethereum pallet. I don't see any other pallet that needs it. Rename to CallDispatch is wired this pallet already called pallet-messages-dispatch, then there is another associated type called CallDispatch, After the CallDispatch executes logic, there is another call dispatch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

@hackfisher hackfisher Jun 8, 2022

Choose a reason for hiding this comment

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

I agree with @wuminzhe , why not use CallFilter for validation, and it is doing the duplicate dispatch and cases match which will be called later.

Why not directly use the spec described in #100 ?

@boundless-forest boundless-forest marked this pull request as ready for review June 6, 2022 04:03
@boundless-forest
Copy link
Member Author

@hackfisher @AurevoirXavier PTAR

Comment on lines 149 to 150
EthereumCallDispatched(ChainId, BridgeMessageIdOf<T, I>, DispatchResult),
EthereumCallValidityError(ChainId, BridgeMessageIdOf<T, I>, EthereumCallValidityError),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is too specific to put them in this generic pallet.

@@ -297,6 +311,39 @@ impl<T: Config<I>, I: 'static> MessageDispatch<T::AccountId, T::BridgeMessageId>
return dispatch_result
}

// Dispatch Ethereum call earlier before pay
match T::EthereumCallDispatcher::dispatch(&call, &origin_account) {
Copy link
Contributor

@hackfisher hackfisher Jun 8, 2022

Choose a reason for hiding this comment

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

I agree with @wuminzhe , why not use CallFilter for validation, and it is doing the duplicate dispatch and cases match which will be called later.

Why not directly use the spec described in #100 ?

@boundless-forest boundless-forest marked this pull request as draft June 8, 2022 07:12
@boundless-forest
Copy link
Member Author

Prefer #111

@boundless-forest boundless-forest deleted the bear-dev-dispatch-eth-call branch June 10, 2022 06:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants