Skip to content

Add eWASM Contract Interface specification #29

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

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A few key points:
eWASM is a restricted subset of WASM to be used for contracts in Ethereum.

eWASM:
* specifies the semantics for an *eWASM contract*
* specifies the [semantics for an *eWASM contract*](./contract_interface.md)
* specifies an [Ethereum environment interface](./eth_interface.md) to facilitate interaction with the Ethereum environment from an *eWASM contract*
* specifies [metering](./metering.md) for instructions
* and aims to restrict [non-deterministic behavior](https://github.com/WebAssembly/design/blob/master/Nondeterminism.md)
Expand Down Expand Up @@ -49,6 +49,7 @@ eWASM:
* [FAQ](./faq.md)
* [Rationale](./rationale.md)
* [Ethereum environment interface](./eth_interface.md)
* [eWASM Contract Interface](./contract_interface.md)
* [Original Proposal](https://github.com/ethereum/EIPs/issues/48) (EIP#48)
* [WebAssembly design documents](https://github.com/WebAssembly/design)

Expand Down
30 changes: 30 additions & 0 deletions contract_interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# eWASM Contract Interface (ECI) Specification; Version 0

The eWASM Contract Interface (ECI) specifies the structure of a contract module.

### Wire format

Every contract must be stored in the [WebAssembly Binary Encoding](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md) format (in short, WASM bytecode).

### Imports

A contract can only import symbols specified in the [Ethereum Environment Interface](./eth_interface.md).

### Exports

A contract must have exactly two exported symbols:
- `memory`: the shared memory space available for the EEI to write into.
Copy link
Member

Choose a reason for hiding this comment

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

This could be optional and we could assume that kernel will also just have access to memory. Currently we also export the memory becuase there is no other way to accesses it. But according to JSapi we should be able to create a wasm instance with memory externally defined (i think).

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 memory supplied to instantiate will be copied over to the instance memory. It is not a pointer as far as I see.

- `main`: a function with no parameters and no result value.

### Entry point

The method exported as `main` will be executed by the VM.
Copy link
Member

Choose a reason for hiding this comment

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

This functionality could be replaces with start. The reason we are currently using main is due to the limitation of our prototype.

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 main is used in order to have access to the instance memory.

start also depends on language support.


### Debug-mode

Debug-mode is a special VM option, where an additional set of debugging interfaces are available to contracts. On a live VM, any bytecode trying to import these
symbols should be rejected.

The imports are available under the `debug` namespace:
- `print(i32 offset, i32 length)`: print a string as pointed by `offset`
- `printHex(i32 offset, i32 length)`: print a hex representation of the memory pointed to by `offset`