-
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
Outbound queue v2 #4
base: xcm-v5
Are you sure you want to change the base?
Conversation
Workflow
which means we can execute multiple commands on Ethereum in one message.
|
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.
Hey I'd prefer to move the crate to primitives/merkle-tree
rather than adding more code to core
. In fact I think the core
crate has too much code and potentially needs be split up further.
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.
We shouldn't just add V2 code and leave v1 code as is. The two versions need to co-exist in a coherent and neatly ordered manner.
I think we should move to this layout:
* core/src/outbound/v1/mod.rs
* core/src/outbound/v2/mod.rs
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.
@@ -172,3 +174,13 @@ impl Default for AssetMetadata { | |||
|
|||
/// Maximum length of a string field in ERC20 token metada | |||
const METADATA_FIELD_MAX_LEN: u32 = 32; | |||
|
|||
// Origin for high-priority governance commands | |||
pub fn primary_governance_origin() -> H256 { |
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 is now a V1-only type, so should go in core/src/v1/mod.rs
.
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.
850fe96
Actually it's V2 specific.
The usage in
polkadot-sdk/bridges/snowbridge/pallets/outbound-queue-v2/src/send_message_impl.rs
Lines 45 to 47 in ba03ae6
if ticket.origin != primary_governance_origin() { | |
ensure!(!Self::operating_mode().is_halted(), SendError::Halted); | |
} |
} | ||
|
||
// Origin for lower-priority governance commands | ||
pub fn second_governance_origin() -> H256 { |
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.
ditto
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.
...rachains/integration-tests/emulated/tests/bridges/bridge-hub-westend/src/tests/snowbridge.rs
Outdated
Show resolved
Hide resolved
pub id: H256, | ||
/// Commands to execute in Ethereum | ||
pub commands: BoundedVec<CommandWrapper, ConstU32<5>>, |
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 probably limit to 8 (I like constants being a factor of 2). And we should probably use a constant.
pub commands: BoundedVec<CommandWrapper, ConstU32<5>>, | |
pub commands: BoundedVec<CommandWrapper, ConstU32<MAX_COMMANDS>>, |
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.
Token::Tuple(vec![ | ||
Token::FixedBytes(Vec::from(x.channel_id.as_ref())), | ||
let header = vec![ | ||
Token::FixedBytes(x.origin.as_bytes().to_owned()), |
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 use the the sol!
macro to auto-generate encoders for InboundMessage
? Its from this library which is already used by outbound queue: https://alloy.rs/
Token::FixedBytes
is from the older ethabi-decode
crate which we should stop using and migrate to alloy crates.
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.
mode: OperatingMode, | ||
}, | ||
/// Transfer ether from an agent contract to a recipient account | ||
TransferNativeFromAgent { |
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 command doesn't exist anymore, I believe
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.
} | ||
|
||
/// ABI-encode the Command. | ||
pub fn abi_encode(&self) -> Vec<u8> { |
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 use the sol!
macro from the alloy-rs crates to generate the encoders automatically? We should deprecate use of ethabi::encode
, as its an unmaintained library.
See example from https://github.com/paritytech/polkadot-sdk/blob/aeebf2f383390f2f86527d70212162d5dbea8b93/bridges/snowbridge/pallets/inbound-queue/src/envelope.rs#L11
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.
// The base transaction cost, which includes: | ||
// 21_000 transaction cost, roughly worst case 64_000 for calldata, and 100_000 | ||
// for message verification | ||
const MAXIMUM_BASE_GAS: u64 = 185_000; |
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 won't be needed in V2.
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.
Check details in emulated tests how to construct transfer message for both ENA&PNA with XCMV5 instructions.
|
BoundedVec::try_from(ticket.encode()).map_err(|_| SendError::MessageTooLarge)?; | ||
|
||
T::MessageQueue::enqueue_message(message.as_bounded_slice(), origin); | ||
Self::deposit_event(Event::MessageQueued { message: ticket.clone() }); |
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 isn't sufficient for dry-running, because the message
at this stage in the processing pipeline isn't the same that is forwarded to the Ethereum gateway. Its missing information such as the gas limit. Without knowing the gas limits, we can't dry run properly on Ethereum.
In other words, we need the dry-run API to output the final message, the SCALE-encoded equivalent of this type: https://github.com/Snowfork/snowbridge/blob/fa9b8a7b3551cc9df8ee3239dc2830be5d84728e/contracts/src/v2/Types.sol#L8
This makes it much more easy for the UX to dry-run the resulting message on Ethereum.
We can ignore the message nonce for dry-run purposes on Ethereum.
So I you think you should explore adding a custom runtime API that takes the ExportMessage XCM, converts it to the final ethereum 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.
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.
Meanwhile to remove the fee when validate ExportMessage so that we can decrease the delivery fee config on AH and make it as an user input.
More context in paritytech#4826 (comment)
80dad67
to
74d23af
Compare
fffd895
to
df137c0
Compare
Resolves: https://linear.app/snowfork/issue/SNO-1205