-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zink): gather development tools to zink folder (#294)
* chore(zink): rename tools to zink folder * docs(README): make README compact * docs(PR): update PR template * docs(book): update the README of the book * docs(README): notice bounty issues in README
- Loading branch information
Showing
30 changed files
with
91 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,69 @@ | ||
<img align="right" width="150" height="150" top="100" src = "https://avatars.githubusercontent.com/u/138247979?s=400&u=cbf4b9e9da048899a947f08d92e030806d5bd50b&v=4"/> | ||
|
||
# The Zink Project | ||
# The Zink Language | ||
|
||
> [!CAUTION] | ||
> | ||
> This project is still under active development, plz DO NOT use it in production. | ||
> This project is still under active development, please DO NOT use it in production. | ||
[![zink][version-badge]][version-link] | ||
[![ci][ci-badge]][ci-link] | ||
[![telegram][telegram-badge]][telegram-group] | ||
|
||
[The Zink project][book] mainly provides a singlepass compiler `zinkc` which compiles | ||
WASM to EVM bytecode, the source code of your smart contracts could be any language you like! | ||
Welcome to the Zink Language! [Bounty issues](https://zink-lang.org/budgets) are now available, join the development of Zink by reading the [book](https://zink-lang.org/). | ||
|
||
```mermaid | ||
flowchart LR | ||
R{{Rust}} --> W(WebAssembly) | ||
O[...] --> W | ||
W --> Z{Zink Compiler} | ||
Z --> V[(EVM)] | ||
``` | ||
```rust | ||
//! ERC20 Example (WIP) | ||
#[zink::contract] | ||
pub struct ERC20; | ||
|
||
#[zink::calls] | ||
impl ERC20 { | ||
/// VMs that zink supports | ||
pub fn support() -> [zink::String; 4] { | ||
["EVM", "WASM", "RISC-V", "...OTHER_VMS"] | ||
} | ||
} | ||
|
||
Here we highly recommend you to choose `rust` as the language of your smart contracts | ||
which will unlock all of the following features: | ||
#[zink::interface] | ||
impl ERC20 for ERC20 { | ||
fn name() -> zink::String { | ||
"Zink Language".to_string() | ||
} | ||
} | ||
``` | ||
|
||
- **Safe**: `rustc` is watching you! Furthermore, after compiling your rust code to WASM, | ||
`zinkc` will precompute all of the stack and memory usage in your contracts to ensure they | ||
are safe in EVM bytecode as well! | ||
- **Safe**: `rustc` monitors your code! | ||
|
||
- **High Performance**: The optimizations are provided by the three of `rustc`, `wasm-opt` | ||
and `zinkc`, your contracts will have the smallest size with **strong performance** in EVM | ||
bytecode at the end! | ||
- **Efficient**: Efficient EVM bytecode from `rustc`, `wasm-opt`, and `zinkc`. | ||
|
||
- **Compatible**: All of the `no_std` libraries in rust are your libraries, you can use your | ||
solidity contracts as part of your zink contracts and your zink contracts as part of your | ||
solidity contracts :) | ||
- **Modular**: Upload and download your contract components via `crates.io`. | ||
|
||
- **Easy Debugging**: Developing your smart contracts with only one programming language! | ||
zink will provide everything you need for developing your contracts officially based on the | ||
stable projects in rust like the `foundry` tools. | ||
- **Rusty**: All of the rust tools are available for your contracts! | ||
|
||
Run `cargo install zinkup` to install the toolchain! | ||
|
||
## Fibonacci Example | ||
|
||
| fib(n) | Zink | [email protected] | | ||
| ------ | ---- | --------------- | | ||
| 0 | 110 | 614 | | ||
| 1 | 110 | 614 | | ||
| 2 | 262 | 1322 | | ||
| 3 | 414 | 2030 | | ||
| 4 | 718 | 3446 | | ||
| 5 | 1174 | 5570 | | ||
|
||
```rust | ||
/// Calculates the nth fibonacci number using recursion. | ||
#[no_mangle] | ||
pub extern "C" fn recursion(n: usize) -> usize { | ||
if n < 2 { | ||
n | ||
} else { | ||
recursion(n - 1) + recursion(n - 2) | ||
} | ||
} | ||
``` | ||
|
||
As an example for the benchmark, calculating fibonacci sequence with recursion, missed | ||
vyper because it doesn't support recursion...Zink is 5x fast on this, but it is mainly | ||
caused by our current implementation is not completed yet ( missing logic to adapt to more | ||
situations ), let's stay tuned for `v0.3.0`. | ||
## Testing & Development | ||
|
||
## Donation | ||
| Command | Description | | ||
| ---------- | ---------------------- | | ||
| `cargo cc` | Clippy all packages | | ||
| `cargo tt` | Run all tests | | ||
| `cargo be` | Build all examples | | ||
| `cargo te` | Run tests for examples | | ||
|
||
After completing the ERC20 implementation, Zink will focus on MEV logic since everything could | ||
be even more compact and realistic from this dark forest. | ||
We're using `cargo-nextest` for testing, the commands above are described in [.cargo/config.toml](.cargo/config.toml). | ||
|
||
Zink is now moving forward without any grants or backups, if you like this dreaming project, | ||
please feel free to reach out, would be appreciated for any opportunities ^ ^ | ||
## Special Thanks | ||
|
||
- ETH: `0xf0306047Fa598fe95502f466aeb49b68dd94365B` | ||
- SOL: `AZGXAerErfwVzJkiSR8moVPZxe1nEhvjdkvxQ7qR6Yst` | ||
- [MegaETH](https://github.com/megaeth-labs) for the funding and trust! | ||
- [revm](https://github.com/bluealloy/revm) for the EVM in rust! | ||
|
||
## LICENSE | ||
|
||
GPL-3.0-only | ||
|
||
[book]: https://docs.zink-lang.org/ | ||
[book]: https://zink-lang.org/ | ||
[telegram-badge]: https://img.shields.io/endpoint?label=chat&style=flat&url=https%3A%2F%2Fmogyo.ro%2Fquart-apis%2Ftgmembercount%3Fchat_id%3Dzinklang | ||
[telegram-group]: https://t.me/zinklang | ||
[version-badge]: https://img.shields.io/crates/v/zinkc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,10 @@ | ||
# The Zink Book | ||
|
||
This is the book for the Zink Language, you can read it online at [docs.zink-lang.org](https://zink-lang.org/). | ||
|
||
## Validation | ||
|
||
e.g. How Zink Compiler helps you writing your EVM smart contracts ;) | ||
|
||
|
||
#### `0x35` - CALLDATALOAD | ||
|
||
1. validate the function signatures | ||
2. validate the stack usages | ||
|
||
|
||
## Optimizations | ||
|
||
|
||
#### StackCompressor | ||
|
||
The max limit of the defined local variables is 16 due to there is a hard limit | ||
of 16 slots for reaching down the expression stack of EVM. | ||
|
||
|
||
## Function Calls | ||
|
||
### Calling Convention | ||
|
||
There we two ways to handle the calling convention, for storing PC | ||
|
||
1. Store the PC | ||
|
||
few arguments -> store the PC on stack. | ||
lots of arguments -> store the PC in reserved memory. | ||
|
||
|
||
2. Retrieve the PC | ||
|
||
stack -> swap the parameters and the PC | ||
memory -> read from reserved memory | ||
|
||
|
||
3. Jump back to the caller | ||
|
||
stack -> swap the results and the PC | ||
-> dup the PC and pop in caller function | ||
memory -> load PC from memory | ||
## Contributing | ||
|
||
``` | ||
cargo install mdbook | ||
mdbook serve | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.