Skip to content

Commit

Permalink
Merge pull request #21 from firedancer-io/mjain/enhancements
Browse files Browse the repository at this point in the history
Add validation for loader id + return data field in protobuf
  • Loading branch information
mjain-jump authored Apr 11, 2024
2 parents aa234df + 1c3988e commit 085447f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions invoke.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ message EpochContext {
// On "real" ledgers, it is created during the slot boundary.
message SlotContext {}

// TODO: Include return data within the transaction context.
message TxnContext {}

message InstrAcct {
Expand Down Expand Up @@ -94,6 +95,8 @@ message InstrEffects {
repeated AcctState modified_accounts = 3;

uint64 cu_avail = 4;

bytes return_data = 5;
}

// An instruction processing test fixture.
Expand Down
3 changes: 2 additions & 1 deletion src/test_suite/multiprocessing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def build_test_results(file_stem: Path, results: dict[str, str | None]) -> int:
Returns:
- int: 1 if passed, -1 if failed, 0 if skipped.
"""
if results is None:
# If no results or Agave rejects input, mark case as skipped
if results is None or results[globals.solana_shared_library] is None:
# Mark as skipped (0)
return 0

Expand Down
15 changes: 13 additions & 2 deletions src/test_suite/test_suite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import Counter
import shutil
from typing import List
import typer
import ctypes
Expand Down Expand Up @@ -56,15 +57,17 @@ def execute_single_instruction(
lib.sol_compat_fini()

# Print human-readable output
encode_output(instruction_effects)
if instruction_effects:
encode_output(instruction_effects)

print(instruction_effects)


@app.command()
def debug_instruction(
file: Path = typer.Option(None, "--input", "-i", help="Input file"),
shared_library: Path = typer.Option(
Path("impl/firedancer/build/native/clang/lib/libfd_exec_sol_compat.so"),
Path("impl/lib/libsolfuzz_firedancer.so"),
"--target",
"-t",
help="Shared object (.so) target file path to debug",
Expand Down Expand Up @@ -101,6 +104,8 @@ def consolidate_logs(
),
):
# Create the output directory, if necessary
if output_dir.exists():
shutil.rmtree(output_dir)
output_dir.mkdir(parents=True, exist_ok=True)

# Iterate through each library
Expand Down Expand Up @@ -170,6 +175,8 @@ def check_consistency(
globals.n_iterations = num_iterations

# Create the output directory, if necessary
if globals.output_dir.exists():
shutil.rmtree(globals.output_dir)
globals.output_dir.mkdir(parents=True, exist_ok=True)

# Generate the test cases in parallel from files on disk
Expand Down Expand Up @@ -291,6 +298,8 @@ def run_tests(
globals.solana_shared_library = solana_shared_library

# Create the output directory, if necessary
if globals.output_dir.exists():
shutil.rmtree(globals.output_dir)
globals.output_dir.mkdir(parents=True, exist_ok=True)

# Initialize shared libraries
Expand Down Expand Up @@ -363,6 +372,8 @@ def decode_protobuf(
),
):
# Create the output directory, if necessary
if output_dir.exists():
shutil.rmtree(output_dir)
output_dir.mkdir(parents=True, exist_ok=True)

# Keep track of how many files were (un)successfully written
Expand Down
3 changes: 3 additions & 0 deletions src/test_suite/validation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def is_valid(instruction_context: pb.InstrContext) -> bool:
if len(instruction_context.program_id) != 32:
return False

if len(instruction_context.loader_id) != 32:
return False

for account in instruction_context.accounts:
if not account.address or len(account.address) != 32:
return False
Expand Down

0 comments on commit 085447f

Please sign in to comment.