linera-io / linera-protocol

Main repository for the Linera protocol
Apache License 2.0
112 stars 94 forks source link

Run service runtime as an actor spawned by the chain worker #2209

Closed jvff closed 3 days ago

jvff commented 3 days ago

Motivation

In order to keep services running across different queries, the ServiceSyncRuntime type must outlive the queries it handles. The runtime must run in a single thread and does not implement Send (because the User{Contract,Service}Instance types used for the loaded_applications does not implement Send). Therefore, the current approach of spawn_blocking the runtime thread only before handling a query does not work.

Proposal

Make the service runtime run as an actor, executing on its own spawn_blocking thread and waiting for ServiceRuntimeRequests to handle. The thread is started by the ChainWorkerActor, in preparation for the next PR which will use the incoming chain worker requests to determine if the runtime should be restarted or not.

Test Plan

Existing CI tests should catch any regressions, as this is an internal refactor.

Release Plan

Nothing needed, because this is an internal refactor.

Links