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

blockSubscribe RPC Method #416

Closed
wants to merge 0 commits into from
Closed

blockSubscribe RPC Method #416

wants to merge 0 commits into from

Conversation

ruiqic
Copy link
Contributor

@ruiqic ruiqic commented Apr 15, 2024

No description provided.

@michaelhly
Copy link
Owner

Hi, thanks for opening a PR! Would you mind fixing the lint issue and also writing a test?

You can run make lint to run the linter, and make format to format your code. Here is an example of a test:

@pytest.mark.integration
async def test_slot_subscribe(
websocket: SolanaWsClientProtocol,
slot_subscribed: None,
):
"""Test slot subscription."""
main_resp = await websocket.recv()
msg = main_resp[0]
assert isinstance(msg, SlotNotification)
assert msg.result.root >= 0

@ruiqic
Copy link
Contributor Author

ruiqic commented Apr 17, 2024

Hi, thanks for checking. I just added a simple test for slot and used make format to fix all black issues. Let me know.

@ruiqic
Copy link
Contributor Author

ruiqic commented Apr 17, 2024

Test not passing maybe because not all RPCs support this method:

UNSTABLE METHOD
This subscription is considered unstable and is only available if the validator was started with the --rpc-pubsub-enable-block-subscription flag. The format of this subscription may change in the future.
(https://solana.com/docs/rpc/websocket/blocksubscribe)

@michaelhly
Copy link
Owner

Hi @ruiqic. You can add the flag here:

SOLANA_RUN_SH_VALIDATOR_ARGS=--rpc-pubsub-enable-vote-subscription

@michaelhly
Copy link
Owner

Also, would you mind reverting all the formatting changes not related to this PR?

"""
req_id = self.increment_counter_and_get_id()
commitment_to_use = None if commitment is None else _COMMITMENT_TO_SOLDERS[commitment]
encoding_to_use = None if encoding is None else _ACCOUNT_ENCODING_TO_SOLDERS[encoding]
Copy link
Owner

@michaelhly michaelhly Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to use _TX_ENCODING_TO_SOLDERS instead:

Suggested change
encoding_to_use = None if encoding is None else _ACCOUNT_ENCODING_TO_SOLDERS[encoding]
encoding_to_use = None if encoding is None else _TX_ENCODING_TO_SOLDERS[encoding]

_TX_ENCODING_TO_SOLDERS = {
"binary": UiTransactionEncoding.Binary,
"base58": UiTransactionEncoding.Base58,
"base64": UiTransactionEncoding.Base64,
"json": UiTransactionEncoding.Json,
"jsonParsed": UiTransactionEncoding.JsonParsed,
}

@ruiqic
Copy link
Contributor Author

ruiqic commented Apr 17, 2024

Hi, thanks for checking the code. How can the coverage test be fixed?

@michaelhly
Copy link
Owner

I'll fix that separately. @ruiqic, would you mind giving me push access to your forked repo? I just want to push some clean up.

Copy link
Owner

@michaelhly michaelhly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@ruiqic
Copy link
Contributor Author

ruiqic commented Apr 17, 2024

Thanks. I already had Allowing edits by maintainers checked but I invited you as collaborator too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants