From 4ebcf6656c507c3164722148c16e76f7766fe52e Mon Sep 17 00:00:00 2001 From: maskpp Date: Mon, 6 May 2024 14:22:53 +0800 Subject: [PATCH] feat(worker): add `chainId` check in `worker` (#228) * check chain id * Update miner/taiko_worker.go --------- Co-authored-by: David --- miner/taiko_worker.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/miner/taiko_worker.go b/miner/taiko_worker.go index 393f1c1d90b2..2aa04923a7bd 100644 --- a/miner/taiko_worker.go +++ b/miner/taiko_worker.go @@ -172,6 +172,15 @@ func (w *worker) sealBlockWith( env.gasPool = new(core.GasPool).AddGas(gasLimit) for i, tx := range txs { + if tx.ChainId().Cmp(w.chainConfig.ChainID) != 0 { + if i == 0 { + return nil, fmt.Errorf("anchor tx with invalid chain id, expected: %v, actual: %v", w.chainConfig.ChainID, tx.ChainId()) + } else { + log.Debug("Skip an proposed transaction with invalid chain id", "hash", tx.Hash(), "expect", w.chainConfig.ChainID, "actual", tx.ChainId()) + continue + } + } + if i == 0 { if err := tx.MarkAsAnchor(); err != nil { return nil, err