Skip to content

Commit b6b681a

Browse files
authored
solana: Update documentation for v3.0.0 changes (#592)
This PR adds: * Update outdated commands and links * Reorder Solana README headings to follow EVM * Remove obsolete troubleshooting section and add SPL Multisig support section
1 parent 7058b69 commit b6b681a

File tree

6 files changed

+76
-60
lines changed

6 files changed

+76
-60
lines changed

docs/Transceiver.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The Transceiver is intended to offer a protocol-agnostic interface for sending and receiving cross-chain messages. For Native Token Transfers, this entails initiating attestation generation on the source chain, verifying the resulting attestation on the destination chain, and delivering the message to the associated `NttManager`.
66

7-
In the provided implementations ([EVM](/evm/src/Transceiver/Transceiver.sol)/[SVM](/solana/programs/example-native-token-transfers/src/transceivers/wormhole/)), Transceiver are intended to have a many-to-one or one-to-one relationship with Managers.
7+
In the provided implementations ([EVM](/evm/src/Transceiver/Transceiver.sol)/[SVM](/solana/programs/ntt-transceiver/src/wormhole/)), Transceivers are intended to have a many-to-one relationship with Managers.
88

99
## Message Specification
1010

evm/README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,31 @@ Install Foundry tools(https://book.getfoundry.sh/getting-started/installation),
166166
Run the following command to install necessary dependencies and to build the smart contracts:
167167

168168
```shell
169-
$ make build-evm
169+
$ make build
170170
```
171171

172172
### Test
173173

174174
To run the full evm test-suite run the following command:
175175

176176
```shell
177-
$ make test-evm
177+
$ make test
178178
```
179179

180180
The test-suite includes unit tests, along with property-based fuzz tests, and integration-tests.
181181

182182
### Format
183183

184-
To format the files run this command from the root directory.
184+
To check for format errors run the following command:
185185

186186
```shell
187-
$ make fix-fmt
187+
$ make lint
188+
```
189+
190+
To format the files run the following command:
191+
192+
```shell
193+
$ make fix-lint
188194
```
189195

190196
### Gas Snapshots

solana/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.DEFAULT_GOAL = build
22
.PHONY: build cargo-build anchor-build prod-build test cargo-test anchor-test idl sdk clean node_modules lint cargo-lint anchor-lint fix-lint
33

4-
#find and convert version line:
5-
# turn `const VERSION: &str = "major.minor.patch";` into `major_minor_patch`
6-
#use make functions to minimize dependence on shell
4+
# Find and convert version line:
5+
# Turn `const VERSION: &str = "major.minor.patch";` into `major_minor_patch`
6+
# Use make functions to minimize dependence on shell
77
VERSION = $(subst .,_,$(subst ;,,$(subst ",,$(lastword \
88
$(shell grep "const VERSION" programs/example-native-token-transfers/src/lib.rs) \
99
))))
@@ -18,7 +18,7 @@ build: cargo-build anchor-build
1818
cargo-build:
1919
BPF_OUT_DIR="$(pwd)/target/deploy" cargo build-sbf
2020

21-
# after building, remove the generics from the idl file. This is necessary as of anchor 0.29.0,
21+
# After building, remove the generics from the idl file. This is necessary as of anchor 0.29.0,
2222
# because the javascript library does not support generics yet, and just panics
2323
anchor-build:
2424
anchor build --arch sbf

solana/README.md

+61-51
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
# Solana
22

3-
## Prequisities
4-
5-
Ensure that you are using the correct version of the Solana and Anchor CLI tools by consulting `Anchor.toml`.
6-
7-
```toml
8-
[toolchain]
9-
anchor_version = "0.29.0" # CLI
10-
solana_version = "1.18.10"
11-
```
12-
13-
You will also need to install the toolchain listed in `rust-toolchain`. You can verify this by running:
14-
15-
```sh
16-
rustup show
17-
```
18-
193
## Design Overview
204

215
### Message Lifecycle (Solana)
@@ -41,14 +25,14 @@ The program checks rate limits via the `consume_or_delay` function during the tr
4125

4226
If the transfer amount fits within the current capacity:
4327

44-
- Reduce the current capacity
45-
- Refill the inbound capacity for the destination chain
28+
- Reduce the current capacity.
29+
- Refill the inbound capacity for the destination chain.
4630
- Add the transfer to the outbox with `release_timestamp` set to the current timestamp, so it can be released immediately.
4731

4832
If the transfer amount does not fit within the current capacity:
4933

50-
- If `shouldQueue = true`, add the transfer to the outbox with `release_timestamp` set to the current timestamp plus the configured `RATE_LIMIT_DURATION`.
51-
- If `shouldQueue = false`, revert with a `TransferExceedsRateLimit` error
34+
- If `should_queue = true`, add the transfer to the outbox with `release_timestamp` set to the current timestamp plus the configured `RATE_LIMIT_DURATION`.
35+
- If `should_queue = false`, revert with a `TransferExceedsRateLimit` error.
5236

5337
3. **Send**
5438

@@ -76,7 +60,7 @@ The following will be produced in the program logs:
7660
Program log: Instruction: ReceiveMessage
7761
```
7862

79-
[`redeem`] checks the inbound rate limit and places the message in an Inbox. Logic works the same as the outbound rate limit we mentioned previously.
63+
[`redeem`] checks the inbound rate limit and places the message in an Inbox. The logic works the same as the outbound rate limit we mentioned previously.
8064

8165
The following will be produced in the program logs:
8266

@@ -109,51 +93,77 @@ The additional payload field should then have your custom struct available every
10993

11094
You can then modify [release_outbound](./programs/example-native-token-transfers/src/transceivers/wormhole/instructions/release_outbound.rs) and [redeem](./programs/example-native-token-transfers/src/instructions/redeem.rs) to generate and process the additional payload.
11195

112-
## Testing
96+
## SPL Multisig Support
97+
98+
Using [SPL Multisig](https://docs.rs/spl-token/latest/spl_token/state/struct.Multisig.html), you can enable multiple minters on Solana. For example, this allows NTT to burn/mint tokens without being the only authority to do so, i.e. the asset issuer can also retain mint authority.
99+
100+
1. **Create valid SPL Multisig**
101+
102+
The SPL Multisig should meet the following criteria to qualify as a valid mint authority for NTT:
103+
104+
- Number of signers required ([m](https://docs.rs/spl-token/latest/spl_token/state/struct.Multisig.html#structfield.m)) should be `1`
105+
- One of the [signers](https://docs.rs/spl-token/latest/spl_token/state/struct.Multisig.html#structfield.signers) must be the `token_authority` PDA
106+
107+
2. **Set valid SPL Multisig as mint authority**
108+
109+
You can set the created multisig as the mint authority via the [`accept_token_authority`] instruction.
110+
111+
> If the current mint authority is also an SPL Multisig, use the [`accept_token_authority_from_multisig`] instruction instead.
112+
113+
3. **Use [`*_multisig`] instruction variants**
113114

114-
The test files are loacated in the `sdk/solana/__tests__/` directory
115+
To initialize NTT, use the [`initialize_multisig`] instruction instead.
115116

116-
In order to run them, the Solana programs must be built and their IDL made available to the SDK.
117+
In `burning` mode, to release the inbound transfer and the mint tokens to the recipient, use the [`release_inbound_mint_multisig`] instruction instead.
117118

118-
To ensure the SDK has the generated IDL, run the tests with the make command:
119+
## Prerequisites
120+
121+
### Installation
122+
123+
Ensure that you are using the correct version of the Solana and Anchor CLI tools by consulting `Anchor.toml`.
124+
125+
```toml
126+
[toolchain]
127+
anchor_version = "0.29.0" # CLI
128+
solana_version = "1.18.10"
129+
```
130+
131+
Install the toolchain listed in `rust-toolchain`. You can verify this by running:
119132

120133
```sh
121-
make test
134+
rustup show
122135
```
123136

124-
### Troubleshooting
137+
Install [`jq`](https://jqlang.github.io/jq/) and [`tsx`](https://www.npmjs.com/package/tsx) globally as they are required by build scripts.
125138

126-
<details>
127-
<summary><code>make: *** No rule to make target `test'. Stop.</code></summary>
139+
### Build
128140

129-
- Ensure `Makefile` has target `test`
130-
</details>
141+
Run the following command to install necessary dependencies and to build the programs:
131142

132-
<details>
133-
<summary><code>tsx: command not found</code></summary>
143+
```sh
144+
make build
145+
```
134146

135-
- Screenshot:
136-
<img src="images/tsx-command-not-found.png" alt="tsx command not found screenshot">
137-
- Update `Makefile` ([line #29](https://github.com/wormhole-foundation/example-native-token-transfers/blob/main/solana/Makefile#L29)) from:
147+
### Test
138148

139-
```sh
140-
tsx scripts/regenerateIdl.ts $$jsonfile > $$tsfile; \
141-
```
149+
Run the following command to generate the IDL and run the full Solana test-suite:
142150

143-
to:
151+
```sh
152+
make test
153+
```
144154

145-
```sh
146-
npx tsx scripts/regenerateIdl.ts $$jsonfile > $$tsfile; \
147-
```
155+
The test-suite includes cargo unit tests and Anchor integration tests.
148156

149-
</details>
157+
### Format
150158

151-
<details>
152-
<summary><code>Lifecycle script `build:esm` failed with error</code></summary>
159+
Run the following command to check for lint errors:
153160

154-
- Screenshot:
155-
<img src="images/lifecycle-script.png" alt="lifecycle script screenshot">
156-
- This occurs due to Typescript files failing compilation.
157-
- [`patch-idl` script](https://github.com/wormhole-foundation/example-native-token-transfers/blob/main/solana/scripts/patch-idl) requires [`jq`](https://jqlang.github.io/jq/) to be installed. Install `jq` and retry.
161+
```sh
162+
make lint
163+
```
164+
165+
Run the following command to fix lint errors:
158166

159-
</details>
167+
```sh
168+
make fix-lint
169+
```

solana/images/lifecycle-script.png

-38.9 KB
Binary file not shown.
-102 KB
Binary file not shown.

0 commit comments

Comments
 (0)