Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Nov 1, 2024
2 parents 84251fe + af63e5f commit 5d96621
Show file tree
Hide file tree
Showing 57 changed files with 4,806 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
- name: Build binaries
run: cargo build --release --bins --target ${{ matrix.job.target }}
run: cargo build --profile performance --bins --target ${{ matrix.job.target }}

- name: Archive binaries
id: artifacts
Expand Down
71 changes: 61 additions & 10 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
"crates/katana/storage/db",
"crates/katana/storage/provider",
"crates/katana/tasks",
"crates/katana/trie",
"crates/metrics",
"crates/saya/core",
"crates/saya/provider",
Expand Down Expand Up @@ -100,6 +101,7 @@ katana-rpc-types-builder = { path = "crates/katana/rpc/rpc-types-builder" }
katana-runner = { path = "crates/katana/runner" }
katana-slot-controller = { path = "crates/katana/controller" }
katana-tasks = { path = "crates/katana/tasks" }
katana-trie = { path = "crates/katana/trie" }

# torii
torii-client = { path = "crates/torii/client" }
Expand Down Expand Up @@ -254,4 +256,6 @@ alloy-transport = { version = "0.3", default-features = false }

starknet = "0.12.0"
starknet-crypto = "0.7.1"
starknet-types-core = { version = "0.1.6", features = [ "arbitrary" ] }
starknet-types-core = { version = "0.1.7", features = [ "arbitrary", "hash" ] }

bitvec = "1.0.1"
8 changes: 1 addition & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ LABEL description="Dojo is a provable game engine and toolchain for building onc
source="https://github.com/dojoengine/dojo" \
documentation="https://book.dojoengine.org/"

COPY --from=artifacts $TARGETPLATFORM/katana /usr/local/bin/katana
COPY --from=artifacts $TARGETPLATFORM/sozo /usr/local/bin/sozo
COPY --from=artifacts $TARGETPLATFORM/torii /usr/local/bin/torii
COPY --from=artifacts --chmod=755 $TARGETPLATFORM/katana $TARGETPLATFORM/sozo $TARGETPLATFORM/torii /usr/local/bin/

COPY --from=builder /usr/local/bin/curtail /usr/local/bin/curtail

