Skip to content

Commit

Permalink
New files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjain-jump committed Jan 7, 2025
1 parent 10fda8b commit 8f28470
Show file tree
Hide file tree
Showing 3 changed files with 385 additions and 33 deletions.
348 changes: 348 additions & 0 deletions src/test_suite/block_pb2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,348 @@
import sys

_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1"))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2

_sym_db = _symbol_database.Default()
from . import context_pb2 as context__pb2
from . import txn_pb2 as txn__pb2
from . import metadata_pb2 as metadata__pb2

DESCRIPTOR = _descriptor.FileDescriptor(
name="block.proto",
package="org.solana.sealevel.v1",
syntax="proto3",
serialized_pb=_b(
'\n\x0bblock.proto\x12\x16org.solana.sealevel.v1\x1a\rcontext.proto\x1a\ttxn.proto\x1a\x0emetadata.proto"\x8b\x02\n\x0cBlockContext\x12:\n\x04txns\x18\x01 \x03(\x0b2,.org.solana.sealevel.v1.SanitizedTransaction\x126\n\x0bacct_states\x18\x02 \x03(\x0b2!.org.solana.sealevel.v1.AcctState\x12\x17\n\x0fblockhash_queue\x18\x03 \x03(\x0c\x125\n\x08slot_ctx\x18\x04 \x01(\x0b2#.org.solana.sealevel.v1.SlotContext\x127\n\tepoch_ctx\x18\x05 \x01(\x0b2$.org.solana.sealevel.v1.EpochContext"¥\x01\n\x0cBlockEffects\x12\x13\n\x0bfirst_error\x18\x01 \x01(\r\x126\n\x0bacct_states\x18\x02 \x03(\x0b2!.org.solana.sealevel.v1.AcctState\x12\x1b\n\x13slot_capitalization\x18\x03 \x01(\x04\x12\x0f\n\x07lt_hash\x18\x04 \x01(\x0c\x12\x1a\n\x12account_delta_hash\x18\x05 \x01(\x0c\x01\n\x0cBlockFixture\x129\n\x08metadata\x18\x01 \x01(\x0b2\'.org.solana.sealevel.v1.FixtureMetadata\x123\n\x05input\x18\x02 \x01(\x0b2$.org.solana.sealevel.v1.BlockContext\x124\n\x06output\x18\x03 \x01(\x0b2$.org.solana.sealevel.v1.BlockEffectsb\x06proto3'
),
dependencies=[
context__pb2.DESCRIPTOR,
txn__pb2.DESCRIPTOR,
metadata__pb2.DESCRIPTOR,
],
)
_BLOCKCONTEXT = _descriptor.Descriptor(
name="BlockContext",
full_name="org.solana.sealevel.v1.BlockContext",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="txns",
full_name="org.solana.sealevel.v1.BlockContext.txns",
index=0,
number=1,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="acct_states",
full_name="org.solana.sealevel.v1.BlockContext.acct_states",
index=1,
number=2,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="blockhash_queue",
full_name="org.solana.sealevel.v1.BlockContext.blockhash_queue",
index=2,
number=3,
type=12,
cpp_type=9,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="slot_ctx",
full_name="org.solana.sealevel.v1.BlockContext.slot_ctx",
index=3,
number=4,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="epoch_ctx",
full_name="org.solana.sealevel.v1.BlockContext.epoch_ctx",
index=4,
number=5,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[],
serialized_start=82,
serialized_end=349,
)
_BLOCKEFFECTS = _descriptor.Descriptor(
name="BlockEffects",
full_name="org.solana.sealevel.v1.BlockEffects",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="first_error",
full_name="org.solana.sealevel.v1.BlockEffects.first_error",
index=0,
number=1,
type=13,
cpp_type=3,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="acct_states",
full_name="org.solana.sealevel.v1.BlockEffects.acct_states",
index=1,
number=2,
type=11,
cpp_type=10,
label=3,
has_default_value=False,
default_value=[],
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="slot_capitalization",
full_name="org.solana.sealevel.v1.BlockEffects.slot_capitalization",
index=2,
number=3,
type=4,
cpp_type=4,
label=1,
has_default_value=False,
default_value=0,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="lt_hash",
full_name="org.solana.sealevel.v1.BlockEffects.lt_hash",
index=3,
number=4,
type=12,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b(""),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="account_delta_hash",
full_name="org.solana.sealevel.v1.BlockEffects.account_delta_hash",
index=4,
number=5,
type=12,
cpp_type=9,
label=1,
has_default_value=False,
default_value=_b(""),
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[],
serialized_start=352,
serialized_end=517,
)
_BLOCKFIXTURE = _descriptor.Descriptor(
name="BlockFixture",
full_name="org.solana.sealevel.v1.BlockFixture",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="metadata",
full_name="org.solana.sealevel.v1.BlockFixture.metadata",
index=0,
number=1,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="input",
full_name="org.solana.sealevel.v1.BlockFixture.input",
index=1,
number=2,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
_descriptor.FieldDescriptor(
name="output",
full_name="org.solana.sealevel.v1.BlockFixture.output",
index=2,
number=3,
type=11,
cpp_type=10,
label=1,
has_default_value=False,
default_value=None,
message_type=None,
enum_type=None,
containing_type=None,
is_extension=False,
extension_scope=None,
options=None,
file=DESCRIPTOR,
),
],
extensions=[],
nested_types=[],
enum_types=[],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[],
serialized_start=520,
serialized_end=700,
)
_BLOCKCONTEXT.fields_by_name["txns"].message_type = txn__pb2._SANITIZEDTRANSACTION
_BLOCKCONTEXT.fields_by_name["acct_states"].message_type = context__pb2._ACCTSTATE
_BLOCKCONTEXT.fields_by_name["slot_ctx"].message_type = context__pb2._SLOTCONTEXT
_BLOCKCONTEXT.fields_by_name["epoch_ctx"].message_type = context__pb2._EPOCHCONTEXT
_BLOCKEFFECTS.fields_by_name["acct_states"].message_type = context__pb2._ACCTSTATE
_BLOCKFIXTURE.fields_by_name["metadata"].message_type = metadata__pb2._FIXTUREMETADATA
_BLOCKFIXTURE.fields_by_name["input"].message_type = _BLOCKCONTEXT
_BLOCKFIXTURE.fields_by_name["output"].message_type = _BLOCKEFFECTS
DESCRIPTOR.message_types_by_name["BlockContext"] = _BLOCKCONTEXT
DESCRIPTOR.message_types_by_name["BlockEffects"] = _BLOCKEFFECTS
DESCRIPTOR.message_types_by_name["BlockFixture"] = _BLOCKFIXTURE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
BlockContext = _reflection.GeneratedProtocolMessageType(
"BlockContext",
(_message.Message,),
dict(DESCRIPTOR=_BLOCKCONTEXT, __module__="block_pb2"),
)
_sym_db.RegisterMessage(BlockContext)
BlockEffects = _reflection.GeneratedProtocolMessageType(
"BlockEffects",
(_message.Message,),
dict(DESCRIPTOR=_BLOCKEFFECTS, __module__="block_pb2"),
)
_sym_db.RegisterMessage(BlockEffects)
BlockFixture = _reflection.GeneratedProtocolMessageType(
"BlockFixture",
(_message.Message,),
dict(DESCRIPTOR=_BLOCKFIXTURE, __module__="block_pb2"),
)
_sym_db.RegisterMessage(BlockFixture)
22 changes: 22 additions & 0 deletions src/test_suite/context/codec_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import test_suite.context_pb2 as context_pb
import fd58


def encode_acct_state(acct_state: context_pb.AcctState):
# Pubkey
if acct_state.address:
acct_state.address = fd58.enc32(acct_state.address)

# Owner
if acct_state.owner:
acct_state.owner = fd58.enc32(acct_state.owner)


def decode_acct_state(acct_state: context_pb.AcctState):
# Pubkey
if acct_state.address:
acct_state.address = fd58.dec32(acct_state.address)

# Owner
if acct_state.owner:
acct_state.owner = fd58.dec32(acct_state.owner)
Loading

0 comments on commit 8f28470

Please sign in to comment.