Skip to content
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

refactor: Migrate parameter configs to YAML #8310

Merged
merged 5 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ serde = { version = "1.0.136", features = ["alloc", "derive", "rc"] }
serde_ignored = "0.1"
serde_json = "1.0.68"
serde_repr = "0.1.8"
serde_yaml = "0.8.26"
sha2 = "0.10"
sha3 = "0.10"
shell-escape = "0.1.5"
Expand Down
1 change: 1 addition & 0 deletions core/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rand.workspace = true
reed-solomon-erasure.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
smart-default.workspace = true
stdx.workspace = true
strum.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions core/primitives/res/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ Stores resource data which is part of the protocol stable enough to be moved out

### `runtime_configs`

All parameter value to configure the runtime are defined in `parameters.txt`.
All parameter value to configure the runtime are defined in `parameters.yaml`.
Parameters added or changed in protocol upgrades are defined in differential
config files with a naming scheme like `V.txt`, where `V` is the new version.
config files with a naming scheme like `V.yaml`, where `V` is the new version.

The content of the base configuration file is one flat list of typed keys and
untyped values. Key names are defined in
`core/primitives-core/src/parameter.rs`.

The format of the differential files is slightly different. Inserting new
parameters uses the same syntax as the base configuration file: `key: value`.
Parameters that change are specified like this: `key: old_value -> new_value`.
parameters uses the following syntax: `key: { new: value }`.
Parameters that change are specified like this: `key: { old: old_value, new: new_value }`.
Removing a previously defined parameter for a new version is done as follows:
`key: old_value ->`. This causes the parameter value to be undefined in newer
`key: { old: old_value }`. This causes the parameter value to be undefined in newer
versions which generally means the default value is used to fill in the
`RuntimeConfig` object.
1 change: 0 additions & 1 deletion core/primitives/res/runtime_configs/42.txt

This file was deleted.

1 change: 1 addition & 0 deletions core/primitives/res/runtime_configs/42.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage_amount_per_byte: { old: 100_000_000_000_000_000_000, new: 10_000_000_000_000_000_000 }
8 changes: 0 additions & 8 deletions core/primitives/res/runtime_configs/48.txt

This file was deleted.

8 changes: 8 additions & 0 deletions core/primitives/res/runtime_configs/48.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
wasm_regular_op_cost: { old: 3_856_371, new: 2_207_874 }
wasm_ecrecover_base: { old: 3_365_369_625_000, new: 278_821_988_457 }
data_receipt_creation_base_send_sir: { old: 4_697_339_419_375, new: 36_486_732_312 }
data_receipt_creation_base_send_not_sir: { old: 4_697_339_419_375, new: 36_486_732_312 }
data_receipt_creation_base_execution: { old: 4_697_339_419_375, new: 36_486_732_312 }
data_receipt_creation_per_byte_send_sir: { old: 59_357_464, new: 17_212_011 }
data_receipt_creation_per_byte_send_not_sir: { old: 59_357_464, new: 17_212_011 }
data_receipt_creation_per_byte_execution: { old: 59_357_464, new: 17_212_011 }
2 changes: 0 additions & 2 deletions core/primitives/res/runtime_configs/49.txt

This file was deleted.

2 changes: 2 additions & 0 deletions core/primitives/res/runtime_configs/49.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
wasm_regular_op_cost: { old: 2_207_874, new: 822_756 }
max_functions_number_per_contract: { new: 10_000 }
1 change: 0 additions & 1 deletion core/primitives/res/runtime_configs/50.txt

This file was deleted.

1 change: 1 addition & 0 deletions core/primitives/res/runtime_configs/50.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stack_limiter_version: { old: 0, new: 1 }
2 changes: 0 additions & 2 deletions core/primitives/res/runtime_configs/52.txt

This file was deleted.

2 changes: 2 additions & 0 deletions core/primitives/res/runtime_configs/52.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
max_gas_burnt: { old: 200_000_000_000_000, new: 300_000_000_000_000 }
max_gas_burnt_view: { old: 200_000_000_000_000, new: 300_000_000_000_000 }
4 changes: 0 additions & 4 deletions core/primitives/res/runtime_configs/53.txt

This file was deleted.

4 changes: 4 additions & 0 deletions core/primitives/res/runtime_configs/53.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
action_deploy_contract_per_byte_execution: { old: 6_812_999, new: 64_572_944 }
wasmer2_stack_limit: { new: 204_800 }
max_length_storage_key: { old: 4_194_304, new: 2_048 }
max_locals_per_contract: { new: 1_000_000 }
1 change: 0 additions & 1 deletion core/primitives/res/runtime_configs/57.txt

This file was deleted.

1 change: 1 addition & 0 deletions core/primitives/res/runtime_configs/57.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
account_id_validity_rules_version: { old: 0, new: 1 }
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pessimistic_gas_price_inflation_denominator: 100

# Account creation config
min_allowed_top_level_account_length: 32
registrar_account_id: registrar
registrar_account_id: "registrar"

# Storage usage config
storage_amount_per_byte: 100_000_000_000_000_000_000
Expand Down Expand Up @@ -156,5 +156,4 @@ max_length_storage_key: 4_194_304
max_length_storage_value: 4_194_304
max_promises_per_function_call_action: 1_024
max_number_input_data_dependencies: 128
stack_limiter_version: 0
account_id_validity_rules_version: 0
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pessimistic_gas_price_inflation_denominator: 100

# Account creation config
min_allowed_top_level_account_length: 0
registrar_account_id: registrar
registrar_account_id: "registrar"

# Storage usage config
storage_amount_per_byte: 100_000_000_000_000_000_000
Expand Down
18 changes: 9 additions & 9 deletions core/primitives/src/runtime/config_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ macro_rules! include_config {

/// The base config file with all initial parameter values defined.
/// Later version are calculated by applying diffs to this base.
static BASE_CONFIG: &str = include_config!("parameters.txt");
static BASE_CONFIG: &str = include_config!("parameters.yaml");

/// Stores pairs of protocol versions for which runtime config was updated and
/// the file containing the diffs in bytes.
static CONFIG_DIFFS: &[(ProtocolVersion, &str)] = &[
(42, include_config!("42.txt")),
(48, include_config!("48.txt")),
(49, include_config!("49.txt")),
(50, include_config!("50.txt")),
(42, include_config!("42.yaml")),
(48, include_config!("48.yaml")),
(49, include_config!("49.yaml")),
(50, include_config!("50.yaml")),
// max_gas_burnt increased to 300 TGas
(52, include_config!("52.txt")),
(52, include_config!("52.yaml")),
// Increased deployment costs, increased wasmer2 stack_limit, added limiting of contract locals,
// set read_cached_trie_node cost, decrease storage key limit
(53, include_config!("53.txt")),
(57, include_config!("57.txt")),
(53, include_config!("53.yaml")),
(57, include_config!("57.yaml")),
];

/// Testnet parameters for versions <= 29, which (incorrectly) differed from mainnet parameters
pub static INITIAL_TESTNET_CONFIG: &str = include_config!("parameters_testnet.txt");
pub static INITIAL_TESTNET_CONFIG: &str = include_config!("parameters_testnet.yaml");

/// Stores runtime config for each protocol version where it was updated.
#[derive(Debug)]
Expand Down
Loading