l2_sync_etrog

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented is returned when a method is not implemented
	ErrNotImplemented = errors.New("not implemented")
	// ErrFailExecuteBatch is returned when the batch is not executed correctly
	ErrFailExecuteBatch = errors.New("fail execute batch")
	// ErrCriticalClosedBatchDontContainExpectedData is returnted when try to close a batch that is already close but data doesnt match
	ErrCriticalClosedBatchDontContainExpectedData = errors.New("when closing the batch, the batch is already close, but  the data on state doesnt match the expected")
	// ErrCantReprocessBatchMissingPreviousStateBatch can't reprocess a divergent batch because is missing previous state batch
	ErrCantReprocessBatchMissingPreviousStateBatch = errors.New("cant reprocess batch because is missing previous state batch")
)

Functions

This section is empty.

Types

type CheckSyncStatusToProcessBatch

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

CheckSyncStatusToProcessBatch Implements CheckSyncStatusToProcessBatchInterface

func NewCheckSyncStatusToProcessBatch

func NewCheckSyncStatusToProcessBatch(zkevmRPCClient syncinterfaces.ZKEVMClientGlobalExitRootGetter, state StateGERInteface) *CheckSyncStatusToProcessBatch

NewCheckSyncStatusToProcessBatch returns a new instance of CheckSyncStatusToProcessBatch

func (*CheckSyncStatusToProcessBatch) CheckL1SyncGlobalExitRootEnoughToProcessBatch added in v0.6.1

func (c *CheckSyncStatusToProcessBatch) CheckL1SyncGlobalExitRootEnoughToProcessBatch(ctx context.Context, batchNumber uint64, globalExitRoot common.Hash, dbTx pgx.Tx) error

CheckL1SyncGlobalExitRootEnoughToProcessBatch returns nil if the are sync and could process the batch if not:

  • returns syncinterfaces.ErrMissingSyncFromL1 if we are behind the block number that contains the GlobalExitRoot
  • returns l2_shared.NewDeSyncPermissionlessAndTrustedNodeError if trusted and and permissionless are not in same page! pass also the discrepance point

type StateGERInteface

type StateGERInteface interface {
	GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*state.GlobalExitRoot, error)
	GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)
}

StateGERInteface interface that requires from State

type StateInterface

type StateInterface interface {
	BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
	CloseBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error
	GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
	GetForkIDByBatchNumber(batchNumber uint64) uint64
	UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error
	ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
	OpenBatch(ctx context.Context, processingContext state.ProcessingContext, dbTx pgx.Tx) error
	ProcessBatchV2(ctx context.Context, request state.ProcessRequest, updateMerkleTree bool) (*state.ProcessBatchResponse, error)
	StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error
	GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]state.L1DataV2, common.Hash, common.Hash, error)
	GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error)
}

StateInterface contains the methods required to interact with the state.

type SyncTrustedBatchExecutorForEtrog

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

SyncTrustedBatchExecutorForEtrog is the implementation of the SyncTrustedStateBatchExecutorSteps that have the functions to sync a fullBatch, incrementalBatch and reprocessBatch

func NewSyncTrustedBatchExecutorForEtrog

func NewSyncTrustedBatchExecutorForEtrog(stateBatchExecutor StateInterface,
	sync syncinterfaces.SynchronizerFlushIDManager) *SyncTrustedBatchExecutorForEtrog

NewSyncTrustedBatchExecutorForEtrog creates a new SyncTrustedBatchExecutorForEtrog

func (*SyncTrustedBatchExecutorForEtrog) CloseBatch

func (b *SyncTrustedBatchExecutorForEtrog) CloseBatch(ctx context.Context, trustedBatch *types.Batch, dbTx pgx.Tx, debugStr string) error

CloseBatch close a batch

func (*SyncTrustedBatchExecutorForEtrog) CreateEmptyBatch

func (b *SyncTrustedBatchExecutorForEtrog) CreateEmptyBatch(ctx context.Context, data *l2_shared.ProcessData, dbTx pgx.Tx) (*l2_shared.ProcessResponse, error)

CreateEmptyBatch create a new empty batch (no batchL2Data and WIP)

func (*SyncTrustedBatchExecutorForEtrog) FullProcess

FullProcess process a batch that is not on database, so is the first time we process it

func (*SyncTrustedBatchExecutorForEtrog) IncrementalProcess

func (b *SyncTrustedBatchExecutorForEtrog) IncrementalProcess(ctx context.Context, data *l2_shared.ProcessData, dbTx pgx.Tx) (*l2_shared.ProcessResponse, error)

IncrementalProcess process a batch that we have processed before, and we have the intermediate state root, so is going to be process only new Tx

func (*SyncTrustedBatchExecutorForEtrog) NothingProcess

NothingProcess process a batch that is already on database and no new L2batchData, so it is not going to be processed again. Maybe it needs to be close

func (*SyncTrustedBatchExecutorForEtrog) ReProcess

ReProcess process a batch that we have processed before, but we don't have the intermediate state root, so we need to reprocess it

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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