Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non-streaming methods #112

Open
5 of 8 tasks
linuskendall opened this issue Apr 20, 2023 · 5 comments · Fixed by #117 or #122
Open
5 of 8 tasks

Add non-streaming methods #112

linuskendall opened this issue Apr 20, 2023 · 5 comments · Fixed by #117 or #122
Assignees

Comments

@linuskendall
Copy link
Contributor

linuskendall commented Apr 20, 2023

I would like to add non streaming methods that could help users who are writing trading code:

  • getLatestBlockhash
  • getBlockHeight
  • getSlot (we already have support ?)

Harder ones that we could potentially do if we add much more logic to the code

  • getRecentPrioritizationFee (need to store transcation stats, probably out-of-scope)
  • isBlockhashValid (need to store block hashes)

Ones that I don't know if possible (what info would we require to do this? maybe some modification to geyser interface to send some of this info on start up):

  • getVersion
  • getIdentity
  • getEpochInfo

Others..?

@linuskendall
Copy link
Contributor Author

See also #47, which can be a first version (not sure if it can include the solana validator version?).

@shuimuliang shuimuliang self-assigned this Apr 27, 2023
@shuimuliang shuimuliang removed their assignment Apr 27, 2023
@shuimuliang
Copy link
Contributor

linuskendall:
for getLatestBlockhash
if we can we should use the existing interface
I think via block notification + slot notification

@shuimuliang
Copy link
Contributor

share read/write design for MessageBlockMeta

// plugin.rs
#[derive(Debug)]
pub struct PluginInner {
    // ...
    latest_block_meta: Arc<RwLock<Option<MessageBlockMeta>>>,
}

// grpc.rs
#[derive(Clone)]
pub struct GrpcService {
    // ...
    latest_block_meta: Arc<RwLock<Option<MessageBlockMeta>>>,
}

// plugin.rs
    fn notify_block_metadata(
        &mut self,
        blockinfo: ReplicaBlockInfoVersions<'_>,
    ) -> PluginResult<()> {
                // ...
               if let Ok(mut latest_block_meta_write_guard) = inner.latest_block_meta.write() {
                *latest_block_meta_write_guard = Some(block_meta.clone());
            }
}

// grpc.rs
    async fn get_latest_blockhash(&self, _request: Request<GetLatestBlockhashRequest>) -> Result<Response<GetLatestBlockhashResponse>, Status> {
        if let Ok(message_block_meta) = self.latest_block_meta.read() {
            let v= message_block_meta.as_ref();
            if let Some(v) = v {
                let response = GetLatestBlockhashResponse {
                    slot: v.slot,
                    blockhash: v.blockhash.clone(),
                    block_height: v.block_height.unwrap(),
                };
                return Ok(Response::new(response));
            }
        }

        Err(Status::internal("latest_block_meta is None"))
    }

@shuimuliang shuimuliang self-assigned this May 8, 2023
shuimuliang added a commit that referenced this issue May 9, 2023
shuimuliang added a commit that referenced this issue May 10, 2023
…ash (#117)

* feat: unary Ping method for geyser_server

* fix: variables can be used directly in the `format!` string

* feat: Geyser server getLatestBlockhash method

* fix: use RwLock from tokio

by fanatid:
I think it's better to use RwLock from tokio, everything what we have is async

* feat: #112 getBlockHeight & getSlot

* use RwLock and mpsc (#118)

---------

Co-authored-by: Kirill Fomichev <[email protected]>
@shuimuliang shuimuliang reopened this May 10, 2023
@shuimuliang
Copy link
Contributor

shuimuliang commented May 16, 2023

one more question for isBlockhashValid/is_blockhash_valid:

in Solana validator, we could hold a ArcBank instance, and query blockhash within the Bank

We could use the following method:

  1. at server startup, embed a RocksDB or third-party KV database.
  2. record newly received blockhash.
  3. if client queries, return the result.

The potential issue here is:

only newly added blockhashes are recorded at startup, and historical blockhashes are not recorded. it may be necessary to maintain a separate historical database for querying.

shuimuliang added a commit that referenced this issue May 22, 2023
add ping,get_latest_blockhash,get_block_height,get_slot for yellowstone-grpc-client
@shuimuliang shuimuliang linked a pull request May 22, 2023 that will close this issue
@shuimuliang shuimuliang reopened this May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants