From ec74864dd82cefd8024cd763a0e4d3e192d8f920 Mon Sep 17 00:00:00 2001 From: Jake Lang Date: Fri, 27 Jul 2018 10:36:16 -0400 Subject: [PATCH 1/2] Add an extra note about EEI imports and the lack of a start function --- contract_interface.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contract_interface.md b/contract_interface.md index d1a320a5..b98a585a 100644 --- a/contract_interface.md +++ b/contract_interface.md @@ -8,7 +8,10 @@ Every contract must be stored in the [WebAssembly Binary Encoding](https://githu ### Imports -A contract can only import symbols specified in the [Ethereum Environment Interface](./eth_interface.md). +A contract can only import symbols specified in the [Ethereum Environment Interface or EEI](./eth_interface.md). + +In practice, this means that all imports specified by an eWASM module must be from the `ethereum` namespace, +and having a function signature and name directly correspondent to a function specified in the EEI. As mentioned below, there is a `debug` namespace as well, but that is disallowed in production systems. @@ -38,3 +41,5 @@ The method exported as `main` will be executed by the VM. On successful execution, the code should return via a normal code path. If it needs to abort due to a failure, an *unreachable* instruction should be executed. + +Furthermore, the eWASM spec disallows the use of a "start" function in a contract, because it is executed upon module instantiation. From 6a96e468ea27a8ab76341a8c0ed3da3832ed057e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 30 Jul 2018 18:43:49 +0100 Subject: [PATCH 2/2] Explain the reasoning behind disallowing start functions --- contract_interface.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contract_interface.md b/contract_interface.md index b98a585a..19a40701 100644 --- a/contract_interface.md +++ b/contract_interface.md @@ -42,4 +42,12 @@ On successful execution, the code should return via a normal code path. If it needs to abort due to a failure, an *unreachable* instruction should be executed. -Furthermore, the eWASM spec disallows the use of a "start" function in a contract, because it is executed upon module instantiation. +### Start function + +The use of a [start function](https://webassembly.github.io/spec/core/syntax/modules.html#start-function) is disallowed. + +The reason for this is that an eWASM VM would need to have access to the memory space of a contract and that must be acquired prior to executing it. +In the [WebAssembly Javascript API](https://webassembly.org/docs/js/) however the start function is executed right during instantiation, which +leaves no time for the client to acquire the memory area. + +*Note:* This decision was made on WebAssembly version 0xb (pre version 1) and should be revisited.