-
Notifications
You must be signed in to change notification settings - Fork 414
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
Stream lambda function compiler responses #1340
Changes from 3 commits
9285615
42865bf
db6ad48
08f8d8f
5aa6120
c026b30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
CompilerOutput, | ||
ISolidityCompiler, | ||
JsonInput, | ||
} from "@ethereum-sourcify/lib-sourcify"; | ||
import logger from "../../../../common/logger"; | ||
import { SolcLambda } from "../lambda/SolcLambda"; | ||
import { SolcLocal } from "../local/SolcLocal"; | ||
|
||
export class SolcLambdaWithLocalFallback implements ISolidityCompiler { | ||
private solcLambda = new SolcLambda(); | ||
private solcLocal = new SolcLocal(); | ||
|
||
public async compile( | ||
version: string, | ||
solcJsonInput: JsonInput, | ||
forceEmscripten: boolean = false | ||
): Promise<CompilerOutput> { | ||
let compilerOutput: CompilerOutput; | ||
try { | ||
compilerOutput = await this.solcLambda.compile( | ||
version, | ||
solcJsonInput, | ||
forceEmscripten | ||
); | ||
} catch (e) { | ||
logger.error( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that here we need to run local compilation only on the specific "too big output" error not all the errors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I pushed the new commit before I saw your comment update) The problem with this is that I cannot really find out which error code is given by AWS in the case the response is too big. I was checking the docs and they were not very helpful (https://docs.aws.amazon.com/lambda/latest/api/API_InvokeWithResponseStreamCompleteEvent.html). We could also try to find a contract whose compiler output is bigger than the response stream limit of 20 MB. I'm just not sure how to go about that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking... Maybe on the lambda side you can find the output size and if it's more than 20mb send a specific response. Could this work? Continues here: #1340 (comment) |
||
"Lambda compilation error - Falling back to local compilation" | ||
); | ||
compilerOutput = await this.solcLocal.compile( | ||
version, | ||
solcJsonInput, | ||
forceEmscripten | ||
); | ||
} | ||
return compilerOutput; | ||
} | ||
} |
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.
Continuing this comment: #1340 (comment)
like this:
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.
Ah nice idea! That should work out! Thanks for the hint