Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,870 changes: 1,559 additions & 311 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ debug = true
inherits = "release"

[workspace.dependencies]
cainome = { version = "0.10.1", features = [ "abigen-rs" ] }
cainome-cairo-serde = { version = "0.4.1" }
cainome = { git = "https://github.com/cartridge-gg/cainome", branch = "types-rs-100-blake2s", features = [ "abigen-rs" ] }
cainome-cairo-serde = { git = "https://github.com/cartridge-gg/cainome", branch = "types-rs-100-blake2s" }

dojo-utils = { path = "crates/dojo/utils" }

Expand All @@ -80,9 +80,9 @@ sozo-walnut = { path = "crates/sozo/walnut" }
merge-options = { path = "crates/macros/merge-options" }

# On the branch to support rpc 0.9 (incl starknet bump)
katana-runner = { git = "https://github.com/dojoengine/katana", rev = "eba352a" }
katana-runner = { git = "https://github.com/dojoengine/katana", branch = "types-rs-100-blake2s" }

anyhow = "1.0.89"
anyhow = "1"
arbitrary = { version = "1.3.2", features = [ "derive" ] }
assert_fs = "1.1"
assert_matches = "1.5.0"
Expand All @@ -91,7 +91,7 @@ auto_impl = "1.2.0"
base64 = "0.21.2"
bigdecimal = "0.4.1"
bytes = "1.6"
cairo-lang-starknet-classes = "2.13.1"
cairo-lang-starknet-classes = "=2.13.1"
camino = { version = "1.1.2", features = [ "serde1" ] }
chrono = { version = "0.4.24", features = [ "serde" ] }
clap = { version = "4.5.16", features = [ "derive", "env", "string" ] }
Expand Down Expand Up @@ -138,14 +138,13 @@ salsa = "0.16.1"
scarb-metadata = "1.15.1"
semver = "1.0.5"
serde = { version = "1.0", features = [ "derive" ] }
serde_json = { version = "1.0.142", features = [ "arbitrary_precision" ] }
serde_json = { version = "1", features = [ "arbitrary_precision" ] }
serde_with = "3.11.0"
similar-asserts = "1.5.0"
smol_str = { version = "0.3", features = [ "serde" ] }
spinoff = "0.8.0"
sqlx = { version = "0.8.2", features = [ "chrono", "macros", "regexp", "runtime-async-std", "runtime-tokio", "sqlite", "uuid" ] }
#starknet_api = "0.11.0"
starknet_api = { git = "https://github.com/dojoengine/sequencer", rev = "802c5dc" }
starknet_api = "0.16.0-rc.1"
strum = "0.25"
strum_macros = "0.25"
tempfile = "3.9.0"
Expand All @@ -169,12 +168,10 @@ mime_guess = "2.0"
hyper = "1.5"
warp = "0.3"

# Slot integration. Dojo don't need to manually include `account_sdk` as dependency as `slot` already re-exports it.
slot-core = { git = "https://github.com/cartridge-gg/slot", branch = "compartmentalization" }
slot-session = { git = "https://github.com/cartridge-gg/slot", branch = "compartmentalization" }
slot = { git = "https://github.com/cartridge-gg/slot", branch = "types-rs-100-blake2s" }

starknet = "0.17"
starknet-crypto = "0.8"
starknet-types-core = { version = "0.2", features = [ "arbitrary", "hash" ] }
starknet = { git = "https://github.com/dojoengine/starknet-rs", branch = "feat/types-rs-100-blake2s" }
starknet-crypto = { git = "https://github.com/dojoengine/starknet-rs", branch = "feat/types-rs-100-blake2s" }
starknet-types-core = { version = "1.0.0", features = [ "arbitrary", "hash" ] }

bitvec = "1.0.1"
5 changes: 2 additions & 3 deletions bin/sozo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
slot-core = { workspace = true, optional = true }
slot-session = { workspace = true, optional = true }
slot = { workspace = true, optional = true }

anyhow.workspace = true
async-trait.workspace = true
Expand Down Expand Up @@ -54,7 +53,7 @@ serde_json.workspace = true
[features]
default = [ "controller", "walnut" ]

controller = [ "dep:slot-core", "dep:slot-session" ]
controller = [ "dep:slot" ]
walnut = [ "dep:sozo-walnut", "sozo-ops/walnut" ]

