You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modules currently own their ModuleStores and are guaranteed exclusive (write-)access to them. But a module may depend on the services of another module. Such a service is usually providing some sort of validation and reading from or writing to the ModuleStore. We need a mechanism through which a module can define how other modules can interact with it and use its services.
This is a proposal for one such system of interfaces to enable inter-module communication heavily inspired by the Cosmos SDK's Keepers concept.
Module design
A module must define the following -
A base type that owns the Store instance and optionally implements the Module trait.
pubstructAuth<S>{store:SharedStore<S>,}
Reader traits that provide read-only access to certain Paths in the ModuleStore. Modules may define multiple Reader traits depending on the granularity of access control required.
Types that implement the Readers and Keepers that the module wants to expose. Ideally, these types are composed out of TypedStores so they only have access to specific store Paths.
// instantiate the application with a KV store implementation of choicelet app = BaseCoinApp::new(InMemoryStore::default()).expect("Failed to init app");// instantiate modules and setup inter-module communication (if required)let auth = Auth::new(app.module_store(&prefix::Auth{}.identifier()));let bank = Bank::new(
app.module_store(&prefix::Bank{}.identifier()),
auth.account_reader(),
auth.account_keeper(),);let ibc = Ibc::new(app.module_store(&prefix::Ibc{}.identifier()));let staking = Staking::new(app.module_store(&prefix::Staking{}.identifier()));// register modules with the applet app = app
.add_module(prefix::Bank{}.identifier(), bank).add_module(prefix::Bank{}.identifier(), ibc.clone());// run the blocking ABCI server on a separate threadlet server = ServerBuilder::new(opt.read_buf_size).bind(format!("{}:{}", opt.host, opt.port), app.clone()).unwrap();
std::thread::spawn(move || {
server.listen().unwrap();});// run the gRPC serverlet grpc_server = Server::builder().add_service(auth.query()).add_service(staking.query())// ....serve(format!("{}:{}", opt.host, opt.grpc_port).parse().unwrap());Runtime::new().unwrap().block_on(async{ grpc_server.await.unwrap()});
The text was updated successfully, but these errors were encountered:
If you're aiming to make this a production-grade framework I'd actually consider getting on a call with Aaron / Ethan Frey at some point to share their learnings.
Modules currently own their
ModuleStore
s and are guaranteed exclusive (write-)access to them. But a module may depend on the services of another module. Such a service is usually providing some sort of validation and reading from or writing to theModuleStore
. We need a mechanism through which a module can define how other modules can interact with it and use its services.This is a proposal for one such system of interfaces to enable inter-module communication heavily inspired by the Cosmos SDK's
Keeper
s concept.Module design
A module must define the following -
Store
instance and optionally implements theModule
trait.Reader
traits that provide read-only access to certainPath
s in theModuleStore
. Modules may define multipleReader
traits depending on the granularity of access control required.Keeper
traits that provide write access to certainPath
s in theModuleStore
.Reader
s andKeeper
s that the module wants to expose. Ideally, these types are composed out ofTypedStore
s so they only have access to specific storePath
s.Reader
s &Keeper
s.Dependent modules
Modules that depend on other modules must provide a ctor that indicates this dependency and must not be constructible in any other way.
App initialization
The text was updated successfully, but these errors were encountered: