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

Batch Precompile Clean-up #1044

Closed
2 tasks done
gitofdeepanshu opened this issue Oct 9, 2023 · 15 comments
Closed
2 tasks done

Batch Precompile Clean-up #1044

gitofdeepanshu opened this issue Oct 9, 2023 · 15 comments
Assignees
Labels
astar Related to Astar documentation Add documentation runtime This PR/Issue is related to the topic “runtime”. shibuya related to shibuya shiden related to shiden runtime

Comments

@gitofdeepanshu
Copy link
Contributor

gitofdeepanshu commented Oct 9, 2023

Description

Clean up related to Batch Precompile after removing the revert code.

Required Tasks

@gitofdeepanshu gitofdeepanshu added documentation Add documentation shiden related to shiden runtime astar Related to Astar shibuya related to shibuya runtime This PR/Issue is related to the topic “runtime”. labels Oct 9, 2023
@gitofdeepanshu gitofdeepanshu self-assigned this Oct 9, 2023
@HyunggyuJang
Copy link

Can I ask the background for this decision? IMHO, it is quite valuable utility function.

@Dinonard
Copy link
Member

Can I ask the background for this decision? IMHO, it is quite valuable utility function.

We decided it's not needed to have on the runtime level.
The main motivation for adding this was a specific UI requirement, but we found out it can be handled differently.

If you want to utilize batch calls in EVM, there are prexisting contracts which allow for this.
We could deploy one such contract and document how to use it in Astar docs.
However, there hasn't been a requirement for this so far, except good to have.

@HyunggyuJang
Copy link

HyunggyuJang commented Oct 10, 2023

If you want to utilize batch calls in EVM, there are prexisting contracts which allow for this.

I guess, you mean Multicall, but it doesn't allow to call methods from the caller address; also there is no general way to do that from plain EVM contract, unless the target contract provides some batch call methods that utilize delegate call.

I agree that it might not have great impact on the production as the state query methods can be achieved via multicall, but when it comes to mutate the state of blockchain, as I wrote above, there is no general way to batch the calls, except to execute them one by one from the client side, which costs a lot of transmission time. I found the batch precompile is sweet feature. It's sad that it will be gone.

@Dinonard
Copy link
Member

From the client side it's possible to achieve the same functionality via dispatch precompile.
However, it's not allowed to be used by smart contracts.

Our portal is using this functionality right now.

@HyunggyuJang
Copy link

From the client side it's possible to achieve the same functionality via dispatch precompile. However, it's not allowed to be used by smart contracts.

Our portal is using this functionality right now.

It makes sense. So, currently runtime call filter blocks dispatch precompile, but is allowed from direct call from client side, right? Then my use case also can be handled similarly. Thanks a lot!

@Dinonard
Copy link
Member

Yes, but there's also a filter for distpatch - right now batch, dApp staking and some pallet-asset calls are allowed.

But if needed, e.g. by you, we can consider adding more of those.
I'd suggest to open a Github issue if there's a feature you need.

@HyunggyuJang
Copy link

HyunggyuJang commented Oct 10, 2023

I'd suggest to open a Github issue if there's a feature you need.

Noticed! Thanks for your sincere response. I'll open an issue if I found some use cases that I might use the dispatch precompile :)

@Dinonard
Copy link
Member

Noticed! Thanks for your sincere response. I'll open an issue if I found some use cases that I might use the dispatch precompile :)

No problem! And please don't hesitate to do so! We'll be happy to receive requirements like this! 😄

@HyunggyuJang
Copy link

TL;DR dispatch precompile doesn't cover batch precompile, is there any way to batch EVM calls?

@Dinonard Sorry for the delay, I have a chance to use batch call as you gave advice. I believe what you referred at

Our portal is using this functionality right now.

comes from https://github.com/AstarNetwork/astar-apps/pull/930/files#diff-e08c21311328ec6676f39662564895de8cbb99cb0542e0e41cbf372d199d8427.

I inspected it, and found that it uses batch utility for extrinsics. Unlike batch precompile, this way, it doesn't allow batch EVM calls as the CallOrigin is currently set as a root origin. I.e., we cannot call evm call as a extrinsic.

@Dinonard
Copy link
Member

If you want to call other EVM smart contracts as part of a batch call, you shouldn't use the pallet-evm. That call is not supposed to be used by anyone (hence the root only filter).

There are ways to create batch call in EVM, e.g. like this: https://docs.openzeppelin.com/contracts/4.x/api/utils#Multicall.

@HyunggyuJang
Copy link

Yep, but as I said above, multicall doesn't allow to call methods with caller address :( That was the reason why I valued batch precompile.

I guess, you mean Multicall, but it doesn't allow to call methods from the caller address; also there is no general way to do that from plain EVM contract, unless the target contract provides some batch call methods that utilize delegate call.

@Dinonard
Copy link
Member

There's this too: https://github.com/mds1/multicall/tree/main/src

This allows you to change addresses and construct complex calls.

@HyunggyuJang
Copy link

It does allow the target address, but not the caller address. With multicall, the caller address is the address of multicall contract, not the msg.sender.

@Dinonard
Copy link
Member

Dinonard commented Oct 23, 2023

You can use delegatecall though, right?

EDIT: Anyhow, if there's a concrete scenario and/or business case, and same functionality cannot be achieved via existing EVM capabilities, we will consider it.
We don't want to add functionality because it's just good to have, unless there's a demand for it.

@HyunggyuJang
Copy link

You can use delegatecall though, right?

It requires contracts to inherit multicall contract; cannot batch the calls across different contracts.

Anyhow, if there's a concrete scenario and/or business case, and same functionality cannot be achieved via existing EVM capabilities, we will consider it.
We don't want to add functionality because it's just good to have, unless there's a demand for it.

Agree. For now, it is a utility function for the backend side, not the frontend; i.e., not critical from the user perspective of dapp. Thanks for your sincere elaboration! Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astar Related to Astar documentation Add documentation runtime This PR/Issue is related to the topic “runtime”. shibuya related to shibuya shiden related to shiden runtime
Projects
None yet
Development

No branches or pull requests

3 participants