Skip to content

Commit

Permalink
bump solana to 1.9.18 (solana-labs#97)
Browse files Browse the repository at this point in the history
* bump t o 1.9.18

* Solve clippy warnings after bump update

* bump solana version in script

* fixing various warnings

* fix all clippy warnings in the tests

* fmt

Co-authored-by: Andrei Hrs <andrei_hristescu@yahoo.com>
  • Loading branch information
0xripleys and andreihrs authored Aug 19, 2022
1 parent 6a2d4aa commit 1feaffc
Show file tree
Hide file tree
Showing 25 changed files with 1,093 additions and 1,287 deletions.
2,144 changes: 977 additions & 1,167 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ci/solana-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if [[ -n $SOLANA_VERSION ]]; then
solana_version="$SOLANA_VERSION"
else
solana_version=v1.8.14
solana_version=v1.9.18
fi

export solana_version="$solana_version"
Expand Down
12 changes: 6 additions & 6 deletions token-lending/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ version = "0.1.0"

[dependencies]
clap = "=2.34.0"
solana-clap-utils = "=1.8.14"
solana-cli-config = "=1.8.14"
solana-client = "=1.8.14"
solana-logger = "=1.8.14"
solana-sdk = "=1.8.14"
solana-program = "=1.8.14"
solana-clap-utils = "=1.9.18"
solana-cli-config = "=1.9.18"
solana-client = "=1.9.18"
solana-logger = "=1.9.18"
solana-sdk = "=1.9.18"
solana-program = "=1.9.18"
solend-program = { path="../program", features = [ "no-entrypoint" ] }
spl-token = { version = "3.2.0", features=["no-entrypoint"] }

Expand Down
59 changes: 37 additions & 22 deletions token-lending/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use {
keypair::signer_from_path,
},
solana_client::rpc_client::RpcClient,
solana_program::{native_token::lamports_to_sol, program_pack::Pack, pubkey::Pubkey},
solana_program::{
message::Message, native_token::lamports_to_sol, program_pack::Pack, pubkey::Pubkey,
},
solana_sdk::{
commitment_config::CommitmentConfig,
signature::{Keypair, Signer},
Expand Down Expand Up @@ -824,7 +826,9 @@ fn command_create_lending_market(
.rpc_client
.get_minimum_balance_for_rent_exemption(LendingMarket::LEN)?;

let mut transaction = Transaction::new_with_payer(
let recent_blockhash = config.rpc_client.get_latest_blockhash()?;

let message = Message::new_with_blockhash(
&[
// Account for the lending market
create_account(
Expand All @@ -845,15 +849,17 @@ fn command_create_lending_market(
),
],
Some(&config.fee_payer.pubkey()),
&recent_blockhash,
);

let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?;
check_fee_payer_balance(
config,
lending_market_balance + fee_calculator.calculate_fee(transaction.message()),
lending_market_balance + config.rpc_client.get_fee_for_message(&message)?,
)?;
transaction.sign(

let transaction = Transaction::new(
&vec![config.fee_payer.as_ref(), &lending_market_keypair],
message,
recent_blockhash,
);
send_transaction(config, transaction)?;
Expand Down Expand Up @@ -939,8 +945,9 @@ fn command_add_reserve(
+ user_collateral_balance
+ liquidity_supply_balance
+ liquidity_fee_receiver_balance;
let recent_blockhash = config.rpc_client.get_latest_blockhash()?;

let mut transaction_1 = Transaction::new_with_payer(
let message_1 = Message::new_with_blockhash(
&[
create_account(
&config.fee_payer.pubkey(),
Expand Down Expand Up @@ -972,9 +979,10 @@ fn command_add_reserve(
),
],
Some(&config.fee_payer.pubkey()),
&recent_blockhash,
);

let mut transaction_2 = Transaction::new_with_payer(
let message_2 = Message::new_with_blockhash(
&[
create_account(
&config.fee_payer.pubkey(),
Expand All @@ -992,9 +1000,10 @@ fn command_add_reserve(
),
],
Some(&config.fee_payer.pubkey()),
&recent_blockhash,
);

let mut transaction_3 = Transaction::new_with_payer(
let message_3 = Message::new_with_blockhash(
&[
approve(
&spl_token::id(),
Expand Down Expand Up @@ -1032,45 +1041,49 @@ fn command_add_reserve(
.unwrap(),
],
Some(&config.fee_payer.pubkey()),
&recent_blockhash,
);

let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?;
check_fee_payer_balance(
config,
total_balance
+ fee_calculator.calculate_fee(transaction_1.message())
+ fee_calculator.calculate_fee(transaction_2.message())
+ fee_calculator.calculate_fee(transaction_3.message()),
+ config.rpc_client.get_fee_for_message(&message_1)?
+ config.rpc_client.get_fee_for_message(&message_2)?
+ config.rpc_client.get_fee_for_message(&message_3)?,
)?;
transaction_1.sign(

let transaction_1 = Transaction::new(
&vec![
config.fee_payer.as_ref(),
&reserve_keypair,
&collateral_mint_keypair,
&collateral_supply_keypair,
&user_collateral_keypair,
],
message_1,
recent_blockhash,
);
transaction_2.sign(
send_transaction(config, transaction_1)?;
let transaction_2 = Transaction::new(
&vec![
config.fee_payer.as_ref(),
&liquidity_supply_keypair,
&liquidity_fee_receiver_keypair,
],
message_2,
recent_blockhash,
);
transaction_3.sign(
send_transaction(config, transaction_2)?;
let transaction_3 = Transaction::new(
&vec![
config.fee_payer.as_ref(),
&source_liquidity_owner_keypair,
&lending_market_owner_keypair,
&user_transfer_authority_keypair,
],
message_3,
recent_blockhash,
);
send_transaction(config, transaction_1)?;
send_transaction(config, transaction_2)?;
send_transaction(config, transaction_3)?;
Ok(())
}
Expand Down Expand Up @@ -1252,7 +1265,9 @@ fn command_update_reserve(
reserve.liquidity.switchboard_oracle_pubkey = switchboard_feed_pubkey.unwrap();
}

let mut transaction = Transaction::new_with_payer(
let recent_blockhash = config.rpc_client.get_latest_blockhash()?;

let message = Message::new_with_blockhash(
&[update_reserve_config(
config.lending_program_id,
reserve.config,
Expand All @@ -1264,15 +1279,15 @@ fn command_update_reserve(
reserve.liquidity.switchboard_oracle_pubkey,
)],
Some(&config.fee_payer.pubkey()),
&recent_blockhash,
);

let (recent_blockhash, fee_calculator) = config.rpc_client.get_recent_blockhash()?;
check_fee_payer_balance(config, fee_calculator.calculate_fee(transaction.message()))?;

transaction.sign(
let transaction = Transaction::new(
&vec![config.fee_payer.as_ref(), &lending_market_owner_keypair],
message,
recent_blockhash,
);

send_transaction(config, transaction)?;
Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions token-lending/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ arrayref = "0.3.6"
bytemuck = "1.5.1"
num-derive = "0.3"
num-traits = "0.2"
solana-program = "=1.8.14"
solana-program = "=1.9.18"
spl-token = { version = "3.2.0", features=["no-entrypoint"] }
switchboard-program = "0.2.0"
switchboard-v2 = "0.1.3"
thiserror = "1.0"
uint = "=0.9.0"
uint = "=0.9.1"

[dev-dependencies]
assert_matches = "1.5.0"
base64 = "0.13"
log = "0.4.14"
proptest = "1.0"
solana-program-test = "=1.8.14"
solana-sdk = "=1.8.14"
solana-program-test = "=1.9.18"
solana-sdk = "=1.9.18"
serde = "1.0"
serde_yaml = "0.8"

Expand Down
5 changes: 2 additions & 3 deletions token-lending/program/tests/borrow_obligation_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use helpers::*;
use solana_program_test::*;
use solana_sdk::{
instruction::InstructionError,
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::{Transaction, TransactionError},
};
Expand All @@ -28,7 +27,7 @@ async fn test_borrow_usdc_fixed_amount() {
);

// limit to track compute unit increase
test.set_bpf_compute_max_units(55_000);
test.set_compute_max_units(55_000);

const USDC_TOTAL_BORROW_FRACTIONAL: u64 = 1_000 * FRACTIONAL_TO_USDC;
const FEE_AMOUNT: u64 = 100;
Expand Down Expand Up @@ -172,7 +171,7 @@ async fn test_borrow_sol_max_amount() {
);

// limit to track compute unit increase
test.set_bpf_compute_max_units(60_000);
test.set_compute_max_units(60_000);

const FEE_AMOUNT: u64 = 5000;
const HOST_FEE_AMOUNT: u64 = 1000;
Expand Down
5 changes: 2 additions & 3 deletions token-lending/program/tests/deposit_obligation_collateral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod helpers;
use helpers::*;
use solana_program_test::*;
use solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::Transaction,
};
Expand All @@ -24,7 +23,7 @@ async fn test_success() {
);

// limit to track compute unit increase
test.set_bpf_compute_max_units(38_000);
test.set_compute_max_units(38_000);

const SOL_DEPOSIT_AMOUNT_LAMPORTS: u64 = 10 * LAMPORTS_TO_SOL * INITIAL_COLLATERAL_RATIO;
const SOL_RESERVE_COLLATERAL_LAMPORTS: u64 = 2 * SOL_DEPOSIT_AMOUNT_LAMPORTS;
Expand Down Expand Up @@ -112,7 +111,7 @@ async fn test_success() {
assert!(banks_client.process_transaction(transaction).await.is_ok());

let sol_reserve = sol_test_reserve.get_state(&mut banks_client).await;
assert_eq!(sol_reserve.last_update.stale, true);
assert!(sol_reserve.last_update.stale);

// check that collateral tokens were transferred
let collateral_supply_balance =
Expand Down
6 changes: 3 additions & 3 deletions token-lending/program/tests/deposit_reserve_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod helpers;

use helpers::*;
use solana_program_test::*;
use solana_sdk::{pubkey::Pubkey, signature::Keypair};
use solana_sdk::signature::Keypair;
use solend_program::processor::process_instruction;

#[tokio::test]
Expand All @@ -16,7 +16,7 @@ async fn test_success() {
);

// limit to track compute unit increase
test.set_bpf_compute_max_units(50_000);
test.set_compute_max_units(50_000);

let user_accounts_owner = Keypair::new();
let lending_market = add_lending_market(&mut test);
Expand Down Expand Up @@ -65,7 +65,7 @@ async fn test_success() {
.await;

let usdc_reserve = usdc_test_reserve.get_state(&mut banks_client).await;
assert_eq!(usdc_reserve.last_update.stale, true);
assert!(usdc_reserve.last_update.stale);

let user_remaining_liquidity_amount =
get_token_balance(&mut banks_client, usdc_test_reserve.user_liquidity_pubkey).await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod helpers;

use helpers::*;
use solana_program_test::*;
use solana_sdk::{pubkey::Pubkey, signature::Keypair};
use solana_sdk::signature::Keypair;
use solend_program::processor::process_instruction;

#[tokio::test]
Expand All @@ -16,7 +16,7 @@ async fn test_success() {
);

// limit to track compute unit increase
test.set_bpf_compute_max_units(70_000);
test.set_compute_max_units(70_000);

let user_accounts_owner = Keypair::new();
let lending_market = add_lending_market(&mut test);
Expand Down Expand Up @@ -62,5 +62,5 @@ async fn test_success() {
.await;

let usdc_reserve = usdc_test_reserve.get_state(&mut banks_client).await;
assert_eq!(usdc_reserve.last_update.stale, true);
assert!(usdc_reserve.last_update.stale);
}
20 changes: 7 additions & 13 deletions token-lending/program/tests/flash_loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn test_success() {
);

// limit to track compute unit increase
test.set_bpf_compute_max_units(50_000);
test.set_compute_max_units(50_000);

const FLASH_LOAN_AMOUNT: u64 = 1_000 * FRACTIONAL_TO_USDC;
const FEE_AMOUNT: u64 = 3_000_000;
Expand All @@ -35,7 +35,7 @@ async fn test_success() {
test.prefer_bpf(false);
test.add_program(
"flash_loan_receiver",
receiver_program_id.clone(),
receiver_program_id,
processor!(helpers::flash_loan_receiver::process_instruction),
);

Expand Down Expand Up @@ -94,11 +94,8 @@ async fn test_success() {
usdc_test_reserve.config.fee_receiver,
usdc_test_reserve.liquidity_host_pubkey,
lending_market.pubkey,
receiver_program_id.clone(),
vec![AccountMeta::new_readonly(
receiver_authority_pubkey.clone(),
false,
)],
receiver_program_id,
vec![AccountMeta::new_readonly(receiver_authority_pubkey, false)],
)],
Some(&payer.pubkey()),
);
Expand Down Expand Up @@ -152,7 +149,7 @@ async fn test_failure() {
test.prefer_bpf(false);
test.add_program(
"flash_loan_receiver",
flash_loan_receiver_program_id.clone(),
flash_loan_receiver_program_id,
processor!(helpers::flash_loan_receiver::process_instruction),
);

Expand Down Expand Up @@ -203,11 +200,8 @@ async fn test_failure() {
usdc_test_reserve.config.fee_receiver,
usdc_test_reserve.liquidity_host_pubkey,
lending_market.pubkey,
flash_loan_receiver_program_id.clone(),
vec![AccountMeta::new_readonly(
receiver_authority_pubkey.clone(),
false,
)],
flash_loan_receiver_program_id,
vec![AccountMeta::new_readonly(receiver_authority_pubkey, false)],
)],
Some(&payer.pubkey()),
);
Expand Down
Loading

0 comments on commit 1feaffc

Please sign in to comment.