diff --git a/.env.example b/.env.example index 5fed379..b3d084c 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ SOLANA_NODE_RPC_ENDPOINT=... SOLANA_NODE_WSS_ENDPOINT=... +GEYSER_ENDPOINT=... +GEYSER_API_TOKEN=... SOLANA_PRIVATE_KEY=... \ No newline at end of file diff --git a/src/cli.py b/src/cli.py index 90a4620..3f35bc0 100644 --- a/src/cli.py +++ b/src/cli.py @@ -65,6 +65,9 @@ async def main() -> None: rpc_endpoint: str | None = os.environ.get("SOLANA_NODE_RPC_ENDPOINT") wss_endpoint: str | None = os.environ.get("SOLANA_NODE_WSS_ENDPOINT") private_key: str | None = os.environ.get("SOLANA_PRIVATE_KEY") + geyser_endpoint: str | None = os.environ.get("GEYSER_ENDPOINT") + geyser_api_token: str | None = os.environ.get("GEYSER_API_TOKEN") + # Validate configuration values if not rpc_endpoint or not rpc_endpoint.startswith(("http://", "https://")): @@ -79,6 +82,14 @@ async def main() -> None: logger.error("Invalid private key. Key appears to be missing or too short") sys.exit(1) + if config.LISTENER_TYPE.lower() == "geyser": + if not geyser_endpoint: + logger.error("GEYSER_ENDPOINT environment variable is not set") + sys.exit(1) + if not geyser_api_token: + logger.error("GEYSER_API_TOKEN environment variable is not set") + sys.exit(1) + # Get trading parameters buy_amount: float = args.amount if args.amount is not None else config.BUY_AMOUNT buy_slippage: float = ( @@ -97,6 +108,8 @@ async def main() -> None: sell_slippage=sell_slippage, max_retries=config.MAX_RETRIES, listener_type=config.LISTENER_TYPE, + geyser_endpoint=geyser_endpoint, + geyser_api_token=geyser_api_token, ) try: diff --git a/src/config.py b/src/config.py index b90c11e..70497bd 100644 --- a/src/config.py +++ b/src/config.py @@ -15,7 +15,7 @@ SELL_SLIPPAGE: float = 0.4 # Consistent slippage tolerance to maintain trading # EXTREME FAST Mode configuration # When enabled, skips waiting for the bonding curve to stabilize and RPC price check. # The bot buys the specified number of tokens directly, making the process faster but less precise. -EXTREME_FAST_MODE: bool = False +EXTREME_FAST_MODE: bool = True # Amount of tokens to buy in EXTREME FAST mode. No price calculation is done; the bot buys exactly this amount. EXTREME_FAST_TOKEN_AMOUNT: int = 30 @@ -24,15 +24,16 @@ EXTREME_FAST_TOKEN_AMOUNT: int = 30 # Manage transaction speed and cost on the Solana network ENABLE_DYNAMIC_PRIORITY_FEE: bool = False # Adaptive fee calculation ENABLE_FIXED_PRIORITY_FEE: bool = True # Use consistent, predictable fee -FIXED_PRIORITY_FEE: int = 2_000 # Base fee in microlamports +FIXED_PRIORITY_FEE: int = 500_000 # Base fee in microlamports EXTRA_PRIORITY_FEE: float = 0.0 # Percentage increase on priority fee (0.1 = 10%) -HARD_CAP_PRIOR_FEE: int = 200_000 # Maximum allowable fee to prevent excessive spending in microlamports +HARD_CAP_PRIOR_FEE: int = 500_000 # Maximum allowable fee to prevent excessive spending in microlamports # Listener configuration # Choose method for detecting new tokens on the network # "logs": Recommended for more stable token detection # "blocks": Unstable method, potentially less reliable +# "geyser": The fastest way for getting updates, requires Geyser endpoint LISTENER_TYPE = "logs" @@ -48,7 +49,7 @@ WAIT_TIME_BEFORE_NEW_TOKEN: int | float = 15 # Pause between token trades # Token and account management # Control token processing and account cleanup strategies -MAX_TOKEN_AGE: int | float = 0.1 # Maximum token age in seconds for processing +MAX_TOKEN_AGE: int | float = 0.001 # Maximum token age in seconds for processing # Cleanup mode determines when to manage token accounts. Options: # "disabled": No cleanup will occur. @@ -98,7 +99,7 @@ def validate_configuration() -> None: raise ValueError("Cannot enable both dynamic and fixed priority fees simultaneously") # Validate listener type - if LISTENER_TYPE not in ["logs", "blocks"]: + if LISTENER_TYPE not in ["logs", "blocks", "geyser"]: raise ValueError("LISTENER_TYPE must be either 'logs' or 'blocks'") # Validate cleanup mode diff --git a/src/core/client.py b/src/core/client.py index a39140b..d0caa16 100644 --- a/src/core/client.py +++ b/src/core/client.py @@ -8,7 +8,7 @@ from typing import Any import aiohttp from solana.rpc.async_api import AsyncClient -from solana.rpc.commitment import Confirmed +from solana.rpc.commitment import Processed from solana.rpc.types import TxOpts from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price from solders.hash import Hash @@ -163,7 +163,7 @@ class SolanaClient: for attempt in range(max_retries): try: tx_opts = TxOpts( - skip_preflight=skip_preflight, preflight_commitment=Confirmed + skip_preflight=skip_preflight, preflight_commitment=Processed ) response = await client.send_transaction(transaction, tx_opts) return response.value diff --git a/src/geyser/generated/geyser_pb2.py b/src/geyser/generated/geyser_pb2.py new file mode 100644 index 0000000..222873f --- /dev/null +++ b/src/geyser/generated/geyser_pb2.py @@ -0,0 +1,140 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: geyser.proto +# Protobuf Python Version: 5.29.0 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder + +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 29, + 0, + '', + 'geyser.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + +from geyser.generated.solana_storage_pb2 import * + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cgeyser.proto\x12\x06geyser\x1a\x14solana-storage.proto\"\xf6\t\n\x10SubscribeRequest\x12\x38\n\x08\x61\x63\x63ounts\x18\x01 \x03(\x0b\x32&.geyser.SubscribeRequest.AccountsEntry\x12\x32\n\x05slots\x18\x02 \x03(\x0b\x32#.geyser.SubscribeRequest.SlotsEntry\x12@\n\x0ctransactions\x18\x03 \x03(\x0b\x32*.geyser.SubscribeRequest.TransactionsEntry\x12M\n\x13transactions_status\x18\n \x03(\x0b\x32\x30.geyser.SubscribeRequest.TransactionsStatusEntry\x12\x34\n\x06\x62locks\x18\x04 \x03(\x0b\x32$.geyser.SubscribeRequest.BlocksEntry\x12=\n\x0b\x62locks_meta\x18\x05 \x03(\x0b\x32(.geyser.SubscribeRequest.BlocksMetaEntry\x12\x32\n\x05\x65ntry\x18\x08 \x03(\x0b\x32#.geyser.SubscribeRequest.EntryEntry\x12\x30\n\ncommitment\x18\x06 \x01(\x0e\x32\x17.geyser.CommitmentLevelH\x00\x88\x01\x01\x12\x46\n\x13\x61\x63\x63ounts_data_slice\x18\x07 \x03(\x0b\x32).geyser.SubscribeRequestAccountsDataSlice\x12/\n\x04ping\x18\t \x01(\x0b\x32\x1c.geyser.SubscribeRequestPingH\x01\x88\x01\x01\x1aW\n\rAccountsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x35\n\x05value\x18\x02 \x01(\x0b\x32&.geyser.SubscribeRequestFilterAccounts:\x02\x38\x01\x1aQ\n\nSlotsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x32\n\x05value\x18\x02 \x01(\x0b\x32#.geyser.SubscribeRequestFilterSlots:\x02\x38\x01\x1a_\n\x11TransactionsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x39\n\x05value\x18\x02 \x01(\x0b\x32*.geyser.SubscribeRequestFilterTransactions:\x02\x38\x01\x1a\x65\n\x17TransactionsStatusEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x39\n\x05value\x18\x02 \x01(\x0b\x32*.geyser.SubscribeRequestFilterTransactions:\x02\x38\x01\x1aS\n\x0b\x42locksEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x33\n\x05value\x18\x02 \x01(\x0b\x32$.geyser.SubscribeRequestFilterBlocks:\x02\x38\x01\x1a[\n\x0f\x42locksMetaEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x37\n\x05value\x18\x02 \x01(\x0b\x32(.geyser.SubscribeRequestFilterBlocksMeta:\x02\x38\x01\x1aQ\n\nEntryEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x32\n\x05value\x18\x02 \x01(\x0b\x32#.geyser.SubscribeRequestFilterEntry:\x02\x38\x01\x42\r\n\x0b_commitmentB\x07\n\x05_ping\"\xbf\x01\n\x1eSubscribeRequestFilterAccounts\x12\x0f\n\x07\x61\x63\x63ount\x18\x02 \x03(\t\x12\r\n\x05owner\x18\x03 \x03(\t\x12=\n\x07\x66ilters\x18\x04 \x03(\x0b\x32,.geyser.SubscribeRequestFilterAccountsFilter\x12#\n\x16nonempty_txn_signature\x18\x05 \x01(\x08H\x00\x88\x01\x01\x42\x19\n\x17_nonempty_txn_signature\"\xf3\x01\n$SubscribeRequestFilterAccountsFilter\x12\x44\n\x06memcmp\x18\x01 \x01(\x0b\x32\x32.geyser.SubscribeRequestFilterAccountsFilterMemcmpH\x00\x12\x12\n\x08\x64\x61tasize\x18\x02 \x01(\x04H\x00\x12\x1d\n\x13token_account_state\x18\x03 \x01(\x08H\x00\x12H\n\x08lamports\x18\x04 \x01(\x0b\x32\x34.geyser.SubscribeRequestFilterAccountsFilterLamportsH\x00\x42\x08\n\x06\x66ilter\"y\n*SubscribeRequestFilterAccountsFilterMemcmp\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12\x0f\n\x05\x62ytes\x18\x02 \x01(\x0cH\x00\x12\x10\n\x06\x62\x61se58\x18\x03 \x01(\tH\x00\x12\x10\n\x06\x62\x61se64\x18\x04 \x01(\tH\x00\x42\x06\n\x04\x64\x61ta\"m\n,SubscribeRequestFilterAccountsFilterLamports\x12\x0c\n\x02\x65q\x18\x01 \x01(\x04H\x00\x12\x0c\n\x02ne\x18\x02 \x01(\x04H\x00\x12\x0c\n\x02lt\x18\x03 \x01(\x04H\x00\x12\x0c\n\x02gt\x18\x04 \x01(\x04H\x00\x42\x05\n\x03\x63mp\"Y\n\x1bSubscribeRequestFilterSlots\x12!\n\x14\x66ilter_by_commitment\x18\x01 \x01(\x08H\x00\x88\x01\x01\x42\x17\n\x15_filter_by_commitment\"\xd2\x01\n\"SubscribeRequestFilterTransactions\x12\x11\n\x04vote\x18\x01 \x01(\x08H\x00\x88\x01\x01\x12\x13\n\x06\x66\x61iled\x18\x02 \x01(\x08H\x01\x88\x01\x01\x12\x16\n\tsignature\x18\x05 \x01(\tH\x02\x88\x01\x01\x12\x17\n\x0f\x61\x63\x63ount_include\x18\x03 \x03(\t\x12\x17\n\x0f\x61\x63\x63ount_exclude\x18\x04 \x03(\t\x12\x18\n\x10\x61\x63\x63ount_required\x18\x06 \x03(\tB\x07\n\x05_voteB\t\n\x07_failedB\x0c\n\n_signature\"\xd9\x01\n\x1cSubscribeRequestFilterBlocks\x12\x17\n\x0f\x61\x63\x63ount_include\x18\x01 \x03(\t\x12!\n\x14include_transactions\x18\x02 \x01(\x08H\x00\x88\x01\x01\x12\x1d\n\x10include_accounts\x18\x03 \x01(\x08H\x01\x88\x01\x01\x12\x1c\n\x0finclude_entries\x18\x04 \x01(\x08H\x02\x88\x01\x01\x42\x17\n\x15_include_transactionsB\x13\n\x11_include_accountsB\x12\n\x10_include_entries\"\"\n SubscribeRequestFilterBlocksMeta\"\x1d\n\x1bSubscribeRequestFilterEntry\"C\n!SubscribeRequestAccountsDataSlice\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12\x0e\n\x06length\x18\x02 \x01(\x04\"\"\n\x14SubscribeRequestPing\x12\n\n\x02id\x18\x01 \x01(\x05\"\x85\x04\n\x0fSubscribeUpdate\x12\x0f\n\x07\x66ilters\x18\x01 \x03(\t\x12\x31\n\x07\x61\x63\x63ount\x18\x02 \x01(\x0b\x32\x1e.geyser.SubscribeUpdateAccountH\x00\x12+\n\x04slot\x18\x03 \x01(\x0b\x32\x1b.geyser.SubscribeUpdateSlotH\x00\x12\x39\n\x0btransaction\x18\x04 \x01(\x0b\x32\".geyser.SubscribeUpdateTransactionH\x00\x12\x46\n\x12transaction_status\x18\n \x01(\x0b\x32(.geyser.SubscribeUpdateTransactionStatusH\x00\x12-\n\x05\x62lock\x18\x05 \x01(\x0b\x32\x1c.geyser.SubscribeUpdateBlockH\x00\x12+\n\x04ping\x18\x06 \x01(\x0b\x32\x1b.geyser.SubscribeUpdatePingH\x00\x12+\n\x04pong\x18\t \x01(\x0b\x32\x1b.geyser.SubscribeUpdatePongH\x00\x12\x36\n\nblock_meta\x18\x07 \x01(\x0b\x32 .geyser.SubscribeUpdateBlockMetaH\x00\x12-\n\x05\x65ntry\x18\x08 \x01(\x0b\x32\x1c.geyser.SubscribeUpdateEntryH\x00\x42\x0e\n\x0cupdate_oneof\"o\n\x16SubscribeUpdateAccount\x12\x33\n\x07\x61\x63\x63ount\x18\x01 \x01(\x0b\x32\".geyser.SubscribeUpdateAccountInfo\x12\x0c\n\x04slot\x18\x02 \x01(\x04\x12\x12\n\nis_startup\x18\x03 \x01(\x08\"\xc8\x01\n\x1aSubscribeUpdateAccountInfo\x12\x0e\n\x06pubkey\x18\x01 \x01(\x0c\x12\x10\n\x08lamports\x18\x02 \x01(\x04\x12\r\n\x05owner\x18\x03 \x01(\x0c\x12\x12\n\nexecutable\x18\x04 \x01(\x08\x12\x12\n\nrent_epoch\x18\x05 \x01(\x04\x12\x0c\n\x04\x64\x61ta\x18\x06 \x01(\x0c\x12\x15\n\rwrite_version\x18\x07 \x01(\x04\x12\x1a\n\rtxn_signature\x18\x08 \x01(\x0cH\x00\x88\x01\x01\x42\x10\n\x0e_txn_signature\"\x94\x01\n\x13SubscribeUpdateSlot\x12\x0c\n\x04slot\x18\x01 \x01(\x04\x12\x13\n\x06parent\x18\x02 \x01(\x04H\x00\x88\x01\x01\x12\'\n\x06status\x18\x03 \x01(\x0e\x32\x17.geyser.CommitmentLevel\x12\x17\n\ndead_error\x18\x04 \x01(\tH\x01\x88\x01\x01\x42\t\n\x07_parentB\r\n\x0b_dead_error\"g\n\x1aSubscribeUpdateTransaction\x12;\n\x0btransaction\x18\x01 \x01(\x0b\x32&.geyser.SubscribeUpdateTransactionInfo\x12\x0c\n\x04slot\x18\x02 \x01(\x04\"\xd8\x01\n\x1eSubscribeUpdateTransactionInfo\x12\x11\n\tsignature\x18\x01 \x01(\x0c\x12\x0f\n\x07is_vote\x18\x02 \x01(\x08\x12?\n\x0btransaction\x18\x03 \x01(\x0b\x32*.solana.storage.ConfirmedBlock.Transaction\x12\x42\n\x04meta\x18\x04 \x01(\x0b\x32\x34.solana.storage.ConfirmedBlock.TransactionStatusMeta\x12\r\n\x05index\x18\x05 \x01(\x04\"\xa1\x01\n SubscribeUpdateTransactionStatus\x12\x0c\n\x04slot\x18\x01 \x01(\x04\x12\x11\n\tsignature\x18\x02 \x01(\x0c\x12\x0f\n\x07is_vote\x18\x03 \x01(\x08\x12\r\n\x05index\x18\x04 \x01(\x04\x12<\n\x03\x65rr\x18\x05 \x01(\x0b\x32/.solana.storage.ConfirmedBlock.TransactionError\"\xa0\x04\n\x14SubscribeUpdateBlock\x12\x0c\n\x04slot\x18\x01 \x01(\x04\x12\x11\n\tblockhash\x18\x02 \x01(\t\x12\x37\n\x07rewards\x18\x03 \x01(\x0b\x32&.solana.storage.ConfirmedBlock.Rewards\x12@\n\nblock_time\x18\x04 \x01(\x0b\x32,.solana.storage.ConfirmedBlock.UnixTimestamp\x12@\n\x0c\x62lock_height\x18\x05 \x01(\x0b\x32*.solana.storage.ConfirmedBlock.BlockHeight\x12\x13\n\x0bparent_slot\x18\x07 \x01(\x04\x12\x18\n\x10parent_blockhash\x18\x08 \x01(\t\x12\"\n\x1a\x65xecuted_transaction_count\x18\t \x01(\x04\x12<\n\x0ctransactions\x18\x06 \x03(\x0b\x32&.geyser.SubscribeUpdateTransactionInfo\x12\x1d\n\x15updated_account_count\x18\n \x01(\x04\x12\x34\n\x08\x61\x63\x63ounts\x18\x0b \x03(\x0b\x32\".geyser.SubscribeUpdateAccountInfo\x12\x15\n\rentries_count\x18\x0c \x01(\x04\x12-\n\x07\x65ntries\x18\r \x03(\x0b\x32\x1c.geyser.SubscribeUpdateEntry\"\xe2\x02\n\x18SubscribeUpdateBlockMeta\x12\x0c\n\x04slot\x18\x01 \x01(\x04\x12\x11\n\tblockhash\x18\x02 \x01(\t\x12\x37\n\x07rewards\x18\x03 \x01(\x0b\x32&.solana.storage.ConfirmedBlock.Rewards\x12@\n\nblock_time\x18\x04 \x01(\x0b\x32,.solana.storage.ConfirmedBlock.UnixTimestamp\x12@\n\x0c\x62lock_height\x18\x05 \x01(\x0b\x32*.solana.storage.ConfirmedBlock.BlockHeight\x12\x13\n\x0bparent_slot\x18\x06 \x01(\x04\x12\x18\n\x10parent_blockhash\x18\x07 \x01(\t\x12\"\n\x1a\x65xecuted_transaction_count\x18\x08 \x01(\x04\x12\x15\n\rentries_count\x18\t \x01(\x04\"\x9d\x01\n\x14SubscribeUpdateEntry\x12\x0c\n\x04slot\x18\x01 \x01(\x04\x12\r\n\x05index\x18\x02 \x01(\x04\x12\x12\n\nnum_hashes\x18\x03 \x01(\x04\x12\x0c\n\x04hash\x18\x04 \x01(\x0c\x12\"\n\x1a\x65xecuted_transaction_count\x18\x05 \x01(\x04\x12\"\n\x1astarting_transaction_index\x18\x06 \x01(\x04\"\x15\n\x13SubscribeUpdatePing\"!\n\x13SubscribeUpdatePong\x12\n\n\x02id\x18\x01 \x01(\x05\"\x1c\n\x0bPingRequest\x12\r\n\x05\x63ount\x18\x01 \x01(\x05\"\x1d\n\x0cPongResponse\x12\r\n\x05\x63ount\x18\x01 \x01(\x05\"\\\n\x19GetLatestBlockhashRequest\x12\x30\n\ncommitment\x18\x01 \x01(\x0e\x32\x17.geyser.CommitmentLevelH\x00\x88\x01\x01\x42\r\n\x0b_commitment\"^\n\x1aGetLatestBlockhashResponse\x12\x0c\n\x04slot\x18\x01 \x01(\x04\x12\x11\n\tblockhash\x18\x02 \x01(\t\x12\x1f\n\x17last_valid_block_height\x18\x03 \x01(\x04\"X\n\x15GetBlockHeightRequest\x12\x30\n\ncommitment\x18\x01 \x01(\x0e\x32\x17.geyser.CommitmentLevelH\x00\x88\x01\x01\x42\r\n\x0b_commitment\".\n\x16GetBlockHeightResponse\x12\x14\n\x0c\x62lock_height\x18\x01 \x01(\x04\"Q\n\x0eGetSlotRequest\x12\x30\n\ncommitment\x18\x01 \x01(\x0e\x32\x17.geyser.CommitmentLevelH\x00\x88\x01\x01\x42\r\n\x0b_commitment\"\x1f\n\x0fGetSlotResponse\x12\x0c\n\x04slot\x18\x01 \x01(\x04\"\x13\n\x11GetVersionRequest\"%\n\x12GetVersionResponse\x12\x0f\n\x07version\x18\x01 \x01(\t\"m\n\x17IsBlockhashValidRequest\x12\x11\n\tblockhash\x18\x01 \x01(\t\x12\x30\n\ncommitment\x18\x02 \x01(\x0e\x32\x17.geyser.CommitmentLevelH\x00\x88\x01\x01\x42\r\n\x0b_commitment\"7\n\x18IsBlockhashValidResponse\x12\x0c\n\x04slot\x18\x01 \x01(\x04\x12\r\n\x05valid\x18\x02 \x01(\x08*\x83\x01\n\x0f\x43ommitmentLevel\x12\r\n\tPROCESSED\x10\x00\x12\r\n\tCONFIRMED\x10\x01\x12\r\n\tFINALIZED\x10\x02\x12\x18\n\x14\x46IRST_SHRED_RECEIVED\x10\x03\x12\r\n\tCOMPLETED\x10\x04\x12\x10\n\x0c\x43REATED_BANK\x10\x05\x12\x08\n\x04\x44\x45\x41\x44\x10\x06\x32\x93\x04\n\x06Geyser\x12\x44\n\tSubscribe\x12\x18.geyser.SubscribeRequest\x1a\x17.geyser.SubscribeUpdate\"\x00(\x01\x30\x01\x12\x33\n\x04Ping\x12\x13.geyser.PingRequest\x1a\x14.geyser.PongResponse\"\x00\x12]\n\x12GetLatestBlockhash\x12!.geyser.GetLatestBlockhashRequest\x1a\".geyser.GetLatestBlockhashResponse\"\x00\x12Q\n\x0eGetBlockHeight\x12\x1d.geyser.GetBlockHeightRequest\x1a\x1e.geyser.GetBlockHeightResponse\"\x00\x12<\n\x07GetSlot\x12\x16.geyser.GetSlotRequest\x1a\x17.geyser.GetSlotResponse\"\x00\x12W\n\x10IsBlockhashValid\x12\x1f.geyser.IsBlockhashValidRequest\x1a .geyser.IsBlockhashValidResponse\"\x00\x12\x45\n\nGetVersion\x12\x19.geyser.GetVersionRequest\x1a\x1a.geyser.GetVersionResponse\"\x00\x42;Z9github.com/rpcpool/yellowstone-grpc/examples/golang/protoP\x00\x62\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'geyser_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'Z9github.com/rpcpool/yellowstone-grpc/examples/golang/proto' + _globals['_SUBSCRIBEREQUEST_ACCOUNTSENTRY']._loaded_options = None + _globals['_SUBSCRIBEREQUEST_ACCOUNTSENTRY']._serialized_options = b'8\001' + _globals['_SUBSCRIBEREQUEST_SLOTSENTRY']._loaded_options = None + _globals['_SUBSCRIBEREQUEST_SLOTSENTRY']._serialized_options = b'8\001' + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSENTRY']._loaded_options = None + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSENTRY']._serialized_options = b'8\001' + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSSTATUSENTRY']._loaded_options = None + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSSTATUSENTRY']._serialized_options = b'8\001' + _globals['_SUBSCRIBEREQUEST_BLOCKSENTRY']._loaded_options = None + _globals['_SUBSCRIBEREQUEST_BLOCKSENTRY']._serialized_options = b'8\001' + _globals['_SUBSCRIBEREQUEST_BLOCKSMETAENTRY']._loaded_options = None + _globals['_SUBSCRIBEREQUEST_BLOCKSMETAENTRY']._serialized_options = b'8\001' + _globals['_SUBSCRIBEREQUEST_ENTRYENTRY']._loaded_options = None + _globals['_SUBSCRIBEREQUEST_ENTRYENTRY']._serialized_options = b'8\001' + _globals['_COMMITMENTLEVEL']._serialized_start=6020 + _globals['_COMMITMENTLEVEL']._serialized_end=6151 + _globals['_SUBSCRIBEREQUEST']._serialized_start=47 + _globals['_SUBSCRIBEREQUEST']._serialized_end=1317 + _globals['_SUBSCRIBEREQUEST_ACCOUNTSENTRY']._serialized_start=662 + _globals['_SUBSCRIBEREQUEST_ACCOUNTSENTRY']._serialized_end=749 + _globals['_SUBSCRIBEREQUEST_SLOTSENTRY']._serialized_start=751 + _globals['_SUBSCRIBEREQUEST_SLOTSENTRY']._serialized_end=832 + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSENTRY']._serialized_start=834 + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSENTRY']._serialized_end=929 + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSSTATUSENTRY']._serialized_start=931 + _globals['_SUBSCRIBEREQUEST_TRANSACTIONSSTATUSENTRY']._serialized_end=1032 + _globals['_SUBSCRIBEREQUEST_BLOCKSENTRY']._serialized_start=1034 + _globals['_SUBSCRIBEREQUEST_BLOCKSENTRY']._serialized_end=1117 + _globals['_SUBSCRIBEREQUEST_BLOCKSMETAENTRY']._serialized_start=1119 + _globals['_SUBSCRIBEREQUEST_BLOCKSMETAENTRY']._serialized_end=1210 + _globals['_SUBSCRIBEREQUEST_ENTRYENTRY']._serialized_start=1212 + _globals['_SUBSCRIBEREQUEST_ENTRYENTRY']._serialized_end=1293 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTS']._serialized_start=1320 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTS']._serialized_end=1511 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTSFILTER']._serialized_start=1514 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTSFILTER']._serialized_end=1757 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTSFILTERMEMCMP']._serialized_start=1759 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTSFILTERMEMCMP']._serialized_end=1880 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTSFILTERLAMPORTS']._serialized_start=1882 + _globals['_SUBSCRIBEREQUESTFILTERACCOUNTSFILTERLAMPORTS']._serialized_end=1991 + _globals['_SUBSCRIBEREQUESTFILTERSLOTS']._serialized_start=1993 + _globals['_SUBSCRIBEREQUESTFILTERSLOTS']._serialized_end=2082 + _globals['_SUBSCRIBEREQUESTFILTERTRANSACTIONS']._serialized_start=2085 + _globals['_SUBSCRIBEREQUESTFILTERTRANSACTIONS']._serialized_end=2295 + _globals['_SUBSCRIBEREQUESTFILTERBLOCKS']._serialized_start=2298 + _globals['_SUBSCRIBEREQUESTFILTERBLOCKS']._serialized_end=2515 + _globals['_SUBSCRIBEREQUESTFILTERBLOCKSMETA']._serialized_start=2517 + _globals['_SUBSCRIBEREQUESTFILTERBLOCKSMETA']._serialized_end=2551 + _globals['_SUBSCRIBEREQUESTFILTERENTRY']._serialized_start=2553 + _globals['_SUBSCRIBEREQUESTFILTERENTRY']._serialized_end=2582 + _globals['_SUBSCRIBEREQUESTACCOUNTSDATASLICE']._serialized_start=2584 + _globals['_SUBSCRIBEREQUESTACCOUNTSDATASLICE']._serialized_end=2651 + _globals['_SUBSCRIBEREQUESTPING']._serialized_start=2653 + _globals['_SUBSCRIBEREQUESTPING']._serialized_end=2687 + _globals['_SUBSCRIBEUPDATE']._serialized_start=2690 + _globals['_SUBSCRIBEUPDATE']._serialized_end=3207 + _globals['_SUBSCRIBEUPDATEACCOUNT']._serialized_start=3209 + _globals['_SUBSCRIBEUPDATEACCOUNT']._serialized_end=3320 + _globals['_SUBSCRIBEUPDATEACCOUNTINFO']._serialized_start=3323 + _globals['_SUBSCRIBEUPDATEACCOUNTINFO']._serialized_end=3523 + _globals['_SUBSCRIBEUPDATESLOT']._serialized_start=3526 + _globals['_SUBSCRIBEUPDATESLOT']._serialized_end=3674 + _globals['_SUBSCRIBEUPDATETRANSACTION']._serialized_start=3676 + _globals['_SUBSCRIBEUPDATETRANSACTION']._serialized_end=3779 + _globals['_SUBSCRIBEUPDATETRANSACTIONINFO']._serialized_start=3782 + _globals['_SUBSCRIBEUPDATETRANSACTIONINFO']._serialized_end=3998 + _globals['_SUBSCRIBEUPDATETRANSACTIONSTATUS']._serialized_start=4001 + _globals['_SUBSCRIBEUPDATETRANSACTIONSTATUS']._serialized_end=4162 + _globals['_SUBSCRIBEUPDATEBLOCK']._serialized_start=4165 + _globals['_SUBSCRIBEUPDATEBLOCK']._serialized_end=4709 + _globals['_SUBSCRIBEUPDATEBLOCKMETA']._serialized_start=4712 + _globals['_SUBSCRIBEUPDATEBLOCKMETA']._serialized_end=5066 + _globals['_SUBSCRIBEUPDATEENTRY']._serialized_start=5069 + _globals['_SUBSCRIBEUPDATEENTRY']._serialized_end=5226 + _globals['_SUBSCRIBEUPDATEPING']._serialized_start=5228 + _globals['_SUBSCRIBEUPDATEPING']._serialized_end=5249 + _globals['_SUBSCRIBEUPDATEPONG']._serialized_start=5251 + _globals['_SUBSCRIBEUPDATEPONG']._serialized_end=5284 + _globals['_PINGREQUEST']._serialized_start=5286 + _globals['_PINGREQUEST']._serialized_end=5314 + _globals['_PONGRESPONSE']._serialized_start=5316 + _globals['_PONGRESPONSE']._serialized_end=5345 + _globals['_GETLATESTBLOCKHASHREQUEST']._serialized_start=5347 + _globals['_GETLATESTBLOCKHASHREQUEST']._serialized_end=5439 + _globals['_GETLATESTBLOCKHASHRESPONSE']._serialized_start=5441 + _globals['_GETLATESTBLOCKHASHRESPONSE']._serialized_end=5535 + _globals['_GETBLOCKHEIGHTREQUEST']._serialized_start=5537 + _globals['_GETBLOCKHEIGHTREQUEST']._serialized_end=5625 + _globals['_GETBLOCKHEIGHTRESPONSE']._serialized_start=5627 + _globals['_GETBLOCKHEIGHTRESPONSE']._serialized_end=5673 + _globals['_GETSLOTREQUEST']._serialized_start=5675 + _globals['_GETSLOTREQUEST']._serialized_end=5756 + _globals['_GETSLOTRESPONSE']._serialized_start=5758 + _globals['_GETSLOTRESPONSE']._serialized_end=5789 + _globals['_GETVERSIONREQUEST']._serialized_start=5791 + _globals['_GETVERSIONREQUEST']._serialized_end=5810 + _globals['_GETVERSIONRESPONSE']._serialized_start=5812 + _globals['_GETVERSIONRESPONSE']._serialized_end=5849 + _globals['_ISBLOCKHASHVALIDREQUEST']._serialized_start=5851 + _globals['_ISBLOCKHASHVALIDREQUEST']._serialized_end=5960 + _globals['_ISBLOCKHASHVALIDRESPONSE']._serialized_start=5962 + _globals['_ISBLOCKHASHVALIDRESPONSE']._serialized_end=6017 + _globals['_GEYSER']._serialized_start=6154 + _globals['_GEYSER']._serialized_end=6685 +# @@protoc_insertion_point(module_scope) diff --git a/src/geyser/generated/geyser_pb2.pyi b/src/geyser/generated/geyser_pb2.pyi new file mode 100644 index 0000000..909f4fb --- /dev/null +++ b/src/geyser/generated/geyser_pb2.pyi @@ -0,0 +1,485 @@ +import solana_storage_pb2 as _solana_storage_pb2 +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union +from solana_storage_pb2 import ConfirmedBlock as ConfirmedBlock +from solana_storage_pb2 import ConfirmedTransaction as ConfirmedTransaction +from solana_storage_pb2 import Transaction as Transaction +from solana_storage_pb2 import Message as Message +from solana_storage_pb2 import MessageHeader as MessageHeader +from solana_storage_pb2 import MessageAddressTableLookup as MessageAddressTableLookup +from solana_storage_pb2 import TransactionStatusMeta as TransactionStatusMeta +from solana_storage_pb2 import TransactionError as TransactionError +from solana_storage_pb2 import InnerInstructions as InnerInstructions +from solana_storage_pb2 import InnerInstruction as InnerInstruction +from solana_storage_pb2 import CompiledInstruction as CompiledInstruction +from solana_storage_pb2 import TokenBalance as TokenBalance +from solana_storage_pb2 import UiTokenAmount as UiTokenAmount +from solana_storage_pb2 import ReturnData as ReturnData +from solana_storage_pb2 import Reward as Reward +from solana_storage_pb2 import Rewards as Rewards +from solana_storage_pb2 import UnixTimestamp as UnixTimestamp +from solana_storage_pb2 import BlockHeight as BlockHeight +from solana_storage_pb2 import NumPartitions as NumPartitions +from solana_storage_pb2 import RewardType as RewardType + +DESCRIPTOR: _descriptor.FileDescriptor +Unspecified: _solana_storage_pb2.RewardType +Fee: _solana_storage_pb2.RewardType +Rent: _solana_storage_pb2.RewardType +Staking: _solana_storage_pb2.RewardType +Voting: _solana_storage_pb2.RewardType + +class CommitmentLevel(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + PROCESSED: _ClassVar[CommitmentLevel] + CONFIRMED: _ClassVar[CommitmentLevel] + FINALIZED: _ClassVar[CommitmentLevel] + FIRST_SHRED_RECEIVED: _ClassVar[CommitmentLevel] + COMPLETED: _ClassVar[CommitmentLevel] + CREATED_BANK: _ClassVar[CommitmentLevel] + DEAD: _ClassVar[CommitmentLevel] +PROCESSED: CommitmentLevel +CONFIRMED: CommitmentLevel +FINALIZED: CommitmentLevel +FIRST_SHRED_RECEIVED: CommitmentLevel +COMPLETED: CommitmentLevel +CREATED_BANK: CommitmentLevel +DEAD: CommitmentLevel + +class SubscribeRequest(_message.Message): + __slots__ = ("accounts", "slots", "transactions", "transactions_status", "blocks", "blocks_meta", "entry", "commitment", "accounts_data_slice", "ping") + class AccountsEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SubscribeRequestFilterAccounts + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SubscribeRequestFilterAccounts, _Mapping]] = ...) -> None: ... + class SlotsEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SubscribeRequestFilterSlots + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SubscribeRequestFilterSlots, _Mapping]] = ...) -> None: ... + class TransactionsEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SubscribeRequestFilterTransactions + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SubscribeRequestFilterTransactions, _Mapping]] = ...) -> None: ... + class TransactionsStatusEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SubscribeRequestFilterTransactions + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SubscribeRequestFilterTransactions, _Mapping]] = ...) -> None: ... + class BlocksEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SubscribeRequestFilterBlocks + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SubscribeRequestFilterBlocks, _Mapping]] = ...) -> None: ... + class BlocksMetaEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SubscribeRequestFilterBlocksMeta + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SubscribeRequestFilterBlocksMeta, _Mapping]] = ...) -> None: ... + class EntryEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: SubscribeRequestFilterEntry + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[SubscribeRequestFilterEntry, _Mapping]] = ...) -> None: ... + ACCOUNTS_FIELD_NUMBER: _ClassVar[int] + SLOTS_FIELD_NUMBER: _ClassVar[int] + TRANSACTIONS_FIELD_NUMBER: _ClassVar[int] + TRANSACTIONS_STATUS_FIELD_NUMBER: _ClassVar[int] + BLOCKS_FIELD_NUMBER: _ClassVar[int] + BLOCKS_META_FIELD_NUMBER: _ClassVar[int] + ENTRY_FIELD_NUMBER: _ClassVar[int] + COMMITMENT_FIELD_NUMBER: _ClassVar[int] + ACCOUNTS_DATA_SLICE_FIELD_NUMBER: _ClassVar[int] + PING_FIELD_NUMBER: _ClassVar[int] + accounts: _containers.MessageMap[str, SubscribeRequestFilterAccounts] + slots: _containers.MessageMap[str, SubscribeRequestFilterSlots] + transactions: _containers.MessageMap[str, SubscribeRequestFilterTransactions] + transactions_status: _containers.MessageMap[str, SubscribeRequestFilterTransactions] + blocks: _containers.MessageMap[str, SubscribeRequestFilterBlocks] + blocks_meta: _containers.MessageMap[str, SubscribeRequestFilterBlocksMeta] + entry: _containers.MessageMap[str, SubscribeRequestFilterEntry] + commitment: CommitmentLevel + accounts_data_slice: _containers.RepeatedCompositeFieldContainer[SubscribeRequestAccountsDataSlice] + ping: SubscribeRequestPing + def __init__(self, accounts: _Optional[_Mapping[str, SubscribeRequestFilterAccounts]] = ..., slots: _Optional[_Mapping[str, SubscribeRequestFilterSlots]] = ..., transactions: _Optional[_Mapping[str, SubscribeRequestFilterTransactions]] = ..., transactions_status: _Optional[_Mapping[str, SubscribeRequestFilterTransactions]] = ..., blocks: _Optional[_Mapping[str, SubscribeRequestFilterBlocks]] = ..., blocks_meta: _Optional[_Mapping[str, SubscribeRequestFilterBlocksMeta]] = ..., entry: _Optional[_Mapping[str, SubscribeRequestFilterEntry]] = ..., commitment: _Optional[_Union[CommitmentLevel, str]] = ..., accounts_data_slice: _Optional[_Iterable[_Union[SubscribeRequestAccountsDataSlice, _Mapping]]] = ..., ping: _Optional[_Union[SubscribeRequestPing, _Mapping]] = ...) -> None: ... + +class SubscribeRequestFilterAccounts(_message.Message): + __slots__ = ("account", "owner", "filters", "nonempty_txn_signature") + ACCOUNT_FIELD_NUMBER: _ClassVar[int] + OWNER_FIELD_NUMBER: _ClassVar[int] + FILTERS_FIELD_NUMBER: _ClassVar[int] + NONEMPTY_TXN_SIGNATURE_FIELD_NUMBER: _ClassVar[int] + account: _containers.RepeatedScalarFieldContainer[str] + owner: _containers.RepeatedScalarFieldContainer[str] + filters: _containers.RepeatedCompositeFieldContainer[SubscribeRequestFilterAccountsFilter] + nonempty_txn_signature: bool + def __init__(self, account: _Optional[_Iterable[str]] = ..., owner: _Optional[_Iterable[str]] = ..., filters: _Optional[_Iterable[_Union[SubscribeRequestFilterAccountsFilter, _Mapping]]] = ..., nonempty_txn_signature: bool = ...) -> None: ... + +class SubscribeRequestFilterAccountsFilter(_message.Message): + __slots__ = ("memcmp", "datasize", "token_account_state", "lamports") + MEMCMP_FIELD_NUMBER: _ClassVar[int] + DATASIZE_FIELD_NUMBER: _ClassVar[int] + TOKEN_ACCOUNT_STATE_FIELD_NUMBER: _ClassVar[int] + LAMPORTS_FIELD_NUMBER: _ClassVar[int] + memcmp: SubscribeRequestFilterAccountsFilterMemcmp + datasize: int + token_account_state: bool + lamports: SubscribeRequestFilterAccountsFilterLamports + def __init__(self, memcmp: _Optional[_Union[SubscribeRequestFilterAccountsFilterMemcmp, _Mapping]] = ..., datasize: _Optional[int] = ..., token_account_state: bool = ..., lamports: _Optional[_Union[SubscribeRequestFilterAccountsFilterLamports, _Mapping]] = ...) -> None: ... + +class SubscribeRequestFilterAccountsFilterMemcmp(_message.Message): + __slots__ = ("offset", "bytes", "base58", "base64") + OFFSET_FIELD_NUMBER: _ClassVar[int] + BYTES_FIELD_NUMBER: _ClassVar[int] + BASE58_FIELD_NUMBER: _ClassVar[int] + BASE64_FIELD_NUMBER: _ClassVar[int] + offset: int + bytes: bytes + base58: str + base64: str + def __init__(self, offset: _Optional[int] = ..., bytes: _Optional[bytes] = ..., base58: _Optional[str] = ..., base64: _Optional[str] = ...) -> None: ... + +class SubscribeRequestFilterAccountsFilterLamports(_message.Message): + __slots__ = ("eq", "ne", "lt", "gt") + EQ_FIELD_NUMBER: _ClassVar[int] + NE_FIELD_NUMBER: _ClassVar[int] + LT_FIELD_NUMBER: _ClassVar[int] + GT_FIELD_NUMBER: _ClassVar[int] + eq: int + ne: int + lt: int + gt: int + def __init__(self, eq: _Optional[int] = ..., ne: _Optional[int] = ..., lt: _Optional[int] = ..., gt: _Optional[int] = ...) -> None: ... + +class SubscribeRequestFilterSlots(_message.Message): + __slots__ = ("filter_by_commitment",) + FILTER_BY_COMMITMENT_FIELD_NUMBER: _ClassVar[int] + filter_by_commitment: bool + def __init__(self, filter_by_commitment: bool = ...) -> None: ... + +class SubscribeRequestFilterTransactions(_message.Message): + __slots__ = ("vote", "failed", "signature", "account_include", "account_exclude", "account_required") + VOTE_FIELD_NUMBER: _ClassVar[int] + FAILED_FIELD_NUMBER: _ClassVar[int] + SIGNATURE_FIELD_NUMBER: _ClassVar[int] + ACCOUNT_INCLUDE_FIELD_NUMBER: _ClassVar[int] + ACCOUNT_EXCLUDE_FIELD_NUMBER: _ClassVar[int] + ACCOUNT_REQUIRED_FIELD_NUMBER: _ClassVar[int] + vote: bool + failed: bool + signature: str + account_include: _containers.RepeatedScalarFieldContainer[str] + account_exclude: _containers.RepeatedScalarFieldContainer[str] + account_required: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, vote: bool = ..., failed: bool = ..., signature: _Optional[str] = ..., account_include: _Optional[_Iterable[str]] = ..., account_exclude: _Optional[_Iterable[str]] = ..., account_required: _Optional[_Iterable[str]] = ...) -> None: ... + +class SubscribeRequestFilterBlocks(_message.Message): + __slots__ = ("account_include", "include_transactions", "include_accounts", "include_entries") + ACCOUNT_INCLUDE_FIELD_NUMBER: _ClassVar[int] + INCLUDE_TRANSACTIONS_FIELD_NUMBER: _ClassVar[int] + INCLUDE_ACCOUNTS_FIELD_NUMBER: _ClassVar[int] + INCLUDE_ENTRIES_FIELD_NUMBER: _ClassVar[int] + account_include: _containers.RepeatedScalarFieldContainer[str] + include_transactions: bool + include_accounts: bool + include_entries: bool + def __init__(self, account_include: _Optional[_Iterable[str]] = ..., include_transactions: bool = ..., include_accounts: bool = ..., include_entries: bool = ...) -> None: ... + +class SubscribeRequestFilterBlocksMeta(_message.Message): + __slots__ = () + def __init__(self) -> None: ... + +class SubscribeRequestFilterEntry(_message.Message): + __slots__ = () + def __init__(self) -> None: ... + +class SubscribeRequestAccountsDataSlice(_message.Message): + __slots__ = ("offset", "length") + OFFSET_FIELD_NUMBER: _ClassVar[int] + LENGTH_FIELD_NUMBER: _ClassVar[int] + offset: int + length: int + def __init__(self, offset: _Optional[int] = ..., length: _Optional[int] = ...) -> None: ... + +class SubscribeRequestPing(_message.Message): + __slots__ = ("id",) + ID_FIELD_NUMBER: _ClassVar[int] + id: int + def __init__(self, id: _Optional[int] = ...) -> None: ... + +class SubscribeUpdate(_message.Message): + __slots__ = ("filters", "account", "slot", "transaction", "transaction_status", "block", "ping", "pong", "block_meta", "entry") + FILTERS_FIELD_NUMBER: _ClassVar[int] + ACCOUNT_FIELD_NUMBER: _ClassVar[int] + SLOT_FIELD_NUMBER: _ClassVar[int] + TRANSACTION_FIELD_NUMBER: _ClassVar[int] + TRANSACTION_STATUS_FIELD_NUMBER: _ClassVar[int] + BLOCK_FIELD_NUMBER: _ClassVar[int] + PING_FIELD_NUMBER: _ClassVar[int] + PONG_FIELD_NUMBER: _ClassVar[int] + BLOCK_META_FIELD_NUMBER: _ClassVar[int] + ENTRY_FIELD_NUMBER: _ClassVar[int] + filters: _containers.RepeatedScalarFieldContainer[str] + account: SubscribeUpdateAccount + slot: SubscribeUpdateSlot + transaction: SubscribeUpdateTransaction + transaction_status: SubscribeUpdateTransactionStatus + block: SubscribeUpdateBlock + ping: SubscribeUpdatePing + pong: SubscribeUpdatePong + block_meta: SubscribeUpdateBlockMeta + entry: SubscribeUpdateEntry + def __init__(self, filters: _Optional[_Iterable[str]] = ..., account: _Optional[_Union[SubscribeUpdateAccount, _Mapping]] = ..., slot: _Optional[_Union[SubscribeUpdateSlot, _Mapping]] = ..., transaction: _Optional[_Union[SubscribeUpdateTransaction, _Mapping]] = ..., transaction_status: _Optional[_Union[SubscribeUpdateTransactionStatus, _Mapping]] = ..., block: _Optional[_Union[SubscribeUpdateBlock, _Mapping]] = ..., ping: _Optional[_Union[SubscribeUpdatePing, _Mapping]] = ..., pong: _Optional[_Union[SubscribeUpdatePong, _Mapping]] = ..., block_meta: _Optional[_Union[SubscribeUpdateBlockMeta, _Mapping]] = ..., entry: _Optional[_Union[SubscribeUpdateEntry, _Mapping]] = ...) -> None: ... + +class SubscribeUpdateAccount(_message.Message): + __slots__ = ("account", "slot", "is_startup") + ACCOUNT_FIELD_NUMBER: _ClassVar[int] + SLOT_FIELD_NUMBER: _ClassVar[int] + IS_STARTUP_FIELD_NUMBER: _ClassVar[int] + account: SubscribeUpdateAccountInfo + slot: int + is_startup: bool + def __init__(self, account: _Optional[_Union[SubscribeUpdateAccountInfo, _Mapping]] = ..., slot: _Optional[int] = ..., is_startup: bool = ...) -> None: ... + +class SubscribeUpdateAccountInfo(_message.Message): + __slots__ = ("pubkey", "lamports", "owner", "executable", "rent_epoch", "data", "write_version", "txn_signature") + PUBKEY_FIELD_NUMBER: _ClassVar[int] + LAMPORTS_FIELD_NUMBER: _ClassVar[int] + OWNER_FIELD_NUMBER: _ClassVar[int] + EXECUTABLE_FIELD_NUMBER: _ClassVar[int] + RENT_EPOCH_FIELD_NUMBER: _ClassVar[int] + DATA_FIELD_NUMBER: _ClassVar[int] + WRITE_VERSION_FIELD_NUMBER: _ClassVar[int] + TXN_SIGNATURE_FIELD_NUMBER: _ClassVar[int] + pubkey: bytes + lamports: int + owner: bytes + executable: bool + rent_epoch: int + data: bytes + write_version: int + txn_signature: bytes + def __init__(self, pubkey: _Optional[bytes] = ..., lamports: _Optional[int] = ..., owner: _Optional[bytes] = ..., executable: bool = ..., rent_epoch: _Optional[int] = ..., data: _Optional[bytes] = ..., write_version: _Optional[int] = ..., txn_signature: _Optional[bytes] = ...) -> None: ... + +class SubscribeUpdateSlot(_message.Message): + __slots__ = ("slot", "parent", "status", "dead_error") + SLOT_FIELD_NUMBER: _ClassVar[int] + PARENT_FIELD_NUMBER: _ClassVar[int] + STATUS_FIELD_NUMBER: _ClassVar[int] + DEAD_ERROR_FIELD_NUMBER: _ClassVar[int] + slot: int + parent: int + status: CommitmentLevel + dead_error: str + def __init__(self, slot: _Optional[int] = ..., parent: _Optional[int] = ..., status: _Optional[_Union[CommitmentLevel, str]] = ..., dead_error: _Optional[str] = ...) -> None: ... + +class SubscribeUpdateTransaction(_message.Message): + __slots__ = ("transaction", "slot") + TRANSACTION_FIELD_NUMBER: _ClassVar[int] + SLOT_FIELD_NUMBER: _ClassVar[int] + transaction: SubscribeUpdateTransactionInfo + slot: int + def __init__(self, transaction: _Optional[_Union[SubscribeUpdateTransactionInfo, _Mapping]] = ..., slot: _Optional[int] = ...) -> None: ... + +class SubscribeUpdateTransactionInfo(_message.Message): + __slots__ = ("signature", "is_vote", "transaction", "meta", "index") + SIGNATURE_FIELD_NUMBER: _ClassVar[int] + IS_VOTE_FIELD_NUMBER: _ClassVar[int] + TRANSACTION_FIELD_NUMBER: _ClassVar[int] + META_FIELD_NUMBER: _ClassVar[int] + INDEX_FIELD_NUMBER: _ClassVar[int] + signature: bytes + is_vote: bool + transaction: _solana_storage_pb2.Transaction + meta: _solana_storage_pb2.TransactionStatusMeta + index: int + def __init__(self, signature: _Optional[bytes] = ..., is_vote: bool = ..., transaction: _Optional[_Union[_solana_storage_pb2.Transaction, _Mapping]] = ..., meta: _Optional[_Union[_solana_storage_pb2.TransactionStatusMeta, _Mapping]] = ..., index: _Optional[int] = ...) -> None: ... + +class SubscribeUpdateTransactionStatus(_message.Message): + __slots__ = ("slot", "signature", "is_vote", "index", "err") + SLOT_FIELD_NUMBER: _ClassVar[int] + SIGNATURE_FIELD_NUMBER: _ClassVar[int] + IS_VOTE_FIELD_NUMBER: _ClassVar[int] + INDEX_FIELD_NUMBER: _ClassVar[int] + ERR_FIELD_NUMBER: _ClassVar[int] + slot: int + signature: bytes + is_vote: bool + index: int + err: _solana_storage_pb2.TransactionError + def __init__(self, slot: _Optional[int] = ..., signature: _Optional[bytes] = ..., is_vote: bool = ..., index: _Optional[int] = ..., err: _Optional[_Union[_solana_storage_pb2.TransactionError, _Mapping]] = ...) -> None: ... + +class SubscribeUpdateBlock(_message.Message): + __slots__ = ("slot", "blockhash", "rewards", "block_time", "block_height", "parent_slot", "parent_blockhash", "executed_transaction_count", "transactions", "updated_account_count", "accounts", "entries_count", "entries") + SLOT_FIELD_NUMBER: _ClassVar[int] + BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + REWARDS_FIELD_NUMBER: _ClassVar[int] + BLOCK_TIME_FIELD_NUMBER: _ClassVar[int] + BLOCK_HEIGHT_FIELD_NUMBER: _ClassVar[int] + PARENT_SLOT_FIELD_NUMBER: _ClassVar[int] + PARENT_BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + EXECUTED_TRANSACTION_COUNT_FIELD_NUMBER: _ClassVar[int] + TRANSACTIONS_FIELD_NUMBER: _ClassVar[int] + UPDATED_ACCOUNT_COUNT_FIELD_NUMBER: _ClassVar[int] + ACCOUNTS_FIELD_NUMBER: _ClassVar[int] + ENTRIES_COUNT_FIELD_NUMBER: _ClassVar[int] + ENTRIES_FIELD_NUMBER: _ClassVar[int] + slot: int + blockhash: str + rewards: _solana_storage_pb2.Rewards + block_time: _solana_storage_pb2.UnixTimestamp + block_height: _solana_storage_pb2.BlockHeight + parent_slot: int + parent_blockhash: str + executed_transaction_count: int + transactions: _containers.RepeatedCompositeFieldContainer[SubscribeUpdateTransactionInfo] + updated_account_count: int + accounts: _containers.RepeatedCompositeFieldContainer[SubscribeUpdateAccountInfo] + entries_count: int + entries: _containers.RepeatedCompositeFieldContainer[SubscribeUpdateEntry] + def __init__(self, slot: _Optional[int] = ..., blockhash: _Optional[str] = ..., rewards: _Optional[_Union[_solana_storage_pb2.Rewards, _Mapping]] = ..., block_time: _Optional[_Union[_solana_storage_pb2.UnixTimestamp, _Mapping]] = ..., block_height: _Optional[_Union[_solana_storage_pb2.BlockHeight, _Mapping]] = ..., parent_slot: _Optional[int] = ..., parent_blockhash: _Optional[str] = ..., executed_transaction_count: _Optional[int] = ..., transactions: _Optional[_Iterable[_Union[SubscribeUpdateTransactionInfo, _Mapping]]] = ..., updated_account_count: _Optional[int] = ..., accounts: _Optional[_Iterable[_Union[SubscribeUpdateAccountInfo, _Mapping]]] = ..., entries_count: _Optional[int] = ..., entries: _Optional[_Iterable[_Union[SubscribeUpdateEntry, _Mapping]]] = ...) -> None: ... + +class SubscribeUpdateBlockMeta(_message.Message): + __slots__ = ("slot", "blockhash", "rewards", "block_time", "block_height", "parent_slot", "parent_blockhash", "executed_transaction_count", "entries_count") + SLOT_FIELD_NUMBER: _ClassVar[int] + BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + REWARDS_FIELD_NUMBER: _ClassVar[int] + BLOCK_TIME_FIELD_NUMBER: _ClassVar[int] + BLOCK_HEIGHT_FIELD_NUMBER: _ClassVar[int] + PARENT_SLOT_FIELD_NUMBER: _ClassVar[int] + PARENT_BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + EXECUTED_TRANSACTION_COUNT_FIELD_NUMBER: _ClassVar[int] + ENTRIES_COUNT_FIELD_NUMBER: _ClassVar[int] + slot: int + blockhash: str + rewards: _solana_storage_pb2.Rewards + block_time: _solana_storage_pb2.UnixTimestamp + block_height: _solana_storage_pb2.BlockHeight + parent_slot: int + parent_blockhash: str + executed_transaction_count: int + entries_count: int + def __init__(self, slot: _Optional[int] = ..., blockhash: _Optional[str] = ..., rewards: _Optional[_Union[_solana_storage_pb2.Rewards, _Mapping]] = ..., block_time: _Optional[_Union[_solana_storage_pb2.UnixTimestamp, _Mapping]] = ..., block_height: _Optional[_Union[_solana_storage_pb2.BlockHeight, _Mapping]] = ..., parent_slot: _Optional[int] = ..., parent_blockhash: _Optional[str] = ..., executed_transaction_count: _Optional[int] = ..., entries_count: _Optional[int] = ...) -> None: ... + +class SubscribeUpdateEntry(_message.Message): + __slots__ = ("slot", "index", "num_hashes", "hash", "executed_transaction_count", "starting_transaction_index") + SLOT_FIELD_NUMBER: _ClassVar[int] + INDEX_FIELD_NUMBER: _ClassVar[int] + NUM_HASHES_FIELD_NUMBER: _ClassVar[int] + HASH_FIELD_NUMBER: _ClassVar[int] + EXECUTED_TRANSACTION_COUNT_FIELD_NUMBER: _ClassVar[int] + STARTING_TRANSACTION_INDEX_FIELD_NUMBER: _ClassVar[int] + slot: int + index: int + num_hashes: int + hash: bytes + executed_transaction_count: int + starting_transaction_index: int + def __init__(self, slot: _Optional[int] = ..., index: _Optional[int] = ..., num_hashes: _Optional[int] = ..., hash: _Optional[bytes] = ..., executed_transaction_count: _Optional[int] = ..., starting_transaction_index: _Optional[int] = ...) -> None: ... + +class SubscribeUpdatePing(_message.Message): + __slots__ = () + def __init__(self) -> None: ... + +class SubscribeUpdatePong(_message.Message): + __slots__ = ("id",) + ID_FIELD_NUMBER: _ClassVar[int] + id: int + def __init__(self, id: _Optional[int] = ...) -> None: ... + +class PingRequest(_message.Message): + __slots__ = ("count",) + COUNT_FIELD_NUMBER: _ClassVar[int] + count: int + def __init__(self, count: _Optional[int] = ...) -> None: ... + +class PongResponse(_message.Message): + __slots__ = ("count",) + COUNT_FIELD_NUMBER: _ClassVar[int] + count: int + def __init__(self, count: _Optional[int] = ...) -> None: ... + +class GetLatestBlockhashRequest(_message.Message): + __slots__ = ("commitment",) + COMMITMENT_FIELD_NUMBER: _ClassVar[int] + commitment: CommitmentLevel + def __init__(self, commitment: _Optional[_Union[CommitmentLevel, str]] = ...) -> None: ... + +class GetLatestBlockhashResponse(_message.Message): + __slots__ = ("slot", "blockhash", "last_valid_block_height") + SLOT_FIELD_NUMBER: _ClassVar[int] + BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + LAST_VALID_BLOCK_HEIGHT_FIELD_NUMBER: _ClassVar[int] + slot: int + blockhash: str + last_valid_block_height: int + def __init__(self, slot: _Optional[int] = ..., blockhash: _Optional[str] = ..., last_valid_block_height: _Optional[int] = ...) -> None: ... + +class GetBlockHeightRequest(_message.Message): + __slots__ = ("commitment",) + COMMITMENT_FIELD_NUMBER: _ClassVar[int] + commitment: CommitmentLevel + def __init__(self, commitment: _Optional[_Union[CommitmentLevel, str]] = ...) -> None: ... + +class GetBlockHeightResponse(_message.Message): + __slots__ = ("block_height",) + BLOCK_HEIGHT_FIELD_NUMBER: _ClassVar[int] + block_height: int + def __init__(self, block_height: _Optional[int] = ...) -> None: ... + +class GetSlotRequest(_message.Message): + __slots__ = ("commitment",) + COMMITMENT_FIELD_NUMBER: _ClassVar[int] + commitment: CommitmentLevel + def __init__(self, commitment: _Optional[_Union[CommitmentLevel, str]] = ...) -> None: ... + +class GetSlotResponse(_message.Message): + __slots__ = ("slot",) + SLOT_FIELD_NUMBER: _ClassVar[int] + slot: int + def __init__(self, slot: _Optional[int] = ...) -> None: ... + +class GetVersionRequest(_message.Message): + __slots__ = () + def __init__(self) -> None: ... + +class GetVersionResponse(_message.Message): + __slots__ = ("version",) + VERSION_FIELD_NUMBER: _ClassVar[int] + version: str + def __init__(self, version: _Optional[str] = ...) -> None: ... + +class IsBlockhashValidRequest(_message.Message): + __slots__ = ("blockhash", "commitment") + BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + COMMITMENT_FIELD_NUMBER: _ClassVar[int] + blockhash: str + commitment: CommitmentLevel + def __init__(self, blockhash: _Optional[str] = ..., commitment: _Optional[_Union[CommitmentLevel, str]] = ...) -> None: ... + +class IsBlockhashValidResponse(_message.Message): + __slots__ = ("slot", "valid") + SLOT_FIELD_NUMBER: _ClassVar[int] + VALID_FIELD_NUMBER: _ClassVar[int] + slot: int + valid: bool + def __init__(self, slot: _Optional[int] = ..., valid: bool = ...) -> None: ... diff --git a/src/geyser/generated/geyser_pb2_grpc.py b/src/geyser/generated/geyser_pb2_grpc.py new file mode 100644 index 0000000..84fcd5e --- /dev/null +++ b/src/geyser/generated/geyser_pb2_grpc.py @@ -0,0 +1,355 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" + +import grpc + +import geyser.generated.geyser_pb2 as geyser__pb2 + +GRPC_GENERATED_VERSION = '1.71.0' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + ' but the generated code in geyser_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) + + +class GeyserStub: + """Missing associated documentation comment in .proto file.""" + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.Subscribe = channel.stream_stream( + '/geyser.Geyser/Subscribe', + request_serializer=geyser__pb2.SubscribeRequest.SerializeToString, + response_deserializer=geyser__pb2.SubscribeUpdate.FromString, + _registered_method=True) + self.Ping = channel.unary_unary( + '/geyser.Geyser/Ping', + request_serializer=geyser__pb2.PingRequest.SerializeToString, + response_deserializer=geyser__pb2.PongResponse.FromString, + _registered_method=True) + self.GetLatestBlockhash = channel.unary_unary( + '/geyser.Geyser/GetLatestBlockhash', + request_serializer=geyser__pb2.GetLatestBlockhashRequest.SerializeToString, + response_deserializer=geyser__pb2.GetLatestBlockhashResponse.FromString, + _registered_method=True) + self.GetBlockHeight = channel.unary_unary( + '/geyser.Geyser/GetBlockHeight', + request_serializer=geyser__pb2.GetBlockHeightRequest.SerializeToString, + response_deserializer=geyser__pb2.GetBlockHeightResponse.FromString, + _registered_method=True) + self.GetSlot = channel.unary_unary( + '/geyser.Geyser/GetSlot', + request_serializer=geyser__pb2.GetSlotRequest.SerializeToString, + response_deserializer=geyser__pb2.GetSlotResponse.FromString, + _registered_method=True) + self.IsBlockhashValid = channel.unary_unary( + '/geyser.Geyser/IsBlockhashValid', + request_serializer=geyser__pb2.IsBlockhashValidRequest.SerializeToString, + response_deserializer=geyser__pb2.IsBlockhashValidResponse.FromString, + _registered_method=True) + self.GetVersion = channel.unary_unary( + '/geyser.Geyser/GetVersion', + request_serializer=geyser__pb2.GetVersionRequest.SerializeToString, + response_deserializer=geyser__pb2.GetVersionResponse.FromString, + _registered_method=True) + + +class GeyserServicer: + """Missing associated documentation comment in .proto file.""" + + def Subscribe(self, request_iterator, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Ping(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetLatestBlockhash(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetBlockHeight(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetSlot(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def IsBlockhashValid(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def GetVersion(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_GeyserServicer_to_server(servicer, server): + rpc_method_handlers = { + 'Subscribe': grpc.stream_stream_rpc_method_handler( + servicer.Subscribe, + request_deserializer=geyser__pb2.SubscribeRequest.FromString, + response_serializer=geyser__pb2.SubscribeUpdate.SerializeToString, + ), + 'Ping': grpc.unary_unary_rpc_method_handler( + servicer.Ping, + request_deserializer=geyser__pb2.PingRequest.FromString, + response_serializer=geyser__pb2.PongResponse.SerializeToString, + ), + 'GetLatestBlockhash': grpc.unary_unary_rpc_method_handler( + servicer.GetLatestBlockhash, + request_deserializer=geyser__pb2.GetLatestBlockhashRequest.FromString, + response_serializer=geyser__pb2.GetLatestBlockhashResponse.SerializeToString, + ), + 'GetBlockHeight': grpc.unary_unary_rpc_method_handler( + servicer.GetBlockHeight, + request_deserializer=geyser__pb2.GetBlockHeightRequest.FromString, + response_serializer=geyser__pb2.GetBlockHeightResponse.SerializeToString, + ), + 'GetSlot': grpc.unary_unary_rpc_method_handler( + servicer.GetSlot, + request_deserializer=geyser__pb2.GetSlotRequest.FromString, + response_serializer=geyser__pb2.GetSlotResponse.SerializeToString, + ), + 'IsBlockhashValid': grpc.unary_unary_rpc_method_handler( + servicer.IsBlockhashValid, + request_deserializer=geyser__pb2.IsBlockhashValidRequest.FromString, + response_serializer=geyser__pb2.IsBlockhashValidResponse.SerializeToString, + ), + 'GetVersion': grpc.unary_unary_rpc_method_handler( + servicer.GetVersion, + request_deserializer=geyser__pb2.GetVersionRequest.FromString, + response_serializer=geyser__pb2.GetVersionResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'geyser.Geyser', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('geyser.Geyser', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class Geyser: + """Missing associated documentation comment in .proto file.""" + + @staticmethod + def Subscribe(request_iterator, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.stream_stream( + request_iterator, + target, + '/geyser.Geyser/Subscribe', + geyser__pb2.SubscribeRequest.SerializeToString, + geyser__pb2.SubscribeUpdate.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def Ping(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/geyser.Geyser/Ping', + geyser__pb2.PingRequest.SerializeToString, + geyser__pb2.PongResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetLatestBlockhash(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/geyser.Geyser/GetLatestBlockhash', + geyser__pb2.GetLatestBlockhashRequest.SerializeToString, + geyser__pb2.GetLatestBlockhashResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetBlockHeight(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/geyser.Geyser/GetBlockHeight', + geyser__pb2.GetBlockHeightRequest.SerializeToString, + geyser__pb2.GetBlockHeightResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetSlot(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/geyser.Geyser/GetSlot', + geyser__pb2.GetSlotRequest.SerializeToString, + geyser__pb2.GetSlotResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def IsBlockhashValid(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/geyser.Geyser/IsBlockhashValid', + geyser__pb2.IsBlockhashValidRequest.SerializeToString, + geyser__pb2.IsBlockhashValidResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + + @staticmethod + def GetVersion(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/geyser.Geyser/GetVersion', + geyser__pb2.GetVersionRequest.SerializeToString, + geyser__pb2.GetVersionResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) diff --git a/src/geyser/generated/solana_storage_pb2.py b/src/geyser/generated/solana_storage_pb2.py new file mode 100644 index 0000000..7458363 --- /dev/null +++ b/src/geyser/generated/solana_storage_pb2.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: solana-storage.proto +# Protobuf Python Version: 5.29.0 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 29, + 0, + '', + 'solana-storage.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14solana-storage.proto\x12\x1dsolana.storage.ConfirmedBlock\"\xa1\x03\n\x0e\x43onfirmedBlock\x12\x1a\n\x12previous_blockhash\x18\x01 \x01(\t\x12\x11\n\tblockhash\x18\x02 \x01(\t\x12\x13\n\x0bparent_slot\x18\x03 \x01(\x04\x12I\n\x0ctransactions\x18\x04 \x03(\x0b\x32\x33.solana.storage.ConfirmedBlock.ConfirmedTransaction\x12\x36\n\x07rewards\x18\x05 \x03(\x0b\x32%.solana.storage.ConfirmedBlock.Reward\x12@\n\nblock_time\x18\x06 \x01(\x0b\x32,.solana.storage.ConfirmedBlock.UnixTimestamp\x12@\n\x0c\x62lock_height\x18\x07 \x01(\x0b\x32*.solana.storage.ConfirmedBlock.BlockHeight\x12\x44\n\x0enum_partitions\x18\x08 \x01(\x0b\x32,.solana.storage.ConfirmedBlock.NumPartitions\"\x9b\x01\n\x14\x43onfirmedTransaction\x12?\n\x0btransaction\x18\x01 \x01(\x0b\x32*.solana.storage.ConfirmedBlock.Transaction\x12\x42\n\x04meta\x18\x02 \x01(\x0b\x32\x34.solana.storage.ConfirmedBlock.TransactionStatusMeta\"Z\n\x0bTransaction\x12\x12\n\nsignatures\x18\x01 \x03(\x0c\x12\x37\n\x07message\x18\x02 \x01(\x0b\x32&.solana.storage.ConfirmedBlock.Message\"\xad\x02\n\x07Message\x12<\n\x06header\x18\x01 \x01(\x0b\x32,.solana.storage.ConfirmedBlock.MessageHeader\x12\x14\n\x0c\x61\x63\x63ount_keys\x18\x02 \x03(\x0c\x12\x18\n\x10recent_blockhash\x18\x03 \x01(\x0c\x12H\n\x0cinstructions\x18\x04 \x03(\x0b\x32\x32.solana.storage.ConfirmedBlock.CompiledInstruction\x12\x11\n\tversioned\x18\x05 \x01(\x08\x12W\n\x15\x61\x64\x64ress_table_lookups\x18\x06 \x03(\x0b\x32\x38.solana.storage.ConfirmedBlock.MessageAddressTableLookup\"~\n\rMessageHeader\x12\x1f\n\x17num_required_signatures\x18\x01 \x01(\r\x12$\n\x1cnum_readonly_signed_accounts\x18\x02 \x01(\r\x12&\n\x1enum_readonly_unsigned_accounts\x18\x03 \x01(\r\"d\n\x19MessageAddressTableLookup\x12\x13\n\x0b\x61\x63\x63ount_key\x18\x01 \x01(\x0c\x12\x18\n\x10writable_indexes\x18\x02 \x01(\x0c\x12\x18\n\x10readonly_indexes\x18\x03 \x01(\x0c\"\xda\x05\n\x15TransactionStatusMeta\x12<\n\x03\x65rr\x18\x01 \x01(\x0b\x32/.solana.storage.ConfirmedBlock.TransactionError\x12\x0b\n\x03\x66\x65\x65\x18\x02 \x01(\x04\x12\x14\n\x0cpre_balances\x18\x03 \x03(\x04\x12\x15\n\rpost_balances\x18\x04 \x03(\x04\x12L\n\x12inner_instructions\x18\x05 \x03(\x0b\x32\x30.solana.storage.ConfirmedBlock.InnerInstructions\x12\x1f\n\x17inner_instructions_none\x18\n \x01(\x08\x12\x14\n\x0clog_messages\x18\x06 \x03(\t\x12\x19\n\x11log_messages_none\x18\x0b \x01(\x08\x12G\n\x12pre_token_balances\x18\x07 \x03(\x0b\x32+.solana.storage.ConfirmedBlock.TokenBalance\x12H\n\x13post_token_balances\x18\x08 \x03(\x0b\x32+.solana.storage.ConfirmedBlock.TokenBalance\x12\x36\n\x07rewards\x18\t \x03(\x0b\x32%.solana.storage.ConfirmedBlock.Reward\x12!\n\x19loaded_writable_addresses\x18\x0c \x03(\x0c\x12!\n\x19loaded_readonly_addresses\x18\r \x03(\x0c\x12>\n\x0breturn_data\x18\x0e \x01(\x0b\x32).solana.storage.ConfirmedBlock.ReturnData\x12\x18\n\x10return_data_none\x18\x0f \x01(\x08\x12#\n\x16\x63ompute_units_consumed\x18\x10 \x01(\x04H\x00\x88\x01\x01\x42\x19\n\x17_compute_units_consumed\"\x1f\n\x10TransactionError\x12\x0b\n\x03\x65rr\x18\x01 \x01(\x0c\"i\n\x11InnerInstructions\x12\r\n\x05index\x18\x01 \x01(\r\x12\x45\n\x0cinstructions\x18\x02 \x03(\x0b\x32/.solana.storage.ConfirmedBlock.InnerInstruction\"x\n\x10InnerInstruction\x12\x18\n\x10program_id_index\x18\x01 \x01(\r\x12\x10\n\x08\x61\x63\x63ounts\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\x12\x19\n\x0cstack_height\x18\x04 \x01(\rH\x00\x88\x01\x01\x42\x0f\n\r_stack_height\"O\n\x13\x43ompiledInstruction\x12\x18\n\x10program_id_index\x18\x01 \x01(\r\x12\x10\n\x08\x61\x63\x63ounts\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\x9d\x01\n\x0cTokenBalance\x12\x15\n\raccount_index\x18\x01 \x01(\r\x12\x0c\n\x04mint\x18\x02 \x01(\t\x12\x45\n\x0fui_token_amount\x18\x03 \x01(\x0b\x32,.solana.storage.ConfirmedBlock.UiTokenAmount\x12\r\n\x05owner\x18\x04 \x01(\t\x12\x12\n\nprogram_id\x18\x05 \x01(\t\"^\n\rUiTokenAmount\x12\x11\n\tui_amount\x18\x01 \x01(\x01\x12\x10\n\x08\x64\x65\x63imals\x18\x02 \x01(\r\x12\x0e\n\x06\x61mount\x18\x03 \x01(\t\x12\x18\n\x10ui_amount_string\x18\x04 \x01(\t\".\n\nReturnData\x12\x12\n\nprogram_id\x18\x01 \x01(\x0c\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c\"\x94\x01\n\x06Reward\x12\x0e\n\x06pubkey\x18\x01 \x01(\t\x12\x10\n\x08lamports\x18\x02 \x01(\x03\x12\x14\n\x0cpost_balance\x18\x03 \x01(\x04\x12>\n\x0breward_type\x18\x04 \x01(\x0e\x32).solana.storage.ConfirmedBlock.RewardType\x12\x12\n\ncommission\x18\x05 \x01(\t\"\x87\x01\n\x07Rewards\x12\x36\n\x07rewards\x18\x01 \x03(\x0b\x32%.solana.storage.ConfirmedBlock.Reward\x12\x44\n\x0enum_partitions\x18\x02 \x01(\x0b\x32,.solana.storage.ConfirmedBlock.NumPartitions\"\"\n\rUnixTimestamp\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\"#\n\x0b\x42lockHeight\x12\x14\n\x0c\x62lock_height\x18\x01 \x01(\x04\"\'\n\rNumPartitions\x12\x16\n\x0enum_partitions\x18\x01 \x01(\x04*I\n\nRewardType\x12\x0f\n\x0bUnspecified\x10\x00\x12\x07\n\x03\x46\x65\x65\x10\x01\x12\x08\n\x04Rent\x10\x02\x12\x0b\n\x07Staking\x10\x03\x12\n\n\x06Voting\x10\x04\x42;Z9github.com/rpcpool/yellowstone-grpc/examples/golang/protob\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'solana_storage_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'Z9github.com/rpcpool/yellowstone-grpc/examples/golang/proto' + _globals['_REWARDTYPE']._serialized_start=3042 + _globals['_REWARDTYPE']._serialized_end=3115 + _globals['_CONFIRMEDBLOCK']._serialized_start=56 + _globals['_CONFIRMEDBLOCK']._serialized_end=473 + _globals['_CONFIRMEDTRANSACTION']._serialized_start=476 + _globals['_CONFIRMEDTRANSACTION']._serialized_end=631 + _globals['_TRANSACTION']._serialized_start=633 + _globals['_TRANSACTION']._serialized_end=723 + _globals['_MESSAGE']._serialized_start=726 + _globals['_MESSAGE']._serialized_end=1027 + _globals['_MESSAGEHEADER']._serialized_start=1029 + _globals['_MESSAGEHEADER']._serialized_end=1155 + _globals['_MESSAGEADDRESSTABLELOOKUP']._serialized_start=1157 + _globals['_MESSAGEADDRESSTABLELOOKUP']._serialized_end=1257 + _globals['_TRANSACTIONSTATUSMETA']._serialized_start=1260 + _globals['_TRANSACTIONSTATUSMETA']._serialized_end=1990 + _globals['_TRANSACTIONERROR']._serialized_start=1992 + _globals['_TRANSACTIONERROR']._serialized_end=2023 + _globals['_INNERINSTRUCTIONS']._serialized_start=2025 + _globals['_INNERINSTRUCTIONS']._serialized_end=2130 + _globals['_INNERINSTRUCTION']._serialized_start=2132 + _globals['_INNERINSTRUCTION']._serialized_end=2252 + _globals['_COMPILEDINSTRUCTION']._serialized_start=2254 + _globals['_COMPILEDINSTRUCTION']._serialized_end=2333 + _globals['_TOKENBALANCE']._serialized_start=2336 + _globals['_TOKENBALANCE']._serialized_end=2493 + _globals['_UITOKENAMOUNT']._serialized_start=2495 + _globals['_UITOKENAMOUNT']._serialized_end=2589 + _globals['_RETURNDATA']._serialized_start=2591 + _globals['_RETURNDATA']._serialized_end=2637 + _globals['_REWARD']._serialized_start=2640 + _globals['_REWARD']._serialized_end=2788 + _globals['_REWARDS']._serialized_start=2791 + _globals['_REWARDS']._serialized_end=2926 + _globals['_UNIXTIMESTAMP']._serialized_start=2928 + _globals['_UNIXTIMESTAMP']._serialized_end=2962 + _globals['_BLOCKHEIGHT']._serialized_start=2964 + _globals['_BLOCKHEIGHT']._serialized_end=2999 + _globals['_NUMPARTITIONS']._serialized_start=3001 + _globals['_NUMPARTITIONS']._serialized_end=3040 +# @@protoc_insertion_point(module_scope) diff --git a/src/geyser/generated/solana_storage_pb2.pyi b/src/geyser/generated/solana_storage_pb2.pyi new file mode 100644 index 0000000..10312a6 --- /dev/null +++ b/src/geyser/generated/solana_storage_pb2.pyi @@ -0,0 +1,238 @@ +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class RewardType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + Unspecified: _ClassVar[RewardType] + Fee: _ClassVar[RewardType] + Rent: _ClassVar[RewardType] + Staking: _ClassVar[RewardType] + Voting: _ClassVar[RewardType] +Unspecified: RewardType +Fee: RewardType +Rent: RewardType +Staking: RewardType +Voting: RewardType + +class ConfirmedBlock(_message.Message): + __slots__ = ("previous_blockhash", "blockhash", "parent_slot", "transactions", "rewards", "block_time", "block_height", "num_partitions") + PREVIOUS_BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + PARENT_SLOT_FIELD_NUMBER: _ClassVar[int] + TRANSACTIONS_FIELD_NUMBER: _ClassVar[int] + REWARDS_FIELD_NUMBER: _ClassVar[int] + BLOCK_TIME_FIELD_NUMBER: _ClassVar[int] + BLOCK_HEIGHT_FIELD_NUMBER: _ClassVar[int] + NUM_PARTITIONS_FIELD_NUMBER: _ClassVar[int] + previous_blockhash: str + blockhash: str + parent_slot: int + transactions: _containers.RepeatedCompositeFieldContainer[ConfirmedTransaction] + rewards: _containers.RepeatedCompositeFieldContainer[Reward] + block_time: UnixTimestamp + block_height: BlockHeight + num_partitions: NumPartitions + def __init__(self, previous_blockhash: _Optional[str] = ..., blockhash: _Optional[str] = ..., parent_slot: _Optional[int] = ..., transactions: _Optional[_Iterable[_Union[ConfirmedTransaction, _Mapping]]] = ..., rewards: _Optional[_Iterable[_Union[Reward, _Mapping]]] = ..., block_time: _Optional[_Union[UnixTimestamp, _Mapping]] = ..., block_height: _Optional[_Union[BlockHeight, _Mapping]] = ..., num_partitions: _Optional[_Union[NumPartitions, _Mapping]] = ...) -> None: ... + +class ConfirmedTransaction(_message.Message): + __slots__ = ("transaction", "meta") + TRANSACTION_FIELD_NUMBER: _ClassVar[int] + META_FIELD_NUMBER: _ClassVar[int] + transaction: Transaction + meta: TransactionStatusMeta + def __init__(self, transaction: _Optional[_Union[Transaction, _Mapping]] = ..., meta: _Optional[_Union[TransactionStatusMeta, _Mapping]] = ...) -> None: ... + +class Transaction(_message.Message): + __slots__ = ("signatures", "message") + SIGNATURES_FIELD_NUMBER: _ClassVar[int] + MESSAGE_FIELD_NUMBER: _ClassVar[int] + signatures: _containers.RepeatedScalarFieldContainer[bytes] + message: Message + def __init__(self, signatures: _Optional[_Iterable[bytes]] = ..., message: _Optional[_Union[Message, _Mapping]] = ...) -> None: ... + +class Message(_message.Message): + __slots__ = ("header", "account_keys", "recent_blockhash", "instructions", "versioned", "address_table_lookups") + HEADER_FIELD_NUMBER: _ClassVar[int] + ACCOUNT_KEYS_FIELD_NUMBER: _ClassVar[int] + RECENT_BLOCKHASH_FIELD_NUMBER: _ClassVar[int] + INSTRUCTIONS_FIELD_NUMBER: _ClassVar[int] + VERSIONED_FIELD_NUMBER: _ClassVar[int] + ADDRESS_TABLE_LOOKUPS_FIELD_NUMBER: _ClassVar[int] + header: MessageHeader + account_keys: _containers.RepeatedScalarFieldContainer[bytes] + recent_blockhash: bytes + instructions: _containers.RepeatedCompositeFieldContainer[CompiledInstruction] + versioned: bool + address_table_lookups: _containers.RepeatedCompositeFieldContainer[MessageAddressTableLookup] + def __init__(self, header: _Optional[_Union[MessageHeader, _Mapping]] = ..., account_keys: _Optional[_Iterable[bytes]] = ..., recent_blockhash: _Optional[bytes] = ..., instructions: _Optional[_Iterable[_Union[CompiledInstruction, _Mapping]]] = ..., versioned: bool = ..., address_table_lookups: _Optional[_Iterable[_Union[MessageAddressTableLookup, _Mapping]]] = ...) -> None: ... + +class MessageHeader(_message.Message): + __slots__ = ("num_required_signatures", "num_readonly_signed_accounts", "num_readonly_unsigned_accounts") + NUM_REQUIRED_SIGNATURES_FIELD_NUMBER: _ClassVar[int] + NUM_READONLY_SIGNED_ACCOUNTS_FIELD_NUMBER: _ClassVar[int] + NUM_READONLY_UNSIGNED_ACCOUNTS_FIELD_NUMBER: _ClassVar[int] + num_required_signatures: int + num_readonly_signed_accounts: int + num_readonly_unsigned_accounts: int + def __init__(self, num_required_signatures: _Optional[int] = ..., num_readonly_signed_accounts: _Optional[int] = ..., num_readonly_unsigned_accounts: _Optional[int] = ...) -> None: ... + +class MessageAddressTableLookup(_message.Message): + __slots__ = ("account_key", "writable_indexes", "readonly_indexes") + ACCOUNT_KEY_FIELD_NUMBER: _ClassVar[int] + WRITABLE_INDEXES_FIELD_NUMBER: _ClassVar[int] + READONLY_INDEXES_FIELD_NUMBER: _ClassVar[int] + account_key: bytes + writable_indexes: bytes + readonly_indexes: bytes + def __init__(self, account_key: _Optional[bytes] = ..., writable_indexes: _Optional[bytes] = ..., readonly_indexes: _Optional[bytes] = ...) -> None: ... + +class TransactionStatusMeta(_message.Message): + __slots__ = ("err", "fee", "pre_balances", "post_balances", "inner_instructions", "inner_instructions_none", "log_messages", "log_messages_none", "pre_token_balances", "post_token_balances", "rewards", "loaded_writable_addresses", "loaded_readonly_addresses", "return_data", "return_data_none", "compute_units_consumed") + ERR_FIELD_NUMBER: _ClassVar[int] + FEE_FIELD_NUMBER: _ClassVar[int] + PRE_BALANCES_FIELD_NUMBER: _ClassVar[int] + POST_BALANCES_FIELD_NUMBER: _ClassVar[int] + INNER_INSTRUCTIONS_FIELD_NUMBER: _ClassVar[int] + INNER_INSTRUCTIONS_NONE_FIELD_NUMBER: _ClassVar[int] + LOG_MESSAGES_FIELD_NUMBER: _ClassVar[int] + LOG_MESSAGES_NONE_FIELD_NUMBER: _ClassVar[int] + PRE_TOKEN_BALANCES_FIELD_NUMBER: _ClassVar[int] + POST_TOKEN_BALANCES_FIELD_NUMBER: _ClassVar[int] + REWARDS_FIELD_NUMBER: _ClassVar[int] + LOADED_WRITABLE_ADDRESSES_FIELD_NUMBER: _ClassVar[int] + LOADED_READONLY_ADDRESSES_FIELD_NUMBER: _ClassVar[int] + RETURN_DATA_FIELD_NUMBER: _ClassVar[int] + RETURN_DATA_NONE_FIELD_NUMBER: _ClassVar[int] + COMPUTE_UNITS_CONSUMED_FIELD_NUMBER: _ClassVar[int] + err: TransactionError + fee: int + pre_balances: _containers.RepeatedScalarFieldContainer[int] + post_balances: _containers.RepeatedScalarFieldContainer[int] + inner_instructions: _containers.RepeatedCompositeFieldContainer[InnerInstructions] + inner_instructions_none: bool + log_messages: _containers.RepeatedScalarFieldContainer[str] + log_messages_none: bool + pre_token_balances: _containers.RepeatedCompositeFieldContainer[TokenBalance] + post_token_balances: _containers.RepeatedCompositeFieldContainer[TokenBalance] + rewards: _containers.RepeatedCompositeFieldContainer[Reward] + loaded_writable_addresses: _containers.RepeatedScalarFieldContainer[bytes] + loaded_readonly_addresses: _containers.RepeatedScalarFieldContainer[bytes] + return_data: ReturnData + return_data_none: bool + compute_units_consumed: int + def __init__(self, err: _Optional[_Union[TransactionError, _Mapping]] = ..., fee: _Optional[int] = ..., pre_balances: _Optional[_Iterable[int]] = ..., post_balances: _Optional[_Iterable[int]] = ..., inner_instructions: _Optional[_Iterable[_Union[InnerInstructions, _Mapping]]] = ..., inner_instructions_none: bool = ..., log_messages: _Optional[_Iterable[str]] = ..., log_messages_none: bool = ..., pre_token_balances: _Optional[_Iterable[_Union[TokenBalance, _Mapping]]] = ..., post_token_balances: _Optional[_Iterable[_Union[TokenBalance, _Mapping]]] = ..., rewards: _Optional[_Iterable[_Union[Reward, _Mapping]]] = ..., loaded_writable_addresses: _Optional[_Iterable[bytes]] = ..., loaded_readonly_addresses: _Optional[_Iterable[bytes]] = ..., return_data: _Optional[_Union[ReturnData, _Mapping]] = ..., return_data_none: bool = ..., compute_units_consumed: _Optional[int] = ...) -> None: ... + +class TransactionError(_message.Message): + __slots__ = ("err",) + ERR_FIELD_NUMBER: _ClassVar[int] + err: bytes + def __init__(self, err: _Optional[bytes] = ...) -> None: ... + +class InnerInstructions(_message.Message): + __slots__ = ("index", "instructions") + INDEX_FIELD_NUMBER: _ClassVar[int] + INSTRUCTIONS_FIELD_NUMBER: _ClassVar[int] + index: int + instructions: _containers.RepeatedCompositeFieldContainer[InnerInstruction] + def __init__(self, index: _Optional[int] = ..., instructions: _Optional[_Iterable[_Union[InnerInstruction, _Mapping]]] = ...) -> None: ... + +class InnerInstruction(_message.Message): + __slots__ = ("program_id_index", "accounts", "data", "stack_height") + PROGRAM_ID_INDEX_FIELD_NUMBER: _ClassVar[int] + ACCOUNTS_FIELD_NUMBER: _ClassVar[int] + DATA_FIELD_NUMBER: _ClassVar[int] + STACK_HEIGHT_FIELD_NUMBER: _ClassVar[int] + program_id_index: int + accounts: bytes + data: bytes + stack_height: int + def __init__(self, program_id_index: _Optional[int] = ..., accounts: _Optional[bytes] = ..., data: _Optional[bytes] = ..., stack_height: _Optional[int] = ...) -> None: ... + +class CompiledInstruction(_message.Message): + __slots__ = ("program_id_index", "accounts", "data") + PROGRAM_ID_INDEX_FIELD_NUMBER: _ClassVar[int] + ACCOUNTS_FIELD_NUMBER: _ClassVar[int] + DATA_FIELD_NUMBER: _ClassVar[int] + program_id_index: int + accounts: bytes + data: bytes + def __init__(self, program_id_index: _Optional[int] = ..., accounts: _Optional[bytes] = ..., data: _Optional[bytes] = ...) -> None: ... + +class TokenBalance(_message.Message): + __slots__ = ("account_index", "mint", "ui_token_amount", "owner", "program_id") + ACCOUNT_INDEX_FIELD_NUMBER: _ClassVar[int] + MINT_FIELD_NUMBER: _ClassVar[int] + UI_TOKEN_AMOUNT_FIELD_NUMBER: _ClassVar[int] + OWNER_FIELD_NUMBER: _ClassVar[int] + PROGRAM_ID_FIELD_NUMBER: _ClassVar[int] + account_index: int + mint: str + ui_token_amount: UiTokenAmount + owner: str + program_id: str + def __init__(self, account_index: _Optional[int] = ..., mint: _Optional[str] = ..., ui_token_amount: _Optional[_Union[UiTokenAmount, _Mapping]] = ..., owner: _Optional[str] = ..., program_id: _Optional[str] = ...) -> None: ... + +class UiTokenAmount(_message.Message): + __slots__ = ("ui_amount", "decimals", "amount", "ui_amount_string") + UI_AMOUNT_FIELD_NUMBER: _ClassVar[int] + DECIMALS_FIELD_NUMBER: _ClassVar[int] + AMOUNT_FIELD_NUMBER: _ClassVar[int] + UI_AMOUNT_STRING_FIELD_NUMBER: _ClassVar[int] + ui_amount: float + decimals: int + amount: str + ui_amount_string: str + def __init__(self, ui_amount: _Optional[float] = ..., decimals: _Optional[int] = ..., amount: _Optional[str] = ..., ui_amount_string: _Optional[str] = ...) -> None: ... + +class ReturnData(_message.Message): + __slots__ = ("program_id", "data") + PROGRAM_ID_FIELD_NUMBER: _ClassVar[int] + DATA_FIELD_NUMBER: _ClassVar[int] + program_id: bytes + data: bytes + def __init__(self, program_id: _Optional[bytes] = ..., data: _Optional[bytes] = ...) -> None: ... + +class Reward(_message.Message): + __slots__ = ("pubkey", "lamports", "post_balance", "reward_type", "commission") + PUBKEY_FIELD_NUMBER: _ClassVar[int] + LAMPORTS_FIELD_NUMBER: _ClassVar[int] + POST_BALANCE_FIELD_NUMBER: _ClassVar[int] + REWARD_TYPE_FIELD_NUMBER: _ClassVar[int] + COMMISSION_FIELD_NUMBER: _ClassVar[int] + pubkey: str + lamports: int + post_balance: int + reward_type: RewardType + commission: str + def __init__(self, pubkey: _Optional[str] = ..., lamports: _Optional[int] = ..., post_balance: _Optional[int] = ..., reward_type: _Optional[_Union[RewardType, str]] = ..., commission: _Optional[str] = ...) -> None: ... + +class Rewards(_message.Message): + __slots__ = ("rewards", "num_partitions") + REWARDS_FIELD_NUMBER: _ClassVar[int] + NUM_PARTITIONS_FIELD_NUMBER: _ClassVar[int] + rewards: _containers.RepeatedCompositeFieldContainer[Reward] + num_partitions: NumPartitions + def __init__(self, rewards: _Optional[_Iterable[_Union[Reward, _Mapping]]] = ..., num_partitions: _Optional[_Union[NumPartitions, _Mapping]] = ...) -> None: ... + +class UnixTimestamp(_message.Message): + __slots__ = ("timestamp",) + TIMESTAMP_FIELD_NUMBER: _ClassVar[int] + timestamp: int + def __init__(self, timestamp: _Optional[int] = ...) -> None: ... + +class BlockHeight(_message.Message): + __slots__ = ("block_height",) + BLOCK_HEIGHT_FIELD_NUMBER: _ClassVar[int] + block_height: int + def __init__(self, block_height: _Optional[int] = ...) -> None: ... + +class NumPartitions(_message.Message): + __slots__ = ("num_partitions",) + NUM_PARTITIONS_FIELD_NUMBER: _ClassVar[int] + num_partitions: int + def __init__(self, num_partitions: _Optional[int] = ...) -> None: ... diff --git a/src/geyser/generated/solana_storage_pb2_grpc.py b/src/geyser/generated/solana_storage_pb2_grpc.py new file mode 100644 index 0000000..1544a78 --- /dev/null +++ b/src/geyser/generated/solana_storage_pb2_grpc.py @@ -0,0 +1,24 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + + +GRPC_GENERATED_VERSION = '1.71.0' +GRPC_VERSION = grpc.__version__ +_version_not_supported = False + +try: + from grpc._utilities import first_version_is_lower + _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) +except ImportError: + _version_not_supported = True + +if _version_not_supported: + raise RuntimeError( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in solana_storage_pb2_grpc.py depends on' + + f' grpcio>={GRPC_GENERATED_VERSION}.' + + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' + + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' + ) diff --git a/src/geyser/proto/geyser.proto b/src/geyser/proto/geyser.proto new file mode 100644 index 0000000..a6f0421 --- /dev/null +++ b/src/geyser/proto/geyser.proto @@ -0,0 +1,262 @@ +syntax = "proto3"; + +import public "solana-storage.proto"; + +option go_package = "github.com/rpcpool/yellowstone-grpc/examples/golang/proto"; + +package geyser; + +service Geyser { + rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeUpdate) {} + rpc Ping(PingRequest) returns (PongResponse) {} + rpc GetLatestBlockhash(GetLatestBlockhashRequest) returns (GetLatestBlockhashResponse) {} + rpc GetBlockHeight(GetBlockHeightRequest) returns (GetBlockHeightResponse) {} + rpc GetSlot(GetSlotRequest) returns (GetSlotResponse) {} + rpc IsBlockhashValid(IsBlockhashValidRequest) returns (IsBlockhashValidResponse) {} + rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) {} +} + +enum CommitmentLevel { + PROCESSED = 0; + CONFIRMED = 1; + FINALIZED = 2; + FIRST_SHRED_RECEIVED = 3; + COMPLETED = 4; + CREATED_BANK = 5; + DEAD = 6; +} + +message SubscribeRequest { + map accounts = 1; + map slots = 2; + map transactions = 3; + map transactions_status = 10; + map blocks = 4; + map blocks_meta = 5; + map entry = 8; + optional CommitmentLevel commitment = 6; + repeated SubscribeRequestAccountsDataSlice accounts_data_slice = 7; + optional SubscribeRequestPing ping = 9; +} + +message SubscribeRequestFilterAccounts { + repeated string account = 2; + repeated string owner = 3; + repeated SubscribeRequestFilterAccountsFilter filters = 4; + optional bool nonempty_txn_signature = 5; +} + +message SubscribeRequestFilterAccountsFilter { + oneof filter { + SubscribeRequestFilterAccountsFilterMemcmp memcmp = 1; + uint64 datasize = 2; + bool token_account_state = 3; + SubscribeRequestFilterAccountsFilterLamports lamports = 4; + } +} + +message SubscribeRequestFilterAccountsFilterMemcmp { + uint64 offset = 1; + oneof data { + bytes bytes = 2; + string base58 = 3; + string base64 = 4; + } +} + +message SubscribeRequestFilterAccountsFilterLamports { + oneof cmp { + uint64 eq = 1; + uint64 ne = 2; + uint64 lt = 3; + uint64 gt = 4; + } +} + +message SubscribeRequestFilterSlots { + optional bool filter_by_commitment = 1; +} + +message SubscribeRequestFilterTransactions { + optional bool vote = 1; + optional bool failed = 2; + optional string signature = 5; + repeated string account_include = 3; + repeated string account_exclude = 4; + repeated string account_required = 6; +} + +message SubscribeRequestFilterBlocks { + repeated string account_include = 1; + optional bool include_transactions = 2; + optional bool include_accounts = 3; + optional bool include_entries = 4; +} + +message SubscribeRequestFilterBlocksMeta {} + +message SubscribeRequestFilterEntry {} + +message SubscribeRequestAccountsDataSlice { + uint64 offset = 1; + uint64 length = 2; +} + +message SubscribeRequestPing { + int32 id = 1; +} + +message SubscribeUpdate { + repeated string filters = 1; + oneof update_oneof { + SubscribeUpdateAccount account = 2; + SubscribeUpdateSlot slot = 3; + SubscribeUpdateTransaction transaction = 4; + SubscribeUpdateTransactionStatus transaction_status = 10; + SubscribeUpdateBlock block = 5; + SubscribeUpdatePing ping = 6; + SubscribeUpdatePong pong = 9; + SubscribeUpdateBlockMeta block_meta = 7; + SubscribeUpdateEntry entry = 8; + } +} + +message SubscribeUpdateAccount { + SubscribeUpdateAccountInfo account = 1; + uint64 slot = 2; + bool is_startup = 3; +} + +message SubscribeUpdateAccountInfo { + bytes pubkey = 1; + uint64 lamports = 2; + bytes owner = 3; + bool executable = 4; + uint64 rent_epoch = 5; + bytes data = 6; + uint64 write_version = 7; + optional bytes txn_signature = 8; +} + +message SubscribeUpdateSlot { + uint64 slot = 1; + optional uint64 parent = 2; + CommitmentLevel status = 3; + optional string dead_error = 4; +} + +message SubscribeUpdateTransaction { + SubscribeUpdateTransactionInfo transaction = 1; + uint64 slot = 2; +} + +message SubscribeUpdateTransactionInfo { + bytes signature = 1; + bool is_vote = 2; + solana.storage.ConfirmedBlock.Transaction transaction = 3; + solana.storage.ConfirmedBlock.TransactionStatusMeta meta = 4; + uint64 index = 5; +} + +message SubscribeUpdateTransactionStatus { + uint64 slot = 1; + bytes signature = 2; + bool is_vote = 3; + uint64 index = 4; + solana.storage.ConfirmedBlock.TransactionError err = 5; +} + +message SubscribeUpdateBlock { + uint64 slot = 1; + string blockhash = 2; + solana.storage.ConfirmedBlock.Rewards rewards = 3; + solana.storage.ConfirmedBlock.UnixTimestamp block_time = 4; + solana.storage.ConfirmedBlock.BlockHeight block_height = 5; + uint64 parent_slot = 7; + string parent_blockhash = 8; + uint64 executed_transaction_count = 9; + repeated SubscribeUpdateTransactionInfo transactions = 6; + uint64 updated_account_count = 10; + repeated SubscribeUpdateAccountInfo accounts = 11; + uint64 entries_count = 12; + repeated SubscribeUpdateEntry entries = 13; +} + +message SubscribeUpdateBlockMeta { + uint64 slot = 1; + string blockhash = 2; + solana.storage.ConfirmedBlock.Rewards rewards = 3; + solana.storage.ConfirmedBlock.UnixTimestamp block_time = 4; + solana.storage.ConfirmedBlock.BlockHeight block_height = 5; + uint64 parent_slot = 6; + string parent_blockhash = 7; + uint64 executed_transaction_count = 8; + uint64 entries_count = 9; +} + +message SubscribeUpdateEntry { + uint64 slot = 1; + uint64 index = 2; + uint64 num_hashes = 3; + bytes hash = 4; + uint64 executed_transaction_count = 5; + uint64 starting_transaction_index = 6; // added in v1.18, for solana 1.17 value is always 0 +} + +message SubscribeUpdatePing {} + +message SubscribeUpdatePong { + int32 id = 1; +} + +// non-streaming methods + +message PingRequest { + int32 count = 1; +} + +message PongResponse { + int32 count = 1; +} + +message GetLatestBlockhashRequest { + optional CommitmentLevel commitment = 1; +} + +message GetLatestBlockhashResponse { + uint64 slot = 1; + string blockhash = 2; + uint64 last_valid_block_height = 3; +} + +message GetBlockHeightRequest { + optional CommitmentLevel commitment = 1; +} + +message GetBlockHeightResponse { + uint64 block_height = 1; +} + +message GetSlotRequest { + optional CommitmentLevel commitment = 1; +} + +message GetSlotResponse { + uint64 slot = 1; +} + +message GetVersionRequest {} + +message GetVersionResponse { + string version = 1; +} + +message IsBlockhashValidRequest { + string blockhash = 1; + optional CommitmentLevel commitment = 2; +} + +message IsBlockhashValidResponse { + uint64 slot = 1; + bool valid = 2; +} \ No newline at end of file diff --git a/src/geyser/proto/solana-storage.proto b/src/geyser/proto/solana-storage.proto new file mode 100644 index 0000000..56e3eb0 --- /dev/null +++ b/src/geyser/proto/solana-storage.proto @@ -0,0 +1,149 @@ +syntax = "proto3"; + +package solana.storage.ConfirmedBlock; + +option go_package = "github.com/rpcpool/yellowstone-grpc/examples/golang/proto"; + +message ConfirmedBlock { + string previous_blockhash = 1; + string blockhash = 2; + uint64 parent_slot = 3; + repeated ConfirmedTransaction transactions = 4; + repeated Reward rewards = 5; + UnixTimestamp block_time = 6; + BlockHeight block_height = 7; + NumPartitions num_partitions = 8; +} + +message ConfirmedTransaction { + Transaction transaction = 1; + TransactionStatusMeta meta = 2; +} + +message Transaction { + repeated bytes signatures = 1; + Message message = 2; +} + +message Message { + MessageHeader header = 1; + repeated bytes account_keys = 2; + bytes recent_blockhash = 3; + repeated CompiledInstruction instructions = 4; + bool versioned = 5; + repeated MessageAddressTableLookup address_table_lookups = 6; +} + +message MessageHeader { + uint32 num_required_signatures = 1; + uint32 num_readonly_signed_accounts = 2; + uint32 num_readonly_unsigned_accounts = 3; +} + +message MessageAddressTableLookup { + bytes account_key = 1; + bytes writable_indexes = 2; + bytes readonly_indexes = 3; +} + +message TransactionStatusMeta { + TransactionError err = 1; + uint64 fee = 2; + repeated uint64 pre_balances = 3; + repeated uint64 post_balances = 4; + repeated InnerInstructions inner_instructions = 5; + bool inner_instructions_none = 10; + repeated string log_messages = 6; + bool log_messages_none = 11; + repeated TokenBalance pre_token_balances = 7; + repeated TokenBalance post_token_balances = 8; + repeated Reward rewards = 9; + repeated bytes loaded_writable_addresses = 12; + repeated bytes loaded_readonly_addresses = 13; + ReturnData return_data = 14; + bool return_data_none = 15; + + // Sum of compute units consumed by all instructions. + // Available since Solana v1.10.35 / v1.11.6. + // Set to `None` for txs executed on earlier versions. + optional uint64 compute_units_consumed = 16; +} + +message TransactionError { + bytes err = 1; +} + +message InnerInstructions { + uint32 index = 1; + repeated InnerInstruction instructions = 2; +} + +message InnerInstruction { + uint32 program_id_index = 1; + bytes accounts = 2; + bytes data = 3; + + // Invocation stack height of an inner instruction. + // Available since Solana v1.14.6 + // Set to `None` for txs executed on earlier versions. + optional uint32 stack_height = 4; +} + +message CompiledInstruction { + uint32 program_id_index = 1; + bytes accounts = 2; + bytes data = 3; +} + +message TokenBalance { + uint32 account_index = 1; + string mint = 2; + UiTokenAmount ui_token_amount = 3; + string owner = 4; + string program_id = 5; +} + +message UiTokenAmount { + double ui_amount = 1; + uint32 decimals = 2; + string amount = 3; + string ui_amount_string = 4; +} + +message ReturnData { + bytes program_id = 1; + bytes data = 2; +} + +enum RewardType { + Unspecified = 0; + Fee = 1; + Rent = 2; + Staking = 3; + Voting = 4; +} + +message Reward { + string pubkey = 1; + int64 lamports = 2; + uint64 post_balance = 3; + RewardType reward_type = 4; + string commission = 5; +} + +message Rewards { + repeated Reward rewards = 1; + NumPartitions num_partitions = 2; +} + +message UnixTimestamp { + int64 timestamp = 1; +} + +message BlockHeight { + uint64 block_height = 1; +} + +message NumPartitions { + uint64 num_partitions = 1; +} \ No newline at end of file diff --git a/src/monitoring/geyser_event_processor.py b/src/monitoring/geyser_event_processor.py new file mode 100644 index 0000000..cd05009 --- /dev/null +++ b/src/monitoring/geyser_event_processor.py @@ -0,0 +1,92 @@ +""" +Event processing for pump.fun tokens using Geyser data. +""" + +import struct +from typing import Final + +from solders.pubkey import Pubkey + +from trading.base import TokenInfo +from utils.logger import get_logger + +logger = get_logger(__name__) + + +class GeyserEventProcessor: + """Processes token creation events from Geyser stream.""" + + CREATE_DISCRIMINATOR: Final[bytes] = struct.pack(" TokenInfo | None: + """Process transaction data and extract token creation info. + + Args: + instruction_data: Raw instruction data + accounts: List of account indices + keys: List of account public keys + + Returns: + TokenInfo if token creation found, None otherwise + """ + if not instruction_data.startswith(self.CREATE_DISCRIMINATOR): + return None + + try: + # Skip past the 8-byte discriminator + offset = 8 + + # Helper to read strings (prefixed with length) + def read_string(): + nonlocal offset + # Get string length (4-byte uint) + length = struct.unpack_from("= len(accounts): + return None + account_index = accounts[index] + if account_index >= len(keys): + return None + return Pubkey.from_bytes(keys[account_index]) + + name = read_string() + symbol = read_string() + uri = read_string() + + mint = get_account_key(0) + bonding_curve = get_account_key(2) + associated_bonding_curve = get_account_key(3) + user = get_account_key(7) + + if not all([mint, bonding_curve, associated_bonding_curve, user]): + logger.warning("Missing required account keys in token creation") + return None + + return TokenInfo( + name=name, + symbol=symbol, + uri=uri, + mint=mint, + bonding_curve=bonding_curve, + associated_bonding_curve=associated_bonding_curve, + user=user, + ) + + except Exception as e: + logger.error(f"Failed to process transaction data: {e}") + return None diff --git a/src/monitoring/geyser_listener.py b/src/monitoring/geyser_listener.py new file mode 100644 index 0000000..8581fe8 --- /dev/null +++ b/src/monitoring/geyser_listener.py @@ -0,0 +1,159 @@ +""" +Geyser monitoring for pump.fun tokens. +""" + +import asyncio +from collections.abc import Awaitable, Callable + +import grpc +from solders.pubkey import Pubkey + +from geyser.generated import geyser_pb2, geyser_pb2_grpc +from monitoring.base_listener import BaseTokenListener +from monitoring.geyser_event_processor import GeyserEventProcessor +from trading.base import TokenInfo +from utils.logger import get_logger + +logger = get_logger(__name__) + + +class GeyserListener(BaseTokenListener): + """Geyser listener for pump.fun token creation events.""" + + def __init__(self, geyser_endpoint: str, geyser_api_token: str, pump_program: Pubkey): + """Initialize token listener. + + Args: + geyser_endpoint: Geyser gRPC endpoint URL + geyser_api_token: API token for authentication + pump_program: Pump.fun program address + """ + self.geyser_endpoint = geyser_endpoint + self.geyser_api_token = geyser_api_token + self.pump_program = pump_program + self.event_processor = GeyserEventProcessor(pump_program) + + async def _create_geyser_connection(self): + """Establish a secure connection to the Geyser endpoint.""" + auth = grpc.metadata_call_credentials( + lambda context, callback: callback( + (("authorization", f"Basic {self.geyser_api_token}"),), None + ) + ) + creds = grpc.composite_channel_credentials( + grpc.ssl_channel_credentials(), auth + ) + channel = grpc.aio.secure_channel(self.geyser_endpoint, creds) + return geyser_pb2_grpc.GeyserStub(channel), channel + + def _create_subscription_request(self): + """Create a subscription request for Pump.fun transactions.""" + request = geyser_pb2.SubscribeRequest() + request.transactions["pump_filter"].account_include.append(str(self.pump_program)) + request.transactions["pump_filter"].failed = False + request.commitment = geyser_pb2.CommitmentLevel.PROCESSED + return request + + async def listen_for_tokens( + self, + token_callback: Callable[[TokenInfo], Awaitable[None]], + match_string: str | None = None, + creator_address: str | None = None, + ) -> None: + """Listen for new token creations using Geyser subscription. + + Args: + token_callback: Callback function for new tokens + match_string: Optional string to match in token name/symbol + creator_address: Optional creator address to filter by + """ + while True: + try: + stub, channel = await self._create_geyser_connection() + request = self._create_subscription_request() + + logger.info(f"Connected to Geyser endpoint: {self.geyser_endpoint}") + logger.info(f"Monitoring for transactions involving program: {self.pump_program}") + + try: + async for update in stub.Subscribe(iter([request])): + token_info = await self._process_update(update) + if not token_info: + continue + + logger.info( + f"New token detected: {token_info.name} ({token_info.symbol})" + ) + + if match_string and not ( + match_string.lower() in token_info.name.lower() + or match_string.lower() in token_info.symbol.lower() + ): + logger.info( + f"Token does not match filter '{match_string}'. Skipping..." + ) + continue + + if ( + creator_address + and str(token_info.user) != creator_address + ): + logger.info( + f"Token not created by {creator_address}. Skipping..." + ) + continue + + await token_callback(token_info) + + except grpc.aio.AioRpcError as e: + logger.error(f"gRPC error: {e.details()}") + await asyncio.sleep(5) + + finally: + await channel.close() + + except Exception as e: + logger.error(f"Geyser connection error: {e}") + logger.info("Reconnecting in 10 seconds...") + await asyncio.sleep(10) + + async def _process_update(self, update) -> TokenInfo | None: + """Process a Geyser update and extract token creation info. + + Args: + update: Geyser update from the subscription + + Returns: + TokenInfo if a token creation is found, None otherwise + """ + try: + if not update.HasField("transaction"): + return None + + tx = update.transaction.transaction.transaction + msg = getattr(tx, "message", None) + if msg is None: + return None + + for ix in msg.instructions: + # Skip non-Pump.fun program instructions + program_idx = ix.program_id_index + if program_idx >= len(msg.account_keys): + continue + + program_id = msg.account_keys[program_idx] + if bytes(program_id) != bytes(self.pump_program): + continue + + # Process instruction data + token_info = self.event_processor.process_transaction_data( + ix.data, ix.accounts, msg.account_keys + ) + if token_info: + return token_info + + return None + + except Exception as e: + logger.error(f"Error processing Geyser update: {e}") + return None diff --git a/src/trading/trader.py b/src/trading/trader.py index ea306e1..a690c55 100644 --- a/src/trading/trader.py +++ b/src/trading/trader.py @@ -22,6 +22,7 @@ from core.priority_fee.manager import PriorityFeeManager from core.pubkeys import PumpAddresses from core.wallet import Wallet from monitoring.block_listener import BlockListener +from monitoring.geyser_listener import GeyserListener from monitoring.logs_listener import LogsListener from trading.base import TokenInfo, TradeResult from trading.buyer import TokenBuyer @@ -43,7 +44,9 @@ class PumpTrader: buy_slippage: float, sell_slippage: float, max_retries: int = 5, - listener_type: str = "block", # Add this parameter + listener_type: str = "logs", + geyser_endpoint: str | None = None, + geyser_api_token: str | None = None, ): """Initialize the pump trader. @@ -55,7 +58,9 @@ class PumpTrader: buy_slippage: Slippage tolerance for buys sell_slippage: Slippage tolerance for sells max_retries: Maximum number of retry attempts - listener_type: Type of listener to use ('block' or 'logs') + listener_type: Type of listener to use ('logs', 'blocks', or 'geyser') + geyser_endpoint: Geyser endpoint URL (required for geyser listener) + geyser_api_token: Geyser API token (required for geyser listener) """ self.solana_client = SolanaClient(rpc_endpoint) self.wallet = Wallet(private_key) @@ -92,7 +97,18 @@ class PumpTrader: ) # Initialize the appropriate listener type - if listener_type.lower() == "logs": + listener_type = listener_type.lower() + if listener_type == "geyser": + if not geyser_endpoint or not geyser_api_token: + raise ValueError("Geyser endpoint and API token are required for geyser listener") + + self.token_listener = GeyserListener( + geyser_endpoint, + geyser_api_token, + PumpAddresses.PROGRAM + ) + logger.info("Using Geyser listener for token monitoring") + elif listener_type == "logs": self.token_listener = LogsListener(wss_endpoint, PumpAddresses.PROGRAM) logger.info("Using logsSubscribe listener for token monitoring") else: diff --git a/tests/compare_listeners.py b/tests/compare_listeners.py index 809b7c7..2c6b0bd 100644 --- a/tests/compare_listeners.py +++ b/tests/compare_listeners.py @@ -1,6 +1,6 @@ """ -Test script to compare BlockListener and LogsListener -Runs both listeners simultaneously to compare their performance +Test script to compare BlockListener, LogsListener, and GeyserListener +Runs all listeners simultaneously to compare their performance """ import asyncio @@ -10,13 +10,18 @@ import sys import time from pathlib import Path +from dotenv import load_dotenv + sys.path.append(str(Path(__file__).parent.parent / "src")) from core.pubkeys import PumpAddresses from monitoring.block_listener import BlockListener +from monitoring.geyser_listener import GeyserListener from monitoring.logs_listener import LogsListener from trading.base import TokenInfo +load_dotenv() + logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" ) @@ -46,9 +51,30 @@ class TimingTokenCallback: print(f"{'=' * 50}\n") +async def listen_with_timeout(listener, callback, timeout): + """Run a listener for a specified duration""" + try: + listen_task = asyncio.create_task( + listener.listen_for_tokens(callback.on_token_created) + ) + + await asyncio.sleep(timeout) + + listen_task.cancel() + try: + await listen_task + except asyncio.CancelledError: + pass + except Exception as e: + logger.error(f"Error in listener {callback.name}: {e}") + + async def run_comparison(test_duration: int = 300): - """Run both listeners and compare their performance""" + """Run all listeners and compare their performance""" wss_endpoint = os.environ.get("SOLANA_NODE_WSS_ENDPOINT") + geyser_endpoint = os.environ.get("GEYSER_ENDPOINT") + geyser_api_token = os.environ.get("GEYSER_API_TOKEN") + if not wss_endpoint: logger.error("SOLANA_NODE_WSS_ENDPOINT environment variable is not set") return @@ -57,70 +83,115 @@ async def run_comparison(test_duration: int = 300): block_listener = BlockListener(wss_endpoint, PumpAddresses.PROGRAM) logs_listener = LogsListener(wss_endpoint, PumpAddresses.PROGRAM) - + block_callback = TimingTokenCallback("BlockListener") logs_callback = TimingTokenCallback("LogsListener") - logger.info("Starting both listeners...") - block_task = asyncio.create_task( - block_listener.listen_for_tokens(block_callback.on_token_created) - ) - logs_task = asyncio.create_task( - logs_listener.listen_for_tokens(logs_callback.on_token_created) - ) + listener_tasks = [ + listen_with_timeout(block_listener, block_callback, test_duration), + listen_with_timeout(logs_listener, logs_callback, test_duration) + ] + + callbacks = [block_callback, logs_callback] + listener_names = ["BlockListener", "LogsListener"] + + # Initialize Geyser listener if credentials are available + if geyser_endpoint and geyser_api_token: + logger.info(f"Connecting to Geyser API: {geyser_endpoint}") + geyser_listener = GeyserListener(geyser_endpoint, geyser_api_token, PumpAddresses.PROGRAM) + geyser_callback = TimingTokenCallback("GeyserListener") + + listener_tasks.append( + listen_with_timeout(geyser_listener, geyser_callback, test_duration) + ) + + callbacks.append(geyser_callback) + listener_names.append("GeyserListener") + else: + logger.warning("Geyser API credentials not found. Running without Geyser listener.") + logger.info("Starting all listeners simultaneously...") logger.info(f"Comparison running for {test_duration} seconds...") + try: - await asyncio.sleep(test_duration) + # Start all listeners at the same time + start_time = time.time() + await asyncio.gather(*listener_tasks) + end_time = time.time() + + logger.info(f"Test completed in {end_time - start_time:.2f} seconds") + except KeyboardInterrupt: logger.info("Test interrupted by user") - finally: - block_task.cancel() - logs_task.cancel() - try: - await asyncio.gather(block_task, logs_task, return_exceptions=True) - except asyncio.CancelledError: - pass + # No need for explicit cancellation as gather() will be interrupted - logger.info(f"BlockListener detected {len(block_callback.detected_tokens)} tokens") - logger.info(f"LogsListener detected {len(logs_callback.detected_tokens)} tokens") + for i, callback in enumerate(callbacks): + logger.info(f"{listener_names[i]} detected {len(callback.detected_tokens)} tokens") - # Find tokens detected by both listeners - block_mints = {str(token.mint) for token in block_callback.detected_tokens} - logs_mints = {str(token.mint) for token in logs_callback.detected_tokens} - common_mints = block_mints.intersection(logs_mints) + # Find tokens detected by multiple listeners + all_mints = {} + for i, callback in enumerate(callbacks): + mints = {str(token.mint) for token in callback.detected_tokens} + all_mints[listener_names[i]] = mints - logger.info(f"Tokens detected by both listeners: {len(common_mints)}") + # Analyze common detections between all listeners + if len(callbacks) > 1: + logger.info("\nAnalyzing token detection across listeners:") + + # Find tokens detected by all listeners + if len(callbacks) > 2: # If we have all 3 listeners + common_to_all = set.intersection(*all_mints.values()) + logger.info(f"Tokens detected by all listeners: {len(common_to_all)}") + + # Compare pairs of listeners + listeners = list(all_mints.keys()) + for i in range(len(listeners)): + for j in range(i+1, len(listeners)): + listener1 = listeners[i] + listener2 = listeners[j] + common = all_mints[listener1].intersection(all_mints[listener2]) + logger.info(f"Tokens detected by both {listener1} and {listener2}: {len(common)}") + + unique1 = all_mints[listener1] - all_mints[listener2] + unique2 = all_mints[listener2] - all_mints[listener1] + logger.info(f"Tokens unique to {listener1}: {len(unique1)}") + logger.info(f"Tokens unique to {listener2}: {len(unique2)}") + + # Find tokens detected by at least one listener + all_detected = set.union(*all_mints.values()) + logger.info(f"Total unique tokens detected by any listener: {len(all_detected)}") - # Compare detection times for common tokens - if common_mints: - logger.info("\nPerformance comparison for tokens detected by both listeners:") - logger.info("Token Mint | BlockListener Time | LogsListener Time | Difference (ms)") + logger.info("\nDetection speed comparison:") + + # Collect all tokens detected by at least two listeners + detection_comparisons = [] + for mint in set.union(*all_mints.values()): + detections = {} + for i, callback in enumerate(callbacks): + if mint in callback.detection_times: + detections[listener_names[i]] = callback.detection_times[mint] + + if len(detections) > 1: # Only consider tokens detected by multiple listeners + detection_comparisons.append((mint, detections)) + + if detection_comparisons: + logger.info("Token | " + " | ".join(listener_names) + " | Fastest") logger.info("-" * 80) - for mint in common_mints: - block_time = block_callback.detection_times.get(mint) - logs_time = logs_callback.detection_times.get(mint) + for mint, detections in detection_comparisons: + # Create row with detection times or "N/A" if not detected + times = [] + for name in listener_names: + time_str = f"{detections.get(name, 0):.6f}" if name in detections else "N/A" + times.append(time_str) - if block_time and logs_time: - diff_ms = abs(block_time - logs_time) * 1000 # Convert to milliseconds - faster = "BlockListener" if block_time < logs_time else "LogsListener" - - logger.info(f"{mint[:10]}... | {block_time:.6f} | {logs_time:.6f} | {diff_ms:.2f}ms ({faster} faster)") - - # Report tokens only detected by one listener - block_only = block_mints - logs_mints - logs_only = logs_mints - block_mints - - if block_only: - logger.info(f"\nTokens only detected by BlockListener: {len(block_only)}") - for mint in block_only: - logger.info(f" - {mint}") - - if logs_only: - logger.info(f"\nTokens only detected by LogsListener: {len(logs_only)}") - for mint in logs_only: - logger.info(f" - {mint}") + # Determine fastest listener + valid_times = {name: time for name, time in detections.items() if time > 0} + fastest = min(valid_times.items(), key=lambda x: x[1])[0] if valid_times else "N/A" + + logger.info(f"{mint[:10]}... | " + " | ".join(times) + f" | {fastest}") + else: + logger.info("No tokens were detected by multiple listeners for timing comparison") if __name__ == "__main__": diff --git a/tests/test_block_listener.py b/tests/test_block_listener.py index 9648f21..1be17f8 100644 --- a/tests/test_block_listener.py +++ b/tests/test_block_listener.py @@ -9,12 +9,16 @@ import os import sys from pathlib import Path +from dotenv import load_dotenv + sys.path.append(str(Path(__file__).parent.parent / "src")) from core.pubkeys import PumpAddresses from monitoring.block_listener import BlockListener from trading.base import TokenInfo +load_dotenv() + logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" ) @@ -91,7 +95,7 @@ async def test_block_listener( if __name__ == "__main__": match_string = None # Update if you want to filter tokens by name/symbol creator_address = None # Update if you want to filter tokens by creator address - test_duration = 15 + test_duration = 30 logger.info("Starting block listener test (using blockSubscribe)") asyncio.run(test_block_listener(match_string, creator_address, test_duration)) diff --git a/tests/test_geyser_listener.py b/tests/test_geyser_listener.py new file mode 100644 index 0000000..7c9e030 --- /dev/null +++ b/tests/test_geyser_listener.py @@ -0,0 +1,107 @@ +""" +Test script for GeyserListener +Tests gRPC monitoring for new pump.fun tokens using Geyser +""" + +import asyncio +import logging +import os +import sys +from pathlib import Path + +from dotenv import load_dotenv + +sys.path.append(str(Path(__file__).parent.parent / "src")) + +from core.pubkeys import PumpAddresses +from monitoring.geyser_listener import GeyserListener +from trading.base import TokenInfo + +load_dotenv() + +logging.basicConfig( + level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" +) +logger = logging.getLogger("geyser-listener-test") + + +class TestTokenCallback: + def __init__(self): + self.detected_tokens = [] + + async def on_token_created(self, token_info: TokenInfo) -> None: + """Process detected token""" + logger.info(f"New token detected: {token_info.name} ({token_info.symbol})") + logger.info(f"Mint: {token_info.mint}") + self.detected_tokens.append(token_info) + print(f"\n{'=' * 50}") + print(f"NEW TOKEN: {token_info.name}") + print(f"Symbol: {token_info.symbol}") + print(f"Mint: {token_info.mint}") + print(f"URI: {token_info.uri}") + print(f"Creator: {token_info.user}") + print(f"Bonding Curve: {token_info.bonding_curve}") + print(f"Associated Bonding Curve: {token_info.associated_bonding_curve}") + print(f"{'=' * 50}\n") + + +async def test_geyser_listener( + match_string: str | None = None, + creator_address: str | None = None, + test_duration: int = 60, +): + """Test the Geyser listener functionality""" + geyser_endpoint = os.environ.get("GEYSER_ENDPOINT") + geyser_api_token = os.environ.get("GEYSER_API_TOKEN") + + if not geyser_endpoint: + logger.error("GEYSER_ENDPOINT environment variable is not set") + return [] + + if not geyser_api_token: + logger.error("GEYSER_API_TOKEN environment variable is not set") + return [] + + logger.info(f"Connecting to Geyser API: {geyser_endpoint}") + listener = GeyserListener(geyser_endpoint, geyser_api_token, PumpAddresses.PROGRAM) + callback = TestTokenCallback() + + if match_string: + logger.info(f"Filtering tokens matching: {match_string}") + if creator_address: + logger.info(f"Filtering tokens by creator: {creator_address}") + + listen_task = asyncio.create_task( + listener.listen_for_tokens( + callback.on_token_created, + match_string=match_string, + creator_address=creator_address, + ) + ) + + logger.info(f"Listening for {test_duration} seconds...") + try: + await asyncio.sleep(test_duration) + except KeyboardInterrupt: + logger.info("Test interrupted by user") + finally: + listen_task.cancel() + try: + await listen_task + except asyncio.CancelledError: + pass + + logger.info(f"Detected {len(callback.detected_tokens)} tokens") + for token in callback.detected_tokens: + logger.info(f" - {token.name} ({token.symbol}): {token.mint}") + + return callback.detected_tokens + + +if __name__ == "__main__": + match_string = None # Update if you want to filter tokens by name/symbol + creator_address = None # Update if you want to filter tokens by creator address + test_duration = 30 + + logger.info("Starting Geyser listener test (using Geyser API)") + asyncio.run(test_geyser_listener(match_string, creator_address, test_duration)) diff --git a/tests/test_logs_listener.py b/tests/test_logs_listener.py index 8dcc05f..e27e1b2 100644 --- a/tests/test_logs_listener.py +++ b/tests/test_logs_listener.py @@ -9,12 +9,16 @@ import os import sys from pathlib import Path +from dotenv import load_dotenv + sys.path.append(str(Path(__file__).parent.parent / "src")) from core.pubkeys import PumpAddresses from monitoring.logs_listener import LogsListener from trading.base import TokenInfo +load_dotenv() + logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" ) @@ -91,7 +95,7 @@ async def test_logs_listener( if __name__ == "__main__": match_string = None # Update if you want to filter tokens by name/symbol creator_address = None # Update if you want to filter tokens by creator address - test_duration = 15 + test_duration = 30 logger.info("Starting logs listener test (using logsSubscribe)") asyncio.run(test_logs_listener(match_string, creator_address, test_duration))