...
More details on initial research:
View file | ||||
---|---|---|---|---|
|
Problem
Integrations with different tools from Blockchain ecosystem required additional changes in Iroha 1.0 and Михаил Болдыревwith Andrei Lebedevhad to build more levels of abstractions to support them.
Data Model solution is an attempt to make Iroha "backend" more extensible without need to change already existing parts.
Solution
A data model (further referred to as DM) is a business model abstraction. It may provide interfaces to execute some commands and query some state. A DM implementation is a module that can be attached to an Iroha node. In that case, the set of commands delivered to a DM module is strictly determined by the ledger, which enables to build extensible blockchain applications.
Data Model approach gives an ability to extend basic Peer-side (server-side) functionality with general purpose languages (python, C++, etc.) and environments.
Iroha Users can deploy payload schemes for commands and queries:
Code Block | ||||
---|---|---|---|---|
| ||||
message Set {
string key = 1;
string value = 2;
}
message Nuke {}
message Command {
// extends CallModel
message Payload {
oneof command {
Set set = 1;
Nuke nuke = 2;
}
}
Payload payload = 1;
.iroha.protocol.DataModelId dm_id = 2;
}
|
And their implementations:
Expand | ||
---|---|---|
|
Implementation has no strict API, so it can work with disk and network I/O, use available libraries, global static memory, etc.
It also has no Iroha API inside, but it can be added if needed.
Decisions
- Use protobuf schema for Commands and Queries payloads
- Commands and Queries implementation should align to appropriate interfaces (rollback_block, load_persistent, etc.)
- Executor makes a decision to proceed with command/query or not
Alternatives
- Use client-side transformers and adapters to support 3rd party tools via Client-side Iroha API
- Use already existing WASM runtimes as a backend
Concerns
- No strict requirements to environment is powerful yet dangerous solution
- Solution did not align well with Iroha 2.0 in it's current form
Assumptions
- Clients and Iroha use gRPC or another protocol with Protobuf
- Custom commands and queries has no obvious API for Iroha
Risks
- Protobuf will not be enough for 3rd party applications and users `[9;7]`
- Powerful environments will require a lot of resources `[9;5]`