Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bench: make bench transactions succeed #2561

Merged
merged 1 commit into from
Jul 31, 2024
Merged
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
59 changes: 37 additions & 22 deletions src/app/fddev/tiles/fd_benchg.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,24 @@ typedef struct __attribute__((packed)) {
uchar fee_payer[32];
uchar compute_budget_program[32]; /* = {COMPUTE_BUDGET_PROG_ID} */
uchar recent_blockhash[32];
uchar instr_cnt; /* = 1 */
uchar instr_cnt; /* = 2 */
/* Start of instruction */
uchar prog_id; /* = 1 */
uchar acct_cnt; /* = 0 */
uchar data_sz; /* = 9 */
uchar set_cu_price; /* = 3 */
ulong micro_lamports_per_cu; /* Can be any value, doesn't affect the transaction price */
} transfer_t;
struct __attribute__((packed)) {
uchar prog_id; /* = 1 */
uchar acct_cnt; /* = 0 */
uchar data_sz; /* = 9 */
uchar set_cu_price; /* = 3 */
ulong micro_lamports_per_cu; /* Prefereably less than 10k or so */
} _1;
/* Start of second instruction */
struct __attribute__((packed)) {
uchar prog_id; /* = 1 */
uchar acct_cnt; /* = 0 */
uchar data_sz; /* = 5 */
uchar set_cu_limit; /* = 2 */
uint cus; /* = 300 */
} _2;
} bench_transaction_t;

static inline void
after_credit( void * _ctx,
Expand All @@ -79,37 +89,42 @@ after_credit( void * _ctx,

if( FD_UNLIKELY( !ctx->has_recent_blockhash ) ) return;

transfer_t * transfer = (transfer_t *)fd_chunk_to_laddr( ctx->mem, ctx->out_chunk );
*transfer = (transfer_t){
bench_transaction_t * txn = (bench_transaction_t *)fd_chunk_to_laddr( ctx->mem, ctx->out_chunk );
*txn = (bench_transaction_t){
/* Fixed values */
.sig_cnt = 1,
._sig_cnt = 1,
.ro_signed_cnt = 0,
.ro_unsigned_cnt = 1,
.acct_addr_cnt = 2,
.compute_budget_program = {COMPUTE_BUDGET_PROG_ID},
.instr_cnt = 1,
.prog_id = 1,
.acct_cnt = 0,
.data_sz = 9,
.set_cu_price = 3,
.instr_cnt = 2,
._1.prog_id = 1,
._1.acct_cnt = 0,
._1.data_sz = 9,
._1.set_cu_price = 3,
._2.prog_id = 1,
._2.acct_cnt = 0,
._2.data_sz = 5,
._2.set_cu_limit = 2,
._2.cus = 300,

/* Variable */
.micro_lamports_per_cu = ctx->lamport_idx, /* Unique per transaction so they aren't duplicates */
._1.micro_lamports_per_cu = ctx->lamport_idx, /* Unique per transaction so they aren't duplicates */
};

fd_memcpy( transfer->fee_payer, ctx->acct_public_keys[ ctx->sender_idx ].uc, 32UL );
fd_memcpy( transfer->recent_blockhash, ctx->recent_blockhash, 32UL );
fd_memcpy( txn->fee_payer, ctx->acct_public_keys[ ctx->sender_idx ].uc, 32UL );
fd_memcpy( txn->recent_blockhash, ctx->recent_blockhash, 32UL );

fd_ed25519_sign( transfer->signature,
&(transfer->_sig_cnt),
sizeof(*transfer)-65UL,
fd_ed25519_sign( txn->signature,
&(txn->_sig_cnt),
sizeof(bench_transaction_t)-65UL,
ctx->acct_public_keys[ ctx->sender_idx ].uc,
ctx->acct_private_keys[ ctx->sender_idx ].uc,
ctx->sha );

fd_mux_publish( mux, 0UL, ctx->out_chunk, sizeof(*transfer), 0UL, 0UL, 0UL );
ctx->out_chunk = fd_dcache_compact_next( ctx->out_chunk, sizeof(*transfer), ctx->out_chunk0, ctx->out_wmark );
fd_mux_publish( mux, 0UL, ctx->out_chunk, sizeof(bench_transaction_t), 0UL, 0UL, 0UL );
ctx->out_chunk = fd_dcache_compact_next( ctx->out_chunk, sizeof(bench_transaction_t), ctx->out_chunk0, ctx->out_wmark );

ctx->sender_idx = (ctx->sender_idx + 1UL) % ctx->acct_cnt;
if( FD_UNLIKELY( !ctx->sender_idx ) ) {
Expand Down
Loading