Bridge TFT from Stellar to Solana #144

Open
opened 2024-12-09 09:54:47 +00:00 by thabeta · 9 comments
Owner

Basic premise: Being able to bridge TFT Stellar <=> Solana

2 things are needed:

  • TFT on Solana
  • A bridge to move TFT's held by a user on stellar to a solana wallet

TFT on solana can be set up with the token2022 program. Since solana smart contracts behave differently compared to ethereum, the flow of bridging will need to be adjusted somewhat. Instead of storing the tx hashes on the contract, we will have the bridge emit a memo with said tx hash. Conversely to burn tokens on solana and bridge back to stellar, the user will have to include the appropriate memo and use the default burn instruction of the token program.

For the bridge side, since a Solana tx has a 64 bytes identifier, we will need to hash this again to convert it to 32byte identifier to add on the steller transaction.

Basic premise: Being able to bridge TFT Stellar <=> Solana 2 things are needed: - TFT on Solana - A bridge to move TFT's held by a user on stellar to a solana wallet TFT on solana can be set up with the token2022 program. Since solana smart contracts behave differently compared to ethereum, the flow of bridging will need to be adjusted somewhat. Instead of storing the tx hashes on the contract, we will have the bridge emit a memo with said tx hash. Conversely to burn tokens on solana and bridge back to stellar, the user will have to include the appropriate memo and use the default burn instruction of the token program. For the bridge side, since a Solana tx has a 64 bytes identifier, we will need to hash this again to convert it to 32byte identifier to add on the steller transaction.
lee was assigned by thabeta 2024-12-09 10:02:47 +00:00
thabeta added the
Story
label 2024-12-09 10:05:18 +00:00
thabeta added this to the tfgrid_3_16 project 2024-12-30 15:15:41 +00:00
despiegk added the
Urgent
label 2024-12-30 15:23:15 +00:00
Owner

@lee please add more content above
mycelium is giving us a delay, mycelium will have to wait

Ahmed will help lee with his team, they will let Kristof know when we will have first version done

@lee please add more content above mycelium is giving us a delay, mycelium will have to wait Ahmed will help lee with his team, they will let Kristof know when we will have first version done
thabeta added the due date 2025-01-06 2024-12-31 13:45:13 +00:00
Author
Owner

Sameh will be able to support @lee with his workload

Sameh will be able to support @lee with his workload
Member

After some deliberation, I've decided to not implement single sig and instead focus on multisig directly as the amount of extra work for the temporary setup is not worth it.

Other than that, there is a problem with the size of solana transaction ids. These are 64 bytes and can thus not be stored as memo in a stellar tx, which is needed for replay protection. Will try to figure out some alternative solutions

After some deliberation, I've decided to not implement single sig and instead focus on multisig directly as the amount of extra work for the temporary setup is not worth it. Other than that, there is a problem with the size of solana transaction ids. These are 64 bytes and can thus not be stored as memo in a stellar tx, which is needed for replay protection. Will try to figure out some alternative solutions
Owner

After some deliberation, I've decided to not implement single sig and instead focus on multisig directly as the amount of extra work for the temporary setup is not worth it.

Good idea/decision! If multisig is the standard, it might be even simpler than single sig to set up.

Other than that, there is a problem with the size of solana transaction ids. These are 64 bytes and can thus not be stored as memo in a stellar tx, which is needed for replay protection. Will try to figure out some alternative solutions

So we need a bijective function between Solana's 64 bytes and stellar memo? Maybe limit the possible state of Solana transactions and reduce the set to fit with stellar memo tx? Tough one!

> After some deliberation, I've decided to not implement single sig and instead focus on multisig directly as the amount of extra work for the temporary setup is not worth it. Good idea/decision! If multisig is the standard, it might be even simpler than single sig to set up. > Other than that, there is a problem with the size of solana transaction ids. These are 64 bytes and can thus not be stored as memo in a stellar tx, which is needed for replay protection. Will try to figure out some alternative solutions So we need a bijective function between Solana's 64 bytes and stellar memo? Maybe limit the possible state of Solana transactions and reduce the set to fit with stellar memo tx? Tough one!
Member

Bridge is code complete. Initial testing locally however has revealed that there is an issue in the multisig handling for solana transactions. In the existing ethereum bridge, we pass the information and generate a signature based on it. For solana this approach was mimiced by generating the tx on each signer, and then passing the signers signature to the master. This does not seem to work, as the generated transaction to sign is not always the same.

We'll work around this by passing the full transactions from the master, signing it, and returning the signature along with the index in the array of signatures.

In the meantime, we can also start the full testnet setup

