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

How to limit the gas of the message on source chain and target chain? #171

Open
hackfisher opened this issue May 27, 2022 · 5 comments
Open
Assignees
Labels

Comments

@hackfisher
Copy link
Contributor

To open the message service to smart contracts, the message user will be able to customize the target dispatch contract call, and the source callback call etc.

And all the messages in one lane must be delivered in order, so if some dispatch/callback call consume too much gas and exceed the block max limit, then the block producers on target/source chain might refuse to include those relay transactions, and relayers can do nothing in this situation, following messages will be blocked by this message(nonce) too.

To avoid this potential attack, the dispatch/callback call must give an MESSAGE_MAX_DISPATCH_GAS/ MESSAGE_MAX_CALLBACK_GAS to limit the dispatch_gas_limit/callback_gas_limit encoded in the message.

The dispatch_gas_limit/callback_gas_limit encoded in the message has two functions:

  1. To limit the largest consumable gas for the smart contract(programmable + context_dynamic), and will be set as the gas limit in evm transactions. With the gas limited settings, these two value can be used to limit the gas, and for system level MESSAGE_MAX_DISPATCH_GAS/ MESSAGE_MAX_CALLBACK_GAS comparison.
  2. To give an extra message fee estimation prepaid by the user in addition to the relayer market fee, this is different compared to current, but is better because it simply the fee model for the relayers, they do not to consider the gas.

But there are extra factors need to detail and research further for 2, because, the fee prepaid are in source chain's token, but the dispatch_gas_limit might be in target chain's token, to calculate the prepaid fee, there might require an extra conversion between source token and target token here, and simple way will require introduce price feed by oracle.

cc @xiaoch05

@hackfisher
Copy link
Contributor Author

Duplicate with darwinia-network/darwinia-messages-substrate#107 for s2s

for evm to evm bridges, we might need to check we have same design.

@hackfisher hackfisher transferred this issue from darwinia-network/darwinia Jun 8, 2022
@hackfisher hackfisher moved this to 📋 Backlog in (Archive)Msgport Jun 8, 2022
@hujw77
Copy link
Collaborator

hujw77 commented Jun 8, 2022

@hackfisher
Copy link
Contributor Author

@wuminzhe Will require SDK docs for this.

@hujw77
Copy link
Collaborator

hujw77 commented Dec 8, 2022

@wuminzhe Does SDK docs adopt the requires?

@wuminzhe
Copy link
Collaborator

wuminzhe commented Dec 8, 2022

@wuminzhe Does SDK docs adopt the requires?

No.

Does this need oracle? @hackfisher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants