Skip to content

Commit

Permalink
feat(miner): use []*ethapi.RPCTransaction in RPC response body (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Feb 24, 2025
1 parent 36430eb commit afd09af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion miner/taiko_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/internal/ethapi"
)

// PreBuiltTxList is a pre-built transaction list based on the latest chain state,
// with estimated gas used / bytes.
type PreBuiltTxList struct {
TxList types.Transactions
TxList []*ethapi.RPCTransaction
EstimatedGasUsed uint64
BytesLength uint64
}
Expand Down
12 changes: 11 additions & 1 deletion miner/taiko_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -93,7 +94,7 @@ func (w *Miner) buildTransactionsLists(
}

return lastTransaction, &PreBuiltTxList{
TxList: env.txs,
TxList: w.toRPCTransactions(env.txs),
EstimatedGasUsed: env.header.GasLimit - env.gasPool.Gas(),
BytesLength: uint64(len(b)),
}, nil
Expand Down Expand Up @@ -338,6 +339,15 @@ loop:
return lastTransaction
}

// toRPCTransactions converts the given transactions to RPC transactions.
func (w *Miner) toRPCTransactions(txs types.Transactions) []*ethapi.RPCTransaction {
var rpcTxs []*ethapi.RPCTransaction
for _, tx := range txs {
rpcTxs = append(rpcTxs, ethapi.NewRPCPendingTransaction(tx, nil, w.chainConfig))
}
return rpcTxs
}

// encodeAndCompressTxList encodes and compresses the given transactions list.
func encodeAndCompressTxList(txs types.Transactions) ([]byte, error) {
b, err := rlp.EncodeToBytes(txs)
Expand Down

0 comments on commit afd09af

Please sign in to comment.