Skip to content

Commit 4333d51

Browse files
author
colinlyguo
committed
Revert "feat(bridge-history): support codecv7"
This reverts commit 82dd5e0.
1 parent 82dd5e0 commit 4333d51

File tree

15 files changed

+55
-217
lines changed

15 files changed

+55
-217
lines changed

bridge-history-api/abi/backend_abi.go

Lines changed: 4 additions & 11 deletions
Large diffs are not rendered by default.

bridge-history-api/abi/backend_abi_test.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

bridge-history-api/cmd/fetcher/app/app.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ func action(ctx *cli.Context) error {
6868

6969
observability.Server(ctx, db)
7070

71-
l1MessageFetcher, err := fetcher.NewL1MessageFetcher(subCtx, cfg.L1, db, l1Client)
72-
if err != nil {
73-
log.Crit("failed to create L1MessageFetcher", "err", err)
74-
}
71+
l1MessageFetcher := fetcher.NewL1MessageFetcher(subCtx, cfg.L1, db, l1Client)
7572
go l1MessageFetcher.Start()
7673

7774
l2MessageFetcher := fetcher.NewL2MessageFetcher(subCtx, cfg.L2, db, l2Client)

bridge-history-api/conf/config.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
"ScrollChainAddr": "0xa13BAF47339d63B743e7Da8741db5456DAc1E556",
2020
"GatewayRouterAddr": "0xF8B1378579659D8F7EE5f3C929c2f3E332E41Fd6",
2121
"MessageQueueAddr": "0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B",
22-
"MessageQueueV2Addr": "0x0000000000000000000000000000000000000000",
2322
"BatchBridgeGatewayAddr": "0x5Bcfd99c34cf7E06fc756f6f5aE7400504852bc4",
2423
"GasTokenGatewayAddr": "0x0000000000000000000000000000000000000000",
25-
"WrappedTokenGatewayAddr": "0x0000000000000000000000000000000000000000",
26-
"BlobScanAPIEndpoint": "https://api.blobscan.com/blobs/"
24+
"WrappedTokenGatewayAddr": "0x0000000000000000000000000000000000000000"
2725
},
2826
"L2": {
2927
"confirmation": 0,

bridge-history-api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/go-redis/redis/v8 v8.11.5
1111
github.com/pressly/goose/v3 v3.16.0
1212
github.com/prometheus/client_golang v1.19.0
13-
github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950
13+
github.com/scroll-tech/go-ethereum v1.10.14-0.20250304112538-3c454e7101a3
1414
github.com/stretchr/testify v1.9.0
1515
github.com/urfave/cli/v2 v2.25.7
1616
golang.org/x/sync v0.11.0

bridge-history-api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
311311
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
312312
github.com/scroll-tech/da-codec v0.1.3-0.20250226072559-f8a8d3898f54 h1:qVpsVu1J91opTn6HYeuzWcBRVhQmPR8g05i+PlOjlI4=
313313
github.com/scroll-tech/da-codec v0.1.3-0.20250226072559-f8a8d3898f54/go.mod h1:xECEHZLVzbdUn+tNbRJhRIjLGTOTmnFQuTgUTeVLX58=
314-
github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950 h1:qfOaRflvH1vtnFWloB7BveKlP/VqYgMqLJ6e9TlBJ/8=
315-
github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950/go.mod h1:OblWe1+QrZwdpwO0j/LY3BSGuKT3YPUFBDQQgvvfStQ=
314+
github.com/scroll-tech/go-ethereum v1.10.14-0.20250304112538-3c454e7101a3 h1:y0L8+O3anBJIpboVWhNlUx3VC59he+0fd4b8PnDR16w=
315+
github.com/scroll-tech/go-ethereum v1.10.14-0.20250304112538-3c454e7101a3/go.mod h1:OblWe1+QrZwdpwO0j/LY3BSGuKT3YPUFBDQQgvvfStQ=
316316
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
317317
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
318318
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=

bridge-history-api/internal/config/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,9 @@ type FetcherConfig struct {
3030
ScrollChainAddr string `json:"ScrollChainAddr"`
3131
GatewayRouterAddr string `json:"GatewayRouterAddr"`
3232
MessageQueueAddr string `json:"MessageQueueAddr"`
33-
MessageQueueV2Addr string `json:"MessageQueueV2Addr"`
3433
BatchBridgeGatewayAddr string `json:"BatchBridgeGatewayAddr"`
3534
GasTokenGatewayAddr string `json:"GasTokenGatewayAddr"`
3635
WrappedTokenGatewayAddr string `json:"WrappedTokenGatewayAddr"`
37-
38-
BeaconNodeAPIEndpoint string `json:"BeaconNodeAPIEndpoint"`
39-
BlobScanAPIEndpoint string `json:"BlobScanAPIEndpoint"`
40-
BlockNativeAPIEndpoint string `json:"BlockNativeAPIEndpoint"`
4136
}
4237

4338
// RedisConfig redis config

bridge-history-api/internal/controller/fetcher/l1_fetcher.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package fetcher
22

33
import (
44
"context"
5-
"fmt"
65
"math/big"
76
"time"
87

@@ -11,7 +10,6 @@ import (
1110
"github.com/scroll-tech/go-ethereum/common"
1211
"github.com/scroll-tech/go-ethereum/ethclient"
1312
"github.com/scroll-tech/go-ethereum/log"
14-
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"
1513
"gorm.io/gorm"
1614

1715
"scroll-tech/bridge-history-api/internal/config"
@@ -37,32 +35,13 @@ type L1MessageFetcher struct {
3735
}
3836

3937
// NewL1MessageFetcher creates a new L1MessageFetcher instance.
40-
func NewL1MessageFetcher(ctx context.Context, cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) (*L1MessageFetcher, error) {
41-
blobClientList := blob_client.NewBlobClients()
42-
if cfg.BeaconNodeAPIEndpoint != "" {
43-
beaconNodeClient, err := blob_client.NewBeaconNodeClient(cfg.BeaconNodeAPIEndpoint)
44-
if err != nil {
45-
log.Warn("failed to create BeaconNodeClient", "err", err)
46-
} else {
47-
blobClientList.AddBlobClient(beaconNodeClient)
48-
}
49-
}
50-
if cfg.BlobScanAPIEndpoint != "" {
51-
blobClientList.AddBlobClient(blob_client.NewBlobScanClient(cfg.BlobScanAPIEndpoint))
52-
}
53-
if cfg.BlockNativeAPIEndpoint != "" {
54-
blobClientList.AddBlobClient(blob_client.NewBlockNativeClient(cfg.BlockNativeAPIEndpoint))
55-
}
56-
if blobClientList.Size() == 0 {
57-
return nil, fmt.Errorf("no blob client is configured")
58-
}
59-
38+
func NewL1MessageFetcher(ctx context.Context, cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L1MessageFetcher {
6039
c := &L1MessageFetcher{
6140
ctx: ctx,
6241
cfg: cfg,
6342
client: client,
6443
eventUpdateLogic: logic.NewEventUpdateLogic(db, true),
65-
l1FetcherLogic: logic.NewL1FetcherLogic(cfg, db, client, blobClientList),
44+
l1FetcherLogic: logic.NewL1FetcherLogic(cfg, db, client),
6645
}
6746

6847
reg := prometheus.DefaultRegisterer
@@ -79,7 +58,7 @@ func NewL1MessageFetcher(ctx context.Context, cfg *config.FetcherConfig, db *gor
7958
Help: "Latest blockchain height the L1 message fetcher has synced with.",
8059
})
8160

82-
return c, nil
61+
return c
8362
}
8463

8564
// Start starts the L1 message fetching process.

bridge-history-api/internal/logic/l1_event_parser.go

Lines changed: 8 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ package logic
22

33
import (
44
"context"
5-
"fmt"
65
"math/big"
76

8-
"github.com/scroll-tech/da-codec/encoding"
97
"github.com/scroll-tech/go-ethereum/common"
108
"github.com/scroll-tech/go-ethereum/core/types"
119
"github.com/scroll-tech/go-ethereum/crypto"
1210
"github.com/scroll-tech/go-ethereum/ethclient"
1311
"github.com/scroll-tech/go-ethereum/log"
14-
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"
1512

1613
backendabi "scroll-tech/bridge-history-api/abi"
1714
"scroll-tech/bridge-history-api/internal/config"
@@ -22,17 +19,15 @@ import (
2219

2320
// L1EventParser the l1 event parser
2421
type L1EventParser struct {
25-
cfg *config.FetcherConfig
26-
client *ethclient.Client
27-
blobClient blob_client.BlobClient
22+
cfg *config.FetcherConfig
23+
client *ethclient.Client
2824
}
2925

3026
// NewL1EventParser creates l1 event parser
31-
func NewL1EventParser(cfg *config.FetcherConfig, client *ethclient.Client, blobClient blob_client.BlobClient) *L1EventParser {
27+
func NewL1EventParser(cfg *config.FetcherConfig, client *ethclient.Client) *L1EventParser {
3228
return &L1EventParser{
33-
cfg: cfg,
34-
client: client,
35-
blobClient: blobClient,
29+
cfg: cfg,
30+
client: client,
3631
}
3732
}
3833

@@ -238,7 +233,6 @@ func (e *L1EventParser) ParseL1SingleCrossChainEventLogs(ctx context.Context, lo
238233

239234
// ParseL1BatchEventLogs parses L1 watched batch events.
240235
func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.Log, client *ethclient.Client) ([]*orm.BatchEvent, error) {
241-
txBlobIndexMap := make(map[common.Hash]int)
242236
var l1BatchEvents []*orm.BatchEvent
243237
for _, vlog := range logs {
244238
switch vlog.Topics[0] {
@@ -253,37 +247,11 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.
253247
log.Error("Failed to get commit batch tx or the tx is still pending", "err", err, "isPending", isPending)
254248
return nil, err
255249
}
256-
version, startBlock, endBlock, err := utils.GetBatchRangeFromCalldata(commitTx.Data())
250+
startBlock, endBlock, err := utils.GetBatchRangeFromCalldata(commitTx.Data())
257251
if err != nil {
258252
log.Error("Failed to get batch range from calldata", "hash", commitTx.Hash().String(), "height", vlog.BlockNumber)
259253
return nil, err
260254
}
261-
if version >= 7 { // It's a batch with version >= 7.
262-
currentIndex := txBlobIndexMap[vlog.TxHash]
263-
264-
if currentIndex >= len(commitTx.BlobHashes()) {
265-
return nil, fmt.Errorf("not enough blob hashes for commit transaction: %s, index in tx: %d, total blobs: %d, batch index: %d, batch hash: %s",
266-
vlog.TxHash.String(), currentIndex, len(commitTx.BlobHashes()), event.BatchIndex.Uint64(), event.BatchHash.String())
267-
}
268-
header, err := client.HeaderByHash(ctx, vlog.BlockHash)
269-
if err != nil {
270-
return nil, fmt.Errorf("failed to get L1 block header for blob context, blockHash: %s, err: %w", vlog.BlockHash.Hex(), err)
271-
}
272-
blobVersionedHash := commitTx.BlobHashes()[currentIndex]
273-
blocks, err := e.processVersionedBlob(ctx, version, blobVersionedHash, header.Time, event.BatchIndex.Uint64())
274-
if err != nil {
275-
return nil, fmt.Errorf("failed to process versioned blob, blobVersionedHash: %s, block number: %d, blob index: %d, err: %w",
276-
blobVersionedHash.String(), vlog.BlockNumber, currentIndex, err)
277-
}
278-
if len(blocks) == 0 {
279-
return nil, fmt.Errorf("no blocks found in the blob, blobVersionedHash: %s, block number: %d, blob index: %d",
280-
blobVersionedHash.String(), vlog.BlockNumber, currentIndex)
281-
}
282-
startBlock = blocks[0].Number()
283-
endBlock = blocks[len(blocks)-1].Number()
284-
285-
txBlobIndexMap[vlog.TxHash] = currentIndex + 1
286-
}
287255
l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{
288256
BatchStatus: int(btypes.BatchStatusTypeCommitted),
289257
BatchIndex: event.BatchIndex.Uint64(),
@@ -292,8 +260,8 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.
292260
EndBlockNumber: endBlock,
293261
L1BlockNumber: vlog.BlockNumber,
294262
})
295-
case backendabi.L1RevertBatchV0EventSig:
296-
event := backendabi.L1RevertBatchV0Event{}
263+
case backendabi.L1RevertBatchEventSig:
264+
event := backendabi.L1RevertBatchEvent{}
297265
if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "RevertBatch", vlog); err != nil {
298266
log.Error("Failed to unpack RevertBatch event", "err", err)
299267
return nil, err
@@ -304,19 +272,6 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.
304272
BatchHash: event.BatchHash.String(),
305273
L1BlockNumber: vlog.BlockNumber,
306274
})
307-
case backendabi.L1RevertBatchV7EventSig:
308-
event := backendabi.L1RevertBatchV7Event{}
309-
if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "RevertBatch", vlog); err != nil {
310-
log.Error("Failed to unpack RevertBatch event", "err", err)
311-
return nil, err
312-
}
313-
for i := event.StartBatchIndex.Uint64(); i <= event.FinishBatchIndex.Uint64(); i++ {
314-
l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{
315-
BatchStatus: int(btypes.BatchStatusTypeReverted),
316-
BatchIndex: i,
317-
L1BlockNumber: vlog.BlockNumber,
318-
})
319-
}
320275
case backendabi.L1FinalizeBatchEventSig:
321276
event := backendabi.L1FinalizeBatchEvent{}
322277
if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "FinalizeBatch", vlog); err != nil {
@@ -434,32 +389,3 @@ func getRealFromAddress(ctx context.Context, eventSender common.Address, eventMe
434389
}
435390
return sender.String(), nil
436391
}
437-
438-
func (e *L1EventParser) processVersionedBlob(ctx context.Context, version uint8, versionedHash common.Hash, l1BlockTime uint64, batchIndex uint64) ([]encoding.DABlock, error) {
439-
blob, err := e.blobClient.GetBlobByVersionedHashAndBlockTime(ctx, versionedHash, l1BlockTime)
440-
if err != nil {
441-
return nil, fmt.Errorf("failed to get blob %s: %w", versionedHash.Hex(), err)
442-
}
443-
if blob == nil {
444-
return nil, fmt.Errorf("blob %s not found", versionedHash.Hex())
445-
}
446-
447-
codec, err := encoding.CodecFromVersion(encoding.CodecVersion(version))
448-
if err != nil {
449-
return nil, fmt.Errorf("unsupported codec version: %v, batch index: %v, err: %w", version, batchIndex, err)
450-
}
451-
452-
blobPayload, err := codec.DecodeBlob(blob)
453-
if err != nil {
454-
return nil, fmt.Errorf("blob %s decode error: %w", versionedHash.Hex(), err)
455-
}
456-
457-
blocks := blobPayload.Blocks()
458-
if len(blocks) == 0 {
459-
return nil, fmt.Errorf("empty blocks in blob %s", versionedHash.Hex())
460-
}
461-
462-
log.Debug("Successfully processed blob", "versionedHash", versionedHash.Hex(), "blocksCount", len(blocks), "batchIndex", batchIndex)
463-
464-
return blocks, nil
465-
}

bridge-history-api/internal/logic/l1_fetcher.go

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/scroll-tech/go-ethereum/core/types"
1212
"github.com/scroll-tech/go-ethereum/ethclient"
1313
"github.com/scroll-tech/go-ethereum/log"
14-
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"
1514
"gorm.io/gorm"
1615

1716
backendabi "scroll-tech/bridge-history-api/abi"
@@ -50,7 +49,7 @@ type L1FetcherLogic struct {
5049
}
5150

5251
// NewL1FetcherLogic creates L1 fetcher logic
53-
func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client, blobClient blob_client.BlobClient) *L1FetcherLogic {
52+
func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L1FetcherLogic {
5453
addressList := []common.Address{
5554
common.HexToAddress(cfg.StandardERC20GatewayAddr),
5655
common.HexToAddress(cfg.CustomERC20GatewayAddr),
@@ -120,10 +119,6 @@ func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient
120119
gatewayList = append(gatewayList, common.HexToAddress(cfg.WrappedTokenGatewayAddr))
121120
}
122121

123-
if common.HexToAddress(cfg.MessageQueueV2Addr) != (common.Address{}) {
124-
addressList = append(addressList, common.HexToAddress(cfg.MessageQueueV2Addr))
125-
}
126-
127122
log.Info("L1 Fetcher configured with the following address list", "addresses", addressList, "gateways", gatewayList)
128123

129124
f := &L1FetcherLogic{
@@ -134,7 +129,7 @@ func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient
134129
client: client,
135130
addressList: addressList,
136131
gatewayList: gatewayList,
137-
parser: NewL1EventParser(cfg, client, blobClient),
132+
parser: NewL1EventParser(cfg, client),
138133
}
139134

140135
reg := prometheus.DefaultRegisterer
@@ -229,7 +224,7 @@ func (f *L1FetcherLogic) l1FetcherLogs(ctx context.Context, from, to uint64) ([]
229224
Topics: make([][]common.Hash, 1),
230225
}
231226

232-
query.Topics[0] = make([]common.Hash, 17)
227+
query.Topics[0] = make([]common.Hash, 16)
233228
query.Topics[0][0] = backendabi.L1DepositETHSig
234229
query.Topics[0][1] = backendabi.L1DepositERC20Sig
235230
query.Topics[0][2] = backendabi.L1DepositERC721Sig
@@ -238,15 +233,14 @@ func (f *L1FetcherLogic) l1FetcherLogs(ctx context.Context, from, to uint64) ([]
238233
query.Topics[0][5] = backendabi.L1RelayedMessageEventSig
239234
query.Topics[0][6] = backendabi.L1FailedRelayedMessageEventSig
240235
query.Topics[0][7] = backendabi.L1CommitBatchEventSig
241-
query.Topics[0][8] = backendabi.L1RevertBatchV0EventSig
242-
query.Topics[0][9] = backendabi.L1RevertBatchV7EventSig
243-
query.Topics[0][10] = backendabi.L1FinalizeBatchEventSig
244-
query.Topics[0][11] = backendabi.L1QueueTransactionEventSig
245-
query.Topics[0][12] = backendabi.L1DequeueTransactionEventSig
246-
query.Topics[0][13] = backendabi.L1DropTransactionEventSig
247-
query.Topics[0][14] = backendabi.L1ResetDequeuedTransactionEventSig
248-
query.Topics[0][15] = backendabi.L1BridgeBatchDepositSig
249-
query.Topics[0][16] = backendabi.L1DepositWrappedTokenSig
236+
query.Topics[0][8] = backendabi.L1RevertBatchEventSig
237+
query.Topics[0][9] = backendabi.L1FinalizeBatchEventSig
238+
query.Topics[0][10] = backendabi.L1QueueTransactionEventSig
239+
query.Topics[0][11] = backendabi.L1DequeueTransactionEventSig
240+
query.Topics[0][12] = backendabi.L1DropTransactionEventSig
241+
query.Topics[0][13] = backendabi.L1ResetDequeuedTransactionEventSig
242+
query.Topics[0][14] = backendabi.L1BridgeBatchDepositSig
243+
query.Topics[0][15] = backendabi.L1DepositWrappedTokenSig
250244

251245
eventLogs, err := f.client.FilterLogs(ctx, query)
252246
if err != nil {

0 commit comments

Comments
 (0)