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

[stateless_validation] Add a soft size limit for state witness #10703

Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions core/parameters/res/runtime_configs/83.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
state_witness_size_soft_limit: {old: 999_999_999_999_999, new: 16_000_000}
2 changes: 1 addition & 1 deletion core/parameters/res/runtime_configs/parameters.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
---
burnt_gas_reward 3 / 10
pessimistic_gas_price_inflation 103 / 100
state_witness_size_soft_limit 999_999_999_999_999
min_allowed_top_level_account_length 65
registrar_account_id registrar
storage_amount_per_byte 10000000000000000000
Expand Down Expand Up @@ -180,4 +181,3 @@ function_call_weight true
vm_kind NearVm
eth_implicit_accounts false
yield_resume false

3 changes: 3 additions & 0 deletions core/parameters/res/runtime_configs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pessimistic_gas_price_inflation: {
denominator: 100,
}

# Stateless validation config
state_witness_size_soft_limit: 999_999_999_999_999

# Account creation config
min_allowed_top_level_account_length: 32
registrar_account_id: "registrar"
Expand Down
3 changes: 3 additions & 0 deletions core/parameters/res/runtime_configs/parameters_testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pessimistic_gas_price_inflation: {
denominator: 100,
}

# Stateless validation config
state_witness_size_soft_limit: 999_999_999_999_999

# Account creation config
min_allowed_top_level_account_length: 0
registrar_account_id: "registrar"
Expand Down
1 change: 1 addition & 0 deletions core/parameters/src/config_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static CONFIG_DIFFS: &[(ProtocolVersion, &str)] = &[
(62, include_config!("62.yaml")),
(63, include_config!("63.yaml")),
(64, include_config!("64.yaml")),
(83, include_config!("83.yaml")),
(129, include_config!("129.yaml")),
// Introduce ETH-implicit accounts.
(138, include_config!("138.yaml")),
Expand Down
5 changes: 5 additions & 0 deletions core/parameters/src/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ pub struct RuntimeFeesConfig {

/// Pessimistic gas price inflation ratio.
pub pessimistic_gas_price_inflation_ratio: Rational32,

/// The maximum size of the state witness after which we defer execution of any new receipts.
pub state_witness_size_soft_limit: usize,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is not a part of the LimitConfig? It is a limit after all.

If its because LimitConfig itself is a part of vm::Config, then I think we might want to "just" move the LimitConfig such that it is no longer as specific to VM. On the other hand, it doesn't matter either way: we can easily change the place of the parameter in the future so long as we take care to keep the RuntimeConfigView backwards compatible.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you could move it to RuntimeConfig proper.

Copy link
Contributor Author

@shreyan-gupta shreyan-gupta Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, I anticipate more stateless validation related configs like state witness hard_limit for individual contracts etc. to come in. I personally wasn't sure whether I should create a new struct like StatelessValidationConfig in RuntimeConfig or just put it in RuntimeFeesConfig.

Yes, I don't like vm::Config for this as it seems specific to VMs and state_witness_size_soft_limit is technically used outside the VM.

Not too sure what do do here, but like you suggested, let me try to move this to RuntimeConfig proper.

}

/// Describes cost of storage per block
Expand Down Expand Up @@ -466,6 +469,7 @@ impl RuntimeFeesConfig {
execution: 200_000_000_000,
},
},
state_witness_size_soft_limit: usize::MAX,
}
}

Expand All @@ -477,6 +481,7 @@ impl RuntimeFeesConfig {
storage_usage_config: StorageUsageConfig::free(),
burnt_gas_reward: Rational32::from_integer(0),
pessimistic_gas_price_inflation_ratio: Rational32::from_integer(0),
state_witness_size_soft_limit: usize::MAX,
}
}

Expand Down
3 changes: 3 additions & 0 deletions core/parameters/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub enum Parameter {
BurntGasReward,
PessimisticGasPriceInflation,

// Stateless validation config
StateWitnessSizeSoftLimit,

// Account creation config
MinAllowedTopLevelAccountLength,
RegistrarAccountId,
Expand Down
1 change: 1 addition & 0 deletions core/parameters/src/parameter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ impl TryFrom<&ParameterTable> for RuntimeConfig {
num_bytes_account: params.get(Parameter::StorageNumBytesAccount)?,
num_extra_bytes_record: params.get(Parameter::StorageNumExtraBytesRecord)?,
},
state_witness_size_soft_limit: params.get(Parameter::StateWitnessSizeSoftLimit)?,
},
wasm_config: Config {
ext_costs: ExtCostsConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 16000000
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 16000000
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 16000000
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ expression: config_view
"pessimistic_gas_price_inflation_ratio": [
103,
100
]
],
"state_witness_size_soft_limit": 999999999999999
},
"wasm_config": {
"ext_costs": {
Expand Down
Loading
Loading