Skip to content

Commit 81a7c5c

Browse files
committed
test: compress and close sdk
stash
1 parent 2e57db9 commit 81a7c5c

File tree

19 files changed

+1012
-513
lines changed

19 files changed

+1012
-513
lines changed

Cargo.lock

Lines changed: 26 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ rand = "0.8.5"
235235

236236
[patch.crates-io]
237237
# Profiling logs and state is handled here
238-
solana-program-runtime = { path = "../agave/program-runtime" }
238+
solana-program-runtime = { git = "https://github.com/Lightprotocol/agave", rev = "580e29f03e4176a4a5525abc188a948c6595c47f" }
239239
# Profiling syscalls are defined here
240-
solana-bpf-loader-program = { path = "../agave/programs/bpf_loader" }
240+
solana-bpf-loader-program = { git = "https://github.com/Lightprotocol/agave", rev = "580e29f03e4176a4a5525abc188a948c6595c47f" }
241+
# Patch solana-program-memory to use older version where is_nonoverlapping is public
242+
solana-program-memory = { git = "https://github.com/anza-xyz/solana-sdk", rev = "1c1d667f161666f12f5a43ebef8eda9470a8c6ee" }

program-libs/ctoken-types/src/instructions/transfer2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl Compression {
134134
source_or_recipient: u8,
135135
authority: u8,
136136
rent_recipient_index: u8,
137+
compressed_account_index: u8,
137138
) -> Self {
138139
Compression {
139140
amount, // the full balance of the ctoken account to be compressed
@@ -142,7 +143,7 @@ impl Compression {
142143
source_or_recipient,
143144
authority,
144145
pool_account_index: rent_recipient_index,
145-
pool_index: 0,
146+
pool_index: compressed_account_index,
146147
bump: 0,
147148
}
148149
}

programs/compressed-token/program/src/transfer2/native_compression/native.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ fn validate_compressed_token_account(
174174
.get_u8(compressed_token_account.owner, "CompressAndClose: owner")?
175175
.key()
176176
{
177+
msg!(
178+
"*compressed_token.owner {:?} packed_accounts owner: {:?}",
179+
solana_pubkey::Pubkey::new_from_array(compressed_token.owner.to_bytes()),
180+
solana_pubkey::Pubkey::new_from_array(
181+
*packed_accounts
182+
.get_u8(compressed_token_account.owner, "CompressAndClose: owner")?
183+
.key()
184+
)
185+
);
177186
return Err(ErrorCode::CompressAndCloseInvalidOwner.into());
178187
}
179188
// Compression amount must match the output amount

sdk-libs/client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ solana-clock = { workspace = true }
2727
solana-signature = { workspace = true }
2828
solana-commitment-config = { workspace = true }
2929
solana-account = { workspace = true }
30+
solana-signer = { workspace = true }
3031
solana-epoch-info = { workspace = true }
3132
solana-keypair = { workspace = true }
3233
solana-compute-budget-interface = { workspace = true }

sdk-libs/client/src/rpc/rpc_trait.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use solana_keypair::Keypair;
1414
use solana_pubkey::Pubkey;
1515
use solana_rpc_client_api::config::RpcSendTransactionConfig;
1616
use solana_signature::Signature;
17+
use solana_signer::Signer;
1718
use solana_transaction::Transaction;
1819
use solana_transaction_status_client_types::TransactionStatus;
1920

@@ -170,9 +171,21 @@ pub trait Rpc: Send + Sync + Debug + 'static {
170171
) -> Result<Signature, RpcError> {
171172
let blockhash = self.get_latest_blockhash().await?.0;
172173
let mut transaction = Transaction::new_with_payer(instructions, Some(payer));
173-
transaction
174-
.try_sign(signers, blockhash)
175-
.map_err(|e| RpcError::CustomError(e.to_string()))?;
174+
transaction.try_sign(signers, blockhash).map_err(|e| {
175+
println!(
176+
"Provided signers: {:?}",
177+
signers.iter().map(|s| s.pubkey()).collect::<Vec<_>>()
178+
);
179+
180+
let message = transaction.message();
181+
let num_required_signatures = message.header.num_required_signatures as usize;
182+
println!(
183+
"Expected signers (first {} accounts in message): {:?}",
184+
num_required_signatures,
185+
message.account_keys[..num_required_signatures].to_vec()
186+
);
187+
RpcError::CustomError(e.to_string())
188+
})?;
176189
self.process_transaction(transaction).await
177190
}
178191

sdk-libs/compressed-token-sdk/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ edition = { workspace = true }
66
[features]
77

88
anchor = ["anchor-lang", "light-compressed-token-types/anchor"]
9+
profile-program = [
10+
"light-profiler/profile-program",
11+
"light-compressed-account/profile-program",
12+
"light-ctoken-types/profile-program",
13+
]
14+
profile-heap = [
15+
"light-profiler/profile-heap",
16+
"light-compressed-account/profile-heap",
17+
"light-ctoken-types/profile-heap",
18+
]
919

1020
[dependencies]
1121
# Light Protocol dependencies
@@ -30,6 +40,7 @@ spl-pod = { workspace = true }
3040
light-account-checks = { workspace = true, features = ["solana"] }
3141
light-sdk-types = { workspace = true }
3242
light-zero-copy = { workspace = true }
43+
light-profiler = { workspace = true }
3344

3445
# Optional Anchor dependency
3546
anchor-lang = { workspace = true, optional = true }
@@ -38,3 +49,11 @@ anchor-lang = { workspace = true, optional = true }
3849
light-account-checks = { workspace = true, features = ["test-only", "solana"] }
3950
anchor-lang = { workspace = true }
4051
light-compressed-token = { workspace = true }
52+
53+
54+
[lints.rust.unexpected_cfgs]
55+
level = "allow"
56+
check-cfg = [
57+
'cfg(target_os, values("solana"))',
58+
'cfg(feature, values("frozen-abi", "no-entrypoint"))',
59+
]

0 commit comments

Comments
 (0)