forked from firedancer-io/firedancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz, flamenco: factor out pb dumping logic to separate file
- Loading branch information
1 parent
e0465c9
commit 08b853e
Showing
7 changed files
with
764 additions
and
736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#ifndef HEADER_fd_src_flamenco_runtime_tests_fd_dump_pb_h | ||
#define HEADER_fd_src_flamenco_runtime_tests_fd_dump_pb_h | ||
|
||
/* fd_dump_pb.h provides APIs for dumping instructions, transactions, and slots | ||
into a digestable and replayable Protobuf message. This is useful for debugging | ||
ledger test mismatches, collecting seed corpora, and gathering real data to test | ||
new harnesses. | ||
The following arguments can be added when replaying ledger transactions: | ||
COMMON: | ||
--dump-proto-output-dir <output_dir> | ||
* Defines the output directory to dump Protobuf messages to | ||
--dump-proto-start-slot <slot_number> | ||
* Defines the starting slot to dump Protobuf messages from | ||
HARNESS-SPECIFIC FILTERS: | ||
Transactions: | ||
--dump-txn-to-pb <0/1> | ||
* If enabled, transactions will be dumped to the specified output directory | ||
* File name format is "txn-<base58_enc_sig>.bin" | ||
* Each file represents a single transaction as a serialized TxnContext Protobuf message | ||
--dump-proto-sig-filter <base_58_enc_sig> | ||
* If enabled, only transactions with the specified signature will be dumped | ||
Instructions: | ||
--dump-instr-to-pb <0/1> | ||
* If enabled, instructions will be dumped to the specified output directory | ||
* File name format is "instr-<base58_enc_sig>-<instruction_idx>.bin", where instruction_idx is 1-indexed | ||
* Each file represents a single instruction as a serialized InstrContext Protobuf message | ||
--dump-proto-sig-filter <base_58_enc_sig> | ||
* If enabled, only instructions with the specified signature will be dumped | ||
CPI: Currently not directly invokable with a CLI argument. See details below. | ||
Other notes: | ||
solana-conformance (https://github.com/firedancer-io/solana-conformance) | ||
* Allows decoding / executing / debugging of above Protobuf messages in an isolated environment | ||
* Allows execution result(s) comparison between Firedancer and Solana / Agave | ||
* See solana-conformance/README.md for functionality and use cases */ | ||
|
||
#include <unistd.h> | ||
#include <sys/mman.h> | ||
#include <errno.h> | ||
|
||
#include "../../fd_flamenco.h" | ||
#include "../../fd_flamenco_base.h" | ||
#include "../fd_system_ids.h" | ||
#include "../fd_runtime.h" | ||
#include "../fd_executor.h" | ||
#include "../../vm/fd_vm.h" | ||
#include "../../../util/log/fd_log.h" | ||
|
||
#include "../../nanopb/pb_encode.h" | ||
#include "generated/elf.pb.h" | ||
#include "generated/invoke.pb.h" | ||
#include "generated/txn.pb.h" | ||
#include "generated/vm.pb.h" | ||
|
||
FD_PROTOTYPES_BEGIN | ||
|
||
#define TOSTRING(x) #x | ||
#define STRINGIFY(x) TOSTRING(x) | ||
|
||
void | ||
fd_dump_instr_to_protobuf( fd_exec_txn_ctx_t * txn_ctx, | ||
fd_instr_info_t * instr, | ||
ushort instruction_idx ); | ||
|
||
void | ||
fd_dump_txn_to_protobuf( fd_exec_txn_ctx_t *txn_ctx, fd_spad_t * spad ); | ||
|
||
/* Captures the state of the VM (including the instruction context). | ||
Meant to be invoked at the start of the VM_SYSCALL_CPI_ENTRYPOINT like so: | ||
``` | ||
dump_vm_cpi_state(vm, STRINGIFY(FD_EXPAND_THEN_CONCAT2(sol_invoke_signed_, VM_SYSCALL_CPI_ABI)), | ||
instruction_va, acct_infos_va, acct_info_cnt, signers_seeds_va, signers_seeds_cnt); | ||
``` | ||
Assumes that a `vm_cpi_state` directory exists in the current working directory. Generates a | ||
unique dump for combination of (tile_id, caller_pubkey, instr_sz). */ | ||
void | ||
fd_dump_vm_cpi_state( fd_vm_t * vm, | ||
char const * fn_name, | ||
ulong instruction_va, | ||
ulong acct_infos_va, | ||
ulong acct_info_cnt, | ||
ulong signers_seeds_va, | ||
ulong signers_seeds_cnt ); | ||
|
||
FD_PROTOTYPES_END | ||
|
||
#endif /* HEADER_fd_src_flamenco_runtime_tests_fd_dump_pb_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters