Skip to content

Commit

Permalink
infra: sync with main from gl tezos kernel repo on commit d4585026
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilevos committed Aug 10, 2023
1 parent 8953ca3 commit ece9204
Show file tree
Hide file tree
Showing 219 changed files with 62,143 additions and 11,381 deletions.
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
target/
_build
preimage

stripped_debug_kernel.wasm
24 changes: 21 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
run_everything:
image: nixos/nix
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'

stages:
- test
- build

cargo-test:
stage: test
image: rust
script:
- rustup component add clippy rustfmt
- cargo fmt --check
- cargo clippy -- -D warnings
- cargo test

cargo-build:
stage: build
image: rust
variables:
TZWITTER_L1_CONTRACT: "KT1..."
script:
- nix develop --experimental-features "nix-command flakes" --extra-substituters https://tezos.nix-cache.workers.dev --extra-trusted-public-keys tezos-nix-cache.marigold.dev-1:4nS7FPPQPKJIaNQcbwzN6m7kylv16UCWWgjeZZr2wXA= --command cargo make ci
- cargo build --release
7 changes: 6 additions & 1 deletion 00_debug_kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2022 Marigold <[email protected]>
# SPDX-FileCopyrightText: 2022 Nomadic Labs <[email protected]>
#
# SPDX-License-Identifier: MIT

[package]
name = "debug-kernel"
version = "0.1.0"
Expand All @@ -7,4 +12,4 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
tezos-smart-rollup = "0.1.0"
tezos-smart-rollup = "0.2.1"
12 changes: 6 additions & 6 deletions 00_debug_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ and read from the shared inbox.
## Running the example

First, compile the kernel to WASM with Cargo:

<!-- $MDX skip -->

```sh
$ cargo build --release --target wasm32-unknown-unknown
```

Then you can execute the kernel locally against the provided inputs (empty in this example) and commands:

```sh
$ octez-smart-rollup-wasm-debugger \
> ../target/wasm32-unknown-unknown/release/debug_kernel.wasm \
> --inputs ./inputs.json \
> --commands ./commands.json
octez-smart-rollup-wasm-debugger ../target/wasm32-unknown-unknown/release/debug_kernel.wasm --inputs ./inputs.json <<< $(cat ./commands.txt)
Loaded 0 inputs at level 0
Hello from kernel!
Evaluation took 222965 ticks so far
Status: Evaluating
Internal_status: Evaluation succeeded
```

Additionally, you can omit the `--commands` flag to enter a REPL mode and
explore the execution of the kernel interactively. Try it out!
Additionally, you can omit the `<<< $(cat ./commands.txt)` to enter a REPL mode and
explore the execution of the kernel interactively.
4 changes: 0 additions & 4 deletions 00_debug_kernel/commands.json

This file was deleted.

2 changes: 2 additions & 0 deletions 00_debug_kernel/commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
load inputs
step result
5 changes: 5 additions & 0 deletions 00_debug_kernel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// SPDX-FileCopyrightText: 2022 Marigold <[email protected]>
// SPDX-FileCopyrightText: 2022 Nomadic Labs <[email protected]>
//
// SPDX-License-Identifier: MIT

extern crate alloc;

use tezos_smart_rollup::{kernel_entry, prelude::*};
Expand Down
7 changes: 6 additions & 1 deletion 01_storage_kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2023 Marigold <[email protected]>
# SPDX-FileCopyrightText: 2023 Nomadic Labs <[email protected]>
#
# SPDX-License-Identifier: MIT

[package]
name = "storage-kernel"
version = "0.1.0"
Expand All @@ -7,4 +12,4 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
tezos-smart-rollup = {version = "0.1.0", features = ["testing"]}
tezos-smart-rollup = {version = "0.2.0", features = ["testing"]}
12 changes: 8 additions & 4 deletions 01_storage_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@ Additionally, we introduce the Mock Host to enable a simple unit test of our ker
Run the unit test with `cargo test`:

<!-- $MDX skip -->

```sh
$ cargo test
```

To run the kernel locally, compile the kernel to WASM with Cargo:

<!-- $MDX skip -->

```sh
$ cargo build --release --target wasm32-unknown-unknown
```

Then you can execute the kernel against the provided inputs (empty in this example) and commands:

```sh
$ octez-smart-rollup-wasm-debugger \
> ../target/wasm32-unknown-unknown/release/storage_kernel.wasm \
> --inputs ./inputs.json \
> --commands ./commands.json
$ octez-smart-rollup-wasm-debugger ../target/wasm32-unknown-unknown/release/storage_kernel.wasm --inputs ./inputs.json <<< $(cat ./commands.txt)
68656c6c6f20776f726c64
Loaded 0 inputs at level 0
Evaluation took 235916 ticks so far
Status: Evaluating
Internal_status: Evaluation succeeded
```

