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

chore: Da dispersal unit tests update #720

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

romanzac
Copy link
Contributor

@romanzac romanzac commented Sep 3, 2024

Batch of tests for data availability - dispersal to improve coverage.

@romanzac romanzac marked this pull request as ready for review September 13, 2024 07:31
@romanzac romanzac requested a review from bacv September 13, 2024 07:36
@romanzac
Copy link
Contributor Author

Hi @bacv, I've been trying to write error cases for behavior, after difficulties moved to swarm testing. Let's review test_dispersal_with_swarms and see what to do next ?

});

tokio::time::sleep(Duration::from_secs(1)).await;
executor.dial(addr2).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

After dialing, executor needs to signal the other end about new stream:

let executor_open_stream_sender = executor.open_stream_sender();
executor_open_stream_sender.send(*validator_peer).unwrap();

To have open_stream_sender you'd need to target the da-integration-tests branch.

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 could not wrap my head around one problem. When I call executor_disperse_blob_sender.send(), handle_dispersal_event() is never called from run().loop. What else should I do ?

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 feel like our Swarm abstractions are only wrappers around libp2p's concepts? And we just forward all good and bad into upper layers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like our Swarm abstractions are only wrappers around libp2p's concepts? And we just forward all good and bad into upper layers.

Well, they are. This is just a networking layer, it should not do anything else that forward/received messages according to the specs.

Copy link
Member

Choose a reason for hiding this comment

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

I could not wrap my head around one problem. When I call executor_disperse_blob_sender.send(), handle_dispersal_event() is never called from run().loop. What else should I do ?

If you inspect the executor dispersal behaviour, you'll see that before the blob is sent, the peer_id for desired subnetwork need to be available (.../executor/behaviour.rs:289). For this reason try to apply the changes I suggested and call open_stream_sender().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me invest one more day and finish this exercise. Perhaps it will be useful for error case tests which require deep understanding of streams.

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 feel like our Swarm abstractions are only wrappers around libp2p's concepts? And we just forward all good and bad into upper layers.

Well, they are. This is just a networking layer, it should not do anything else that forward/received messages according to the specs.

Let me study Swarms in lipp2p more. Both go-waku and nwaku don't use them, that's why I need to have a deeper look.

You can think of Swarm as a hook or controller for all the underlying behaviours.

I feel uncomfortable we bring channels/hooks into higher levels. Channels are like pipes, no house has them visible unless it is for aestetical reasons :)

Here is an example how things get confusing:
Once dispersal_broadcast_sender became dispersal_events_sender. Just one level away we already start forgetting and shifting. Let my un-smartness be a guide here.

dispersal_broadcast_sender: UnboundedSender<DispersalEvent>,

let (dispersal_events_sender, dispersal_events_receiver) = unbounded_channel();

@danielSanchezQ Could not we have something like Event Manager which understands messages, errors? Backend user could just drop data and it will be taken care of ? Any performance penalty for this one more redirect ? WDYT ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just one level away we already start forgetting and shifting
what do you mean by this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just one level away we already start forgetting and shifting
what do you mean by this?

Channel with the same purpose has different names.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just one level away we already start forgetting and shifting
what do you mean by this?

Channel with the same purpose has different names.

Well, yeah, we could make it more consistent in naming. But having the channels go away the layer should be good. I may be missing the point, but I do not think having an extra layer (event manager) would solve anything.

We usually have 3 layers:

-----------------------------
 Core (behaviours + Swarm)
-----------------------------
Backend (network backend service)
-----------------------------
Service
-----------------------------

The most important one is the Service, as the API should not change at all if possible. Imagine we change the core for something else (my most famous exaple: Pigeons). We just need to create a new (pigeons) backend while the service is left untouched. That makes pieces to be changed easily, is basically changing the type in the final overwatch app.

What I wanted to say with all this is that:

  • Wrapping types is ok for the service and backend, if changing types is just a matter of rewrap (into the stream from whatever).
  • Escaping types are not, otherwise is difficult to refactor.

let executor_task = tokio::spawn(async move {
executor.run().await;
});
assert!(executor_task.await.is_ok());
Copy link
Member

Choose a reason for hiding this comment

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

It would be great if you could update the asserts part to listen for responses, we should consider test successful if for all dispersed blobs we'd get DispersalEvent::DispersalSuccess.

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