Skip to content

Commit

Permalink
remove FinalizeAndAssembleWithoutAnchorTx interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Dec 9, 2024
1 parent febfe1e commit 4c4b82d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
5 changes: 0 additions & 5 deletions consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,6 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
return block, nil
}

// CHANGE(taiko): same as FinalizeAndAssemble.
func (beacon *Beacon) FinalizeAndAssembleWithoutAnchorTx(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
return beacon.FinalizeAndAssemble(chain, header, state, body, receipts)
}

// Seal generates a new sealing request for the given input block and pushes
// the result into the given channel.
//
Expand Down
5 changes: 0 additions & 5 deletions consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,6 @@ func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
return types.NewBlock(header, &types.Body{Transactions: body.Transactions}, receipts, trie.NewStackTrie(nil)), nil
}

// CHANGE(taiko): same as FinalizeAndAssemble.
func (c *Clique) FinalizeAndAssembleWithoutAnchorTx(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
return c.FinalizeAndAssemble(chain, header, state, body, receipts)
}

// Authorize injects a private key into the consensus engine to mint new blocks
// with.
func (c *Clique) Authorize(signer common.Address, signFn SignerFn) {
Expand Down
3 changes: 0 additions & 3 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ type Engine interface {
// consensus rules that happen at finalization (e.g. block rewards).
FinalizeAndAssemble(chain ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error)

// CHANGE(taiko): same as FinalizeAndAssemble but just don't validate anchor tx in taiko engine.
FinalizeAndAssembleWithoutAnchorTx(chain ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error)

// Seal generates a new sealing request for the given input block and pushes
// the result into the given channel.
//
Expand Down
5 changes: 0 additions & 5 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,6 @@ func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
return types.NewBlock(header, &types.Body{Transactions: body.Transactions, Uncles: body.Uncles}, receipts, trie.NewStackTrie(nil)), nil
}

// CHANGE(taiko): same as FinalizeAndAssemble.
func (ethash *Ethash) FinalizeAndAssembleWithoutAnchorTx(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
return ethash.FinalizeAndAssemble(chain, header, state, body, receipts)
}

// SealHash returns the hash of a block prior to it being sealed.
func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
hasher := sha3.NewLegacyKeccak256()
Expand Down
13 changes: 12 additions & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package miner
import (
"errors"
"fmt"
"github.com/ethereum/go-ethereum/consensus/taiko"
"math/big"
"sync/atomic"
"time"
Expand Down Expand Up @@ -125,10 +126,20 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
}
body.Requests = requests
}
block, err := miner.engine.FinalizeAndAssembleWithoutAnchorTx(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

0 comments on commit 4c4b82d

Please sign in to comment.