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

Codeowner #31

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @danipopes @klkvr @mattsse
* @hedgar2017
82 changes: 67 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,83 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.11.4](https://github.com/foundry-rs/compilers/releases/tag/v0.11.4) - 2024-10-02
## [0.11.5](https://github.com/foundry-rs/compilers/releases/tag/v0.11.5) - 2024-10-14

### Bug Fixes

- Include `evm.legacyAssembly` output ([#206](https://github.com/foundry-rs/compilers/issues/206))
- Ast Node Bindings ([#199](https://github.com/foundry-rs/compilers/issues/199))
- Actualize output selection options ([#196](https://github.com/foundry-rs/compilers/issues/196))
- Accept partial first sourcemap element ([#209](https://github.com/foundry-rs/compilers/issues/209))

### Dependencies

- [deps] Bump alloy ([#193](https://github.com/foundry-rs/compilers/issues/193))
### Miscellaneous Tasks

### Documentation
- Allow adding vyper sources with `add_raw_source` w/ `.vy` / `.vyi` extension ([#211](https://github.com/foundry-rs/compilers/issues/211))
- [`ci`] Fix deny (add `ZLib` exception) ([#212](https://github.com/foundry-rs/compilers/issues/212))

- Fix typos ([#202](https://github.com/foundry-rs/compilers/issues/202))
## [0.11.4](https://github.com/foundry-rs/compilers/releases/tag/v0.11.4) - 2024-10-02

### Features

- Better extra_args handling ([#208](https://github.com/foundry-rs/compilers/issues/208))
- Better error messages for incompatible versions ([#200](https://github.com/foundry-rs/compilers/issues/200))

### Miscellaneous Tasks

- Release 0.11.4

## [0.11.3](https://github.com/foundry-rs/compilers/releases/tag/v0.11.3) - 2024-09-30

### Miscellaneous Tasks

- Release 0.11.3
- Proper generate legacy asm extra output file ([#207](https://github.com/foundry-rs/compilers/issues/207))

## [0.11.2](https://github.com/foundry-rs/compilers/releases/tag/v0.11.2) - 2024-09-30

### Bug Fixes

- Include `evm.legacyAssembly` output ([#206](https://github.com/foundry-rs/compilers/issues/206))

### Documentation

- Fix typos ([#202](https://github.com/foundry-rs/compilers/issues/202))

### Miscellaneous Tasks

- Release 0.11.2
- Clippy ([#204](https://github.com/foundry-rs/compilers/issues/204))
- Use serde_json::from_str ([#203](https://github.com/foundry-rs/compilers/issues/203))

## [0.11.1](https://github.com/foundry-rs/compilers/releases/tag/v0.11.1) - 2024-09-17

### Bug Fixes

- Ast Node Bindings ([#199](https://github.com/foundry-rs/compilers/issues/199))
- Actualize output selection options ([#196](https://github.com/foundry-rs/compilers/issues/196))

### Features

- Better error messages for incompatible versions ([#200](https://github.com/foundry-rs/compilers/issues/200))

### Miscellaneous Tasks

- Release 0.11.1
- Improve error handling in source map parsing ([#201](https://github.com/foundry-rs/compilers/issues/201))
- Clippy happy ([#195](https://github.com/foundry-rs/compilers/issues/195))
- Fix up the README example ([#194](https://github.com/foundry-rs/compilers/issues/194))

## [0.11.0](https://github.com/foundry-rs/compilers/releases/tag/v0.11.0) - 2024-09-02

### Dependencies

- [deps] Bump alloy ([#193](https://github.com/foundry-rs/compilers/issues/193))

### Miscellaneous Tasks

- Release 0.11.0

## [0.10.3](https://github.com/foundry-rs/compilers/releases/tag/v0.10.3) - 2024-08-26

### Bug Fixes

- [flatten] Update license handling logic ([#184](https://github.com/foundry-rs/compilers/issues/184))
- Unify logic for ignored warnings ([#179](https://github.com/foundry-rs/compilers/issues/179))
- Remove outdated build infos ([#177](https://github.com/foundry-rs/compilers/issues/177))
- Make remappings resolution more deterministic ([#176](https://github.com/foundry-rs/compilers/issues/176))

### Documentation

Expand All @@ -57,16 +92,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Always provide `Default` for `MultiCompiler` ([#188](https://github.com/foundry-rs/compilers/issues/188))
- [vyper] Add experimental codegen to settings ([#186](https://github.com/foundry-rs/compilers/issues/186))
- More user-friendly error when no compiler is available ([#185](https://github.com/foundry-rs/compilers/issues/185))
- Sanitize EVM version for vyper ([#181](https://github.com/foundry-rs/compilers/issues/181))

### Miscellaneous Tasks

- Release 0.10.3
- Release 0.10.2

### Other

- Incorrect Default EVM Version for Solidity Compiler 0.4.21-0.5.4 ([#189](https://github.com/foundry-rs/compilers/issues/189))

## [0.10.2](https://github.com/foundry-rs/compilers/releases/tag/v0.10.2) - 2024-08-01

### Bug Fixes

- Unify logic for ignored warnings ([#179](https://github.com/foundry-rs/compilers/issues/179))
- Remove outdated build infos ([#177](https://github.com/foundry-rs/compilers/issues/177))
- Make remappings resolution more deterministic ([#176](https://github.com/foundry-rs/compilers/issues/176))

### Features

- Sanitize EVM version for vyper ([#181](https://github.com/foundry-rs/compilers/issues/181))

### Miscellaneous Tasks

- Release 0.10.2

### Other

- Update README to link docs and update install instructions ([#180](https://github.com/foundry-rs/compilers/issues/180))

## [0.10.1](https://github.com/foundry-rs/compilers/releases/tag/v0.10.1) - 2024-07-26
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
authors = ["Foundry Maintainers"]
version = "0.11.4"
version = "0.11.5"
rust-version = "1.70"
readme = "README.md"
license = "MIT OR Apache-2.0"
Expand All @@ -31,11 +31,11 @@ unused-must-use = "deny"
all = "warn"

[workspace.dependencies]
foundry-compilers = { path = "crates/compilers", version = "0.11.4" }
foundry-compilers-artifacts = { path = "crates/artifacts/artifacts", version = "0.11.4" }
foundry-compilers-artifacts-solc = { path = "crates/artifacts/solc", version = "0.11.4" }
foundry-compilers-artifacts-vyper = { path = "crates/artifacts/vyper", version = "0.11.4" }
foundry-compilers-core = { path = "crates/core", version = "0.11.4" }
foundry-compilers = { path = "crates/compilers", version = "0.11.5" }
foundry-compilers-artifacts = { path = "crates/artifacts/artifacts", version = "0.11.5" }
foundry-compilers-artifacts-solc = { path = "crates/artifacts/solc", version = "0.11.5" }
foundry-compilers-artifacts-vyper = { path = "crates/artifacts/vyper", version = "0.11.5" }
foundry-compilers-core = { path = "crates/core", version = "0.11.5" }

alloy-json-abi = { version = "0.8", features = ["serde_json"] }
alloy-primitives = { version = "0.8", features = ["serde", "rand"] }
Expand Down
102 changes: 74 additions & 28 deletions crates/artifacts/solc/src/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ impl From<std::num::TryFromIntError> for SyntaxError {

#[derive(PartialEq, Eq)]
enum Token<'a> {
/// Decimal number
Number(&'a str),
/// `;`
Semicolon,
/// `:`
Colon,
/// `i` which represents an instruction that goes into a function
In,
Expand Down Expand Up @@ -175,7 +178,7 @@ pub type SourceMap = Vec<SourceElement>;
/// A single element in a [`SourceMap`].
///
/// Solidity reference: <https://docs.soliditylang.org/en/latest/internals/source_mappings.html#source-mappings>
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct SourceElement {
offset: u32,
length: u32,
Expand All @@ -184,12 +187,37 @@ pub struct SourceElement {
jump_and_modifier_depth: u32,
}

impl fmt::Debug for SourceElement {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SourceElement")
.field("offset", &self.offset())
.field("length", &self.length())
.field("index", &self.index_i32())
.field("jump", &self.jump())
.field("modifier_depth", &self.modifier_depth())
.field("formatted", &format_args!("{self}"))
.finish()
}
}

impl Default for SourceElement {
fn default() -> Self {
Self::new()
}
}

impl SourceElement {
/// Creates a new source element with default values.
pub fn new_invalid() -> Self {
pub fn new() -> Self {
Self { offset: 0, length: 0, index: -1, jump_and_modifier_depth: 0 }
}

/// Creates a new source element with default values.
#[deprecated = "use `new` instead"]
pub fn new_invalid() -> Self {
Self::new()
}

/// The byte-offset to the start of the range in the source file.
#[inline]
pub fn offset(&self) -> u32 {
Expand Down Expand Up @@ -295,10 +323,10 @@ impl fmt::Display for SourceElementBuilder {
}

if let Some(s) = self.offset {
if self.index == Some(None) {
if s == 0 && self.index == Some(None) {
f.write_str("-1")?;
} else {
s.fmt(f)?;
write!(f, "{s}")?;
}
}
if self.length.is_none()
Expand All @@ -311,10 +339,10 @@ impl fmt::Display for SourceElementBuilder {
f.write_char(':')?;

if let Some(s) = self.length {
if self.index == Some(None) {
if s == 0 && self.index == Some(None) {
f.write_str("-1")?;
} else {
s.fmt(f)?;
write!(f, "{s}")?;
}
}
if self.index.is_none() && self.jump.is_none() && self.modifier_depth.is_none() {
Expand All @@ -324,15 +352,15 @@ impl fmt::Display for SourceElementBuilder {

if let Some(s) = self.index {
let s = s.map(|s| s as i64).unwrap_or(-1);
s.fmt(f)?;
write!(f, "{s}")?;
}
if self.jump.is_none() && self.modifier_depth.is_none() {
return Ok(());
}
f.write_char(':')?;

if let Some(s) = self.jump {
s.fmt(f)?;
write!(f, "{s}")?;
}
if self.modifier_depth.is_none() {
return Ok(());
Expand All @@ -353,17 +381,11 @@ impl fmt::Display for SourceElementBuilder {

impl SourceElementBuilder {
fn finish(self, prev: Option<SourceElement>) -> Result<SourceElement, SyntaxError> {
let no_prev = prev.is_none();
let mut element = prev.unwrap_or_else(SourceElement::new_invalid);
let mut element = prev.unwrap_or_default();
macro_rules! get_field {
(| $field:ident | $e:expr) => {
if let Some($field) = self.$field {
$e;
} else if no_prev {
return Err(SyntaxError::new(
None,
format!("no previous {}", stringify!($field)),
));
}
};
}
Expand Down Expand Up @@ -498,9 +520,9 @@ impl<'input> Parser<'input> {
#[cfg(test)]
if let Some(out) = self.output.as_mut() {
if self.last_element.is_some() {
let _ = out.write_char(';');
out.write_char(';').unwrap();
}
let _ = out.write_str(&builder.to_string());
write!(out, "{builder}").unwrap();
}

let element = builder.finish(self.last_element.take())?;
Expand Down Expand Up @@ -554,29 +576,53 @@ pub fn parse(input: &str) -> Result<SourceMap, SyntaxError> {
mod tests {
use super::*;

fn parse_test(input: &str) {
match parse_test_(input) {
Ok(_) => {}
Err(e) => panic!("{e}"),
}
}

fn parse_test_(input: &str) -> Result<SourceMap, SyntaxError> {
let mut s = String::new();
let mut p = Parser::new(input);
p.output = Some(&mut s);
let sm = p.collect::<Result<SourceMap, _>>()?;
if s != input {
return Err(SyntaxError::new(
None,
format!("mismatched output:\n actual: {s:?}\n expected: {input:?}\n sm: {sm:#?}"),
));
}
Ok(sm)
}

#[test]
fn empty() {
parse_test("");
}

#[test]
fn can_parse_source_maps() {
fn source_maps() {
// all source maps from the compiler output test data
let source_maps = include_str!("../../../../test-data/out-source-maps.txt");

for (line, s) in source_maps.lines().enumerate() {
parse(s).unwrap_or_else(|e| panic!("Failed to parse line {line}: {e}"));
let line = line + 1;
parse_test_(s).unwrap_or_else(|e| panic!("Failed to parse line {line}: {e}\n{s:?}"));
}
}

#[test]
fn can_parse_foundry_cheatcodes_sol_maps() {
fn cheatcodes() {
let s = include_str!("../../../../test-data/cheatcodes.sol-sourcemap.txt");
let mut out = String::new();
let mut parser = Parser::new(s);
parser.output = Some(&mut out);
let _map = parser.collect::<Result<SourceMap, _>>().unwrap();
assert_eq!(out, s);
parse_test(s);
}

// https://github.com/foundry-rs/foundry/issues/8986
#[test]
fn can_parse_empty() {
let s = Parser::new("").collect::<Result<SourceMap, _>>().unwrap();
assert_eq!(s.len(), 0);
fn univ4_deployer() {
let s = ":::-:0;;1888:10801:91;2615:100;;;2679:3;2615:100;;;;2700:4;2615:100;;;;-1:-1:-1;2615:100:91;;;;2546:169;;;-1:-1:-1;;2546:169:91;;;;;;;;;;;2615:100;2546:169;;;2615:100;2797:101;;;;;;;;;-1:-1:-1;;2797:101:91;;;;;;;;2546:169;2721:177;;;;;;;;;;;;;;;;;;2957:101;1888:10801;2957:101;2797;2957;;;-1:-1:-1;;2957:101:91;;;;356:29:89;2957:101:91;;;;2904:154;;;-1:-1:-1;;2904:154:91;;;;;;;;;;;;-1:-1:-1;;;;;;2904:154:91;;;;;;;;4018:32;;;;;4048:2;4018:32;;;4056:74;;;-1:-1:-1;;;;;4056:74:91;;;;;;;;1888:10801;;;;;;;;;;;;;;;;";
parse_test(s);
}
}
2 changes: 1 addition & 1 deletion crates/compilers/src/project_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub(crate) fn create_contract_file(path: &Path, content: impl AsRef<str>) -> Res

fn contract_file_name(name: &str) -> String {
let name = name.trim();
if name.ends_with(".sol") {
if name.ends_with(".sol") || name.ends_with(".vy") || name.ends_with(".vyi") {
name.to_string()
} else {
format!("{name}.sol")
Expand Down
2 changes: 2 additions & 0 deletions crates/compilers/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

// <https://github.com/tokio-rs/tracing/blob/master/tracing-core/src/dispatch.rs>

#![allow(static_mut_refs)] // TODO

use foundry_compilers_artifacts::remappings::Remapping;
use semver::Version;
use std::{
Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ allow = [
"LicenseRef-webpki",
"BSL-1.0",
"Unicode-3.0",
"Zlib",
]

# Allow 1 or more licenses on a per-crate basis, so that particular licenses
Expand Down