A big picture of SCORU
A talk by Yann and Hans about scaling Tezos with rollups: https://www.youtube.com/watch?v=SRDlaAhhKBY
What is "WASM" - WebAssembly PVM?
Why choose WASM as the programming language for smart rollups?
cargo
- the official Rust package manager, provides an official target to compile .wasm
binary file that are valid WASM kernel.What is "PVM"?
What is "kernel" in SCORU?[2]
Recap: the relationship of kernel, wasm, pvm
What is the role of a "kernel" in SCORU?
What are the "rules" for kernel that can be complied with the WASM?[3]
kernel_next
that takes no arguments and returns nothing.rollup_safe_core
.Diagram of the kernel repo (maybe out of date), but good to add here to have a general picture
Host bindings implementation:
Source code of this bindings is at: https://gitlab.com/tezos/kernel/-/tree/main/host and its doc is at https://tezos.gitlab.io/kernel/doc/host/index.html
This define the SCORU wasm host function. The host exposes "safe capabilites" as a set of C-style APIs. The host
crate defines these as extern
functions (see rollup_core
) and is reponsible for providing safe wrappers which can be called from safe rust.
crate::runtime::Runtime
when reading an inputRawRollupCore
that used when compiling to wasm.Example of some use cases of kernel in SCORU at the moment:
A simple kernel with transaction functionality similar to TORUs: https://tezos.gitlab.io/kernel/doc/kernel_core/index.html.
e2e tests covering the top-level behaviour of the transactions kernel: https://gitlab.com/tezos/kernel/-/blob/main/e2e_kernel_tests/tests/tx_kernel.rs.
The milestone of warm kernel transactions: https://gitlab.com/tezos/tezos/-/milestones/86#tab-issues
- bls: BLS support for the kernel. Provides signature verification and de-serialization for BLS signatures and public keys.
- deposit: deposit tickets into the kernel state
- encoding: defines tezos-encoding compabible structures.
- inbox: types and encoding for the inbox-half of the L1/L2 communication protocol. In general, this module is a re-implementation of the tezos protocol inbox message repr.
- memory: defines operations over kernel memory - persisted in RAM between yields
- outbox: types and encodings for the outbox-half of the L1/L2 communcation protocol. Similar as inbox, this module is a re-implementation of the tezos-protocol outbox message repr
- transactions: transactions kernel core logic for handling messages
- tx_kernel: define the kernel_next
for the transaction kernel
Host: RawRollupCore
is defined in wasm_host.rs
pub fn deposit_ticket<Host: RawRollupCore>(
memory: &mut Memory,
account_address: Layer2Tz4Hash,
ticket: StringTicket
) -> Result<(), DepositError>
transactions_run
the entrypoint of the transactions kernel (like main function for the tx-kernel). It is where it calls the host modules for the implementation, such as: input
, rollup_core
, runtime
ββββpub fn transactions_run<Host: RawRollupCore>(host: &mut Host) {
ββββ...
ββββ if let Some(input) = host.read_input (MAX_READ_INPUT_SIZE){
ββββ match input {
ββββ Input::Message(message) => {
ββββ ...
ββββ }
ββββ Input::Slot(_message) => todo!
ββββ }
ββββ }
ββββ}
ββββpub fn prepare_for_processing<'a, Host>(
ββββmessage: ExternalInboxMessage<'a>,
ββββaccounts: &mut Accounts
ββββ) -> Option<impl FnMut(&Accounts) ->
ββββProcessedOutcome + 'a> where Host: RawRollupCore,
ββββpub fn handle_withdrawals<Host: RawRollupCore>(
ββββ host: &mut Host,
ββββ memory: &mut Memory,
ββββ withdrawals: Vec<Withdrawal>
ββββ)
kernel
: kernel_entry
macros derive kernel_next
and mock_kernel_next
entrypoints.
tx_kernel
: define the kernel_next
for the transactions kernel. It defines inside the function transactions_run
above.
kernel_next
: function is called by the wasm host at regular intervals.ββββββββpub fn kernel_next()
ββββββββ
ββββββββ#[cfg(feature = "tx-kernel")]
ββββββββpub mod tx_kernel {
ββββββββuse crate::transactions_run;
ββββββββuse kernel::kernel_entry;
ββββββββkernel_entry!(transactions_run);
ββββββββ}
mock_kernel_next
: is called by the mock_host at regular intervals. Mock runtime provides a host that can used in integration and unit tests. Used when not compiling to wasm.ββββββββpub fn mock_kernel_next(host: &mut MockHost)
https://tezos.gitlab.io/kernel/doc/evm_kernel/index.html. This contains the EVM kernel, this kernel runs EVM contract code emulating Ethereum, but on a rollup.
e2e tests for the EVM-kernel: https://gitlab.com/tezos/kernel/-/blob/main/e2e_kernel_tests/tests/evm_kernel.rs.
The milestone of evm on wasm: https://gitlab.com/tezos/tezos/-/milestones/108#tab-issues
- ethereum: types and functions for Ethereum compapility
- deposit: deposit tickets into the kernel state
- inbox: types and encodings for the inbox for the EVM kernel
- memory: defines operations over kernel memory - persisted in RAM between yields
- outbox: types and encodings for the outbox-half of the L1/L2 communication protocols
- transactions: handle transactions
- evm_kernel: define the kernel_next
for the transactions kernel
Details design of kernel in SCORU:
Execution environment
State: the smart rollups have two states
kernel_next
function and is similar to RAM.kernel_next
calls. It consists: inbox, and outbox, and a durable storage which is similar to a file system.
read_only
are not writable by a kernel, but it can be used by the PVM to give information to the kernel.Control Flow:
kernel_next
is called from a "transient state".
kernel_next
is called.kernel_next
is called only once.Host functions:
Implementing a WASM kernel in Rust
Testing the kernel
from this MR: https://gitlab.com/tezos/tezos/-/merge_requests/6629
Some on-going milestones:
TX_kernel
and future EVM kernel
Design document: https://hackmd.io/dkiwun7JQnCgHjuVbmtX_Q β©οΈ
Reference from NL post: https://research-development.nomadic-labs.com/next-generation-rollups.html β©οΈ
Reference from this MR: https://gitlab.com/tezos/tezos/-/merge_requests/6629 β©οΈ