Skip to content

Commit b39191e

Browse files
committed
Merge branch 'main' into improve-stats
2 parents d2c7e9b + 3a19201 commit b39191e

File tree

19 files changed

+744
-268
lines changed

19 files changed

+744
-268
lines changed

Diff for: Cargo.lock

+664-228
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ dojo-types = { path = "crates/dojo-types" }
6969
dojo-world = { path = "crates/dojo-world" }
7070

7171
# katana
72+
katana-cairo = { path = "crates/katana/cairo" }
7273
katana-codecs = { path = "crates/katana/storage/codecs" }
7374
katana-codecs-derive = { path = "crates/katana/storage/codecs/derive" }
7475
katana-core = { path = "crates/katana/core", default-features = false }

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It is designed to significantly reduce the complexity of developing provable app
1212

1313
## Getting Started
1414

15-
See the [getting started](https://book.dojoengine.org/getting-started/quick-start) section in the Dojo book to start building provable applications with Dojo.
15+
See the [getting started](https://book.dojoengine.org/getting-started) section in the Dojo book to start building provable applications with Dojo.
1616

1717
You can find more detailed documentation in the Dojo Book [here](https://book.dojoengine.org/).
1818

Diff for: bin/sozo/src/main.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ fn main() {
2323
let ui = Ui::new(args.ui_verbosity(), OutputFormat::Text);
2424

2525
if let Err(err) = cli_main(args) {
26-
ui.error(format!("{err}"));
27-
err.chain().skip(1).for_each(|clause| eprintln!("reason: {:?}", clause));
26+
ui.anyhow(&err);
2827
exit(1);
2928
}
3029
}

Diff for: crates/dojo-world/src/migration/strategy.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ pub fn prepare_for_migration(
6969
target_dir: &Utf8PathBuf,
7070
diff: WorldDiff,
7171
) -> Result<MigrationStrategy> {
72-
let entries = fs::read_dir(target_dir)
73-
.map_err(|err| anyhow!("Failed reading source directory: {err}"))?;
72+
let entries = fs::read_dir(target_dir).with_context(|| {
73+
format!(
74+
"Failed trying to read target directory ({target_dir})\nNOTE: build files are profile \
75+
specified so make sure to run build command with correct profile. For e.g. `sozo -P \
76+
my_profile build`"
77+
)
78+
})?;
7479

7580
let mut artifact_paths = HashMap::new();
7681
for entry in entries.flatten() {

Diff for: crates/katana/cairo/Cargo.toml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
description = "Collection of Cairo language dependencies that are used throughout Katana. Unifying the Cairo language based dependencies to avoid dependency conflict with the versions used by Dojo."
3+
edition.workspace = true
4+
license.workspace = true
5+
name = "katana-cairo"
6+
repository.workspace = true
7+
version.workspace = true
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
# Use from git instead of crates.io registry so that the workspace patches aren't applied.
12+
[dependencies]
13+
cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" }
14+
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" }
15+
cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" }
16+
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" }
17+
cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" }
18+
cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" }
19+
cairo-vm = "0.9.2"

Diff for: crates/katana/cairo/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![warn(unused_crate_dependencies)]
2+
3+
//! Re-export of the Cairo language crates used throughout Katana.
4+
5+
pub mod lang {
6+
pub use {
7+
cairo_lang_casm as casm, cairo_lang_runner as runner, cairo_lang_sierra as sierra,
8+
cairo_lang_starknet as starknet, cairo_lang_starknet_classes as starknet_classes,
9+
cairo_lang_utils as utils,
10+
};
11+
}
12+
13+
pub use cairo_vm;

Diff for: crates/katana/executor/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ tracing.workspace = true
2222
alloy-primitives.workspace = true
2323

2424
# blockifier deps
25-
blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "7d866a24", features = [ "testing" ], optional = true }
26-
cairo-vm = { workspace = true, optional = true }
25+
blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "57c11586", features = [ "testing" ], optional = true }
26+
katana-cairo = { workspace = true, optional = true }
2727

2828
# Disable SIR for now until they support Cairo 2.6.3
2929
# # starknet_in_rust deps
@@ -33,7 +33,7 @@ cairo-vm = { workspace = true, optional = true }
3333

3434
[dev-dependencies]
3535
anyhow.workspace = true
36-
cairo-vm.workspace = true
36+
katana-cairo.workspace = true
3737
katana-provider = { workspace = true, features = [ "test-utils" ] }
3838
katana-rpc-types.workspace = true
3939
rstest.workspace = true
@@ -46,7 +46,7 @@ criterion.workspace = true
4646
pprof = { version = "0.13.0", features = [ "criterion", "flamegraph" ] }
4747

4848
[features]
49-
blockifier = [ "dep:blockifier", "dep:cairo-vm" ]
49+
blockifier = [ "dep:blockifier", "dep:katana-cairo" ]
5050
default = [ "blockifier" ]
5151
# native = [ "sir", "sir/cairo-native" ]
5252
# sir = [ "dep:sir", "dep:starknet-types-core" ]

Diff for: crates/katana/executor/benches/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashMap;
22

3-
use cairo_vm::vm::runners::builtin_runner::{
3+
use katana_cairo::cairo_vm::vm::runners::builtin_runner::{
44
BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME,
55
OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME,
66
SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME,

Diff for: crates/katana/executor/src/implementation/blockifier/utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use blockifier::transaction::transactions::{
2626
L1HandlerTransaction,
2727
};
2828
use blockifier::versioned_constants::VersionedConstants;
29-
use cairo_vm::types::errors::program_errors::ProgramError;
30-
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
29+
use katana_cairo::cairo_vm::types::errors::program_errors::ProgramError;
30+
use katana_cairo::cairo_vm::vm::runners::cairo_runner::ExecutionResources;
3131
use katana_primitives::env::{BlockEnv, CfgEnv};
3232
use katana_primitives::fee::TxFeeInfo;
3333
use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses};
@@ -656,7 +656,7 @@ mod tests {
656656

657657
use std::collections::HashSet;
658658

659-
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
659+
use katana_cairo::cairo_vm::vm::runners::cairo_runner::ExecutionResources;
660660
use katana_primitives::chain::{ChainId, NamedChainId};
661661
use starknet_api::core::EntryPointSelector;
662662
use starknet_api::hash::StarkFelt;

Diff for: crates/katana/executor/tests/fixtures/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub mod transaction;
33
use std::collections::HashMap;
44

55
use alloy_primitives::U256;
6-
use cairo_vm::vm::runners::builtin_runner::{
6+
use katana_cairo::cairo_vm::vm::runners::builtin_runner::{
77
BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME,
88
OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME,
99
SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME,

Diff for: crates/katana/primitives/Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ version.workspace = true
99
[dependencies]
1010
anyhow.workspace = true
1111
base64.workspace = true
12-
cairo-vm.workspace = true
1312
derive_more.workspace = true
1413
lazy_static.workspace = true
1514
rand = { workspace = true, features = [ "small_rng" ] }
@@ -24,10 +23,8 @@ strum_macros.workspace = true
2423
thiserror.workspace = true
2524

2625
alloy-primitives.workspace = true
27-
cairo-lang-sierra.workspace = true
28-
cairo-lang-starknet-classes.workspace = true
29-
cairo-lang-starknet.workspace = true
3026
flate2.workspace = true
27+
katana-cairo.workspace = true
3128
starknet_api.workspace = true
3229

3330
[dev-dependencies]

Diff for: crates/katana/primitives/src/class.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
1+
use katana_cairo::lang::sierra::program::Program;
2+
use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass;
3+
use katana_cairo::lang::starknet_classes::contract_class::ContractEntryPoints;
24

35
use crate::FieldElement;
46

@@ -17,8 +19,8 @@ pub type DeprecatedCompiledClass = ::starknet_api::deprecated_contract_class::Co
1719
#[derive(Debug, Clone, Eq, PartialEq)]
1820
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1921
pub struct SierraProgram {
20-
pub program: cairo_lang_sierra::program::Program,
21-
pub entry_points_by_type: cairo_lang_starknet_classes::contract_class::ContractEntryPoints,
22+
pub program: Program,
23+
pub entry_points_by_type: ContractEntryPoints,
2224
}
2325

2426
#[derive(Debug, Clone, Eq, PartialEq)]

Diff for: crates/katana/primitives/src/conversion/rpc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::io::{self, Read, Write};
33
use std::mem;
44

55
use anyhow::{Context, Result};
6-
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
6+
use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass;
77
use serde::Deserialize;
88
use serde_json::json;
99
use serde_with::serde_as;
@@ -186,10 +186,10 @@ pub fn legacy_rpc_to_compiled_class(
186186
/// [ContractClass](cairo_lang_starknet::contract_class::ContractClass) type.
187187
fn rpc_to_cairo_contract_class(
188188
contract_class: &FlattenedSierraClass,
189-
) -> Result<cairo_lang_starknet_classes::contract_class::ContractClass, std::io::Error> {
189+
) -> Result<katana_cairo::lang::starknet_classes::contract_class::ContractClass, std::io::Error> {
190190
let value = serde_json::to_value(contract_class)?;
191191

192-
Ok(cairo_lang_starknet_classes::contract_class::ContractClass {
192+
Ok(katana_cairo::lang::starknet_classes::contract_class::ContractClass {
193193
abi: serde_json::from_value(value["abi"].clone()).ok(),
194194
sierra_program: serde_json::from_value(value["sierra_program"].clone())?,
195195
entry_points_by_type: serde_json::from_value(value["entry_points_by_type"].clone())?,

Diff for: crates/katana/primitives/src/genesis/json.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use std::sync::Arc;
1212

1313
use alloy_primitives::U256;
1414
use base64::prelude::*;
15-
use cairo_lang_starknet_classes::casm_contract_class::StarknetSierraCompilationError;
16-
use cairo_vm::types::errors::program_errors::ProgramError;
15+
use katana_cairo::cairo_vm::types::errors::program_errors::ProgramError;
16+
use katana_cairo::lang::starknet_classes::casm_contract_class::StarknetSierraCompilationError;
1717
use serde::de::value::MapAccessDeserializer;
1818
use serde::de::Visitor;
1919
use serde::{Deserialize, Serialize};

Diff for: crates/katana/primitives/src/utils/class.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
2-
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
3-
use cairo_lang_starknet_classes::contract_class::ContractClass;
2+
use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass;
3+
use katana_cairo::lang::starknet_classes::contract_class::ContractClass;
44
use serde_json::Value;
55

66
use crate::class::{

Diff for: crates/sozo/ops/src/migration/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ where
7575
|e| {
7676
ui.error(e.to_string());
7777
anyhow!(
78-
"\n Use `sozo clean` to clean your project, or `sozo clean --manifests-abis` \
79-
to clean manifest and abi files only.\nThen, rebuild your project with `sozo \
80-
build`.",
78+
"\n Use `sozo clean` to clean your project.\nThen, rebuild your project with \
79+
`sozo build`.",
8180
)
8281
},
8382
)?;

Diff for: crates/torii/core/src/engine.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::HashMap;
1+
use std::collections::BTreeMap;
22
use std::time::Duration;
33

44
use anyhow::Result;
@@ -207,7 +207,7 @@ impl<P: Provider + Sync> Engine<P> {
207207
&mut self,
208208
from: u64,
209209
to: u64,
210-
mut pending_block_tx: Option<FieldElement>,
210+
pending_block_tx: Option<FieldElement>,
211211
) -> Result<Option<FieldElement>> {
212212
// Process all blocks from current to latest.
213213
let get_events = |token: Option<String>| {
@@ -232,10 +232,11 @@ impl<P: Provider + Sync> Engine<P> {
232232

233233
// Transactions & blocks to process
234234
let mut last_block = 0_u64;
235-
let mut blocks = HashMap::new();
235+
let mut blocks = BTreeMap::new();
236236

237237
// Flatten events pages and events according to the pending block cursor
238238
// to array of (block_number, transaction_hash)
239+
let mut pending_block_tx_cursor = pending_block_tx;
239240
let mut transactions = vec![];
240241
for events_page in &events_pages {
241242
for event in &events_page.events {
@@ -269,14 +270,20 @@ impl<P: Provider + Sync> Engine<P> {
269270

270271
// Then we skip all transactions until we reach the last pending processed
271272
// transaction (if any)
272-
if let Some(tx) = pending_block_tx {
273+
if let Some(tx) = pending_block_tx_cursor {
273274
if event.transaction_hash != tx {
274275
continue;
275276
}
276277

277-
// Then we skip that processed transaction
278-
pending_block_tx = None;
279-
continue;
278+
pending_block_tx_cursor = None;
279+
}
280+
281+
// Skip the latest pending block transaction events
282+
// * as we might have multiple events for the same transaction
283+
if let Some(tx) = pending_block_tx {
284+
if event.transaction_hash == tx {
285+
continue;
286+
}
280287
}
281288

282289
if let Some((_, last_tx_hash)) = transactions.last() {

Diff for: crates/torii/graphql/src/query/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ fn build_type_mapping(
6565
})
6666
.collect::<sqlx::Result<TypeMapping>>()?;
6767

68-
println!("{:#?}", type_mapping);
69-
7068
Ok(type_mapping)
7169
}
7270

0 commit comments

Comments
 (0)