-
Notifications
You must be signed in to change notification settings - Fork 277
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
[discussion] Align configuration-related instructions with the RFC #4028
Comments
I'm used to mapping an integer constant to some name as an argument in embedded code, but I'm not sure, which Rust feature here, struct or enum, is more convenient. |
To me submitting parameters in the struct (or enum) make more sense than current approach which is unnecessary broad atm, it's aligned with the way i wanted to store parameters initially (here). I would prefer struct with optional fields (this way we would be forward and backward compatible) and it would be possible to update whole config with just one isi, which seems convenient.
Imo iroha should have some default values for such case.
I think we can add this later so that initially we would support only default representations, and then we can extend it with human readable representations. |
A very similar issue has been present for permission tokens and other literals, hope the data model will be exhaustive henceforth. Suggested implementations are fine. As for the defaults I'm generally fine with having ones, though there is an example when it could be confusing. Imagine there is an Iroha upgrade in the future and within the upgrade the defaults are changed. To eliminate the risk of inconsistency or blockstore corruption in that case I'd suggest the peer submitting the genesis to forcibly append an ISI (or transaction with one) with the defaults for missing config entries in the initial genesis provided by the user. As for naming I'd support simplifying those to plain literals as shown above. As for value formats, as @Erigara said, we don't need that flexibility in first place. That might even introduce confusion or user input errors. |
That is a good point. |
Struct or enum?Initially I'd vote for enum, but after @Erigara's point I'm not so sure. Genesis or default?I'd prefer explicit parameters, so I vote for genesis. These parameters could be implemented not just as plain instructions, but as genesis fields which will be transmitted as instructions. Like we do for Flat or namespace format?I have no opinion here. Both is fine to me. I think it depends more on the end-user UX. Human-readable time formatI'm agree with others, to me it seems to be too complicated for now. |
I want to highlight that default values are still required, because we need some parameter values anyway to perform genesis round. |
Summarising the comments and adding some other bits from my side, here is a complete changeset:
@Erigara @Arjentix @Mingela does it look satisfying and complete for you? |
Oh, that complicates my idea... |
Yes, looks nice |
Yeah, lgtm |
Also, there is
|
Also, here is how we can rename the parameters to fit them into a single flat namespace: - sumeragi.block_time
+ block_time
- sumeragi.commit_time
+ commit_time
- sumeragi.max_transactions_in_block
+ max_transactions_in_block
- wsv.transaction_limits
+ wsv_transaction_limits
- wsv.identifier_length_limits
+ wsv_identifier_length_limits
- wsv.domain_metadata_limits
+ wsv_domain_metadata_limits
- wsv.account_metadata_limits
+ wsv_account_metadata_limits
- wsv.asset_definition_metadata_limits
+ wsv_asset_definition_metadata_limits
- wsv.asset_metadata_limits
+ wsv_asset_metadata_limits
- wsv.wasm_runtime.fuel_limit
+ wasm_runtime_fuel_limit
- wsv.wasm_runtime.memory_limit
+ wasm_runtime_memory_limit upd: I forgot that this work is already done in Iroha: So, we can adopt it. |
Could you elaborate on the scenarios the events are gonna be thrown respectively upon? |
|
The whole configuration state will be the easiest and the most fail-safe option I guess |
Overall design so farPoints:
Here is an overview of the updated data model: /// Unified representation of configuration parameter
enum Parameter {
Core(CoreParameter),
Custom(CustomParameter)
}
enum CoreParameter {
BlockTimeMs(u64),
CommitTimeMs(u64),
// -- snip --
}
struct CustomParameter {
id: CustomParameterId,
payload: JsonString
}
/// Unified ID of a [`Parameter`] - needed for event filters
enum ParameterId {
Core(CoreParameterId),
Custom(CustomParameterId)
}
enum CoreParameterId {
BlockTimeMs,
CommitTimeMs,
// -- snip --
}
struct CustomParameterId {
name: Name
}
/// Core parameters as a structure. Convenient for internal use and
/// also as a result of [`QueryBox::FindConfiguration`]
struct CoreParametersState {
block_time_ms: u64,
commit_time_ms: u64
// ...
}
// ***** ISI *****
enum InstructionBox {
// -- snip --
SetParameter(Parameter)
}
// ***** Query *****
enum QueryBox {
// -- snip --
FindConfiguration
}
struct FindConfigurationResult {
/// A complete structure of core parameters
core: CoreParametersState,
custom: Vec<CustomParameter>
}
// ***** Events *****
/// Origin - [`ParameterId`]
enum ConfigurationEvent {
ParameterSet(Parameter),
}
/// Part of the `EventFilter::Data::Configuration` ->
struct ConfigurationEventFilter {
id_matcher: Option<ParameterId>,
/// if there is only one event, we don't need a set for it, do we?
event_set: ConfigurationEventSet
} How setting parameters would look in JSON ISI format: [
{
SetParameter: {
Core: {
BlockTimeMs: 1000
}
}
},
{
SetParameter: {
Custom: {
id: "foo",
payload: {
bar: 42
}
}
}
}
] Questions:
|
I guess we should provide the same interface for core and custom parameters, the special value can be defined for a custom parameter to treat that removed/reset (e.g. 0 or -1 for numerics, empty string, etc) by the parameter creator.
A sequence seems fine. What about allowing an array of parameters to be expected by the ISI? That way a number of specific events can be emitted with a reasonable effort required to support such. |
no, just like we don't support it for permission tokens. You can create/delete a token/parameter by upgrading executor |
I find this unconvincing. |
Summarizing comments & discussion:
|
Thought of an alternative, simpler design, inspired by how Instead of introducing Executor Data Model concept (#4597), we can:
Pros:
Cons:
Will have a prototype and see |
we need Executor Data Model schema, that was a good concept. Users need a query to find out what custom permissions, parameters or instructions are available. We can discuss on how to handle parameters. Excluding parameters data model schema should look like: struct ExecutorDataModel {
permissions: Vec<PermissionId>,
instructions: Vec<Name>,
// parameters: Vec<ParameterId>
schema: JsonString
} having just one query |
@0x009922 can we consider this ticket finished? |
I think so! |
Description
According to the Configuration Overhaul RFC (#2585), the instructions set related to setting chain-wide configuration parameters should be redefined. For more details and reasoning behind it please read the document.
The goal of this issue is to work on the design first, without implementing it. We should establish the design simultaneously with the updating of the configuration reference (hyperledger-iroha/iroha-2-docs#392). Only after the all parts of the reference are consistent and "good enough", we will start implementing it.
Set of chain-wide parameters
sumeragi.block_time
sumeragi.commit_time
sumeragi.max_transactions_in_block
wsv.transaction_limits
wsv.identifier_length_limits
wsv.domain_metadata_limits
wsv.account_metadata_limits
wsv.asset_definition_metadata_limits
wsv.asset_metadata_limits
wsv.wasm_runtime.fuel_limit
wsv.wasm_runtime.memory_limit
Thoughts
Current
NewParameter
andSetParameter
instructions accept any kind of key-value pair. There is a set of "magic keys" which are mapped into config parameters.The core of Iroha has a limited set of parameters. Therefore, I propose to hard-code this set into the data model, and introduce an instruction to set/update parameters using this strictly defined set.
Notes:
wsv.wasm_runtime.fuel_limits
, but justwasm_fuel_limits
. Also, should the naming be aligned with naming of parameters in local configuration file? (or even in env?)"2s 300ms"
. Will the instruction also support it? I think yes, for consistency.How the instruction might look like? I don't have an idea how to do it better.
A structure might look like:
Or a enum?
The text was updated successfully, but these errors were encountered: