MEVM
Table of Contents
Overview
This document provides the technical specification for the mevm
system, a modified version of the Ethereum Virtual Machine (EVM). With the integration of SuaveExecutionBackend
, the mevm
introduces confidential computation and allows for enhanced interaction with APIs.
Core Architecture
The MEVM is a modified runtime exposed to the EVM. The MEVM is a combination of an interpreter as well as a SuaveExecutionBackend
. A diagram from our suave-geth reference implementation can be seen below.
SuaveExecutionBackend
Functioning as a foundation for the MEVM, the SuaveExecutionBackend
facilitates the execution of confidential processes. Key features include:
- Confidential APIs: Dedicated endpoints for secure data interactions.
- Confidential Input Management: Streamlined processing of confidential data inputs.
- Caller Stack Tracing: Tracing capabilities for tracking transaction initiators.
Reference Implementation (Golang):
type SuaveExecutionBackend struct {
ConfidentialStoreEngine *suave.ConfidentialStoreEngine
MempoolBackend suave.MempoolBackend
ConfidentialEthBackend suave.ConfidentialEthBackend
}
MEVM Interpreter
The modified interpreter not only handles standard EVM operations but also caters to the complexities introduced by confidential computations.
In our current suave-geth reference implementation this looks like:
- Introduction of
IsConfidential
to the interpreter's configuration. - Alterations to the
Run
function to accommodate confidential APIs. - Modifications to the
Run
function to trace the caller stack.
From the suave-geth reference implementation, the capabilities enabled by this modified interpreter are exposed to the virtual machine via SuaveContext
and its components.
type SuaveContext struct {
Backend *SuaveExecutionBackend
ConfidentialComputeRequestTx *types.Transaction
ConfidentialInputs []byte
CallerStack []*common.Address
}
Additional Capabilities
The MEVM has several additional capabilities over the regular EVM.
Confidential execution of smart contracts
The virtual machine (MEVM) inside SUAVE nodes have two modes of operation: regular and confidential. Regular on-chain environment is your usual Ethereum virtual machine environment.
The confidential execution environment provides additional precompiles, both directly and through a convenient library. Confidential execution is not verifiable during on-chain state transition, instead the result of the confidential execution is cached in the transaction (SuaveTransaction
). Users requesting confidential compute requests specify which execution nodes they trust with execution, and the execution nodes' signature is used for verifying the transaction on-chain.
The cached result of confidential execution is used as calldata in the transaction that inevitably makes its way onto the SUAVE chain.
Other than ability to access new precompiles, the contracts aiming to be executed confidentially are written as usual in Solidity (or any other language) and compiled to EVM bytecode.
Confidential APIs
In the suave-geth reference implementation, confidential precompiles have access to the following Confidential APIs during execution. This is subject to change!
type ConfidentialStoreEngine interface {
Initialize(bid Bid, creationTx *types.Transaction, key string, value []byte) (Bid, error)
Store(bidId BidId, sourceTx *types.Transaction, caller common.Address, key string, value []byte) (Bid, error)
Retrieve(bid BidId, caller common.Address, key string) ([]byte, error)
}
type MempoolBackend interface {
SubmitBid(Bid) error
FetchBidById(BidId) (Bid, error)
FetchBidsByProtocolAndBlock(blockNumber uint64, namespace string) []Bid
}
type ConfidentialEthBackend interface {
BuildEthBlock(ctx context.Context, args *BuildBlockArgs, txs types.Transactions) (*engine.ExecutionPayloadEnvelope, error)
BuildEthBlockFromBundles(ctx context.Context, args *BuildBlockArgs, bundles []types.SBundle) (*engine.ExecutionPayloadEnvelope, error)
}
MEVM Example Flow + Diagram
TODO