Skip to content

Commit

Permalink
fix(sequencing): fix transactions serializtion (#3149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware authored Jan 7, 2025
1 parent 7849270 commit 12e7766
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"max_amount": "0x0",
"max_price_per_unit": "0x0"
},
"L1_DATA": {
"L1_DATA_GAS": {
"max_amount": "0x0",
"max_price_per_unit": "0x0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"max_amount": "0x0",
"max_price_per_unit": "0x0"
},
"L1_DATA": {
"L1_DATA_GAS": {
"max_amount": "0x0",
"max_price_per_unit": "0x0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"max_amount": "0x0",
"max_price_per_unit": "0x0"
},
"L1_DATA": {
"L1_DATA_GAS": {
"max_amount": "0x0",
"max_price_per_unit": "0x0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use starknet_api::transaction::fields::{
ContractAddressSalt,
Fee,
PaymasterData,
ResourceBounds,
Tip,
TransactionSignature,
ValidResourceBounds,
Expand Down Expand Up @@ -114,14 +115,37 @@ impl From<(ThinStateDiff, BlockInfo, StarknetVersion)> for CentralStateDiff {
}
}

#[derive(Debug, PartialEq, Serialize)]
pub struct CentralResourceBounds {
#[serde(rename = "L1_GAS")]
pub l1_gas: ResourceBounds,
#[serde(rename = "L2_GAS")]
pub l2_gas: ResourceBounds,
#[serde(rename = "L1_DATA_GAS")]
pub l1_data_gas: ResourceBounds,
}

impl From<ValidResourceBounds> for CentralResourceBounds {
fn from(resource_bounds: ValidResourceBounds) -> CentralResourceBounds {
match resource_bounds {
ValidResourceBounds::AllResources(resource_bounds) => CentralResourceBounds {
l1_gas: resource_bounds.l1_gas,
l2_gas: resource_bounds.l2_gas,
l1_data_gas: resource_bounds.l1_data_gas,
},
_ => panic!("Transaction should be V3"),
}
}
}

// TODO(Yael): organize the fields of transactions in the same order.
#[derive(Debug, PartialEq, Serialize)]
pub struct CentralInvokeTransactionV3 {
pub sender_address: ContractAddress,
pub calldata: Calldata,
pub signature: TransactionSignature,
pub nonce: Nonce,
// TODO(yael): Consider defining a type for resource_bounds that matches the python object.
pub resource_bounds: ValidResourceBounds,
pub resource_bounds: CentralResourceBounds,
pub tip: Tip,
pub paymaster_data: PaymasterData,
pub account_deployment_data: AccountDeploymentData,
Expand All @@ -138,7 +162,7 @@ impl From<InvokeTransaction> for CentralInvokeTransactionV3 {
calldata: tx.calldata(),
signature: tx.signature(),
nonce: tx.nonce(),
resource_bounds: tx.resource_bounds(),
resource_bounds: tx.resource_bounds().into(),
tip: tx.tip(),
paymaster_data: tx.paymaster_data(),
account_deployment_data: tx.account_deployment_data(),
Expand All @@ -158,7 +182,7 @@ pub enum CentralInvokeTransaction {

#[derive(Debug, PartialEq, Serialize)]
pub struct CentralDeployAccountTransactionV3 {
pub resource_bounds: ValidResourceBounds,
pub resource_bounds: CentralResourceBounds,
pub tip: Tip,
pub signature: TransactionSignature,
pub nonce: Nonce,
Expand All @@ -175,7 +199,7 @@ pub struct CentralDeployAccountTransactionV3 {
impl From<DeployAccountTransaction> for CentralDeployAccountTransactionV3 {
fn from(tx: DeployAccountTransaction) -> CentralDeployAccountTransactionV3 {
CentralDeployAccountTransactionV3 {
resource_bounds: tx.resource_bounds(),
resource_bounds: tx.resource_bounds().into(),
tip: tx.tip(),
signature: tx.signature(),
nonce: tx.nonce(),
Expand Down Expand Up @@ -204,7 +228,7 @@ fn into_string_tuple(val: SierraVersion) -> (String, String, String) {

#[derive(Debug, PartialEq, Serialize)]
pub struct CentralDeclareTransactionV3 {
pub resource_bounds: ValidResourceBounds,
pub resource_bounds: CentralResourceBounds,
pub tip: Tip,
pub signature: TransactionSignature,
pub nonce: Nonce,
Expand All @@ -224,7 +248,7 @@ pub struct CentralDeclareTransactionV3 {
impl From<DeclareTransaction> for CentralDeclareTransactionV3 {
fn from(tx: DeclareTransaction) -> CentralDeclareTransactionV3 {
CentralDeclareTransactionV3 {
resource_bounds: tx.resource_bounds(),
resource_bounds: tx.resource_bounds().into(),
tip: tx.tip(),
signature: tx.signature(),
nonce: tx.nonce(),
Expand Down

0 comments on commit 12e7766

Please sign in to comment.