Updates from master
This commit is contained in:
@ -50,7 +50,6 @@ use solana_sdk::{
|
|||||||
use solana_transaction_status::token_balances::{
|
use solana_transaction_status::token_balances::{
|
||||||
collect_token_balances, TransactionTokenBalancesSet,
|
collect_token_balances, TransactionTokenBalancesSet,
|
||||||
};
|
};
|
||||||
use solana_vote_program::vote_transaction;
|
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cmp,
|
cmp,
|
||||||
@ -1033,7 +1032,7 @@ impl BankingStage {
|
|||||||
.filter_map(|tx_index| {
|
.filter_map(|tx_index| {
|
||||||
let p = &msgs.packets[*tx_index];
|
let p = &msgs.packets[*tx_index];
|
||||||
let tx: Transaction = limited_deserialize(&p.data[0..p.meta.size]).ok()?;
|
let tx: Transaction = limited_deserialize(&p.data[0..p.meta.size]).ok()?;
|
||||||
if votes_only && vote_transaction::parse_vote_transaction(&tx).is_none() {
|
if votes_only && !solana_runtime::bank::is_simple_vote_transaction(&tx) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
tx.verify_precompiles(libsecp256k1_0_5_upgrade_enabled)
|
tx.verify_precompiles(libsecp256k1_0_5_upgrade_enabled)
|
||||||
@ -1174,7 +1173,7 @@ impl BankingStage {
|
|||||||
msgs,
|
msgs,
|
||||||
&transaction_indexes,
|
&transaction_indexes,
|
||||||
bank.libsecp256k1_0_5_upgrade_enabled(),
|
bank.libsecp256k1_0_5_upgrade_enabled(),
|
||||||
false,
|
bank.vote_only_bank(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let tx_count = transaction_to_packet_indexes.len();
|
let tx_count = transaction_to_packet_indexes.len();
|
||||||
@ -2914,4 +2913,37 @@ mod tests {
|
|||||||
transaction.message_data()
|
transaction.message_data()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_transactions_from_packets() {
|
||||||
|
use solana_vote_program::vote_state::Vote;
|
||||||
|
solana_logger::setup();
|
||||||
|
let mut vote_packet = Packet::default();
|
||||||
|
let vote_instruction = solana_vote_program::vote_instruction::vote(
|
||||||
|
&Pubkey::new_unique(),
|
||||||
|
&Pubkey::new_unique(),
|
||||||
|
Vote::default(),
|
||||||
|
);
|
||||||
|
let vote_transaction =
|
||||||
|
Transaction::new_with_payer(&[vote_instruction], Some(&Pubkey::new_unique()));
|
||||||
|
Packet::populate_packet(&mut vote_packet, None, &vote_transaction).unwrap();
|
||||||
|
let mut non_vote = Packet::default();
|
||||||
|
let tx = system_transaction::transfer(
|
||||||
|
&Keypair::new(),
|
||||||
|
&Pubkey::new_unique(),
|
||||||
|
2,
|
||||||
|
Hash::default(),
|
||||||
|
);
|
||||||
|
Packet::populate_packet(&mut non_vote, None, &tx).unwrap();
|
||||||
|
let msgs = Packets::new(vec![non_vote, vote_packet]);
|
||||||
|
let packet_indexes = [0, 1];
|
||||||
|
let (transactions, _transaction_to_packet_indexes) =
|
||||||
|
BankingStage::transactions_from_packets(&msgs, &packet_indexes, false, true);
|
||||||
|
assert_eq!(transactions.len(), 1);
|
||||||
|
assert!(!transactions[0].transaction().signatures.is_empty());
|
||||||
|
|
||||||
|
let (transactions, _transaction_to_packet_indexes) =
|
||||||
|
BankingStage::transactions_from_packets(&msgs, &packet_indexes, false, false);
|
||||||
|
assert_eq!(transactions.len(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1228,6 +1228,13 @@ impl ReplayStage {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let root_distance = poh_slot - root_slot;
|
let root_distance = poh_slot - root_slot;
|
||||||
|
const MAX_ROOT_DISTANCE_FOR_VOTE_ONLY: Slot = 500;
|
||||||
|
let vote_only_bank = if root_distance > MAX_ROOT_DISTANCE_FOR_VOTE_ONLY {
|
||||||
|
datapoint_info!("vote-only-bank", ("slot", poh_slot, i64));
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
let tpu_bank = Self::new_bank_from_parent_with_notify(
|
let tpu_bank = Self::new_bank_from_parent_with_notify(
|
||||||
&parent,
|
&parent,
|
||||||
@ -1235,7 +1242,7 @@ impl ReplayStage {
|
|||||||
root_slot,
|
root_slot,
|
||||||
my_pubkey,
|
my_pubkey,
|
||||||
rpc_subscriptions,
|
rpc_subscriptions,
|
||||||
root_distance > 500,
|
vote_only_bank,
|
||||||
);
|
);
|
||||||
|
|
||||||
let tpu_bank = bank_forks.write().unwrap().insert(tpu_bank);
|
let tpu_bank = bank_forks.write().unwrap().insert(tpu_bank);
|
||||||
|
@ -5150,7 +5150,7 @@ pub fn goto_end_of_slot(bank: &mut Bank) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_simple_vote_transaction(transaction: &Transaction) -> bool {
|
pub fn is_simple_vote_transaction(transaction: &Transaction) -> bool {
|
||||||
if transaction.message.instructions.len() == 1 {
|
if transaction.message.instructions.len() == 1 {
|
||||||
let instruction = &transaction.message.instructions[0];
|
let instruction = &transaction.message.instructions[0];
|
||||||
let program_pubkey =
|
let program_pubkey =
|
||||||
|
Reference in New Issue
Block a user