rollup_sync_service

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeChunkBlockRanges

func DecodeChunkBlockRanges(chunks [][]byte) ([]*rawdb.ChunkBlockRange, error)

DecodeChunkBlockRanges decodes the provided chunks into a list of block ranges. Each chunk contains information about multiple blocks, which are decoded and their ranges (from the start block to the end block) are returned.

func UnpackLog

func UnpackLog(c *abi.ABI, out interface{}, event string, log types.Log) error

UnpackLog unpacks a retrieved log into the provided output structure.

Types

type BatchHeader

type BatchHeader struct {
	// contains filtered or unexported fields
}

BatchHeader contains batch header info to be committed.

func NewBatchHeader

func NewBatchHeader(version uint8, batchIndex, totalL1MessagePoppedBefore uint64, parentBatchHash common.Hash, chunks []*Chunk) (*BatchHeader, error)

NewBatchHeader creates a new BatchHeader

func (*BatchHeader) Encode

func (b *BatchHeader) Encode() []byte

Encode encodes the BatchHeader into RollupV2 BatchHeaderV0Codec Encoding.

func (*BatchHeader) Hash

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

Hash calculates the hash of the batch header.

type BlockContext

type BlockContext struct {
	BlockHash       common.Hash
	ParentHash      common.Hash
	BlockNumber     uint64
	Timestamp       uint64
	BaseFee         *big.Int
	GasLimit        uint64
	NumTransactions uint16
	NumL1Messages   uint16
}

BlockContext represents the essential data of a block in the ScrollChain. It provides an overview of block attributes including hash values, block numbers, gas details, and transaction counts.

type Chunk

type Chunk struct {
	Blocks []*WrappedBlock `json:"blocks"`
}

Chunk contains blocks to be encoded

func (*Chunk) Encode

func (c *Chunk) Encode(totalL1MessagePoppedBefore uint64) ([]byte, error)

Encode encodes the Chunk into RollupV2 Chunk Encoding.

func (*Chunk) Hash

func (c *Chunk) Hash(totalL1MessagePoppedBefore uint64) (common.Hash, error)

Hash hashes the Chunk into RollupV2 Chunk Hash

func (*Chunk) NumL1Messages

func (c *Chunk) NumL1Messages(totalL1MessagePoppedBefore uint64) uint64

NumL1Messages returns the number of L1 messages in this chunk. This number is the sum of included and skipped L1 messages.

type L1Client

type L1Client struct {
	// contains filtered or unexported fields
}

L1Client is a wrapper around EthClient that adds methods for conveniently collecting rollup events of ScrollChain contract.

type L1CommitBatchEvent

type L1CommitBatchEvent struct {
	BatchIndex *big.Int
	BatchHash  common.Hash
}

L1CommitBatchEvent represents a CommitBatch event raised by the ScrollChain contract.

type L1FinalizeBatchEvent

type L1FinalizeBatchEvent struct {
	BatchIndex   *big.Int
	BatchHash    common.Hash
	StateRoot    common.Hash
	WithdrawRoot common.Hash
}

L1FinalizeBatchEvent represents a FinalizeBatch event raised by the ScrollChain contract.

type L1RevertBatchEvent

type L1RevertBatchEvent struct {
	BatchIndex *big.Int
	BatchHash  common.Hash
}

L1RevertBatchEvent represents a RevertBatch event raised by the ScrollChain contract.

type RollupSyncService

type RollupSyncService struct {
	// contains filtered or unexported fields
}

RollupSyncService collects ScrollChain batch commit/revert/finalize events and stores metadata into db.

func NewRollupSyncService

func NewRollupSyncService(ctx context.Context, genesisConfig *params.ChainConfig, db ethdb.Database, l1Client sync_service.EthClient, bc *core.BlockChain, l1DeploymentBlock uint64) (*RollupSyncService, error)

func (*RollupSyncService) Start

func (s *RollupSyncService) Start()

func (*RollupSyncService) Stop

func (s *RollupSyncService) Stop()

type WrappedBlock

type WrappedBlock struct {
	Header *types.Header `json:"header"`
	// Transactions is only used for recover types.Transactions, the from of types.TransactionData field is missing.
	Transactions []*types.TransactionData `json:"transactions"`
	WithdrawRoot common.Hash              `json:"withdraw_trie_root,omitempty"`
}

WrappedBlock contains the block's Header, Transactions and WithdrawTrieRoot hash.

func (*WrappedBlock) Encode

func (w *WrappedBlock) Encode(totalL1MessagePoppedBefore uint64) ([]byte, error)

Encode encodes the WrappedBlock into RollupV2 BlockContext Encoding.

Jump to

Keyboard shortcuts

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