Skip to content

Commit

Permalink
Migrate to Cairo 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Jul 25, 2023
1 parent 54810ef commit 75fdb33
Show file tree
Hide file tree
Showing 35 changed files with 1,635 additions and 1,213 deletions.
1,199 changes: 630 additions & 569 deletions Cargo.lock

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,31 @@ version = "0.1.0"
anyhow = "1.0.66"
async-trait = "0.1.68"
blockifier = { git = "/~https://github.com/starkware-libs/blockifier" }
cairo-lang-casm = "2.0.1"
cairo-lang-compiler = "2.0.1"
cairo-lang-debug = "2.0.1"
cairo-lang-defs = "2.0.1"
cairo-lang-diagnostics = "2.0.1"
cairo-lang-filesystem = "2.0.1"
cairo-lang-formatter = "2.0.1"
cairo-lang-language-server = "2.0.1"
cairo-lang-lowering = "2.0.1"
cairo-lang-parser = "2.0.1"
cairo-lang-plugins = "2.0.1"
cairo-lang-project = "2.0.1"
cairo-lang-semantic = { version = "2.0.1", features = [ "testing" ] }
cairo-lang-sierra = "2.0.1"
cairo-lang-sierra-generator = "2.0.1"
cairo-lang-sierra-to-casm = "2.0.1"
cairo-lang-starknet = "2.0.1"
cairo-lang-syntax = "2.0.1"
cairo-lang-test-runner = "2.0.1"
cairo-lang-test-utils = "2.0.1"
cairo-lang-utils = "2.0.1"
cairo-lang-casm = "2.1.0-rc1"
cairo-lang-compiler = "2.1.0-rc1"
cairo-lang-debug = "2.1.0-rc1"
cairo-lang-defs = "2.1.0-rc1"
cairo-lang-diagnostics = "2.1.0-rc1"
cairo-lang-filesystem = "2.1.0-rc1"
cairo-lang-formatter = "2.1.0-rc1"
cairo-lang-language-server = "2.1.0-rc1"
cairo-lang-lowering = "2.1.0-rc1"
cairo-lang-parser = "2.1.0-rc1"
cairo-lang-plugins = "2.1.0-rc1"
cairo-lang-project = "2.1.0-rc1"
cairo-lang-semantic = { version = "2.1.0-rc1", features = ["testing"] }
cairo-lang-sierra = "2.1.0-rc1"
cairo-lang-sierra-generator = "2.1.0-rc1"
cairo-lang-sierra-to-casm = "2.1.0-rc1"
cairo-lang-starknet = "2.1.0-rc1"
cairo-lang-syntax = "2.1.0-rc1"
cairo-lang-test-runner = "2.1.0-rc1"
cairo-lang-test-utils = "2.1.0-rc1"
cairo-lang-utils = "2.1.0-rc1"
cairo-vm = "0.6.0"
camino = { version = "1.1.2", features = [ "serde1" ] }
chrono = { version = "0.4.24", features = [ "serde" ] }
clap = { version = "4.2", features = [ "derive" ] }
camino = { version = "1.1.2", features = ["serde1"] }
chrono = { version = "0.4.24", features = ["serde"] }
clap = { version = "4.2", features = ["derive"] }
colored = "2"
console = "0.15.7"
convert_case = "0.6.0"
Expand All @@ -65,26 +65,26 @@ num-bigint = "0.4"
pretty_assertions = "1.2.1"
rayon = "0.9.0"
salsa = "0.16.1"
scarb = { git="/~https://github.com/software-mansion/scarb", version="0.5.1" }
scarb = { git = "/~https://github.com/software-mansion/scarb", rev = "c7b2e34" }
semver = "1.0.5"
serde = { version = "1.0.156", features = [ "derive" ] }
serde = { version = "1.0.156", features = ["derive"] }
serde_json = "1.0"
serde_with = "2.3.1"
smol_str = { version = "0.2.0", features = [ "serde" ] }
smol_str = { version = "0.2.0", features = ["serde"] }
starknet = "0.4.0"
starknet-crypto = "0.5.1"
starknet_api = { git = "/~https://github.com/starkware-libs/starknet-api", rev = "a4c78ff" }
starknet_api = { git = "/~https://github.com/starkware-libs/starknet-api", rev = "ecc9b6946ef13003da202838e4124a9ad2efabb0" }
test-log = "0.2.11"
thiserror = "1.0.32"
tokio = { version = "1.16", features = [ "full" ] }
tokio = { version = "1.16", features = ["full"] }
toml = "0.7.4"
tracing = "0.1"
tracing-subscriber = "0.3.16"
yansi = "0.5.1"

[patch."https://github.com/starkware-libs/blockifier"]
blockifier = { git = "/~https://github.com/dojoengine/blockifier", rev = "f5b684d" }
blockifier = { git = "/~https://github.com/dojoengine/blockifier", rev = "007a4aafad49acd751e408b4e37d963d72a26792" }

