Replies: 3 comments 4 replies
-
I don't have the full picture yet, so I'm going to leave notes here before I jump to conclusions/PRs. Generic thoughts:
Side note: I feel that we should strive to use ractor internally but provide interfaces (crates, structs, etc) that don't depend on them so the user can choose to use a different framework. I'm not sure how feasible that is, but it's a good stretch goal. Back to the Host trait: If the topic is the Host trait defined in
Regarding the open questions:
|
Beta Was this translation helpful? Give feedback.
-
One more thing we could do to streamline this process further is to provide a default implementation of the Here is how it might work: Because default type members are still unstable, we cannot do the obvious: use core::marker::PhantomData;
struct SignedMessage<Msg>(PhantomData<Msg>);
enum DefaultVote {
Prevote
}
struct DefaultProposal {}
trait Context {
type Vote = DefaultVote;
type Proposal = DefaultVote;
type Value;
fn new_prevote(&self) -> Self::Vote {
DefaultVote::Prevote
}
fn sign_vote(&self, vote: Self::Vote) -> SignedMessage<Self::Vote>;
// etc.
} Instead we might be able to do something like this, at the expense of a bunch of boilerplate: use core::marker::PhantomData;
struct SignedMessage<Msg>(PhantomData<Msg>);
enum DefaultVote {
Prevote
}
struct DefaultProposal {}
trait Context {
type Vote;
type Proposal;
type Value;
fn new_prevote(&self) -> Self::Vote;
fn sign_vote(&self, vote: Self::Vote) -> SignedMessage<Self::Vote>;
// etc.
}
trait DefaultContext {
type Value;
fn sign_vote(&self, vote: DefaultVote) -> SignedMessage<DefaultVote>;
// etc.
}
impl<T> Context for T where T: DefaultContext {
type Vote = DefaultVote;
type Proposal = DefaultProposal;
type Value = T::Value;
fn new_prevote(&self) -> DefaultVote {
DefaultVote::Prevote
}
fn sign_vote(&self, vote: DefaultVote) -> SignedMessage<DefaultVote> {
<T as DefaultContext>::sign_vote(self, vote)
}
} Applications would then only need to implement the One open question is whether or not to also provide a default Protobuf-based implementation of |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I was just going through all the discussion. I don't have much too add on top of what that has been discussed. Just a few comments:
I agree, we should avoid renaming things using client or server names. Using an actor model it is more related to messaging paradigms if that's what we want. The question should be, if we try to force this into a client/server paradigm will it add constraints on future uses cases that could open up if we stick with the actor model paradigm ? If so, we should consider this fact on renaming things and structuring. I couldn't access Greg's doc, but what I could help in the future is to go over the refactoring and try to implement an app and provide feedback if there are still pain points or not so clear or brittle design patterns. |
Beta Was this translation helpful? Give feedback.
-
This proposal outlines a strategy to streamline the process of defining and running applications on top of Malachite.
Background
Currently, implementing a Malachite application requires multiple manual steps and detailed knowledge of the framework's internals.
This creates unnecessary complexity and potential barriers to adoption.
Current implementation
To develop an application on Malachite, the following steps are currently required:
malachite_common::Context
and associated traitsmalachite_actors::util::codec::NetworkCodec
Host
actor that can receivemalachite_actors::host::HostMsg<_>
messagesmalachite_node::Node
Proposed solution
The solution introduces three distinct integration patterns (actor, channel, and gRPC) through four new crates:
Common functionality (
malachite-app
)malachite-app
crate providing core functionality:malachite-common
undercommon
moduleNetworkCodec
traitmalachite_node::Node
trait toApplication
and move it to themalachite-app
crateActor-based apps (
malachite-app-actor
)malachite-app-actor
cratemalachite_actors
crate underactors
modulerun
function inmalachite-app-actor
which:Context
andNetworkCodec
Channel-based apps (
malachite-app-channel
)malachite-app-channel
crateHost
actor which forwards messages through channel(s)run
function which returns the channel(s) for the app to make use ofgRPC-based apps (
malachite-app-grpc
)malachite-app-grpc
crateHost
actor which performs gRPC calls to a serverrun
function which takes the gRPC server address and starts the hostBenefits
Open Questions
Host
actor be renamed toApplication
?Application
trait as well.Application
trait stay named Node so that we can useApplication
for what is now the host?NetworkCodec
trait be moved tomalachite-common
?malachite-actors
crateContext
andApplication
traits on the same struct? Or is it more flexible to define two structures, one for the context and one for the app?Related concerns
malachite-consensus
, we should ensure that the crate re-exports everything needed, without users having to pull multiple crates.Next Steps
Beta Was this translation helpful? Give feedback.
All reactions