zkevm

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 Imported by: 0

README

zkEVM DataStreamer

zkEVM DataSreamer diagram

Binary file format

Header page

The first page is the header.
Header page size = 4096 bytes

Magic numbers

At the beginning of the file there are the following magic bytes (file signature): polygonDATSTREAM

Header entry format

u8 packetType = 1
u32 headerLength = 29
u64 streamType // 1:Sequencer
u64 totalLength // Total bytes used in the file
u64 totalEntries // Total number of data entries

Data page

From the second page starts the data pages.
Page size = 1 MB

Data entry format

u8 packetType // 2:Data entry, 0:Padding, (1:Header)
u32 length // Total length of the entry (17 bytes + length(data))
u32 entryType // 1:L2 block, 2:L2 tx
u64 entryNumber // Entry number (sequential starting with 0)
u8[] data

If an entry do not fits in the remaining page space we store this entry in the next page.

Diagram

Alt

TCP/IP Commands

All the commands available for stream clients returns a result.
Some commands like start may return more data.

Start

u64 command = 1;
u64 streamType // 1:Sequencer
u64 fromEntryNumber;

After the command, the system start stream data from that entry number.

If already started terminate connection.

Stop

u64 command = 2;
u64 streamType // 1:Sequencer

Stop streaming data.

If not started terminate connection.

The result is sended just after it's stopped.

Header

u64 command = 3;
u64 streamType // 1:Sequencer

Returns the current status of the header.

If started, terminate the connection.

Result format

u8 packetType // 0xFF:Result
u32 length // Total length of the entry
u32 errorNum // Error code (0:OK)
u8[] errorStr

Sequencer entries

Start L2 Block

Entry type = 1

Entry data:

u64 batchNum
u64 blockL2Num
u64 timestamp
u8[32] globalExitRoot
u8[20] coinbase
u16 forkId

L2 TX

Entry type = 2

Entry data:

u8 gasPricePercentage
u8 isValid // Intrinsic
u32 encodedTXLength
u8[] encodedTX

End L2 Block

Entry type = 3

Entry data:

u64 blockL2Num u256 l2BlockHash
u256 stateRoot

API Interface

  • StartAtomicOp()
  • AddStreamEntry(u32 entryType, u8[] data) -> return u64 entryNumber
  • CommitAtomicOp()
  • RollbackAtomicOp()

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "v0.1.0"
	GitRev    = "undefined"
	GitBranch = "undefined"
	BuildDate = "Fri, 17 Jun 1988 01:58:00 +0200"
)

Populated during build, don't touch!

Functions

func PrintVersion

func PrintVersion(w io.Writer)

PrintVersion prints version info into the provided io.Writer.

Types

This section is empty.

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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