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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specification for v0.2.0 #69

Closed
clearloop opened this issue Aug 5, 2023 · 1 comment
Closed

Specification for v0.2.0 #69

clearloop opened this issue Aug 5, 2023 · 1 comment

Comments

@clearloop
Copy link
Member

clearloop commented Aug 5, 2023

Exactly everything required by ERC20 馃

https://github.com/zink-lang/zink/milestone/2

1. WebAssembly

Still far away to complete the MVP instructions of WASM, once we have implemented all of these, we can archive that any WASM program works for EVM.

1.1. Memory Allocator

The main blocker of compiling Zink projects EVM contracts in real world is that that we are currently missing the implementation of memory allocator:

Since EVM uses 32-byte as the basic unit for memory management, we need to implement our own memory allocator to align the compiled memory operations in WASM to EVM, see alloc::GlobalAlloc

1.2. Tests of Vector

This is what we can get directly from the implementation of 1.1, require tests for custom vector operations.

1.3. Instructions

reference to wasm-ops, complete the MVP instructions,

  • Control Flow: select, br_table, call_indirect
  • Data & State: global related instructions
  • Memory: tests of loadN, storeN
  • Comparison : tests for integers
  • Bitwise: implement missed bitwise operations in EVM
  • Arithmetic: div and rem are not tested
  • Data Conversions: almost missing all of them

2. Contract Interfaces

To be a EVM contract : )

2.1. Selector

The selector implementation is free to go since EVM simply starts from the first byte of EVM binaries which is the main function in general.

The question is that shall we align our selector implementation to solidity?

Guess the answer is yes and no, it is really necessary to adapt the current infrastructure, but, we can do it better with the rust ecosystem, the most simple way to go is that we provide an external function select or just main in the compiled WASM, make it the main function, actually a jump table, jumping to specified function by the selector.

The problem needs to be solved is that, how we detect that if the selected function is called as a transaction or just a internal call? requires research on it.

2.2. Storage

Basically, we need to implement globals to reach this demand, besides, the storage operations require the implementation of host functions since it is out of basic instructions that we can translate from WASM to EVM bytecode.

2.3. Events

Events operations are similar to the storage implementation, however, it requires customized types as well.

3. Example for v0.2.0

ERC20 is reasonable, just do it!

ref: OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol

@clearloop clearloop added this to the v0.2.0 - Contract milestone Aug 5, 2023
@clearloop clearloop changed the title Tracking issue for v0.2.0 Specification for v0.2.0 Aug 5, 2023
@clearloop clearloop pinned this issue Aug 5, 2023
@clearloop
Copy link
Member Author

stick to v0.1.x till syncing to the solidity implementation

@clearloop clearloop unpinned this issue Nov 13, 2023
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

No branches or pull requests

1 participant