Additionally, you can omit the `<<< $(cat ./commands.txt)` to enter a REPL mode and
explore the execution of the kernel interactively.
5 changes: 0 additions & 5 deletions 01_storage_kernel/commands.json

This file was deleted.

3 changes: 3 additions & 0 deletions 01_storage_kernel/commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load inputs
step result
show key /greeting
5 changes: 5 additions & 0 deletions 01_storage_kernel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// SPDX-FileCopyrightText: 2023 Marigold <[email protected]>
// SPDX-FileCopyrightText: 2023 Nomadic Labs <[email protected]>
//
// SPDX-License-Identifier: MIT

extern crate alloc;

use tezos_smart_rollup::{kernel_entry, prelude::*, storage::path::OwnedPath};
Expand Down
7 changes: 6 additions & 1 deletion 02_reboot_kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2023 Marigold <[email protected]>
# SPDX-FileCopyrightText: 2023 Nomadic Labs <[email protected]>
#
# SPDX-License-Identifier: MIT

[package]
name = "reboot-kernel"
version = "0.1.0"
Expand All @@ -7,4 +12,4 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
tezos-smart-rollup = "0.1.0"
tezos-smart-rollup = "0.2.1"
12 changes: 6 additions & 6 deletions 02_reboot_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ the kernel and learn how to mark the kernel for reboot at runtime.
## Running the example

First, compile the kernel to WASM with Cargo:

<!-- $MDX skip -->

```sh
$ cargo build --release --target wasm32-unknown-unknown
```

Then you can execute the kernel locally against the provided inputs (empty in this example) and commands:

```sh
$ octez-smart-rollup-wasm-debugger \
> ../target/wasm32-unknown-unknown/release/reboot_kernel.wasm \
> --inputs ./inputs.json \
> --commands ./commands.json
$ octez-smart-rollup-wasm-debugger ../target/wasm32-unknown-unknown/release/reboot_kernel.wasm --inputs ./inputs.json <<< $(cat ./commands.txt)
Loaded 0 inputs at level 0
Hello from kernel!
Evaluation took 256897 ticks so far
Expand All @@ -36,5 +36,5 @@ Status: Evaluating
Internal_status: Evaluation succeeded
```

Additionally, you can omit the `--commands` flag to enter a REPL mode and
explore the execution of the kernel interactively. Try it out!
Additionally, you can omit the `<<< $(cat ./commands.txt)` to enter a REPL mode and
explore the execution of the kernel interactively.
7 changes: 0 additions & 7 deletions 02_reboot_kernel/commands.json

This file was deleted.

5 changes: 5 additions & 0 deletions 02_reboot_kernel/commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
load inputs
step result
step result
step result
step result
6 changes: 5 additions & 1 deletion 02_reboot_kernel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2023 Marigold <[email protected]>
//
// SPDX-License-Identifier: MIT

use tezos_smart_rollup::{kernel_entry, prelude::*, storage::path::OwnedPath};

