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

[indexer][test cluster] support indexer backed rpc in cluster test and add some indexer reader tests #19906

Merged
merged 7 commits into from
Oct 20, 2024

Conversation

emmazzz
Copy link
Contributor

@emmazzz emmazzz commented Oct 18, 2024

Description

This PR adds support in TestCluster to start indexer writer and indexer backed jsonrpc so that any testing done using TestCluster and fullnode jsonrpc can now be easily switched to using indexer jsonrpc. It's a step needed towards deprecation of fullnode jsonrpc. And a few tests are added/adapted from existing rpc tests.

Test plan

Added tests.


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Oct 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 19, 2024 11:54pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2024 11:54pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2024 11:54pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2024 11:54pm

crates/test-cluster/src/indexer_util.rs Outdated Show resolved Hide resolved
crates/test-cluster/src/indexer_util.rs Outdated Show resolved Hide resolved
.collect();

let object_resp = http_client.multi_get_objects(object_digests, None).await?;
assert_eq!(5, object_resp.len());
Copy link
Contributor

Choose a reason for hiding this comment

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

assert_eq on object_digests and digests from object_resp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an assert_eq comparing the results from fullnode and indexer, and actually found a discrepancy due to us not sorting by object ids. Also fixed in the latest commit.

crates/sui-indexer/tests/json_rpc_tests.rs Outdated Show resolved Hide resolved
crates/sui-indexer/tests/json_rpc_tests.rs Show resolved Hide resolved
Copy link
Contributor

@wlmyng wlmyng left a comment

Choose a reason for hiding this comment

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

thanks for setting this up

crates/test-cluster/src/lib.rs Outdated Show resolved Hide resolved

// TODO: this only starts indexer writer and reader (jsonrpc server) today.
// Consider adding graphql server here as well.
pub(crate) async fn setup_indexer_backed_rpc(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should simply be the new function of IndexerHandle. It will make this function a lot more discoverable.

let mut cancellation_tokens = vec![];
let database = TempDb::new().unwrap();
let pg_address = database.database().url().as_str().to_owned();
let indexer_jsonrpc_address = format!("127.0.0.1:{}", get_available_port("127.0.0.1"));
Copy link
Contributor

Choose a reason for hiding this comment

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

There should already be some localhost and port util function somewhere.

@@ -0,0 +1,84 @@
// Copyright (c) Mysten Labs, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider just naming this file test_indexer_handler

let mut data_ingestion_path = None;

if self.indexer_backed_rpc {
if self.data_ingestion_dir.is_none() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this code be moved to line 1138?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot. self.start_swarm() right after this block uses self.data_ingestion_dir.

@emmazzz emmazzz merged commit cc167f6 into main Oct 20, 2024
50 checks passed
@emmazzz emmazzz deleted the emma/indexer-json-test branch October 20, 2024 00:20
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.

4 participants