Skip to content

Commit

Permalink
Use of official Starknet client (#46)
Browse files Browse the repository at this point in the history
* Replaced manual RPC client with `starknet-rs` client.

* Enforce rust 1.78.0.

* Created trait `VisitedPcsRaw` for blockifier.

* Removed todo in 'replace_type_id'

* Implemented 'get_compiled_class_hash' in state reader

* Improved log and return ZERO when contract hasn't been deployed yet

* Implemented transaction trace report

* Improved logging

* Added documentation to visited_pcs

* Refactoring of function 'convert_transaction'

* Updated wrong comments for 'missing_panics_doc'

* Improved error reporting

* Fixed panic with concurrent 'client' access
  • Loading branch information
Eagle941 authored Sep 30, 2024
1 parent bd2dcde commit 0d63282
Show file tree
Hide file tree
Showing 26 changed files with 3,048 additions and 928 deletions.
1,106 changes: 894 additions & 212 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ members = [
[workspace.package]
# Edition 2021 is chosen to support async.
edition = "2021"
# Version chosen only because 1.78.0 is the stable version when writing this Cargo.toml
# If this version is changed, amend the version set in `build.yml`
# Version 1.80.1 or higher is not compatible because it enforces check of `cfg` names and values. The dependency `blockifier` currently uses unknown values for `target_pointer_width`.
# If this version is changed, amend the version set in `build.yml` and `rust-toolchain.toml`.
rust-version = "1.78.0"
license = "Apache-2.0"
repository = "https://github.com/reilabs/starknet-replay"
Expand All @@ -20,4 +20,4 @@ readme = "README.md"
[workspace.dependencies]
anyhow = "1.0.75"
tracing = "0.1.37"
itertools = { version = "0.11.0", default-features = false }
itertools = { version = "0.12.1", default-features = false }
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
description = "A CLI tool to replay Starknet transactions and print histogram of libfuncs usage"
categories = ["cryptography::cryptocurrencies"]
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn run(args: Args) -> anyhow::Result<()> {
check_file(&txt_out, overwrite)?;
check_file(&trace_out, overwrite)?;

let storage = RpcStorage::new(rpc_url)?;
let storage = RpcStorage::new(rpc_url);

let replay_range = ReplayRange::new(start_block, end_block)?;

Expand Down
34 changes: 17 additions & 17 deletions starknet-replay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
description = "Back end to replay Starknet transactions and print histogram of libfuncs usage."
categories = ["cryptography::cryptocurrencies"]
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
Expand All @@ -13,44 +14,43 @@ keywords.workspace = true
publish = false

[dependencies]
# Ensure cairo-vm matches the version used by blockifier
cairo-vm = "1.0.0-rc5"
# All `cairo-lang-` crates must have the same version
cairo-lang-starknet-classes = "2.6.0"
cairo-lang-sierra-to-casm = "2.6.0"
cairo-lang-runner = "2.6.0"
cairo-lang-compiler = "2.6.0"
cairo-lang-sierra = "2.6.0"
cairo-lang-utils = "2.6.0"
cairo-lang-sierra-generator = "2.6.0"
cairo-lang-starknet-classes = "2.7.0-rc.1"
cairo-lang-sierra-to-casm = "2.7.0-rc.1"
cairo-lang-runner = "2.7.0-rc.1"
cairo-lang-compiler = "2.7.0-rc.1"
cairo-lang-sierra = "2.7.0-rc.1"
cairo-lang-utils = "2.7.0-rc.1"
cairo-lang-sierra-generator = "2.7.0-rc.1"
# Some changes are required to `starkware-libs/blockifier`. These changes are
# in the branch `extract_libfunc` of Reilabs' fork and need to be merged
# into the main branch.
# Hardcoding the commit hash for the time being.
blockifier = { git = "https://github.com/reilabs/blockifier.git", rev = "fdb86caf85435cb42ae363c7b04b5620bc80c24a" }
blockifier = { git = "https://github.com/reilabs/blockifier.git", rev = "e3141f67338cbb03595f24984b615042877229e0" }
# `plotters` is using the latest (as of 30-May-2024) commit on the branch
# `next-release-devel` because it contains the fix for bug #551 related to
# anchoring of labels when rotated. Issue #26.
plotters = { git = "https://github.com/plotters-rs/plotters.git", rev = "a7a3f8989af20931dd9e7e1f204d5254de3a8053" }
flate2 = "1.0.25"
rayon = "1.8.0"
starknet_api = "0.10.0"
starknet-core = "0.10.0"
# The versions of `starknet` dependencies must match the version used in blockifier.
starknet_api = "0.13.0-rc.0"
starknet-core = "0.11.0"
starknet-providers = "0.11.0"
serde = "1.0.192"
serde_json = "1.0.105"
serde_with = "3.0.0"
smol_str = { version = "0.2.0", features = ["serde"] }
thiserror = "1.0.61"
jsonrpc = { version = "0.18.0", features = ["minreq_http"] }
url = "2.5.2"
hex = "0.4.3"
once_cell = "1.17.1"
tokio = { version = "1.27.0", features = ["full"] }
primitive-types = "0.12.2"
anyhow.workspace = true
tracing.workspace = true
itertools.workspace = true

[dependencies.minreq]
version = "2.11.2"
features = ["https"]

[dev-dependencies]
indoc = "2.0.5"
rand = "0.8.4"
Expand Down
208 changes: 179 additions & 29 deletions starknet-replay/resources/versioned_constants_13_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@
"syscall_base_gas_cost": 1
},
"keccak_round_cost_gas_cost": 180000,
"sha256_process_block_gas_cost": {
"step_gas_cost": 0,
"range_check_gas_cost": 0,
"syscall_base_gas_cost": 0
},
"error_block_number_out_of_range": "Block number out of range",
"error_out_of_gas": "Out of gas",
"error_invalid_input_len": "Invalid input length",
Expand Down Expand Up @@ -333,6 +338,11 @@
"n_memory_holes": 0,
"n_steps": 84
},
"Sha256ProcessBlock": {
"builtin_instance_counter": {},
"n_memory_holes": 0,
"n_steps": 0
},
"StorageRead": {
"builtin_instance_counter": {},
"n_memory_holes": 0,
Expand All @@ -346,49 +356,189 @@
},
"execute_txs_inner": {
"Declare": {
"builtin_instance_counter": {
"pedersen_builtin": 15,
"range_check_builtin": 63
"resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 15,
"range_check_builtin": 63
},
"n_memory_holes": 0,
"n_steps": 2711
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
},
"n_memory_holes": 0,
"n_steps": 2711
"deprecated_resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 15,
"range_check_builtin": 63
},
"n_memory_holes": 0,
"n_steps": 2711
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
}
},
"DeployAccount": {
"builtin_instance_counter": {
"pedersen_builtin": 23,
"range_check_builtin": 83
"resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 23,
"range_check_builtin": 83
},
"n_memory_holes": 0,
"n_steps": 3628
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
},
"n_memory_holes": 0,
"n_steps": 3628
"deprecated_resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 23,
"range_check_builtin": 83
},
"n_memory_holes": 0,
"n_steps": 3628
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
}
},
"InvokeFunction": {
"builtin_instance_counter": {
"pedersen_builtin": 16,
"range_check_builtin": 80
"resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 16,
"range_check_builtin": 80
},
"n_memory_holes": 0,
"n_steps": 3382
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
},
"n_memory_holes": 0,
"n_steps": 3382
"deprecated_resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 16,
"range_check_builtin": 80
},
"n_memory_holes": 0,
"n_steps": 3382
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
}
},
"L1Handler": {
"builtin_instance_counter": {
"pedersen_builtin": 11,
"range_check_builtin": 17
"resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 11,
"range_check_builtin": 17
},
"n_memory_holes": 0,
"n_steps": 1069
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
},
"n_memory_holes": 0,
"n_steps": 1069
"deprecated_resources": {
"constant": {
"builtin_instance_counter": {
"pedersen_builtin": 11,
"range_check_builtin": 17
},
"n_memory_holes": 0,
"n_steps": 1069
},
"calldata_factor": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
}
}
},
"compute_os_kzg_commitment_info": {
"n_steps": 0,
"builtin_instance_counter": {},
"n_memory_holes": 0
}
},
"validate_max_n_steps": 1000000,
"vm_resource_fee_cost": {
"bitwise_builtin": 0.32,
"ec_op_builtin": 5.12,
"ecdsa_builtin": 10.24,
"keccak_builtin": 10.24,
"n_steps": 0.005,
"output_builtin": 0,
"pedersen_builtin": 0.16,
"poseidon_builtin": 0.16,
"range_check_builtin": 0.08
"add_mod_builtin": [
0,
1
],
"bitwise_builtin": [
32,
100
],
"ec_op_builtin": [
512,
100
],
"ecdsa_builtin": [
1024,
100
],
"keccak_builtin": [
1024,
100
],
"mul_mod_builtin": [
0,
1
],
"n_steps": [
5,
1000
],
"output_builtin": [
0,
1
],
"pedersen_builtin": [
16,
100
],
"poseidon_builtin": [
16,
100
],
"range_check_builtin": [
8,
100
],
"range_check96_builtin": [
0,
1
]
}
}
Loading

0 comments on commit 0d63282

Please sign in to comment.