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

Get rid of Konan_* imports #1

Open
ligi opened this issue Sep 23, 2018 · 2 comments
Open

Get rid of Konan_* imports #1

ligi opened this issue Sep 23, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@ligi
Copy link
Member

ligi commented Sep 23, 2018

currently the import section looks like this:

  (import "env" "Konan_abort" (func $Konan_abort (type 3)))
  (import "env" "Konan_date_now" (func $Konan_date_now (type 3)))
  (import "env" "Konan_heap_grow" (func $Konan_heap_grow (type 1)))
  (import "env" "Konan_heap_lower" (func $Konan_heap_lower (type 4)))
  (import "env" "Konan_heap_upper" (func $Konan_heap_upper (type 4)))
  (import "env" "Konan_js_allocateArena" (func $Konan_js_allocateArena (type 4))
)
  (import "env" "Konan_js_arg_size" (func $Konan_js_arg_size (type 1)))
  (import "env" "Konan_js_fetch_arg" (func $Konan_js_fetch_arg (type 0)))
  (import "env" "abort" (func $abort (type 5)))
  (import "env" "callDataCopy" (func $callDataCopy (type 7)))
  (import "env" "finish" (func $finish (type 6)))
  (import "env" "getCallDataSize" (func $getCallDataSize (type 4)))
  (import "env" "getTxOrigin" (func $getTxOrigin (type 1)))
  (import "env" "revert" (func $revert (type 6)))
  (import "env" "storageLoad" (func $storageLoad (type 6)))
  (import "env" "storageStore" (func $storageStore (type 6)))
  (import "env" "write" (func $write (type 2)))
  (import "env" "memory" (memory (;0;) 17))

Create this file by building via ./gradlew wat

These Konan_ imports need to vanish - so it can be used in the eWasm context. The import section must look like this (taken from https://github.com/lrettig/wrc20-challenge/blob/master/build/main.wat):

 (import "ethereum" "getCallDataSize" (func $~lib/ethereum/getCallDataSize (result i32)))
 (import "ethereum" "revert" (func $~lib/ethereum/revert (param i32 i32)))
 (import "ethereum" "callDataCopy" (func $~lib/ethereum/callDataCopy (param i32 i32 i32)))
 (import "ethereum" "storageLoad" (func $~lib/ethereum/storageLoad (param i32 i32)))
 (import "ethereum" "return" (func $~lib/ethereum/finish (param i32 i32)))
 (import "ethereum" "getCaller" (func $~lib/ethereum/getCaller (param i32)))
 (import "ethereum" "storageStore" (func $~lib/ethereum/storageStore (param i32 i32)))

Also we must find a way to change the module source from "env" to "etheruem" - but this is the easier part as far as I see, I have seen this just being replaced in build-scripts. But it would be nicer if we could specify it when declaring the import in eei.kt like this:

@SymbolName("getCallDataSize")
external fun eei_getCallDataSize(): Int

Perhaps there is a way to also specify the module there.

@ligi ligi added the enhancement New feature or request label Sep 23, 2018
@ligi ligi changed the title get rid of Konan_ imports Get rid of Konan_* imports Sep 23, 2018
@gballet
Copy link

gballet commented Sep 23, 2018

@ligi another thing that I would like to know is how to select what is the module name for each symbol, because 1) the module that should be included is called "ethereum" and 2) even if we can't get rid of all the Konan_ symbols then they will be provided by an auxiliary module that won't provide functions like getTxOrigin.

@gballet
Copy link

gballet commented Sep 24, 2018

As an intermediate solution, it would be possible to have:

  • write as a function that does nothing
  • abort and Konan_abort as functions that call revert
  • Konan_notify_memory_grow as a function that either does nothing or belongs to a kotlin module that exports memory:
(module
  (type $0 (func)
  # Best guess as to what the max mem will be
  (memory $0 256)
  (export "memory" (memory $0))
  (export "Konan_notify_memory_grow (func $0))
  (func $0 (type $0)
    (nop)
  )
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
@ligi @gballet and others