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: solana implementation #13

Draft
wants to merge 138 commits into
base: main
Choose a base branch
from
Draft

feat: solana implementation #13

wants to merge 138 commits into from

Conversation

eloylp
Copy link
Member

@eloylp eloylp commented Apr 1, 2024

At Eiger, we are implementing the integration between Axelar and Solana.

This PR introduces the necessary logic for the ampd component, including:

  • The Solana message verifier handler.
  • The Solana verifier set verifier handler.
  • The logic required to validate Solana addresses.

Both verifier components share the same Solana transaction fetch and log parsing logic, which facilitates identifying event sequences within Solana programs execution outputs.

Todos

  • Unit tests
  • Manual tests
  • Documentation
  • Connect epics/issues

Steps to Test

  1. Configure ampd with an updated ampd.toml file, pointing to a local tofnd setup.
  2. tofnd must be up and running.
  3. Compile and start the ampd daemon.
  4. Execute the memo program flow, which sends a message from Evm to Solana and viceversa. Scripts can be found at solana-axelar-scripts

Expected Behaviour

It should forward GMP messages from one chain to the another, passing them thorugh the axelar devnet network.

Other Notes

Manual testing is missing because we are waiting for Axelar contract approval.

eloylp and others added 30 commits February 6, 2024 20:44
* Add Solana account parsing tools.
* Add solana verification functionality

* Add unit tests to Solana message verifier

* Refactor

* Solana msg verifier reshape (#4)

* remove comment

* Use Solana types from Solana crates

We were using hand crafted Solana types for interacting with RPC.

* refactor: make clippy happy

* Add some traces to Solana msg verifier

* Remove outdated todos

* refactor: re-use already calculated variable

* Clarify test code usage

* Solana msg verifier, try till one program log matches gw event

* Add note to axelar to review when in PR

* fail if tx_id is not found in signatures

* Always fail on chain at handler level

* Handle errors in case a tx cannot be found (finish the handler)

* Remove commented code

* Use original type from solana-axelar repo

* Ensure that we verify sender address in sol msg verifier

* Do not panic on PartialEq

* refactor: clippy

* remove no longer used code

* Add more tests definition to solana msg verify iteration logic

---------

Co-authored-by: eloylp <[email protected]>
Were only intended during development to understand the API.
Co-authored-by: tilacog <[email protected]>
Co-authored-by: tilacog <[email protected]>
Co-authored-by: tilacog <[email protected]>
ampd/Cargo.toml Outdated Show resolved Hide resolved
ampd/src/config.rs Outdated Show resolved Hide resolved
ampd/src/solana/mod.rs Outdated Show resolved Hide resolved
@eloylp eloylp requested a review from frenzox January 10, 2025 10:18
Cargo.toml Outdated
Copy link
Member

@ctoyan ctoyan Jan 10, 2025

Choose a reason for hiding this comment

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

I see you've added a lot of dependencies across the Cargo.toml files. In my PR Axelar asked to remove as much dependencies as possible.
Just sharing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have been trying to see how to minimize this. All dependencies are needed and are actually segregated in a consistent way, were the common ones belongs to the workspace and the specific ones, to just their crates.

I think the solution to the problem of dependencies needs to be though from an architectural point of view. In a way, we implement the ampd deps on our daemons, instead of the opposite. This was already subject of discussions in the past.

But maybe i am missing something. How did you solved the issue ? Maybe i can get inspiration :)

Copy link
Member

Choose a reason for hiding this comment

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

I would double check if we really need all of these Solana ones:

solana-account-decoder = "=2.0.16"
solana-client = "=2.0.16"
solana-program = "=2.0.16"
solana-sdk = "=2.0.16"
solana-rpc-client-api = "=2.0.16"
solana-version = "=2.0.16"
solana-zk-token-sdk = "=2.0.16"
solana-transaction-status = "=2.0.16"

Because I have doubts that all of them are required

Copy link
Member Author

Choose a reason for hiding this comment

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

True, i was assuming we had here some unused deps check. I will check it.

@@ -15,7 +15,7 @@ pub trait Finalizer: Send + Sync {
async fn latest_finalized_block_height(&self) -> Result<U64>;
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Default)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
Copy link
Member

Choose a reason for hiding this comment

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

Do you need that change for the evm finalizer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah, i think i can remember now. This is because the the Finalization struct is part of the Chain struct , which is part of the Config . Once we derive Clone in the parent (The Config) the res of the structs need to implement it as well. This was done because testing for being able to clone a config template in memory.

I honestly think its not bad to have that Clone there, as it favours testing. I would let them decide, but config is not an expensive thing to clone IMO.

Copy link
Member

Choose a reason for hiding this comment

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

The derive(Clone) can be put behind a conditional test macro. But I believe that would only make the code uglier. Let's keep it unless we're told otherwise

Copy link
Member

Choose a reason for hiding this comment

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

I don't know if it's intentional of you just missed, but this file has no unit tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as i understood, the logic in mod.rs is common logic used by msg_verifier.rs and verifier_set_verifier.rs , which have their own unit tests. Initially i consider there's already good coverage there, but let me know @ctoyan @roberts-pumpurs if we want to add some more unit tests, even if they are a bit redundant.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that adding extra tests here is redundant and not worth the time

@eloylp
Copy link
Member Author

eloylp commented Jan 13, 2025

Okay, description updated, first feedback round addressed. Re requesting review !

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

Successfully merging this pull request may close these issues.

5 participants