Skip to content

Commit 84dbd2d

Browse files
committed
gui: add support for source ip / tpu
1 parent e74c524 commit 84dbd2d

File tree

8 files changed

+93
-15
lines changed

8 files changed

+93
-15
lines changed

book/api/websocket.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,16 +1276,27 @@ new validator identity.
12761276
"transactions": {
12771277
"start_timestamp_nanos": "1739657041688346791",
12781278
"target_end_timestamp_nanos": "1739657042088346880",
1279-
"txn_start_timestamps_nanos": ["1739657041706960598"],
1280-
"txn_stop_timestamps_nanos": ["1739657041707477011"],
1281-
"txn_compute_units_requested": [0],
1282-
"txn_compute_units_estimated": [3428],
1283-
"txn_compute_units_rebated": [0],
1284-
"txn_micro_lamports_per_cu": ["0"],
1279+
"txn_arrival_timestamps_nanos": ["1754409729593613895"],
1280+
"txn_bank_idx": [0],
1281+
"txn_compute_units_consumed": [3428],
1282+
"txn_compute_units_requested": [3428],
1283+
"txn_end_timstamps_nanos": ["1754409729594477657"],
12851284
"txn_error_code": [0],
12861285
"txn_from_bundle": [false],
12871286
"txn_is_simple_vote": [true],
1288-
"txn_bank_idx": [0]
1287+
"txn_landed": [true],
1288+
"txn_load_end_timstamps_nanos": ["1754409729594455631"],
1289+
"txn_mb_end_timestamps_nanos": ["1754409729594625003"],
1290+
"txn_mb_start_timestamps_nanos": ["1754409729594431327"],
1291+
"txn_microblock_id": [0],
1292+
"txn_preload_end_timstamps_nanos": ["1754409729594432846"],
1293+
"txn_priority_fee": ["0"],
1294+
"txn_signature": ["2BfWBnhTP1ZZwFZutwThj5VT1hX71X9otbgFr21W2XJfcppXakbPCvJ2eCh8eBcS74Lfjar5AuowuppAjsEceSuW"],
1295+
"txn_start_timstamps_nanos": ["1754409729594451074"],
1296+
"txn_transaction_fee": [0],
1297+
"txn_tips": ["0"],
1298+
"txn_source_ipv4": ["123.123.123.123"],
1299+
"txn_source_tpu": ["gossip"],
12891300
}
12901301
}
12911302
}
@@ -1378,9 +1389,22 @@ new validator identity.
13781389
| txn_error_code | `number[]` | `txn_error_code[i]` is the error code that explains the failure for the `i`-th transaction in the slot. See below for more details |
13791390
| txn_from_bundle | `boolean[]` | `txn_from_bundle[i]` is `true` if the `i`-th transaction in the slot came from a bundle and `false` otherwise. A bundle is a microblock with 1-5 transactions that atomically fail or succeed. It is sent to the validator from a compatible block engine (e.g. jito) that can additionally collect MEV rewards that are distributed to stakers (i.e. tips) |
13801391
| txn_is_simple_vote | `boolean[]` | `txn_is_simple_vote[i]` is `true` if the `i`-th transaction in the slot is a simple vote and `false` otherwise |
1392+
| txn_landed | `boolean[]` | `txn_landed[i]` is `true` if the `i`-th transaction in the slot was included in the produced block. A scheduled transaction may not be included in the block for any number of reasons (e.g. a failed bundle, a duplicate transaction, invalid fee-payer) |
13811393
| txn_bank_idx | `number[]` | `txn_bank_idx[i]` is the index of the bank tile that executed the `i`-th transaction in the slot |
13821394
| txn_microblock_id | `string[]` | `txn_microblock_id[i]` is the index of the microblock for the `i`-th transaction in the slot. Microblocks are collections of 1+ transactions. All of the transactions from a bundle share the same microblock. Microblock ids are monotonically increasing in the order they appear in the block and start at 0 for each slot |
13831395
| txn_signature | `string[]` | `txn_signature[i]` is the base58 signature of the `i`-th transaction in the slot |
1396+
| txn_source_ipv4 | `number[]` | `txn_signature[i]` is the source ipv4 address for the `i`-th transaction in the slot |
1397+
| txn_source_tpu | `string[]` | `txn_signature[i]` is the transaction processing unit (TPU) which handled the `i`-th transaction in the slot |
1398+
1399+
The source tpu for a transaction can be one of the following
1400+
1401+
| TPU | Description |
1402+
|--------|-------------|
1403+
| quic | the primary ingress tpu for user transactions. Utilizes the quic protocol to recieve packets |
1404+
| udp | ingress transactions recieved as simple UDP packets |
1405+
| gossip | vote transactions recieved from the gossip network |
1406+
| bundle | bundle transacionts recieved by the bundle tile from a block builder. Utilizes a grpc connection to recieve packets |
1407+
| send | vote transactions procuded by this validator recieved from the send tile. These transactions are meant for the active cluster leader |
13841408

