Skip to content

Use new spec filtering logic from SDK#2551

Open
mootz12 wants to merge 1 commit intomainfrom
spec-shaking-update
Open

Use new spec filtering logic from SDK#2551
mootz12 wants to merge 1 commit intomainfrom
spec-shaking-update

Conversation

@mootz12
Copy link
Copy Markdown
Contributor

@mootz12 mootz12 commented May 4, 2026

What

  • Move v2 contract spec shaking into a dedicated contract module that detects v2 metadata with soroban-meta and calls the new SDK strip implementation.
  • Applies spec shaking during build only, removes it from optimize.
  • Replace CLI-local spec filtering and deduplication with soroban_spec::strip::shake_contract_spec.
  • Return Rust interface generation errors from contract info interface.

Why

Spec shaking v2 needs the marker graph during build, but deployed artifacts should not retain that sidecar custom section. The SDK owns the marker format and strip logic, so delegating to it keeps the CLI aligned with upstream behavior and avoids duplicated filtering code.

Rust interface generation can now fail; returning that error gives users the real failure instead of assuming generation is infallible.

Known limitations

Copilot AI review requested due to automatic review settings May 4, 2026 20:06
@mootz12 mootz12 requested a review from a team as a code owner May 4, 2026 20:06
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX May 4, 2026
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedcargo/​stellar-xdr@​26.0.0 ⏵ 26.0.193100100100100
Updatedcargo/​ethnum@​1.5.2 ⏵ 1.5.310010095100100

View full report

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors Soroban contract spec shaking to use the upstream SDK’s v2-aware strip/shake implementation, ensuring the marker-graph sidecar is used during build but removed from produced artifacts. It also improves error reporting for Rust interface generation in contract info interface.

Changes:

  • Introduces a dedicated contract::spec_shaking module that detects v2 metadata via soroban-meta and delegates stripping to soroban_spec::strip::shake_contract_spec.
  • Moves spec shaking to contract build (including post-optimization) and removes CLI-local filtering/dedup logic.
  • Propagates Rust interface generation errors from contract info interface.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
cmd/soroban-cli/src/commands/contract/spec_shaking.rs Adds v2 detection + SDK-based spec shaking, with unit tests ensuring sidecar removal.
cmd/soroban-cli/src/commands/contract/mod.rs Exposes the new spec_shaking module within the contract command module.
cmd/soroban-cli/src/commands/contract/info/interface.rs Returns Rust interface generation errors instead of assuming generation is infallible.
cmd/soroban-cli/src/commands/contract/build.rs Applies spec shaking during build flow and adjusts build summary byte handling.
cmd/soroban-cli/Cargo.toml Adds soroban-meta dependency and soroban-spec-markers for tests.
cmd/crates/soroban-test/tests/it/build.rs Updates spec-shaking fixture setup and adds an integration assertion that the sidecar graph is removed.
cmd/crates/soroban-test/tests/fixtures/workspace-with-spec-shaking/contracts/shaking/src/lib.rs Minor fixture tweak to avoid an unused parameter.
cmd/crates/soroban-test/Cargo.toml Adds soroban-spec-markers dev-dependency for the new integration test.
Cargo.toml Updates workspace deps and adds a git-based patch section to pull unreleased SDK changes.
Cargo.lock Lockfile updates reflecting dependency changes (including git-sourced Soroban crates).

let out_file_path = Path::new(out_dir).join(&file);
fs::copy(target_file_path, &out_file_path).map_err(Error::CopyingWasmFile)?;
fs::copy(&target_file_path, &out_file_path).map_err(Error::CopyingWasmFile)?;
spec_shaking::shake_file_if_v2(&target_file_path)?;
Comment on lines +313 to 315
let wasm_bytes_before_optimization =
fs::read(&final_path).map_err(Error::ReadingWasmFile)?;

Comment on lines +21 to +29
pub fn shake_file_if_v2(wasm_path: &Path) -> Result<(), Error> {
let wasm = fs::read(wasm_path).map_err(Error::ReadingWasmFile)?;
let Some(shaken) = shake_if_v2(&wasm)? else {
return Ok(());
};

fs::remove_file(wasm_path).map_err(Error::DeletingArtifact)?;
fs::write(wasm_path, shaken).map_err(Error::WritingWasmFile)
}
Comment on lines 68 to 75
let res = match self.output {
InfoOutput::XdrBase64 => base64,
InfoOutput::Json => serde_json::to_string(&spec)?,
InfoOutput::JsonFormatted => serde_json::to_string_pretty(&spec)?,
InfoOutput::Rust => soroban_spec_rust::generate_without_file(&spec)
InfoOutput::Rust => soroban_spec_rust::generate_without_file(&spec)?
.to_formatted_string()
.expect("Unexpected spec format error"),
};
.as_table_mut()
.unwrap()
.insert("soroban-sdk".to_string(), toml::Value::Table(soroban_sdk));
fixture_table.insert("patch".to_string(), workspace_table["patch"].clone());
Comment thread Cargo.toml
Comment on lines +147 to +157

[patch.crates-io]
soroban-sdk = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
soroban-sdk-macros = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
soroban-meta = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
soroban-spec = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
soroban-spec-rust = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
soroban-ledger-snapshot = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
soroban-token-sdk = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
soroban-token-spec = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
stellar-asset-spec = { git = "https://github.com/stellar/rs-soroban-sdk", branch = "spec-shaking-marker-fix-3" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

2 participants