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

feat: add support for preprocessing sources #252

Merged
merged 75 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
abd521f
wip
klkvr Sep 11, 2024
fb64ca7
wip
klkvr Sep 11, 2024
0876b01
add preprocessor
klkvr Sep 11, 2024
314f284
wip
klkvr Sep 11, 2024
86f0562
wip
klkvr Sep 11, 2024
af6550f
fixes
klkvr Sep 13, 2024
276bc94
helper libs
klkvr Sep 13, 2024
fa5d7bf
some docs
klkvr Sep 13, 2024
15ce120
clean up
klkvr Sep 13, 2024
a379db3
fixes
klkvr Sep 16, 2024
25e5ef9
Merge branch 'main' into klkvr/pp-test-rebase
grandizzy Feb 18, 2025
3faaa02
Port to solar
grandizzy Feb 19, 2025
0f78197
Clippy
grandizzy Feb 19, 2025
594c09b
Changes after review
grandizzy Feb 19, 2025
3105272
Patch solar to get HIR visitor impl
grandizzy Feb 19, 2025
7d0edb8
Review changes
grandizzy Feb 19, 2025
4025e5a
reuse replace source fn
grandizzy Feb 19, 2025
0c940d1
Clippy
grandizzy Feb 19, 2025
79d0a0f
Cleanup, move Update type in lib
grandizzy Feb 19, 2025
d37cafb
Change replace_source_content sig, move apply_updates
grandizzy Feb 20, 2025
c526df6
Port to solar HIR, refactor
grandizzy Feb 26, 2025
e691a96
add preprocessing parse constructors
grandizzy Feb 26, 2025
4241d2b
Contract id cleanup
grandizzy Feb 26, 2025
c86c4aa
Cleanup, filter collected dependencies to be source contracts
grandizzy Feb 27, 2025
f4a109d
Cleanup, remove Hir:: usage, use ContractIds
grandizzy Feb 28, 2025
f0818ea
Optional preprocessed cache
grandizzy Mar 3, 2025
2d1e59f
Review cleanup
grandizzy Mar 3, 2025
c354a7c
Simplify find and remove branches
grandizzy Mar 3, 2025
719d4e8
Autodetect and recompile mocks
grandizzy Mar 4, 2025
4342f82
Fix description
grandizzy Mar 4, 2025
d8ece14
Cleanup autodetect and update cached mocks:
grandizzy Mar 5, 2025
c4ec52c
Invalidate cache on preprocess option toggle
grandizzy Mar 5, 2025
15ec56f
Bump solar rev
grandizzy Mar 14, 2025
2f80366
Move preproc tests
grandizzy Mar 14, 2025
1a3de9f
Preprocess by input reference
grandizzy Mar 14, 2025
5c4becb
Merge branch 'main' into klkvr/pp-test-rebase
grandizzy Mar 14, 2025
0fd4caa
Update crates/compilers/src/preprocessor/deps.rs
grandizzy Mar 20, 2025
6259e8d
Merge branch 'main' into klkvr/pp-test-rebase
grandizzy Mar 24, 2025
c41692d
Bump solar
grandizzy Mar 24, 2025
8138172
Rust backtrace to debug win failure
grandizzy Mar 24, 2025
2947ec6
Update crates/compilers/src/lib.rs
grandizzy Mar 24, 2025
af7cc59
Update crates/compilers/src/preprocessor/deps.rs
grandizzy Mar 24, 2025
cb0f1d8
Handle vars without name in ctor
grandizzy Mar 24, 2025
ebda056
Better way to determine constructor call
grandizzy Mar 24, 2025
64c5ecd
Use Path, add named args test
grandizzy Mar 25, 2025
67ac483
Ensure / for win
grandizzy Mar 25, 2025
6b3e887
clean
DaniPopes Mar 25, 2025
c04627d
Use solar main
grandizzy Mar 25, 2025
0d0f5d9
Ensure / for win in import
grandizzy Mar 25, 2025
6a81147
Support value and salt in constructors
grandizzy Mar 26, 2025
322e80a
Handle named args with call args and offset
grandizzy Mar 26, 2025
5d02555
cleaning
DaniPopes Mar 26, 2025
8dd35c3
chore: replace SourceMapLocation with Range<usize>
DaniPopes Mar 26, 2025
a7bc520
fmt
DaniPopes Mar 26, 2025
6b907d1
Cleanup BytecodeDependencyKind::New
grandizzy Mar 26, 2025
446a5d8
Use sources that are already read
grandizzy Mar 26, 2025
4eefc93
fix: correctly set paths in ParsingContext
DaniPopes Mar 27, 2025
9b15b7a
clippy
grandizzy Mar 28, 2025
d27f6f4
Merge branch 'main' into klkvr/pp-test-rebase
grandizzy Mar 28, 2025
fb5ebc2
bump
DaniPopes Mar 28, 2025
59ebda6
feat: avoid reparsing for interface_repr_hash
DaniPopes Mar 31, 2025
4451c71
perf: cache interface_hash in ArtifactsCacheInner
DaniPopes Mar 31, 2025
73ae218
chore: change &PathBuf to &Path
DaniPopes Apr 1, 2025
a9341af
com
DaniPopes Apr 1, 2025
a48b275
fix: correctly create Session and ParsingContext from solc input
DaniPopes Apr 2, 2025
49b65bf
fix: better check for 'is_source_file'
DaniPopes Apr 3, 2025
de0bebc
chore: rm &PathBuf
DaniPopes Apr 3, 2025
14cabe3
test: dapptools instead of hardhat paths
DaniPopes Apr 3, 2025
93b3c3f
Continue compiling if preprocessor fails parsing
grandizzy Apr 3, 2025
5377589
chore: move preprocessor to foundry
DaniPopes Apr 3, 2025
48df36d
check
DaniPopes Apr 3, 2025
743ff47
clippy
DaniPopes Apr 3, 2025
a3f4c4d
nit
DaniPopes Apr 3, 2025
87b9346
Bump solar version
grandizzy Apr 7, 2025
2527d65
Merge branch 'main' into klkvr/pp-test-rebase
grandizzy Apr 7, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/target
/Cargo.lock

cache/
/cache
test-data/**/cache/

.vscode
/.envrc
Expand All @@ -12,4 +13,4 @@ cache/
devenv.local.nix
.direnv
.pre-commit-config.yaml
.lock
.lock
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ manual-string-new = "warn"
uninlined-format-args = "warn"
use-self = "warn"
redundant-clone = "warn"
# until <https://github.com/rust-lang/rust-clippy/issues/13885> is fixed
literal-string-with-formatting-args = "allow"

result-large-err = "allow"
large-enum-variant = "allow"

[workspace.lints.rust]
rust-2018-idioms = "warn"
Expand Down Expand Up @@ -54,7 +55,8 @@ semver = { version = "1.0", features = ["serde"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1.0"
similar-asserts = "1"
solar-parse = { version = "=0.1.1", default-features = false }
solar-parse = { version = "=0.1.2", default-features = false }
solar-sema = { version = "=0.1.2", default-features = false }
svm = { package = "svm-rs", version = "0.5", default-features = false }
tempfile = "3.9"
thiserror = "2"
Expand Down
2 changes: 1 addition & 1 deletion crates/artifacts/solc/src/ast/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{fmt, fmt::Write, str::FromStr};
/// Represents the source location of a node: `<start byte>:<length>:<source index>`.
///
/// The `start`, `length` and `index` can be -1 which is represented as `None`
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct SourceLocation {
pub start: Option<usize>,
pub length: Option<usize>,
Expand Down
8 changes: 7 additions & 1 deletion crates/artifacts/solc/src/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ impl Source {
/// Generate a non-cryptographically secure checksum of the file's content.
#[cfg(feature = "checksum")]
pub fn content_hash(&self) -> String {
alloy_primitives::hex::encode(<md5::Md5 as md5::Digest>::digest(self.content.as_bytes()))
Self::content_hash_of(&self.content)
}

/// Generate a non-cryptographically secure checksum of the given source.
#[cfg(feature = "checksum")]
pub fn content_hash_of(src: &str) -> String {
alloy_primitives::hex::encode(<md5::Md5 as md5::Digest>::digest(src))
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/compilers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ thiserror.workspace = true
path-slash.workspace = true
yansi.workspace = true
solar-parse.workspace = true
solar-sema.workspace = true
futures-util = { workspace = true, optional = true }
tokio = { workspace = true, optional = true }

Expand Down
Loading