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

feat(state-sync) State sync actors #9669

Merged
merged 5 commits into from
Oct 24, 2023

Conversation

VanBarbascu
Copy link
Contributor

Create dummy state sync actors.
Wrap them in an adapter that will be used to command and control them from client and network.

nearcore/src/lib.rs Show resolved Hide resolved
use super::adapter::SyncMessageForClient;
use near_network::state_sync::SyncActorMessageForNetwork;
struct MessageSenders {
client_adapter: Sender<SyncMessageForClient>,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: feel free to leave as is, but these two fields could just go directly in struct SyncActor right? seems simpler to me that way but it's a style preference, do it as you like it

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 would keep them bundled.

use tracing::log::info;

use super::adapter::SyncMessageForClient;
use near_network::state_sync::SyncActorMessageForNetwork;
Copy link
Contributor

Choose a reason for hiding this comment

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

appears to be missing. Also, another nit on this and the SyncMessageForClient, but why not just call them something simpler like SyncMessage? We know it's meant for the network because it's in the near_network crate, and same for SyncMessageForClient, since it's defined by near_client

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 went for SyncMessage. My intention was to keep it clear where is this message intended to be used.

Copy link
Contributor

Choose a reason for hiding this comment

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

where ... intended to be used

A good API is about what an object does and not about for what purpose it should be used.

Copy link
Contributor

Choose a reason for hiding this comment

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

where ... intended to be used

A good API is about what an object does and not about for what purpose it should be used.

Sure, but I think the point still stands to be honest, because what it does is already covered by the name SyncMessage right? Like, I think it would be strange if we renamed near_network::types::NetworkRequests::Block to near_network::types::NetworkRequests::BlockForNetwork

Copy link
Contributor

Choose a reason for hiding this comment

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

@marcelo-gonzalez I agree with you and my comment supported your point :)

chain/client/src/sync/adapter.rs Outdated Show resolved Hide resolved
chain/client/src/sync/adapter.rs Outdated Show resolved Hide resolved
chain/client/src/sync/adapter.rs Show resolved Hide resolved
chain/client/src/sync/adapter.rs Outdated Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Outdated Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Outdated Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Show resolved Hide resolved
@VanBarbascu VanBarbascu force-pushed the state-sync-actors branch 2 times, most recently from 68f230d to 070d128 Compare October 19, 2023 09:31
@gmilescu gmilescu added the Node Node team label Oct 19, 2023
chain/client/src/sync/sync_actor.rs Outdated Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Outdated Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Outdated Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Show resolved Hide resolved
chain/client/src/sync/sync_actor.rs Outdated Show resolved Hide resolved
where
M: Message + Send + 'static,
M::Result: Send,

Copy link
Contributor

Choose a reason for hiding this comment

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

The empty line seems unnecessary.

@VanBarbascu VanBarbascu added this pull request to the merge queue Oct 24, 2023
Merged via the queue into near:master with commit fdf1cd0 Oct 24, 2023
9 checks passed
@VanBarbascu VanBarbascu deleted the state-sync-actors branch October 24, 2023 18:30
marcelo-gonzalez added a commit to marcelo-gonzalez/nearcore that referenced this pull request Oct 26, 2023
This is the first step in moving the state sync logic to model where
one thread per shard will be started. Here we move the part
application logic from `SyncJobsActor to the `SyncActor` added in
near#9669. This means that the core
of the logic is still in the client actor, but the requests to apply
parts will be sent to different threads running these `SyncActor`s.

In an ideal world, we'll be able to separate out more of the logic so
that each of these actors can interact with the network layer, taking
responsibility for downloading/requesting the parts themselves, but
for now this PR will just take the first step towards that and set
things up.

Also we make a few changes to the scaffolding added in near#9669
to make things easier/more direct.
 * don't initialize the `SyncArbiter` in
   `nearcore::start_with_config()` like all the others, but instead
   just make it a field in the `ClientActor`, since its logic has no
   need to run separately in another thread or something. It's just
   managing the threads that the `ClientActor` knows how to start (how
   many, when to start them, etc). that means we don't need to store
   the client and network actors in that struct.

 * change `ShardUId` to `ShardId` throughout just to make things a
   little easier, since it shouldn't be incorrect. If there's a change
   in shard layout version, we can still just send requests to actors
   by shard ID
nikurt pushed a commit that referenced this pull request Nov 2, 2023
Create dummy state sync actors.
Wrap them in an adapter that will be used to command and control them
from client and network.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Node Node team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DSS] Move downloading logic from Client Actor to StateSync Actor
4 participants