-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add keccak-lys example EE written in Lys
- Loading branch information
Showing
6 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
beacon_state: | ||
execution_scripts: | ||
- scripts/keccak-lys/build/main.wasm | ||
shard_pre_state: | ||
exec_env_states: | ||
- "0000000000000000000000000000000000000000000000000000000000000000" | ||
shard_blocks: | ||
- env: 0 | ||
data: "" | ||
- env: 0 | ||
data: "" | ||
shard_post_state: | ||
exec_env_states: | ||
- "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
all: | ||
lys main.lys |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# keccak-lys | ||
|
||
Sample EE script written in [Lys]. | ||
|
||
## Build | ||
|
||
Install Node.js and npm first. Then install the lys compiler: | ||
```shell | ||
npm i -g lys | ||
``` | ||
|
||
Finally build the EE via: | ||
```shell | ||
lys main.lys | ||
``` | ||
|
||
Or simply run `make`. | ||
|
||
[Lys]: https://github.com/lys-lang/lys |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#[extern "env" "loadPreStateRoot"] | ||
fun loadPreStateRoot(ptr: u32): void = panic() | ||
|
||
#[extern "env" "eth2_blockDataSize"] | ||
fun blockDataSize(): u32 = panic() | ||
|
||
#[extern "env" "eth2_blockDataCopy"] | ||
fun blockDataCopy(ptr: u32, offset: u32, len: u32): void = panic() | ||
|
||
#[extern "env" "eth2_savePostStateRoot"] | ||
fun savePostStateRoot(ptr: u32): void = panic() |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import system::hash::keccak | ||
|
||
import eth2 | ||
|
||
#[export] | ||
fun main(): void = { | ||
var len = blockDataSize() | ||
var input = bytes(len) | ||
blockDataCopy(input.ptr, 0 as u32, len) | ||
|
||
var k = Keccak() | ||
Keccak.update(k, input) | ||
var ret = Keccak.digest(k) | ||
|
||
savePostStateRoot(ret.ptr) | ||
} |