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

Use snfoundry profiler #313

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion packages/client/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mod test;
pub mod test;
18 changes: 9 additions & 9 deletions packages/client/src/test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ use utreexo::stump::proof::UtreexoBatchProof;

/// Integration testing program arguments.
#[derive(Drop)]
struct Args {
pub struct Args {
/// Current (initial) chain state.
chain_state: ChainState,
pub chain_state: ChainState,
/// Batch of blocks that have to be applied to the current chain state.
blocks: Array<Block>,
pub blocks: Array<Block>,
/// Expected chain state (that we want to compare the result with).
expected_chain_state: ChainState,
pub expected_chain_state: ChainState,
/// Optional Utreexo arguments.
utreexo_args: Option<UtreexoArgs>,
pub utreexo_args: Option<UtreexoArgs>,
/// If this flag is set, locking scripts will be executed
execute_script: bool,
pub execute_script: bool,
}

/// Utreexo arguments necessary for constraining the UTXO set.
#[derive(Drop, Serde)]
struct UtreexoArgs {
/// Current (initial) accumulator state.
state: UtreexoStumpState,
pub state: UtreexoStumpState,
/// Batch inclusion proof for TXOs spent during the current block.
/// Note that it doesn't support flow with multiple blocks applied
/// in a single program run.
proof: UtreexoBatchProof,
pub proof: UtreexoBatchProof,
/// Expected accumulator state at the end of the execution.
expected_state: UtreexoStumpState,
pub expected_state: UtreexoStumpState,
}

/// Integration testing program entrypoint.
Expand Down
1 change: 0 additions & 1 deletion packages/utils/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub mod numeric;
pub mod sort;
pub mod word_array;


// pub mod sha256;
// Let's use core non provable functions for now. Much faster.
pub use core::sha256;
Expand Down
5 changes: 5 additions & 0 deletions profiling/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target
.snfoundry_versioned_programs/
.snfoundry_cache/
snfoundry_trace/
profile/
10 changes: 10 additions & 0 deletions profiling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Profiling
```
snforge test --build-profile -- --show-details
```

## Pprof
```
go tool pprof -http=":8000" profile/shinigami_profiling_tests\:\:test\:\:test_24839_full.pb.gz
```

77 changes: 77 additions & 0 deletions profiling/Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "client"
version = "0.1.0"
dependencies = [
"consensus",
"utreexo",
]

[[package]]
name = "consensus"
version = "0.1.0"
dependencies = [
"shinigami_engine",
"utils",
]

[[package]]
name = "profiling"
version = "0.1.0"
dependencies = [
"client",
"consensus",
"snforge_std",
"utreexo",
]

[[package]]
name = "ripemd160"
version = "0.1.0"
source = "git+https://github.com/j1mbo64/ripemd160_cairo.git#833e07d7d074d4ee51ceb40a5bcb4af2fe6898f3"

[[package]]
name = "sha1"
version = "0.1.0"
source = "git+https://github.com/j1mbo64/sha1_cairo.git#2b65bc00a829bdcc244c140d0f31feda32f8d2c4"

[[package]]
name = "shinigami_engine"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/shinigami.git?rev=1963116#1963116dc6f24eb32d0513c6394ad64da515ceff"
dependencies = [
"ripemd160",
"sha1",
"shinigami_utils",
]

[[package]]
name = "shinigami_utils"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/shinigami.git?rev=1963116#1963116dc6f24eb32d0513c6394ad64da515ceff"

[[package]]
name = "snforge_scarb_plugin"
version = "0.34.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.34.0#d6976d4635cbe69bd199fd502788c469d408ed2d"

[[package]]
name = "snforge_std"
version = "0.34.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.34.0#d6976d4635cbe69bd199fd502788c469d408ed2d"
dependencies = [
"snforge_scarb_plugin",
]

[[package]]
name = "utils"
version = "0.1.0"

[[package]]
name = "utreexo"
version = "0.1.0"
dependencies = [
"utils",
]
54 changes: 54 additions & 0 deletions profiling/Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[package]
name = "profiling"
version = "0.1.0"
edition = "2024_07"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
starknet = "2.9.1"
# raito = { git = "https://github.com/keep-starknet-strange/raito.git", rev = "bdbbf08" }

client = { path = ".."}
consensus = { path = ".."}
utreexo = { path = ".."}

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.34.0" }
assert_macros = "2.9.1"

[[target.starknet-contract]]
sierra = true

[scripts]
test = "snforge test"

# Visit https://foundry-rs.github.io/starknet-foundry/appendix/scarb-toml.html for more information

# [tool.snforge] # Define `snforge` tool section
# exit_first = true # Stop tests execution immediately upon the first failure
# fuzzer_runs = 1234 # Number of runs of the random fuzzer
# fuzzer_seed = 1111 # Seed for the random fuzzer

# [[tool.snforge.fork]] # Used for fork testing
# name = "SOME_NAME" # Fork name
# url = "http://your.rpc.url" # Url of the RPC provider
# block_id.tag = "latest" # Block to fork from (block tag)

# [[tool.snforge.fork]]
# name = "SOME_SECOND_NAME"
# url = "http://your.second.rpc.url"
# block_id.number = "123" # Block to fork from (block number)

# [[tool.snforge.fork]]
# name = "SOME_THIRD_NAME"
# url = "http://your.third.rpc.url"
# block_id.hash = "0x123" # Block to fork from (block hash)

# [profile.dev.cairo] # Configure Cairo compiler
# unstable-add-statements-code-locations-debug-info = true # Should be used if you want to use coverage
# unstable-add-statements-functions-debug-info = true # Should be used if you want to use coverage/profiler
# inlining-strategy = "avoid" # Should be used if you want to use coverage

# [features] # Used for conditional compilation
# enable_for_tests = [] # Feature name and list of other features that should be enabled with it
11 changes: 11 additions & 0 deletions profiling/snfoundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Visit https://foundry-rs.github.io/starknet-foundry/appendix/snfoundry-toml.html
# and https://foundry-rs.github.io/starknet-foundry/projects/configuration.html for more information

# [sncast.default] # Define a profile name
# url = "https://free-rpc.nethermind.io/sepolia-juno/v0_7" # Url of the RPC provider
# accounts-file = "../account-file" # Path to the file with the account data
# account = "mainuser" # Account from `accounts_file` or default account file that will be used for the transactions
# keystore = "~/keystore" # Path to the keystore file
# wait-params = { timeout = 300, retry-interval = 10 } # Wait for submitted transaction parameters
# block-explorer = "StarkScan" # Block explorer service used to display links to transaction details
# show-explorer-links = true # Print links pointing to pages with transaction details in the chosen block explorer
Loading
Loading