diff --git a/.gitignore b/.gitignore index 805667e..2c14e90 100644 --- a/.gitignore +++ b/.gitignore @@ -153,9 +153,6 @@ dmypy.json # Cython debug symbols cython_debug/ -# Cython generated -superbased58.c - # PyCharm # JetBrains specific template is maintained in a separate JetBrains.gitignore that can # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore diff --git a/install.sh b/install.sh index 3225f72..2e3a843 100755 --- a/install.sh +++ b/install.sh @@ -6,4 +6,3 @@ source test_suite_env/bin/activate make -j -C impl pip install . protoc --python_out=src/test_suite invoke.proto -python setup.py build_ext --inplace diff --git a/pyproject.toml b/pyproject.toml index 398e748..ba9ac31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,14 +4,15 @@ description = "Tests client targets against Solana" authors = [ { name = "Manik Jain", email = "mjain@jumptrading.com"} ] -dynamic = ['readme', 'version'] +dynamic = ['version'] +readme = "README.md" requires-python = ">=3.11" dependencies = [ - "base58~=2.1.0", - "loguru~=0.7.0", - "protobuf~=3.19.0", - "typer~=0.9.0", - "Cython>=3.0.9" + "fd58~=0.1.0", + "loguru~=0.7.0", + "protobuf~=3.19.0", + "typer~=0.9.0", + "Cython>=3.0.9" ] [project.scripts] @@ -32,10 +33,5 @@ dev = [ ] [build-system] -requires = ['setuptools', "wheel", "Cython", 'setuptools_scm[toml]'] +requires = ['setuptools'] build-backend = "setuptools.build_meta" - -[tool.setuptools.dynamic] -readme = {file = ["README.md"], content-type = "text/markdown"} - -[tool.setuptools_scm] diff --git a/setup.py b/setup.py deleted file mode 100644 index 7daef3c..0000000 --- a/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -from setuptools import setup, Extension -from Cython.Build import cythonize - -extensions = [ - Extension( - "superbased58", - sources=["superbased58.pyx"], - include_dirs=["impl/firedancer/src/ballet/base58"], - library_dirs=["impl/lib"], - libraries=["fd_ballet"], - ), -] - -setup( - ext_modules=cythonize(extensions), -) diff --git a/src/test_suite/codec_utils.py b/src/test_suite/codec_utils.py index fcc568d..13be1c6 100644 --- a/src/test_suite/codec_utils.py +++ b/src/test_suite/codec_utils.py @@ -1,5 +1,5 @@ import base64 -import superbased58 +import fd58 import test_suite.invoke_pb2 as pb @@ -12,17 +12,13 @@ def decode_input(instruction_context: pb.InstrContext): - instruction_context (pb.InstrContext): Instruction context (will be modified). """ if instruction_context.program_id: - instruction_context.program_id = superbased58.decode_32( - instruction_context.program_id - ) + instruction_context.program_id = fd58.dec32(instruction_context.program_id) if instruction_context.loader_id: - instruction_context.loader_id = superbased58.decode_32( - instruction_context.loader_id - ) + instruction_context.loader_id = fd58.dec32(instruction_context.loader_id) for i in range(len(instruction_context.accounts)): if instruction_context.accounts[i].address: - instruction_context.accounts[i].address = superbased58.decode_32( + instruction_context.accounts[i].address = fd58.dec32( instruction_context.accounts[i].address ) if instruction_context.accounts[i].data: @@ -30,7 +26,7 @@ def decode_input(instruction_context: pb.InstrContext): instruction_context.accounts[i].data ) if instruction_context.accounts[i].owner: - instruction_context.accounts[i].owner = superbased58.decode_32( + instruction_context.accounts[i].owner = fd58.dec32( instruction_context.accounts[i].owner ) @@ -47,17 +43,13 @@ def encode_input(instruction_context: pb.InstrContext): - instruction_context (pb.InstrContext): Instruction context (will be modified). """ if instruction_context.program_id: - instruction_context.program_id = superbased58.encode_32( - instruction_context.program_id - ) + instruction_context.program_id = fd58.enc32(instruction_context.program_id) if instruction_context.loader_id: - instruction_context.loader_id = superbased58.encode_32( - instruction_context.loader_id - ) + instruction_context.loader_id = fd58.enc32(instruction_context.loader_id) for i in range(len(instruction_context.accounts)): if instruction_context.accounts[i].address: - instruction_context.accounts[i].address = superbased58.encode_32( + instruction_context.accounts[i].address = fd58.enc32( instruction_context.accounts[i].address ) if instruction_context.accounts[i].data: @@ -65,7 +57,7 @@ def encode_input(instruction_context: pb.InstrContext): instruction_context.accounts[i].data ) if instruction_context.accounts[i].owner: - instruction_context.accounts[i].owner = superbased58.encode_32( + instruction_context.accounts[i].owner = fd58.enc32( instruction_context.accounts[i].owner ) @@ -83,7 +75,7 @@ def encode_output(instruction_effects: pb.InstrEffects): """ for i in range(len(instruction_effects.modified_accounts)): if instruction_effects.modified_accounts[i].address: - instruction_effects.modified_accounts[i].address = superbased58.encode_32( + instruction_effects.modified_accounts[i].address = fd58.enc32( instruction_effects.modified_accounts[i].address ) if instruction_effects.modified_accounts[i].data: @@ -91,6 +83,6 @@ def encode_output(instruction_effects: pb.InstrEffects): instruction_effects.modified_accounts[i].data ) if instruction_effects.modified_accounts[i].owner: - instruction_effects.modified_accounts[i].owner = superbased58.encode_32( + instruction_effects.modified_accounts[i].owner = fd58.enc32( instruction_effects.modified_accounts[i].owner ) diff --git a/superbased58.pxd b/superbased58.pxd deleted file mode 100644 index a746a25..0000000 --- a/superbased58.pxd +++ /dev/null @@ -1,6 +0,0 @@ -# superbased58.pxd -cdef extern from "fd_base58.h": - char* fd_base58_encode_32(const unsigned char* bytes, unsigned long* opt_len, char* out) - char* fd_base58_encode_64(const unsigned char* bytes, unsigned long* opt_len, char* out) - unsigned char* fd_base58_decode_32(const char* encoded, unsigned char* out) - unsigned char* fd_base58_decode_64(const char* encoded, unsigned char* out) diff --git a/superbased58.pyx b/superbased58.pyx deleted file mode 100644 index afe1e4d..0000000 --- a/superbased58.pyx +++ /dev/null @@ -1,32 +0,0 @@ -cimport superbased58 - -# Constants for buffer sizes including null terminator -cpdef encode_32(bytes data): - cdef char[45] out_buffer - cdef unsigned long length = 0 - cdef char* result = superbased58.fd_base58_encode_32( data, &length, out_buffer) - if result == NULL: - raise MemoryError("Failed to encode data.") - return out_buffer[:length] - -cpdef encode_64(bytes data): - cdef char[89] out_buffer - cdef unsigned long length = 0 - cdef char* result = superbased58.fd_base58_encode_64( data, &length, out_buffer) - if result == NULL: - raise MemoryError("Failed to encode data.") - return out_buffer[:length] - -cpdef decode_32(bytes encoded): - cdef unsigned char[32] out_buffer - cdef unsigned char* result = superbased58.fd_base58_decode_32(encoded, out_buffer) - if result == NULL: - raise ValueError("Failed to decode data.") - return out_buffer[:32] - -cpdef decode_64(bytes encoded): - cdef unsigned char[64] out_buffer - cdef unsigned char* result = superbased58.fd_base58_decode_64(encoded, out_buffer) - if result == NULL: - raise ValueError("Failed to decode data.") - return out_buffer[:64] diff --git a/tests/test_solana_test_suite.py b/tests/test_solana_test_suite.py deleted file mode 100644 index 2c084a7..0000000 --- a/tests/test_solana_test_suite.py +++ /dev/null @@ -1,31 +0,0 @@ -import base58 -import superbased58 -import os - - -def test_superbased58_32_bytes(): - """ - Tests superbased58 against base58 for 32 byte encoding/decoding. - """ - for _ in range(10000): - data = os.urandom(32) - base_58_encoded = base58.b58encode(data) - superbased58_encoded = superbased58.encode_32(data) - assert base_58_encoded == superbased58_encoded - assert base58.b58decode(base_58_encoded) == superbased58.decode_32( - superbased58_encoded - ) - - -def test_superbased58_64_bytes(): - """ - Tests superbased58 against base58 for 64 byte encoding/decoding. - """ - for _ in range(10000): - data = os.urandom(64) - base_58_encoded = base58.b58encode(data) - superbased58_encoded = superbased58.encode_64(data) - assert base_58_encoded == superbased58_encoded - assert base58.b58decode(base_58_encoded) == superbased58.decode_64( - superbased58_encoded - )