Bridge TFT from Stellar to Solana #144
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Basic premise: Being able to bridge TFT Stellar <=> Solana
2 things are needed:
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 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
Sameh will be able to support @lee with his workload
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
Good idea/decision! If multisig is the standard, it might be even simpler than single sig to set up.
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!
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 running on testnet and testing is in progress
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
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, 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 isTFTqrVLZAMFfbC4bEpfiN1PRTfcYiuHheTs9d297uk6
.Docs on how to use the bridge are included in the PR