Skip to content

Commit

Permalink
hack: restore JSON API compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed May 20, 2022
1 parent 0b5b31b commit 8d3cb59
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 14 deletions.
13 changes: 13 additions & 0 deletions core/primitives-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,15 @@ pub struct ExtCostsConfig {
/// Cost of calling `validator_total_stake`.
pub validator_total_stake_base: Gas,

// Workaround to keep JSON serialization backwards-compatible
// <https://github.com/near/nearcore/pull/6587#discussion_r876113324>.
//
// Remove once #5516 is fixed.
#[serde(default, rename = "contract_compile_base")]
pub _unused1: Gas,
#[serde(default, rename = "contract_compile_bytes")]
pub _unused2: Gas,

// #############
// # Alt BN128 #
// #############
Expand Down Expand Up @@ -477,6 +486,8 @@ impl ExtCostsConfig {
promise_return: SAFETY_MULTIPLIER * 186717462,
validator_stake_base: SAFETY_MULTIPLIER * 303944908800,
validator_total_stake_base: SAFETY_MULTIPLIER * 303944908800,
_unused1: 0,
_unused2: 0,
#[cfg(feature = "protocol_feature_alt_bn128")]
alt_bn128_g1_multiexp_base: 713_000_000_000,
#[cfg(feature = "protocol_feature_alt_bn128")]
Expand Down Expand Up @@ -547,6 +558,8 @@ impl ExtCostsConfig {
promise_return: 0,
validator_stake_base: 0,
validator_total_stake_base: 0,
_unused1: 0,
_unused2: 0,
#[cfg(feature = "protocol_feature_alt_bn128")]
alt_bn128_g1_multiexp_base: 0,
#[cfg(feature = "protocol_feature_alt_bn128")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 3856371,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 3856371,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 2207874,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 3856371,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 3856371,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 2207874,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ expression: store.get_config(*version)
"promise_and_per_promise": 5452176,
"promise_return": 560152386,
"validator_stake_base": 911834726400,
"validator_total_stake_base": 911834726400
"validator_total_stake_base": 911834726400,
"contract_compile_base": 0,
"contract_compile_bytes": 0
},
"grow_mem_cost": 1,
"regular_op_cost": 822756,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ fn ext_costs_config(cost_table: &CostTable) -> anyhow::Result<ExtCostsConfig> {
// TODO: accurately price host functions that expose validator information.
validator_stake_base: 303944908800,
validator_total_stake_base: 303944908800,
_unused1: 0,
_unused2: 0,
#[cfg(feature = "protocol_feature_alt_bn128")]
alt_bn128_g1_sum_base: get(Cost::AltBn128G1SumBase)?,
#[cfg(feature = "protocol_feature_alt_bn128")]
Expand Down

0 comments on commit 8d3cb59

Please sign in to comment.