-
Notifications
You must be signed in to change notification settings - Fork 0
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(resolc): integrate revive compiler for evm to resolc compilation #1
base: main
Are you sure you want to change the base?
Conversation
9b66169
to
b2150f7
Compare
72f27b9
to
b647eca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collection of nits
pub use foundry_compilers_artifacts_solc as solc; | ||
pub use foundry_compilers_artifacts_vyper as vyper; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accidental?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 6? If yes nope just following integration similar to solc and vyper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9, the new newline
pub missing_libraries: Option<HashSet<String>>, | ||
} | ||
|
||
impl Default for ResolcContract { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can't find where it's used?
Self { abi: c.abi.as_ref(), bin, bin_runtime } | ||
} | ||
} | ||
fn create_compact_bytecode( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn create_compact_bytecode( | |
impl ResolcContract { | |
fn json_abi(&self) -> Option<JsonAbi> { | |
self.abi.clone() | |
} | |
fn compact_bytecode(&self) -> Option<CompactBytecode> { | |
self.resolc_evm.as_ref().and_then(|resolc_evm| resolc_evm.bytecode.as_ref()).map( | |
|bytecode| CompactBytecode { | |
object: bytecode.object.clone(), | |
source_map: None, | |
link_references: BTreeMap::default(), | |
}, | |
) | |
} | |
fn compact_deployed_bytecode(&self) -> Option<CompactDeployedBytecode> { | |
self.resolc_evm | |
.as_ref() | |
.and_then(|resolc_evm| resolc_evm.deployed_bytecode.as_ref()) | |
.and_then(|item| item.bytecode.as_ref()) | |
.map(|deployed_bytecode| { | |
let compact_bytecode_deployed = CompactBytecode { | |
object: deployed_bytecode.object.clone(), | |
source_map: None, | |
link_references: BTreeMap::default(), | |
}; | |
CompactDeployedBytecode { | |
bytecode: Some(compact_bytecode_deployed), | |
immutable_references: BTreeMap::default(), | |
} | |
}) | |
.to_owned() | |
} | |
} |
} | ||
} | ||
|
||
impl<'a> From<&'a ResolcContract> for CompactContractRef<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl<'a> From<&'a ResolcContract> for CompactContractRef<'a> { | |
impl<'a> From<&'a ResolcContract> for CompactContractRef<'a> { | |
fn from(c: &'a ResolcContract) -> Self { | |
let (bin, bin_runtime) = match &c.resolc_evm { | |
Some(evm) => { | |
let bin = evm.bytecode.as_ref().map(|code| &code.object); | |
let bin_runtime = evm | |
.deployed_bytecode | |
.as_ref() | |
.and_then(|deployed| deployed.bytecode.as_ref().map(|code| &code.object)); | |
(bin, bin_runtime) | |
} | |
_ => (None, None), | |
}; | |
Self { abi: c.abi.as_ref(), bin, bin_runtime } | |
} | |
} |
} | ||
} | ||
|
||
impl From<ResolcContract> for CompactContractBytecode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl From<ResolcContract> for CompactContractBytecode { | |
impl From<ResolcContract> for CompactContractBytecode { | |
fn from(value: ResolcContract) -> Self { | |
Self { | |
abi: value.json_abi(), | |
bytecode: value.compact_bytecode(), | |
deployed_bytecode: value.compact_deployed_bytecode(), | |
} | |
} | |
} |
or it's intended to always return every field to None if at least one of them is None?
"aarch64" => Ok(ResolcOS::LinuxARM64), | ||
_ => Ok(ResolcOS::LinuxAMD64), | ||
}, | ||
"macos" | "darwin" => match std::env::consts::ARCH { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"macos" | "darwin" => match std::env::consts::ARCH { | |
"macos" => match std::env::consts::ARCH { |
.filter(|v| uniques.insert((v.major, v.minor, v.patch))) | ||
.map(CompilerVersion::Remote), | ||
); | ||
all_versions.sort_unstable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why unstable sort here?
Ok(Self::compilers_dir()?.join(format!("{}v{}", os.get_resolc_prefix(), version))) | ||
} | ||
|
||
pub fn find_installed_version(version: &Version) -> Result<Option<PathBuf>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn find_installed_version(version: &Version) -> Result<Option<PathBuf>> { | |
pub fn find_installed_version(version: &Version) -> Result<Option<PathBuf>> { | |
Self::compiler_path(version) | |
.map(|resolc| if !resolc.is_file() { None } else { Some(resolc) }) | |
} |
}) | ||
} | ||
|
||
#[cfg(feature = "async")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it's marked as feature async if the api used is non async? shouldn't it be possible to use tokio API?
"aarch64" => assert!(matches!(os, ResolcOS::LinuxARM64)), | ||
_ => assert!(matches!(os, ResolcOS::LinuxAMD64)), | ||
}, | ||
"macos" | "darwin" => match std::env::consts::ARCH { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"macos" | "darwin" => match std::env::consts::ARCH { | |
"macos" => match std::env::consts::ARCH { |
This commit removes some omissions i made related to github releases and downloading from Github aswell as fixing tests that had flawed logic
This commit fixes the issue with mac based systems seems like resolc doesnt work but wasm does
Description
This PR adds the initial integration of Revive compiler with foundry-compilers to compile EVM contracts to Resolc bytecode.
Changes
Testing
Impact
Checklist