Bridge is code complete. Initial testing locally however has revealed that there is an issue in the multisig handling for solana transactions. In the existing ethereum bridge, we pass the information and generate a signature based on it. For solana this approach was mimiced by generating the tx on each signer, and then passing the signers signature to the master. This does not seem to work, as the generated transaction to sign is not always the same. We'll work around this by passing the full transactions from the master, signing it, and returning the signature along with the index in the array of signatures. In the meantime, we can also start the full testnet setup
Member

Bridge is running on testnet and testing is in progress

Bridge is running on testnet and testing is in progress
thabeta removed the
Urgent
label 2025-01-09 13:50:46 +00:00
Member

Most of today was spent on a libp2p issue. It seems that libp2p is suddenly refusing to forward messages to followers. This is the same code which is running on the existing bridges, so not sure what the issue is. Upgrading libp2p to the latest versions does not seem to improve the situation, so I'll revert that back tomorrow.

Eventually I patched the libp2p dependency locally to remove the validation which prevents transient connections from being used, which seems to allow us to continue testing.

There was some cleanup needed for stellar signing due to the way the bridge was setup. Existing bridges assume the bridge account itself is the leader in the multisig. Solana code has been fixed to allow the leader to use any address, not just the bridge address itself. Other than that, signing stellar/refunding works.

All in all, the libp2p issues will need to be solved eventually but the current workaround should unblock testing

Most of today was spent on a libp2p issue. It seems that libp2p is suddenly refusing to forward messages to followers. This is the same code which is running on the existing bridges, so not sure what the issue is. Upgrading libp2p to the latest versions does not seem to improve the situation, so I'll revert that back tomorrow. Eventually I patched the libp2p dependency locally to remove the validation which prevents transient connections from being used, which seems to allow us to continue testing. There was some cleanup needed for stellar signing due to the way the bridge was setup. Existing bridges assume the bridge account itself is the leader in the multisig. Solana code has been fixed to allow the leader to use any address, not just the bridge address itself. Other than that, signing stellar/refunding works. All in all, the libp2p issues will need to be solved eventually but the current workaround should unblock testing
Member

Bridge is fully working. Implemented some additional code to streamline the inclusion of the stellar tx hash (when going stellar -> Solana), to make sure the lib we use doesn't include a leading length byte in the memo at the start.

For now I'm continuing to look into the libp2p issue and why its misbehaving, the setup is similar to our other bridges so not sure what is going on there.

I'll add some docs tomorrow on how to set it up and how to use it, so someone can also look into a frontend for this if needed

Bridge is fully working. Implemented some additional code to streamline the inclusion of the stellar tx hash (when going stellar -> Solana), to make sure the lib we use doesn't include a leading length byte in the memo at the start. For now I'm continuing to look into the libp2p issue and why its misbehaving, the setup is similar to our other bridges so not sure what is going on there. I'll add some docs tomorrow on how to set it up and how to use it, so someone can also look into a frontend for this if needed
Member

Bridge is fully working, testnet instance is running (on some servers I manage in our DC upstairs). I'll hand over the testnet setup to ops next week.

PR for the bridge code is available here: https://github.com/threefoldfoundation/tft/pull/276. Note that this does not include a frontend at the moment. If that is needed, someone can adapt one from the existing stellar-evm bridge.

For the testnet setup, the bride account on stellar is GDGIQWZDFVWJPAFG7PJ5AXMOK7NVFVFWELZILI5MLHGSZULBTBGIBYHW. On solana, tokens are burned to trigger the bridging, and the token mint used right now is TFTqrVLZAMFfbC4bEpfiN1PRTfcYiuHheTs9d297uk6.

Docs on how to use the bridge are included in the PR

Bridge is fully working, testnet instance is running (on some servers I manage in our DC upstairs). I'll hand over the testnet setup to ops next week. PR for the bridge code is available here: https://github.com/threefoldfoundation/tft/pull/276. Note that this does not include a frontend at the moment. If that is needed, someone can adapt one from the existing stellar-evm bridge. For the testnet setup, the bride account on stellar is [`GDGIQWZDFVWJPAFG7PJ5AXMOK7NVFVFWELZILI5MLHGSZULBTBGIBYHW`](https://stellar.expert/explorer/testnet/account/GDGIQWZDFVWJPAFG7PJ5AXMOK7NVFVFWELZILI5MLHGSZULBTBGIBYHW). On solana, tokens are burned to trigger the bridging, and the token mint used right now is [`TFTqrVLZAMFfbC4bEpfiN1PRTfcYiuHheTs9d297uk6`](https://solscan.io/token/TFTqrVLZAMFfbC4bEpfiN1PRTfcYiuHheTs9d297uk6?cluster=testnet). Docs on how to use the bridge are included in the PR
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

2025-01-06

Dependencies

No dependencies set.

Reference: tfgrid/circle_engineering#144
No description provided.