Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
feat: add more constants toVersionedConstants
Browse files Browse the repository at this point in the history
- Add gateway constants, these are only for transparency, and aren't
  used directly by the Blockifier whatsoever.
- Pass `validate_max_n_steps` into the blockifier via native_blockifier,
  to override versioned constants defaults.
- Sort json
  • Loading branch information
Gilad Chase committed Jan 25, 2024
1 parent 0c2e2ff commit e0e3eec
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
25 changes: 14 additions & 11 deletions crates/blockifier/resources/versioned_constants.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"gateway": {
"max_calldata_length": 4000,
"max_contract_bytecode_size": 61440
},
"invoke_tx_max_n_steps": 3000000,
"max_recursion_depth": 50,
"validate_max_n_steps": 1000000,
"vm_resource_fee_cost": {

"bitwise_builtin":0.32,
"ec_op_builtin":5.12,
"ecdsa_builtin":10.24,
"keccak_builtin":10.24,
"bitwise_builtin": 0.32,
"ec_op_builtin": 5.12,
"ecdsa_builtin": 10.24,
"keccak_builtin": 10.24,
"n_steps": 0.005,
"output_builtin": 0,
"pedersen_builtin": 0.16,
"poseidon_builtin":0.16,
"range_check_builtin":0.08
},
"invoke_tx_max_n_steps": 3000000,
"max_recursion_depth": 50,
"validate_max_n_steps": 1000000
"poseidon_builtin": 0.16,
"range_check_builtin": 0.08
}
}
3 changes: 3 additions & 0 deletions crates/blockifier/src/versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ static DEFAULT_CONSTANTS: Lazy<VersionedConstants> = Lazy::new(|| {
.expect("Versioned constants json file is malformed")
});

/// Contains constants for the Blockifier that may vary between versions.
/// Additional constants in the JSON file, not used by Blockifier but included for transparency, are
/// automatically ignored during deserialization.
#[derive(Clone, Debug, Default, Deserialize)]
pub struct VersionedConstants {
// Fee related.
Expand Down
4 changes: 3 additions & 1 deletion crates/native_blockifier/src/py_block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ pub struct PyBlockExecutor {
#[pymethods]
impl PyBlockExecutor {
#[new]
#[pyo3(signature = (general_config, max_recursion_depth, target_storage_config))]
#[pyo3(signature = (general_config, validate_max_n_steps, max_recursion_depth, target_storage_config))]
pub fn create(
general_config: PyGeneralConfig,
validate_max_n_steps: u32,
max_recursion_depth: usize,
target_storage_config: StorageConfig,
) -> Self {
Expand All @@ -48,6 +49,7 @@ impl PyBlockExecutor {

let versioned_constants = VersionedConstants {
max_recursion_depth,
validate_max_n_steps,
..VersionedConstants::latest_constants().clone()
};

Expand Down
5 changes: 3 additions & 2 deletions crates/native_blockifier/src/py_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@ pub struct PyValidator {
#[pymethods]
impl PyValidator {
#[new]
#[pyo3(signature = (general_config, state_reader_proxy, next_block_info, max_recursion_depth, max_nonce_for_validation_skip))]
#[pyo3(signature = (general_config, state_reader_proxy, next_block_info, validate_max_n_steps, max_recursion_depth, max_nonce_for_validation_skip))]
pub fn create(
general_config: PyGeneralConfig,
state_reader_proxy: &PyAny,
next_block_info: PyBlockInfo,
validate_max_n_steps: u32,
max_recursion_depth: usize,
max_nonce_for_validation_skip: PyFelt,
) -> NativeBlockifierResult<Self> {
let versioned_constants = VersionedConstants {
max_recursion_depth,
validate_max_n_steps,
..VersionedConstants::latest_constants().clone()
};

let tx_executor = TransactionExecutor::new(
PyStateReader::new(state_reader_proxy),
&general_config,
// TODO(Gilad): add max_validate_n_steps override argument and override here.
&versioned_constants,
next_block_info,
GlobalContractCache::default(),
Expand Down

0 comments on commit e0e3eec

Please sign in to comment.