Skip to content

Commit

Permalink
feat(rpc/v08): add l1_data_gas to v3 transaction resource bounds
Browse files Browse the repository at this point in the history
This is a partial implementation: since we don't _really_ use these
new values other than passing those on to the Starknet gateway when
submitting new transactions the new field is not added to the
`ResourceBounds` type in the common crate.

We'll have to do that once these values need to be stored in storage
and used in the P2P protocol when adding proper support for Starknet
0.13.4.

Closes: #2379
  • Loading branch information
kkovaacs committed Nov 15, 2024
1 parent 7395898 commit c89bd8a
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/gateway-types/src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,14 @@ pub mod transaction {
pub l1_gas: ResourceBound,
#[serde(rename = "L2_GAS")]
pub l2_gas: ResourceBound,
// Introduced in Starknet v0.13.4. This has to be optional because not sending it to the
// gateway is not equivalent to sending an explicit zero bound.
#[serde(
default,
skip_serializing_if = "Option::is_none",
rename = "L1_DATA_GAS"
)]
pub l1_data_gas: Option<ResourceBound>,
}

impl From<ResourceBounds> for pathfinder_common::transaction::ResourceBounds {
Expand All @@ -816,6 +824,8 @@ pub mod transaction {
Self {
l1_gas: value.l1_gas.into(),
l2_gas: value.l2_gas.into(),
// TODO: add this when adding support for Starknet 0.13.4
l1_data_gas: None,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/rpc/fixtures/0.6.0/broadcasted_transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@
],
"nonce": "0x8",
"resource_bounds": {
"l1_data_gas": {
"max_amount": "0x3333",
"max_price_per_unit": "0x4444"
},
"l1_gas": {
"max_amount": "0x1111",
"max_price_per_unit": "0x2222"
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/src/method/add_declare_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ mod tests {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0),
paymaster_data: vec![],
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/src/method/add_deploy_account_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ mod tests {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0),
paymaster_data: vec![],
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/src/method/add_invoke_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ mod tests {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0),
paymaster_data: vec![],
Expand Down
9 changes: 9 additions & 0 deletions crates/rpc/src/v02/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub mod syncing;
pub struct ResourceBounds {
pub l1_gas: ResourceBound,
pub l2_gas: ResourceBound,
#[serde(skip_serializing_if = "Option::is_none")]
pub l1_data_gas: Option<ResourceBound>,
}

impl crate::dto::DeserializeForVersion for ResourceBounds {
Expand All @@ -21,6 +23,7 @@ impl crate::dto::DeserializeForVersion for ResourceBounds {
Ok(Self {
l1_gas: value.deserialize("l1_gas")?,
l2_gas: value.deserialize("l2_gas")?,
l1_data_gas: value.deserialize_optional("l1_data_gas")?,
})
})
}
Expand Down Expand Up @@ -907,6 +910,7 @@ pub mod request {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0x1234),
paymaster_data: vec![
Expand Down Expand Up @@ -976,6 +980,7 @@ pub mod request {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0x1234),
paymaster_data: vec![
Expand Down Expand Up @@ -1006,6 +1011,10 @@ pub mod request {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: Some(ResourceBound {
max_amount: ResourceAmount(0x3333),
max_price_per_unit: ResourcePricePerUnit(0x4444),
}),
},
tip: Tip(0x1234),
paymaster_data: vec![
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/src/v06/method/add_declare_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ mod tests {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0),
paymaster_data: vec![],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ mod tests {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0),
paymaster_data: vec![],
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/src/v06/method/add_invoke_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ mod tests {
max_amount: ResourceAmount(0),
max_price_per_unit: ResourcePricePerUnit(0),
},
l1_data_gas: None,
},
tip: Tip(0),
paymaster_data: vec![],
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/src/v06/method/simulate_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ pub(crate) mod tests {
max_amount: ResourceAmount(10000),
max_price_per_unit: ResourcePricePerUnit(100000000),
},
l1_data_gas: None,
},
tip: Tip(0),
paymaster_data: vec![],
Expand Down

0 comments on commit c89bd8a

Please sign in to comment.