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

feat: FuelVM support for Hyperlane #4861

Open
wants to merge 52 commits into
base: main
Choose a base branch
from

Conversation

Mantas-M
Copy link
Contributor

Description

Support FuelVM chains on the Hyperlane Protocol
Configurations for FuelTestnet and FuelIgnition

Backward compatibility

Yes

Testing

Contract repo E2E testing on local Fuel and EVM nodes
Contract repo E2E testing on Fuel Testnet and Base Sepolia

Notes

The configurations for the Fuel Testnet and Ignition are still WIP

Mantas-M and others added 23 commits October 2, 2024 10:58
Copy link

changeset-bot bot commented Nov 15, 2024

⚠️ No Changeset found

Latest commit: b8ccc5d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.53%. Comparing base (719d022) to head (f3e41e8).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4861   +/-   ##
=======================================
  Coverage   77.53%   77.53%           
=======================================
  Files         103      103           
  Lines        2110     2110           
  Branches      190      190           
=======================================
  Hits         1636     1636           
  Misses        453      453           
  Partials       21       21           
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 79.39% <ø> (ø)
isms 83.68% <ø> (ø)
token 91.27% <ø> (ø)
middlewares 79.80% <ø> (ø)

Copy link
Contributor

@aroralanuk aroralanuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments; e2e as part of this PR will be necessary for approval but shouldn't be a blocker for audit.


impl FromBits256Array for Vec<Bits256> {
fn into_h256_array(self) -> [H256; 32] {
assert!(self.len() == 32);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we maybe make this return an Err instead of panicking? afaict it's only used for the merkle tree which is trusted and should never be other than 32 elements in length, but I wanna make sure we don't accidentally use this elsewhere and panic

.filter_map(move |(index, tx)| {
if !tx.is_valid()
|| !self.is_transaction_from_contract(&tx)
|| !self.has_event(&tx)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I see that has_event basically does the same work as extract_log later on. Should we consolidate?

let decoder = &self.log_decoder;
for (index, receipt) in receipts.into_iter().enumerate() {
if let Ok(decoded_logs) = decoder.decode_logs_with_type::<E>(&[receipt]) {
if !decoded_logs.is_empty() && decoded_logs.len() == 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it ever be possible to have multiple decoded logs here? I guess not because a single receipt can at most relate to one log? https://docs.fuel.network/docs/specs/abi/receipts/#logdata-receipt

false
}

fn extract_log<T>(&self, receipts: Vec<Receipt>) -> Option<(T, usize)>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if these receipts include multiple logs? for example, if a transaction sends two messages, iiuc we'd pass in all the receipts from that transaction here and we'd only return the first event. Should this return a Vec instead?

where
T: Into<Indexed<T>> + PartialEq + Send + Sync + Debug + 'static + From<E>,
{
data.blocks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is no better way of just querying the events we care about? Going through each and every transaction to ever exist is unfortunate as it'll mean backfill indexing will take a super long time

}

#[derive(cynic::QueryFragment, Clone, Debug)]
pub struct Receipt {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to define this ourselves instead of the Receipt from fuels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It all boils down to them not having the full data of their GraphQL implemented with cynic.
The main culprit here is the Block,which does not return all the data we would use when indexing. That's one of the main reasons why indexing by using their SDK would be inefficient.

Due to that, and because we cannot mix different cynic schemas, we need to redefine the fragments, which are useful and relevant, along with some needed boilerplate.

fn process_calldata(&self, message: &HyperlaneMessage, metadata: &[u8]) -> Vec<u8> {
// Seems like this is not needed for Fuel, as it's only used in mocks
todo!()
fn process_calldata(&self, _message: &HyperlaneMessage, _metadata: &[u8]) -> Vec<u8> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha yeah we should probably remove this from the trait, but we can do that later

network.config.node.bound_address().to_string()
),
}],
grpc_urls: vec![],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these necessary for Fuel? this and the bech32 prefix are cosmos specific iiuc?

@@ -0,0 +1 @@

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,6 @@
[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole rust/main/utils/run-locally/src/fuel/fuel-contracts dir including the .bin and jsons is pretty massive

Is there any way to more tightly integrate this with the fuel contracts? E.g. pull this release as part of e2e or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants