-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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-alt] - add rpc api ingestion to indexer-alt #20787
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
8b65939
to
5d6f78d
Compare
5d6f78d
to
bf7ed0c
Compare
#[clap(long)] | ||
pub basic_auth: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include some documentation of the expected format of this CLI arg, below you can see that its expected to be <username>:<password>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on the docs here, and some other comments:
- Let's also clarify that it is only relevant if
--rpc-api-url
is set. - Consider accepting this value via an environment variable as well.
crates/sui-rpc-api/src/client/mod.rs
Outdated
let value: MetadataValue<Ascii> = format!("Basic {}", auth) | ||
.parse() | ||
.map_err(Into::into) | ||
.map_err(Status::from_error)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is a username/password lets make sure to set the sensitive flag on the MetadataValue:
https://docs.rs/tonic/latest/tonic/metadata/struct.MetadataValue.html#method.set_sensitive
.tls_config( | ||
ClientTlsConfig::new() | ||
.with_enabled_roots() | ||
.assume_http2(true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? any TLS negotiation should include h2 in ALPN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is needed for the full node we setup in the private net
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some high level thoughts but the change on the indexing framework side looks good here, I see that @bmwill has some unresolved comments on the RPC API side, so I will leave it with him for the final stamp.
Ok(Bytes::from( | ||
Blob::encode(&data, BlobEncoding::Bcs)?.to_bytes(), | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly sure we're going to decode this straight away, which is a little unfortunate -- is it worth changing the IngestionClientTrait
so that fetch
returns a CheckpointData
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added FetchData, which can be either raw bytes or CheckpointData
use sui_storage::blob::{Blob, BlobEncoding}; | ||
use url::Url; | ||
|
||
pub(crate) struct RpcIngestionClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in two minds about this myself, but do we need this type? (As opposed to implementing IngestionClientTrait
directly on sui_rpc_api::Client
?
#[clap(long)] | ||
pub basic_auth: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on the docs here, and some other comments:
- Let's also clarify that it is only relevant if
--rpc-api-url
is set. - Consider accepting this value via an environment variable as well.
let basic_auth = args.basic_auth.map(|s| { | ||
let split = s.split(":").collect::<Vec<_>>(); | ||
assert_eq!(2, split.len()); | ||
(split[0].to_string(), split[1].to_string()) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not accept this as two different flags to avoid hand-rolling the parser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am now using the username and password encoded in the URL instead of having separated args
@@ -76,6 +77,17 @@ impl IngestionClient { | |||
} | |||
} | |||
|
|||
pub(crate) fn new_rpc( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this above new_impl
so it's with the other constructors?
Note #20986 added support for configuring auth |
thanks! that's great! I will rebase and update this PR |
18cd4de
to
82b8fe2
Compare
@@ -150,7 +154,7 @@ impl Client { | |||
|
|||
let (metadata, response, _extentions) = self | |||
.raw_client() | |||
.max_decoding_message_size(64 * 1024 * 1024) | |||
.max_decoding_message_size(128 * 1024 * 1024) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the checkpoint in our test environment exceeded 64Mb, I bumped the max decoding message size to avoid the error, @bmwill do you know what is the correct value to set here?
this PR is ready for more review, thanks! |
542562a
to
e35b491
Compare
impl IngestionClientTrait for RpcClient { | ||
async fn fetch(&self, checkpoint: u64) -> FetchResult { | ||
let data = self.get_full_checkpoint(checkpoint).await.map_err(|e| { | ||
if e.message().contains("not found") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more structured way to identify that a checkpoint is not found based on the response @bmwill ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errors are a bit of a mess still and i'm actively working on this as we speak. right now i think the gRPC Code::Unknown is always returned (which is not great)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a Code::NOT_FOUND
though which will eventually be returned here (hopefully by the next release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok #21163 should address this and allow you to look at the error code directly
FetchData::CheckPointData(data) => { | ||
self.metrics | ||
.total_ingested_bytes | ||
.inc_by(size_of_val(&data) as u64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_of_val
is not going to do the right thing here, because it's not going to look through pointers etc. @bmwill, is there a way to get similar information out from the gRPC client? If not, I would opt for not trying to replicate this metric in the case of RPC clients at all (but then we should update its documentation to mention that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not presently. but we could hook in something if we needed. Agreed that the way this is being done right now would produce inaccurate results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove this for RPC client for now until we have a better way to get the size information.
…eserilised CheckpointData * use username and password in URL instead of separated field * implement IngestionClientTrait for sui_rpc_api::Client instead of RpcIngestionClient
e35b491
to
1a47c37
Compare
Description
add rpc api ingestion to indexer-alt, this is to unblock a private-net app indexer.
Test plan
How did you test the new or updated feature?
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.