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

fix: substrate runner, support new libp2p addr log #1892

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

niklasad1
Copy link
Member

No description provided.

@niklasad1 niklasad1 requested a review from a team as a code owner January 2, 2025 10:03
.rsplit_once("New listen address: /ip4/127.0.0.1/tcp/")
// slightly newer message:
.or_else(|| line.rsplit_once("New listen address address=/ip4/127.0.0.1/tcp/"))
Copy link
Member Author

@niklasad1 niklasad1 Jan 2, 2025

Choose a reason for hiding this comment

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

EDIT: ok I see, it comes from libp2p_tcp, probably this crate was bumped in polkadot-sdk

Copy link
Contributor

@pkhry pkhry left a comment

Choose a reason for hiding this comment

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

LGTM.

But a small nit: while we are at it can we make function try_find_substrate_port_from_output in subxt-runner return Result<SubstrateNodeInfo, Error> and fail early in the function if some of the values are not present?(we use the function only once on line 105 and we try to unconditionally extract optinoal values)

@niklasad1
Copy link
Member Author

But a small nit: while we are at it can we make function try_find_substrate_port_from_output in subxt-runner return Result<SubstrateNodeInfo, Error> and fail early in the function if some of the values are not present?(we use the function only once on line 105 and we try to unconditionally extract optinoal values)

We can't really just return early if some line couldn't be parsed because these are logs from the substrate node which we iterator line by line (i.e. std::io::Read) that contains a bunch of unrelated stuff which we are not interested in. So the assumption is the rpc server port, libp2p address and libp2p port should be found in the first 100 log entries when starting the node. Then line 105 is just a way to stop the iteration as soon as all values are found which is checked every iteration

Also, this function panics if any of patterns was matched but parsing the value failed, which works in the same way but less elegant ^^

Perhaps we could just read all lines to a String then do search it for the values but should be less efficient but more readable I guess.

@pkhry
Copy link
Contributor

pkhry commented Jan 2, 2025

But a small nit: while we are at it can we make function try_find_substrate_port_from_output in subxt-runner return Result<SubstrateNodeInfo, Error> and fail early in the function if some of the values are not present?(we use the function only once on line 105 and we try to unconditionally extract optinoal values)

We can't really just return early if some line couldn't be parsed because these are logs from the substrate node which we iterator line by line (i.e. std::io::Read) that contains a bunch of unrelated stuff which we are not interested in. So the assumption is the rpc server port, libp2p address and libp2p port should be found in the first 100 log entries when starting the node. Then line 105 is just a way to stop the iteration as soon as all values are found which is checked every iteration

Also, this function panics if any of patterns was matched but parsing the value failed, which works in the same way but less elegant ^^

Perhaps we could just read all lines to a String then do search it for the values but should be less efficient but more readable I guess.

I was thinking more inline of just making fields non optional in the struct SubstrateNodeInfo

@niklasad1
Copy link
Member Author

I was thinking more inline of just making fields non optional in the struct SubstrateNodeInfo

aight, I see yeah that's a good idea :)

@niklasad1 niklasad1 merged commit 27e275f into master Jan 6, 2025
13 checks passed
@niklasad1 niklasad1 deleted the na-fix-substrate-runner-p2p-port branch January 6, 2025 11:52
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.

3 participants