Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Detect tracer key in sigverify (#25579)
Browse files Browse the repository at this point in the history
* Mark the tracer transaction

* simplify tracer check

(cherry picked from commit 90a3315)
  • Loading branch information
carllin committed May 31, 2022
1 parent 21e940b commit 18acf7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl SigVerifier for TransactionSigVerifier {
removed_before_sigverify_stage: bool,
is_dup: bool,
) {
sigverify::check_for_tracer_packet(packet);
if packet.meta.is_tracer_packet() {
if removed_before_sigverify_stage {
self.tracer_packet_stats
Expand Down
24 changes: 17 additions & 7 deletions perf/src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const TRACER_KEY_BYTES: [u8; 32] = [
155, 90, 30, 39, 116, 115, 238, 38, 126, 21, 232, 133,
];
const TRACER_KEY: Pubkey = Pubkey::new_from_array(TRACER_KEY_BYTES);
const TRACER_KEY_OFFSET_IN_TRANSACTION: usize = 69;

lazy_static! {
static ref PAR_THREAD_POOL: ThreadPool = rayon::ThreadPoolBuilder::new()
Expand Down Expand Up @@ -155,13 +156,6 @@ fn verify_packet(packet: &mut Packet, reject_non_vote: bool) {
return;
}

// Check for tracer pubkey
if !packet.meta.is_tracer_packet()
&& &packet.data[pubkey_start..pubkey_end] == TRACER_KEY.as_ref()
{
packet.meta.flags |= PacketFlags::TRACER_PACKET;
}

pubkey_start = pubkey_end;
sig_start = sig_end;
}
Expand Down Expand Up @@ -318,6 +312,22 @@ fn do_get_packet_offsets(
))
}

pub fn check_for_tracer_packet(packet: &mut Packet) -> bool {
let first_pubkey_start: usize = TRACER_KEY_OFFSET_IN_TRANSACTION;
let first_pubkey_end = first_pubkey_start.saturating_add(size_of::<Pubkey>());
// Check for tracer pubkey
if packet.meta.size > first_pubkey_start {
let is_tracer_packet =
&packet.data()[first_pubkey_start..first_pubkey_end] == TRACER_KEY.as_ref();
if is_tracer_packet {
packet.meta.flags |= PacketFlags::TRACER_PACKET;
}
is_tracer_packet
} else {
false
}
}

fn get_packet_offsets(
packet: &mut Packet,
current_offset: usize,
Expand Down

0 comments on commit 18acf7c

Please sign in to comment.