|
1 | 1 | # program-authority-escrow |
2 | 2 |
|
3 | | -A minimalistic, stateless program to safely transfer a solana program from one upgrade authority to another one. |
| 3 | +A stateless Solana program for safe program authority transfers. |
4 | 4 |
|
5 | | -The way it works : |
6 | | -- The current authority uses Propose to transfer the authority of any program to a PDA of the escrow seeded by (current_authority, new_authority) |
7 | | -- Once the authority has been transferred two outcomes are possible : |
8 | | - - If the current authority calls Revert, the PDA will give the authority back to the current authority |
9 | | - - If the new authority calls Accept, the PDA will give the authority to the new authority |
| 5 | +The current authority calls `propose` to transfer authority to an escrow PDA seeded by `(current_authority, new_authority)`. From there: |
| 6 | +- The current authority can call `revert` to reclaim authority |
| 7 | +- The new authority can call `accept` to complete the transfer |
10 | 8 |
|
11 | | -Basically, this program enforces that the new authority has signed before they accept the authority. |
12 | | -This makes errors where we mistakenly transfer the authority to a key that we don't own reversible. |
| 9 | +This ensures the new authority has signed before accepting, making accidental transfers to wrong keys reversible. |
| 10 | + |
| 11 | +Build with `cargo build-sbf` and test with `cargo test-sbf`. |
| 12 | + |
| 13 | +## Tutorial: Transfer Program Authority to a Squads Multisig |
| 14 | + |
| 15 | +This tutorial walks through transferring a Solana program's upgrade authority from a single keypair to a Squads v3 multisig vault. |
| 16 | + |
| 17 | +### Prerequisites |
| 18 | + |
| 19 | +Install dependencies: |
13 | 20 |
|
14 | | -## Testing |
15 | | -To run tests: |
16 | 21 | ```shell |
17 | | -cargo test-sbf |
| 22 | +pnpm install |
18 | 23 | ``` |
19 | 24 |
|
20 | | -## Building |
21 | | -To build: |
| 25 | +You'll need: |
| 26 | +- The current program authority keypair (file path or Ledger hardware wallet) |
| 27 | +- Your program's address |
| 28 | +- Your Squads v3 multisig address |
| 29 | +- A multisig member keypair to create and approve the proposal |
| 30 | + |
| 31 | +### Step 1: Propose the Transfer |
| 32 | + |
| 33 | +The current authority proposes transferring the program to the escrow. This moves authority from your keypair to a temporary escrow PDA, where it waits for the new authority to accept. |
| 34 | + |
| 35 | +```shell |
| 36 | +pnpm propose \ |
| 37 | + --keypair /path/to/current-authority.json \ |
| 38 | + --program <PROGRAM_ADDRESS> \ |
| 39 | + --authority <MULTISIG_VAULT_ADDRESS> |
| 40 | +``` |
| 41 | + |
| 42 | +The `--authority` should be the multisig vault PDA that will become the new program authority. You can find this address in the Squads UI or derive it using vault index 1 (the default). |
| 43 | + |
| 44 | +If using a Ledger: |
| 45 | + |
| 46 | +```shell |
| 47 | +pnpm propose \ |
| 48 | + --keypair ledger \ |
| 49 | + --derivation-path 0/0 \ |
| 50 | + --program <PROGRAM_ADDRESS> \ |
| 51 | + --authority <MULTISIG_VAULT_ADDRESS> |
| 52 | +``` |
| 53 | + |
| 54 | +### Step 2: Accept via Multisig Proposal |
| 55 | + |
| 56 | +The new authority (the multisig vault) must accept the transfer. Since a vault can't sign directly, this creates a Squads proposal that members vote on. |
| 57 | + |
| 58 | +```shell |
| 59 | +pnpm accept \ |
| 60 | + --keypair /path/to/multisig-member.json \ |
| 61 | + --program <PROGRAM_ADDRESS> \ |
| 62 | + --authority <PREVIOUS_AUTHORITY_ADDRESS> \ |
| 63 | + --multisig <MULTISIG_ADDRESS> |
| 64 | +``` |
| 65 | + |
| 66 | +Here: |
| 67 | +- `--keypair` is a multisig member who will create and initially approve the proposal |
| 68 | +- `--authority` is the previous authority that proposed the transfer (from Step 1) |
| 69 | +- `--multisig` is the Squads multisig address (not the vault) |
| 70 | + |
| 71 | +This command: |
| 72 | +1. Creates a new transaction in the multisig |
| 73 | +2. Adds the accept instruction |
| 74 | +3. Activates the transaction |
| 75 | +4. Casts the first approval vote |
| 76 | + |
| 77 | +### Step 3: Complete Multisig Approval |
| 78 | + |
| 79 | +Other multisig members must now approve the proposal in the Squads UI until it reaches the threshold. Once approved and executed, the program authority transfer is complete. |
| 80 | + |
| 81 | +### Reverting a Transfer |
| 82 | + |
| 83 | +If you need to cancel before the new authority accepts, the current authority can revert: |
| 84 | + |
| 85 | +```shell |
| 86 | +pnpm revert \ |
| 87 | + --keypair /path/to/current-authority.json \ |
| 88 | + --program <PROGRAM_ADDRESS> \ |
| 89 | + --authority <NEW_AUTHORITY_ADDRESS> |
| 90 | +``` |
| 91 | + |
| 92 | +If the current authority is already a multisig vault: |
| 93 | + |
| 94 | +```shell |
| 95 | +pnpm revert \ |
| 96 | + --keypair /path/to/multisig-member.json \ |
| 97 | + --program <PROGRAM_ADDRESS> \ |
| 98 | + --authority <NEW_AUTHORITY_ADDRESS> \ |
| 99 | + --multisig <MULTISIG_ADDRESS> |
| 100 | +``` |
| 101 | + |
| 102 | +### Advanced Options |
| 103 | + |
| 104 | +All scripts support these additional options: |
| 105 | + |
| 106 | +| Option | Description | |
| 107 | +|--------|-------------| |
| 108 | +| `-u, --url <rpc_url>` | RPC endpoint (default: `https://api.mainnet-beta.solana.com`) | |
| 109 | +| `-i, --authority-index <n>` | Multisig vault index (default: 1) | |
| 110 | +| `-M, --multisig-program <address>` | Custom Squads v3 program address | |
| 111 | +| `-d, --derivation-path <path>` | Ledger derivation path as `account/change` | |
| 112 | + |
| 113 | +Run any script without arguments to see full usage: |
22 | 114 |
|
23 | 115 | ```shell |
24 | | -cargo build-sbf |
| 116 | +pnpm propose |
| 117 | +pnpm accept |
| 118 | +pnpm revert |
25 | 119 | ``` |
26 | | -Artifacts will be placed at: `target/deploy/*.so` |
|
0 commit comments