[[bench]]
Expand Down
5 changes: 5 additions & 0 deletions bin/sozo/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,16 @@ impl BuildArgs {
// directly during the compilation to get the data we need from it.
bindgen.generate(None).await?;

// During the build, the class hashes are not used. Set to true as default since it
// will be the standard once 0.14.1 hits mainnet.
let use_blake2s_casm_class_hash = true;

if self.stats != StatOptions::default() {
let world = WorldLocal::from_directory(
scarb_metadata.target_dir_profile(),
&scarb_metadata.current_profile,
scarb_metadata.load_dojo_profile_config().unwrap(),
use_blake2s_casm_class_hash,
)?;

let world_stat = world.to_stat_item();
Expand Down
2 changes: 1 addition & 1 deletion bin/sozo/src/commands/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async fn match_event<P: Provider + Send + Sync>(
let block_id = if let Some(block_number) = block_number {
BlockId::Number(block_number)
} else {
BlockId::Tag(BlockTag::PreConfirmed)
BlockId::Tag(BlockTag::Latest)
};

let (name, content) = match event {
Expand Down
24 changes: 11 additions & 13 deletions bin/sozo/src/commands/options/account/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ use std::collections::HashMap;

use anyhow::{bail, Result};
use dojo_world::contracts::contract_info::ContractInfo;
use slot_session::account_sdk::account::session::account::SessionAccount;
use slot_session::account_sdk::account::session::merkle::MerkleTree;
use slot_session::account_sdk::account::session::policy::{
CallPolicy, MerkleLeaf, Policy, ProvedPolicy,
};
use slot_session::account_sdk::provider::CartridgeJsonRpcProvider;
use slot_session::{FullSessionInfo, PolicyMethod};
use slot::account_sdk::account::session::account::SessionAccount;
use slot::account_sdk::account::session::merkle::MerkleTree;
use slot::account_sdk::account::session::policy::{CallPolicy, MerkleLeaf, Policy, ProvedPolicy};
use slot::account_sdk::provider::CartridgeJsonRpcProvider;
use slot::session::{FullSessionInfo, PolicyMethod};
use starknet::core::types::Felt;
use starknet::core::utils::get_selector_from_name;
use starknet::macros::felt;
Expand Down Expand Up @@ -40,7 +38,7 @@ pub async fn create_controller(
let chain_id = rpc_provider.chain_id().await?;

trace!(target: "account::controller", "Loading Slot credentials.");
let credentials = slot_core::credentials::Credentials::load()?;
let credentials = slot::credential::Credentials::load()?;
let username = credentials.account.id;

// Right now, the Cartridge Controller API ensures that there's always a Controller associated
Expand All @@ -52,7 +50,7 @@ pub async fn create_controller(
let policies = collect_policies(contract_address, contracts)?;

// Check if the session exists, if not create a new one
let session_details = match slot_session::get(chain_id)? {
let session_details = match slot::session::get(chain_id)? {
Some(session) => {
trace!(target: "account::controller", expires_at = %session.session.inner.expires_at, policies = session.session.proved_policies.len(), "Found existing session.");

Expand All @@ -69,17 +67,17 @@ pub async fn create_controller(
"Policies have changed. Creating new session."
);

let session = slot_session::create(rpc_url.clone(), &policies).await?;
slot_session::store(chain_id, &session)?;
let session = slot::session::create(rpc_url.clone(), &policies).await?;
slot::session::store(chain_id, &session)?;
session
}
}

// Create a new session if not found
None => {
trace!(target: "account::controller", %username, chain = format!("{chain_id:#}"), "Creating new session.");
let session = slot_session::create(rpc_url.clone(), &policies).await?;
slot_session::store(chain_id, &session)?;
let session = slot::session::create(rpc_url.clone(), &policies).await?;
slot::session::store(chain_id, &session)?;
session
}
};
Expand Down
8 changes: 4 additions & 4 deletions bin/sozo/src/commands/options/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use dojo_utils::env::DOJO_ACCOUNT_ADDRESS_ENV_VAR;
use dojo_world::config::Environment;
use dojo_world::contracts::ContractInfo;
#[cfg(feature = "controller")]
use slot_session::account_sdk::provider::CartridgeJsonRpcProvider;
use slot::account_sdk::provider::CartridgeJsonRpcProvider;
use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount};
use starknet::core::types::{BlockId, BlockTag, Felt};
use starknet::providers::Provider;
Expand Down Expand Up @@ -130,9 +130,9 @@ impl AccountOptions {
let mut account =
SingleOwnerAccount::new(provider, signer, account_address, chain_id, encoding);

// The default is `Latest` in starknet-rs, which does not reflect
// the nonce changes in the pending block.
account.set_block_id(BlockId::Tag(BlockTag::PreConfirmed));
// Since now the block frequency is higher than before, using latest is
// totally fine. We keep it explicitely set here to easy toggle if necessary.
account.set_block_id(BlockId::Tag(BlockTag::Latest));
Comment on lines +133 to +135
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in comment.

Ohayo sensei! The updated comment is much clearer and addresses the previous confusion about BlockTag behavior. Good fix! However, there's a small typo: "explicitely" should be "explicitly".

Apply this diff to fix the typo:

-        // Since now the block frequency is higher than before, using latest is
-        // totally fine. We keep it explicitely set here to easy toggle if necessary.
+        // Since now the block frequency is higher than before, using latest is
+        // totally fine. We keep it explicitly set here to easy toggle if necessary.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Since now the block frequency is higher than before, using latest is
// totally fine. We keep it explicitely set here to easy toggle if necessary.
account.set_block_id(BlockId::Tag(BlockTag::Latest));
// Since now the block frequency is higher than before, using latest is
// totally fine. We keep it explicitly set here to easy toggle if necessary.
account.set_block_id(BlockId::Tag(BlockTag::Latest));
🤖 Prompt for AI Agents
In bin/sozo/src/commands/options/account/mod.rs around lines 133 to 135, there's
a typo in the comment: change "explicitely" to "explicitly" so the comment reads
correctly; update the comment text accordingly on that line.

Ok(account)
}

Expand Down
4 changes: 2 additions & 2 deletions bin/sozo/src/commands/options/account/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use async_trait::async_trait;
#[cfg(feature = "controller")]
use slot_session::account_sdk::provider::CartridgeJsonRpcProvider;
use slot::account_sdk::provider::CartridgeJsonRpcProvider;
use starknet::accounts::{
single_owner, Account, ConnectedAccount, ExecutionEncoder, RawDeclarationV3, RawExecutionV3,
SingleOwnerAccount,
Expand All @@ -28,7 +28,7 @@ pub enum SozoAccountSignError {

#[cfg(feature = "controller")]
#[error(transparent)]
Controller(#[from] slot_session::account_sdk::signers::SignError),
Controller(#[from] slot::account_sdk::signers::SignError),
}

/// To unify the account types, we define a wrapper type that implements the
Expand Down
8 changes: 8 additions & 0 deletions bin/sozo/src/commands/options/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ pub struct StarknetOptions {
#[arg(help = "The Starknet RPC endpoint.")]
#[arg(global = true)]
pub rpc_url: Option<Url>,

#[arg(long, default_value = "false")]
#[arg(help = "Whether to use the blake2s class hash, which is currently required for \
Sepolia. Sozo will attempt to detect the chain id from the rpc url and set \
this flag automatically if the RPC URL contains `sepolia` or `testnet`. \
Otherwise, use this flag to manually set it.")]
#[arg(global = true)]
pub use_blake2s_casm_class_hash: bool,
}

impl StarknetOptions {
Expand Down
4 changes: 2 additions & 2 deletions bin/sozo/src/commands/options/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ pub struct TransactionOptions {
#[arg(long)]
#[arg(help = "The finality status to wait for. Since 0.14, the nodes syncing is sometime \
not fast enough to propagate the transaction to the nodes in the \
PRE-CONFIRMED state. The default is ACCEPTED_ON_L2. Available options are: \
PRE-CONFIRMED, ACCEPTED_ON_L2, ACCEPTED_ON_L1.")]
PRE_CONFIRMED state. The default is ACCEPTED_ON_L2. Available options are: \
PRE_CONFIRMED, ACCEPTED_ON_L2, ACCEPTED_ON_L1.")]
#[arg(global = true)]
#[arg(default_value = "ACCEPTED_ON_L2")]
pub finality_status: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions bin/sozo/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::commands::options::world::WorldOptions;
/// providers.
pub const MAX_BLOCK_RANGE: u64 = 200_000;

pub const RPC_SPEC_VERSION: &str = "0.9.0-rc.2";
pub const RPC_SPEC_VERSION: &str = "0.9.0";

pub const CALLDATA_DOC: &str = "
Space separated values e.g., 0x12345 128 u256:9999999999 str:'hello world'.
Expand Down Expand Up @@ -96,7 +96,7 @@ pub async fn get_world_diff_and_provider(
scarb_metadata: &Metadata,
ui: &SozoUi,
) -> Result<(WorldDiff, JsonRpcClient<HttpTransport>, String)> {
let world_local = scarb_metadata.load_dojo_world_local()?;
let world_local = scarb_metadata.load_dojo_world_local(starknet.use_blake2s_casm_class_hash)?;
let profile_config = scarb_metadata.load_dojo_profile_config()?;

let env = profile_config.env.as_ref();
Expand Down
10 changes: 9 additions & 1 deletion crates/dojo/bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ fn gather_dojo_data(
)));
}

let world_local = WorldLocal::from_directory(&target_dir, profile_name, profile_config)?;
// TODO: Currently, the class hashes are not used by the bindgen.
// However, we would need to surface it in the future.
let use_blake2s_casm_class_hash = false;
let world_local = WorldLocal::from_directory(
&target_dir,
profile_name,
profile_config,
use_blake2s_casm_class_hash,
)?;

let mut models = HashMap::new();
let mut contracts = HashMap::new();
Expand Down
Loading
Loading