Skip to content

Commit

Permalink
Merge pull request #2410 from eqlabs/vbar/resource-bounds-with-data-gas
Browse files Browse the repository at this point in the history
feat: l1_data_gas in ResourceBounds
  • Loading branch information
vbar authored Nov 27, 2024
2 parents 57a6b10 + 60c1ef0 commit 71ab4f3
Show file tree
Hide file tree
Showing 11 changed files with 435 additions and 66 deletions.
4 changes: 4 additions & 0 deletions crates/common/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ pub enum EntryPointType {
pub struct ResourceBounds {
pub l1_gas: ResourceBound,
pub l2_gas: ResourceBound,
pub l1_data_gas: Option<ResourceBound>,
}

#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Dummy)]
Expand Down Expand Up @@ -1103,6 +1104,7 @@ mod tests {
max_price_per_unit: ResourcePricePerUnit(0x2540be400),
},
l2_gas: Default::default(),
l1_data_gas: Default::default(),
},
sender_address: contract_address!(
"0x2fab82e4aef1d8664874e1f194951856d48463c3e6bf9a8c68e234a629a6f50"
Expand Down Expand Up @@ -1222,6 +1224,7 @@ mod tests {
max_price_per_unit: ResourcePricePerUnit(0x5af3107a4000),
},
l2_gas: Default::default(),
l1_data_gas: Default::default(),
},
constructor_calldata: vec![call_param!(
"0x5cd65f3d7daea6c63939d659b8473ea0c5cd81576035a4d34e52fb06840196c"
Expand Down Expand Up @@ -1411,6 +1414,7 @@ mod tests {
max_price_per_unit: ResourcePricePerUnit(0x5af3107a4000),
},
l2_gas: Default::default(),
l1_data_gas: Default::default(),
},
sender_address: contract_address!(
"0x35acd6dd6c5045d18ca6d0192af46b335a5402c02d41f46e4e77ea2c951d9a3"
Expand Down
1 change: 1 addition & 0 deletions crates/gateway-types/src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ pub mod transaction {
Self {
l1_gas: value.l1_gas.into(),
l2_gas: value.l2_gas.into(),
l1_data_gas: value.l1_data_gas.map(|g| g.into()),
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions crates/p2p/src/client/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ impl ToDto<p2p_proto::transaction::TransactionVariant> for TransactionVariant {
resource_bounds: p2p_proto::transaction::ResourceBounds {
l1_gas: x.resource_bounds.l1_gas.to_dto(),
l2_gas: x.resource_bounds.l2_gas.to_dto(),
l1_data_gas: x.resource_bounds.l1_data_gas.map(|g| g.to_dto()),
},
tip: x.tip.0,
paymaster_data: x.paymaster_data.into_iter().map(|p| p.0).collect(),
Expand Down Expand Up @@ -235,6 +236,7 @@ impl ToDto<p2p_proto::transaction::TransactionVariant> for TransactionVariant {
resource_bounds: p2p_proto::transaction::ResourceBounds {
l1_gas: x.resource_bounds.l1_gas.to_dto(),
l2_gas: x.resource_bounds.l2_gas.to_dto(),
l1_data_gas: x.resource_bounds.l1_data_gas.map(|g| g.to_dto()),
},
tip: x.tip.0,
paymaster_data: x.paymaster_data.into_iter().map(|p| p.0).collect(),
Expand Down Expand Up @@ -269,6 +271,7 @@ impl ToDto<p2p_proto::transaction::TransactionVariant> for TransactionVariant {
resource_bounds: p2p_proto::transaction::ResourceBounds {
l1_gas: x.resource_bounds.l1_gas.to_dto(),
l2_gas: x.resource_bounds.l2_gas.to_dto(),
l1_data_gas: x.resource_bounds.l1_data_gas.map(|g| g.to_dto()),
},
tip: x.tip.0,
paymaster_data: x.paymaster_data.into_iter().map(|p| p.0).collect(),
Expand Down Expand Up @@ -804,6 +807,16 @@ impl TryFromDto<p2p_proto::transaction::ResourceBounds> for ResourceBounds {
dto.l2_gas.max_price_per_unit.try_into()?,
),
},
l1_data_gas: if let Some(g) = dto.l1_data_gas {
Some(ResourceBound {
max_amount: pathfinder_common::ResourceAmount(g.max_amount.try_into()?),
max_price_per_unit: pathfinder_common::ResourcePricePerUnit(
g.max_price_per_unit.try_into()?,
),
})
} else {
None
},
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/p2p_proto/proto/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ message ResourceLimits {
message ResourceBounds {
ResourceLimits l1_gas = 1;
ResourceLimits l2_gas = 2;
optional ResourceLimits l1_data_gas = 3;
}

message AccountSignature {
Expand Down
2 changes: 2 additions & 0 deletions crates/p2p_proto/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub struct ResourceLimits {
pub struct ResourceBounds {
pub l1_gas: ResourceLimits,
pub l2_gas: ResourceLimits,
#[optional]
pub l1_data_gas: Option<ResourceLimits>,
}

#[derive(Debug, Clone, PartialEq, Eq, ToProtobuf, TryFromProtobuf, Dummy)]
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl From<ResourceBounds> for pathfinder_common::transaction::ResourceBounds {
Self {
l1_gas: resource_bounds.l1_gas.into(),
l2_gas: resource_bounds.l2_gas.into(),
l1_data_gas: resource_bounds.l1_data_gas.map(|g| g.into()),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/rpc/src/v06/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ mod tests {
max_price_per_unit: ResourcePricePerUnit(10),
},
l2_gas: Default::default(),
l1_data_gas: Default::default(),
},
tip: Tip(5),
paymaster_data: vec![],
Expand Down Expand Up @@ -658,6 +659,7 @@ mod tests {
max_price_per_unit: ResourcePricePerUnit(10),
},
l2_gas: Default::default(),
l1_data_gas: Default::default(),
},
tip: Tip(5),
paymaster_data: vec![],
Expand Down Expand Up @@ -770,6 +772,7 @@ mod tests {
max_price_per_unit: ResourcePricePerUnit(10),
},
l2_gas: Default::default(),
l1_data_gas: Default::default(),
},
tip: Tip(5),
paymaster_data: vec![],
Expand Down
Loading

0 comments on commit 71ab4f3

Please sign in to comment.