RUN chmod +x /usr/local/bin/katana \
&& chmod +x /usr/local/bin/sozo \
&& chmod +x /usr/local/bin/torii
13 changes: 10 additions & 3 deletions bin/sozo/src/commands/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ impl ExecuteArgs {
let txn_config: TxnConfig = self.transaction.into();

Check warning on line 81 in bin/sozo/src/commands/execute.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/execute.rs#L81

Added line #L81 was not covered by tests

config.tokio_handle().block_on(async {

Check warning on line 83 in bin/sozo/src/commands/execute.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/execute.rs#L83

Added line #L83 was not covered by tests
let (world_diff, account, _) =
utils::get_world_diff_and_account(self.account, self.starknet, self.world, &ws)
.await?;
// We could save the world diff computation extracting the account directly from the
// options.
let (world_diff, account, _) = utils::get_world_diff_and_account(
self.account,
self.starknet.clone(),
self.world,
&ws,
&mut None,

Check warning on line 91 in bin/sozo/src/commands/execute.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/execute.rs#L91

Added line #L91 was not covered by tests
)
.await?;

let contract_address = match &descriptor {
ContractDescriptor::Address(address) => Some(*address),
Expand Down
25 changes: 14 additions & 11 deletions bin/sozo/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use colored::Colorize;
use dojo_utils::{self, TxnConfig};
use dojo_world::contracts::WorldContract;
use scarb::core::{Config, Workspace};
use sozo_ops::migrate::{Migration, MigrationResult, MigrationUi};
use sozo_ops::migrate::{Migration, MigrationResult};
use sozo_ops::migration_ui::MigrationUi;
use sozo_scarbext::WorkspaceExt;
use spinoff::{spinner, spinners, Spinner};
use starknet::core::utils::parse_cairo_short_string;
use starknet::providers::Provider;
use tabled::settings::Style;
Expand Down Expand Up @@ -45,17 +45,19 @@ impl MigrateArgs {

let MigrateArgs { world, starknet, account, .. } = self;

let frames = spinner!(["⛩️ ", "🎃", "👻", "🧟", "💀"], 500);
// let frames = spinner!(["⛩️ ", "🥷 ", "🗡️ "], 500);

config.tokio_handle().block_on(async {
print_banner(&ws, &starknet).await?;

let mut spinner =
MigrationUi::Spinner(Spinner::new(frames, "Evaluating world diff...", None));
let mut spinner = MigrationUi::new("Evaluating world diff...");

let (world_diff, account, rpc_url) =
utils::get_world_diff_and_account(account, starknet, world, &ws).await?;
let (world_diff, account, rpc_url) = utils::get_world_diff_and_account(
account,
starknet,
world,
&ws,
&mut Some(&mut spinner),
)
.await?;

Check warning on line 60 in bin/sozo/src/commands/migrate.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/migrate.rs#L53-L60

Added lines #L53 - L60 were not covered by tests

let world_address = world_diff.world_info.address;

Expand Down Expand Up @@ -84,7 +86,7 @@ impl MigrateArgs {
("🎃", format!("No changes for world at address {:#066x}", world_address))
};

spinner.stop_and_persist(symbol, Box::leak(end_text.into_boxed_str()));
spinner.stop_and_persist_boxed(symbol, end_text);

Ok(())
})
Expand All @@ -100,7 +102,8 @@ pub struct Banner {

/// Prints the migration banner.
async fn print_banner(ws: &Workspace<'_>, starknet: &StarknetOptions) -> Result<()> {
let (provider, rpc_url) = starknet.provider(None)?;
let profile_config = ws.load_profile_config()?;
let (provider, rpc_url) = starknet.provider(profile_config.env.as_ref())?;

let chain_id = provider.chain_id().await?;
let chain_id = parse_cairo_short_string(&chain_id)
Expand Down
2 changes: 1 addition & 1 deletion bin/sozo/src/commands/options/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl AccountOptions {
let account_address = self.account_address(env_metadata)?;

let signer = self.signer.signer(env_metadata, false)?;
trace!(?signer, "Signer obtained.");

trace!("Fetching chain id...");
let chain_id = provider.chain_id().await?;
trace!(?chain_id);

Expand Down
4 changes: 2 additions & 2 deletions bin/sozo/src/commands/options/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub struct StarknetOptions {

impl StarknetOptions {
/// The default request timeout in milliseconds. This is not the transaction inclusion timeout.
/// Refer to [`dojo_utils::tx::waiter::TransactionWaiter::DEFAULT_TIMEOUT`] for the transaction inclusion
/// timeout.
/// Refer to [`dojo_utils::tx::waiter::TransactionWaiter::DEFAULT_TIMEOUT`] for the transaction
/// inclusion timeout.
const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_secs(30);

/// Returns a [`JsonRpcClient`] and the rpc url.
Expand Down
11 changes: 11 additions & 0 deletions bin/sozo/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dojo_world::local::WorldLocal;
use katana_rpc_api::starknet::RPC_SPEC_VERSION;
use scarb::core::{TomlManifest, Workspace};
use semver::Version;
use sozo_ops::migration_ui::MigrationUi;
use sozo_scarbext::WorkspaceExt;
use starknet::accounts::{Account, ConnectedAccount};
use starknet::core::types::Felt;
Expand Down Expand Up @@ -144,19 +145,29 @@ pub async fn get_world_diff_and_account(
starknet: StarknetOptions,
world: WorldOptions,
ws: &Workspace<'_>,
ui: &mut Option<&mut MigrationUi>,

Check warning on line 148 in bin/sozo/src/utils.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/utils.rs#L148

Added line #L148 was not covered by tests
) -> Result<(WorldDiff, SozoAccount<JsonRpcClient<HttpTransport>>, String)> {
let profile_config = ws.load_profile_config()?;
let env = profile_config.env.as_ref();

let (world_diff, provider, rpc_url) =
get_world_diff_and_provider(starknet.clone(), world, ws).await?;

// Ensures we don't interfere with the spinner if a password must be prompted.
if let Some(ui) = ui {
ui.stop();
}

Check warning on line 159 in bin/sozo/src/utils.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/utils.rs#L157-L159

Added lines #L157 - L159 were not covered by tests

let account = {
account
.account(provider, world_diff.world_info.address, &starknet, env, &world_diff)
.await?
};

if let Some(ui) = ui {
ui.restart("Verifying account...");
}

Check warning on line 169 in bin/sozo/src/utils.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/utils.rs#L167-L169

Added lines #L167 - L169 were not covered by tests

if !dojo_utils::is_deployed(account.address(), &account.provider()).await? {
return Err(anyhow!("Account with address {:#x} doesn't exist.", account.address()));
}
Expand Down
Loading

0 comments on commit 5d96621

Please sign in to comment.