13851409
These are the possible error codes that might be included in `txn_error_code` and their meanings.
13861410

src/disco/bundle/fd_bundle_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ fd_bundle_client_visit_pb_bundle_txn(
565565
return true;
566566
}
567567

568-
uint _ip4; uint ip4 = fd_uint_if( packet.has_meta, fd_cstr_to_ip4_addr( packet.meta.addr, &_ip4 ) ? _ip4 : 0U, 0U );
568+
uint _ip4; uint ip4 = fd_uint_if( packet.has_meta, fd_cstr_to_ip4_addr( packet.meta.addr, &_ip4 ) ? _ip4 : ctx->server_ip4_addr, ctx->server_ip4_addr );
569569
fd_bundle_tile_publish_bundle_txn(
570570
ctx,
571571
packet.data.bytes, packet.data.size,

src/disco/gui/fd_gui.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,8 @@ fd_gui_microblock_execution_begin( fd_gui_t * gui,
18051805
txn_entry->priority_fee = priority_rewards;
18061806
txn_entry->transaction_fee = sig_rewards;
18071807
txn_entry->timestamp_delta_start_nanos = (int)((double)(tickcount - slot->txs.reference_ticks) / fd_tempo_tick_per_ns( NULL ));
1808+
txn_entry->source_ipv4 = txn_payload->source_ipv4;
1809+
txn_entry->source_tpu = txn_payload->source_tpu;
18081810
txn_entry->microblock_idx = microblock_idx;
18091811
txn_entry->flags |= (uchar)FD_GUI_TXN_FLAGS_STARTED;
18101812
txn_entry->flags &= (uchar)(~(uchar)(FD_GUI_TXN_FLAGS_IS_SIMPLE_VOTE | FD_GUI_TXN_FLAGS_FROM_BUNDLE));

src/disco/gui/fd_gui.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ struct __attribute__((packed)) fd_gui_txn {
266266
uchar txn_end_pct;
267267
uchar txn_preload_end_pct;
268268
uchar flags; /* assigned with the FD_GUI_TXN_FLAGS_* macros */
269-
uint microblock_idx;
269+
uchar source_tpu; /* FD_TXN_M_TPU_SOURCE_* */
270+
uint source_ipv4;
271+
uint microblock_idx;
270272
};
271273

272274

src/disco/gui/fd_gui_printf.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "../../waltz/http/fd_http_server_private.h"
77
#include "../../ballet/utf8/fd_utf8.h"
8+
#include "../../disco/fd_txn_m_t.h"
89

910
#ifdef __has_include
1011
#if __has_include("../../app/fdctl/version.h")
@@ -1324,6 +1325,40 @@ fd_gui_printf_slot_transactions_request( fd_gui_t * gui,
13241325
jsonp_open_array( gui, "txn_tips" );
13251326
for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong_as_str( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->tips );
13261327
jsonp_close_array( gui );
1328+
jsonp_open_array( gui, "txn_source_ipv4" );
1329+
for( ulong i=0UL; i<txn_cnt; i++) {
1330+
char addr[ 64 ];
1331+
fd_cstr_printf_check( addr, sizeof(addr), NULL, FD_IP4_ADDR_FMT, FD_IP4_ADDR_FMT_ARGS( gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->source_ipv4 ) );
1332+
jsonp_string( gui, NULL, addr );
1333+
}
1334+
jsonp_close_array( gui );
1335+
jsonp_open_array( gui, "txn_source_tpu" );
1336+
for( ulong i=0UL; i<txn_cnt; i++) {
1337+
switch ( gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->source_tpu ) {
1338+
case FD_TXN_M_TPU_SOURCE_QUIC: {
1339+
jsonp_string( gui, NULL, "quic");
1340+
break;
1341+
}
1342+
case FD_TXN_M_TPU_SOURCE_UDP : {
1343+
jsonp_string( gui, NULL, "udp");
1344+
break;
1345+
}
1346+
case FD_TXN_M_TPU_SOURCE_GOSSIP: {
1347+
jsonp_string( gui, NULL, "gossip");
1348+
break;
1349+
}
1350+
case FD_TXN_M_TPU_SOURCE_BUNDLE: {
1351+
jsonp_string( gui, NULL, "bundle");
1352+
break;
1353+
}
1354+
case FD_TXN_M_TPU_SOURCE_SEND : {
1355+
jsonp_string( gui, NULL, "send");
1356+
break;
1357+
}
1358+
default: FD_LOG_ERR(("unknown tpu"));
1359+
}
1360+
}
1361+
jsonp_close_array( gui );
13271362
jsonp_open_array( gui, "txn_microblock_id" );
13281363
for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->microblock_idx );
13291364
jsonp_close_array( gui );

src/disco/pack/fd_microblock.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ struct __attribute__((aligned(64))) fd_txn_p {
7171
};
7272
/* The time that the transaction arrived to the pack tile in ticks. Set by pack and intended to be read from a transaction on a pack->bank link. */
7373
long scheduler_arrival_time_nanos;
74+
75+
/* Source ipv4 address and tpu pipeline for this transaction. TPU is one of FD_TXN_M_TPU_SOURCE_* */
76+
uchar source_tpu;
77+
uint source_ipv4;
78+
7479
/* Populated by pack, bank. A combination of the bitfields
7580
FD_TXN_P_FLAGS_* defined above. The bank sets the high byte with
7681
the transaction result code. */

src/disco/pack/fd_pack.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,8 +1982,10 @@ fd_pack_schedule_impl( fd_pack_t * pack,
19821982
copy anyway. */
19831983
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, payload_sz )+sizeof(((fd_txn_p_t*)NULL)->payload_sz )<=1280UL, nt_memcpy );
19841984
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, blockhash_slot )+sizeof(((fd_txn_p_t*)NULL)->blockhash_slot)<=1280UL, nt_memcpy );
1985-
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, flags )+sizeof(((fd_txn_p_t*)NULL)->flags )<=1280UL, nt_memcpy );
19861985
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, scheduler_arrival_time_nanos )+sizeof(((fd_txn_p_t*)NULL)->scheduler_arrival_time_nanos )<=1280UL, nt_memcpy );
1986+
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, source_tpu )+sizeof(((fd_txn_p_t*)NULL)->source_tpu )<=1280UL, nt_memcpy );
1987+
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, source_ipv4 )+sizeof(((fd_txn_p_t*)NULL)->source_ipv4 )<=1280UL, nt_memcpy );
1988+
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, flags )+sizeof(((fd_txn_p_t*)NULL)->flags )<=1280UL, nt_memcpy );
19871989
FD_STATIC_ASSERT( offsetof(fd_txn_p_t, _ ) <=1280UL, nt_memcpy );
19881990
const ulong offset_into_txn = 1280UL - offsetof(fd_txn_p_t, _ );
19891991
fd_memcpy( offset_into_txn+(uchar *)TXN(out), offset_into_txn+(uchar const *)txn,
@@ -1995,8 +1997,10 @@ fd_pack_schedule_impl( fd_pack_t * pack,
19951997
out->payload_sz = cur->txn->payload_sz;
19961998
out->pack_cu.requested_exec_plus_acct_data_cus = cur->txn->pack_cu.requested_exec_plus_acct_data_cus;
19971999
out->pack_cu.non_execution_cus = cur->txn->pack_cu.non_execution_cus;
1998-
out->flags = cur->txn->flags;
19992000
out->scheduler_arrival_time_nanos = cur->txn->scheduler_arrival_time_nanos;
2001+
out->source_tpu = cur->txn->source_tpu;
2002+
out->source_ipv4 = cur->txn->source_ipv4;
2003+
out->flags = cur->txn->flags;
20002004
}
20012005
out++;
20022006

@@ -2408,8 +2412,10 @@ fd_pack_try_schedule_bundle( fd_pack_t * pack,
24082412
out->payload_sz = cur->txn->payload_sz;
24092413
out->pack_cu.requested_exec_plus_acct_data_cus = cur->txn->pack_cu.requested_exec_plus_acct_data_cus;
24102414
out->pack_cu.non_execution_cus = cur->txn->pack_cu.non_execution_cus;
2411-
out->flags = cur->txn->flags;
24122415
out->scheduler_arrival_time_nanos = cur->txn->scheduler_arrival_time_nanos;
2416+
out->source_tpu = cur->txn->source_tpu;
2417+
out->source_ipv4 = cur->txn->source_ipv4;
2418+
out->flags = cur->txn->flags;
24132419
out++;
24142420

24152421
pack->cumulative_block_cost += cur->compute_est;

src/disco/pack/fd_pack_tile.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,10 @@ during_frag( fd_pack_ctx_t * ctx,
818818
FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu]", chunk, sz, ctx->in[ in_idx ].chunk0, ctx->in[ in_idx ].wmark ));
819819

820820
fd_txn_m_t * txnm = (fd_txn_m_t *)dcache_entry;
821-
ulong payload_sz = txnm->payload_sz;
822-
ulong txn_t_sz = txnm->txn_t_sz;
821+
ulong payload_sz = txnm->payload_sz;
822+
ulong txn_t_sz = txnm->txn_t_sz;
823+
uint source_ipv4 = txnm->source_ipv4;
824+
uchar source_tpu = txnm->source_tpu;
823825
FD_TEST( payload_sz<=FD_TPU_MTU );
824826
FD_TEST( txn_t_sz <=FD_TXN_MAX_SZ );
825827
fd_txn_t * txn = fd_txn_m_txn_t( txnm );
@@ -898,8 +900,10 @@ during_frag( fd_pack_ctx_t * ctx,
898900
fd_memcpy( ctx->cur_spot->txnp->payload, fd_txn_m_payload( txnm ), payload_sz );
899901
fd_memcpy( TXN(ctx->cur_spot->txnp), txn, txn_t_sz );
900902
fd_memcpy( ctx->cur_spot->alt_accts, fd_txn_m_alut( txnm ), addr_table_sz );
901-
ctx->cur_spot->txnp->payload_sz = payload_sz;
902903
ctx->cur_spot->txnp->scheduler_arrival_time_nanos = ctx->approx_wallclock_ns + (long)((double)(fd_tickcount() - ctx->approx_tickcount) / ctx->ticks_per_ns);
904+
ctx->cur_spot->txnp->payload_sz = payload_sz;
905+
ctx->cur_spot->txnp->source_ipv4 = source_ipv4;
906+
ctx->cur_spot->txnp->source_tpu = source_tpu;
903907

904908
break;
905909
}

0 commit comments

Comments
 (0)