/// In this example, we'll begin to explore the control
Expand All @@ -24,7 +28,7 @@ use tezos_smart_rollup::{kernel_entry, prelude::*, storage::path::OwnedPath};
/// a single call to the entry function; instead, mark
/// it for reboot, exit, and process the remaining inputs
/// in the next call.
fn entry(host: &mut impl Runtime) {
pub fn entry(host: &mut impl Runtime) {
debug_msg!(host, "Hello from kernel!\n");
let greeting_path: OwnedPath = "/greeting".as_bytes().to_vec().try_into().unwrap();
let _ = Runtime::store_write(host, &greeting_path, "hello world".as_bytes(), 0);
Expand Down
7 changes: 6 additions & 1 deletion 03_inbox_kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2023 Marigold <[email protected]>
# SPDX-FileCopyrightText: 2023 Nomadic Labs <[email protected]>
#
# SPDX-License-Identifier: MIT

[package]
name = "inbox-kernel"
version = "0.1.0"
Expand All @@ -7,4 +12,4 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
tezos-smart-rollup = "0.1.0"
tezos-smart-rollup = "0.2.1"
11 changes: 7 additions & 4 deletions 03_inbox_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
## Running the example

To run the kernel locally, compile the kernel to WASM with Cargo:

<!-- $MDX skip -->

```sh
$ cargo build --release --target wasm32-unknown-unknown
```

Then you can execute the kernel against the provided inputs and commands:

```sh
$ octez-smart-rollup-wasm-debugger \
> ../target/wasm32-unknown-unknown/release/inbox_kernel.wasm \
> --inputs ./inputs.json \
> --commands ./commands.json
$ octez-smart-rollup-wasm-debugger ../target/wasm32-unknown-unknown/release/inbox_kernel.wasm --inputs ./inputs.json <<< $(cat ./commands.txt)
Loaded 2 inputs at level 0
Inbox level: 0 Internal message: start of level
Inbox level: 0 Internal message: level info (block predecessor: BKiHLREqU3JkXfzEDYAkmmfX48gBDtYhMrpA98s7Aq4SzbUAB6M, predecessor_timestamp: 1970-01-01T00:00:00Z
Expand All @@ -24,3 +24,6 @@ Evaluation took 1093784 ticks so far
Status: Evaluating
Internal_status: Evaluation succeeded
```
Additionally, you can omit the `<<< $(cat ./commands.txt)` to enter a REPL mode and
explore the execution of the kernel interactively.
4 changes: 0 additions & 4 deletions 03_inbox_kernel/commands.json

This file was deleted.

2 changes: 2 additions & 0 deletions 03_inbox_kernel/commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
load inputs
step result
13 changes: 9 additions & 4 deletions 03_inbox_kernel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// SPDX-FileCopyrightText: 2023 Marigold <[email protected]>
// SPDX-FileCopyrightText: 2023 Nomadic Labs <[email protected]>
//
// SPDX-License-Identifier: MIT

use tezos_smart_rollup::{
inbox::{InboxMessage, InternalInboxMessage},
kernel_entry,
Expand Down Expand Up @@ -39,7 +44,7 @@ fn read_inbox_message<Expr: Michelson>(host: &mut impl Runtime) {
match InboxMessage::<Expr>::parse(message.as_ref()) {
Ok(parsed_msg) => match parsed_msg {
(remaining, InboxMessage::Internal(msg)) => {
assert!(remaining.is_empty());
debug_assert!(remaining.is_empty());
match msg {
InternalInboxMessage::StartOfLevel => {
// The "Start of level" message is pushed by the Layer 1
Expand Down Expand Up @@ -78,8 +83,8 @@ fn read_inbox_message<Expr: Michelson>(host: &mut impl Runtime) {
// For a simple practical example, see `counter-kernel`, where
// external messages are used to encode the state transitions
// of a counter.
assert!(remaining.is_empty());
let message = String::from_utf8_lossy(&msg);
debug_assert!(remaining.is_empty());
let message = String::from_utf8_lossy(msg);
debug_msg!(host, "External message: \"{}\"\n", message);
}
},
Expand Down Expand Up @@ -107,7 +112,7 @@ fn read_inbox_message<Expr: Michelson>(host: &mut impl Runtime) {
}
}

fn entry(host: &mut impl Runtime) {
pub fn entry(host: &mut impl Runtime) {
// Every rollup has a Michelson type, declared at origination, which
// represents the kind of data it can receive via internal transfer
// messages. We won't delve into this here - for simplicity, the type
Expand Down
7 changes: 6 additions & 1 deletion 04_filtering_kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2023 Marigold <[email protected]>
# SPDX-FileCopyrightText: 2023 Nomadic Labs <[email protected]>
#
# SPDX-License-Identifier: MIT

[package]
name = "filtering-kernel"
version = "0.1.0"
Expand All @@ -7,4 +12,4 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
tezos-smart-rollup = "0.1.0"
tezos-smart-rollup = "0.2.1"
12 changes: 8 additions & 4 deletions 04_filtering_kernel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@
Run the unit test with `cargo test`:

<!-- $MDX skip -->

```sh
$ cargo test
```

To run the kernel locally, compile the kernel to WASM with Cargo:

<!-- $MDX skip -->

```sh
$ cargo build --release --target wasm32-unknown-unknown
```

Then you can execute the kernel against the provided inputs (empty in this example) and commands:

```sh
$ octez-smart-rollup-wasm-debugger \
> ../target/wasm32-unknown-unknown/release/filtering_kernel.wasm \
> --inputs ./inputs.json \
> --commands ./commands.json
$ octez-smart-rollup-wasm-debugger ../target/wasm32-unknown-unknown/release/filtering_kernel.wasm --inputs ./inputs.json <<< $(cat ./commands.txt)
Loaded 2 inputs at level 0
External message: "This message is for me"
Evaluation took 417738 ticks so far
Status: Evaluating
Internal_status: Evaluation succeeded
```

Additionally, you can omit the `<<< $(cat ./commands.txt)` to enter a REPL mode and
explore the execution of the kernel interactively.
4 changes: 0 additions & 4 deletions 04_filtering_kernel/commands.json

This file was deleted.

2 changes: 2 additions & 0 deletions 04_filtering_kernel/commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
load inputs
step result
Loading

0 comments on commit ece9204

Please sign in to comment.