weeaa / jito-go

🪙 Jito Go SDK [unnoficial]
https://www.jito.wtf
Apache License 2.0
80 stars 23 forks source link

subscribe to program updates #1

Closed shardyr closed 8 months ago

shardyr commented 8 months ago

Hey, is it possible to subscribe to program updates? If not, when is this feature going to be added?

weeaa commented 8 months ago

Hi there, if you're referring to this function, then yes it should be possible. You would need a Geyser compatible RPC since Jito discontinued their own afaik.

I'm unable to test (since I do not own a compatible node) but will happily test if you own one 😊

edit: it appears that the proto files weren't properly pushed to the repository, but the issue has been resolved now

shardyr commented 8 months ago

I was refering to this function https://github.com/jito-labs/jito-ts/blob/7f9b6373eeaafa62cede73a0bbfa0b02a12a8601/src/sdk/block-engine/searcher.ts#L134, I was able however to make my own implementation with something like this. Might be a good idea to add this to the repo so people don't have to come up with their own implementations 👍

sub, err := searcherClient.SearcherService.SubscribeMempool(searcherClient.Auth.GrpcCtx, &proto.MempoolSubscription{
    Msg: &proto.MempoolSubscription_ProgramV0Sub{ProgramV0Sub: &proto.ProgramSubscriptionV0{
        Programs: programs,
    }},
    Regions: regions,
})

By the way, I think there should be bundle simulation support added. I'm currently working on my own implementation for this but I believe it can be done a lot better than I did.

Edit: On a side note I'd also like to thank you for making and publishing this sdk. I've been looking for a Jito SDK for Golang for months and here it is 😊 Much appreciated!

weeaa commented 8 months ago

Heyo, added the function to subscribe to programs. I also added bundle simulation, you would require a compatible jito-solana validator to perform the request.

thanks, appreciate your message and support ❤️

shardyr commented 8 months ago

Thank you for such a quick update :) There is one final, crucial thing I would like to ask for, to be exact bundle simulation config. Similar to the one available in the jito-ts TypeScript SDK.

export type SimulateBundleConfig = {
  /** list of accounts to return the pre transaction execution state for. The length of the array must be equal to the number transactions in the bundle */
  preExecutionAccountsConfigs: ({
    encoding: 'base64';
    addresses: string[];
  } | null)[];
  /** list of accounts to return the post transaction execution state for. The length of the array must be equal to the number transactions in the bundle */
  postExecutionAccountsConfigs: ({
    encoding: 'base64';
    addresses: string[];
  } | null)[];
  /** Optional parameter to specify the bank to run simulation against */
  simulationBank?: SimulationSlotConfig;
  /** Optional parameter used to enable signature verification before simulation */
  skipSigVerify?: boolean;
  /** Optional parameter used to replace the simulated transaction's recent blockhash with the latest blockhash */
  replaceRecentBlockhash?: boolean;
};

Let me know if it's possible to add this 😊 Cheers

shardyr commented 8 months ago

Also, there is a few errors in the current bundle simulation function and types. For instance, rentEpoch should be a *big.Int instead if an *int to prevent overflow. If you have a Discord or Telegram I could message you there and help you with testing (I have access to Jito RPC). If you're down, my Discord username is shar.d :)