monomer

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 24 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 submodules and a configured L1 backend. We use buf to manage protobufs.

Prerequisites
  1. Install go 1.22 or higher.

  2. Initialize submodules:

    git submodule update --init --recursive
    
  3. Install jq

  4. Install foundry

  5. Install buf:

    make install-buf
    
  6. Install golangci-lint:

    make install-golangci-lint
    
    
  7. Install go-test-coverage:

    make install-go-test-coverage
    
    
Running tests
  1. Set up the environment for end-to-end (e2e) tests:
    make setup-e2e
    
  2. Run the e2e tests:
    make e2e
    
  3. Run the unit tests:
    make test
    
Code Quality, Linting and Coverage
  1. Run linting:
    make lint
    
  2. Check test coverage
    make check-cover
    
Cleaning Up
  1. Clean up generated files and artifacts:
    make clean
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptCosmosTxsToEthTxs

func AdaptCosmosTxsToEthTxs(cosmosTxs bfttypes.Txs) (ethtypes.Transactions, error)

func AdaptNonDepositCosmosTxToEthTx

func AdaptNonDepositCosmosTxToEthTx(cosmosTx bfttypes.Tx) *ethtypes.Transaction

func AdaptPayloadTxsToCosmosTxs

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

AdaptPayloadTxsToCosmosTxs assumes the deposit transactions come first.

func GetDepositTxs

func GetDepositTxs(txsBytes [][]byte) (ethtypes.Transactions, error)

func NewChainConfig

func NewChainConfig(chainID *big.Int) *params.ChainConfig

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
	Txs    bfttypes.Txs
}

func MakeBlock

func MakeBlock(h *Header, txs bfttypes.Txs) (*Block, error)

MakeBlock creates a block and calculates the extrinsic properties on the header (like the block hash).

func NewBlock

func NewBlock(h *Header, txs bfttypes.Txs) *Block

NewBlock creates a new block. The header and txs must be non-nil. It performs no other validation.

func SetHeader

func SetHeader(block *Block) (*Block, error)

SetHeader calculates the extrinsic properties on the header (like the block hash) and resets them. It assumes the block has been created with NewBlock.

func (*Block) ToCometLikeBlock

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

func (*Block) ToEth

func (b *Block) ToEth() (*ethtypes.Block, error)

type ChainID

type ChainID uint64

func (ChainID) Big

func (id ChainID) Big() *big.Int

func (ChainID) HexBig

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

func (ChainID) String

func (id ChainID) String() string

type CosmosETHAddress added in v0.1.2

type CosmosETHAddress common.Address

CosmosETHAddress is a Cosmos address packed into an Ethereum address. Only addresses derived from secp256k1 keys can be packed into an Ethereum address. See [ADR-28] for more details.

func PubkeyToCosmosETHAddress added in v0.1.2

func PubkeyToCosmosETHAddress(pubKey *ecdsa.PublicKey) CosmosETHAddress

PubkeyToCosmosETHAddress converts a secp256k1 public key to a CosmosETHAddress. Passing in a non-secp256k1 key results in undefined behavior.

func (CosmosETHAddress) Encode added in v0.1.2

func (a CosmosETHAddress) Encode(hrp string) (string, error)
type Header struct {
	ChainID    ChainID
	Height     uint64
	Time       uint64
	ParentHash common.Hash
	StateRoot  common.Hash
	GasLimit   uint64
	Hash       common.Hash
}

func (*Header) ToComet

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

func (*Header) ToEth

func (h *Header) ToEth() *ethtypes.Header

ToEth converts a partial Monomer Header to an Ethereum Header. Extrinsic properties on the header (like the block hash) need to be set separately by SetHeader.

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
	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.

Directories

Path Synopsis
app
cmd
monogen Module
e2e
url
eth
gen
Package opdevnet contains helpers to build and run an OP devnet, including the L1 but excluding the OP execution engine.
Package opdevnet contains helpers to build and run an OP devnet, including the L1 but excluding the OP execution engine.
x
rollup/testutil
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.

Jump to

Keyboard shortcuts

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