feat(worker): add chainId check in worker (#228)

* check chain id

* Update miner/taiko_worker.go

---------

Co-authored-by: David <david@taiko.xyz>
This commit is contained in:
maskpp 2024-05-06 14:22:53 +08:00 committed by GitHub
parent 6094ec356d
commit 4ebcf6656c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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