From 0ffd69ad2cb7e2103fc673222a8a085369ba15c1 Mon Sep 17 00:00:00 2001 From: Eduard S Date: Wed, 10 Feb 2021 16:34:53 +0100 Subject: [PATCH] Verify stateroot at sync --- synchronizer/synchronizer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index 2a1d8f4..81d861f 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -929,9 +929,15 @@ func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, e return nil, tracerr.Wrap(err) } if s.stateDB.CurrentBatch() != batchNum { - return nil, tracerr.Wrap(fmt.Errorf("stateDB.BatchNum (%v) != evtForgeBatch.BatchNum = (%v)", + return nil, tracerr.Wrap(fmt.Errorf("stateDB.BatchNum (%v) != "+ + "evtForgeBatch.BatchNum = (%v)", s.stateDB.CurrentBatch(), batchNum)) } + if s.stateDB.MT.Root().BigInt().Cmp(forgeBatchArgs.NewStRoot) != 0 { + return nil, tracerr.Wrap(fmt.Errorf("stateDB.MTRoot (%v) != "+ + "forgeBatchArgs.NewStRoot (%v)", + s.stateDB.MT.Root().BigInt(), forgeBatchArgs.NewStRoot)) + } // Transform processed PoolL2 txs to L2 and store in BatchData l2Txs, err := common.PoolL2TxsToL2Txs(poolL2Txs) // NOTE: This is a big uggly, find a better way