-
Notifications
You must be signed in to change notification settings - Fork 709
update ProgramPrepare to accept wasm instead of statedb and code #4284
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ package programs | |||||
|
|
||||||
| import ( | ||||||
| "errors" | ||||||
| "fmt" | ||||||
| "unsafe" | ||||||
|
|
||||||
| "github.com/ethereum/go-ethereum/arbitrum/multigas" | ||||||
|
|
@@ -124,10 +125,9 @@ func programRequiresPrepare( | |||||
|
|
||||||
| //go:wasmimport programs program_prepare | ||||||
| func ProgramPrepare( | ||||||
| statedbPtr unsafe.Pointer, | ||||||
| wasmPtr unsafe.Pointer, | ||||||
| moduleHashPtr unsafe.Pointer, | ||||||
| addressForLoggingPtr unsafe.Pointer, | ||||||
| codePtr unsafe.Pointer, | ||||||
| codeSize uint64, | ||||||
| codehashPtr unsafe.Pointer, | ||||||
| maxWasmSize uint32, | ||||||
|
|
@@ -156,21 +156,25 @@ func startProgram(module uint32) uint32 | |||||
| //go:wasmimport programs send_response | ||||||
| func sendResponse(req_id uint32) uint32 | ||||||
|
|
||||||
| func handleProgramPrepare(statedb vm.StateDB, moduleHash common.Hash, addressForLogging common.Address, code []byte, codehash common.Hash, params *StylusParams, time uint64, debugMode bool, program Program, runCtx *core.MessageRunContext) []byte { | ||||||
| func handleProgramPrepare(statedb vm.StateDB, moduleHash common.Hash, programAddress common.Address, code []byte, codehash common.Hash, params *StylusParams, time uint64, debugMode bool, program Program, runCtx *core.MessageRunContext) []byte { | ||||||
| requiresPrepare := programRequiresPrepare(unsafe.Pointer(&moduleHash[0])) | ||||||
| if requiresPrepare != 0 { | ||||||
| var debugInt uint32 | ||||||
| if debugMode { | ||||||
| debugInt = 1 | ||||||
| } | ||||||
|
|
||||||
| wasm, err := getWasm(statedb, programAddress, params) | ||||||
|
Contributor
Author
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. we could use nitro/arbos/programs/native.go Lines 279 to 280 in db29e55
Member
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. If we used
Contributor
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. the comment is exactly why you want to use getWasmFromContractCode and not getWasm. There are weird edgeCases like delegateCall and reading code from programAddressForLogging might not be correct, but the code you have here is correct and can be passed to getWasmFromCode |
||||||
| if err != nil { | ||||||
| panic(fmt.Sprintf("failed to get wasm for program, program address: %v, err: %v", programAddress.Hex(), err)) | ||||||
| } | ||||||
|
|
||||||
| codeSize := uint64(len(code)) | ||||||
|
|
||||||
| ProgramPrepare( | ||||||
| unsafe.Pointer(&statedb), | ||||||
| unsafe.Pointer(&wasm), | ||||||
| unsafe.Pointer(&moduleHash), | ||||||
| unsafe.Pointer(&addressForLogging), | ||||||
| unsafe.Pointer(&code), | ||||||
| unsafe.Pointer(&programAddress), | ||||||
| codeSize, | ||||||
| unsafe.Pointer(&codehash), | ||||||
| params.MaxWasmSize, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ### Changed | ||
| - update ProgramPrepare to accept wasm instead of statedb and code |
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.
we need wasmSize instea of codeSize, and right after wasmPtr