-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(spending_limits): allow spending limits for non-members * fix(multisig_add_member) Additional check for duplication upon member config action. * fix(multisig_add_spending_limit) In the case of a controlled multisig (with config_authority), we run a duplicate check on the member keys in the spending limit. * fix(close_account) * updated account context for vault closing to incorporate missing proposal account (non init) * feat(config_transaction_accounts_close,vault_transaction_accounts_close): allow closing stale tx accounts with no proposal * feat(batch_accounts_close): allow closing stale tx accounts with no proposal --------- Co-authored-by: Vladimir Guguiev <[email protected]> * fix(cancellation_realloc) * Cancelation realloc and current member state check/retain * added comment about realloc * move new vote logic to a v2 ix to preserve backwards compatibility * new proposal cancel instruction (v2) * new account context labeled as ProposalCancel specifically * add the retain old member keys to existing cancel logic * Execute optimizations (#110) * fix(vault_seeds): removed iterations * pass vault seed slice directly * fix(execute-tx-message): optimization - moved signer seed iterations out of loop * chore(typo): fixed Fixed "threshold" typo * fix: Heap Optimization (#111) * heap optimization/removing inefficient clone * add: comments around explicit usage and consequences of `core::mem::take` --------- Co-authored-by: slg <[email protected]> * chore(cancel-tests): added test and sdk methods for cancel realloc * chore(cancel-test): verify account size changed * Feat: Incremental Transaction Uploading (#113) * wip: incremental tx uploading * add: incremental tx uploading ixns * generate sdk & add tests - createbuffer & extend passing* - createVaultTxFromBuffer failing with "Program Failed to Complete" * base case tests passing * add comments for clarity * expose buffer close & add test * add: extra tests -- buffer creation and extension * add: tests for transactionBufferClose * fix: uncomment tests * fix: space allocation buffer creation * add: additional helper for buffer size * add: buffer deserialization checks * dummy vercel commit * feat: tx buffer example & out of memory example --------- Co-authored-by: Joey Meere <[email protected]> * Feat: Custom Bump Allocator (#114) * wip: incremental tx uploading * add: incremental tx uploading ixns * generate sdk & add tests - createbuffer & extend passing* - createVaultTxFromBuffer failing with "Program Failed to Complete" * base case tests passing * add comments for clarity * expose buffer close & add test * add: extra tests -- buffer creation and extension * add: tests for transactionBufferClose * fix: uncomment tests * fix: space allocation buffer creation * add: additional helper for buffer size * add: buffer deserialization checks * dummy vercel commit * feat: tx buffer example & out of memory example * initial commit * feat: flipped bump allocator on its head * feat: heap tests, buffer chunking util + refactor * remove: heap test ix & add: allocator docs * rm: heapTest testing suite * add: script for running anchor test in detach * revert: Cargo.toml anchor-lang change * linting: cargo fmt --------- Co-authored-by: Joey Meere <[email protected]> * WIP * refactor: vault_transaction_from_buffer * feat: wrap context for createFromBuffer * add: comments * chore: fmt * refactor: wrap ProposalVote context inside ProposalCancelV2 * fix: typo * fix: comments from certora preliminary findings * fix: transaction_buffer_close seed constraints * fix: confusing semantics * fix: buffer vec size * small comment fixes * refactor: lamport mutation into system transfer * feat: u8 for buffer seeding * fix: bind transaction_buffer seeds to creator * remove: current member check for transaction_buffer_close * fix: creator check on vault_tx_create_from_buffer * remove: multisig mut in transaction_buffer instructions * remove: testing code from allocator * fix: tests * fix: MAX_BUFFER_SIZE saturation in invariant check * remove: heap testing instruction * deprecate: multisig_create * refactor: sdk for multisig_create deprecation * refactor: tests for multisig_create deprecation * add: custom deprecation error * tests: uncomment and fix * (tests)fix: broken tests from multisig_create deprecation * bump: program version to 2.1.0 * fix(program): space calculation transaction_buffer * bump: Anchor.toml solana-cli to 1.18.16 * bump(idl): to 2.1.0 * modify: max transaction_buffer size * fix(tests): accomodate new max buffer size * fix(tests): custom heap --------- Co-authored-by: Vladimir Guguiev <[email protected]> Co-authored-by: Orion <[email protected]> Co-authored-by: Joey Meere <[email protected]> Co-authored-by: Iceomatic <[email protected]>
- Loading branch information
1 parent
19597dc
commit 4a39ae1
Showing
70 changed files
with
6,291 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
{ | ||
"private": true, | ||
"workspaces": [ | ||
"sdk/*" | ||
], | ||
"scripts": { | ||
"build": "turbo run build", | ||
"test": "turbo run build && anchor test -- --features=testing && echo \"\n⚠️ Don't forget to recompile the .so file before deployment\n\"", | ||
"pretest": "mkdir -p target/deploy && cp ./test-program-keypair.json ./target/deploy/squads_multisig_program-keypair.json", | ||
"ts": "turbo run ts && yarn tsc --noEmit" | ||
}, | ||
"devDependencies": { | ||
"@solana/spl-token": "*", | ||
"@solana/spl-memo": "^0.2.3", | ||
"@types/bn.js": "5.1.0", | ||
"@types/mocha": "10.0.1", | ||
"@types/node-fetch": "2.6.2", | ||
"mocha": "10.2.0", | ||
"prettier": "2.6.2", | ||
"ts-node": "10.9.1", | ||
"turbo": "1.6.3", | ||
"typescript": "*" | ||
}, | ||
"resolutions": { | ||
"@solana/web3.js": "1.70.3", | ||
"@solana/spl-token": "0.3.6", | ||
"typescript": "4.9.4" | ||
} | ||
"private": true, | ||
"workspaces": [ | ||
"sdk/*" | ||
], | ||
"scripts": { | ||
"build": "turbo run build", | ||
"test:detached": "turbo run build && anchor test --detach -- --features=testing && echo \"\n⚠️ Don't forget to recompile the .so file before deployment\n\"", | ||
"test": "turbo run build && anchor test -- --features=testing && echo \"\n⚠️ Don't forget to recompile the .so file before deployment\n\"", | ||
"pretest": "mkdir -p target/deploy && cp ./test-program-keypair.json ./target/deploy/squads_multisig_program-keypair.json", | ||
"ts": "turbo run ts && yarn tsc --noEmit" | ||
}, | ||
"devDependencies": { | ||
"@solana/spl-token": "*", | ||
"@solana/spl-memo": "^0.2.3", | ||
"@types/bn.js": "5.1.0", | ||
"@types/mocha": "10.0.1", | ||
"@types/node-fetch": "2.6.2", | ||
"mocha": "10.2.0", | ||
"prettier": "2.6.2", | ||
"ts-node": "10.9.1", | ||
"turbo": "1.6.3", | ||
"typescript": "*" | ||
}, | ||
"resolutions": { | ||
"@solana/web3.js": "1.70.3", | ||
"@solana/spl-token": "0.3.6", | ||
"typescript": "4.9.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
Optimizing Bump Heap Allocation | ||
Objective: Increase available heap memory while maintaining flexibility in program invocation. | ||
1. Initial State: Default 32 KiB Heap | ||
Memory Layout: | ||
0x300000000 0x300008000 | ||
| | | ||
v v | ||
[--------------------] | ||
^ ^ | ||
| | | ||
VM Lower VM Upper | ||
Boundary Boundary | ||
Default Allocator (Allocates Backwards / Top Down) (Default 32 KiB): | ||
0x300000000 0x300008000 | ||
| | | ||
[--------------------] | ||
^ | ||
| | ||
Allocation starts here (SAFE) | ||
2. Naive Approach: Increase HEAP_LENGTH to 8 * 32 KiB + Default Allocator | ||
Memory Layout with Increased HEAP_LENGTH: | ||
0x300000000 0x300008000 0x300040000 | ||
| | | | ||
v v v | ||
[--------------------|------------------------------------|] | ||
^ ^ ^ | ||
| | | | ||
VM Lower VM Upper Allocation starts here | ||
Boundary Boundary (ACCESS VIOLATION!) | ||
Issue: Access violation occurs without requestHeapFrame, requiring it for every transaction. | ||
3. Optimized Solution: Forward Allocation with Flexible Heap Usage | ||
Memory Layout (Same as Naive Approach): | ||
0x300000000 0x300008000 0x300040000 | ||
| | | | ||
v v v | ||
[--------------------|------------------------------------|] | ||
^ ^ ^ | ||
| | | | ||
VM Lower VM Upper Allocator & VM | ||
Boundary Boundary Heap Limit | ||
Forward Allocator Behavior: | ||
a) Without requestHeapFrame: | ||
0x300000000 0x300008000 | ||
| | | ||
[--------------------] | ||
^ ^ | ||
| | | ||
VM Lower VM Upper | ||
Boundary Boundary | ||
Allocation | ||
starts here (SAFE) | ||
b) With requestHeapFrame: | ||
0x300000000 0x300008000 0x300040000 | ||
| | | | ||
[--------------------|------------------------------------|] | ||
^ ^ ^ | ||
| | | | ||
VM Lower | VM Upper | ||
Boundary Boundary | ||
Allocation Allocation continues Maximum allocation | ||
starts here with requestHeapFrame with requestHeapFrame | ||
(SAFE) | ||
Key Advantages: | ||
1. Compatibility: Functions without requestHeapFrame for allocations ≤32 KiB. | ||
2. Extensibility: Supports larger allocations when requestHeapFrame is invoked. | ||
3. Efficiency: Eliminates mandatory requestHeapFrame calls for all transactions. | ||
Conclusion: | ||
The forward allocation strategy offers a robust solution, providing both backward | ||
compatibility for smaller heap requirements and the flexibility to utilize extended | ||
heap space when necessary. | ||
The following allocator is a copy of the bump allocator found in | ||
solana_program::entrypoint and | ||
https://github.com/solana-labs/solana-program-library/blob/master/examples/rust/custom-heap/src/entrypoint.rs | ||
but with changes to its HEAP_LENGTH and its | ||
starting allocation address. | ||
*/ | ||
|
||
use solana_program::entrypoint::HEAP_START_ADDRESS; | ||
use std::{alloc::Layout, mem::size_of, ptr::null_mut}; | ||
|
||
/// Length of the memory region used for program heap. | ||
pub const HEAP_LENGTH: usize = 8 * 32 * 1024; | ||
|
||
struct BumpAllocator; | ||
|
||
unsafe impl std::alloc::GlobalAlloc for BumpAllocator { | ||
#[inline] | ||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { | ||
const POS_PTR: *mut usize = HEAP_START_ADDRESS as *mut usize; | ||
const TOP_ADDRESS: usize = HEAP_START_ADDRESS as usize + HEAP_LENGTH; | ||
const BOTTOM_ADDRESS: usize = HEAP_START_ADDRESS as usize + size_of::<*mut u8>(); | ||
let mut pos = *POS_PTR; | ||
if pos == 0 { | ||
// First time, set starting position to bottom address | ||
pos = BOTTOM_ADDRESS; | ||
} | ||
// Align the position upwards | ||
pos = (pos + layout.align() - 1) & !(layout.align() - 1); | ||
let next_pos = pos.saturating_add(layout.size()); | ||
if next_pos > TOP_ADDRESS { | ||
return null_mut(); | ||
} | ||
*POS_PTR = next_pos; | ||
pos as *mut u8 | ||
} | ||
|
||
#[inline] | ||
unsafe fn dealloc(&self, _: *mut u8, _: Layout) { | ||
// I'm a bump allocator, I don't free | ||
} | ||
} | ||
|
||
// Only use the allocator if we're not in a no-entrypoint context | ||
#[cfg(not(feature = "no-entrypoint"))] | ||
#[global_allocator] | ||
static A: BumpAllocator = BumpAllocator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.