diff --git a/bridge-history-api/Makefile b/bridge-history-api/Makefile index 361b081f4e..2f731fa1da 100644 --- a/bridge-history-api/Makefile +++ b/bridge-history-api/Makefile @@ -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 diff --git a/bridge-history-api/abi/backend_abi.go b/bridge-history-api/abi/backend_abi.go index 6da8a8d0fa..b2ab704312 100644 --- a/bridge-history-api/abi/backend_abi.go +++ b/bridge-history-api/abi/backend_abi.go @@ -55,7 +55,8 @@ var ( L2FailedRelayedMessageEventSig common.Hash L1CommitBatchEventSig common.Hash - L1RevertBatchEventSig common.Hash + L1RevertBatchV0EventSig common.Hash + L1RevertBatchV7EventSig common.Hash L1FinalizeBatchEventSig common.Hash L1QueueTransactionEventSig common.Hash @@ -111,7 +112,8 @@ func init() { IScrollChainABI, _ = IScrollChainMetaData.GetAbi() L1CommitBatchEventSig = IScrollChainABI.Events["CommitBatch"].ID - L1RevertBatchEventSig = IScrollChainABI.Events["RevertBatch"].ID + L1RevertBatchV0EventSig = IScrollChainABI.Events["RevertBatch"].ID + L1RevertBatchV7EventSig = IScrollChainABI.Events["RevertBatch0"].ID L1FinalizeBatchEventSig = IScrollChainABI.Events["FinalizeBatch"].ID IL1MessageQueueABI, _ = IL1MessageQueueMetaData.GetAbi() @@ -163,7 +165,7 @@ var IL2ScrollMessengerMetaData = &bind.MetaData{ } var IScrollChainMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\": false,\"inputs\": [{\"indexed\": true,\"internalType\": \"uint256\",\"name\": \"batchIndex\",\"type\": \"uint256\"},{\"indexed\": true,\"internalType\": \"bytes32\",\"name\": \"batchHash\",\"type\": \"bytes32\"}],\"name\": \"CommitBatch\",\"type\": \"event\"},{\"anonymous\": false,\"inputs\": [{\"indexed\": true,\"internalType\": \"uint256\",\"name\": \"batchIndex\",\"type\": \"uint256\"},{\"indexed\": true,\"internalType\": \"bytes32\",\"name\": \"batchHash\",\"type\": \"bytes32\"},{\"indexed\": false,\"internalType\": \"bytes32\",\"name\": \"stateRoot\",\"type\": \"bytes32\"},{\"indexed\": false,\"internalType\": \"bytes32\",\"name\": \"withdrawRoot\",\"type\": \"bytes32\"}],\"name\": \"FinalizeBatch\",\"type\": \"event\"},{\"anonymous\": false,\"inputs\": [{\"indexed\": true,\"internalType\": \"uint256\",\"name\": \"batchIndex\",\"type\": \"uint256\"},{\"indexed\": true,\"internalType\": \"bytes32\",\"name\": \"batchHash\",\"type\": \"bytes32\"}],\"name\": \"RevertBatch\",\"type\": \"event\"},{\"anonymous\": false,\"inputs\": [{\"indexed\": false,\"internalType\": \"uint256\",\"name\": \"oldMaxNumTxInChunk\",\"type\": \"uint256\"},{\"indexed\": false,\"internalType\": \"uint256\",\"name\": \"newMaxNumTxInChunk\",\"type\": \"uint256\"}],\"name\": \"UpdateMaxNumTxInChunk\",\"type\": \"event\"},{\"anonymous\": false,\"inputs\": [{\"indexed\": true,\"internalType\": \"address\",\"name\": \"account\",\"type\": \"address\"},{\"indexed\": false,\"internalType\": \"bool\",\"name\": \"status\",\"type\": \"bool\"}],\"name\": \"UpdateProver\",\"type\": \"event\"},{\"anonymous\": false,\"inputs\": [{\"indexed\": true,\"internalType\": \"address\",\"name\": \"account\",\"type\": \"address\"},{\"indexed\": false,\"internalType\": \"bool\",\"name\": \"status\",\"type\": \"bool\"}],\"name\": \"UpdateSequencer\",\"type\": \"event\"},{\"inputs\": [{\"internalType\": \"uint8\",\"name\": \"version\",\"type\": \"uint8\"},{\"internalType\": \"bytes\",\"name\": \"parentBatchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes[]\",\"name\": \"chunks\",\"type\": \"bytes[]\"},{\"internalType\": \"bytes\",\"name\": \"skippedL1MessageBitmap\",\"type\": \"bytes\"}],\"name\": \"commitBatch\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"uint8\",\"name\": \"version\",\"type\": \"uint8\"},{\"internalType\": \"bytes\",\"name\": \"parentBatchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes[]\",\"name\": \"chunks\",\"type\": \"bytes[]\"},{\"internalType\": \"bytes\",\"name\": \"skippedL1MessageBitmap\",\"type\": \"bytes\"},{\"internalType\": \"bytes\",\"name\": \"blobDataProof\",\"type\": \"bytes\"}],\"name\": \"commitBatchWithBlobProof\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"uint256\",\"name\": \"batchIndex\",\"type\": \"uint256\"}],\"name\": \"committedBatches\",\"outputs\": [{\"internalType\": \"bytes32\",\"name\": \"\",\"type\": \"bytes32\"}],\"stateMutability\": \"view\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes32\",\"name\": \"prevStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"postStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"withdrawRoot\",\"type\": \"bytes32\"}],\"name\": \"finalizeBatch\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes32\",\"name\": \"prevStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"postStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"withdrawRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes\",\"name\": \"blobDataProof\",\"type\": \"bytes\"}],\"name\": \"finalizeBatch4844\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes32\",\"name\": \"prevStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"postStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"withdrawRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes\",\"name\": \"aggrProof\",\"type\": \"bytes\"}],\"name\": \"finalizeBatchWithProof\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes32\",\"name\": \"prevStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"postStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"withdrawRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes\",\"name\": \"blobDataProof\",\"type\": \"bytes\"},{\"internalType\": \"bytes\",\"name\": \"aggrProof\",\"type\": \"bytes\"}],\"name\": \"finalizeBatchWithProof4844\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes32\",\"name\": \"postStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"withdrawRoot\",\"type\": \"bytes32\"}],\"name\": \"finalizeBundle\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes32\",\"name\": \"postStateRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes32\",\"name\": \"withdrawRoot\",\"type\": \"bytes32\"},{\"internalType\": \"bytes\",\"name\": \"aggrProof\",\"type\": \"bytes\"}],\"name\": \"finalizeBundleWithProof\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"uint256\",\"name\": \"batchIndex\",\"type\": \"uint256\"}],\"name\": \"finalizedStateRoots\",\"outputs\": [{\"internalType\": \"bytes32\",\"name\": \"\",\"type\": \"bytes32\"}],\"stateMutability\": \"view\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"_batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"bytes32\",\"name\": \"_stateRoot\",\"type\": \"bytes32\"}],\"name\": \"importGenesisBatch\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"uint256\",\"name\": \"batchIndex\",\"type\": \"uint256\"}],\"name\": \"isBatchFinalized\",\"outputs\": [{\"internalType\": \"bool\",\"name\": \"\",\"type\": \"bool\"}],\"stateMutability\": \"view\",\"type\": \"function\"},{\"inputs\": [],\"name\": \"lastFinalizedBatchIndex\",\"outputs\": [{\"internalType\": \"uint256\",\"name\": \"\",\"type\": \"uint256\"}],\"stateMutability\": \"view\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"bytes\",\"name\": \"batchHeader\",\"type\": \"bytes\"},{\"internalType\": \"uint256\",\"name\": \"count\",\"type\": \"uint256\"}],\"name\": \"revertBatch\",\"outputs\": [],\"stateMutability\": \"nonpayable\",\"type\": \"function\"},{\"inputs\": [{\"internalType\": \"uint256\",\"name\": \"batchIndex\",\"type\": \"uint256\"}],\"name\": \"withdrawRoots\",\"outputs\": [{\"internalType\": \"bytes32\",\"name\": \"\",\"type\": \"bytes32\"}],\"stateMutability\": \"view\",\"type\": \"function\"}]", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"batchHash\",\"type\":\"bytes32\"}],\"name\":\"CommitBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"batchHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"}],\"name\":\"FinalizeBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"batchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"batchHash\",\"type\":\"bytes32\"}],\"name\":\"RevertBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"startBatchIndex\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"finishBatchIndex\",\"type\":\"uint256\"}],\"name\":\"RevertBatch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"enabled\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastCommittedBatchIndex\",\"type\":\"uint256\"}],\"name\":\"UpdateEnforcedBatchMode\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"parentBatchHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"totalL1MessagesPoppedOverall\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"zkProof\",\"type\":\"bytes\"}],\"internalType\":\"structScrollChainInterface.FinalizeStruct\",\"name\":\"finalizeStruct\",\"type\":\"tuple\"}],\"name\":\"commitAndFinalizeBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"parentBatchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes[]\",\"name\":\"chunks\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes\",\"name\":\"skippedL1MessageBitmap\",\"type\":\"bytes\"}],\"name\":\"commitBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"parentBatchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes[]\",\"name\":\"chunks\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes\",\"name\":\"skippedL1MessageBitmap\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"blobDataProof\",\"type\":\"bytes\"}],\"name\":\"commitBatchWithBlobProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"parentBatchHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"lastBatchHash\",\"type\":\"bytes32\"}],\"name\":\"commitBatches\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"_prevStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_withdrawRoot\",\"type\":\"bytes32\"}],\"name\":\"finalizeBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_withdrawRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"_blobDataProof\",\"type\":\"bytes\"}],\"name\":\"finalizeBatch4844\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"prevStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"aggrProof\",\"type\":\"bytes\"}],\"name\":\"finalizeBatchWithProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"prevStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"blobDataProof\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"aggrProof\",\"type\":\"bytes\"}],\"name\":\"finalizeBatchWithProof4844\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"}],\"name\":\"finalizeBundle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"totalL1MessagesPoppedOverall\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"aggrProof\",\"type\":\"bytes\"}],\"name\":\"finalizeBundlePostEuclidV2\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"totalL1MessagesPoppedOverall\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"}],\"name\":\"finalizeBundlePostEuclidV2NoProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"withdrawRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"aggrProof\",\"type\":\"bytes\"}],\"name\":\"finalizeBundleWithProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"postStateRoot\",\"type\":\"bytes32\"}],\"name\":\"finalizeEuclidInitialBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"_stateRoot\",\"type\":\"bytes32\"}],\"name\":\"importGenesisBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"revertBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"batchHeader\",\"type\":\"bytes\"}],\"name\":\"revertBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } var IL1MessageQueueMetaData = &bind.MetaData{ @@ -270,11 +272,16 @@ type L1CommitBatchEvent struct { BatchHash common.Hash } -type L1RevertBatchEvent struct { +type L1RevertBatchV0Event struct { BatchIndex *big.Int BatchHash common.Hash } +type L1RevertBatchV7Event struct { + StartBatchIndex *big.Int + FinishBatchIndex *big.Int +} + type L1FinalizeBatchEvent struct { BatchIndex *big.Int BatchHash common.Hash diff --git a/bridge-history-api/abi/backend_abi_test.go b/bridge-history-api/abi/backend_abi_test.go new file mode 100644 index 0000000000..95a3d77f09 --- /dev/null +++ b/bridge-history-api/abi/backend_abi_test.go @@ -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) +} diff --git a/bridge-history-api/cmd/fetcher/app/app.go b/bridge-history-api/cmd/fetcher/app/app.go index d055c119eb..abb11002c8 100644 --- a/bridge-history-api/cmd/fetcher/app/app.go +++ b/bridge-history-api/cmd/fetcher/app/app.go @@ -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) diff --git a/bridge-history-api/conf/config.json b/bridge-history-api/conf/config.json index 79304bfbe4..90e71e13c2 100644 --- a/bridge-history-api/conf/config.json +++ b/bridge-history-api/conf/config.json @@ -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, diff --git a/bridge-history-api/go.mod b/bridge-history-api/go.mod index 9c14c0e097..84ff9fe68e 100644 --- a/bridge-history-api/go.mod +++ b/bridge-history-api/go.mod @@ -10,7 +10,8 @@ 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.20250304112538-3c454e7101a3 + github.com/scroll-tech/da-codec v0.1.3-0.20250226072559-f8a8d3898f54 + github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950 // It's a hotfix for the header hash compatibility issue, pls change this with caution github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.25.7 golang.org/x/sync v0.11.0 @@ -90,7 +91,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 diff --git a/bridge-history-api/go.sum b/bridge-history-api/go.sum index 55e18bd187..11155638f5 100644 --- a/bridge-history-api/go.sum +++ b/bridge-history-api/go.sum @@ -311,8 +311,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/scroll-tech/da-codec v0.1.3-0.20250226072559-f8a8d3898f54 h1:qVpsVu1J91opTn6HYeuzWcBRVhQmPR8g05i+PlOjlI4= github.com/scroll-tech/da-codec v0.1.3-0.20250226072559-f8a8d3898f54/go.mod h1:xECEHZLVzbdUn+tNbRJhRIjLGTOTmnFQuTgUTeVLX58= -github.com/scroll-tech/go-ethereum v1.10.14-0.20250304112538-3c454e7101a3 h1:y0L8+O3anBJIpboVWhNlUx3VC59he+0fd4b8PnDR16w= -github.com/scroll-tech/go-ethereum v1.10.14-0.20250304112538-3c454e7101a3/go.mod h1:OblWe1+QrZwdpwO0j/LY3BSGuKT3YPUFBDQQgvvfStQ= +github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950 h1:qfOaRflvH1vtnFWloB7BveKlP/VqYgMqLJ6e9TlBJ/8= +github.com/scroll-tech/go-ethereum v1.10.14-0.20250305084331-57148478e950/go.mod h1:OblWe1+QrZwdpwO0j/LY3BSGuKT3YPUFBDQQgvvfStQ= github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE= github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= diff --git a/bridge-history-api/internal/config/config.go b/bridge-history-api/internal/config/config.go index 4b738e63b6..f6a44aa84d 100644 --- a/bridge-history-api/internal/config/config.go +++ b/bridge-history-api/internal/config/config.go @@ -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 diff --git a/bridge-history-api/internal/controller/fetcher/l1_fetcher.go b/bridge-history-api/internal/controller/fetcher/l1_fetcher.go index e718213671..8efdce1302 100644 --- a/bridge-history-api/internal/controller/fetcher/l1_fetcher.go +++ b/bridge-history-api/internal/controller/fetcher/l1_fetcher.go @@ -2,6 +2,7 @@ package fetcher import ( "context" + "fmt" "math/big" "time" @@ -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" @@ -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 @@ -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. diff --git a/bridge-history-api/internal/logic/l1_event_parser.go b/bridge-history-api/internal/logic/l1_event_parser.go index 967222e302..cca71902c1 100644 --- a/bridge-history-api/internal/logic/l1_event_parser.go +++ b/bridge-history-api/internal/logic/l1_event_parser.go @@ -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" @@ -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, } } @@ -232,7 +237,20 @@ 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 CodecV7 introduced multiple CommitBatch events per transaction, + // each CommitBatch event corresponds to an individual 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 + // - Derive the index of the current batch + // 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. + // 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] { @@ -247,11 +265,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(), @@ -260,8 +326,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 @@ -272,6 +338,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 { @@ -389,3 +468,27 @@ func getRealFromAddress(ctx context.Context, eventSender common.Address, eventMe } return sender.String(), nil } + +func (e *L1EventParser) getBatchBlockRangeFromBlob(ctx context.Context, codec encoding.Codec, versionedHash common.Hash, l1BlockTime uint64) ([]encoding.DABlock, error) { + blob, err := e.blobClient.GetBlobByVersionedHashAndBlockTime(ctx, versionedHash, l1BlockTime) + if err != nil { + return nil, fmt.Errorf("failed to get blob %s: %w", versionedHash.Hex(), err) + } + if blob == nil { + return nil, fmt.Errorf("blob %s not found", versionedHash.Hex()) + } + + blobPayload, err := codec.DecodeBlob(blob) + if err != nil { + return nil, fmt.Errorf("blob %s decode error: %w", versionedHash.Hex(), err) + } + + blocks := blobPayload.Blocks() + if len(blocks) == 0 { + return nil, fmt.Errorf("empty blocks in blob %s", versionedHash.Hex()) + } + + log.Debug("Successfully processed blob", "versionedHash", versionedHash.Hex(), "blocksCount", len(blocks)) + + return blocks, nil +} diff --git a/bridge-history-api/internal/logic/l1_fetcher.go b/bridge-history-api/internal/logic/l1_fetcher.go index 966665e6be..1312f4edf6 100644 --- a/bridge-history-api/internal/logic/l1_fetcher.go +++ b/bridge-history-api/internal/logic/l1_fetcher.go @@ -11,6 +11,7 @@ import ( "github.com/scroll-tech/go-ethereum/core/types" "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" backendabi "scroll-tech/bridge-history-api/abi" @@ -49,7 +50,7 @@ type L1FetcherLogic struct { } // NewL1FetcherLogic creates L1 fetcher logic -func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L1FetcherLogic { +func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client, blobClient blob_client.BlobClient) *L1FetcherLogic { addressList := []common.Address{ common.HexToAddress(cfg.StandardERC20GatewayAddr), common.HexToAddress(cfg.CustomERC20GatewayAddr), @@ -119,6 +120,10 @@ func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient gatewayList = append(gatewayList, common.HexToAddress(cfg.WrappedTokenGatewayAddr)) } + if common.HexToAddress(cfg.MessageQueueV2Addr) != (common.Address{}) { + addressList = append(addressList, common.HexToAddress(cfg.MessageQueueV2Addr)) + } + log.Info("L1 Fetcher configured with the following address list", "addresses", addressList, "gateways", gatewayList) f := &L1FetcherLogic{ @@ -129,7 +134,7 @@ func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient client: client, addressList: addressList, gatewayList: gatewayList, - parser: NewL1EventParser(cfg, client), + parser: NewL1EventParser(cfg, client, blobClient), } reg := prometheus.DefaultRegisterer @@ -168,14 +173,10 @@ func (f *L1FetcherLogic) getBlocksAndDetectReorg(ctx context.Context, from, to u return false, 0, lastBlockHash, blocks, nil } -func (f *L1FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, blocks []*types.Block) (map[uint64]uint64, []*orm.CrossMessage, error) { +func (f *L1FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, blocks []*types.Block) ([]*orm.CrossMessage, error) { var l1RevertedTxs []*orm.CrossMessage - blockTimestampsMap := make(map[uint64]uint64) - for i := from; i <= to; i++ { block := blocks[i-from] - blockTimestampsMap[block.NumberU64()] = block.Time() - for _, tx := range block.Transactions() { // Gateways: L1 deposit. // Messenger: L1 deposit retry (replayMessage), L1 deposit refund (dropMessage), L2 withdrawal's claim (relayMessageWithProof). @@ -187,7 +188,7 @@ func (f *L1FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, bl receipt, receiptErr := f.client.TransactionReceipt(ctx, tx.Hash()) if receiptErr != nil { log.Error("Failed to get transaction receipt", "txHash", tx.Hash().String(), "err", receiptErr) - return nil, nil, receiptErr + return nil, receiptErr } // Check if the transaction is failed @@ -199,7 +200,7 @@ func (f *L1FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, bl sender, senderErr := signer.Sender(tx) if senderErr != nil { log.Error("get sender failed", "chain id", tx.ChainId().Uint64(), "tx hash", tx.Hash().String(), "err", senderErr) - return nil, nil, senderErr + return nil, senderErr } l1RevertedTxs = append(l1RevertedTxs, &orm.CrossMessage{ @@ -213,7 +214,7 @@ func (f *L1FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, bl }) } } - return blockTimestampsMap, l1RevertedTxs, nil + return l1RevertedTxs, nil } func (f *L1FetcherLogic) l1FetcherLogs(ctx context.Context, from, to uint64) ([]types.Log, error) { @@ -224,7 +225,7 @@ func (f *L1FetcherLogic) l1FetcherLogs(ctx context.Context, from, to uint64) ([] Topics: make([][]common.Hash, 1), } - query.Topics[0] = make([]common.Hash, 16) + query.Topics[0] = make([]common.Hash, 17) query.Topics[0][0] = backendabi.L1DepositETHSig query.Topics[0][1] = backendabi.L1DepositERC20Sig query.Topics[0][2] = backendabi.L1DepositERC721Sig @@ -233,14 +234,15 @@ func (f *L1FetcherLogic) l1FetcherLogs(ctx context.Context, from, to uint64) ([] query.Topics[0][5] = backendabi.L1RelayedMessageEventSig query.Topics[0][6] = backendabi.L1FailedRelayedMessageEventSig query.Topics[0][7] = backendabi.L1CommitBatchEventSig - query.Topics[0][8] = backendabi.L1RevertBatchEventSig - query.Topics[0][9] = backendabi.L1FinalizeBatchEventSig - query.Topics[0][10] = backendabi.L1QueueTransactionEventSig - query.Topics[0][11] = backendabi.L1DequeueTransactionEventSig - query.Topics[0][12] = backendabi.L1DropTransactionEventSig - query.Topics[0][13] = backendabi.L1ResetDequeuedTransactionEventSig - query.Topics[0][14] = backendabi.L1BridgeBatchDepositSig - query.Topics[0][15] = backendabi.L1DepositWrappedTokenSig + query.Topics[0][8] = backendabi.L1RevertBatchV0EventSig + query.Topics[0][9] = backendabi.L1RevertBatchV7EventSig + query.Topics[0][10] = backendabi.L1FinalizeBatchEventSig + query.Topics[0][11] = backendabi.L1QueueTransactionEventSig + query.Topics[0][12] = backendabi.L1DequeueTransactionEventSig + query.Topics[0][13] = backendabi.L1DropTransactionEventSig + query.Topics[0][14] = backendabi.L1ResetDequeuedTransactionEventSig + query.Topics[0][15] = backendabi.L1BridgeBatchDepositSig + query.Topics[0][16] = backendabi.L1DepositWrappedTokenSig eventLogs, err := f.client.FilterLogs(ctx, query) if err != nil { @@ -264,12 +266,18 @@ func (f *L1FetcherLogic) L1Fetcher(ctx context.Context, from, to uint64, lastBlo return isReorg, reorgHeight, blockHash, nil, nil } - blockTimestampsMap, l1RevertedTxs, err := f.getRevertedTxs(ctx, from, to, blocks) + l1RevertedTxs, err := f.getRevertedTxs(ctx, from, to, blocks) if err != nil { log.Error("L1Fetcher getRevertedTxs failed", "from", from, "to", to, "error", err) return false, 0, common.Hash{}, nil, err } + // Map block number to block timestamp to avoid fetching block header multiple times to get block timestamp. + blockTimestampsMap := make(map[uint64]uint64) + for _, block := range blocks { + blockTimestampsMap[block.NumberU64()] = block.Time() + } + eventLogs, err := f.l1FetcherLogs(ctx, from, to) if err != nil { log.Error("L1Fetcher l1FetcherLogs failed", "from", from, "to", to, "error", err) @@ -282,7 +290,7 @@ func (f *L1FetcherLogic) L1Fetcher(ctx context.Context, from, to uint64, lastBlo return false, 0, common.Hash{}, nil, err } - l1BatchEvents, err := f.parser.ParseL1BatchEventLogs(ctx, eventLogs, f.client) + l1BatchEvents, err := f.parser.ParseL1BatchEventLogs(ctx, eventLogs, f.client, blockTimestampsMap) if err != nil { log.Error("failed to parse L1 batch event logs", "from", from, "to", to, "err", err) return false, 0, common.Hash{}, nil, err diff --git a/bridge-history-api/internal/orm/batch_event.go b/bridge-history-api/internal/orm/batch_event.go index 1b3bea3bbd..aaa66f4683 100644 --- a/bridge-history-api/internal/orm/batch_event.go +++ b/bridge-history-api/internal/orm/batch_event.go @@ -117,7 +117,7 @@ func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvent } case btypes.BatchStatusTypeReverted: db = db.Where("batch_index = ?", l1BatchEvent.BatchIndex) - db = db.Where("batch_hash = ?", l1BatchEvent.BatchHash) + db = db.Where("batch_status != ?", btypes.BatchStatusTypeFinalized) updateFields["batch_status"] = btypes.BatchStatusTypeReverted if err := db.Updates(updateFields).Error; err != nil { return fmt.Errorf("failed to update batch event, error: %w", err) diff --git a/bridge-history-api/internal/utils/utils.go b/bridge-history-api/internal/utils/utils.go index 09cd91c79b..2879ce7d28 100644 --- a/bridge-history-api/internal/utils/utils.go +++ b/bridge-history-api/internal/utils/utils.go @@ -66,25 +66,26 @@ func ComputeMessageHash( return common.BytesToHash(crypto.Keccak256(data)) } -// GetBatchRangeFromCalldata find the block range from calldata, both inclusive. -func GetBatchRangeFromCalldata(txData []byte) (uint64, uint64, error) { +// GetBatchVersionAndBlockRangeFromCalldata find the block range from calldata, both inclusive. +func GetBatchVersionAndBlockRangeFromCalldata(txData []byte) (uint8, uint64, uint64, error) { const methodIDLength = 4 if len(txData) < methodIDLength { - return 0, 0, fmt.Errorf("transaction data is too short, length of tx data: %v, minimum length required: %v", len(txData), methodIDLength) + return 0, 0, 0, fmt.Errorf("transaction data is too short, length of tx data: %v, minimum length required: %v", len(txData), methodIDLength) } method, err := backendabi.IScrollChainABI.MethodById(txData[:methodIDLength]) if err != nil { - return 0, 0, fmt.Errorf("failed to get method by ID, ID: %v, err: %w", txData[:methodIDLength], err) + return 0, 0, 0, fmt.Errorf("failed to get method by ID, ID: %v, err: %w", txData[:methodIDLength], err) } values, err := method.Inputs.Unpack(txData[methodIDLength:]) if err != nil { - return 0, 0, fmt.Errorf("failed to unpack transaction data using ABI, tx data: %v, err: %w", txData, err) + return 0, 0, 0, fmt.Errorf("failed to unpack transaction data using ABI, tx data: %v, err: %w", txData, err) } var chunks [][]byte + var version uint8 if method.Name == "importGenesisBatch" { - return 0, 0, nil + return 0, 0, 0, nil } else if method.Name == "commitBatch" { type commitBatchArgs struct { Version uint8 @@ -95,11 +96,11 @@ func GetBatchRangeFromCalldata(txData []byte) (uint64, uint64, error) { var args commitBatchArgs if err = method.Inputs.Copy(&args, values); err != nil { - return 0, 0, fmt.Errorf("failed to decode calldata into commitBatch args, values: %+v, err: %w", values, err) + return 0, 0, 0, fmt.Errorf("failed to decode calldata into commitBatch args, values: %+v, err: %w", values, err) } chunks = args.Chunks - + version = args.Version } else if method.Name == "commitBatchWithBlobProof" { type commitBatchWithBlobProofArgs struct { Version uint8 @@ -111,10 +112,22 @@ func GetBatchRangeFromCalldata(txData []byte) (uint64, uint64, error) { var args commitBatchWithBlobProofArgs if err = method.Inputs.Copy(&args, values); err != nil { - return 0, 0, fmt.Errorf("failed to decode calldata into commitBatchWithBlobProofArgs args, values: %+v, err: %w", values, err) + return 0, 0, 0, fmt.Errorf("failed to decode calldata into commitBatchWithBlobProofArgs args, values: %+v, err: %w", values, err) } chunks = args.Chunks + version = args.Version + } else if method.Name == "commitBatches" || method.Name == "commitAndFinalizeBatch" { + if len(values) < 3 { + return 0, 0, 0, fmt.Errorf("insufficient arguments for %s, expected 3, got %d", method.Name, len(values)) + } + + var ok bool + version, ok = values[0].(uint8) + if !ok { + return 0, 0, 0, fmt.Errorf("invalid version type: %T", values[0]) + } + return version, 0, 0, nil } var startBlock uint64 @@ -124,7 +137,7 @@ func GetBatchRangeFromCalldata(txData []byte) (uint64, uint64, error) { // | 1 byte | 60 bytes | ... | 60 bytes | // | num blocks | block 1 | ... | block n | if len(chunks) == 0 { - return 0, 0, errors.New("invalid chunks") + return 0, 0, 0, errors.New("invalid chunks") } chunk := chunks[0] block := chunk[1:61] // first block in chunk @@ -135,7 +148,36 @@ func GetBatchRangeFromCalldata(txData []byte) (uint64, uint64, error) { block = chunk[1+lastBlockIndex*60 : 1+lastBlockIndex*60+60] // last block in chunk finishBlock = binary.BigEndian.Uint64(block[0:8]) - return startBlock, finishBlock, err + return version, startBlock, finishBlock, err +} + +// GetParentBatchHashFromCalldata gets the parent batch hash from calldata. +// It only supports commitBatches and commitAndFinalizeBatch, which only accept batches >= v7. +func GetParentBatchHashFromCalldata(txData []byte) (common.Hash, error) { + const methodIDLength = 4 + if len(txData) < methodIDLength { + return common.Hash{}, fmt.Errorf("transaction data is too short, length of tx data: %v, minimum length required: %v", len(txData), methodIDLength) + } + method, err := backendabi.IScrollChainABI.MethodById(txData[:methodIDLength]) + if err != nil { + return common.Hash{}, fmt.Errorf("failed to get method by ID, ID: %v, err: %w", txData[:methodIDLength], err) + } + values, err := method.Inputs.Unpack(txData[methodIDLength:]) + if err != nil { + return common.Hash{}, fmt.Errorf("failed to unpack transaction data using ABI, tx data: %v, err: %w", txData, err) + } + + if method.Name == "commitBatches" || method.Name == "commitAndFinalizeBatch" { + if len(values) < 3 { + return common.Hash{}, fmt.Errorf("insufficient arguments for %s, expected 3, got %d", method.Name, len(values)) + } + parentBatchHash, ok := values[1].([32]byte) + if !ok { + return common.Hash{}, fmt.Errorf("invalid parentBatchHash type: %T", values[1]) + } + return common.BytesToHash(parentBatchHash[:]), nil + } + return common.Hash{}, fmt.Errorf("method %s does not support parent batch header", method.Name) } // GetBlocksInRange gets a batch of blocks for a block range [start, end] inclusive. diff --git a/bridge-history-api/internal/utils/utils_test.go b/bridge-history-api/internal/utils/utils_test.go index 83ce517aab..71092e8a62 100644 --- a/bridge-history-api/internal/utils/utils_test.go +++ b/bridge-history-api/internal/utils/utils_test.go @@ -20,28 +20,58 @@ func TestKeccak2(t *testing.T) { func TestGetBatchRangeFromCalldata(t *testing.T) { // single chunk - start, finish, err := GetBatchRangeFromCalldata(common.Hex2Bytes("1325aca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000005900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003d0100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000100000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000")) + version, start, finish, err := GetBatchVersionAndBlockRangeFromCalldata(common.Hex2Bytes("1325aca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000005900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003d0100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000100000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000")) assert.NoError(t, err) - assert.Equal(t, start, uint64(1)) - assert.Equal(t, finish, uint64(1)) + assert.Equal(t, uint8(0x0), version) + assert.Equal(t, uint64(1), start) + assert.Equal(t, uint64(1), finish) // multiple chunk - start, finish, err = GetBatchRangeFromCalldata(common.Hex2Bytes("1325aca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000003e0000000000000000000000000000000000000000000000000000000000000007900000000000000000100000000000000010000000000000001038433daac85a0b03cd443ed50bc85e832c883061651ae2182b2984751e0b340119b828c2a2798d2c957228ebeaff7e10bb099ae0d4e224f3eeb779ff61cba610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004c01000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000010000000001000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b403000000000000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000300000000000000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00050000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012c01000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa800000000000000000000000000000000000000000000000000000000000000aa")) + version, start, finish, err = GetBatchVersionAndBlockRangeFromCalldata(common.Hex2Bytes("1325aca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000003e0000000000000000000000000000000000000000000000000000000000000007900000000000000000100000000000000010000000000000001038433daac85a0b03cd443ed50bc85e832c883061651ae2182b2984751e0b340119b828c2a2798d2c957228ebeaff7e10bb099ae0d4e224f3eeb779ff61cba610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004c01000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000010000000001000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b403000000000000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000300000000000000000b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00050000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012c01000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000100000000010000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa800000000000000000000000000000000000000000000000000000000000000aa")) assert.NoError(t, err) - assert.Equal(t, start, uint64(10)) - assert.Equal(t, finish, uint64(20)) + assert.Equal(t, uint8(0x0), version) + assert.Equal(t, uint64(10), start) + assert.Equal(t, uint64(20), finish) // genesis batch - start, finish, err = GetBatchRangeFromCalldata(common.Hex2Bytes("3fdeecb200000000000000000000000000000000000000000000000000000000000000402dcb5308098d24a37fc1487a229fcedb09fa4343ede39cbad365bc925535bb09000000000000000000000000000000000000000000000000000000000000005900000000000000000000000000000000000000000000000000c252bc9780c4d83cf11f14b8cd03c92c4d18ce07710ba836d31d12da216c8330000000000000000000000000000000000000000000000000000000000000000000000000000000")) + version, start, finish, err = GetBatchVersionAndBlockRangeFromCalldata(common.Hex2Bytes("3fdeecb200000000000000000000000000000000000000000000000000000000000000402dcb5308098d24a37fc1487a229fcedb09fa4343ede39cbad365bc925535bb09000000000000000000000000000000000000000000000000000000000000005900000000000000000000000000000000000000000000000000c252bc9780c4d83cf11f14b8cd03c92c4d18ce07710ba836d31d12da216c8330000000000000000000000000000000000000000000000000000000000000000000000000000000")) assert.NoError(t, err) - assert.Equal(t, start, uint64(0)) - assert.Equal(t, finish, uint64(0)) + assert.Equal(t, uint8(0x0), version) + assert.Equal(t, uint64(0), start) + assert.Equal(t, uint64(0), finish) // commitBatchWithBlobProof batch - start, finish, err = GetBatchRangeFromCalldata(common.Hex2Bytes("86b053a9000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000010e000000000000000000000000000000000000000000000000000000000000000c10300000000000000010000000000000000000000000000000094a96eafdcaba89de89d3aab8b00a760c439fc1a4328623b5953465443d739370132d1238782d359051322a61d997a57f5b2f86d6f36c2aad4eda0118e3a213afecb4ed603fb4ec7bc10a3d879687f4f6659c4eaa894b2bdd1aafb739be031b600000000668ec25a0b3a20d1a749d0917ef837a9973e549be83321ecafc3b8388f25c5c247078e383e4b062167826f53032aa9bb0fc2a8ef610e1c4e5d0f70ee133a76b5020224a800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000054000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000006c00000000000000000000000000000000000000000000000000000000000000720000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000007e0000000000000000000000000000000000000000000000000000000000000084000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000000009c00000000000000000000000000000000000000000000000000000000000000a200000000000000000000000000000000000000000000000000000000000000a800000000000000000000000000000000000000000000000000000000000000ae00000000000000000000000000000000000000000000000000000000000000b400000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c600000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000d200000000000000000000000000000000000000000000000000000000000000d800000000000000000000000000000000000000000000000000000000000000de00000000000000000000000000000000000000000000000000000000000000e400000000000000000000000000000000000000000000000000000000000000ea0000000000000000000000000000000000000000000000000000000000000003d01000000000000002900000000668ec25d0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002a00000000668ec2600000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002b00000000668ec2630000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002c00000000668ec2660000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002d00000000668ec2690000000000000000000000000000000000000000000000000000000002e71a60000000000098968000340000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002e00000000668ec26c0000000000000000000000000000000000000000000000000000000002e71a60000000000098968000390000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002f00000000668ec26f0000000000000000000000000000000000000000000000000000000002e71a60000000000098968000370000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003000000000668ec2720000000000000000000000000000000000000000000000000000000002e71a60000000000098968000370000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003100000000668ec2750000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003200000000668ec2780000000000000000000000000000000000000000000000000000000002e71a60000000000098968000390000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003300000000668ec27b0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003400000000668ec27e0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003500000000668ec2810000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003600000000668ec2840000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003700000000668ec2870000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003800000000668ec28a0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003900000000668ec28d0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003a00000000668ec2900000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003b00000000668ec2930000000000000000000000000000000000000000000000000000000002e71a60000000000098968000410000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003c00000000668ec2960000000000000000000000000000000000000000000000000000000002e71a600000000000989680003a0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003d00000000668ec2990000000000000000000000000000000000000000000000000000000002e71a600000000000989680003f0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003e00000000668ec29c0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003f00000000668ec29f0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003a0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004000000000668ec2a20000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004100000000668ec2a50000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004200000000668ec2a80000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004300000000668ec2ab0000000000000000000000000000000000000000000000000000000002e71a60000000000098968000400000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004400000000668ec2ae0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004500000000668ec2b10000000000000000000000000000000000000000000000000000000002e71a600000000000989680003b0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004600000000668ec2b40000000000000000000000000000000000000000000000000000000002e71a600000000000989680003f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a025721923b89e95d2169ed2b0304539e726adfe8a1357ad1e0e85012ed44c430e09de2d3196138a6665cc8006c7b3be1249fe546c41f456c2067694909aff4083a605bebe5796e499aaddfeb2c34c1122a08db345702d08402e2d4eecf5444bcc00415b72b0ff537f64067fa3c5b2718aaff409b3d54c925345845ceb8d263d4e52f4003cd813c01a40e97e985d7cfc6af1e96e94dc11b812cc166e5637db5499")) + version, start, finish, err = GetBatchVersionAndBlockRangeFromCalldata(common.Hex2Bytes("86b053a9000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000010c000000000000000000000000000000000000000000000000000000000000010e000000000000000000000000000000000000000000000000000000000000000c10300000000000000010000000000000000000000000000000094a96eafdcaba89de89d3aab8b00a760c439fc1a4328623b5953465443d739370132d1238782d359051322a61d997a57f5b2f86d6f36c2aad4eda0118e3a213afecb4ed603fb4ec7bc10a3d879687f4f6659c4eaa894b2bdd1aafb739be031b600000000668ec25a0b3a20d1a749d0917ef837a9973e549be83321ecafc3b8388f25c5c247078e383e4b062167826f53032aa9bb0fc2a8ef610e1c4e5d0f70ee133a76b5020224a800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000054000000000000000000000000000000000000000000000000000000000000005a00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000006c00000000000000000000000000000000000000000000000000000000000000720000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000007e0000000000000000000000000000000000000000000000000000000000000084000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000000009c00000000000000000000000000000000000000000000000000000000000000a200000000000000000000000000000000000000000000000000000000000000a800000000000000000000000000000000000000000000000000000000000000ae00000000000000000000000000000000000000000000000000000000000000b400000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c600000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000d200000000000000000000000000000000000000000000000000000000000000d800000000000000000000000000000000000000000000000000000000000000de00000000000000000000000000000000000000000000000000000000000000e400000000000000000000000000000000000000000000000000000000000000ea0000000000000000000000000000000000000000000000000000000000000003d01000000000000002900000000668ec25d0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002a00000000668ec2600000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002b00000000668ec2630000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002c00000000668ec2660000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002d00000000668ec2690000000000000000000000000000000000000000000000000000000002e71a60000000000098968000340000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002e00000000668ec26c0000000000000000000000000000000000000000000000000000000002e71a60000000000098968000390000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000002f00000000668ec26f0000000000000000000000000000000000000000000000000000000002e71a60000000000098968000370000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003000000000668ec2720000000000000000000000000000000000000000000000000000000002e71a60000000000098968000370000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003100000000668ec2750000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003200000000668ec2780000000000000000000000000000000000000000000000000000000002e71a60000000000098968000390000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003300000000668ec27b0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003400000000668ec27e0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003500000000668ec2810000000000000000000000000000000000000000000000000000000002e71a600000000000989680003c0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003600000000668ec2840000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003700000000668ec2870000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003800000000668ec28a0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003900000000668ec28d0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003a00000000668ec2900000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003b00000000668ec2930000000000000000000000000000000000000000000000000000000002e71a60000000000098968000410000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003c00000000668ec2960000000000000000000000000000000000000000000000000000000002e71a600000000000989680003a0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003d00000000668ec2990000000000000000000000000000000000000000000000000000000002e71a600000000000989680003f0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003e00000000668ec29c0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000003f00000000668ec29f0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003a0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004000000000668ec2a20000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004100000000668ec2a50000000000000000000000000000000000000000000000000000000002e71a600000000000989680003d0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004200000000668ec2a80000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004300000000668ec2ab0000000000000000000000000000000000000000000000000000000002e71a60000000000098968000400000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004400000000668ec2ae0000000000000000000000000000000000000000000000000000000002e71a600000000000989680003e0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004500000000668ec2b10000000000000000000000000000000000000000000000000000000002e71a600000000000989680003b0000000000000000000000000000000000000000000000000000000000000000000000003d01000000000000004600000000668ec2b40000000000000000000000000000000000000000000000000000000002e71a600000000000989680003f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a025721923b89e95d2169ed2b0304539e726adfe8a1357ad1e0e85012ed44c430e09de2d3196138a6665cc8006c7b3be1249fe546c41f456c2067694909aff4083a605bebe5796e499aaddfeb2c34c1122a08db345702d08402e2d4eecf5444bcc00415b72b0ff537f64067fa3c5b2718aaff409b3d54c925345845ceb8d263d4e52f4003cd813c01a40e97e985d7cfc6af1e96e94dc11b812cc166e5637db5499")) assert.NoError(t, err) - assert.Equal(t, start, uint64(41)) - assert.Equal(t, finish, uint64(70)) + assert.Equal(t, uint8(0x3), version) + assert.Equal(t, uint64(41), start) + assert.Equal(t, uint64(70), finish) + + // commitBatches batches + version, start, finish, err = GetBatchVersionAndBlockRangeFromCalldata(common.Hex2Bytes( + "9bbaa2ba" + // Method ID + "0000000000000000000000000000000000000000000000000000000000000007" + // Version = 7 (uint8, padded to 32 bytes) + "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20" + // ParentBatchHash (bytes32) + "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", // LastBatchHash (bytes32) + )) + assert.NoError(t, err) + assert.Equal(t, uint8(7), version) + assert.Equal(t, uint64(0), start) + assert.Equal(t, uint64(0), finish) +} + +func TestGetParentBatchHeaderFromCalldata(t *testing.T) { + // commitBatches calldata + txData := common.Hex2Bytes( + "9bbaa2ba" + // Method ID + "0000000000000000000000000000000000000000000000000000000000000007" + // Version = 7 (uint8, padded to 32 bytes) + "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20" + // ParentBatchHash (bytes32) + "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", // LastBatchHash (bytes32) + ) + + parentBatchHash, err := GetParentBatchHashFromCalldata(txData) + assert.NoError(t, err) + assert.Equal(t, common.HexToHash("0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"), parentBatchHash) } // TestConvertBigIntArrayToString tests the ConvertBigIntArrayToString function diff --git a/build/dockerfiles/bridgehistoryapi-api.Dockerfile b/build/dockerfiles/bridgehistoryapi-api.Dockerfile index bca98b2c77..736e382f8a 100644 --- a/build/dockerfiles/bridgehistoryapi-api.Dockerfile +++ b/build/dockerfiles/bridgehistoryapi-api.Dockerfile @@ -1,5 +1,5 @@ # Download Go dependencies -FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base +FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as base WORKDIR /src COPY go.mod* ./ diff --git a/build/dockerfiles/bridgehistoryapi-db-cli.Dockerfile b/build/dockerfiles/bridgehistoryapi-db-cli.Dockerfile index 7d28745d85..a838a3bb7b 100644 --- a/build/dockerfiles/bridgehistoryapi-db-cli.Dockerfile +++ b/build/dockerfiles/bridgehistoryapi-db-cli.Dockerfile @@ -1,5 +1,5 @@ # Download Go dependencies -FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base +FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as base WORKDIR /src COPY ./bridge-history-api/go.* ./ diff --git a/build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile b/build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile index 203d54bba6..fc706fa504 100644 --- a/build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile +++ b/build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile @@ -1,5 +1,5 @@ # Download Go dependencies -FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base +FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as base WORKDIR /src COPY go.mod* ./ diff --git a/build/dockerfiles/coordinator-api.Dockerfile b/build/dockerfiles/coordinator-api.Dockerfile index 3d1f7660dc..3e501d65a0 100644 --- a/build/dockerfiles/coordinator-api.Dockerfile +++ b/build/dockerfiles/coordinator-api.Dockerfile @@ -1,5 +1,5 @@ # Build libzkp dependency -FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as chef +FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as chef WORKDIR app FROM chef as planner diff --git a/build/dockerfiles/coordinator-cron.Dockerfile b/build/dockerfiles/coordinator-cron.Dockerfile index d15d9e3aaa..185236f723 100644 --- a/build/dockerfiles/coordinator-cron.Dockerfile +++ b/build/dockerfiles/coordinator-cron.Dockerfile @@ -1,5 +1,5 @@ # Download Go dependencies -FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base +FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as base WORKDIR /src COPY go.work* ./ diff --git a/build/dockerfiles/db_cli.Dockerfile b/build/dockerfiles/db_cli.Dockerfile index 328a4de283..ca0f507038 100644 --- a/build/dockerfiles/db_cli.Dockerfile +++ b/build/dockerfiles/db_cli.Dockerfile @@ -1,5 +1,5 @@ # Download Go dependencies -FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base +FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as base WORKDIR /src COPY go.work* ./ diff --git a/build/dockerfiles/gas_oracle.Dockerfile b/build/dockerfiles/gas_oracle.Dockerfile index 2272a43b82..2538a40152 100644 --- a/build/dockerfiles/gas_oracle.Dockerfile +++ b/build/dockerfiles/gas_oracle.Dockerfile @@ -1,5 +1,5 @@ # Download Go dependencies -FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base +FROM scrolltech/go-rust-builder:go-1.22-rust-nightly-2023-12-03 as base WORKDIR /src COPY go.work* ./ diff --git a/common/version/version.go b/common/version/version.go index 1dc5109984..638d3f60d0 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.4.90" +var tag = "v4.4.91" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/go.work.sum b/go.work.sum index 9805523937..dddeaa03ef 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1355,6 +1355,7 @@ github.com/scroll-tech/da-codec v0.1.1-0.20241005172014-aca0bef21638 h1:2KIfClLB github.com/scroll-tech/da-codec v0.1.1-0.20241005172014-aca0bef21638/go.mod h1:6jxEQvNc7GQKMSUi25PthAUY3WnZL8CN0yWivBgAXi0= github.com/scroll-tech/da-codec v0.1.1-0.20241014152913-2703f226fb0b h1:5H6V6ybacXFJ2ti+eFwtf+12Otufod6goxK6/u7Nu1k= github.com/scroll-tech/da-codec v0.1.1-0.20241014152913-2703f226fb0b/go.mod h1:48uxaqVgpD8ulH8p+nrBtfeLHZ9tX82bVVdPNkW3rPE= +github.com/scroll-tech/da-codec v0.1.3-0.20250210041951-d028c537b995/go.mod h1:UZhhjzqYsyEhcvY0Y+SP+oMdeOUqFn/UXpbAYuPGzg0= github.com/scroll-tech/go-ethereum v1.10.14-0.20240607130425-e2becce6a1a4/go.mod h1:byf/mZ8jLYUCnUePTicjJWn+RvKdxDn7buS6glTnMwQ= github.com/scroll-tech/go-ethereum v1.10.14-0.20240821074444-b3fa00861e5e/go.mod h1:swB5NSp8pKNDuYsTxfR08bHS6L56i119PBx8fxvV8Cs= github.com/scroll-tech/go-ethereum v1.10.14-0.20241010064814-3d88e870ae22/go.mod h1:r9FwtxCtybMkTbWYCyBuevT9TW3zHmOTHqD082Uh+Oo=