[patch.crates-io]
cairo-felt = { git = "/~https://github.com/dojoengine/cairo-rs.git", rev = "b1a3683fe20bb668e4ab72cd9f99b8a0a33515a8" }
cairo-vm = { git = "/~https://github.com/dojoengine/cairo-rs.git", rev = "b1a3683fe20bb668e4ab72cd9f99b8a0a33515a8" }
cairo-felt = { git = "/~https://github.com/dojoengine/cairo-rs.git", rev = "69f30bcd1acf99631645bcc4efc434553e2f146e" }
cairo-vm = { git = "/~https://github.com/dojoengine/cairo-rs.git", rev = "69f30bcd1acf99631645bcc4efc434553e2f146e" }
4 changes: 2 additions & 2 deletions crates/dojo-core/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "dojo"
version = "0.1.0"
cairo-version = "2.0.0"
cairo-version = "2.1.0-rc1"
description = "The Dojo Core library for autonomous worlds."

[dependencies]
dojo_plugin = { git = "/~https://github.com/dojoengine/dojo" }
starknet = "2.0.0"
starknet = "2.1.0-rc1"
1 change: 0 additions & 1 deletion crates/dojo-core/src/interfaces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ trait IComponent<T> {
#[starknet::interface]
trait ISystem<T> {
fn name(self: @T) -> felt252;
fn dependencies(self: @T) -> Array<(felt252, bool)>;
}
2 changes: 1 addition & 1 deletion crates/dojo-core/src/world.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use starknet::{ContractAddress, ClassHash, StorageAccess, StorageBaseAddress, SyscallResult};
use starknet::{ContractAddress, ClassHash, StorageBaseAddress, SyscallResult};
use traits::{Into, TryInto};
use option::OptionTrait;

Expand Down
4 changes: 4 additions & 0 deletions crates/dojo-lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cairo-lang-utils.workspace = true
convert_case.workspace = true
dojo-types = { path = "../dojo-types" }
dojo-world = { path = "../dojo-world" }
indoc.workspace = true
itertools.workspace = true
scarb.workspace = true
semver.workspace = true
Expand All @@ -51,3 +52,6 @@ env_logger = "0.10.0"
pretty_assertions.workspace = true
test-log.workspace = true
dojo-test-utils = { path = "../dojo-test-utils" }

[build-dependencies]
cargo_metadata = "0.15.4"
89 changes: 89 additions & 0 deletions crates/dojo-lang/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
use std::path::{Path, PathBuf};
use std::process::Command;

use cargo_metadata::MetadataCommand;

fn main() {
commit_info();
cairo_version();
}

fn commit_info() {
if !Path::new("../../.git").exists() {
return;
}
println!("cargo:rerun-if-changed=../../.git/index");
let output = match Command::new("git")
.arg("log")
.arg("-1")
.arg("--date=short")
.arg("--format=%H %h %cd")
.arg("--abbrev=9")
.current_dir("..")
.output()
{
Ok(output) if output.status.success() => output,
_ => return,
};
let stdout = String::from_utf8(output.stdout).unwrap();
let mut parts = stdout.split_whitespace();
let mut next = || parts.next().unwrap();
println!("cargo:rustc-env=DOJO_COMMIT_HASH={}", next());
println!("cargo:rustc-env=DOJO_COMMIT_SHORT_HASH={}", next());
println!("cargo:rustc-env=DOJO_COMMIT_DATE={}", next())
}

fn cairo_version() {
let cargo_lock = find_cargo_lock();
println!("cargo:rerun-if-changed={}", cargo_lock.display());

let metadata = MetadataCommand::new()
.manifest_path("./Cargo.toml")
.verbose(true)
.exec()
.expect("Failed to execute cargo metadata");

let resolve = metadata.resolve.expect("Expected metadata resolve to be present.");

let root = resolve.root.expect("Expected metadata resolve root to be present.");
assert!(root.repr.starts_with("dojo"), "Expected metadata resolve root to be `dojo`.");

let dojo_node = resolve.nodes.iter().find(|node| node.id == root).unwrap();
let compiler_dep = dojo_node.deps.iter().find(|dep| dep.name == "cairo_lang_compiler").unwrap();
let compiler_package = metadata.packages.iter().find(|pkg| pkg.id == compiler_dep.pkg).unwrap();

let version = compiler_package.version.to_string();
println!("cargo:rustc-env=DOJO_CAIRO_VERSION={version}");

let mut rev = format!("refs/tags/v{version}");
if let Some(source) = &compiler_package.source {
let source = source.to_string();
if source.starts_with("git+") {
if let Some((_, commit)) = source.split_once('#') {
println!("cargo:rustc-env=DOJO_CAIRO_COMMIT_HASH={commit}");
let mut short_commit = commit.to_string();
short_commit.truncate(9);
println!("cargo:rustc-env=DOJO_CAIRO_SHORT_COMMIT_HASH={short_commit}");
rev = commit.to_string();
}
}
}
println!("cargo:rustc-env=DOJO_CAIRO_COMMIT_REV={rev}");
}

fn find_cargo_lock() -> PathBuf {
let in_workspace = PathBuf::from("../../Cargo.lock");
if in_workspace.exists() {
return in_workspace;
}

let in_package = PathBuf::from("Cargo.lock");
if in_package.exists() {
return in_package;
}

panic!(
"Couldn't find Cargo.lock of this package. Something's wrong with build execution \
environment."
)
}
103 changes: 0 additions & 103 deletions crates/dojo-lang/src/commands/set.rs

This file was deleted.

Loading

0 comments on commit 75fdb33

Please sign in to comment.