Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
41606fe
support first version of CodecV6 in relayer and add functionality to …
jonastheis Dec 30, 2024
0c0c417
adjust Sender to support multiple blobs when sending a transaction
jonastheis Dec 31, 2024
78c9963
implement batch submission of multiple batches per transaction and co…
jonastheis Dec 31, 2024
940fde0
implement missing part of commit logic for CodecV6
jonastheis Dec 31, 2024
ca8d930
feat(rollup-relayer): add Euclid support
omerfirmak Jan 9, 2025
421afe9
deprecate halo2 provers, start openvm prover
omerfirmak Jan 27, 2025
b460d4a
Merge remote-tracking branch 'origin/omerfirmak/mpt' into feat/use-co…
jonastheis Jan 28, 2025
182f8e3
update go.mod to latest da-codec version V7
jonastheis Jan 28, 2025
783b965
update go.mod to latest da-codec version V7
jonastheis Feb 5, 2025
5a479c3
address review comments
jonastheis Feb 5, 2025
310abdd
add InitialL1MessageQueueHash and LastL1MessageQueueHash to chunk and…
jonastheis Feb 5, 2025
2efbbd7
add support for bundles with CodecV7
jonastheis Feb 5, 2025
e713424
update contextIDFromBatches prefix to v7
jonastheis Feb 5, 2025
f4e17bc
fix ci
jonastheis Feb 5, 2025
99c0a9f
update to latest da-codec
jonastheis Feb 10, 2025
8db5339
fix issues with chunks when handling CodecV7
jonastheis Feb 10, 2025
69a80d4
add testCommitBatchAndFinalizeBundleCodecV7 for relayer
jonastheis Feb 10, 2025
5f22950
feat(prover): euclid prover first draft
omerfirmak Feb 5, 2025
9412c7f
feat(coordinator): abstract proof types behind an interface
omerfirmak Feb 6, 2025
c3a3bad
feat(rollup-relayer): add Euclid support
omerfirmak Jan 9, 2025
2de45f0
feat(coordinator): add euclid proof types
omerfirmak Feb 6, 2025
f01af24
fix: potentially flaky testResubmitZeroGasPriceTransaction
omerfirmak Feb 7, 2025
2bd0655
feat: Add Euclid verifier
omerfirmak Feb 7, 2025
848d3a6
fix: re-enable supported forks check
omerfirmak Feb 7, 2025
e5ad9c6
feat: allow stopping fake finalization at fork boundary
omerfirmak Feb 13, 2025
b424cef
feat: add CPU prover dockerfile
omerfirmak Feb 13, 2025
ac17696
feat: update contracts to euclid version
omerfirmak Feb 13, 2025
d503d4a
fix: base64 encode VKs
omerfirmak Feb 17, 2025
bf08436
fix: prover using wrong resources for batch/bundle circuits
omerfirmak Feb 17, 2025
83c73f8
fix: coordinator ignore euclid transition chunk
omerfirmak Feb 17, 2025
d3acd6b
adjust to recent CodecV7 changes. remove initialL1MessageQueueIndex a…
jonastheis Feb 19, 2025
f13863e
Merge remote-tracking branch 'origin/omerfirmak/euclid-prover' into f…
jonastheis Feb 20, 2025
8b57dd6
fixes after merge
jonastheis Feb 20, 2025
37924b0
feat: bump zkvm-prover to rc4
omerfirmak Feb 20, 2025
fbc14ac
address review comments
jonastheis Feb 20, 2025
867fda6
fix: add batch tasks details for v6 codec
omerfirmak Feb 20, 2025
2e9827a
fix: properly propagate verifier errors
omerfirmak Feb 21, 2025
01fa3b3
feat: use verifier-only types in coordinator
omerfirmak Feb 21, 2025
50ebf17
fix: generate evm proofs for bundles
omerfirmak Feb 21, 2025
e1a0bab
add new contract ABI and adjust submission to it
jonastheis Feb 24, 2025
bb9d404
fix: force byte arrays to be marshaled as JSON arrays
omerfirmak Feb 24, 2025
0125dd6
add new contract ABI
jonastheis Feb 27, 2025
121ce09
update config and adjust to new contract ABI
jonastheis Feb 27, 2025
ed394a6
make sure that all batches committed in the same tx are part of the s…
jonastheis Feb 27, 2025
a55de1f
feat: set code tx support (#1600)
colinlyguo Feb 27, 2025
89ede0d
build rollup images with --platform=linux/amd64
jonastheis Feb 27, 2025
782e019
Merge branch 'feat/use-codec-v6' of github.com:scroll-tech/scroll int…
jonastheis Feb 27, 2025
081d289
update da-codec dependency
jonastheis Feb 27, 2025
47a6c23
fix bug where chunk and batch blocks mismatch
jonastheis Feb 28, 2025
eb5758b
feat: bump to zkvm-prover rc5
roynalnaruto Feb 28, 2025
7353f30
update l2geth version in go.mod
jonastheis Feb 28, 2025
673777f
use go 1.22 in Dockerfile builder
jonastheis Feb 28, 2025
554a233
refactor: move euclid prover to new subdir
omerfirmak Mar 4, 2025
e27ab5a
Merge remote-tracking branch 'origin/develop' into omerfirmak/euclid-…
omerfirmak Mar 4, 2025
26a49cb
Merge remote-tracking branch 'origin/omerfirmak/euclid-prover' into f…
jonastheis Mar 6, 2025
8ea4315
update go.work.sum
jonastheis Mar 6, 2025
55b32e1
add debug log message
jonastheis Mar 6, 2025
d6674e8
add configuration parameter maxChunksPerBatch for batch proposer
jonastheis Mar 6, 2025
a1c4562
add configuration parameter maxChunksPerBatch for batch proposer
jonastheis Mar 6, 2025
c8b614f
unit tests fix
Mar 6, 2025
f91c999
fix batch proposer panic
Thegaram Mar 6, 2025
82dd5e0
feat(bridge-history): support codecv7
Mar 6, 2025
4333d51
Revert "feat(bridge-history): support codecv7"
Mar 6, 2025
b30f4d0
chore(zkvm-circuit): upgrade to 0.1.0-rc.6 (#1610)
colinlyguo Mar 7, 2025
03c63a6
update batch/chunk details for phase2
omerfirmak Mar 7, 2025
9f4c9ee
fix: prover version (#1611)
yiweichi Mar 7, 2025
101cc46
update dependencies
Mar 7, 2025
a868bc1
simplify version checks
Mar 7, 2025
8b08a57
Revert "simplify version checks"
Mar 7, 2025
f1ea4b3
process task with CodecV7, add check for BlobDataProof length and add…
jonastheis Mar 8, 2025
b7e7d1a
Merge remote-tracking branch 'origin/omerfirmak/euclid-prover' into f…
jonastheis Mar 8, 2025
94bee19
feat(bridge-history): support codecv7 (#1609)
colinlyguo Mar 8, 2025
f27ddb7
remove debug line
jonastheis Mar 8, 2025
da96331
tweak comments and some renamings
Mar 9, 2025
d79aaef
fix CI
jonastheis Mar 10, 2025
ab7038c
Merge branch 'feat/use-codec-v6' of github.com:scroll-tech/scroll int…
jonastheis Mar 10, 2025
47219f2
run goimports
jonastheis Mar 10, 2025
95adcc3
fix tests
jonastheis Mar 10, 2025
224546e
add new ABI and add more tests
jonastheis Mar 10, 2025
0799dd4
fix linter
jonastheis Mar 10, 2025
7a70e37
fix test
jonastheis Mar 10, 2025
57d50b7
Merge branch 'develop' into omerfirmak/euclid-prover
omerfirmak Mar 10, 2025
20dffe4
chore: auto version bump [bot]
omerfirmak Mar 10, 2025
867307d
Merge remote-tracking branch 'origin/omerfirmak/euclid-prover' into f…
jonastheis Mar 10, 2025
c9f6e8c
Merge remote-tracking branch 'origin/develop' into feat/use-codec-v6
jonastheis Mar 10, 2025
9b462e4
go mod tidy
jonastheis Mar 10, 2025
d57e6b0
chore: auto version bump [bot]
jonastheis Mar 10, 2025
4d677b3
address review comments
jonastheis Mar 10, 2025
90d1563
Merge remote-tracking branch 'origin/develop' into feat/use-codec-v6
jonastheis Mar 10, 2025
d987931
go mod tidy
jonastheis Mar 10, 2025
38b3239
chore: auto version bump [bot]
jonastheis Mar 10, 2025
e99a851
Merge branch 'feat/use-codec-v6' of github.com:scroll-tech/scroll int…
jonastheis Mar 10, 2025
bb6ee2c
Merge branch 'develop' into feat/use-codec-v6
jonastheis Mar 10, 2025
af38122
chore: auto version bump [bot]
jonastheis Mar 10, 2025
2cc9f65
chore: auto version bump [bot]
georgehao Mar 11, 2025
eacdc78
fix(bridge-history): overwrite l2geth dependency by replace (#1617)
colinlyguo Mar 11, 2025
bee4151
fix(coordinator): prover type string (#1618)
colinlyguo Mar 11, 2025
db5206d
Merge branch 'develop' into feat/use-codec-v6
Thegaram Mar 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bridge-history-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ reset-env:
go build -o $(PWD)/build/bin/bridgehistoryapi-db-cli ./cmd/db_cli && $(PWD)/build/bin/bridgehistoryapi-db-cli reset

bridgehistoryapi-docker:
DOCKER_BUILDKIT=1 docker build -t scrolltech/bridgehistoryapi-fetcher:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile
DOCKER_BUILDKIT=1 docker build -t scrolltech/bridgehistoryapi-api:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/bridgehistoryapi-api.Dockerfile
DOCKER_BUILDKIT=1 docker build -t scrolltech/bridgehistoryapi-db-cli:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/bridgehistoryapi-db-cli.Dockerfile
DOCKER_BUILDKIT=1 docker build -t scrolltech/bridgehistoryapi-fetcher:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile --platform=linux/amd64
DOCKER_BUILDKIT=1 docker build -t scrolltech/bridgehistoryapi-api:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/bridgehistoryapi-api.Dockerfile --platform=linux/amd64
DOCKER_BUILDKIT=1 docker build -t scrolltech/bridgehistoryapi-db-cli:${IMAGE_VERSION} ${REPO_ROOT_DIR}/ -f ${REPO_ROOT_DIR}/build/dockerfiles/bridgehistoryapi-db-cli.Dockerfile --platform=linux/amd64
15 changes: 11 additions & 4 deletions bridge-history-api/abi/backend_abi.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions bridge-history-api/abi/backend_abi_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package backendabi

import (
"testing"

"github.com/scroll-tech/go-ethereum/crypto"
"github.com/stretchr/testify/assert"
)

func TestEventSignatures(t *testing.T) {
assert.Equal(t, crypto.Keccak256Hash([]byte("RevertBatch(uint256,bytes32)")), L1RevertBatchV0EventSig)
assert.Equal(t, crypto.Keccak256Hash([]byte("RevertBatch(uint256,uint256)")), L1RevertBatchV7EventSig)
}
5 changes: 4 additions & 1 deletion bridge-history-api/cmd/fetcher/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ func action(ctx *cli.Context) error {

observability.Server(ctx, db)

l1MessageFetcher := fetcher.NewL1MessageFetcher(subCtx, cfg.L1, db, l1Client)
l1MessageFetcher, err := fetcher.NewL1MessageFetcher(subCtx, cfg.L1, db, l1Client)
if err != nil {
log.Crit("failed to create L1MessageFetcher", "err", err)
}
go l1MessageFetcher.Start()

l2MessageFetcher := fetcher.NewL2MessageFetcher(subCtx, cfg.L2, db, l2Client)
Expand Down
4 changes: 3 additions & 1 deletion bridge-history-api/conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
"ScrollChainAddr": "0xa13BAF47339d63B743e7Da8741db5456DAc1E556",
"GatewayRouterAddr": "0xF8B1378579659D8F7EE5f3C929c2f3E332E41Fd6",
"MessageQueueAddr": "0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B",
"MessageQueueV2Addr": "0x0000000000000000000000000000000000000000",
"BatchBridgeGatewayAddr": "0x5Bcfd99c34cf7E06fc756f6f5aE7400504852bc4",
"GasTokenGatewayAddr": "0x0000000000000000000000000000000000000000",
"WrappedTokenGatewayAddr": "0x0000000000000000000000000000000000000000"
"WrappedTokenGatewayAddr": "0x0000000000000000000000000000000000000000",
"BlobScanAPIEndpoint": "https://api.blobscan.com/blobs/"
},
"L2": {
"confirmation": 0,
Expand Down
6 changes: 4 additions & 2 deletions bridge-history-api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ require (
github.com/go-redis/redis/v8 v8.11.5
github.com/pressly/goose/v3 v3.16.0
github.com/prometheus/client_golang v1.19.0
github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950 // It's a hotfix for the header hash incompatibility issue, pls change this with caution
github.com/scroll-tech/da-codec v0.1.3-0.20250226072559-f8a8d3898f54
github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.25.7
golang.org/x/sync v0.11.0
gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde
)

replace github.com/scroll-tech/go-ethereum => github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950 // It's a hotfix for the header hash incompatibility issue, pls change this with caution

require (
dario.cat/mergo v1.0.0 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
Expand Down Expand Up @@ -90,7 +93,6 @@ require (
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/scroll-tech/da-codec v0.1.3-0.20250226072559-f8a8d3898f54 // indirect
github.com/scroll-tech/zktrie v0.8.4 // indirect
github.com/sethvargo/go-retry v0.2.4 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand Down
5 changes: 5 additions & 0 deletions bridge-history-api/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ type FetcherConfig struct {
ScrollChainAddr string `json:"ScrollChainAddr"`
GatewayRouterAddr string `json:"GatewayRouterAddr"`
MessageQueueAddr string `json:"MessageQueueAddr"`
MessageQueueV2Addr string `json:"MessageQueueV2Addr"`
BatchBridgeGatewayAddr string `json:"BatchBridgeGatewayAddr"`
GasTokenGatewayAddr string `json:"GasTokenGatewayAddr"`
WrappedTokenGatewayAddr string `json:"WrappedTokenGatewayAddr"`

BeaconNodeAPIEndpoint string `json:"BeaconNodeAPIEndpoint"`
BlobScanAPIEndpoint string `json:"BlobScanAPIEndpoint"`
BlockNativeAPIEndpoint string `json:"BlockNativeAPIEndpoint"`
}

// RedisConfig redis config
Expand Down
27 changes: 24 additions & 3 deletions bridge-history-api/internal/controller/fetcher/l1_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fetcher

import (
"context"
"fmt"
"math/big"
"time"

Expand All @@ -10,6 +11,7 @@ import (
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/ethclient"
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"
"gorm.io/gorm"

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

// NewL1MessageFetcher creates a new L1MessageFetcher instance.
func NewL1MessageFetcher(ctx context.Context, cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L1MessageFetcher {
func NewL1MessageFetcher(ctx context.Context, cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) (*L1MessageFetcher, error) {
blobClient := blob_client.NewBlobClients()
if cfg.BeaconNodeAPIEndpoint != "" {
beaconNodeClient, err := blob_client.NewBeaconNodeClient(cfg.BeaconNodeAPIEndpoint)
if err != nil {
log.Warn("failed to create BeaconNodeClient", "err", err)
} else {
blobClient.AddBlobClient(beaconNodeClient)
}
}
if cfg.BlobScanAPIEndpoint != "" {
blobClient.AddBlobClient(blob_client.NewBlobScanClient(cfg.BlobScanAPIEndpoint))
}
if cfg.BlockNativeAPIEndpoint != "" {
blobClient.AddBlobClient(blob_client.NewBlockNativeClient(cfg.BlockNativeAPIEndpoint))
}
if blobClient.Size() == 0 {
return nil, fmt.Errorf("no blob client is configured")
}

c := &L1MessageFetcher{
ctx: ctx,
cfg: cfg,
client: client,
eventUpdateLogic: logic.NewEventUpdateLogic(db, true),
l1FetcherLogic: logic.NewL1FetcherLogic(cfg, db, client),
l1FetcherLogic: logic.NewL1FetcherLogic(cfg, db, client, blobClient),
}

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

return c
return c, nil
}

// Start starts the L1 message fetching process.
Expand Down
122 changes: 113 additions & 9 deletions bridge-history-api/internal/logic/l1_event_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ package logic

import (
"context"
"fmt"
"math/big"

"github.com/scroll-tech/da-codec/encoding"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
"github.com/scroll-tech/go-ethereum/ethclient"
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"

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

// L1EventParser the l1 event parser
type L1EventParser struct {
cfg *config.FetcherConfig
client *ethclient.Client
cfg *config.FetcherConfig
client *ethclient.Client
blobClient blob_client.BlobClient
}

// NewL1EventParser creates l1 event parser
func NewL1EventParser(cfg *config.FetcherConfig, client *ethclient.Client) *L1EventParser {
func NewL1EventParser(cfg *config.FetcherConfig, client *ethclient.Client, blobClient blob_client.BlobClient) *L1EventParser {
return &L1EventParser{
cfg: cfg,
client: client,
cfg: cfg,
client: client,
blobClient: blobClient,
}
}

Expand Down Expand Up @@ -232,7 +237,21 @@ func (e *L1EventParser) ParseL1SingleCrossChainEventLogs(ctx context.Context, lo
}

// ParseL1BatchEventLogs parses L1 watched batch events.
func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.Log, client *ethclient.Client) ([]*orm.BatchEvent, error) {
func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.Log, client *ethclient.Client, blockTimestampsMap map[uint64]uint64) ([]*orm.BatchEvent, error) {
// Since multiple CommitBatch events per transaction is introduced >= CodecV7,
// with one transaction carrying multiple blobs,
// each CommitBatch event corresponds to a blob containing block range data.
// To correctly process these events, we need to:
// 1. Parsing the associated blob data to extract the block range for each event
// 2. Tracking the parent batch hash for each processed CommitBatch event, to:
// - Validate the batch hash, since parent batch hash is needed to calculate the batch hash
// - Derive the index of the current batch by the number of parent batch hashes tracked
// In commitBatches and commitAndFinalizeBatch, the parent batch hash is passed in calldata,
// so that we can use it to get the first batch's parent batch hash, and derive the rest.
// The index map serves this purpose with:
// Key: commit transaction hash
// Value: parent batch hashes (in order) for each processed CommitBatch event in the transaction
txBlobIndexMap := make(map[common.Hash][]common.Hash)
var l1BatchEvents []*orm.BatchEvent
for _, vlog := range logs {
switch vlog.Topics[0] {
Expand All @@ -247,11 +266,59 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.
log.Error("Failed to get commit batch tx or the tx is still pending", "err", err, "isPending", isPending)
return nil, err
}
startBlock, endBlock, err := utils.GetBatchRangeFromCalldata(commitTx.Data())
version, startBlock, endBlock, err := utils.GetBatchVersionAndBlockRangeFromCalldata(commitTx.Data())
if err != nil {
log.Error("Failed to get batch range from calldata", "hash", commitTx.Hash().String(), "height", vlog.BlockNumber)
return nil, err
}
if version >= 7 { // It's a batch with version >= 7.
codec, err := encoding.CodecFromVersion(encoding.CodecVersion(version))
if err != nil {
return nil, fmt.Errorf("unsupported codec version: %v, err: %w", version, err)
}

// we append the batch hash to the slice for the current commit transaction after processing the batch.
// that means the current index of the batch within the transaction is len(txBlobIndexMap[vlog.TxHash]).
currentIndex := len(txBlobIndexMap[vlog.TxHash])
if currentIndex >= len(commitTx.BlobHashes()) {
return nil, fmt.Errorf("commit transaction %s has %d blobs, but trying to access index %d (batch index %d)",
vlog.TxHash.String(), len(commitTx.BlobHashes()), currentIndex, event.BatchIndex.Uint64())
}
blobVersionedHash := commitTx.BlobHashes()[currentIndex]

// validate the batch hash
var parentBatchHash common.Hash
if currentIndex == 0 {
parentBatchHash, err = utils.GetParentBatchHashFromCalldata(commitTx.Data())
if err != nil {
return nil, fmt.Errorf("failed to get parent batch header from calldata, tx hash: %s, err: %w", vlog.TxHash.String(), err)
}
} else {
// here we need to subtract 1 from the current index to get the parent batch hash.
parentBatchHash = txBlobIndexMap[vlog.TxHash][currentIndex-1]
}
calculatedBatch, err := codec.NewDABatchFromParams(event.BatchIndex.Uint64(), blobVersionedHash, parentBatchHash)
if err != nil {
return nil, fmt.Errorf("failed to create new DA batch from params, batch index: %d, err: %w", event.BatchIndex.Uint64(), err)
}
if calculatedBatch.Hash() != event.BatchHash {
return nil, fmt.Errorf("batch hash mismatch for batch %d, expected: %s, got: %s", event.BatchIndex, event.BatchHash.String(), calculatedBatch.Hash().String())
}

blocks, err := e.getBatchBlockRangeFromBlob(ctx, codec, blobVersionedHash, blockTimestampsMap[vlog.BlockNumber])
if err != nil {
return nil, fmt.Errorf("failed to process versioned blob, blobVersionedHash: %s, block number: %d, blob index: %d, err: %w",
blobVersionedHash.String(), vlog.BlockNumber, currentIndex, err)
}
if len(blocks) == 0 {
return nil, fmt.Errorf("no blocks found in the blob, blobVersionedHash: %s, block number: %d, blob index: %d",
blobVersionedHash.String(), vlog.BlockNumber, currentIndex)
}
startBlock = blocks[0].Number()
endBlock = blocks[len(blocks)-1].Number()

txBlobIndexMap[vlog.TxHash] = append(txBlobIndexMap[vlog.TxHash], event.BatchHash)
}
l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{
BatchStatus: int(btypes.BatchStatusTypeCommitted),
BatchIndex: event.BatchIndex.Uint64(),
Expand All @@ -260,8 +327,8 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.
EndBlockNumber: endBlock,
L1BlockNumber: vlog.BlockNumber,
})
case backendabi.L1RevertBatchEventSig:
event := backendabi.L1RevertBatchEvent{}
case backendabi.L1RevertBatchV0EventSig:
event := backendabi.L1RevertBatchV0Event{}
if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "RevertBatch", vlog); err != nil {
log.Error("Failed to unpack RevertBatch event", "err", err)
return nil, err
Expand All @@ -272,6 +339,19 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.
BatchHash: event.BatchHash.String(),
L1BlockNumber: vlog.BlockNumber,
})
case backendabi.L1RevertBatchV7EventSig:
event := backendabi.L1RevertBatchV7Event{}
if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "RevertBatch0", vlog); err != nil {
log.Error("Failed to unpack RevertBatch event", "err", err)
return nil, err
}
for i := event.StartBatchIndex.Uint64(); i <= event.FinishBatchIndex.Uint64(); i++ {
l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{
BatchStatus: int(btypes.BatchStatusTypeReverted),
BatchIndex: i,
L1BlockNumber: vlog.BlockNumber,
})
}
case backendabi.L1FinalizeBatchEventSig:
event := backendabi.L1FinalizeBatchEvent{}
if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "FinalizeBatch", vlog); err != nil {
Expand Down Expand Up @@ -389,3 +469,27 @@ func getRealFromAddress(ctx context.Context, eventSender common.Address, eventMe
}
return sender.String(), nil
}

func (e *L1EventParser) getBatchBlockRangeFromBlob(ctx context.Context, codec encoding.Codec, blobVersionedHash common.Hash, l1BlockTime uint64) ([]encoding.DABlock, error) {
blob, err := e.blobClient.GetBlobByVersionedHashAndBlockTime(ctx, blobVersionedHash, l1BlockTime)
if err != nil {
return nil, fmt.Errorf("failed to get blob %s: %w", blobVersionedHash.Hex(), err)
}
if blob == nil {
return nil, fmt.Errorf("blob %s not found", blobVersionedHash.Hex())
}

blobPayload, err := codec.DecodeBlob(blob)
if err != nil {
return nil, fmt.Errorf("blob %s decode error: %w", blobVersionedHash.Hex(), err)
}

blocks := blobPayload.Blocks()
if len(blocks) == 0 {
return nil, fmt.Errorf("empty blocks in blob %s", blobVersionedHash.Hex())
}

log.Debug("Successfully processed blob", "blobVersionedHash", blobVersionedHash.Hex(), "blocksCount", len(blocks))

return blocks, nil
}
Loading
Loading