Store versioned transactions in the ledger, disabled by default (#19139)
* Add support for versioned transactions, but disable by default * merge conflicts * trent's feedback * bump Cargo.lock * Fix transaction error encoding * Rename legacy_transaction method * cargo clippy * Clean up casts, int arithmetic, and unused methods * Check for duplicates in sanitized message conversion * fix clippy * fix new test * Fix bpf conditional compilation for message module
This commit is contained in:
@ -22,7 +22,7 @@ use {
|
||||
solana_runtime::bank::Bank,
|
||||
solana_sdk::{
|
||||
clock::NUM_CONSECUTIVE_LEADER_SLOTS, hash::Hash, poh_config::PohConfig, pubkey::Pubkey,
|
||||
timing, transaction::Transaction,
|
||||
timing, transaction::VersionedTransaction,
|
||||
},
|
||||
std::{
|
||||
cmp,
|
||||
@ -61,14 +61,14 @@ pub type BankStart = (Arc<Bank>, Arc<Instant>);
|
||||
|
||||
pub struct Record {
|
||||
pub mixin: Hash,
|
||||
pub transactions: Vec<Transaction>,
|
||||
pub transactions: Vec<VersionedTransaction>,
|
||||
pub slot: Slot,
|
||||
pub sender: CrossbeamSender<Result<()>>,
|
||||
}
|
||||
impl Record {
|
||||
pub fn new(
|
||||
mixin: Hash,
|
||||
transactions: Vec<Transaction>,
|
||||
transactions: Vec<VersionedTransaction>,
|
||||
slot: Slot,
|
||||
sender: CrossbeamSender<Result<()>>,
|
||||
) -> Self {
|
||||
@ -106,7 +106,7 @@ impl TransactionRecorder {
|
||||
&self,
|
||||
bank_slot: Slot,
|
||||
mixin: Hash,
|
||||
transactions: Vec<Transaction>,
|
||||
transactions: Vec<VersionedTransaction>,
|
||||
) -> Result<()> {
|
||||
// create a new channel so that there is only 1 sender and when it goes out of scope, the receiver fails
|
||||
let (result_sender, result_receiver) = unbounded();
|
||||
@ -566,7 +566,7 @@ impl PohRecorder {
|
||||
&mut self,
|
||||
bank_slot: Slot,
|
||||
mixin: Hash,
|
||||
transactions: Vec<Transaction>,
|
||||
transactions: Vec<VersionedTransaction>,
|
||||
) -> Result<()> {
|
||||
// Entries without transactions are used to track real-time passing in the ledger and
|
||||
// cannot be generated by `record()`
|
||||
@ -1044,7 +1044,9 @@ mod tests {
|
||||
poh_recorder.tick();
|
||||
let tx = test_tx();
|
||||
let h1 = hash(b"hello world!");
|
||||
assert!(poh_recorder.record(bank.slot(), h1, vec![tx]).is_err());
|
||||
assert!(poh_recorder
|
||||
.record(bank.slot(), h1, vec![tx.into()])
|
||||
.is_err());
|
||||
assert!(entry_receiver.try_recv().is_err());
|
||||
}
|
||||
Blockstore::destroy(&ledger_path).unwrap();
|
||||
@ -1086,7 +1088,7 @@ mod tests {
|
||||
let tx = test_tx();
|
||||
let h1 = hash(b"hello world!");
|
||||
assert_matches!(
|
||||
poh_recorder.record(bank.slot() + 1, h1, vec![tx]),
|
||||
poh_recorder.record(bank.slot() + 1, h1, vec![tx.into()]),
|
||||
Err(PohRecorderError::MaxHeightReached)
|
||||
);
|
||||
}
|
||||
@ -1128,7 +1130,9 @@ mod tests {
|
||||
assert_eq!(poh_recorder.tick_height, 1);
|
||||
let tx = test_tx();
|
||||
let h1 = hash(b"hello world!");
|
||||
assert!(poh_recorder.record(bank.slot(), h1, vec![tx]).is_ok());
|
||||
assert!(poh_recorder
|
||||
.record(bank.slot(), h1, vec![tx.into()])
|
||||
.is_ok());
|
||||
assert_eq!(poh_recorder.tick_cache.len(), 0);
|
||||
|
||||
//tick in the cache + entry
|
||||
@ -1175,7 +1179,9 @@ mod tests {
|
||||
assert_eq!(poh_recorder.tick_height, 2);
|
||||
let tx = test_tx();
|
||||
let h1 = hash(b"hello world!");
|
||||
assert!(poh_recorder.record(bank.slot(), h1, vec![tx]).is_err());
|
||||
assert!(poh_recorder
|
||||
.record(bank.slot(), h1, vec![tx.into()])
|
||||
.is_err());
|
||||
|
||||
let (_bank, (entry, _tick_height)) = entry_receiver.recv().unwrap();
|
||||
assert!(entry.is_tick());
|
||||
@ -1424,7 +1430,9 @@ mod tests {
|
||||
|
||||
let tx = test_tx();
|
||||
let h1 = hash(b"hello world!");
|
||||
assert!(poh_recorder.record(bank.slot(), h1, vec![tx]).is_err());
|
||||
assert!(poh_recorder
|
||||
.record(bank.slot(), h1, vec![tx.into()])
|
||||
.is_err());
|
||||
assert!(poh_recorder.working_bank.is_none());
|
||||
// Make sure the starting slot is updated
|
||||
assert_eq!(poh_recorder.start_slot, end_slot);
|
||||
|
@ -368,7 +368,9 @@ mod tests {
|
||||
solana_measure::measure::Measure,
|
||||
solana_perf::test_tx::test_tx,
|
||||
solana_runtime::bank::Bank,
|
||||
solana_sdk::{clock, hash::hash, pubkey::Pubkey, timing},
|
||||
solana_sdk::{
|
||||
clock, hash::hash, pubkey::Pubkey, timing, transaction::VersionedTransaction,
|
||||
},
|
||||
std::time::Duration,
|
||||
};
|
||||
|
||||
@ -434,7 +436,7 @@ mod tests {
|
||||
let mut total_us = 0;
|
||||
let mut total_times = 0;
|
||||
let h1 = hash(b"hello world!");
|
||||
let tx = test_tx();
|
||||
let tx = VersionedTransaction::from(test_tx());
|
||||
loop {
|
||||
// send some data
|
||||
let mut time = Measure::start("record");
|
||||
|
Reference in New Issue
Block a user