-
Notifications
You must be signed in to change notification settings - Fork 468
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
support cross-compilation of stylus programs #2605
Conversation
… appended with local target if not in list
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.
small comments
results := make(chan result, len(targets)) | ||
for _, target := range targets { | ||
if target == rawdb.TargetWavm { | ||
results <- result{target, module, nil} |
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.
compile wavm before the loop. If it fails - return just that error without trying other compilation. If it succeeds add wavm to the map and do the loop. Inside the loop - skip wavm compilation.
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.
wavm is compiled before the loop iterating over targets and if wavm compilation fails we return error:
nitro/arbos/programs/native.go
Lines 81 to 102 in aba9415
status_mod := userStatus(C.stylus_activate( | |
goSlice(wasm), | |
u16(page_limit), | |
u16(version), | |
cbool(debug), | |
output, | |
&codeHash, | |
moduleHash, | |
stylusData, | |
(*u64)(gasLeft), | |
)) | |
module, msg, err := status_mod.toResult(output.intoBytes(), debug) | |
if err != nil { | |
if debug { | |
log.Warn("activation failed", "err", err, "msg", msg, "program", addressForLogging) | |
} | |
if errors.Is(err, vm.ErrExecutionReverted) { | |
return nil, nil, fmt.Errorf("%w: %s", ErrProgramActivation, msg) | |
} | |
return nil, nil, err | |
} |
I add compiled module to results
channel in the loop to add it to asmMap
later on only if rawdb.TargetWavm
is in the targets list. That way the code is ready for not storing wavm if not needed.
Does it sound right?
I can change it to always include wavm compilation output in the resulting asmMap
, but I think that it is enough to require Wavm in WasmTargets list to have it always stored in db in this version.
let me know what you think
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.
LGTM
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.
LGTM
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.
LGTM
Resolves NIT-2632
Pulls: OffchainLabs/go-ethereum#353