From 8167285560abd311f45cf14fcbe9d7ffd5138477 Mon Sep 17 00:00:00 2001 From: Hendrik Hofstadt Date: Sun, 9 Aug 2020 18:26:58 +0200 Subject: [PATCH] update bridge doc --- docs/solana_program.md | 54 +++++++++++++++++++++++++++++++------- solana/bridge/src/state.rs | 10 +++---- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/docs/solana_program.md b/docs/solana_program.md index 5b8e3f02..10beed3f 100644 --- a/docs/solana_program.md +++ b/docs/solana_program.md @@ -87,7 +87,7 @@ Creates a new `WrappedAsset` to be used to create accounts and later receive tra | 4 | wrapped_mint | WrappedAsset | | | ✅ | ✅ | | 5 | wrapped_meta_account | WrappedAssetMeta | | ✅ | ✅ | ✅ | -#### PostVAA +#### SubmitVAA Submits a VAA signed by the guardians to perform an action. @@ -164,7 +164,9 @@ until the `VAA_EXPIRATION_TIME` has passed and can then be evicted using `IEvict #### _GuardianSet_ Account -> Seed derivation: `guardians_` +> Seed derivation: `guardian || || ` +> +> **bridge**: Pubkey of the bridge > > **index**: Index of the guardian set @@ -175,26 +177,36 @@ still be valid until the expiration time. #### _TransferOutProposal_ Account -> Seed derivation: `out___` +> Seed derivation: `transfer || || || || || || || ` > -> **chain**: CHAIN_ID of the native chain of this asset +> **bridge**: Pubkey of the bridge +> +> **asset_chain**: CHAIN_ID of the native chain of this asset > > **asset**: address of the asset > -> **transfer_hash**: Random ID of the transfer +> **target_chain**: ChainID of the recipient +> +> **target_address**: address of the recipient +> +> **sender**: pubkey of the sender +> +> **nonce**: nonce of the transfer This account is created when a user wants to lock tokens to transfer them to a foreign chain using the `ITransferOut` instruction. It is used to signal a pending transfer to a foreign chain and will also store the respective VAA provided using -`IPostVAA`. +`ISubmitVAA`. Once the VAA has been published this TransferOut is considered completed and can be evicted using `EvictTransferOut` after `VAA_EXPIRATION_TIME` has passed. #### _WrappedAsset_ Mint -> Seed derivation: `wrapped__` +> Seed derivation: `wrapped || || || ` +> +> **bridge**: Pubkey of the bridge > > **chain**: CHAIN_ID of the native chain of this asset > @@ -202,11 +214,33 @@ after `VAA_EXPIRATION_TIME` has passed. This account is an instance of `spl-token/Mint` tracks a wrapped asset on the Solana chain. -#### _NativeAsset_ TokenAccount +#### _WrappedAssetMeta_ Mint -> Seed derivation: `custody_` +> Seed derivation: `meta || || ` > -> **asset**: address of the asset on the native chain +> **bridge**: Pubkey of the bridge +> +> **wrapped**: address of the wrapped asset + +This account tracks the metadata about a wrapped asset to allow reverse lookups. + +#### _Custody_ TokenAccount + +> Seed derivation: `custody || || ` +> +> **bridge**: Pubkey of the bridge +> +> **asset**: address of the asset mint on the native chain This account is an instance of `spl-token/TokenAccount` and holds spl tokens in custody that have been transferred to a foreign chain. + +#### _ClaimedVAA_ Account + +> Seed derivation: `claim || || ` +> +> **bridge**: Pubkey of the bridge +> +> **hash**: signing hash of the VAA + +This account tracks a claimed VAA to prevent replay attacks. diff --git a/solana/bridge/src/state.rs b/solana/bridge/src/state.rs index 858b4927..f7672e9c 100644 --- a/solana/bridge/src/state.rs +++ b/solana/bridge/src/state.rs @@ -275,8 +275,8 @@ impl Bridge { asset: ForeignAddress, target_chain: u8, target_address: ForeignAddress, - user: ForeignAddress, - slot: u32, + sender: ForeignAddress, + nonce: u32, ) -> Vec> { vec![ "transfer".as_bytes().to_vec(), @@ -285,8 +285,8 @@ impl Bridge { asset.as_bytes().to_vec(), target_chain.as_bytes().to_vec(), target_address.as_bytes().to_vec(), - user.as_bytes().to_vec(), - slot.as_bytes().to_vec(), + sender.as_bytes().to_vec(), + nonce.as_bytes().to_vec(), ] } @@ -316,7 +316,7 @@ impl Bridge { /// Calculates derived seeds for a wrapped asset meta entry pub fn derive_wrapped_meta_seeds<'a>(bridge: &Pubkey, mint: &Pubkey) -> Vec> { vec![ - "claim".as_bytes().to_vec(), + "meta".as_bytes().to_vec(), bridge.to_bytes().to_vec(), mint.to_bytes().to_vec(), ]