Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ fn simulate_transaction(
#[tarpc::server]
impl Banks for BanksServer {
async fn send_transaction_with_context(self, _: Context, transaction: VersionedTransaction) {
let message_hash = transaction.message.hash();
let blockhash = transaction.message.recent_blockhash();
let last_valid_block_height = self
.bank_forks
Expand All @@ -219,7 +220,9 @@ impl Banks for BanksServer {
.unwrap();
let signature = transaction.signatures.first().cloned().unwrap_or_default();
let info = TransactionInfo::new(
message_hash,
signature,
*blockhash,
serialize(&transaction).unwrap(),
last_valid_block_height,
None,
Expand Down Expand Up @@ -322,14 +325,17 @@ impl Banks for BanksServer {
return Some(Err(err));
}

let message_hash = sanitized_transaction.message_hash();
let blockhash = transaction.message.recent_blockhash();
let last_valid_block_height = self
.bank(commitment)
.get_blockhash_last_valid_block_height(blockhash)
.unwrap();
let signature = sanitized_transaction.signature();
let info = TransactionInfo::new(
*message_hash,
*signature,
*blockhash,
serialize(&transaction).unwrap(),
last_valid_block_height,
None,
Expand Down
15 changes: 13 additions & 2 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2683,14 +2683,18 @@ fn get_token_program_id_and_mint(

fn _send_transaction(
meta: JsonRpcRequestProcessor,
message_hash: Hash,
signature: Signature,
blockhash: Hash,
wire_transaction: Vec<u8>,
last_valid_block_height: u64,
durable_nonce_info: Option<(Pubkey, Hash)>,
max_retries: Option<usize>,
) -> Result<String> {
let transaction_info = TransactionInfo::new(
message_hash,
signature,
blockhash,
wire_transaction,
last_valid_block_height,
durable_nonce_info,
Expand Down Expand Up @@ -3800,6 +3804,7 @@ pub mod rpc_full {
Error::internal_error()
})?;

let message_hash = transaction.message().hash();
let signature = if !transaction.signatures.is_empty() {
transaction.signatures[0]
} else {
Expand All @@ -3808,7 +3813,9 @@ pub mod rpc_full {

_send_transaction(
meta,
message_hash,
signature,
blockhash,
wire_transaction,
last_valid_block_height,
None,
Expand Down Expand Up @@ -3854,15 +3861,17 @@ pub mod rpc_full {
preflight_bank,
preflight_bank.get_reserved_account_keys(),
)?;
let blockhash = *transaction.message().recent_blockhash();
let message_hash = *transaction.message_hash();
let signature = *transaction.signature();

let mut last_valid_block_height = preflight_bank
.get_blockhash_last_valid_block_height(transaction.message().recent_blockhash())
.get_blockhash_last_valid_block_height(&blockhash)
.unwrap_or(0);

let durable_nonce_info = transaction
.get_durable_nonce()
.map(|&pubkey| (pubkey, *transaction.message().recent_blockhash()));
.map(|&pubkey| (pubkey, blockhash));
if durable_nonce_info.is_some() || (skip_preflight && last_valid_block_height == 0) {
// While it uses a defined constant, this last_valid_block_height value is chosen arbitrarily.
// It provides a fallback timeout for durable-nonce transaction retries in case of
Expand Down Expand Up @@ -3931,7 +3940,9 @@ pub mod rpc_full {

_send_transaction(
meta,
message_hash,
signature,
blockhash,
wire_transaction,
last_valid_block_height,
durable_nonce_info,
Expand Down
11 changes: 11 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5266,6 +5266,17 @@ impl Bank {
.map(|v| v.1)
}

pub fn get_committed_transaction_status_and_slot(
&self,
message_hash: &Hash,
transaction_blockhash: &Hash,
) -> Option<(Slot, bool)> {
let rcache = self.status_cache.read().unwrap();
rcache
.get_status(message_hash, transaction_blockhash, &self.ancestors)
.map(|(slot, status)| (slot, status.is_ok()))
}

pub fn get_signature_status_slot(&self, signature: &Signature) -> Option<(Slot, Result<()>)> {
let rcache = self.status_cache.read().unwrap();
rcache.get_status_any_blockhash(signature, &self.ancestors)
Expand Down
Loading
Loading