types

package
v0.0.0-...-92d349b Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileEntryMinSize  uint32    = 17 // 1+4+4+8
	BookmarkEntryType EntryType = 176
)
View Source
const (
	ResultEntryMinSize = uint32(9)

	// Command errors
	CmdErrOK             = 0
	CmdErrAlreadyStarted = 1
	CmdErrAlreadyStopped = 2
	CmdErrBadFromEntry   = 3
	CmdErrInvalidCommand = 9
)
View Source
const (
	BookmarkTypeStart byte = 0
)
View Source
const HeaderSize = 29

Variables

This section is empty.

Functions

This section is empty.

Types

type Bookmark

type Bookmark struct {
	Type byte
	From uint64
}

func NewL2BlockBookmark

func NewL2BlockBookmark(fromBlock uint64) *Bookmark

func (*Bookmark) Encode

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

type CommandError

type CommandError uint32

type EndL2Block

type EndL2Block struct {
	L2BlockNumber uint64      // 8 bytes
	L2Blockhash   common.Hash // 32 bytes
	StateRoot     common.Hash // 32 bytes
}

func DecodeEndL2Block

func DecodeEndL2Block(data []byte) (*EndL2Block, error)

DecodeEndL2Block decodes a EndL2Block from a byte array

type EntryType

type EntryType uint32
const (

	// EntryTypeL2Block represents a L2 block
	EntryTypeStartL2Block EntryType = 1
	EntryTypeEndL2Block   EntryType = 3
)
const (

	// EntryTypeL2Block represents a L2 block
	EntryTypeGerUpdate EntryType = 4
)
const (

	// EntryTypeL2Tx represents a L2 transaction
	EntryTypeL2Tx EntryType = 2
)

type FileEntry

type FileEntry struct {
	PacketType uint8     // 2:Data entry, 0:Padding, (1:Header)
	Length     uint32    // Length of the entry
	EntryType  EntryType // e.g. 1:L2 block, 2:L2 tx, 176: bookmark
	EntryNum   uint64    // Entry number (sequential starting with 0)
	Data       []byte
}

func DecodeFileEntry

func DecodeFileEntry(b []byte) (*FileEntry, error)

Decode/convert from binary bytes slice to FileEntry type

func (*FileEntry) IsBlockEnd

func (f *FileEntry) IsBlockEnd() bool

func (*FileEntry) IsBlockStart

func (f *FileEntry) IsBlockStart() bool

func (*FileEntry) IsBookmark

func (f *FileEntry) IsBookmark() bool

func (*FileEntry) IsGerUpdate

func (f *FileEntry) IsGerUpdate() bool

func (*FileEntry) IsTx

func (f *FileEntry) IsTx() bool

type FullL2Block

type FullL2Block struct {
	BatchNumber    uint64
	L2BlockNumber  uint64
	Timestamp      int64
	GlobalExitRoot common.Hash
	Coinbase       common.Address
	ForkId         uint16
	L2Blockhash    common.Hash
	StateRoot      common.Hash
	L2Txs          []L2Transaction
	ParentHash     common.Hash
}

func ParseFullL2Block

func ParseFullL2Block(startL2Block *StartL2Block, endL2Block *EndL2Block, l2Txs *[]L2Transaction) *FullL2Block

ParseFullL2Block parses a FullL2Block from a StartL2Block, EndL2Block and a slice of L2Transactions

type GerUpdate

type GerUpdate struct {
	BatchNumber    uint64         // 8 bytes
	Timestamp      uint64         // 8 bytes
	GlobalExitRoot common.Hash    // 32 bytes
	Coinbase       common.Address // 20 bytes
	ForkId         uint16         // 2 bytes
	StateRoot      common.Hash    // 32 bytes
}

StartL2Block represents a zkEvm block

func DecodeGerUpdate

func DecodeGerUpdate(data []byte) (*GerUpdate, error)

decodes a StartL2Block from a byte array

func (*GerUpdate) EncodeToBytes

func (g *GerUpdate) EncodeToBytes() []byte

type HeaderEntry

type HeaderEntry struct {
	PacketType   uint8      // 1:Header
	HeadLength   uint32     // 29
	StreamType   StreamType // 1:Sequencer
	TotalLength  uint64     // Total bytes used in the file
	TotalEntries uint64     // Total number of data entries (entry type 2)
}

func DecodeHeaderEntry

func DecodeHeaderEntry(b []byte) (*HeaderEntry, error)

Decode/convert from binary bytes slice to a header entry type

type L2Transaction

type L2Transaction struct {
	EffectiveGasPricePercentage uint8       // 1 byte
	IsValid                     uint8       // 1 byte
	StateRoot                   common.Hash // 32 bytes
	EncodedLength               uint32      // 4 bytes
	Encoded                     []byte
}

L2Transaction represents a zkEvm transaction

func DecodeL2Transaction

func DecodeL2Transaction(data []byte) (*L2Transaction, error)

DecodeL2Transaction decodes a L2 transaction from a byte array

type ResultEntry

type ResultEntry struct {
	PacketType uint8 // 0xff:Result
	Length     uint32
	ErrorNum   uint32 // 0:No error
	ErrorStr   []byte
}

func DecodeResultEntry

func DecodeResultEntry(b []byte) (*ResultEntry, error)

Decode/convert from binary bytes slice to an entry type

func (*ResultEntry) GetError

func (r *ResultEntry) GetError() error

returns the error string if the result error number is not OK returns nil otherwise

func (ResultEntry) IsOk

func (r ResultEntry) IsOk() bool

checks is the result error number is OK

type StartL2Block

type StartL2Block struct {
	BatchNumber    uint64         // 8 bytes
	L2BlockNumber  uint64         // 8 bytes
	Timestamp      int64          // 8 bytes
	GlobalExitRoot common.Hash    // 32 bytes
	Coinbase       common.Address // 20 bytes
	ForkId         uint16         // 2 bytes
}

StartL2Block represents a zkEvm block

func DecodeStartL2Block

func DecodeStartL2Block(data []byte) (*StartL2Block, error)

decodes a StartL2Block from a byte array

type StreamType

type StreamType uint64

Jump to

Keyboard shortcuts

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