Skip to content

Commit

Permalink
Avoid Reprocess the full batch (#2240)
Browse files Browse the repository at this point in the history
* Avoid reset trusted batch

* avoid read batch from db all the time

* linter

* remove BatchL2Data decodification

* logs

* Avoid process the whole batch

* sync working

* refactor

* remove unused code

* fixed unittest

* removed commented code

---------

Co-authored-by: joanestebanr <[email protected]>
  • Loading branch information
ARR552 and joanestebanr authored Jun 30, 2023
1 parent 99cd6bd commit 93b54af
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 416 deletions.
12 changes: 0 additions & 12 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,18 +996,6 @@ func (etherMan *Client) GetL2ChainID() (uint64, error) {
return etherMan.ZkEVM.ChainID(&bind.CallOpts{Pending: false})
}

// GetL2ForkID returns current L2 Fork ID
func (etherMan *Client) GetL2ForkID() (uint64, error) {
// TODO: implement this
return 1, nil
}

// GetL2ForkIDIntervals return L2 Fork ID intervals
func (etherMan *Client) GetL2ForkIDIntervals() ([]state.ForkIDInterval, error) {
// TODO: implement this
return []state.ForkIDInterval{{FromBatchNumber: 0, ToBatchNumber: math.MaxUint64, ForkId: 1}}, nil
}

// GetL1GasPrice gets the l1 gas price
func (etherMan *Client) GetL1GasPrice(ctx context.Context) *big.Int {
// Get gasPrice from providers
Expand Down
2 changes: 1 addition & 1 deletion state/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ func (s *State) isContractCreation(tx *types.Transaction) bool {
return tx.To() == nil && len(tx.Data()) > 0
}

// StoreTransaction is used by the sequencer to add process a transaction
// StoreTransaction is used by the sequencer and trusted state synchronizer to add process a transaction.
func (s *State) StoreTransaction(ctx context.Context, batchNumber uint64, processedTx *ProcessTransactionResponse, coinbase common.Address, timestamp uint64, dbTx pgx.Tx) error {
if dbTx == nil {
return ErrDBTxNil
Expand Down
4 changes: 2 additions & 2 deletions synchronizer/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ type stateInterface interface {
SetGenesis(ctx context.Context, block state.Block, genesis state.Genesis, dbTx pgx.Tx) ([]byte, error)
OpenBatch(ctx context.Context, processingContext state.ProcessingContext, dbTx pgx.Tx) error
CloseBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error
ProcessSequencerBatch(ctx context.Context, batchNumber uint64, batchL2Data []byte, caller metrics.CallerLabel, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
StoreTransactions(ctx context.Context, batchNum uint64, processedTxs []*state.ProcessTransactionResponse, dbTx pgx.Tx) error
ProcessBatch(ctx context.Context, request state.ProcessRequest, updateMerkleTree bool) (*state.ProcessBatchResponse, error)
StoreTransaction(ctx context.Context, batchNumber uint64, processedTx *state.ProcessTransactionResponse, coinbase common.Address, timestamp uint64, dbTx pgx.Tx) error
GetStateRootByBatchNumber(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (common.Hash, error)
ExecuteBatch(ctx context.Context, batch state.Batch, updateMerkleTree bool, dbTx pgx.Tx) (*pb.ProcessBatchResponse, error)
GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
Expand Down
28 changes: 14 additions & 14 deletions synchronizer/mock_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 93b54af

Please sign in to comment.