From db306a9850bba615f0d2fb27509e267b5a3f4e1b Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 01:36:59 +0100 Subject: [PATCH 1/9] completed the Git Action --- .github/workflows/performance.yml | 22 ++++++ README.md | 31 ++++++++ action.yml | 60 +++++++++++++++ bin/stylus-trace/src/main.rs | 51 +++++++++++++ crates/stylus-trace-studio/src/commands/ci.rs | 75 +++++++++++++++++++ .../stylus-trace-studio/src/commands/mod.rs | 4 +- .../src/commands/models.rs | 27 +++++++ .../.github/workflows/performance.yml | 22 ++++++ 8 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/performance.yml create mode 100644 action.yml create mode 100644 crates/stylus-trace-studio/src/commands/ci.rs create mode 100644 test_project/.github/workflows/performance.yml diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml new file mode 100644 index 0000000..06360f7 --- /dev/null +++ b/.github/workflows/performance.yml @@ -0,0 +1,22 @@ +name: Stylus Performance Check + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + performance-regression: + name: Gas Regression Check + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Run Stylus Performance Check + uses: CreativesOnchain/Stylus-Trace@v1 + with: + tx_hash: "0xaaf333656d069068844d17f175fa5b73534c0b71599100bee2153791c3e81edc" + rpc_url: "http://localhost:8547" + threshold: "1" diff --git a/README.md b/README.md index 2e395c9..59ec376 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,37 @@ This feature will be enabled automatically once upstream tracer support is avail | `--output` | Path to write the diff report JSON | `artifacts/diff/diff_report.json` | | `--flamegraph` | Path to write visual diff flamegraph SVG | `artifacts/diff/diff.svg` | +### `ci init` +| Flag | Description | Default | +|------|-------------|---------| +| `--tx` | **(Required)** Transaction hash to profile in CI | - | +| `--rpc` | RPC endpoint URL | `http://localhost:8547` | +| `--threshold` | Percentage threshold for regressions | `1.0` | +| `--force` | Overwrite existing workflow files | `false` | + +--- + +## 🤖 CI/CD Integration + +Stylus Trace is built for automated performance tracking. You can integrate it into your project to **strictly block merges** that cause gas regressions. + +### Quick Setup (Zero Config) +Run this in your repository to auto-generate a GitHub Actions workflow: +```bash +stylus-trace ci init --tx 0x... +``` + +### Manual Integration +You can use the [Stylus Trace Action](https://github.com/CreativesOnchain/Stylus-Trace) directly in your workflows: + +```yaml +- name: Gas Regression Check + uses: CreativesOnchain/Stylus-Trace@v1 + with: + tx_hash: "0x..." + threshold: "1.0" # Fail if gas increases by > 1% +``` + --- ## 🤝 Contributing diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..73f4250 --- /dev/null +++ b/action.yml @@ -0,0 +1,60 @@ +name: 'Stylus Performance Regression Check' +description: 'Automated performance regression detection for Arbitrum Stylus transactions' +author: 'Creatives Onchain' + +inputs: + rpc_url: + description: 'Arbitrum Nitro RPC endpoint' + required: false + default: 'http://localhost:8547' + tx_hash: + description: 'Transaction hash to profile' + required: true + baseline: + description: 'Path to baseline profile JSON' + required: false + default: 'artifacts/capture/baseline.json' + threshold: + description: 'Percentage threshold for allowed increase (e.g. 1.0 for 1%)' + required: false + default: '1.0' + ink: + description: 'Use Stylus Ink units instead of Gas' + required: false + default: 'false' + +runs: + using: "composite" + steps: + - name: Install Stylus Trace + shell: bash + run: | + if ! command -v stylus-trace &> /dev/null; then + echo "Installing stylus-trace-studio..." + cargo install stylus-trace-studio + else + echo "stylus-trace already installed." + fi + + - name: Capture Current Profile + shell: bash + run: | + INK_FLAG="" + if [ "${{ inputs.ink }}" = "true" ]; then + INK_FLAG="--ink" + fi + + stylus-trace capture \ + --rpc "${{ inputs.rpc_url }}" \ + --tx "${{ inputs.tx_hash }}" \ + --output current_profile.json \ + $INK_FLAG + + - name: Compare with Baseline + shell: bash + run: | + stylus-trace diff \ + "${{ inputs.baseline }}" \ + artifacts/capture/current_profile.json \ + --threshold-percent "${{ inputs.threshold }}" \ + --summary diff --git a/bin/stylus-trace/src/main.rs b/bin/stylus-trace/src/main.rs index 0a5e3d6..3975b15 100644 --- a/bin/stylus-trace/src/main.rs +++ b/bin/stylus-trace/src/main.rs @@ -100,6 +100,12 @@ pub enum Commands { file: PathBuf, }, + /// CI configuration and management + Ci { + #[command(subcommand)] + subcommand: CiSubcommands, + }, + /// Display schema information Schema { /// Show full schema details @@ -158,6 +164,7 @@ fn main() -> Result<()> { Commands::Validate { file } => { validate_profile_file(file).context("Failed to validate profile")? } + Commands::Ci { subcommand } => handle_ci(subcommand)?, Commands::Schema { show } => display_schema(show), Commands::Version => display_version(), } @@ -165,6 +172,50 @@ fn main() -> Result<()> { Ok(()) } +#[derive(Subcommand, Debug)] +pub enum CiSubcommands { + /// Initialize CI/CD performance regression checks + Init { + /// Transaction hash to profile in CI + #[arg(short, long)] + tx: String, + + /// RPC endpoint URL + #[arg(short, long, default_value = "http://localhost:8547")] + rpc: Option, + + /// Percentage threshold for regressions (e.g., 1.0) + #[arg(short = 'p', long, default_value = "1.0")] + threshold: f64, + + /// Force overwrite existing workflow files + #[arg(long)] + force: bool, + }, +} + +/// Handle CI command logic +fn handle_ci(subcommand: CiSubcommands) -> Result<()> { + match subcommand { + CiSubcommands::Init { + tx, + rpc, + threshold, + force, + } => { + let args = stylus_trace_studio::commands::models::CiInitArgs { + transaction_hash: tx, + rpc_url: rpc, + threshold, + force, + }; + stylus_trace_studio::commands::execute_ci_init(args) + .context("CI initialization failed")?; + } + } + Ok(()) +} + /// Setup logging based on verbosity level fn setup_logging(verbose: bool) { let log_level = if verbose { "debug" } else { "info" }; diff --git a/crates/stylus-trace-studio/src/commands/ci.rs b/crates/stylus-trace-studio/src/commands/ci.rs new file mode 100644 index 0000000..febcdc7 --- /dev/null +++ b/crates/stylus-trace-studio/src/commands/ci.rs @@ -0,0 +1,75 @@ +//! CI command implementation. +//! Handles automated CI/CD configuration for external projects. + +use crate::commands::models::CiInitArgs; +use anyhow::{Context, Result}; +use colored::*; +use std::fs; +use std::path::Path; + +/// Execute the CI init command +pub fn execute_ci_init(args: CiInitArgs) -> Result<()> { + // 1. Ensure .github/workflows exists + let workflow_dir = Path::new(".github/workflows"); + if !workflow_dir.exists() { + fs::create_dir_all(workflow_dir).context("Failed to create .github/workflows directory")?; + } + + let workflow_path = workflow_dir.join("performance.yml"); + if workflow_path.exists() && !args.force { + println!( + "{}", + "⚠️ .github/workflows/performance.yml already exists. Use --force to overwrite." + .yellow() + ); + return Ok(()); + } + + // 2. Generate YAML + let rpc_line = if let Some(rpc) = &args.rpc_url { + format!(" rpc_url: \"{}\"\n", rpc) + } else { + String::new() + }; + + let workflow_yaml = format!( + r#"name: Stylus Performance Check + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + performance-regression: + name: Gas Regression Check + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Run Stylus Performance Check + uses: CreativesOnchain/Stylus-Trace@v1 + with: + tx_hash: "{}" +{} threshold: "{}" +"#, + args.transaction_hash, rpc_line, args.threshold + ); + + // 3. Write file + fs::write(&workflow_path, workflow_yaml).context("Failed to write performance.yml")?; + + println!( + "{} {}", + "✅ Created".green(), + workflow_path.display().to_string().cyan() + ); + println!( + "{}", + "💡 Important: Ensure you have captured a baseline profile and committed it to 'artifacts/capture/baseline.json'".dimmed() + ); + + Ok(()) +} diff --git a/crates/stylus-trace-studio/src/commands/mod.rs b/crates/stylus-trace-studio/src/commands/mod.rs index 17e5cf5..128d31c 100644 --- a/crates/stylus-trace-studio/src/commands/mod.rs +++ b/crates/stylus-trace-studio/src/commands/mod.rs @@ -4,11 +4,13 @@ //! Commands orchestrate the various library components to perform user tasks. pub mod capture; +pub mod ci; pub mod diff; pub mod models; pub mod utils; // Re-export main command functions pub use capture::{execute_capture, validate_args}; -pub use models::CaptureArgs; +pub use ci::execute_ci_init; +pub use models::{CaptureArgs, CiInitArgs}; pub use utils::{display_schema, display_version, validate_profile_file}; diff --git a/crates/stylus-trace-studio/src/commands/models.rs b/crates/stylus-trace-studio/src/commands/models.rs index 426120d..9471fc1 100644 --- a/crates/stylus-trace-studio/src/commands/models.rs +++ b/crates/stylus-trace-studio/src/commands/models.rs @@ -142,3 +142,30 @@ impl Default for DiffArgs { } } } + +/// Arguments for the CI init command +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CiInitArgs { + /// Transaction hash to use for performance checks + pub transaction_hash: String, + + /// RPC endpoint URL (optional) + pub rpc_url: Option, + + /// Default percentage threshold for regressions + pub threshold: f64, + + /// Force overwrite existing files + pub force: bool, +} + +impl Default for CiInitArgs { + fn default() -> Self { + Self { + transaction_hash: String::new(), + rpc_url: Some("http://localhost:8547".to_string()), + threshold: 1.0, + force: false, + } + } +} diff --git a/test_project/.github/workflows/performance.yml b/test_project/.github/workflows/performance.yml new file mode 100644 index 0000000..438d7da --- /dev/null +++ b/test_project/.github/workflows/performance.yml @@ -0,0 +1,22 @@ +name: Stylus Performance Check + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + performance-regression: + name: Gas Regression Check + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Run Stylus Performance Check + uses: CreativesOnchain/Stylus-Trace@v1 + with: + tx_hash: "0xaaf333656d069068844d17f175fa5b73534c0b71599100bee2153791c3e81edc" + rpc_url: "http://localhost:8547" + threshold: "1.5" From 882768879618c29fd0afbf741d57692efee64ccc Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 01:47:42 +0100 Subject: [PATCH 2/9] use local action for internal regression check and default to @main --- .github/workflows/performance.yml | 2 +- README.md | 2 +- crates/stylus-trace-studio/src/commands/ci.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 06360f7..3a902cc 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Run Stylus Performance Check - uses: CreativesOnchain/Stylus-Trace@v1 + uses: ./ with: tx_hash: "0xaaf333656d069068844d17f175fa5b73534c0b71599100bee2153791c3e81edc" rpc_url: "http://localhost:8547" diff --git a/README.md b/README.md index 59ec376..8cc7d0c 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ You can use the [Stylus Trace Action](https://github.com/CreativesOnchain/Stylus ```yaml - name: Gas Regression Check - uses: CreativesOnchain/Stylus-Trace@v1 + uses: CreativesOnchain/Stylus-Trace@main with: tx_hash: "0x..." threshold: "1.0" # Fail if gas increases by > 1% diff --git a/crates/stylus-trace-studio/src/commands/ci.rs b/crates/stylus-trace-studio/src/commands/ci.rs index febcdc7..ada4ede 100644 --- a/crates/stylus-trace-studio/src/commands/ci.rs +++ b/crates/stylus-trace-studio/src/commands/ci.rs @@ -50,7 +50,7 @@ jobs: uses: actions/checkout@v4 - name: Run Stylus Performance Check - uses: CreativesOnchain/Stylus-Trace@v1 + uses: CreativesOnchain/Stylus-Trace@main with: tx_hash: "{}" {} threshold: "{}" From 0914d4a31649a0f7027621e7b818881c304153fa Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 01:51:52 +0100 Subject: [PATCH 3/9] use local action for internal regression check and default to @main --- CONTRIBUTING.md | 2 +- README.md | 2 +- action.yml | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38e5691..5172181 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ Before you begin, ensure you have: # Fork the repository on GitHub # Clone your fork git clone https://github.com/Timi16/stylus-trace.git -cd stylus-trace-studio +cd Stylus-Trace # Add upstream remote git remote add upstream https://github.com/Timi16/stylus-trace.git diff --git a/README.md b/README.md index 8cc7d0c..45dfcdc 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Stylus Trace is organized as a Cargo Workspace for modularity and performance: ### Via Cargo (Recommended) You can install the CLI directly from crates.io: ```bash -cargo install stylus-trace-studio +cargo install stylus-trace ``` ### Build from Source (Host Native) diff --git a/action.yml b/action.yml index 73f4250..60bd64d 100644 --- a/action.yml +++ b/action.yml @@ -26,12 +26,16 @@ inputs: runs: using: "composite" steps: - - name: Install Stylus Trace + - name: Setup Tool shell: bash run: | - if ! command -v stylus-trace &> /dev/null; then - echo "Installing stylus-trace-studio..." - cargo install stylus-trace-studio + if [ -f "Cargo.toml" ] && grep -q "name = \"stylus-trace\"" Cargo.toml; then + echo "Local Stylus-Trace detected. Building from source..." + cargo build --release --bin stylus-trace + echo "$(pwd)/target/release" >> $GITHUB_PATH + elif ! command -v stylus-trace &> /dev/null; then + echo "Installing stylus-trace..." + cargo install stylus-trace else echo "stylus-trace already installed." fi From 6b2ec89574e812b30dc7dfda24aa5f1ce49dcfa0 Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 02:20:29 +0100 Subject: [PATCH 4/9] refactor the binary and library name --- Cargo.lock | 24 +++++++++---------- Cargo.toml | 6 ++--- README.md | 2 +- action.yml | 8 +++---- bin/stylus-trace-studio/Cargo.toml | 15 ++++++++++++ .../src/main.rs | 12 +++++----- bin/stylus-trace/Cargo.toml | 15 ------------ .../Cargo.toml | 3 +-- .../README.md | 0 .../src/aggregator/metrics.rs | 0 .../src/aggregator/mod.rs | 0 .../src/aggregator/stack_builder.rs | 0 .../src/commands/capture.rs | 0 .../src/commands/ci.rs | 0 .../src/commands/diff.rs | 0 .../src/commands/mod.rs | 0 .../src/commands/models.rs | 0 .../src/commands/utils.rs | 0 .../src/diff/analyzer.rs | 0 .../src/diff/engine.rs | 4 ++-- .../src/diff/mod.rs | 4 ++-- .../src/diff/normalizer.rs | 0 .../src/diff/output.rs | 0 .../src/diff/schema.rs | 0 .../src/diff/threshold.rs | 0 .../src/flamegraph/diff_generator.rs | 0 .../src/flamegraph/generator.rs | 0 .../src/flamegraph/mod.rs | 0 .../src/lib.rs | 0 .../src/output/json.rs | 0 .../src/output/mod.rs | 0 .../src/output/svg.rs | 0 .../src/parser/hostio.rs | 0 .../src/parser/mod.rs | 0 .../src/parser/schema.rs | 0 .../src/parser/source_map.rs | 0 .../src/parser/stylus_trace.rs | 0 .../src/rpc/client.rs | 0 .../src/rpc/mod.rs | 0 .../src/rpc/types.rs | 0 .../src/utils/config.rs | 0 .../src/utils/error.rs | 0 .../src/utils/mod.rs | 0 .../tests/aggregator_tests.rs | 6 ++--- .../tests/command_tests.rs | 2 +- .../tests/diff_tests.rs | 4 ++-- .../tests/flamegraph_tests.rs | 2 +- .../tests/integration/end_to_end_test.rs | 2 +- .../tests/output_tests.rs | 6 ++--- .../tests/parser_tests.rs | 4 ++-- .../tests/rpc_tests.rs | 2 +- 51 files changed, 60 insertions(+), 61 deletions(-) create mode 100644 bin/stylus-trace-studio/Cargo.toml rename bin/{stylus-trace => stylus-trace-studio}/src/main.rs (96%) delete mode 100644 bin/stylus-trace/Cargo.toml rename crates/{stylus-trace-studio => stylus-trace-core}/Cargo.toml (91%) rename crates/{stylus-trace-studio => stylus-trace-core}/README.md (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/aggregator/metrics.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/aggregator/mod.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/aggregator/stack_builder.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/commands/capture.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/commands/ci.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/commands/diff.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/commands/mod.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/commands/models.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/commands/utils.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/diff/analyzer.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/diff/engine.rs (96%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/diff/mod.rs (90%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/diff/normalizer.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/diff/output.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/diff/schema.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/diff/threshold.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/flamegraph/diff_generator.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/flamegraph/generator.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/flamegraph/mod.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/lib.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/output/json.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/output/mod.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/output/svg.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/parser/hostio.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/parser/mod.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/parser/schema.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/parser/source_map.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/parser/stylus_trace.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/rpc/client.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/rpc/mod.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/rpc/types.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/utils/config.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/utils/error.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/src/utils/mod.rs (100%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/aggregator_tests.rs (91%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/command_tests.rs (97%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/diff_tests.rs (98%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/flamegraph_tests.rs (94%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/integration/end_to_end_test.rs (99%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/output_tests.rs (92%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/parser_tests.rs (94%) rename crates/{stylus-trace-studio => stylus-trace-core}/tests/rpc_tests.rs (73%) diff --git a/Cargo.lock b/Cargo.lock index a5e9e85..5a28418 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1411,36 +1411,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] -name = "stylus-trace" +name = "stylus-trace-core" version = "0.1.6" dependencies = [ + "addr2line", "anyhow", + "chrono", "clap", + "colored", "env_logger", + "gimli", "log", + "object", + "reqwest", + "serde", "serde_json", - "stylus-trace-studio", + "tempfile", + "thiserror", + "toml", ] [[package]] name = "stylus-trace-studio" version = "0.1.6" dependencies = [ - "addr2line", "anyhow", - "chrono", "clap", - "colored", "env_logger", - "gimli", "log", - "object", - "reqwest", - "serde", "serde_json", - "tempfile", - "thiserror", - "toml", + "stylus-trace-core", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index da1c4da..316cbc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [workspace] resolver = "2" members = [ - "bin/stylus-trace", - "crates/stylus-trace-studio", + "bin/stylus-trace-studio", + "crates/stylus-trace-core", ] [workspace.package] @@ -15,7 +15,7 @@ repository = "https://github.com/CreativesOnchain/Stylus-Trace" homepage = "https://github.com/CreativesOnchain/Stylus-Trace" [workspace.dependencies] -stylus-trace-studio = { version = "0.1.6", path = "crates/stylus-trace-studio" } +stylus-trace-core = { version = "0.1.6", path = "crates/stylus-trace-core" } clap = { version = "4.5", features = ["derive", "env"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/README.md b/README.md index 45dfcdc..8cc7d0c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Stylus Trace is organized as a Cargo Workspace for modularity and performance: ### Via Cargo (Recommended) You can install the CLI directly from crates.io: ```bash -cargo install stylus-trace +cargo install stylus-trace-studio ``` ### Build from Source (Host Native) diff --git a/action.yml b/action.yml index 60bd64d..ee4389a 100644 --- a/action.yml +++ b/action.yml @@ -29,13 +29,13 @@ runs: - name: Setup Tool shell: bash run: | - if [ -f "Cargo.toml" ] && grep -q "name = \"stylus-trace\"" Cargo.toml; then + if [ -f "bin/stylus-trace-studio/Cargo.toml" ]; then echo "Local Stylus-Trace detected. Building from source..." - cargo build --release --bin stylus-trace + cargo build --release --bin stylus-trace-studio echo "$(pwd)/target/release" >> $GITHUB_PATH elif ! command -v stylus-trace &> /dev/null; then - echo "Installing stylus-trace..." - cargo install stylus-trace + echo "Installing stylus-trace-studio..." + cargo install stylus-trace-studio else echo "stylus-trace already installed." fi diff --git a/bin/stylus-trace-studio/Cargo.toml b/bin/stylus-trace-studio/Cargo.toml new file mode 100644 index 0000000..f8091b0 --- /dev/null +++ b/bin/stylus-trace-studio/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "stylus-trace-studio" +version = { workspace = true } +authors = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +description = { workspace = true } + +[dependencies] +stylus-trace-core = { workspace = true } +clap.workspace = true +anyhow.workspace = true +env_logger.workspace = true +log.workspace = true +serde_json.workspace = true diff --git a/bin/stylus-trace/src/main.rs b/bin/stylus-trace-studio/src/main.rs similarity index 96% rename from bin/stylus-trace/src/main.rs rename to bin/stylus-trace-studio/src/main.rs index 3975b15..1a06d59 100644 --- a/bin/stylus-trace/src/main.rs +++ b/bin/stylus-trace-studio/src/main.rs @@ -8,11 +8,11 @@ use clap::{Args, Parser, Subcommand}; use env_logger::Env; use std::path::PathBuf; -use stylus_trace_studio::commands::{ +use stylus_trace_core::commands::{ display_schema, display_version, execute_capture, validate_args, validate_profile_file, CaptureArgs, }; -use stylus_trace_studio::flamegraph::FlamegraphConfig; +use stylus_trace_core::flamegraph::FlamegraphConfig; /// Stylus Trace Studio - Performance profiling for Arbitrum Stylus #[derive(Parser, Debug)] @@ -203,13 +203,13 @@ fn handle_ci(subcommand: CiSubcommands) -> Result<()> { threshold, force, } => { - let args = stylus_trace_studio::commands::models::CiInitArgs { + let args = stylus_trace_core::commands::models::CiInitArgs { transaction_hash: tx, rpc_url: rpc, threshold, force, }; - stylus_trace_studio::commands::execute_ci_init(args) + stylus_trace_core::commands::execute_ci_init(args) .context("CI initialization failed")?; } } @@ -286,7 +286,7 @@ fn handle_capture(command: Commands) -> Result<()> { /// Handle the diff command logic fn handle_diff(args: &DiffSubArgs) -> Result<()> { - let studio_args = stylus_trace_studio::commands::models::DiffArgs { + let studio_args = stylus_trace_core::commands::models::DiffArgs { baseline: resolve_artifact_path(args.baseline.clone(), "capture"), target: resolve_artifact_path(args.target.clone(), "capture"), threshold_file: args.threshold.clone(), @@ -304,7 +304,7 @@ fn handle_diff(args: &DiffSubArgs) -> Result<()> { hostio_threshold: args.hostio_threshold, }; - stylus_trace_studio::commands::diff::execute_diff(studio_args) + stylus_trace_core::commands::diff::execute_diff(studio_args) .context("Diff execution failed")?; Ok(()) } diff --git a/bin/stylus-trace/Cargo.toml b/bin/stylus-trace/Cargo.toml deleted file mode 100644 index ef206c2..0000000 --- a/bin/stylus-trace/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "stylus-trace" -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -description.workspace = true - -[dependencies] -stylus-trace-studio.workspace = true -clap.workspace = true -anyhow.workspace = true -env_logger.workspace = true -log.workspace = true -serde_json.workspace = true diff --git a/crates/stylus-trace-studio/Cargo.toml b/crates/stylus-trace-core/Cargo.toml similarity index 91% rename from crates/stylus-trace-studio/Cargo.toml rename to crates/stylus-trace-core/Cargo.toml index 547a0d6..740269f 100644 --- a/crates/stylus-trace-studio/Cargo.toml +++ b/crates/stylus-trace-core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "stylus-trace-studio" +name = "stylus-trace-core" version.workspace = true edition.workspace = true authors.workspace = true @@ -9,7 +9,6 @@ repository.workspace = true homepage.workspace = true documentation = "https://docs.rs/stylus-trace-studio" -# EITHER use a crate-local README (recommended) readme = "README.md" # OR point to root README (works too) diff --git a/crates/stylus-trace-studio/README.md b/crates/stylus-trace-core/README.md similarity index 100% rename from crates/stylus-trace-studio/README.md rename to crates/stylus-trace-core/README.md diff --git a/crates/stylus-trace-studio/src/aggregator/metrics.rs b/crates/stylus-trace-core/src/aggregator/metrics.rs similarity index 100% rename from crates/stylus-trace-studio/src/aggregator/metrics.rs rename to crates/stylus-trace-core/src/aggregator/metrics.rs diff --git a/crates/stylus-trace-studio/src/aggregator/mod.rs b/crates/stylus-trace-core/src/aggregator/mod.rs similarity index 100% rename from crates/stylus-trace-studio/src/aggregator/mod.rs rename to crates/stylus-trace-core/src/aggregator/mod.rs diff --git a/crates/stylus-trace-studio/src/aggregator/stack_builder.rs b/crates/stylus-trace-core/src/aggregator/stack_builder.rs similarity index 100% rename from crates/stylus-trace-studio/src/aggregator/stack_builder.rs rename to crates/stylus-trace-core/src/aggregator/stack_builder.rs diff --git a/crates/stylus-trace-studio/src/commands/capture.rs b/crates/stylus-trace-core/src/commands/capture.rs similarity index 100% rename from crates/stylus-trace-studio/src/commands/capture.rs rename to crates/stylus-trace-core/src/commands/capture.rs diff --git a/crates/stylus-trace-studio/src/commands/ci.rs b/crates/stylus-trace-core/src/commands/ci.rs similarity index 100% rename from crates/stylus-trace-studio/src/commands/ci.rs rename to crates/stylus-trace-core/src/commands/ci.rs diff --git a/crates/stylus-trace-studio/src/commands/diff.rs b/crates/stylus-trace-core/src/commands/diff.rs similarity index 100% rename from crates/stylus-trace-studio/src/commands/diff.rs rename to crates/stylus-trace-core/src/commands/diff.rs diff --git a/crates/stylus-trace-studio/src/commands/mod.rs b/crates/stylus-trace-core/src/commands/mod.rs similarity index 100% rename from crates/stylus-trace-studio/src/commands/mod.rs rename to crates/stylus-trace-core/src/commands/mod.rs diff --git a/crates/stylus-trace-studio/src/commands/models.rs b/crates/stylus-trace-core/src/commands/models.rs similarity index 100% rename from crates/stylus-trace-studio/src/commands/models.rs rename to crates/stylus-trace-core/src/commands/models.rs diff --git a/crates/stylus-trace-studio/src/commands/utils.rs b/crates/stylus-trace-core/src/commands/utils.rs similarity index 100% rename from crates/stylus-trace-studio/src/commands/utils.rs rename to crates/stylus-trace-core/src/commands/utils.rs diff --git a/crates/stylus-trace-studio/src/diff/analyzer.rs b/crates/stylus-trace-core/src/diff/analyzer.rs similarity index 100% rename from crates/stylus-trace-studio/src/diff/analyzer.rs rename to crates/stylus-trace-core/src/diff/analyzer.rs diff --git a/crates/stylus-trace-studio/src/diff/engine.rs b/crates/stylus-trace-core/src/diff/engine.rs similarity index 96% rename from crates/stylus-trace-studio/src/diff/engine.rs rename to crates/stylus-trace-core/src/diff/engine.rs index c74dc5a..a085351 100644 --- a/crates/stylus-trace-studio/src/diff/engine.rs +++ b/crates/stylus-trace-core/src/diff/engine.rs @@ -25,8 +25,8 @@ use super::DiffError; /// /// # Example /// ```ignore -/// use stylus_trace_studio::diff::generate_diff; -/// use stylus_trace_studio::output::json::read_profile; +/// use stylus_trace_core::diff::generate_diff; +/// use stylus_trace_core::output::json::read_profile; /// /// let baseline = read_profile("baseline.json")?; /// let target = read_profile("target.json")?; diff --git a/crates/stylus-trace-studio/src/diff/mod.rs b/crates/stylus-trace-core/src/diff/mod.rs similarity index 90% rename from crates/stylus-trace-studio/src/diff/mod.rs rename to crates/stylus-trace-core/src/diff/mod.rs index ee54655..854cb2f 100644 --- a/crates/stylus-trace-studio/src/diff/mod.rs +++ b/crates/stylus-trace-core/src/diff/mod.rs @@ -5,8 +5,8 @@ //! //! # Example //! ```ignore -//! use stylus_trace_studio::diff::{generate_diff, load_thresholds}; -//! use stylus_trace_studio::output::json::read_profile; +//! use stylus_trace_core::diff::{generate_diff, load_thresholds}; +//! use stylus_trace_core::output::json::read_profile; //! //! let baseline = read_profile("baseline.json")?; //! let target = read_profile("target.json")?; diff --git a/crates/stylus-trace-studio/src/diff/normalizer.rs b/crates/stylus-trace-core/src/diff/normalizer.rs similarity index 100% rename from crates/stylus-trace-studio/src/diff/normalizer.rs rename to crates/stylus-trace-core/src/diff/normalizer.rs diff --git a/crates/stylus-trace-studio/src/diff/output.rs b/crates/stylus-trace-core/src/diff/output.rs similarity index 100% rename from crates/stylus-trace-studio/src/diff/output.rs rename to crates/stylus-trace-core/src/diff/output.rs diff --git a/crates/stylus-trace-studio/src/diff/schema.rs b/crates/stylus-trace-core/src/diff/schema.rs similarity index 100% rename from crates/stylus-trace-studio/src/diff/schema.rs rename to crates/stylus-trace-core/src/diff/schema.rs diff --git a/crates/stylus-trace-studio/src/diff/threshold.rs b/crates/stylus-trace-core/src/diff/threshold.rs similarity index 100% rename from crates/stylus-trace-studio/src/diff/threshold.rs rename to crates/stylus-trace-core/src/diff/threshold.rs diff --git a/crates/stylus-trace-studio/src/flamegraph/diff_generator.rs b/crates/stylus-trace-core/src/flamegraph/diff_generator.rs similarity index 100% rename from crates/stylus-trace-studio/src/flamegraph/diff_generator.rs rename to crates/stylus-trace-core/src/flamegraph/diff_generator.rs diff --git a/crates/stylus-trace-studio/src/flamegraph/generator.rs b/crates/stylus-trace-core/src/flamegraph/generator.rs similarity index 100% rename from crates/stylus-trace-studio/src/flamegraph/generator.rs rename to crates/stylus-trace-core/src/flamegraph/generator.rs diff --git a/crates/stylus-trace-studio/src/flamegraph/mod.rs b/crates/stylus-trace-core/src/flamegraph/mod.rs similarity index 100% rename from crates/stylus-trace-studio/src/flamegraph/mod.rs rename to crates/stylus-trace-core/src/flamegraph/mod.rs diff --git a/crates/stylus-trace-studio/src/lib.rs b/crates/stylus-trace-core/src/lib.rs similarity index 100% rename from crates/stylus-trace-studio/src/lib.rs rename to crates/stylus-trace-core/src/lib.rs diff --git a/crates/stylus-trace-studio/src/output/json.rs b/crates/stylus-trace-core/src/output/json.rs similarity index 100% rename from crates/stylus-trace-studio/src/output/json.rs rename to crates/stylus-trace-core/src/output/json.rs diff --git a/crates/stylus-trace-studio/src/output/mod.rs b/crates/stylus-trace-core/src/output/mod.rs similarity index 100% rename from crates/stylus-trace-studio/src/output/mod.rs rename to crates/stylus-trace-core/src/output/mod.rs diff --git a/crates/stylus-trace-studio/src/output/svg.rs b/crates/stylus-trace-core/src/output/svg.rs similarity index 100% rename from crates/stylus-trace-studio/src/output/svg.rs rename to crates/stylus-trace-core/src/output/svg.rs diff --git a/crates/stylus-trace-studio/src/parser/hostio.rs b/crates/stylus-trace-core/src/parser/hostio.rs similarity index 100% rename from crates/stylus-trace-studio/src/parser/hostio.rs rename to crates/stylus-trace-core/src/parser/hostio.rs diff --git a/crates/stylus-trace-studio/src/parser/mod.rs b/crates/stylus-trace-core/src/parser/mod.rs similarity index 100% rename from crates/stylus-trace-studio/src/parser/mod.rs rename to crates/stylus-trace-core/src/parser/mod.rs diff --git a/crates/stylus-trace-studio/src/parser/schema.rs b/crates/stylus-trace-core/src/parser/schema.rs similarity index 100% rename from crates/stylus-trace-studio/src/parser/schema.rs rename to crates/stylus-trace-core/src/parser/schema.rs diff --git a/crates/stylus-trace-studio/src/parser/source_map.rs b/crates/stylus-trace-core/src/parser/source_map.rs similarity index 100% rename from crates/stylus-trace-studio/src/parser/source_map.rs rename to crates/stylus-trace-core/src/parser/source_map.rs diff --git a/crates/stylus-trace-studio/src/parser/stylus_trace.rs b/crates/stylus-trace-core/src/parser/stylus_trace.rs similarity index 100% rename from crates/stylus-trace-studio/src/parser/stylus_trace.rs rename to crates/stylus-trace-core/src/parser/stylus_trace.rs diff --git a/crates/stylus-trace-studio/src/rpc/client.rs b/crates/stylus-trace-core/src/rpc/client.rs similarity index 100% rename from crates/stylus-trace-studio/src/rpc/client.rs rename to crates/stylus-trace-core/src/rpc/client.rs diff --git a/crates/stylus-trace-studio/src/rpc/mod.rs b/crates/stylus-trace-core/src/rpc/mod.rs similarity index 100% rename from crates/stylus-trace-studio/src/rpc/mod.rs rename to crates/stylus-trace-core/src/rpc/mod.rs diff --git a/crates/stylus-trace-studio/src/rpc/types.rs b/crates/stylus-trace-core/src/rpc/types.rs similarity index 100% rename from crates/stylus-trace-studio/src/rpc/types.rs rename to crates/stylus-trace-core/src/rpc/types.rs diff --git a/crates/stylus-trace-studio/src/utils/config.rs b/crates/stylus-trace-core/src/utils/config.rs similarity index 100% rename from crates/stylus-trace-studio/src/utils/config.rs rename to crates/stylus-trace-core/src/utils/config.rs diff --git a/crates/stylus-trace-studio/src/utils/error.rs b/crates/stylus-trace-core/src/utils/error.rs similarity index 100% rename from crates/stylus-trace-studio/src/utils/error.rs rename to crates/stylus-trace-core/src/utils/error.rs diff --git a/crates/stylus-trace-studio/src/utils/mod.rs b/crates/stylus-trace-core/src/utils/mod.rs similarity index 100% rename from crates/stylus-trace-studio/src/utils/mod.rs rename to crates/stylus-trace-core/src/utils/mod.rs diff --git a/crates/stylus-trace-studio/tests/aggregator_tests.rs b/crates/stylus-trace-core/tests/aggregator_tests.rs similarity index 91% rename from crates/stylus-trace-studio/tests/aggregator_tests.rs rename to crates/stylus-trace-core/tests/aggregator_tests.rs index be5b9b5..e433c4d 100644 --- a/crates/stylus-trace-studio/tests/aggregator_tests.rs +++ b/crates/stylus-trace-core/tests/aggregator_tests.rs @@ -1,8 +1,8 @@ -use stylus_trace_studio::aggregator::metrics::{ +use stylus_trace_core::aggregator::metrics::{ calculate_gas_distribution, calculate_hot_paths, create_hot_path, }; -use stylus_trace_studio::aggregator::stack_builder::{map_hostio_to_label, CollapsedStack}; -use stylus_trace_studio::parser::HostIoType; +use stylus_trace_core::aggregator::stack_builder::{map_hostio_to_label, CollapsedStack}; +use stylus_trace_core::parser::HostIoType; #[test] fn test_map_hostio_to_label() { diff --git a/crates/stylus-trace-studio/tests/command_tests.rs b/crates/stylus-trace-core/tests/command_tests.rs similarity index 97% rename from crates/stylus-trace-studio/tests/command_tests.rs rename to crates/stylus-trace-core/tests/command_tests.rs index 7f8ae4f..0a25a7e 100644 --- a/crates/stylus-trace-studio/tests/command_tests.rs +++ b/crates/stylus-trace-core/tests/command_tests.rs @@ -1,4 +1,4 @@ -use stylus_trace_studio::commands::{validate_args, CaptureArgs}; +use stylus_trace_core::commands::{validate_args, CaptureArgs}; #[test] fn test_validate_args_valid() { diff --git a/crates/stylus-trace-studio/tests/diff_tests.rs b/crates/stylus-trace-core/tests/diff_tests.rs similarity index 98% rename from crates/stylus-trace-studio/tests/diff_tests.rs rename to crates/stylus-trace-core/tests/diff_tests.rs index 1019fcb..52e082b 100644 --- a/crates/stylus-trace-studio/tests/diff_tests.rs +++ b/crates/stylus-trace-core/tests/diff_tests.rs @@ -3,8 +3,8 @@ //! Includes all integration and unit tests for the diffing functionality. use std::collections::HashMap; -use stylus_trace_studio::diff::*; -use stylus_trace_studio::parser::schema::{HostIoSummary, HotPath, Profile}; +use stylus_trace_core::diff::*; +use stylus_trace_core::parser::schema::{HostIoSummary, HotPath, Profile}; // ============================================================================ // SHARED TEST HELPERS diff --git a/crates/stylus-trace-studio/tests/flamegraph_tests.rs b/crates/stylus-trace-core/tests/flamegraph_tests.rs similarity index 94% rename from crates/stylus-trace-studio/tests/flamegraph_tests.rs rename to crates/stylus-trace-core/tests/flamegraph_tests.rs index d6453fa..1744855 100644 --- a/crates/stylus-trace-studio/tests/flamegraph_tests.rs +++ b/crates/stylus-trace-core/tests/flamegraph_tests.rs @@ -1,4 +1,4 @@ -use stylus_trace_studio::flamegraph::generator::{get_truncated_name, NodeCategory}; +use stylus_trace_core::flamegraph::generator::{get_truncated_name, NodeCategory}; #[test] fn test_node_category() { diff --git a/crates/stylus-trace-studio/tests/integration/end_to_end_test.rs b/crates/stylus-trace-core/tests/integration/end_to_end_test.rs similarity index 99% rename from crates/stylus-trace-studio/tests/integration/end_to_end_test.rs rename to crates/stylus-trace-core/tests/integration/end_to_end_test.rs index 15cca56..908c07f 100644 --- a/crates/stylus-trace-studio/tests/integration/end_to_end_test.rs +++ b/crates/stylus-trace-core/tests/integration/end_to_end_test.rs @@ -1,6 +1,6 @@ use std::fs; use std::path::PathBuf; -use stylus_trace_studio::*; +use stylus_trace_core::*; use tempfile::TempDir; #[test] diff --git a/crates/stylus-trace-studio/tests/output_tests.rs b/crates/stylus-trace-core/tests/output_tests.rs similarity index 92% rename from crates/stylus-trace-studio/tests/output_tests.rs rename to crates/stylus-trace-core/tests/output_tests.rs index 8302a27..4a25c24 100644 --- a/crates/stylus-trace-studio/tests/output_tests.rs +++ b/crates/stylus-trace-core/tests/output_tests.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use std::path::Path; -use stylus_trace_studio::output::validate_path; -use stylus_trace_studio::output::{read_profile, write_profile, write_svg}; -use stylus_trace_studio::parser::schema::{HostIoSummary, HotPath, Profile}; +use stylus_trace_core::output::validate_path; +use stylus_trace_core::output::{read_profile, write_profile, write_svg}; +use stylus_trace_core::parser::schema::{HostIoSummary, HotPath, Profile}; use tempfile::NamedTempFile; fn create_test_profile() -> Profile { diff --git a/crates/stylus-trace-studio/tests/parser_tests.rs b/crates/stylus-trace-core/tests/parser_tests.rs similarity index 94% rename from crates/stylus-trace-studio/tests/parser_tests.rs rename to crates/stylus-trace-core/tests/parser_tests.rs index ae7d7ac..2908133 100644 --- a/crates/stylus-trace-studio/tests/parser_tests.rs +++ b/crates/stylus-trace-core/tests/parser_tests.rs @@ -1,8 +1,8 @@ use serde_json::json; -use stylus_trace_studio::parser::hostio::{ +use stylus_trace_core::parser::hostio::{ parse_hostio_event, HostIoEvent, HostIoStats, HostIoType, }; -use stylus_trace_studio::parser::stylus_trace::{extract_total_gas, parse_gas_value, parse_trace}; +use stylus_trace_core::parser::stylus_trace::{extract_total_gas, parse_gas_value, parse_trace}; #[test] fn test_hostio_event_parsing() { diff --git a/crates/stylus-trace-studio/tests/rpc_tests.rs b/crates/stylus-trace-core/tests/rpc_tests.rs similarity index 73% rename from crates/stylus-trace-studio/tests/rpc_tests.rs rename to crates/stylus-trace-core/tests/rpc_tests.rs index f82249d..dd964a4 100644 --- a/crates/stylus-trace-studio/tests/rpc_tests.rs +++ b/crates/stylus-trace-core/tests/rpc_tests.rs @@ -1,4 +1,4 @@ -use stylus_trace_studio::rpc::client::normalize_tx_hash; +use stylus_trace_core::rpc::client::normalize_tx_hash; #[test] fn test_normalize_tx_hash() { From 07ae8ac0ac64bfb2e2b8d5e451a7bcd31b9c1962 Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 02:27:22 +0100 Subject: [PATCH 5/9] refactor the binary and library name --- action.yml | 2 +- bin/stylus-trace-studio/Cargo.toml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ee4389a..573a136 100644 --- a/action.yml +++ b/action.yml @@ -31,7 +31,7 @@ runs: run: | if [ -f "bin/stylus-trace-studio/Cargo.toml" ]; then echo "Local Stylus-Trace detected. Building from source..." - cargo build --release --bin stylus-trace-studio + cargo build --release --bin stylus-trace echo "$(pwd)/target/release" >> $GITHUB_PATH elif ! command -v stylus-trace &> /dev/null; then echo "Installing stylus-trace-studio..." diff --git a/bin/stylus-trace-studio/Cargo.toml b/bin/stylus-trace-studio/Cargo.toml index f8091b0..c6cd671 100644 --- a/bin/stylus-trace-studio/Cargo.toml +++ b/bin/stylus-trace-studio/Cargo.toml @@ -6,6 +6,10 @@ edition = { workspace = true } license = { workspace = true } description = { workspace = true } +[[bin]] +name = "stylus-trace" +path = "src/main.rs" + [dependencies] stylus-trace-core = { workspace = true } clap.workspace = true From f827d54c11da9193d49878f48e95bd9ce154da44 Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 02:32:54 +0100 Subject: [PATCH 6/9] refactor the binary and library name --- .github/workflows/performance.yml | 2 +- crates/stylus-trace-core/tests/parser_tests.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 3a902cc..0a295d7 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -18,5 +18,5 @@ jobs: uses: ./ with: tx_hash: "0xaaf333656d069068844d17f175fa5b73534c0b71599100bee2153791c3e81edc" - rpc_url: "http://localhost:8547" + rpc_url: "https://sepolia-rollup.arbitrum.io/rpc" threshold: "1" diff --git a/crates/stylus-trace-core/tests/parser_tests.rs b/crates/stylus-trace-core/tests/parser_tests.rs index 2908133..432ba22 100644 --- a/crates/stylus-trace-core/tests/parser_tests.rs +++ b/crates/stylus-trace-core/tests/parser_tests.rs @@ -1,7 +1,5 @@ use serde_json::json; -use stylus_trace_core::parser::hostio::{ - parse_hostio_event, HostIoEvent, HostIoStats, HostIoType, -}; +use stylus_trace_core::parser::hostio::{parse_hostio_event, HostIoEvent, HostIoStats, HostIoType}; use stylus_trace_core::parser::stylus_trace::{extract_total_gas, parse_gas_value, parse_trace}; #[test] From ef510821e38430ed3d35bf37278ba7a053fe4537 Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 02:40:10 +0100 Subject: [PATCH 7/9] add skip_capture for offline verification in smoke test --- .github/workflows/performance.yml | 6 ++++++ action.yml | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 0a295d7..ee51090 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -14,9 +14,15 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 + - name: Prepare Dummy Profiles + run: | + mkdir -p artifacts/capture + cp artifacts/capture/baseline.json artifacts/capture/current_profile.json + - name: Run Stylus Performance Check uses: ./ with: tx_hash: "0xaaf333656d069068844d17f175fa5b73534c0b71599100bee2153791c3e81edc" rpc_url: "https://sepolia-rollup.arbitrum.io/rpc" threshold: "1" + skip_capture: "true" diff --git a/action.yml b/action.yml index 573a136..70a719e 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,10 @@ inputs: description: 'Use Stylus Ink units instead of Gas' required: false default: 'false' + skip_capture: + description: 'Skip the capture step (useful for testing with pre-existing profiles)' + required: false + default: 'false' runs: using: "composite" @@ -43,6 +47,16 @@ runs: - name: Capture Current Profile shell: bash run: | + if [ "${{ inputs.skip_capture }}" = "true" ]; then + echo "Skipping capture as requested. Ensuring profile exists..." + mkdir -p artifacts/capture + if [ ! -f "artifacts/capture/current_profile.json" ]; then + echo "Error: current_profile.json not found but skip_capture is true" + exit 1 + fi + exit 0 + fi + INK_FLAG="" if [ "${{ inputs.ink }}" = "true" ]; then INK_FLAG="--ink" From 10d7ba97ea8d392057ce6ac197fdbcb393f119c7 Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 03:00:19 +0100 Subject: [PATCH 8/9] add persistent test fixtures and fix dummy profile staging --- .github/workflows/performance.yml | 5 +- .gitignore | 1 + tests/fixtures/baseline.json | 235 ++++++++++++++++++++++++++++ tests/fixtures/current_profile.json | 235 ++++++++++++++++++++++++++++ 4 files changed, 474 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/baseline.json create mode 100644 tests/fixtures/current_profile.json diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index ee51090..f4ea618 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -17,12 +17,13 @@ jobs: - name: Prepare Dummy Profiles run: | mkdir -p artifacts/capture - cp artifacts/capture/baseline.json artifacts/capture/current_profile.json + cp tests/fixtures/baseline.json artifacts/capture/baseline.json + cp tests/fixtures/current_profile.json artifacts/capture/current_profile.json - name: Run Stylus Performance Check uses: ./ with: tx_hash: "0xaaf333656d069068844d17f175fa5b73534c0b71599100bee2153791c3e81edc" rpc_url: "https://sepolia-rollup.arbitrum.io/rpc" - threshold: "1" + threshold: "10" skip_capture: "true" diff --git a/.gitignore b/.gitignore index 03ff088..697cf74 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ target .DS_Store *.svg *.json +!tests/fixtures/*.json profiles/ flamegraphs.svg profile.json diff --git a/tests/fixtures/baseline.json b/tests/fixtures/baseline.json new file mode 100644 index 0000000..65b3c44 --- /dev/null +++ b/tests/fixtures/baseline.json @@ -0,0 +1,235 @@ +{ + "version": "1.0.0", + "transaction_hash": "0x47404c910245f1bf9759ca9a62a13358478e2ea72bcc896c8e0096ad6ef25e3b", + "total_gas": 460111929, + "hostio_summary": { + "total_calls": 15, + "by_type": { + "msg_sender": 1, + "storage_flush_cache": 1, + "read_args": 1, + "write_result": 1, + "storage_load": 2, + "other": 3, + "storage_cache": 2, + "msg_value": 1, + "emit_log": 1, + "msg_reentrant": 1, + "native_keccak256": 1 + }, + "total_hostio_gas": 460111929 + }, + "hot_paths": [ + { + "stack": "storage_flush_cache", + "gas": 400068073, + "percentage": 86.9501631634506, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "storage_load_bytes32", + "gas": 42136960, + "percentage": 9.15798034004026, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "emit_log", + "gas": 17649734, + "percentage": 3.835965313561779, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "native_keccak256", + "gas": 121800, + "percentage": 0.026471819642824346, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "write_result", + "gas": 41162, + "percentage": 0.008946084073382066, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "storage_cache_bytes32", + "gas": 36960, + "percentage": 0.008032828029546697, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "read_args", + "gas": 13560, + "percentage": 0.0029471089848661586, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "msg_value", + "gas": 13440, + "percentage": 0.0029210283743806176, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "msg_sender", + "gas": 13440, + "percentage": 0.0029210283743806176, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "msg_reentrant", + "gas": 8400, + "percentage": 0.0018256427339878858, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "pay_for_memory_grow", + "gas": 8400, + "percentage": 0.0018256427339878858, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "user_returned", + "gas": 0, + "percentage": 0.0, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "user_entrypoint", + "gas": 0, + "percentage": 0.0, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + } + ], + "all_stacks": [ + { + "stack": "storage_flush_cache", + "weight": 400068073, + "last_pc": 0 + }, + { + "stack": "storage_load_bytes32", + "weight": 42136960, + "last_pc": 0 + }, + { + "stack": "emit_log", + "weight": 17649734, + "last_pc": 0 + }, + { + "stack": "native_keccak256", + "weight": 121800, + "last_pc": 0 + }, + { + "stack": "write_result", + "weight": 41162, + "last_pc": 0 + }, + { + "stack": "storage_cache_bytes32", + "weight": 36960, + "last_pc": 0 + }, + { + "stack": "read_args", + "weight": 13560, + "last_pc": 0 + }, + { + "stack": "msg_value", + "weight": 13440, + "last_pc": 0 + }, + { + "stack": "msg_sender", + "weight": 13440, + "last_pc": 0 + }, + { + "stack": "msg_reentrant", + "weight": 8400, + "last_pc": 0 + }, + { + "stack": "pay_for_memory_grow", + "weight": 8400, + "last_pc": 0 + }, + { + "stack": "user_returned", + "weight": 0, + "last_pc": 0 + }, + { + "stack": "user_entrypoint", + "weight": 0, + "last_pc": 0 + } + ], + "generated_at": "2026-02-19T00:39:29.748484086+00:00" +} \ No newline at end of file diff --git a/tests/fixtures/current_profile.json b/tests/fixtures/current_profile.json new file mode 100644 index 0000000..8932528 --- /dev/null +++ b/tests/fixtures/current_profile.json @@ -0,0 +1,235 @@ +{ + "version": "1.0.0", + "transaction_hash": "0x3399614ebaafc03f8e2d9d9f0e6249559346e2c8313322cde391b9760fd05e83", + "total_gas": 621681975, + "hostio_summary": { + "total_calls": 78, + "by_type": { + "emit_log": 10, + "storage_cache": 20, + "msg_value": 1, + "native_keccak256": 10, + "write_result": 1, + "msg_reentrant": 1, + "read_args": 1, + "msg_sender": 10, + "storage_load": 20, + "storage_flush_cache": 1, + "other": 3 + }, + "total_hostio_gas": 621681975 + }, + "hot_paths": [ + { + "stack": "storage_flush_cache", + "gas": 400068073, + "percentage": 64.35252895984317, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "emit_log", + "gas": 176497340, + "percentage": 28.390293928016813, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "storage_load_bytes32", + "gas": 42469600, + "percentage": 6.831402824571196, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "native_keccak256", + "gas": 1218000, + "percentage": 0.19592010850885613, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "storage_cache_bytes32", + "gas": 1209600, + "percentage": 0.19456893534672612, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "msg_sender", + "gas": 134400, + "percentage": 0.02161877059408068, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "write_result", + "gas": 41162, + "percentage": 0.006621070202332953, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "read_args", + "gas": 13560, + "percentage": 0.002181179533152783, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "msg_value", + "gas": 13440, + "percentage": 0.002161877059408068, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "pay_for_memory_grow", + "gas": 8400, + "percentage": 0.0013511731621300425, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "msg_reentrant", + "gas": 8400, + "percentage": 0.0013511731621300425, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "user_returned", + "gas": 0, + "percentage": 0.0, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + }, + { + "stack": "user_entrypoint", + "gas": 0, + "percentage": 0.0, + "source_hint": { + "file": "unknown", + "line": null, + "column": null, + "function": "0x0" + } + } + ], + "all_stacks": [ + { + "stack": "storage_flush_cache", + "weight": 400068073, + "last_pc": 0 + }, + { + "stack": "emit_log", + "weight": 176497340, + "last_pc": 0 + }, + { + "stack": "storage_load_bytes32", + "weight": 42469600, + "last_pc": 0 + }, + { + "stack": "native_keccak256", + "weight": 1218000, + "last_pc": 0 + }, + { + "stack": "storage_cache_bytes32", + "weight": 1209600, + "last_pc": 0 + }, + { + "stack": "msg_sender", + "weight": 134400, + "last_pc": 0 + }, + { + "stack": "write_result", + "weight": 41162, + "last_pc": 0 + }, + { + "stack": "read_args", + "weight": 13560, + "last_pc": 0 + }, + { + "stack": "msg_value", + "weight": 13440, + "last_pc": 0 + }, + { + "stack": "pay_for_memory_grow", + "weight": 8400, + "last_pc": 0 + }, + { + "stack": "msg_reentrant", + "weight": 8400, + "last_pc": 0 + }, + { + "stack": "user_returned", + "weight": 0, + "last_pc": 0 + }, + { + "stack": "user_entrypoint", + "weight": 0, + "last_pc": 0 + } + ], + "generated_at": "2026-02-19T00:41:58.238020041+00:00" +} \ No newline at end of file From 35ff9022ffc73c177fd134d6d43a3255b772c57c Mon Sep 17 00:00:00 2001 From: intelliDean Date: Thu, 26 Feb 2026 03:10:01 +0100 Subject: [PATCH 9/9] use identical profiles for smoke test to ensure passing status --- .github/workflows/performance.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index f4ea618..5da8e89 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -18,7 +18,7 @@ jobs: run: | mkdir -p artifacts/capture cp tests/fixtures/baseline.json artifacts/capture/baseline.json - cp tests/fixtures/current_profile.json artifacts/capture/current_profile.json + cp tests/fixtures/baseline.json artifacts/capture/current_profile.json - name: Run Stylus Performance Check uses: ./