Skip to content

Commit 46318b5

Browse files
committed
remove duplicated code txsToTxsData with encoding.TxsToTxsData
1 parent 0707b91 commit 46318b5

File tree

1 file changed

+1
-40
lines changed

1 file changed

+1
-40
lines changed

rollup/internal/controller/watcher/l2_watcher.go

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"github.com/prometheus/client_golang/prometheus"
99
"github.com/scroll-tech/da-codec/encoding"
1010
"github.com/scroll-tech/go-ethereum/common"
11-
"github.com/scroll-tech/go-ethereum/common/hexutil"
12-
gethTypes "github.com/scroll-tech/go-ethereum/core/types"
1311
"github.com/scroll-tech/go-ethereum/ethclient"
1412
"github.com/scroll-tech/go-ethereum/event"
1513
"github.com/scroll-tech/go-ethereum/log"
@@ -86,43 +84,6 @@ func (w *L2WatcherClient) TryFetchRunningMissingBlocks(blockHeight uint64) {
8684
}
8785
}
8886

89-
func txsToTxsData(txs gethTypes.Transactions) []*gethTypes.TransactionData {
90-
txsData := make([]*gethTypes.TransactionData, len(txs))
91-
for i, tx := range txs {
92-
v, r, s := tx.RawSignatureValues()
93-
94-
nonce := tx.Nonce()
95-
96-
// We need QueueIndex in `NewBatchHeader`. However, `TransactionData`
97-
// does not have this field. Since `L1MessageTx` do not have a nonce,
98-
// we reuse this field for storing the queue index.
99-
if msg := tx.AsL1MessageTx(); msg != nil {
100-
nonce = msg.QueueIndex
101-
}
102-
103-
txsData[i] = &gethTypes.TransactionData{
104-
Type: tx.Type(),
105-
TxHash: tx.Hash().String(),
106-
Nonce: nonce,
107-
ChainId: (*hexutil.Big)(tx.ChainId()),
108-
Gas: tx.Gas(),
109-
GasPrice: (*hexutil.Big)(tx.GasPrice()),
110-
GasTipCap: (*hexutil.Big)(tx.GasTipCap()),
111-
GasFeeCap: (*hexutil.Big)(tx.GasFeeCap()),
112-
To: tx.To(),
113-
Value: (*hexutil.Big)(tx.Value()),
114-
Data: hexutil.Encode(tx.Data()),
115-
IsCreate: tx.To() == nil,
116-
AccessList: tx.AccessList(),
117-
AuthorizationList: tx.SetCodeAuthorizations(),
118-
V: (*hexutil.Big)(v),
119-
R: (*hexutil.Big)(r),
120-
S: (*hexutil.Big)(s),
121-
}
122-
}
123-
return txsData
124-
}
125-
12687
func (w *L2WatcherClient) getAndStoreBlocks(ctx context.Context, from, to uint64) error {
12788
var blocks []*encoding.Block
12889
for number := from; number <= to; number++ {
@@ -150,7 +111,7 @@ func (w *L2WatcherClient) getAndStoreBlocks(ctx context.Context, from, to uint64
150111
}
151112
blocks = append(blocks, &encoding.Block{
152113
Header: block.Header(),
153-
Transactions: txsToTxsData(block.Transactions()),
114+
Transactions: encoding.TxsToTxsData(block.Transactions()),
154115
WithdrawRoot: common.BytesToHash(withdrawRoot),
155116
RowConsumption: block.RowConsumption,
156117
})

0 commit comments

Comments
 (0)