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

Implement auto port for integration test #327

Closed
wants to merge 8 commits into from
Closed

Conversation

al8n
Copy link
Contributor

@al8n al8n commented Aug 25, 2023

No description provided.

@al8n al8n changed the title implement auto port for integration test Implement auto port for integration test Aug 25, 2023
@al8n al8n added the enhancement New feature or request label Aug 25, 2023
@al8n al8n added this to the Mixnet milestone Aug 25, 2023
This was referenced Aug 25, 2023
@@ -294,11 +292,11 @@ fn create_node_config(
};
#[cfg(feature = "waku")]
{
config.network.backend.inner.port = Some(get_available_port() as usize);
Copy link
Contributor

Choose a reason for hiding this comment

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

how do nodes client know who to contact if the OS decides the port to use? It's a different process, we can't access the address like you do in mixnet node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was solved by PR #330. In this PR, we can get the correct address through the MixnodeHandle struct.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean for standard nodes (

pub async fn spawn(mut config: Config) -> Self {
), not mixnodes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, sorry, I forgot the standard node. Yeah, it is hard to get the port for the standard node, I will rethink it. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

I also forgot about it. My head was too chaotic. It might be not possible to use auto-assigned ports. If port conflict rarely happen, i think we can go ahead with the current solution. what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think #315 made things worse in a way because now you can have conflicts in a single process (previous solution was fine with multiple threads in the same process):

  • process 1 ask for some port, receives port 8002, but does not start yet
  • process 2 ask for some port, we are unlucky and get port 8002 from the random generator
    Since Pick ports more randomly for integration tests #315 is not using any global lock and process 1 has not started, the os reports port 8002 as free, but later they will both try to use it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. I think that both of previous and current solution have this multiprocess problem, since we don’t have cross-process locking.

I thought that the probability of conflict between processes is lower in the current solution. In the previous solution, all processes start with the port 800x (I don’t remember the exact number). This will cause the high probability of conflict.

For single process, you’re right. We may need to revive the lock or something

Copy link
Contributor

Choose a reason for hiding this comment

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

How about reviving the lock from the previous soluton

static NET_PORT: Mutex<u16> = Mutex::new(8000);

but instead of using the constant 8000, what do you think about using a random start port?

Using this lock, the single process would be happy. With a random start port, we can lower the probability of conflicts between processes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll make a simple PR for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll make a simple PR for this.

Opened a PR: #334

But, random port assignment is a problem when doing benchmarks for mixnode, we can use auto port for mixnodes.

As I discussed with Al, I think it would be better to postpone this PR along with #328, until we make CI happy for other PRs.

@youngjoon-lee
Copy link
Contributor

I think we can close this PR? since we've reduced the probability of port conflicts by #334 and switched from Jenkins to Github Actions.

@al8n al8n closed this Sep 4, 2023
@jakubgs jakubgs deleted the integration-auto-port branch February 15, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants