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

"packagizing" the useCompiler #1348

Open
4 tasks
Tracked by #1665
manuelwedler opened this issue Apr 15, 2024 · 2 comments
Open
4 tasks
Tracked by #1665

"packagizing" the useCompiler #1348

manuelwedler opened this issue Apr 15, 2024 · 2 comments

Comments

@manuelwedler
Copy link
Collaborator

manuelwedler commented Apr 15, 2024

We use a function useCompiler in various places to compile contracts. This function provides a small wrapper around the solc compiler in order to download it and invoke the compilation.

The code was duplicated across multiple places, namely in the tests of lib-sourcify, in serverless/compiler-lambda and in the server code. In order to minimize the effort for maintenance and synchronization of these code parts, they should be moved into a public package. Basically the content of services/server/src/server/services/compiler/local/solidityCompiler.ts should be the content of the new package.

Tasks

Preview Give feedback
@manuelwedler manuelwedler converted this from a draft issue Apr 15, 2024
@manuelwedler manuelwedler changed the title "packagizing" the userCompiler "packagizing" the useCompiler Apr 15, 2024
@marcocastignoli
Copy link
Member

marcocastignoli commented Apr 16, 2024

My proposal is to build this package with the idea of shipping multiple compilers in mind. For example doing something like this: https://github.com/lodash/lodash/tree/4.5.0-npm-packages. (We can actually do the same thing just by having multiple compilers under packages/)

The final objective should be being able to do something like this in nodejs

import { CheckedContract } from "@ethereum-sourcify/lib-sourcify"
import {initCompiler} from "@ethereum-sourcify/compilers/solidity/nodejs"

const compiler = initCompiler(...)
const contract = new CheckedContract(compiler, metadata, sources);

And something like this in the browser

import { CheckedContract } from "@ethereum-sourcify/lib-sourcify"
import {initCompiler} from "@ethereum-sourcify/compilers/solidity/browser"

const compiler = initCompiler(...)

const contract = new CheckedContract(compiler, metadata, sources);

And something like this in the lambda function

import {useCompiler} from "@ethereum-sourcify/compilers/solidity/nodejs"

exports.handler = async (event) => {
    return {
      success: true,
      body: await useCompiler(
        event.version,
        event.solcJsonInput,
        event.forceEmscripten
      ),
    }
};

@kuzdogan kuzdogan moved this from Triage to Todo in Sourcify Public Apr 18, 2024
@kuzdogan kuzdogan moved this from Sprint - Up Next to Backlog in Sourcify Public May 13, 2024
@manuelwedler manuelwedler moved this from Backlog to Sprint - Candidates in Sourcify Public Dec 9, 2024
@manuelwedler manuelwedler moved this from Sprint - Candidates to Backlog in Sourcify Public Dec 9, 2024
@marcocastignoli
Copy link
Member

marcocastignoli commented Jan 6, 2025

I'm adding here more context regarding this task after analyzing #1665 and #1784

New package: @ethereum-sourcify/compilers

  • Keep in mind we have multiple languages and each can have multiple versions, and potentially multiple stages in the compilation
    • Languages
      • Solidity
        • solc
        • solcjson
        • solar
      • Vyper
        • vyper-c

(This is just the executable compilers, not interfaces, Interfaces should still be in lib-sourcify)

@marcocastignoli marcocastignoli moved this from Backlog to Sprint - Candidates in Sourcify Public Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Sprint - Candidates
Development

No branches or pull requests

2 participants