-
Notifications
You must be signed in to change notification settings - Fork 0
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
Inbound queue v2 #3
Conversation
@yrong would appreciate an early review here. 🙏🏻 |
let fee_value = 1_000_000_000u128; // TODO needs to be dry-run to get the fee but also | ||
// need to add a fee here for the dry run... Chicken/egg problem? | ||
let fee: Asset = (fee_asset, fee_value).into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC the dry_run
on BH is to convert the InboundMessage to a XCM. Then UI can dry run that XCM on AH for the cost.
So IMO InboundMessage
should contain the fee like V1 before, it can be zero for estimation, after that filled in with the result for calling the Gateway contract from UX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vgeddes or how did you imagine the AH execution fee be specified? I see there is a fee added for register token (which is the foreign asset creation deposit) but no other place in the contracts to specify the AH execution fee. Iiuc this will be the flow:
- Inbound queue runtime API to convert command to XCM
- UX takes XCM and dry-runs the XCM on AH to get fee
- UX takes fee number and adds it to the command, emits OutboundEvent
I don't see such a fee parameter in the contract code, so just wanna get your thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option as mentioned in #3 (comment)
|
||
const MINIMUM_DEPOSIT: u128 = 1; | ||
const LOG_TARGET: &str = "snowbridge-router-primitives"; | ||
|
||
/// Messages from Ethereum are versioned. This is because in future, | ||
/// we may want to evolve the protocol so that the ethereum side sends XCM messages directly. | ||
/// Instead having BridgeHub transcode the messages into XCM. | ||
#[derive(Clone, Encode, Decode, RuntimeDebug)] | ||
pub enum VersionedMessage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This versioned type is unused in V2, in the sense that the ethereum contracts do not send it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vgeddes I wonder why we don't version the message this time around, I made a comment about it here too: yrong#4 (comment)
|
||
let fee_asset = Location::new(1, Here); | ||
let fee_value = 1_000_000_000u128; // TODO get from command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I noted in a previous comment, this fee should also be burnt from the relayers account on BH.
Some other notes:
- Should make the fee configurable via runtime config, ie add
T::XcmPrologueFee: Balance
pallet config - Add to your TODOs to implement an XCM simulation test that calculates an appropriate minimum fee, assuming the worst case where a maximum of eight assets are supplied. Then we add 2x buffer on top of that minimum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should make the fee configurable via runtime config, ie add T::XcmPrologueFee: Balance pallet config
Can we make this fee configurable? Iirc we cannot, because it could include arbitrary instructions such as Transact. I explained the flow as I see it should work over here: #3 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this fee configurable? Iirc we cannot, because it could include arbitrary instructions such as Transact. I explained the flow as I see it should work over here: #3 (comment)
Yeah, I still think InboundMessage should contain the fee like V1 before with AssetId including.
But there is also another option to make it configurable, A Nmap storage item on BH something like:
Destination | Operation | FeeId | FeeAmount |
---|---|---|---|
AH | TransferENA | WETH | 0.0001 |
AH | TransferENA | DOT | 0.01 |
AH | TransferPNA | DOT | 0.01 |
Moonbeam | TransferENA | GLMR | 0.1 |
Moonbeam | Call_Contract_Method_1 | GLMR | 0.5 |
Moonbeam | Call_Contract_Method_2 | GLMR | 10 |
- Destination chain can config multiple assets as fee. e.g. for
TransferENA
to AH both WETH and DOT can be configured as fee. - For multiple hop operations the fee is total of the execution cost on AH and on destination chain. e.g. for
TransferENA
to Moonbeam the fee is 0.0001 WETH + 0.1 GLMR - Operations with Destination to AH should be configured with governance call from Polkadot
- Operations with Destination to Moonbeam should be configured with governance call from Moonbeam
IMO this is doer-able because
- fee on Substrate is very limited and invariable, comparing with the fee on Ethereum side, so
dry_run
every time may not be necessary - we can add
SetAppendix(DepositToBeneficiary)
and return the extra fee to end user, so set a high fee safe enough is not a big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting idea @yrong. It could work. I think the main downside to this (from my perspective) is that many governance calls will be a pain to do. It will require more invention from our team's side, more coordination with other teams.
What is your concern with the dry-run approach? Isn't runtime API calls free so there's no cost to doing the estimation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think InboundMessage should contain the fee like V1 before but with AssetId including.
Yeah, that's why I still prefer this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vgeddes let me know what you think too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a misunderstanding here how fees are supposed to be paid on AH. Please read again the API docs for IGateway.sendMessage
:
// The `xcm` should contain the necessary instructions to: // 1. Pay XCM execution fees for `xcm`, either from assets in holding, // or from the sovereign account of `msg.sender`. // 2. Handle the assets in holding, either depositing them into // some account, or forwarding them to another destination.
Or in other words, its the users responsibility to provide assets and xcm instructions to cover fees. I.e the user-provided xcm
can contain PayFee
instructions.
Please let me know if there is anything that I should clarify about this.
Its only the fixed xcm prologue that requires a small fixed fee to be teleported by the relayer account on BH. To cover the first few instructions which are prepending to the users xcm
.
Our governance messages for registering ENA tokens will use the same API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for clearing it up @vgeddes. I will add it.
Co-authored-by: Vincent Geddes <117534+vgeddes@users.noreply.github.com>
Co-authored-by: Vincent Geddes <117534+vgeddes@users.noreply.github.com>
Co-authored-by: Vincent Geddes <117534+vgeddes@users.noreply.github.com>
Closing in favour of #4. The diff in this PR included changes already made in another PR, so it was hard to see the true diff. |
Resolves: SNO-1164