Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add walnut flag to sozo execute and migrate apply commands #2333

Merged
merged 51 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ebf6761
feat: add sierra to cairo debug information
glihm Aug 22, 2024
f4e2712
Add walnut flag to sozo execute command
barabanovro Aug 22, 2024
550f5bf
Pass rpc url to handle_transaction_result
barabanovro Aug 23, 2024
056d98d
Merge remote-tracking branch 'dojo/main' into feat/walnut-debug-info
glihm Aug 24, 2024
2627286
Add walnut flag to sozo migrate apply command
barabanovro Aug 28, 2024
46d97a9
Move walnut_debug_transaction to walnut crate
barabanovro Aug 28, 2024
143f99a
Cargo fmt
barabanovro Aug 28, 2024
c46b373
Keep only one global walnut flag
barabanovro Aug 29, 2024
a8d9ac4
Add comments
barabanovro Aug 29, 2024
d8eb7e2
Add walnut flag to sozo execute command
barabanovro Aug 22, 2024
a900b4c
Pass rpc url to handle_transaction_result
barabanovro Aug 23, 2024
f8801ab
Add walnut flag to sozo migrate apply command
barabanovro Aug 28, 2024
b47dc41
Move walnut_debug_transaction to walnut crate
barabanovro Aug 28, 2024
2e8b436
Cargo fmt
barabanovro Aug 28, 2024
10739f9
Keep only one global walnut flag
barabanovro Aug 29, 2024
d20d8d1
Add comments
barabanovro Aug 29, 2024
c3ed863
Resolve conflicts
barabanovro Sep 2, 2024
bc78ed2
Merge branch 'sozo-execute-with-walnut' of /~https://github.com/walnuth…
barabanovro Sep 2, 2024
19bf7d3
Fix lint errors
barabanovro Sep 2, 2024
a26a5d4
Merge branch 'feat/walnut-debug-info' into sozo-execute-with-walnut
barabanovro Sep 3, 2024
336626b
Put the walnut crate under the /sozo dir
barabanovro Sep 4, 2024
c830c94
Add constants with API and app URLs
barabanovro Sep 4, 2024
d394aa0
Warn where we fail silently
barabanovro Sep 4, 2024
0c3fa95
Remove unnecessary comments
barabanovro Sep 4, 2024
c0933cc
Check Walnut API key before migration
barabanovro Sep 4, 2024
302b2a0
Add doc comments
barabanovro Sep 4, 2024
9d3147f
Disable walnut flag in auto_authorize
barabanovro Sep 6, 2024
ac47e81
chore; use debug for pending tx log (#2383)
Larkooo Sep 3, 2024
3ac3149
refactor(katana-rpc): `getEvents` include pending block (#2375)
kariy Sep 4, 2024
a320d56
refactor(katana): move predeployedAccounts under DevApi and remove Ka…
glihm Sep 4, 2024
b610620
remove world and indexers table in favour of contracts
lambda-0x Aug 20, 2024
b26c41a
opt(torii): batch query execution in sync_range
lambda-0x Aug 30, 2024
33cb543
refactor(torii): make select block cancel safe
lambda-0x Sep 2, 2024
d8c1b43
opt(torii): use hashmap instead of vector of event processors
lambda-0x Sep 2, 2024
2228fa1
opt(torii): fetch receipts along with blocks instead of fetching them…
lambda-0x Sep 3, 2024
98e2c61
opt(torii): avoid re-processing of transactions in certain case
lambda-0x Sep 3, 2024
92a7f04
wip
kariy Sep 6, 2024
134e0f7
Merge branch 'main' into sozo-execute-with-walnut
kariy Sep 6, 2024
15c5b3a
Add walnut flag to sozo execute command
kariy Sep 6, 2024
8155208
chore(dojo-world): enable manifest feature on `migration` feature
kariy Sep 6, 2024
ced0d63
fmt
kariy Sep 7, 2024
7e4e1e3
refactor: move walnut config into WalnutDebugger
glihm Sep 7, 2024
4953700
fix: ensure only WalnutDebugger is exposed
glihm Sep 7, 2024
e4d9705
fix: restore default dojo_dev.toml
glihm Sep 7, 2024
97b281a
dont print in library code
kariy Sep 8, 2024
122f717
use concrete error types in walnut/verification
kariy Sep 8, 2024
4eabc97
use concrete types again
kariy Sep 8, 2024
13c9dd6
remove unecessary util function
kariy Sep 8, 2024
db61e0e
use json method instead
kariy Sep 8, 2024
f3c966a
fix: fix test
glihm Sep 8, 2024
f780cc9
Merge remote-tracking branch 'dojo/main' into sozo-execute-with-walnut
glihm Sep 8, 2024
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
22 changes: 22 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ members = [
"crates/saya/core",
"crates/saya/provider",
"crates/sozo/signers",
"crates/sozo/walnut",
"crates/torii/client",
"crates/torii/server",
"crates/torii/types-test",
Expand Down Expand Up @@ -111,6 +112,7 @@ saya-provider = { path = "crates/saya/provider" }
# sozo
sozo-ops = { path = "crates/sozo/ops" }
sozo-signers = { path = "crates/sozo/signers" }
sozo-walnut = { path = "crates/sozo/walnut" }

anyhow = "1.0.80"
assert_fs = "1.1"
Expand Down Expand Up @@ -207,6 +209,7 @@ tower-http = "0.4.4"
tracing = "0.1.34"
tracing-subscriber = { version = "0.3.16", features = [ "env-filter", "json" ] }
url = { version = "2.4.0", features = [ "serde" ] }
walkdir = "2.5.0"

# server
hyper = "0.14.27"
Expand Down
1 change: 1 addition & 0 deletions bin/sozo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ serde.workspace = true
serde_json.workspace = true
smol_str.workspace = true
sozo-ops.workspace = true
sozo-walnut.workspace = true
starknet.workspace = true
starknet-crypto.workspace = true
thiserror.workspace = true
Expand Down
47 changes: 38 additions & 9 deletions bin/sozo/src/commands/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use scarb::core::Config;
use scarb_ui::Ui;
use sozo_ops::auth;
use sozo_walnut::WalnutDebugger;
use tracing::trace;

use super::options::account::AccountOptions;
Expand Down Expand Up @@ -149,24 +150,41 @@
) -> Result<()> {
trace!(?kind, ?world, ?starknet, ?account, ?transaction, "Executing Grant command.");
let world =
utils::world_from_env_metadata(world, account, starknet, &env_metadata, config).await?;
utils::world_from_env_metadata(world, account, &starknet, &env_metadata, config).await?;

Check warning on line 153 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L153

Added line #L153 was not covered by tests

let walnut_debugger =
WalnutDebugger::new_from_flag(transaction.walnut, starknet.url(env_metadata.as_ref())?);

Check warning on line 156 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L155-L156

Added lines #L155 - L156 were not covered by tests

match kind {
AuthKind::Writer { models_contracts } => {
trace!(
contracts=?models_contracts,
"Granting Writer permissions."
);
auth::grant_writer(ui, &world, &models_contracts, transaction.into(), default_namespace)
.await
auth::grant_writer(
ui,
&world,
&models_contracts,
&transaction.into(),
default_namespace,
&walnut_debugger,
)
.await

Check warning on line 172 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L164-L172

Added lines #L164 - L172 were not covered by tests
}
AuthKind::Owner { owners_resources } => {
trace!(
resources=?owners_resources,
"Granting Owner permissions."
);
auth::grant_owner(ui, &world, &owners_resources, transaction.into(), default_namespace)
.await
auth::grant_owner(
ui,
&world,
&owners_resources,
&transaction.into(),
default_namespace,
&walnut_debugger,
)
.await

Check warning on line 187 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L179-L187

Added lines #L179 - L187 were not covered by tests
}
}
}
Expand All @@ -185,7 +203,10 @@
) -> Result<()> {
trace!(?kind, ?world, ?starknet, ?account, ?transaction, "Executing Revoke command.");
let world =
utils::world_from_env_metadata(world, account, starknet, &env_metadata, config).await?;
utils::world_from_env_metadata(world, account, &starknet, &env_metadata, config).await?;

Check warning on line 206 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L206

Added line #L206 was not covered by tests

let walnut_debugger =
WalnutDebugger::new_from_flag(transaction.walnut, starknet.url(env_metadata.as_ref())?);

Check warning on line 209 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L208-L209

Added lines #L208 - L209 were not covered by tests

match kind {
AuthKind::Writer { models_contracts } => {
Expand All @@ -197,8 +218,9 @@
ui,
&world,
&models_contracts,
transaction.into(),
&transaction.into(),

Check warning on line 221 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L221

Added line #L221 was not covered by tests
default_namespace,
&walnut_debugger,

Check warning on line 223 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L223

Added line #L223 was not covered by tests
)
.await
}
Expand All @@ -207,8 +229,15 @@
resources=?owners_resources,
"Revoking Owner permissions."
);
auth::revoke_owner(ui, &world, &owners_resources, transaction.into(), default_namespace)
.await
auth::revoke_owner(
ui,
&world,
&owners_resources,
&transaction.into(),
default_namespace,
&walnut_debugger,
)
.await

Check warning on line 240 in bin/sozo/src/commands/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/auth.rs#L232-L240

Added lines #L232 - L240 were not covered by tests
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion bin/sozo/src/commands/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use dojo_world::metadata::get_default_namespace_from_ws;
use scarb::core::Config;
use sozo_ops::execute;
use sozo_walnut::WalnutDebugger;
use tracing::trace;

use super::calldata_decoder;
Expand Down Expand Up @@ -61,11 +62,16 @@
ensure_namespace(&self.tag_or_address, &default_namespace)
};

