Skip to content

Commit

Permalink
feat(blockifier): two allocation_cost gas vectors (#2293)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavGrs authored Nov 27, 2024
1 parent 3da1a47 commit 9421def
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 22 deletions.
13 changes: 10 additions & 3 deletions crates/blockifier/resources/versioned_constants_0_13_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
"disable_cairo0_redeclaration": false,
"enable_stateful_compression": false,
"allocation_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
"blob_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
},
"gas_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
}
},
"ignore_inner_event_resources": false,
"enable_reverts": false,
Expand Down
13 changes: 10 additions & 3 deletions crates/blockifier/resources/versioned_constants_0_13_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@
"disable_cairo0_redeclaration": false,
"enable_stateful_compression": false,
"allocation_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
"blob_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
},
"gas_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
}
},
"ignore_inner_event_resources": true,
"enable_reverts": false,
Expand Down
13 changes: 10 additions & 3 deletions crates/blockifier/resources/versioned_constants_0_13_1_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@
"disable_cairo0_redeclaration": false,
"enable_stateful_compression": false,
"allocation_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
"blob_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
},
"gas_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
}
},
"ignore_inner_event_resources": false,
"enable_reverts": false,
Expand Down
13 changes: 10 additions & 3 deletions crates/blockifier/resources/versioned_constants_0_13_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@
"disable_cairo0_redeclaration": true,
"enable_stateful_compression": false,
"allocation_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
"blob_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
},
"gas_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
}
},
"ignore_inner_event_resources": false,
"enable_reverts": false,
Expand Down
13 changes: 10 additions & 3 deletions crates/blockifier/resources/versioned_constants_0_13_2_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@
"disable_cairo0_redeclaration": true,
"enable_stateful_compression": false,
"allocation_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
"blob_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
},
"gas_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
}
},
"ignore_inner_event_resources": false,
"max_recursion_depth": 50,
Expand Down
13 changes: 10 additions & 3 deletions crates/blockifier/resources/versioned_constants_0_13_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@
"disable_cairo0_redeclaration": true,
"enable_stateful_compression": false,
"allocation_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
"blob_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
},
"gas_cost": {
"l1_gas": 0,
"l1_data_gas": 0,
"l2_gas": 0
}
},
"ignore_inner_event_resources": false,
"max_recursion_depth": 50,
Expand Down
13 changes: 10 additions & 3 deletions crates/blockifier/resources/versioned_constants_0_13_4.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@
"disable_cairo0_redeclaration": true,
"enable_stateful_compression": true,
"allocation_cost": {
"l1_gas": 0,
"l1_data_gas": 32,
"l2_gas": 0
"blob_cost": {
"l1_gas": 0,
"l1_data_gas": 32,
"l2_gas": 0
},
"gas_cost": {
"l1_gas": 551,
"l1_data_gas": 0,
"l2_gas": 0
}
},
"ignore_inner_event_resources": false,
"enable_reverts": true,
Expand Down
17 changes: 16 additions & 1 deletion crates/blockifier/src/versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ pub struct VmResourceCosts {
pub builtins: HashMap<BuiltinName, ResourceCost>,
}

#[derive(Clone, Debug, Default, Deserialize)]
pub struct AllocationCost {
pub blob_cost: GasVector,
pub gas_cost: GasVector,
}

impl AllocationCost {
pub const ZERO: AllocationCost =
AllocationCost { blob_cost: GasVector::ZERO, gas_cost: GasVector::ZERO };

pub fn get_cost(&self, use_kzg_da: bool) -> &GasVector {
if use_kzg_da { &self.blob_cost } else { &self.gas_cost }
}
}

// TODO: This (along with the Serialize impl) is implemented in pub(crate) scope in the VM (named
// serde_generic_map_impl); use it if and when it's public.
fn builtin_map_from_string_map<'de, D: Deserializer<'de>>(
Expand Down Expand Up @@ -186,7 +201,7 @@ pub struct VersionedConstants {
// Fee related.
pub(crate) vm_resource_fee_cost: Arc<VmResourceCosts>,
// Cost of allocating a storage cell.
pub allocation_cost: GasVector,
pub allocation_cost: AllocationCost,

// Resources.
os_resources: Arc<OsResources>,
Expand Down

0 comments on commit 9421def

Please sign in to comment.