-
Notifications
You must be signed in to change notification settings - Fork 58
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
EthereumTokenTransfers
pallet
#835
base: master
Are you sure you want to change the base?
Conversation
…ken-transfers-pallet
…ken-transfers-pallet
…ken-transfers-pallet
…ken-transfers-pallet
WASM runtime size check:Compared to target branchdancebox runtime: 1412 KB (no changes) ✅ flashbox runtime: 824 KB (no changes) ✅ dancelight runtime: 2180 KB (+2180 KB) container chain template simple runtime: 1116 KB (-4300 KB) ✅ container chain template frontier runtime: 1404 KB (-5156 KB) ✅ |
Coverage Report@@ Coverage Diff @@
## master agustin-ethereum-token-transfers-pallet +/- ##
===========================================================================
+ Coverage 66.04% 66.10% +0.06%
+ Files 335 339 +4
+ Lines 58858 59175 +317
===========================================================================
+ Hits 38869 39116 +247
+ Misses 19989 20059 +70
|
#[cfg(feature = "runtime-benchmarks")] | ||
impl<T: snowbridge_pallet_outbound_queue::Config> TicketInfo for Ticket<T> { | ||
fn message_id(&self) -> H256 { | ||
H256::default() |
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.
Why?
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.
Because in benchmarks we need to check the message_id
value thrown by the NativeTokenTransferred
event. If we return the default, we don't need to worry about reading the entropy (which I don't know if it's possible inside benchmarks) to calculate the actual message_id
.
I can take another look, but in my opinion we are fine by just returning the default here.
What does it do?
This PR introduces the
pallet-ethereum-token-transfers
and adds it to Dancelight runtime, alongside:Pallet's structure
The purpose of this pallet is to send the native Starlight token from Starlight to Ethereum. It does this by sending a
MintForeignToken
command to Ethereum through a specificchannel_id
(which is also stored in this pallet).Config types
Currency
: type to manage the internal transfers of native balance.OutboundQueue
: implementation that takes care of validating and send the message to Ethereum.EthereumSystemHandler
: Hook that manages the insertion of channel information inside EthereumSystem pallet.EthereumSovereignAccount
: Sovereign account of Ethereum in Starlight chain. This is the account in which we store and track how much tokens are transferred from Starlight to Ethereum as a whole.FeesAccount
: the account in which we deposit fees (calculated at the moment of delivering the message).TokenLocationReanchored
: the Starlight token location seen from the external chain's (Ethereum) point of view. This is the location that should be stored in EthereumSystem pallet prior to transfer the token using the EthereumTokenTransfers pallet.TokenIdFromLocation
: this is how we convert a Location object to a TokenId, used inside the MintForeignToken command. If the previous TokenLocationReanchored is not found in EthereumSystem, this conversion fails.Extrinsics
set_token_transfer_channel
: only callable by root. Used to specify which channel_id will be used to send the tokens through. It also receives the para_id and agent_id params corresponding to the channel specified.transfer_native_token
: used to perform the actual sending of the tokens, it requires to specify an amount and a recipient, which is a H160 account on the Ethereum side.Storage
Inside the pallet we group and store the channel information using the
ChannelInfo
struct:Events
ChannelInfoSet
: information for the channel was set properly.NativeTokenTransferred
: some native token was successfully transferred to Ethereum.Errors
ChannelIdAlreadyExists
: the requested ChannelId is already present in this pallet.ChannelInfoNotSet
: the channel's information has not been set on this pallet yet.ParaIdAlreadyExists
: the requested ParaId is already present in this pallet.AgentIdAlreadyExists
: the requested AgentId is already present in this pallet.UnknownLocationForToken
: conversion from Location to TokenId failed.InvalidMessage
: the outbound message is invalid prior to send.TransferMessageNotSent
: the outbound message could not be sent.