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: allow multiple languages for compilers #128

Merged
merged 25 commits into from
Jun 3, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented May 27, 2024

This changes Compiler trait to also have associated Language type which is supposed to be an enum with languages supported by the compiler. Also CompilerVersionManager trait is removed and compiler now should contain full logic for version resolution.

For version management we have to keep track of all different languages and versions to compile them with, thus I've rewritten some of the graph logic to use HashMap<C::Language, HashMap<Version, Sources>> during compilation.

Now, instead of representing a binary wrapper, Compiler is more like binary manager which resolves and installs binaries dynamically depending on requested language and version.

It's mostly ready, I just need to add logic for compilation with locked compiler version.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes a lot of sense and simplifies things a lot.

I only have doc nits

Comment on lines 28 to 33
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SolcLanguages {
Solidity,
Yul,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs some docs


#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SolcLanguages {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
pub enum SolcLanguages {
pub enum SolcLanguage {

@@ -136,45 +206,31 @@ impl<E> Default for CompilerOutput<E> {
}
}

pub trait Language: Hash + Eq + Clone + Debug {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also be Display and I think this should be 'static

self
}
#[derive(Debug, Clone, Serialize)]
pub struct SolcVerionedInput {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo


type Input = SolcInput;
impl Compiler for SolcRegistry {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, it's a bit weird that we implement compiler on registry, maybe we can rename this? so it's more obvious that this is compiler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, not sure how to name it

perhaps MultiSolc or just SolcCompiler?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SolcCompiler fits

Copy link
Member

@DaniPopes DaniPopes May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solc compiler = Sol Compiler Compiler 😀

@klkvr klkvr marked this pull request as ready for review May 30, 2024 14:56
@klkvr klkvr requested a review from Evalir as a code owner May 30, 2024 14:56
@klkvr klkvr changed the title [wip] feat: allow multiple languages for compilers feat: allow multiple languages for compilers May 30, 2024
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, I only have pedantic doc nits hehe

src/artifacts/mod.rs Show resolved Hide resolved
src/compile/mod.rs Show resolved Hide resolved
src/compilers/mod.rs Outdated Show resolved Hide resolved
src/compilers/mod.rs Outdated Show resolved Hide resolved
src/compilers/mod.rs Show resolved Hide resolved
src/compilers/multi.rs Outdated Show resolved Hide resolved
src/compilers/vyper/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gg

let mut solc = match self {
Self::Specific(solc) => solc.clone(),

#[cfg(feature = "svm-solc")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can consider removing this feature

@mattsse mattsse merged commit 4e1ee6c into main Jun 3, 2024
14 checks passed
@DaniPopes DaniPopes deleted the klkvr/language-abstraction branch June 3, 2024 16:38
@klkvr klkvr mentioned this pull request Jun 5, 2024
klkvr added a commit that referenced this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants