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

Prototyping canonical SolanaTBTC token with Anchor #650

Merged
merged 28 commits into from
Aug 2, 2023
Merged

Conversation

eth-r
Copy link
Contributor

@eth-r eth-r commented Jul 11, 2023

Refs: #656

This PR is a continuation of tBTC expansion to L2s, sidechains, and non-EVM chains - here Solana. Solana module in large should replicate the same functionality as available in other cross-chain modules like Arbitrum, Optimism, and Polygon. It brings tBTC to Solana with the help of Wormhole. Here's a diagram to illustrate the flow

+----------------------------+         +----------------------------------------------------------------------+
|          Ethereum          |         |                                Solana                                |
|                            |         |                                                                      |
|  +----------------------+  |         |  +----------------------+  +-----------------------+  +------------+ |
|  | Wormhole TokenBridge |--|---------|--| Wormhole TokenBridge |--| SolanaWormholeGateway |--| SolanaTBTC | |
|  +----------------------+  |         |  +----------------------+  +-----------------------+  +------------+ |
|                            |         |                                                                      |
+----------------------------+         +----------------------------------------------------------------------+

Wormhole TokenBridge on Ethereum - holds all TBTC bridged to Solana. This is an external contract created by the Wormhole team.
Wormhole TokenBridge on Solana - mints Wormhole wrapped TBTC ie. wormholeTBTC. This is an external contract created by the Wormhole team.
SolanaWormholeGateway on Solana - acts as a vending machine that wraps and unwraps wormholeTBTC to the canonical tBTC token on Solana. (TO BE YET IMPLEMENTED by the Threshold team)
SolanaTBTC - canonical tBTC token on Solana. This PR creates it and sets up the project structure.


Links:

@dimpar
Copy link
Contributor

dimpar commented Jul 19, 2023

Do you think we can change the project structure like:

cross-chain
|-solana
  |-programs
    |-tbtc
      |-src
        |-lib.rs
      |-Cargo.toml
      |-Xargo.toml
    |-wormhole-gateway (to be added)
      |-src
        |-lib.rs
      |-Cargo.toml
      |-Xargo.toml
  |-migrations
  |-tests
  (rest of the files)

@dimpar dimpar mentioned this pull request Jul 19, 2023
@eth-r eth-r marked this pull request as ready for review July 19, 2023 13:48

pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
let tbtc = &mut ctx.accounts.tbtc;
tbtc.authority = ctx.accounts.authority.key();
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor issue, but this authority should be the same pubkey as the one who deployed the program. The upgrade authority (found in this program's program data, which is an account owned by BpfLoaderUpgradeable) will be this authority. Unlikely, but someone can race you to initialize the instruction after you deploy, setting himself as the authority.

Also a note about upgradeability: how do you plan on managing this? Multisig? You should set the upgrade authority to your multisig address in this instruction. Or it can be managed by an external program, where that external program's PDA can be the upgrade authority.

Copy link
Contributor

@dimpar dimpar Jul 22, 2023

Choose a reason for hiding this comment

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

After the deployment on mainnet we want to set the upgrade authority as Threshold Council multisig.

Copy link
Contributor

@a5-pickle a5-pickle left a comment

Choose a reason for hiding this comment

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

Left some comments.

I also did not see any CPI with the token bridge yet, but I assume this is a work-in-progress. I can take a look again once these CPI calls are written.

@a5-pickle a5-pickle mentioned this pull request Aug 1, 2023
Copy link
Contributor

@a5-pickle a5-pickle left a comment

Choose a reason for hiding this comment

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

NOTE: Wormhole Gateway is still a work-in-progress. Everything looks good so far.

@eth-r
Copy link
Contributor Author

eth-r commented Aug 2, 2023

Can't approve this myself, but looks good to me.

@pdyraga pdyraga enabled auto-merge August 2, 2023 14:02
@pdyraga pdyraga merged commit 9857fd0 into main Aug 2, 2023
36 checks passed
@pdyraga pdyraga deleted the solana-anchor branch August 2, 2023 14:03
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.

4 participants