Skip to content

Commit

Permalink
feat(worker): add chainId check in worker (#228)
Browse files Browse the repository at this point in the history
* check chain id

* Update miner/taiko_worker.go

---------

Co-authored-by: David <david@taiko.xyz>
  • Loading branch information
mask-pp and davidtaikocha committed May 6, 2024
1 parent 6094ec3 commit 4ebcf66
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions miner/taiko_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ebcf66

Please sign in to comment.