Commit a36e0947 authored by Conner Fromknecht's avatar Conner Fromknecht

fix: check for empty block before submitting task in miner

Prior to this commit, an empty block would be submitted to the taskCh
before sanity check whether or not it was empty. This assertion is moved
up to fail before submitting the task.

It seems the placement of the check before was done to get around the
StreamUncle unit test, which would allow commit to submit an empty task
before ultimately failing. Now that the test is modified to reflect the
expected behavior of the sequencer, this placement is no longer
necessary.
parent c753ba81
......@@ -1076,6 +1076,15 @@ func (w *worker) commit(uncles []*types.Header, interval func(), start time.Time
if err != nil {
return err
}
// As a sanity check, ensure all new blocks have exactly one
// transaction. This check is done here just in case any of our
// higher-evel checks failed to catch empty blocks passed to commit.
txs := block.Transactions()
if len(txs) != 1 {
return fmt.Errorf("Block created with %d transactions rather than 1 at %d", len(txs), block.NumberU64())
}
if w.isRunning() {
if interval != nil {
interval()
......@@ -1092,10 +1101,6 @@ func (w *worker) commit(uncles []*types.Header, interval func(), start time.Time
}
feesEth := new(big.Float).Quo(new(big.Float).SetInt(feesWei), new(big.Float).SetInt(big.NewInt(params.Ether)))
txs := block.Transactions()
if len(txs) != 1 {
return fmt.Errorf("Block created with not %d transactions at %d", len(txs), block.NumberU64())
}
tx := txs[0]
bn := tx.L1BlockNumber()
if bn == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment