Skip to content

Commit 17b3f6c

Browse files
thmzltguibescos
andauthored
Revamp scripts (#10)
* Revamp scripts * Remove empty section from Anchor.toml * Switch to pnpm, improve multisig support, update scripts, etc. * fix: ledger send transaction logic (#11) --------- Co-authored-by: guibescos <59208140+guibescos@users.noreply.github.com>
1 parent f52a265 commit 17b3f6c

17 files changed

Lines changed: 5860 additions & 1324 deletions

File tree

Anchor.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[features]
2-
seeds = true
2+
resolution = true
33
skip-lint = false
4+
45
[programs.localnet]
56
program_authority_escrow = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"
67

78
[registry]
89
url = "https://api.apr.dev"
910

1011
[provider]
11-
cluster = "Localnet"
12+
cluster = "localnet"
1213
wallet = "/home/gbescos/.config/solana/id.json"
1314

1415
[scripts]

Cargo.lock

Lines changed: 58 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 108 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,119 @@
11
# program-authority-escrow
22

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.
44

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
108

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:
1320

14-
## Testing
15-
To run tests:
1621
```shell
17-
cargo test-sbf
22+
pnpm install
1823
```
1924

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:
22114

23115
```shell
24-
cargo build-sbf
116+
pnpm propose
117+
pnpm accept
118+
pnpm revert
25119
```
26-
Artifacts will be placed at: `target/deploy/*.so`

0 commit comments

Comments
 (0)