Skip to content

Commit 497dae2

Browse files
authored
factor out solc JSON interface crate (paritytech#264)
The differential testing framework will make a second consumer. There seems to be no re-usable Rust crate for this. But we already have everything here, just needs a small refactor to make it fully re-usable. - Mostly decouple the solc JSON-input-output interface types from the `solidity` frontend crate - Expose the JSON-input-output interface types in a dedicated crate --------- Signed-off-by: Cyrill Leutwiler <[email protected]>
1 parent 36ea69b commit 497dae2

File tree

45 files changed

+328
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+328
-245
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Supported `polkadot-sdk` rev:`c29e72a8628835e34deb6aa7db9a78a2e4eabcee`
88

99
### Added
1010
- Support for solc v0.8.29
11+
- Decouples the solc JSON-input-output type definitions from the Solidity fronted and expose them via a dedicated crate.
1112
- `--supported-solc-versions` for `resolc` binary to return a `semver` range of supported `solc` versions.
1213

1314
### Changed

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ lld-sys = { version = "0.1.0-dev.12", path = "crates/lld-sys" }
2424
revive-llvm-context = { version = "0.1.0-dev.12", path = "crates/llvm-context" }
2525
revive-runtime-api = { version = "0.1.0-dev.12", path = "crates/runtime-api" }
2626
revive-runner = { version = "0.1.0-dev.12", path = "crates/runner" }
27+
revive-solc-json-interface = { version = "0.1.0-dev.12", path = "crates/solc-json-interface" }
2728
revive-solidity = { version = "0.1.0-dev.12", path = "crates/solidity" }
2829
revive-stdlib = { version = "0.1.0-dev.12", path = "crates/stdlib" }
2930
revive-build-utils = { version = "0.1.0-dev.12", path = "crates/build-utils" }

crates/llvm-context/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ revive-common = { workspace = true }
2929
revive-runtime-api = { workspace = true }
3030
revive-linker = { workspace = true }
3131
revive-stdlib = { workspace = true }
32+
revive-solc-json-interface = { workspace = true }

crates/llvm-context/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ pub use self::polkavm::evm::memory as polkavm_evm_memory;
6666
pub use self::polkavm::evm::r#return as polkavm_evm_return;
6767
pub use self::polkavm::evm::return_data as polkavm_evm_return_data;
6868
pub use self::polkavm::evm::storage as polkavm_evm_storage;
69-
pub use self::polkavm::metadata_hash::MetadataHash as PolkaVMMetadataHash;
7069
pub use self::polkavm::r#const as polkavm_const;
7170
pub use self::polkavm::Dependency as PolkaVMDependency;
7271
pub use self::polkavm::DummyDependency as PolkaVMDummyDependency;

crates/llvm-context/src/optimizer/settings/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
pub mod size_level;
44

5+
use revive_solc_json_interface::SolcStandardJsonInputSettingsOptimizer;
56
use serde::Deserialize;
67
use serde::Serialize;
78

@@ -226,3 +227,18 @@ impl std::fmt::Display for Settings {
226227
)
227228
}
228229
}
230+
231+
impl TryFrom<&SolcStandardJsonInputSettingsOptimizer> for Settings {
232+
type Error = anyhow::Error;
233+
234+
fn try_from(value: &SolcStandardJsonInputSettingsOptimizer) -> Result<Self, Self::Error> {
235+
let mut result = match value.mode {
236+
Some(mode) => Self::try_from_cli(mode)?,
237+
None => Self::cycles(),
238+
};
239+
if value.fallback_to_optimizing_for_size.unwrap_or_default() {
240+
result.enable_fallback_to_size();
241+
}
242+
Ok(result)
243+
}
244+
}

crates/llvm-context/src/polkavm/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
pub mod r#const;
44
pub mod context;
55
pub mod evm;
6-
pub mod metadata_hash;
76

87
pub use self::r#const::*;
98

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "revive-solc-json-interface"
3+
version.workspace = true
4+
authors.workspace = true
5+
license.workspace = true
6+
edition.workspace = true
7+
repository.workspace = true
8+
rust-version.workspace = true
9+
description = "Rust bindings for the solc standard JSON and combined JSON interface"
10+
11+
[features]
12+
default = ["parallel"]
13+
parallel = ["rayon"]
14+
resolc = [] # The resolc binary adds a bunch of custom fields to the format
15+
16+
[dependencies]
17+
revive-common = { workspace = true }
18+
19+
anyhow = { workspace = true }
20+
rayon = { workspace = true, optional = true }
21+
semver = { workspace = true }
22+
serde = { workspace = true }
23+
serde_json = { workspace = true }

0 commit comments

Comments
 (0)