Skip to content
Open
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
13 changes: 13 additions & 0 deletions keccak-lys.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
beacon_state:
execution_scripts:
- scripts/keccak-lys/build/main.wasm
shard_pre_state:
exec_env_states:
- "0000000000000000000000000000000000000000000000000000000000000000"
shard_blocks:
- env: 0
data: "00000000000000000000000000000000000000000000000000000000000000ff"
shard_post_state:
exec_env_states:
- "9f1c3493f670fb5a4611e82d5bbb06eb4969a406ecc1e47c0dca6f5ce354d187"
deposit_receipts: []
1 change: 1 addition & 0 deletions scripts/keccak-lys/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
2 changes: 2 additions & 0 deletions scripts/keccak-lys/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
lys main.lys
19 changes: 19 additions & 0 deletions scripts/keccak-lys/README.md
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
11 changes: 11 additions & 0 deletions scripts/keccak-lys/eth2.lys
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()
24 changes: 24 additions & 0 deletions scripts/keccak-lys/main.lys
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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()
var i = 0
loop {
if (i < 256) {
i = i + 1
Keccak.update(k, input)
continue
}
break
}
var ret = Keccak.digest(k)

savePostStateRoot(ret.ptr)
}