let walnut_debugger = WalnutDebugger::new_from_flag(
self.transaction.walnut,
self.starknet.url(env_metadata.as_ref())?,

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

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/execute.rs#L65-L67

Added lines #L65 - L67 were not covered by tests
);

config.tokio_handle().block_on(async {
let world = utils::world_from_env_metadata(
self.world,
self.account,
self.starknet,
&self.starknet,

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L74 was not covered by tests
&env_metadata,
config,
)
Expand Down Expand Up @@ -93,6 +99,7 @@
calldata,
&world,
&tx_config,
&walnut_debugger,

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L102 was not covered by tests
)
.await
})
Expand Down
11 changes: 9 additions & 2 deletions bin/sozo/src/commands/options/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
)]
#[arg(global = true)]
pub receipt: bool,

#[arg(long)]
#[arg(help = "Display the link to debug the transaction with Walnut.")]
#[arg(global = true)]
pub walnut: bool,

Check warning on line 44 in bin/sozo/src/commands/options/transaction.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/options/transaction.rs#L44

Added line #L44 was not covered by tests
}

impl TransactionOptions {
Expand All @@ -52,10 +57,11 @@
(true, false) => Ok(TxnAction::Estimate),
(false, true) => Ok(TxnAction::Simulate),
(false, false) => Ok(TxnAction::Send {
wait: self.wait,
wait: self.wait || self.walnut,

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

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/options/transaction.rs#L60

Added line #L60 was not covered by tests
receipt: self.receipt,
max_fee_raw: self.max_fee_raw,
fee_estimate_multiplier: self.fee_estimate_multiplier,
walnut: self.walnut,

Check warning on line 64 in bin/sozo/src/commands/options/transaction.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/options/transaction.rs#L64

Added line #L64 was not covered by tests
}),
}
}
Expand All @@ -71,9 +77,10 @@
);
Self {
fee_estimate_multiplier: value.fee_estimate_multiplier,
wait: value.wait,
wait: value.wait || value.walnut,
receipt: value.receipt,
max_fee_raw: value.max_fee_raw,
walnut: value.walnut,
}
}
}
9 changes: 7 additions & 2 deletions bin/sozo/src/commands/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use clap::{Args, Subcommand};
use dojo_world::contracts::WorldContractReader;
use scarb::core::Config;
use sozo_ops::register;
use sozo_walnut::WalnutDebugger;
use starknet::accounts::ConnectedAccount;
use starknet::core::types::{BlockId, BlockTag, Felt};
use tracing::trace;
Expand Down Expand Up @@ -58,9 +59,12 @@ impl RegisterArgs {
let world_address = world.world_address.unwrap_or_default();
trace!(?world_address, "Using world address.");

let walnut_debugger =
WalnutDebugger::new_from_flag(transaction.walnut, starknet.url(env_metadata.as_ref())?);

config.tokio_handle().block_on(async {
let world =
utils::world_from_env_metadata(world, account, starknet, &env_metadata, config)
utils::world_from_env_metadata(world, account, &starknet, &env_metadata, config)
.await?;
let provider = world.account.provider();
let mut world_reader = WorldContractReader::new(world_address, &provider);
Expand All @@ -69,10 +73,11 @@ impl RegisterArgs {
register::model_register(
models,
&world,
transaction.into(),
&transaction.into(),
world_reader,
world_address,
config,
&walnut_debugger,
)
.await
})
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 @@ -52,7 +52,7 @@ pub fn load_metadata_from_config(config: &Config) -> Result<Option<Environment>,
pub async fn world_from_env_metadata(
world: WorldOptions,
account: AccountOptions,
starknet: StarknetOptions,
starknet: &StarknetOptions,
env_metadata: &Option<Environment>,
config: &Config,
) -> Result<WorldContract<SozoAccount<JsonRpcClient<HttpTransport>>>, Error> {
Expand All @@ -64,7 +64,7 @@ pub async fn world_from_env_metadata(
.account(
provider,
WorldAddressOrName::Address(world_address),
&starknet,
starknet,
env_metadata,
config,
)
Expand Down
1 change: 0 additions & 1 deletion crates/dojo-lang/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl Compiler for DojoCompiler {

for (decl, contract_class, debug_info) in izip!(contracts, classes, debug_info_classes) {
let contract_name = decl.submodule_id.name(db.upcast_mut());

// note that the qualified path is in snake case while
// the `full_path()` method of StructId uses the original struct name case.
// (see in `get_dojo_model_artifacts`)
Expand Down
2 changes: 2 additions & 0 deletions crates/dojo-utils/src/tx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct TxnConfig {
pub wait: bool,
pub receipt: bool,
pub max_fee_raw: Option<Felt>,
pub walnut: bool,
Copy link

Choose a reason for hiding this comment

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

Ohayo, sensei! Consider setting a default value for walnut.

The addition of the walnut field in TxnConfig is a wise move to enhance functionality. However, it's crucial to ensure that this field is initialized properly to avoid any undefined behavior. Consider setting a default value in the Default trait implementation for TxnConfig.

}

#[derive(Debug, Copy, Clone)]
Expand All @@ -29,6 +30,7 @@ pub enum TxnAction {
/// The multiplier for how much the actual transaction max fee should be relative to the
/// estimated fee. If `None` is provided, the multiplier is set to `1.1`.
fee_estimate_multiplier: Option<f64>,
walnut: bool,
},
Estimate,
Simulate,
Expand Down
4 changes: 2 additions & 2 deletions crates/dojo-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ scarb = { workspace = true, optional = true }
tokio = { version = "1.32.0", features = [ "time" ], default-features = false, optional = true }
toml.workspace = true
url = { workspace = true, optional = true }
walkdir = "2.5.0"
walkdir.workspace = true

[dev-dependencies]
assert_fs.workspace = true
Expand All @@ -52,4 +52,4 @@ tokio.workspace = true
contracts = [ "dep:dojo-types", "dep:http", "dep:num-traits" ]
manifest = [ "contracts", "dep:dojo-types", "dep:scarb", "dep:url" ]
metadata = [ "dep:ipfs-api-backend-hyper", "dep:scarb", "dep:url" ]
migration = [ "dep:dojo-utils", "dep:scarb", "dep:tokio" ]
migration = [ "dep:dojo-utils", "dep:scarb", "dep:tokio", "manifest" ]
1 change: 1 addition & 0 deletions crates/sozo/ops/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tokio.workspace = true
toml.workspace = true
tracing.workspace = true
url.workspace = true
sozo-walnut.workspace = true

dojo-test-utils = { workspace = true, features = [ "build-examples" ], optional = true }
katana-runner = { workspace = true, optional = true }
Expand Down
5 changes: 3 additions & 2 deletions crates/sozo/ops/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
};

match txn_action {
TxnAction::Send { wait, receipt, max_fee_raw, fee_estimate_multiplier } => {
TxnAction::Send { wait, receipt, max_fee_raw, fee_estimate_multiplier, walnut } => {

Check warning on line 251 in crates/sozo/ops/src/account.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/account.rs#L251

Added line #L251 was not covered by tests
let max_fee = if let Some(max_fee_raw) = max_fee_raw {
MaxFeeType::Manual { max_fee: max_fee_raw }
} else {
Expand Down Expand Up @@ -277,7 +277,8 @@
};

let account_deployment = account_deployment.max_fee(max_fee.max_fee());
let txn_config = TxnConfig { fee_estimate_multiplier, wait, receipt, max_fee_raw };
let txn_config =
TxnConfig { fee_estimate_multiplier, wait, receipt, max_fee_raw, walnut };

Check warning on line 281 in crates/sozo/ops/src/account.rs

View check run for this annotation

Codecov / codecov/patch

crates/sozo/ops/src/account.rs#L280-L281

Added lines #L280 - L281 were not covered by tests
do_account_deploy(
max_fee,
txn_config,
Expand Down
Loading
Loading