Config settings summary
- Lenguaje dominante
- Go
- Estrellas
- 121
- Forks
- 63
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
# Settings
An 0chain has a variety of different settings, and setting tyes. We are at the moment in the process of reorganising them into groups.
A setting belongs either to a provider, one of (miner, sharder, blobber, validator, authorizer) or a smart contract, one of (fauset, inerestpool, miner, multisig, storage, vesting, zcn).
Settings can be further split into three types
#### Genesis
These settings are saved to the blockchain during 0cahin genesis. Thereafter they can only be modified with a 0chain transition or viewed with a REST API query. The `.yaml` file these settings are read from can be discarded after the chain has processed its first block.
The plan is to keep these in a `genesis.yaml` file
#### Single provider chain-wide
Settings that change for each individual instance of a provider. These are stored in the blockchain when the provider is added to the 0chain. After being added to an 0chain, these settings can only be changed on the chain with an update transaction and viewed with a REST API query.
The file these settings are read from is only used for the `add_provider` transaction. So the might be used if the provider leaves the chain subsequent to joining, and then later calls `add_provder` again.
The plan is to call these files `0chain_?.yaml`
#### Single provider local
Settings that are local to a particular provider instance. No one else on the chain is interested in these settings. They are stored locally and can be changed by adding the `?.yaml` file and restarting the provide executable.
You can get a good idea of these settings by reading the `?.yaml` file. Typically these are things like database login details.
We should add an endpoint or CLI command to get the currently used local settings directly from the provider.
## Table of settings files
These are the planned file names for each category of settings.
Currently, all genesis settings and all miner and sharder settings are stored in 0cahin.yaml. All blobber settings are in 0chain_blobber.yaml, and validator settings are in 0chain.validator.yaml. We plan to split these three files up to make it clearer what category of setting were are dealing with.
`sc.yaml` contains the settings for smart contracts. Smart contracts do not have access to other settings and other modules should not use these settings. No changes are needed here.
This table tabulates the name of the files the various categories of settings are to be stored in.
| Query settings | Global MPT | Single | Single local |
|----------------- |-------------- |------------------------ |---------------- |
| miner | genesis.yaml | 0chain.miner.yaml | miner.yaml |
| sharder | genesis.yaml | 0chain.sharder.yanml | sharder.yaml |
| blobber | genesis.yaml | 0chian_blobber.yaml | blobber.yaml |
| validator | genesis.yaml | 0chian_validator.yaml | validator.yaml |
| athoriser | genesis.yaml | 0chain.authoriser.yaml | ? |
| faucet sc | sc.yaml | n/a | n/a |
| interestpool sc | sc.yaml | n/a | n/a |
| miner sc | sc.yaml | n/a | n/a |
| multsig sc | n/a | n/a | n/a |
| storage sc | sc.yaml | n/a | n/a |
| vesting sc | sc.yaml | n/a | n/a |
| zcn sc | sc.yaml | n/a | n/a |
[issue 687 Config settings should be added to the blockchain during genesis](https://github.com/0chain/0chain/issues/687),
n/a, smart contracts are all global.
## Update settings process
For data stored on the blockchain we have to use a transaction to change. For locally held settings we change by editing the settings file and restarting the provider.
This table gives either the 0cahin transaction to run to update settings or the file to edit before restarting the provider.
| Update transactions | Global MPT | Single MPT | Single local | Note |
|--------------------- |------------------------------------- |--------------------------------------- |---------------------------- |---------------------------------------------------------- |
| miner | minersc.update_globals | minersc.update_miner_settings | edit local file | |
| sharder | minersc.update_globals | minersc.UpdateSharderSettings | edit local file | |
| blobber | minersc.update_globals | storagesc.update_blobber_settings | edit 0chian_blobber.yaml | |
| validator | minersc.update_globals | *storagesc.update_validator_settings* | edit 0chain_validator.yaml | [issue 773](https://github.com/0chain/0chain/issues/773) |
| athoriser | minersc.update_globals | *zcns.update_authoizer_settings* | edit local file | |
| faucet sc | faucet.update-settings | n/a | n/a | |
| interestpool sc | interestpoolsc.updateVariables | n/a | n/a | |
| miner sc | minersc.updateSettings | n/a | n/a | |
| multsig sc | n/a | n/a | n/a | |
| storage sc | storagesc.update_settings | n/a | n/a | |
| vesting sc | vestingsc.vestingsc-update-settings | n/a | n/a | |
| zcn sc | *zcnsc.update_settings* | n/a | n/a | [issue 881](https://github.com/0chain/0chain/issues/881) |
n/a, smart contracts are all global.
## Query settings
For settings stored on the blockchain, we need to call a REST API endpoint to get the information.
Local settings are read from a local `?.yaml` file. Reading this can give an idea of the settings, but we should add an endpoint to return the local settings currently being used by a particular provider. These settings are not stored on the blockchain so we can not use a transaction.
| Query settings | Global MPT | Single | Single local | Note |
|----------------- |-------------------------- |------------------------- |---------------------------- |---------------------------------------------------------- |
| miner | minersc.globalSettings | minersc.nodeStat | view | |
| sharder | minersc.globalSettings | minersc.nodeStat | view | |
| blobber | minersc.globalSettings | storagesc.getBlobber | view 0chian_blobber.yaml | |
| validator | minersc.globalSettings | storagesc.get_validator | view 0chian_validator.yaml | |
| athoriser | minersc.globalSettings | *zcnsc.get_authoiser* | view | [issue 784](https://github.com/0chain/0chain/issues/784) |
| faucet sc | faucetsc.getConfig | n/a | n/a | |
| interestpool sc | interestpoolsc.getConfig | n/a | n/a | |
| miner sc | minersc.configs | n/a | n/a | |
| multsig sc | n/a | n/a | n/a | |
| storage sc | storagesc.getConfig | n/a | n/a | |
| vesting sc | vesting.getConfig | n/a | n/a | |
| zcn sc | *zcnsc.get_config* | n/a | n/a | [issue 881](https://github.com/0chain/0chain/issues/881) |
n/a, smart contracts are all global.
## Security
Each setting stored on the MPT will have a security setting to indicate who has permission to change that setting.
For global settings, we have the following list
1. Immutable
2. 0chain owner
3. Anyonehttps:
For provider settings
1. Immutable
2. Provider
3. Anyone
For local settings not stored on the blockchain, they can be changed by anyone with access to the filesystem that the provider is running and privileges to restart the provider.
[issue 736 Security level for settings](https://github.com/0chain/0chain/issues/736)
# Colldown
In order to protect against DdOS attacks, we are adding a cooldown period to update settings requests.
#### Open issues
https://github.com/0chain/0chain/issues/881, https://github.com/0chain/0chain/issues/881, https://github.com/0chain/0chain/issues/687, https://github.com/0chain/0chain/issues/736, https://github.com/0chain/0chain/issues/773, https://github.com/0chain/0chain/issues/775, https://github.com/0chain/0chain/issues/776 and https://github.com/0chain/0chain/issues/827.
Guía de contribución
Línea de trabajo
Review the existing configuration files (0chain.yaml, 0chain_blobber.yaml, sc.yaml) to understand the current structure. The task is to reorganize settings into the proposed file groups (genesis.yaml, 0chain.*.yaml, provider.yaml). Check linked issues for context on specific updates needed, such as security levels and cooldown periods. The work involves updating documentation and potentially refactoring configuration loading code.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- blockchain, go, yaml
- Área
- backend, blockchain, documentation
- Tipo de issue
- Documentación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 55/100