monomer

package module
v0.0.0-...-bd2acf7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

Monomer

Monomer uses the OP stack to make Cosmos applications deployable as Ethereum rollups.

⚠ Monomer is pre-production software and should be used with caution. ⚠

At a Glance

Architecture

From the OP stack's perspective, Monomer replaces the default Ethereum compatible execution engine. From the Cosmos application's perspective, Monomer replaces the CometBFT consensus layer.

Development

We use Go 1.22. To run the e2e tests, you'll need the foundry tools and the submodules (git submodule update --init --recursive). We use buf to manage protobufs.

The Makefile includes commands for running tests and generating coverage profiles.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidForkchoiceUpdateResult

func ValidForkchoiceUpdateResult(headBlockHash *common.Hash, id *engine.PayloadID) *opeth.ForkchoiceUpdatedResult

ValidForkchoiceUpdateResult returns a valid ForkchoiceUpdateResult with given head block hash.

Types

type Block

type Block struct {
	Header *Header      `json:"header"`
	Txs    bfttypes.Txs `json:"txs"`
}

func (*Block) Hash

func (b *Block) Hash() common.Hash

Hash returns a unique hash of the block, used as the block identifier

func (*Block) ToCometLikeBlock

func (b *Block) ToCometLikeBlock() *bfttypes.Block

func (*Block) ToEthLikeBlock

func (b *Block) ToEthLikeBlock(txs ethtypes.Transactions, inclTxs bool) map[string]any

This trick is played by the eth rpc server too. Instead of constructing an actual eth block, simply create a map with the right keys so the client can unmarshal it into a block

type ChainID

type ChainID uint64

func (ChainID) HexBig

func (id ChainID) HexBig() *hexutil.Big

func (ChainID) String

func (id ChainID) String() string

type CosmosTxAdapter

type CosmosTxAdapter func(cosmosTxs bfttypes.Txs) (ethtypes.Transactions, error)

CosmosTxAdapter transforms Cosmos transactions into Ethereum transactions.

In practice, this will use msg types from Monomer's rollup module, but importing the rollup module here would create a circular module dependency between Monomer, the SDK, and the rollup module. sdk -> monomer -> rollup -> sdk, where -> is "depends on".

type Header struct {
	ChainID    ChainID     `json:"chain_id"`
	Height     int64       `json:"height"`
	Time       uint64      `json:"time"`
	ParentHash common.Hash `json:"parentHash"`
	// state after txs from the *previous* block
	AppHash  []byte      `json:"app_hash"`
	GasLimit uint64      `json:"gasLimit"`
	Hash     common.Hash `json:"hash"`
}

func (*Header) ToComet

func (h *Header) ToComet() *bfttypes.Header

type PayloadAttributes

type PayloadAttributes struct {
	Timestamp             uint64
	PrevRandao            [32]byte
	SuggestedFeeRecipient common.Address
	Withdrawals           *ethtypes.Withdrawals
	NoTxPool              bool
	GasLimit              uint64
	ParentBeaconBlockRoot *common.Hash
	ParentHash            common.Hash
	Height                int64
	Transactions          []hexutil.Bytes
	CosmosTxs             bfttypes.Txs
	// contains filtered or unexported fields
}

func (*PayloadAttributes) ID

ID returns a PaylodID (a hash) from a PayloadAttributes when it's applied to a head block. Hashing does not conform to go-ethereum/miner/payload_building.go PayloadID is only calculated once, and cached for future calls.

type PayloadTxAdapter

type PayloadTxAdapter func(ethTxs []hexutil.Bytes) (bfttypes.Txs, error)

PayloadTxAdapter transforms Op payload transactions into Cosmos transactions.

In practice, this will use msg types from Monomer's rollup module, but importing the rollup module here would create a circular module dependency between Monomer, the SDK, and the rollup module. sdk -> monomer -> rollup -> sdk, where -> is "depends on".

Directories

Path Synopsis
app
e2e
url
gen
rollup/module/v1
Code generated by protoc-gen-go-pulsar.
Code generated by protoc-gen-go-pulsar.
testapp/module/v1
Code generated by protoc-gen-go-pulsar.
Code generated by protoc-gen-go-pulsar.
x

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL