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

Add an extra note about EEI imports and disallowing a start function #114

Merged
merged 2 commits into from
Jul 30, 2018

Conversation

jakelang
Copy link
Member

while implementing my ECI tool, these implicit features of the ECI seemed to be important to explicitly note.

@@ -24,6 +25,8 @@ 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.

Further more, the ewasm spec disallows the use of a 'start' function in an ewasm contract, because it is executed upon module instantiation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In pwasm we decided to leave it as is. The reason for that we don't want to introduce unnecessary complication s since start function might still be used by the wasm producer. On the other hand, the logic is pretty much the same, consider this pseudo-code:

// let's say `env` is a EEI analog

try {
  // this will implicitly run the `start` function
  instance = instantiate_module(module, env)
  instance.invoke(env, "entrypoint")
} catch {
  // ...
}

there is almost no difference between running or not running the start function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our decision to remove the start function was based on some detail that came up in implementing ewasm-kernel that required something to be done between instantiation and execution. @axic can elaborate a bit more on this.

I think that it seems to be a bit of a workaround that should be streamlined, so it may be revisited in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pepyakin meanwhile I am working on a tool that checks the ECI properties (and later amends them) using the parity-wasm library. It is located at jakelang/libecic. If you have time, could you take a look and give some comments about what could be done better? I am somewhat new to Rust :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it is executed upon module instantiation

This explanation is a little vague, and I can foresee it being the source of future confusion if left as-is. @axic could you perhaps flesh this out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lrettig I was not involved in writing ewasm-kernel, hence the shallowness of the explanation :)

@@ -9,6 +9,7 @@ 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).
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a debug namespace too

Copy link
Member Author

@jakelang jakelang Jul 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On-chain code does not, but I will make note anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #116.


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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ewasm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it intentionally the old styling in this PR. There's the other PR changing all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I will update that PR when this is merged

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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first 'a' in Webassembly should be capitalized

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ewasm

@axic axic merged commit 1fb8241 into ewasm:master Jul 30, 2018
@axic axic removed the in progress label Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants