Open
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
5 tasks
Contributor
There was a problem hiding this comment.
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_shakingmodule that detects v2 metadata viasoroban-metaand delegates stripping tosoroban_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 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" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
soroban-metaand calls the new SDK strip implementation.optimize.soroban_spec::strip::shake_contract_spec.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