Skip to content

Commit 2b0a7cf

Browse files
committed
fix: correct Shank IDL, add devnet smoke test, update CU benchmarks
- Fix 4 instructions missing rent_sysvar in Shank enum (CreateWallet, AddAuthority, TransferOwnership, CreateSession) - Add 3 missing deferred execution instructions to Shank enum (Authorize disc=6, ExecuteDeferred disc=7, ReclaimDeferred disc=8) - Fix RemoveAuthority auth_extra account annotation - Regenerate program/idl.json with all 9 correct instruction layouts - Add comprehensive devnet smoke test exercising all instructions across all auth types (Ed25519, Secp256r1, Session) and roles (Owner, Admin, Spender) with CU/TX size/rent cost reporting - Update CU numbers in docs from local validator to devnet-measured actuals (e.g. Secp256r1 Execute 12,441 -> 9,441 CU) - Expand Costs.md CU table from 7 to 20 rows covering all operations - Add Ed25519 Execute column to comparison tables
1 parent de4eb42 commit 2b0a7cf

7 files changed

Lines changed: 919 additions & 54 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
2525
- ExecuteDeferred instruction (disc=7): TX2 verifies hashes and executes via CPI with vault signing
2626
- ReclaimDeferred instruction (disc=8): closes expired DeferredExec accounts, refunds rent to original payer
2727
- DeferredExecAccount (176 bytes): stores instruction/account hashes, wallet, authority, payer, expiry
28+
- Devnet smoke test (`tests-sdk/tests/devnet-smoke.ts`): exercises all 9 instructions across Ed25519/Secp256r1/Session auth types and Owner/Admin/Spender roles, reporting CU/TX size/rent
2829
- Deferred execution benchmarks (CU + tx size measurements for TX1/TX2)
2930
- Error codes 3014-3018 for deferred execution (expired, hash mismatch, invalid expiry, unauthorized reclaim)
3031
- SDK builders: `createAuthorizeIx`, `createExecuteDeferredIx`, `createReclaimDeferredIx`
@@ -63,6 +64,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6364
- Counter size: u64 -> u32 (4 billion operations per authority is sufficient)
6465
- Execute Secp256r1 transaction size: 708 -> 658 bytes (50 bytes saved)
6566
- Execute Secp256r1 accounts: 8 -> 7 (SlotHashes sysvar removed)
67+
- Cost documentation: updated all CU numbers from local validator to devnet-measured actuals, expanded CU table to all 9 instructions across all auth types and roles
68+
- Shank IDL: fixed 4 instructions missing `rent_sysvar` accounts, added 3 missing deferred execution instructions (Authorize, ExecuteDeferred, ReclaimDeferred)
6669

6770
### Fixed
6871

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ A high-performance smart wallet program on Solana with passkey (WebAuthn/Secp256
2222

2323
## LazorKit vs Normal SOL Transfer
2424

25-
| Metric | Normal Transfer | LazorKit (Secp256r1) | LazorKit (Session) |
26-
|---|---|---|---|
27-
| Compute Units | 150 | 12,441 | 8,983 |
28-
| Transaction Size | 215 bytes | 658 bytes | 452 bytes |
29-
| Accounts | 2 | 7 | 7 |
30-
| Instructions | 1 | 2 | 1 |
31-
| Transaction Fee | 0.000005 SOL | 0.000005 SOL | 0.000005 SOL |
25+
| Metric | Normal Transfer | LazorKit (Secp256r1) | LazorKit (Ed25519) | LazorKit (Session) |
26+
|---|---|---|---|---|
27+
| Compute Units | 150 | 9,441 | 5,864 | 4,483-5,983 |
28+
| Transaction Size | 215 bytes | 658 bytes | 452 bytes | 452 bytes |
29+
| Accounts | 2 | 7 | 7 | 7 |
30+
| Instructions | 1 | 2 | 1 | 1 |
31+
| Transaction Fee | 0.000005 SOL | 0.000005 SOL | 0.000005 SOL | 0.000005 SOL |
3232

33-
Session keys are ideal for frequent transactions -- they skip the Secp256r1 precompile and use a simple Ed25519 signer, resulting in lower CU and smaller transactions.
33+
Session keys are ideal for frequent transactions -- they skip the Secp256r1 precompile and use a simple Ed25519 signer, resulting in lower CU and smaller transactions. All CU measurements are from real devnet transactions.
3434

3535
### Deferred Execution (Large Payloads)
3636

3737
For operations exceeding the ~574 bytes available in a single Secp256r1 Execute tx (e.g., Jupiter swaps):
3838

3939
| Metric | Immediate Execute | Deferred (2 txs) |
4040
|---|---|---|
41-
| Total CU | 12,441 | 18,613 (11,709 + 6,904) |
41+
| Total CU | 9,441 | 15,613 (10,209 + 5,404) |
4242
| Inner Ix Capacity | ~574 bytes | ~1,100 bytes (1.9x) |
4343
| Tx Fee | 0.000005 SOL | 0.00001 SOL |
4444
| Temp Rent | -- | 0.00212 SOL (refunded) |

docs/Architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ For Secp256r1 Execute, the signed payload includes a SHA256 hash of all account
241241

242242
| Path | Inner Ix Capacity | Total CU | Tx Fee |
243243
|---|---|---|---|
244-
| Immediate Execute | ~574 bytes | 12,441 | 0.000005 SOL |
245-
| Deferred (2 txs) | ~1,100 bytes (1.9x) | 18,613 | 0.00001 SOL |
244+
| Immediate Execute | ~574 bytes | 9,441 | 0.000005 SOL |
245+
| Deferred (2 txs) | ~1,100 bytes (1.9x) | 15,613 | 0.00001 SOL |
246246

247247
### Security Properties
248248

docs/Costs.md

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,65 @@
11
# LazorKit Cost Analysis
22

3-
This document provides comprehensive cost data for the LazorKit smart wallet program on Solana. All compute unit (CU) measurements are from real transactions against a local validator. Rent costs use Solana's standard formula.
3+
This document provides comprehensive cost data for the LazorKit smart wallet program on Solana. All compute unit (CU) measurements are from real transactions on devnet. Rent costs use Solana's standard formula.
44

55
> Program ID: `FLb7fyAtkfA4TSa2uYcAT8QKHd2pkoMHgmqfnXFXo7ao`
66
77
---
88

99
## Compute Units & Transaction Size
1010

11-
| Instruction | CU | Tx Size (bytes) | Ix Data (bytes) | Accounts | Instructions |
12-
|---|---|---|---|---|---|
13-
| Normal SOL Transfer (baseline) | 150 | 215 | 12 | 2 | 1 |
14-
| CreateWallet (Ed25519) | 15,187 | 408 | 73 | 6 | 1 |
15-
| CreateWallet (Secp256r1) | 13,687 | 453 | 118 | 6 | 1 |
16-
| AddAuthority (Ed25519 admin) | 5,846 | 473 | 41 | 7 | 1 |
17-
| Execute Secp256r1 (SOL transfer) | 12,441 | 658 | 254 | 7 | 2 |
18-
| Execute Session (SOL transfer) | 8,983 | 452 | 20 | 7 | 1 |
19-
| CreateSession (Ed25519) | 6,015 | 473 | 41 | 7 | 1 |
11+
| Instruction | CU | Tx Size (bytes) |
12+
|---|---|---|
13+
| Normal SOL Transfer (baseline) | 150 | 215 |
14+
| **CreateWallet** | | |
15+
| CreateWallet (Ed25519 owner) | 16,688 | 408 |
16+
| CreateWallet (Secp256r1 owner) | 13,688 | 454 |
17+
| **AddAuthority** | | |
18+
| AddAuthority (Ed25519 owner → Ed25519 admin) | 7,347 | 473 |
19+
| AddAuthority (Ed25519 admin → Ed25519 spender) | 5,853 | 473 |
20+
| AddAuthority (Secp256r1 owner → Ed25519 admin) | 11,621 | 679 |
21+
| AddAuthority (Secp256r1 owner → Secp256r1 spender) | 11,646 | 726 |
22+
| **Execute (SOL Transfer)** | | |
23+
| Execute (Ed25519 owner) | 5,864 | 452 |
24+
| Execute (Ed25519 spender) | 5,864 | 452 |
25+
| Execute (Secp256r1 owner) | 9,441 | 658 |
26+
| Execute (Secp256r1 spender) | 9,441 | 658 |
27+
| Execute (Session key) | 4,483–5,983 | 452 |
28+
| **CreateSession** | | |
29+
| CreateSession (Ed25519 admin) | 9,015 | 473 |
30+
| CreateSession (Secp256r1 admin) | 13,289 | 679 |
31+
| **RemoveAuthority** | | |
32+
| RemoveAuthority (Ed25519) | 621 | 368 |
33+
| RemoveAuthority (Secp256r1) | 4,691 | 574 |
34+
| **TransferOwnership** | | |
35+
| TransferOwnership (Ed25519 → Ed25519) | 5,872 | 466 |
36+
| TransferOwnership (Secp256r1 → Secp256r1) | 14,669 | 719 |
2037

2138
**Notes:**
22-
- CU values are from real transactions on a local validator
23-
- Secp256r1 Execute requires 2 instructions (precompile verification + execute)
24-
- Session Execute is cheaper -- only 1 instruction, no precompile, no auth payload
39+
- CU values are from real transactions on devnet
40+
- Secp256r1 operations require 2 instructions (precompile verification + program ix), increasing TX size by ~200 bytes
41+
- Session Execute is the cheapest auth path -- only 1 instruction, no precompile, no auth payload
2542
- All operations fit well within Solana's 200,000 CU default budget
2643
- Transaction sizes are well within Solana's 1,232-byte limit
44+
- RemoveAuthority refunds rent to a specified destination
2745

2846
### Deferred Execution (Large Payloads)
2947

3048
For operations exceeding the ~574 bytes available in a single Secp256r1 Execute transaction:
3149

3250
| Instruction | CU | Tx Size (bytes) | Accounts | Instructions |
3351
|---|---|---|---|---|
34-
| Authorize (TX1) | 11,709 | 705 | 7 | 2 |
35-
| ExecuteDeferred (TX2, 1 inner ix) | 6,904 | 356 | 7 | 1 |
52+
| Authorize (TX1) | 10,209 | 705 | 7 | 2 |
53+
| ExecuteDeferred (TX2, 1 inner ix) | 5,404 | 356 | 7 | 1 |
3654

3755
| Metric | Immediate Execute | Deferred (2 txs) |
3856
|---|---|---|
39-
| Total CU | 12,441 | 18,613 (11,709 + 6,904) |
57+
| Total CU | 9,441 | 15,613 (10,209 + 5,404) |
4058
| Inner Ix Capacity | ~574 bytes | ~1,100 bytes (1.9x) |
4159
| Tx Fee | 0.000005 SOL | 0.00001 SOL |
4260
| Temp Rent | -- | 0.002116 SOL (refunded) |
4361

44-
The deferred path trades ~50% more total CU and 2x the tx fee for 1.9x the inner instruction space. The DeferredExec account rent (0.002116 SOL) is temporary -- it is refunded when TX2 executes or when the payer reclaims an expired authorization.
62+
The deferred path trades ~66% more total CU and 2x the tx fee for 1.9x the inner instruction space. The DeferredExec account rent (0.002116 SOL) is temporary -- it is refunded when TX2 executes or when the payer reclaims an expired authorization.
4563

4664
---
4765

@@ -61,21 +79,22 @@ The Secp256r1 Execute transaction was optimized from **708 bytes to 658 bytes**
6179

6280
## LazorKit vs Normal SOL Transfer
6381

64-
| Metric | Normal Transfer | LazorKit Secp256r1 | LazorKit Session | Notes |
65-
|---|---|---|---|---|
66-
| Compute Units | 150 | 12,441 | 8,983 | Session uses Ed25519 signer (no precompile) |
67-
| Transaction Size | 215 bytes | 658 bytes | 452 bytes | Session tx is smaller (no precompile ix) |
68-
| Instruction Data | 12 bytes | 254 bytes | 20 bytes | Session has no auth payload |
69-
| Accounts | 2 | 7 | 7 | Secp256r1 uses sysvar_instructions only |
70-
| Instructions per Tx | 1 | 2 | 1 | Session needs only 1 instruction |
71-
| Transaction Fee | 0.000005 SOL | 0.000005 SOL | 0.000005 SOL | Same base fee |
82+
| Metric | Normal Transfer | LazorKit Secp256r1 | LazorKit Ed25519 | LazorKit Session | Notes |
83+
|---|---|---|---|---|---|
84+
| Compute Units | 150 | 9,441 | 5,864 | 4,483–5,983 | Session is cheapest auth path |
85+
| Transaction Size | 215 bytes | 658 bytes | 452 bytes | 452 bytes | Session tx is same as Ed25519 |
86+
| Instruction Data | 12 bytes | 254 bytes | 20 bytes | 20 bytes | Session has no auth payload |
87+
| Accounts | 2 | 7 | 7 | 7 | Secp256r1 uses sysvar_instructions |
88+
| Instructions per Tx | 1 | 2 | 1 | 1 | Only Secp256r1 needs precompile ix |
89+
| Transaction Fee | 0.000005 SOL | 0.000005 SOL | 0.000005 SOL | 0.000005 SOL | Same base fee |
7290

7391
**Why the overhead is acceptable:**
74-
- 12,441 CU (Secp256r1) is only **6.2%** of the 200,000 CU default budget
75-
- 8,983 CU (Session) is only **4.5%** of the 200,000 CU default budget
92+
- 9,441 CU (Secp256r1) is only **4.7%** of the 200,000 CU default budget
93+
- 5,864 CU (Ed25519) is only **2.9%** of the budget
94+
- 4,483–5,983 CU (Session) is only **2.2–3.0%** of the budget
7695
- 658 bytes (Secp256r1) is **53%** of the 1,232-byte transaction limit, leaving **574 bytes** for inner instructions
7796
- Deferred Execution provides ~1,100 bytes for inner instructions when needed (1.9x)
78-
- 452 bytes (Session) is only **37%** of the 1,232-byte limit
97+
- 452 bytes (Ed25519/Session) is only **37%** of the 1,232-byte limit
7998
- Transaction fee is identical (base fee is per-signature, not per-CU)
8099
- The overhead buys: passkey auth, RBAC, replay protection, session keys, multi-sig
81100

@@ -174,11 +193,8 @@ The compact data sizes are achieved through:
174193
## Reproducing These Numbers
175194

176195
```bash
177-
# Start local validator
178-
cd tests-sdk && npm run validator:start
179-
180-
# Run benchmarks
181-
npm run benchmark
196+
# Run devnet smoke test (all instructions, all auth types)
197+
cd tests-sdk && npx tsx tests/devnet-smoke.ts
182198
```
183199

184-
The benchmark script (`tests-sdk/tests/benchmark.ts`) sends real transactions and extracts CU consumption from transaction metadata.
200+
The devnet smoke test exercises all 9 instructions across all authority types (Ed25519, Secp256r1, Session) and roles (Owner, Admin, Spender), reporting CU consumption, TX size, and rent costs from real devnet transactions.

0 commit comments

Comments
 (0)