Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/test_suite/context/codec_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test_suite.context_pb2 as context_pb
import fd58
from test_suite.fuzz_interface import encode_hex_compact, decode_hex_compact


def encode_acct_state(acct_state: context_pb.AcctState):
Expand All @@ -11,6 +12,10 @@ def encode_acct_state(acct_state: context_pb.AcctState):
if acct_state.owner:
acct_state.owner = fd58.enc32(acct_state.owner)

# Data
if acct_state.data:
acct_state.data = encode_hex_compact(acct_state.data)


def decode_acct_state(acct_state: context_pb.AcctState):
# Pubkey
Expand All @@ -20,3 +25,7 @@ def decode_acct_state(acct_state: context_pb.AcctState):
# Owner
if acct_state.owner:
acct_state.owner = fd58.dec32(acct_state.owner)

# Data
if acct_state.data:
acct_state.data = decode_hex_compact(acct_state.data)
20 changes: 20 additions & 0 deletions src/test_suite/instr/codec_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fd58
from test_suite.context.codec_utils import decode_acct_state, encode_acct_state
from test_suite.fuzz_interface import decode_hex_compact, encode_hex_compact
import test_suite.invoke_pb2 as invoke_pb


Expand All @@ -11,12 +12,18 @@ def decode_input(instruction_context: invoke_pb.InstrContext):
Args:
- instruction_context (invoke_pb.InstrContext): Instruction context (will be modified).
"""
# Program ID
if instruction_context.program_id:
instruction_context.program_id = fd58.dec32(instruction_context.program_id)

# Accounts
for i in range(len(instruction_context.accounts)):
decode_acct_state(instruction_context.accounts[i])

# Data
if instruction_context.data:
instruction_context.data = decode_hex_compact(instruction_context.data)


def encode_input(instruction_context: invoke_pb.InstrContext):
"""
Expand All @@ -26,12 +33,18 @@ def encode_input(instruction_context: invoke_pb.InstrContext):
Args:
- instruction_context (invoke_pb.InstrContext): Instruction context (will be modified).
"""
# Program ID
if instruction_context.program_id:
instruction_context.program_id = fd58.enc32(instruction_context.program_id)

# Accounts
for i in range(len(instruction_context.accounts)):
encode_acct_state(instruction_context.accounts[i])

# Data
if instruction_context.data:
instruction_context.data = encode_hex_compact(instruction_context.data)


def encode_output(instruction_effects: invoke_pb.InstrEffects):
"""
Expand All @@ -41,5 +54,12 @@ def encode_output(instruction_effects: invoke_pb.InstrEffects):
Args:
- instruction_effects (invoke_pb.InstrEffects): Instruction effects (will be modified).
"""
# Accounts
for i in range(len(instruction_effects.modified_accounts)):
encode_acct_state(instruction_effects.modified_accounts[i])

# Return data
if instruction_effects.return_data:
instruction_effects.return_data = encode_hex_compact(
instruction_effects.return_data
)
15 changes: 15 additions & 0 deletions src/test_suite/txn/codec_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fd58
from test_suite.context.codec_utils import decode_acct_state, encode_acct_state
from test_suite.fuzz_interface import decode_hex_compact, encode_hex_compact
import test_suite.txn_pb2 as txn_pb


Expand All @@ -22,6 +23,13 @@ def decode_sanitized_tx(tx: txn_pb.SanitizedTransaction):
tx.message.recent_blockhash or bytes([0] * 32)
)

# Instructions
for i in range(len(tx.message.instructions)):
if tx.message.instructions[i].data:
tx.message.instructions[i].data = decode_hex_compact(
tx.message.instructions[i].data
)

# Address table lookups
for i in range(len(tx.message.address_table_lookups)):
if tx.message.address_table_lookups[i].account_key:
Expand Down Expand Up @@ -49,6 +57,13 @@ def encode_sanitized_tx(tx: txn_pb.SanitizedTransaction):
tx.message.recent_blockhash or bytes([0] * 32)
)

# Instructions
for i in range(len(tx.message.instructions)):
if tx.message.instructions[i].data:
tx.message.instructions[i].data = encode_hex_compact(
tx.message.instructions[i].data
)

# Address table lookups
for i in range(len(tx.message.address_table_lookups)):
if tx.message.address_table_lookups[i].account_key:
Expand Down