Feat: New Account Index Enforcement#23
Conversation
|
Additional changes in commit Rust (Program): Tests: While running some tests caught a regression on the SDK that i created in the last PR so here's the SDK changes: |
7f201ae to
976c890
Compare
- Regenerated SDK using solita to include missing `program` account parameter - Updated incrementAccountIndex instruction calls in test files - Fixed 12 out of 15 failing tests (from 0xbbd AccountNotEnoughKeys error) - Remaining 3 failures are unrelated to SDK issue The `program` account was added in commit c0ed7ef for event logging but the SDK wasn't regenerated, causing tests to fail with error 0xbbd (AccountNotEnoughKeys - instruction received 2 accounts instead of 3). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add account utilization tracking and restrictions - Fix internal fund transfer validation - Add error variants for audit findings - Fix spending limit and transaction buffer checks
- Add accountIndexSpendingLimit test suite - Add internalFundTransferDelegate test suite - Add programInteractionExtensions test suite - Restore full test suite imports - Enable transpileOnly in tsconfig for faster test runs
Includes set_account_index, increment_account_index, and audit error variants
- Fix SmartAccountTransactionMessage to use beet.array() for stored state Vec<Pubkey> instead of smallArray (1-byte prefix) - Update fix-smallvec.js to not re-break this on regeneration - Add incrementAccountIndex calls in smart-account-sdk spending limit tests to unlock accountIndex 1 before use
Tests using vault indices > 0 need incrementAccountIndex calls after smart account creation. Also fixes missing program param in existing createIncrementAccountIndexInstruction calls.
# Conflicts: # sdk/smart-account/scripts/fix-smallvec.js
…ec-remediation-v2' into feat/implement-account-utilization # Conflicts: # programs/squads_smart_account_program/src/state/policies/utils/account_tracking.rs # sdk/smart-account/scripts/fix-smallvec.js # tests/index.ts
Implements vault index restriction to control which sub-accounts (vaults) can be used for transactions.
Overview
increment_account_indexinstructionProgram Changes
New Instruction:
increment_account_index• Increments
account_utilizationfield by 1, unlocking the next vault index• Callable by any signer with
Initiate,Vote, orExecutepermission• Cannot exceed index 250 (because that's for reserved account)
New Errors:
•
AccountIndexLocked- when trying to use a vault index that hasn't been unlocked•
MaxAccountIndexReached- when trying to increment beyond 250Validation Enforcement:
•
transaction_create.rs- validates account index when creating async transactions•
transaction_execute_sync.rs- validates for Settings-based sync transactions•
transaction_execute_sync_legacy.rs- validates for legacy sync transactionsConstants (in
state/settings.rs):• FREE_ACCOUNT_MAX_INDEX = 250
• RESERVED_ACCOUNT_START = 251
Tests
8 new tests:
incrementAccountIndex.ts:• Increment successfully (0→1)
• Increment multiple times (0→3)
• Non-signer cannot increment
• Proposer/Voter/Executor can increment (permission tests)
• Cannot increment beyond max index 250
transactionSynchronous.ts:• Sync transaction with locked index fails
• Reserved index (251) bypasses validation
transactionCreateFromBuffer.ts:• Creating transaction with locked index fails