Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): fix bug about miner.Pending call #357

Closed
wants to merge 10 commits into from
11 changes: 11 additions & 0 deletions consensus/taiko/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,17 @@ func (t *Taiko) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *t
return types.NewBlock(header, body, receipts, trie.NewStackTrie(nil)), nil
}

// CHANGE(taiko): same as FinalizeAndAssemble but just don't validate anchor tx in taiko engine.
func (t *Taiko) FinalizeAndAssembleWithoutAnchorTx(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
if body.Withdrawals == nil {
body.Withdrawals = make([]*types.Withdrawal, 0)
}

// Finalize block
t.Finalize(chain, header, state, body)
return types.NewBlock(header, body, receipts, trie.NewStackTrie(nil)), nil
}

// Seal generates a new sealing request for the given input block and pushes
// the result into the given channel.
//
Expand Down
13 changes: 12 additions & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/consensus/taiko"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/stateless"
Expand Down Expand Up @@ -125,10 +126,20 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
}
body.Requests = requests
}
block, err := miner.engine.FinalizeAndAssemble(miner.chain, work.header, work.state, &body, work.receipts)

// CHANGE(taiko): If the calling path is from miner.Pending and the engine is taiko engine then use `FinalizeAndAssembleWithoutAnchorTx`.
var block *types.Block
switch miner.engine.(type) {
case *taiko.Taiko:
engine := miner.engine.(*taiko.Taiko)
block, err = engine.FinalizeAndAssembleWithoutAnchorTx(miner.chain, work.header, work.state, &body, work.receipts)
default:
block, err = miner.engine.FinalizeAndAssemble(miner.chain, work.header, work.state, &body, work.receipts)
}
if err != nil {
return &newPayloadResult{err: err}
}

return &newPayloadResult{
block: block,
fees: totalFees(block, work.receipts),
Expand Down