Skip to content

Commit

Permalink
fix(katana): breaking changes due to blockifier update (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Jun 6, 2023
1 parent 352677d commit 987d17b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 31 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/katana-core/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Sequencer for KatanaSequencer {

let sender = match &account_transaction {
AccountTransaction::Invoke(tx) => tx.sender_address(),
AccountTransaction::Declare(tx) => tx.tx.sender_address(),
AccountTransaction::Declare(tx) => tx.tx().sender_address(),
AccountTransaction::DeployAccount(tx) => tx.contract_address,
};

Expand Down
4 changes: 2 additions & 2 deletions crates/katana-core/src/starknet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use blockifier::transaction::account_transaction::AccountTransaction;
use blockifier::transaction::errors::TransactionExecutionError;
use blockifier::transaction::objects::{AccountTransactionContext, TransactionExecutionInfo};
use blockifier::transaction::transaction_execution::Transaction;
use blockifier::transaction::transactions::{DeclareTransaction, ExecutableTransaction};
use blockifier::transaction::transactions::ExecutableTransaction;
use starknet::core::types::{FieldElement, StateUpdate, TransactionStatus};
use starknet_api::block::{BlockHash, BlockNumber, BlockTimestamp, GasPrice};
use starknet_api::core::{ClassHash, ContractAddress, GlobalRoot, PatriciaKey};
Expand Down Expand Up @@ -254,7 +254,7 @@ impl StarknetWrapper {
let max_fee = match transaction {
AccountTransaction::Invoke(tx) => tx.max_fee(),
AccountTransaction::DeployAccount(tx) => tx.max_fee,
AccountTransaction::Declare(DeclareTransaction { tx, .. }) => match tx {
AccountTransaction::Declare(tx) => match tx.tx() {
starknet_api::transaction::DeclareTransaction::V0(tx) => tx.max_fee,
starknet_api::transaction::DeclareTransaction::V1(tx) => tx.max_fee,
starknet_api::transaction::DeclareTransaction::V2(tx) => tx.max_fee,
Expand Down
3 changes: 1 addition & 2 deletions crates/katana-core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use blockifier::execution::contract_class::ContractClassV1 as BlockifierContract
use blockifier::state::cached_state::CommitmentStateDiff;
use blockifier::transaction::account_transaction::AccountTransaction;
use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction;
use blockifier::transaction::transactions::DeclareTransaction;
use cairo_lang_starknet::casm_contract_class::CasmContractClass;
use flate2::bufread::GzDecoder;
use serde_json::json;
Expand Down Expand Up @@ -57,7 +56,7 @@ pub fn convert_blockifier_tx_to_starknet_api_tx(
constructor_calldata: tx.constructor_calldata.clone(),
})
}
AccountTransaction::Declare(DeclareTransaction { tx, .. }) => match tx {
AccountTransaction::Declare(tx) => match tx.tx() {
starknet_api::transaction::DeclareTransaction::V0(tx) => {
Transaction::Declare(starknet_api::transaction::DeclareTransaction::V0(
starknet_api::transaction::DeclareTransactionV0V1 {
Expand Down
60 changes: 36 additions & 24 deletions crates/katana-rpc/src/starknet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,15 @@ impl<S: Sequencer + Send + Sync + 'static> StarknetApiServer for StarknetRpc<S>
tx.signature.into_iter().map(StarkFelt::from).collect(),
),
};
AccountTransaction::Declare(DeclareTransaction {
tx: starknet_api::transaction::DeclareTransaction::V1(transaction),
contract_class: blockifier::execution::contract_class::ContractClass::V0(
contract_class,
),
})
AccountTransaction::Declare(
DeclareTransaction::new(
starknet_api::transaction::DeclareTransaction::V1(transaction),
blockifier::execution::contract_class::ContractClass::V0(
contract_class,
),
)
.map_err(|_| Error::from(StarknetApiError::InternalServerError))?,
)
}
BroadcastedTransaction::Declare(BroadcastedDeclareTransaction::V2(tx)) => {
let raw_class_str = serde_json::to_string(&tx.contract_class)?;
Expand Down Expand Up @@ -780,12 +783,15 @@ impl<S: Sequencer + Send + Sync + 'static> StarknetApiServer for StarknetRpc<S>
)),
};

AccountTransaction::Declare(DeclareTransaction {
tx: starknet_api::transaction::DeclareTransaction::V2(transaction),
contract_class: blockifier::execution::contract_class::ContractClass::V1(
contract_class,
),
})
AccountTransaction::Declare(
DeclareTransaction::new(
starknet_api::transaction::DeclareTransaction::V2(transaction),
blockifier::execution::contract_class::ContractClass::V1(
contract_class,
),
)
.map_err(|_| Error::from(StarknetApiError::InternalServerError))?,
)
}

BroadcastedTransaction::Invoke(BroadcastedInvokeTransaction::V1(transaction)) => {
Expand Down Expand Up @@ -880,12 +886,15 @@ impl<S: Sequencer + Send + Sync + 'static> StarknetApiServer for StarknetRpc<S>
(
transaction_hash,
class_hash,
AccountTransaction::Declare(DeclareTransaction {
tx: starknet_api::transaction::DeclareTransaction::V1(transaction),
contract_class: blockifier::execution::contract_class::ContractClass::V0(
contract_class,
),
}),
AccountTransaction::Declare(
DeclareTransaction::new(
starknet_api::transaction::DeclareTransaction::V1(transaction),
blockifier::execution::contract_class::ContractClass::V0(
contract_class,
),
)
.map_err(|_| Error::from(StarknetApiError::InternalServerError))?,
),
)
}
BroadcastedDeclareTransaction::V2(tx) => {
Expand Down Expand Up @@ -923,12 +932,15 @@ impl<S: Sequencer + Send + Sync + 'static> StarknetApiServer for StarknetRpc<S>
(
transaction_hash,
class_hash,
AccountTransaction::Declare(DeclareTransaction {
tx: starknet_api::transaction::DeclareTransaction::V2(transaction),
contract_class: blockifier::execution::contract_class::ContractClass::V1(
contract_class,
),
}),
AccountTransaction::Declare(
DeclareTransaction::new(
starknet_api::transaction::DeclareTransaction::V2(transaction),
blockifier::execution::contract_class::ContractClass::V1(
contract_class,
),
)
.map_err(|_| Error::from(StarknetApiError::InternalServerError))?,
),
)
}
};
Expand Down
6 changes: 5 additions & 1 deletion crates/sozo/src/ops/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::{anyhow, Context, Result};
use scarb::core::Config;
use starknet::accounts::{Account, ConnectedAccount, SingleOwnerAccount};
use starknet::core::types::{BlockId, BlockTag, InvokeTransactionResult, StarknetError};
use starknet::core::utils::cairo_short_string_to_felt;
use starknet::providers::jsonrpc::HttpTransport;
use starknet::providers::{JsonRpcClient, Provider, ProviderError};

Expand Down Expand Up @@ -144,7 +145,10 @@ where

let res = world
.deploy(
vec![strategy.executor.as_ref().unwrap().contract_address.unwrap()],
vec![
cairo_short_string_to_felt("placeholder").unwrap(),
strategy.executor.as_ref().unwrap().contract_address.unwrap(),
],
&migrator,
)
.await
Expand Down

0 comments on commit 987d17b

Please sign in to comment.