diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c2376a9d9b..2b9b409cad 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,6 +5,9 @@ on: tags: - v** +env: + AWS_REGION: us-west-2 + jobs: event_watcher: runs-on: ubuntu-latest @@ -29,6 +32,29 @@ jobs: scrolltech/event-watcher:latest # cache-from: type=gha,scope=${{ github.workflow }} # cache-to: type=gha,scope=${{ github.workflow }} + + # build and push to aws ecr + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: event-watcher + IMAGE_TAG: ${{github.ref_name}} + run: | + # Build a docker container and push it to ECR + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker tag scrolltech/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + gas_oracle: runs-on: ubuntu-latest steps: @@ -52,6 +78,30 @@ jobs: scrolltech/gas-oracle:latest # cache-from: type=gha,scope=${{ github.workflow }} # cache-to: type=gha,scope=${{ github.workflow }} + + # build and push to aws ecr + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: gas-oracle + IMAGE_TAG: ${{github.ref_name}} + run: | + # Build a docker container and push it to ECR + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker tag scrolltech/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + rollup_relayer: runs-on: ubuntu-latest steps: @@ -75,52 +125,124 @@ jobs: scrolltech/rollup-relayer:latest # cache-from: type=gha,scope=${{ github.workflow }} # cache-to: type=gha,scope=${{ github.workflow }} + + # build and push to aws ecr + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: rollup-relayer + IMAGE_TAG: ${{github.ref_name}} + run: | + # Build a docker container and push it to ECR + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker tag scrolltech/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + bridgehistoryapi-fetcher: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push bridgehistoryapi-fetcher docker - uses: docker/build-push-action@v2 - with: - context: . - file: ./build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile - push: true - tags: | - scrolltech/bridgehistoryapi-fetcher:${{github.ref_name}} - scrolltech/bridgehistoryapi-fetcher:latest - # cache-from: type=gha,scope=${{ github.workflow }} - # cache-to: type=gha,scope=${{ github.workflow }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push bridgehistoryapi-fetcher docker + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/dockerfiles/bridgehistoryapi-fetcher.Dockerfile + push: true + tags: | + scrolltech/bridgehistoryapi-fetcher:${{github.ref_name}} + scrolltech/bridgehistoryapi-fetcher:latest + # cache-from: type=gha,scope=${{ github.workflow }} + # cache-to: type=gha,scope=${{ github.workflow }} + + # build and push to aws ecr + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: bridgehistoryapi-fetcher + IMAGE_TAG: ${{github.ref_name}} + run: | + # Build a docker container and push it to ECR + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker tag scrolltech/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + bridgehistoryapi-api: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push bridgehistoryapi-api docker - uses: docker/build-push-action@v2 - with: - context: . - file: ./build/dockerfiles/bridgehistoryapi-api.Dockerfile - push: true - tags: | - scrolltech/bridgehistoryapi-api:${{github.ref_name}} - scrolltech/bridgehistoryapi-api:latest - # cache-from: type=gha,scope=${{ github.workflow }} - # cache-to: type=gha,scope=${{ github.workflow }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push bridgehistoryapi-api docker + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/dockerfiles/bridgehistoryapi-api.Dockerfile + push: true + tags: | + scrolltech/bridgehistoryapi-api:${{github.ref_name}} + scrolltech/bridgehistoryapi-api:latest + # cache-from: type=gha,scope=${{ github.workflow }} + # cache-to: type=gha,scope=${{ github.workflow }} + + # build and push to aws ecr + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: bridgehistoryapi-api + IMAGE_TAG: ${{github.ref_name}} + run: | + # Build a docker container and push it to ECR + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker tag scrolltech/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + coordinator-api: runs-on: ubuntu-latest steps: @@ -144,6 +266,30 @@ jobs: scrolltech/coordinator-api:latest # cache-from: type=gha,scope=${{ github.workflow }} # cache-to: type=gha,scope=${{ github.workflow }} + + # build and push to aws ecr + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: coordinator-api + IMAGE_TAG: ${{github.ref_name}} + run: | + # Build a docker container and push it to ECR + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker tag scrolltech/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + coordinator-cron: runs-on: ubuntu-latest steps: @@ -167,3 +313,26 @@ jobs: scrolltech/coordinator-cron:latest # cache-from: type=gha,scope=${{ github.workflow }} # cache-to: type=gha,scope=${{ github.workflow }} + + # build and push to aws ecr + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: coordinator-cron + IMAGE_TAG: ${{github.ref_name}} + run: | + # Build a docker container and push it to ECR + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker tag scrolltech/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG diff --git a/bridge-history-api/conf/config.json b/bridge-history-api/conf/config.json index f93044d48e..bcbf6384f2 100644 --- a/bridge-history-api/conf/config.json +++ b/bridge-history-api/conf/config.json @@ -3,8 +3,8 @@ "confirmation": 0, "endpoint": "https://rpc.ankr.com/eth", "startHeight": 18306000, - "blockTime": 10, - "fetchLimit": 30, + "blockTime": 12, + "fetchLimit": 16, "MessengerAddr": "0x6774Bcbd5ceCeF1336b5300fb5186a12DDD8b367", "ETHGatewayAddr": "0x7F2b8C31F88B6006c382775eea88297Ec1e3E905", "WETHGatewayAddr": "0x7AC440cAe8EB6328de4fA621163a792c1EA9D4fE", @@ -23,7 +23,7 @@ "confirmation": 0, "endpoint": "https://rpc.scroll.io", "blockTime": 3, - "fetchLimit": 100, + "fetchLimit": 64, "MessengerAddr": "0x781e90f1c8Fc4611c9b7497C3B47F99Ef6969CbC", "ETHGatewayAddr": "0x6EA73e05AdC79974B931123675ea8F78FfdacDF0", "WETHGatewayAddr": "0x7003E7B7186f0E6601203b99F7B8DECBfA391cf9", diff --git a/bridge-history-api/go.mod b/bridge-history-api/go.mod index b026dd2f1f..15951c2ed3 100644 --- a/bridge-history-api/go.mod +++ b/bridge-history-api/go.mod @@ -6,7 +6,6 @@ require ( github.com/gin-contrib/cors v1.5.0 github.com/gin-gonic/gin v1.9.1 github.com/go-redis/redis/v8 v8.11.5 - github.com/google/uuid v1.4.0 github.com/pressly/goose/v3 v3.16.0 github.com/prometheus/client_golang v1.14.0 github.com/scroll-tech/go-ethereum v1.10.14-0.20231130005111-38a3a9c9198c @@ -40,6 +39,7 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.4.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/holiman/uint256 v1.2.4 // indirect github.com/huin/goupnp v1.3.0 // indirect diff --git a/bridge-history-api/internal/config/config.go b/bridge-history-api/internal/config/config.go index 4b932c29e2..d52a112ba4 100644 --- a/bridge-history-api/internal/config/config.go +++ b/bridge-history-api/internal/config/config.go @@ -8,11 +8,11 @@ import ( "scroll-tech/common/database" ) -// LayerConfig is the configuration of Layer1/Layer2 -type LayerConfig struct { +// FetcherConfig is the configuration of Layer1 or Layer2 fetcher. +type FetcherConfig struct { Confirmation uint64 `json:"confirmation"` Endpoint string `json:"endpoint"` - StartHeight uint64 `json:"startHeight"` // Can only be configured to contract deployment height, otherwise in the current implementation, the message proof could not be successfully updated. + StartHeight uint64 `json:"startHeight"` // Can only be configured to contract deployment height, message proof should be updated from the very beginning. BlockTime int64 `json:"blockTime"` FetchLimit uint64 `json:"fetchLimit"` MessengerAddr string `json:"MessengerAddr"` @@ -43,8 +43,8 @@ type RedisConfig struct { // Config is the configuration of the bridge history backend type Config struct { - L1 *LayerConfig `json:"L1"` - L2 *LayerConfig `json:"L2"` + L1 *FetcherConfig `json:"L1"` + L2 *FetcherConfig `json:"L2"` DB *database.Config `json:"db"` Redis *RedisConfig `json:"redis"` } diff --git a/bridge-history-api/internal/controller/fetcher/l1_fetcher.go b/bridge-history-api/internal/controller/fetcher/l1_fetcher.go index 9d1125270a..bc92e1147b 100644 --- a/bridge-history-api/internal/controller/fetcher/l1_fetcher.go +++ b/bridge-history-api/internal/controller/fetcher/l1_fetcher.go @@ -20,7 +20,7 @@ import ( // L1MessageFetcher fetches cross message events from L1 and saves them to database. type L1MessageFetcher struct { ctx context.Context - cfg *config.LayerConfig + cfg *config.FetcherConfig client *ethclient.Client l1SyncHeight uint64 @@ -35,7 +35,7 @@ type L1MessageFetcher struct { } // NewL1MessageFetcher creates a new L1MessageFetcher instance. -func NewL1MessageFetcher(ctx context.Context, cfg *config.LayerConfig, db *gorm.DB, client *ethclient.Client) *L1MessageFetcher { +func NewL1MessageFetcher(ctx context.Context, cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L1MessageFetcher { c := &L1MessageFetcher{ ctx: ctx, cfg: cfg, @@ -108,7 +108,6 @@ func (c *L1MessageFetcher) Start() { } func (c *L1MessageFetcher) fetchAndSaveEvents(confirmation uint64) { - c.l1MessageFetcherRunningTotal.Inc() startHeight := c.l1SyncHeight + 1 endHeight, rpcErr := utils.GetBlockNumber(c.ctx, c.client, confirmation) if rpcErr != nil { @@ -134,6 +133,7 @@ func (c *L1MessageFetcher) fetchAndSaveEvents(confirmation uint64) { c.l1MessageFetcherReorgTotal.Inc() log.Warn("L1 reorg happened, exit and re-enter fetchAndSaveEvents", "re-sync height", resyncHeight) c.updateL1SyncHeight(resyncHeight, lastBlockHash) + c.l1MessageFetcherRunningTotal.Inc() return } @@ -143,6 +143,7 @@ func (c *L1MessageFetcher) fetchAndSaveEvents(confirmation uint64) { } c.updateL1SyncHeight(to, lastBlockHash) + c.l1MessageFetcherRunningTotal.Inc() } } diff --git a/bridge-history-api/internal/controller/fetcher/l2_fetcher.go b/bridge-history-api/internal/controller/fetcher/l2_fetcher.go index 9a488f131f..1497ee2c73 100644 --- a/bridge-history-api/internal/controller/fetcher/l2_fetcher.go +++ b/bridge-history-api/internal/controller/fetcher/l2_fetcher.go @@ -20,7 +20,7 @@ import ( // L2MessageFetcher fetches cross message events from L2 and saves them to database. type L2MessageFetcher struct { ctx context.Context - cfg *config.LayerConfig + cfg *config.FetcherConfig db *gorm.DB client *ethclient.Client l2SyncHeight uint64 @@ -35,7 +35,7 @@ type L2MessageFetcher struct { } // NewL2MessageFetcher creates a new L2MessageFetcher instance. -func NewL2MessageFetcher(ctx context.Context, cfg *config.LayerConfig, db *gorm.DB, client *ethclient.Client) *L2MessageFetcher { +func NewL2MessageFetcher(ctx context.Context, cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L2MessageFetcher { c := &L2MessageFetcher{ ctx: ctx, cfg: cfg, @@ -110,7 +110,6 @@ func (c *L2MessageFetcher) fetchAndSaveEvents(confirmation uint64) { return } log.Info("fetch and save missing L2 events", "start height", startHeight, "end height", endHeight, "confirmation", confirmation) - c.l2MessageFetcherRunningTotal.Inc() for from := startHeight; from <= endHeight; from += c.cfg.FetchLimit { to := from + c.cfg.FetchLimit - 1 @@ -128,6 +127,7 @@ func (c *L2MessageFetcher) fetchAndSaveEvents(confirmation uint64) { c.l2MessageFetcherReorgTotal.Inc() log.Warn("L2 reorg happened, exit and re-enter fetchAndSaveEvents", "re-sync height", resyncHeight) c.updateL2SyncHeight(resyncHeight, lastBlockHash) + c.l2MessageFetcherRunningTotal.Inc() return } @@ -142,6 +142,7 @@ func (c *L2MessageFetcher) fetchAndSaveEvents(confirmation uint64) { } c.updateL2SyncHeight(to, lastBlockHash) + c.l2MessageFetcherRunningTotal.Inc() } } diff --git a/bridge-history-api/internal/logic/event_update.go b/bridge-history-api/internal/logic/event_update.go index 2ec430a938..a5229feda9 100644 --- a/bridge-history-api/internal/logic/event_update.go +++ b/bridge-history-api/internal/logic/event_update.go @@ -76,39 +76,30 @@ func (b *EventUpdateLogic) GetL2MessageSyncedHeightInDB(ctx context.Context) (ui // L1InsertOrUpdate inserts or updates l1 messages func (b *EventUpdateLogic) L1InsertOrUpdate(ctx context.Context, l1FetcherResult *L1FilterResult) error { - err := b.db.Transaction(func(tx *gorm.DB) error { - if txErr := b.crossMessageOrm.InsertOrUpdateL1Messages(ctx, l1FetcherResult.DepositMessages, tx); txErr != nil { - log.Error("failed to insert L1 deposit messages", "err", txErr) - return txErr - } - - if txErr := b.crossMessageOrm.InsertOrUpdateL1RelayedMessagesOfL2Withdrawals(ctx, l1FetcherResult.RelayedMessages, tx); txErr != nil { - log.Error("failed to update L1 relayed messages of L2 withdrawals", "err", txErr) - return txErr - } - - if txErr := b.batchEventOrm.InsertOrUpdateBatchEvents(ctx, l1FetcherResult.BatchEvents, tx); txErr != nil { - log.Error("failed to insert or update batch events", "err", txErr) - return txErr - } + if err := b.crossMessageOrm.InsertOrUpdateL1Messages(ctx, l1FetcherResult.DepositMessages); err != nil { + log.Error("failed to insert L1 deposit messages", "err", err) + return err + } - if txErr := b.crossMessageOrm.UpdateL1MessageQueueEventsInfo(ctx, l1FetcherResult.MessageQueueEvents, tx); txErr != nil { - log.Error("failed to insert L1 message queue events", "err", txErr) - return txErr - } + if err := b.crossMessageOrm.InsertOrUpdateL1RelayedMessagesOfL2Withdrawals(ctx, l1FetcherResult.RelayedMessages); err != nil { + log.Error("failed to update L1 relayed messages of L2 withdrawals", "err", err) + return err + } - if txErr := b.crossMessageOrm.InsertFailedGatewayRouterTxs(ctx, l1FetcherResult.RevertedTxs, tx); txErr != nil { - log.Error("failed to insert L1 failed gateway router transactions", "err", txErr) - return txErr - } - return nil - }) + if err := b.batchEventOrm.InsertOrUpdateBatchEvents(ctx, l1FetcherResult.BatchEvents); err != nil { + log.Error("failed to insert or update batch events", "err", err) + return err + } - if err != nil { - log.Error("failed to update db of L1 events", "err", err) + if err := b.crossMessageOrm.UpdateL1MessageQueueEventsInfo(ctx, l1FetcherResult.MessageQueueEvents); err != nil { + log.Error("failed to insert L1 message queue events", "err", err) return err } + if err := b.crossMessageOrm.InsertFailedL1GatewayTxs(ctx, l1FetcherResult.RevertedTxs); err != nil { + log.Error("failed to insert failed L1 gateway transactions", "err", err) + return err + } return nil } @@ -186,24 +177,18 @@ func (b *EventUpdateLogic) UpdateL1BatchIndexAndStatus(ctx context.Context, heig // L2InsertOrUpdate inserts or updates L2 messages func (b *EventUpdateLogic) L2InsertOrUpdate(ctx context.Context, l2FetcherResult *L2FilterResult) error { - err := b.db.Transaction(func(tx *gorm.DB) error { - if txErr := b.crossMessageOrm.InsertOrUpdateL2Messages(ctx, l2FetcherResult.WithdrawMessages, tx); txErr != nil { - log.Error("failed to insert L2 withdrawal messages", "err", txErr) - return txErr - } - if txErr := b.crossMessageOrm.InsertOrUpdateL2RelayedMessagesOfL1Deposits(ctx, l2FetcherResult.RelayedMessages, tx); txErr != nil { - log.Error("failed to update L2 relayed messages of L1 deposits", "err", txErr) - return txErr - } - if txErr := b.crossMessageOrm.InsertFailedGatewayRouterTxs(ctx, l2FetcherResult.OtherRevertedTxs, tx); txErr != nil { - log.Error("failed to insert L2 failed gateway router transactions", "err", txErr) - return txErr - } - return nil - }) + if err := b.crossMessageOrm.InsertOrUpdateL2Messages(ctx, l2FetcherResult.WithdrawMessages); err != nil { + log.Error("failed to insert L2 withdrawal messages", "err", err) + return err + } - if err != nil { - log.Error("failed to update db of L2 events", "err", err) + if err := b.crossMessageOrm.InsertOrUpdateL2RelayedMessagesOfL1Deposits(ctx, l2FetcherResult.RelayedMessages); err != nil { + log.Error("failed to update L2 relayed messages of L1 deposits", "err", err) + return err + } + + if err := b.crossMessageOrm.InsertFailedL2GatewayTxs(ctx, l2FetcherResult.OtherRevertedTxs); err != nil { + log.Error("failed to insert failed L2 gateway transactions", "err", err) return err } return nil diff --git a/bridge-history-api/internal/logic/l1_event_parser.go b/bridge-history-api/internal/logic/l1_event_parser.go index bf5dd1779c..5919176200 100644 --- a/bridge-history-api/internal/logic/l1_event_parser.go +++ b/bridge-history-api/internal/logic/l1_event_parser.go @@ -2,6 +2,7 @@ package logic import ( "context" + "math/big" "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/core/types" @@ -10,21 +11,27 @@ import ( "github.com/scroll-tech/go-ethereum/log" backendabi "scroll-tech/bridge-history-api/abi" + "scroll-tech/bridge-history-api/internal/config" "scroll-tech/bridge-history-api/internal/orm" "scroll-tech/bridge-history-api/internal/utils" ) // L1EventParser the l1 event parser type L1EventParser struct { + cfg *config.FetcherConfig + client *ethclient.Client } // NewL1EventParser creates l1 event parser -func NewL1EventParser() *L1EventParser { - return &L1EventParser{} +func NewL1EventParser(cfg *config.FetcherConfig, client *ethclient.Client) *L1EventParser { + return &L1EventParser{ + cfg: cfg, + client: client, + } } // ParseL1CrossChainEventLogs parses L1 watched cross chain events. -func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimestampsMap map[uint64]uint64) ([]*orm.CrossMessage, []*orm.CrossMessage, error) { +func (e *L1EventParser) ParseL1CrossChainEventLogs(ctx context.Context, logs []types.Log, blockTimestampsMap map[uint64]uint64) ([]*orm.CrossMessage, []*orm.CrossMessage, error) { var l1DepositMessages []*orm.CrossMessage var l1RelayedMessages []*orm.CrossMessage for _, vlog := range logs { @@ -32,7 +39,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1DepositETHSig: event := backendabi.ETHMessageEvent{} if err := utils.UnpackLog(backendabi.IL1ETHGatewayABI, &event, "DepositETH", vlog); err != nil { - log.Warn("Failed to unpack DepositETH event", "err", err) + log.Error("Failed to unpack DepositETH event", "err", err) return nil, nil, err } lastMessage := l1DepositMessages[len(l1DepositMessages)-1] @@ -44,7 +51,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest event := backendabi.ERC20MessageEvent{} err := utils.UnpackLog(backendabi.IL1ERC20GatewayABI, &event, "DepositERC20", vlog) if err != nil { - log.Warn("Failed to unpack DepositERC20 event", "err", err) + log.Error("Failed to unpack DepositERC20 event", "err", err) return nil, nil, err } lastMessage := l1DepositMessages[len(l1DepositMessages)-1] @@ -57,7 +64,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1DepositERC721Sig: event := backendabi.ERC721MessageEvent{} if err := utils.UnpackLog(backendabi.IL1ERC721GatewayABI, &event, "DepositERC721", vlog); err != nil { - log.Warn("Failed to unpack DepositERC721 event", "err", err) + log.Error("Failed to unpack DepositERC721 event", "err", err) return nil, nil, err } lastMessage := l1DepositMessages[len(l1DepositMessages)-1] @@ -70,7 +77,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1BatchDepositERC721Sig: event := backendabi.BatchERC721MessageEvent{} if err := utils.UnpackLog(backendabi.IL1ERC721GatewayABI, &event, "BatchDepositERC721", vlog); err != nil { - log.Warn("Failed to unpack BatchDepositERC721 event", "err", err) + log.Error("Failed to unpack BatchDepositERC721 event", "err", err) return nil, nil, err } lastMessage := l1DepositMessages[len(l1DepositMessages)-1] @@ -83,7 +90,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1DepositERC1155Sig: event := backendabi.ERC1155MessageEvent{} if err := utils.UnpackLog(backendabi.IL1ERC1155GatewayABI, &event, "DepositERC1155", vlog); err != nil { - log.Warn("Failed to unpack DepositERC1155 event", "err", err) + log.Error("Failed to unpack DepositERC1155 event", "err", err) return nil, nil, err } lastMessage := l1DepositMessages[len(l1DepositMessages)-1] @@ -97,7 +104,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1BatchDepositERC1155Sig: event := backendabi.BatchERC1155MessageEvent{} if err := utils.UnpackLog(backendabi.IL1ERC1155GatewayABI, &event, "BatchDepositERC1155", vlog); err != nil { - log.Warn("Failed to unpack BatchDepositERC1155 event", "err", err) + log.Error("Failed to unpack BatchDepositERC1155 event", "err", err) return nil, nil, err } lastMessage := l1DepositMessages[len(l1DepositMessages)-1] @@ -111,12 +118,17 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1SentMessageEventSig: event := backendabi.L1SentMessageEvent{} if err := utils.UnpackLog(backendabi.IL1ScrollMessengerABI, &event, "SentMessage", vlog); err != nil { - log.Warn("Failed to unpack SentMessage event", "err", err) + log.Error("Failed to unpack SentMessage event", "err", err) + return nil, nil, err + } + from, err := getRealFromAddress(ctx, event.Sender, e.client, vlog.TxHash, e.cfg.GatewayRouterAddr) + if err != nil { + log.Error("Failed to get real 'from' address", "err", err) return nil, nil, err } l1DepositMessages = append(l1DepositMessages, &orm.CrossMessage{ L1BlockNumber: vlog.BlockNumber, - Sender: event.Sender.String(), + Sender: from, Receiver: event.Target.String(), TokenType: int(orm.TokenTypeETH), L1TxHash: vlog.TxHash.String(), @@ -130,7 +142,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1RelayedMessageEventSig: event := backendabi.L1RelayedMessageEvent{} if err := utils.UnpackLog(backendabi.IL1ScrollMessengerABI, &event, "RelayedMessage", vlog); err != nil { - log.Warn("Failed to unpack RelayedMessage event", "err", err) + log.Error("Failed to unpack RelayedMessage event", "err", err) return nil, nil, err } l1RelayedMessages = append(l1RelayedMessages, &orm.CrossMessage{ @@ -143,7 +155,7 @@ func (e *L1EventParser) ParseL1CrossChainEventLogs(logs []types.Log, blockTimest case backendabi.L1FailedRelayedMessageEventSig: event := backendabi.L1FailedRelayedMessageEvent{} if err := utils.UnpackLog(backendabi.IL1ScrollMessengerABI, &event, "FailedRelayedMessage", vlog); err != nil { - log.Warn("Failed to unpack FailedRelayedMessage event", "err", err) + log.Error("Failed to unpack FailedRelayedMessage event", "err", err) return nil, nil, err } l1RelayedMessages = append(l1RelayedMessages, &orm.CrossMessage{ @@ -166,17 +178,17 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types. case backendabi.L1CommitBatchEventSig: event := backendabi.L1CommitBatchEvent{} if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "CommitBatch", vlog); err != nil { - log.Warn("Failed to unpack CommitBatch event", "err", err) + log.Error("Failed to unpack CommitBatch event", "err", err) return nil, err } commitTx, isPending, err := client.TransactionByHash(ctx, vlog.TxHash) if err != nil || isPending { - log.Warn("Failed to get commit Batch tx receipt or the tx is still pending", "err", err) + 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()) if err != nil { - log.Warn("Failed to get batch range from calldata", "hash", commitTx.Hash().String(), "height", vlog.BlockNumber) + log.Error("Failed to get batch range from calldata", "hash", commitTx.Hash().String(), "height", vlog.BlockNumber) return nil, err } l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{ @@ -190,7 +202,7 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types. case backendabi.L1RevertBatchEventSig: event := backendabi.L1RevertBatchEvent{} if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "RevertBatch", vlog); err != nil { - log.Warn("Failed to unpack RevertBatch event", "err", err) + log.Error("Failed to unpack RevertBatch event", "err", err) return nil, err } l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{ @@ -202,7 +214,7 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types. case backendabi.L1FinalizeBatchEventSig: event := backendabi.L1FinalizeBatchEvent{} if err := utils.UnpackLog(backendabi.IScrollChainABI, &event, "FinalizeBatch", vlog); err != nil { - log.Warn("Failed to unpack FinalizeBatch event", "err", err) + log.Error("Failed to unpack FinalizeBatch event", "err", err) return nil, err } l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{ @@ -229,7 +241,7 @@ func (e *L1EventParser) ParseL1MessageQueueEventLogs(logs []types.Log, l1Deposit case backendabi.L1QueueTransactionEventSig: event := backendabi.L1QueueTransactionEvent{} if err := utils.UnpackLog(backendabi.IL1MessageQueueABI, &event, "QueueTransaction", vlog); err != nil { - log.Warn("Failed to unpack QueueTransaction event", "err", err) + log.Error("Failed to unpack QueueTransaction event", "err", err) return nil, err } messageHash := common.BytesToHash(crypto.Keccak256(event.Data)) @@ -245,7 +257,7 @@ func (e *L1EventParser) ParseL1MessageQueueEventLogs(logs []types.Log, l1Deposit case backendabi.L1DequeueTransactionEventSig: event := backendabi.L1DequeueTransactionEvent{} if err := utils.UnpackLog(backendabi.IL1MessageQueueABI, &event, "DequeueTransaction", vlog); err != nil { - log.Warn("Failed to unpack DequeueTransaction event", "err", err) + log.Error("Failed to unpack DequeueTransaction event", "err", err) return nil, err } skippedIndices := utils.GetSkippedQueueIndices(event.StartIndex.Uint64(), event.SkippedBitmap) @@ -258,7 +270,7 @@ func (e *L1EventParser) ParseL1MessageQueueEventLogs(logs []types.Log, l1Deposit case backendabi.L1DropTransactionEventSig: event := backendabi.L1DropTransactionEvent{} if err := utils.UnpackLog(backendabi.IL1MessageQueueABI, &event, "DropTransaction", vlog); err != nil { - log.Warn("Failed to unpack DropTransaction event", "err", err) + log.Error("Failed to unpack DropTransaction event", "err", err) return nil, err } l1MessageQueueEvents = append(l1MessageQueueEvents, &orm.MessageQueueEvent{ @@ -270,3 +282,27 @@ func (e *L1EventParser) ParseL1MessageQueueEventLogs(logs []types.Log, l1Deposit } return l1MessageQueueEvents, nil } + +func getRealFromAddress(ctx context.Context, eventSender common.Address, client *ethclient.Client, txHash common.Hash, gatewayRouterAddr string) (string, error) { + from := eventSender.String() + if from == gatewayRouterAddr { + tx, isPending, rpcErr := client.TransactionByHash(ctx, txHash) + if rpcErr != nil || isPending { + log.Error("Failed to get transaction or the transaction is still pending", "rpcErr", rpcErr, "isPending", isPending) + return "", rpcErr + } + // Case 1: deposit/withdraw ETH: EOA -> multisig -> gateway router -> messenger. + if tx.To() != nil && (*tx.To()).String() != gatewayRouterAddr { + return (*tx.To()).String(), nil + } + // Case 2: deposit/withdraw ETH: EOA -> gateway router -> messenger. + signer := types.LatestSignerForChainID(new(big.Int).SetUint64(tx.ChainId().Uint64())) + sender, err := signer.Sender(tx) + if err != nil { + log.Error("Get sender failed", "chain id", tx.ChainId().Uint64(), "tx hash", tx.Hash().String(), "err", err) + return "", err + } + return sender.String(), nil + } + return from, nil +} diff --git a/bridge-history-api/internal/logic/l1_fetcher.go b/bridge-history-api/internal/logic/l1_fetcher.go index 49e297002f..d9e42a48df 100644 --- a/bridge-history-api/internal/logic/l1_fetcher.go +++ b/bridge-history-api/internal/logic/l1_fetcher.go @@ -34,9 +34,10 @@ type L1FilterResult struct { // L1FetcherLogic the L1 fetcher logic type L1FetcherLogic struct { - cfg *config.LayerConfig + cfg *config.FetcherConfig client *ethclient.Client addressList []common.Address + gatewayList []common.Address parser *L1EventParser db *gorm.DB crossMessageOrm *orm.CrossMessage @@ -46,7 +47,7 @@ type L1FetcherLogic struct { } // NewL1FetcherLogic creates L1 fetcher logic -func NewL1FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.Client) *L1FetcherLogic { +func NewL1FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L1FetcherLogic { addressList := []common.Address{ common.HexToAddress(cfg.ETHGatewayAddr), @@ -65,16 +66,34 @@ func NewL1FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.C common.HexToAddress(cfg.MessageQueueAddr), } + gatewayList := []common.Address{ + common.HexToAddress(cfg.ETHGatewayAddr), + + common.HexToAddress(cfg.StandardERC20GatewayAddr), + common.HexToAddress(cfg.CustomERC20GatewayAddr), + common.HexToAddress(cfg.WETHGatewayAddr), + common.HexToAddress(cfg.DAIGatewayAddr), + + common.HexToAddress(cfg.ERC721GatewayAddr), + common.HexToAddress(cfg.ERC1155GatewayAddr), + + common.HexToAddress(cfg.MessengerAddr), + + common.HexToAddress(cfg.GatewayRouterAddr), + } + // Optional erc20 gateways. if common.HexToAddress(cfg.USDCGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.USDCGatewayAddr)) + gatewayList = append(gatewayList, common.HexToAddress(cfg.USDCGatewayAddr)) } if common.HexToAddress(cfg.LIDOGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.LIDOGatewayAddr)) + gatewayList = append(gatewayList, common.HexToAddress(cfg.LIDOGatewayAddr)) } - log.Info("L1 Fetcher configured with the following address list", "addresses", addressList) + log.Info("L1 Fetcher configured with the following address list", "addresses", addressList, "gateways", gatewayList) f := &L1FetcherLogic{ db: db, @@ -83,7 +102,8 @@ func NewL1FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.C cfg: cfg, client: client, addressList: addressList, - parser: NewL1EventParser(), + gatewayList: gatewayList, + parser: NewL1EventParser(cfg, client), } reg := prometheus.DefaultRegisterer @@ -131,15 +151,9 @@ func (f *L1FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, bl blockTimestampsMap[block.NumberU64()] = block.Time() for _, tx := range block.Transactions() { - txTo := tx.To() - if txTo == nil { - continue - } - toAddress := txTo.String() - - // GatewayRouter: L1 deposit. + // Gateways: L1 deposit. // Messenger: L1 deposit retry (replayMessage), L1 deposit refund (dropMessage), L2 withdrawal's claim (relayMessageWithProof). - if toAddress != f.cfg.GatewayRouterAddr && toAddress != f.cfg.MessengerAddr { + if !isTransactionToGateway(tx, f.gatewayList) { continue } @@ -233,7 +247,7 @@ func (f *L1FetcherLogic) L1Fetcher(ctx context.Context, from, to uint64, lastBlo return false, 0, common.Hash{}, nil, err } - l1DepositMessages, l1RelayedMessages, err := f.parser.ParseL1CrossChainEventLogs(eventLogs, blockTimestampsMap) + l1DepositMessages, l1RelayedMessages, err := f.parser.ParseL1CrossChainEventLogs(ctx, eventLogs, blockTimestampsMap) if err != nil { log.Error("failed to parse L1 cross chain event logs", "from", from, "to", to, "err", err) return false, 0, common.Hash{}, nil, err diff --git a/bridge-history-api/internal/logic/l2_event_parser.go b/bridge-history-api/internal/logic/l2_event_parser.go index 20df49d13c..69e44a11db 100644 --- a/bridge-history-api/internal/logic/l2_event_parser.go +++ b/bridge-history-api/internal/logic/l2_event_parser.go @@ -1,26 +1,35 @@ package logic import ( + "context" + "github.com/scroll-tech/go-ethereum/common/hexutil" "github.com/scroll-tech/go-ethereum/core/types" + "github.com/scroll-tech/go-ethereum/ethclient" "github.com/scroll-tech/go-ethereum/log" backendabi "scroll-tech/bridge-history-api/abi" + "scroll-tech/bridge-history-api/internal/config" "scroll-tech/bridge-history-api/internal/orm" "scroll-tech/bridge-history-api/internal/utils" ) // L2EventParser the L2 event parser type L2EventParser struct { + cfg *config.FetcherConfig + client *ethclient.Client } // NewL2EventParser creates the L2 event parser -func NewL2EventParser() *L2EventParser { - return &L2EventParser{} +func NewL2EventParser(cfg *config.FetcherConfig, client *ethclient.Client) *L2EventParser { + return &L2EventParser{ + cfg: cfg, + client: client, + } } // ParseL2EventLogs parses L2 watched events -func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap map[uint64]uint64) ([]*orm.CrossMessage, []*orm.CrossMessage, error) { +func (e *L2EventParser) ParseL2EventLogs(ctx context.Context, logs []types.Log, blockTimestampsMap map[uint64]uint64) ([]*orm.CrossMessage, []*orm.CrossMessage, error) { var l2WithdrawMessages []*orm.CrossMessage var l2RelayedMessages []*orm.CrossMessage for _, vlog := range logs { @@ -29,7 +38,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.ETHMessageEvent{} err := utils.UnpackLog(backendabi.IL2ETHGatewayABI, &event, "WithdrawETH", vlog) if err != nil { - log.Warn("Failed to unpack WithdrawETH event", "err", err) + log.Error("Failed to unpack WithdrawETH event", "err", err) return nil, nil, err } lastMessage := l2WithdrawMessages[len(l2WithdrawMessages)-1] @@ -41,7 +50,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.ERC20MessageEvent{} err := utils.UnpackLog(backendabi.IL2ERC20GatewayABI, &event, "WithdrawERC20", vlog) if err != nil { - log.Warn("Failed to unpack WithdrawERC20 event", "err", err) + log.Error("Failed to unpack WithdrawERC20 event", "err", err) return nil, nil, err } lastMessage := l2WithdrawMessages[len(l2WithdrawMessages)-1] @@ -55,7 +64,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.ERC721MessageEvent{} err := utils.UnpackLog(backendabi.IL2ERC721GatewayABI, &event, "WithdrawERC721", vlog) if err != nil { - log.Warn("Failed to unpack WithdrawERC721 event", "err", err) + log.Error("Failed to unpack WithdrawERC721 event", "err", err) return nil, nil, err } lastMessage := l2WithdrawMessages[len(l2WithdrawMessages)-1] @@ -69,7 +78,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.BatchERC721MessageEvent{} err := utils.UnpackLog(backendabi.IL2ERC721GatewayABI, &event, "BatchWithdrawERC721", vlog) if err != nil { - log.Warn("Failed to unpack BatchWithdrawERC721 event", "err", err) + log.Error("Failed to unpack BatchWithdrawERC721 event", "err", err) return nil, nil, err } lastMessage := l2WithdrawMessages[len(l2WithdrawMessages)-1] @@ -83,7 +92,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.ERC1155MessageEvent{} err := utils.UnpackLog(backendabi.IL2ERC1155GatewayABI, &event, "WithdrawERC1155", vlog) if err != nil { - log.Warn("Failed to unpack WithdrawERC1155 event", "err", err) + log.Error("Failed to unpack WithdrawERC1155 event", "err", err) return nil, nil, err } lastMessage := l2WithdrawMessages[len(l2WithdrawMessages)-1] @@ -98,7 +107,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.BatchERC1155MessageEvent{} err := utils.UnpackLog(backendabi.IL2ERC1155GatewayABI, &event, "BatchWithdrawERC1155", vlog) if err != nil { - log.Warn("Failed to unpack BatchWithdrawERC1155 event", "err", err) + log.Error("Failed to unpack BatchWithdrawERC1155 event", "err", err) return nil, nil, err } lastMessage := l2WithdrawMessages[len(l2WithdrawMessages)-1] @@ -113,12 +122,17 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.L2SentMessageEvent{} err := utils.UnpackLog(backendabi.IL2ScrollMessengerABI, &event, "SentMessage", vlog) if err != nil { - log.Warn("Failed to unpack SentMessage event", "err", err) + log.Error("Failed to unpack SentMessage event", "err", err) + return nil, nil, err + } + from, err := getRealFromAddress(ctx, event.Sender, e.client, vlog.TxHash, e.cfg.GatewayRouterAddr) + if err != nil { + log.Error("Failed to get real 'from' address", "err", err) return nil, nil, err } l2WithdrawMessages = append(l2WithdrawMessages, &orm.CrossMessage{ MessageHash: utils.ComputeMessageHash(event.Sender, event.Target, event.Value, event.MessageNonce, event.Message).String(), - Sender: event.Sender.String(), + Sender: from, Receiver: event.Target.String(), TokenType: int(orm.TokenTypeETH), L2TxHash: vlog.TxHash.String(), @@ -137,7 +151,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.L2RelayedMessageEvent{} err := utils.UnpackLog(backendabi.IL2ScrollMessengerABI, &event, "RelayedMessage", vlog) if err != nil { - log.Warn("Failed to unpack RelayedMessage event", "err", err) + log.Error("Failed to unpack RelayedMessage event", "err", err) return nil, nil, err } l2RelayedMessages = append(l2RelayedMessages, &orm.CrossMessage{ @@ -151,7 +165,7 @@ func (e *L2EventParser) ParseL2EventLogs(logs []types.Log, blockTimestampsMap ma event := backendabi.L2RelayedMessageEvent{} err := utils.UnpackLog(backendabi.IL2ScrollMessengerABI, &event, "FailedRelayedMessage", vlog) if err != nil { - log.Warn("Failed to unpack FailedRelayedMessage event", "err", err) + log.Error("Failed to unpack FailedRelayedMessage event", "err", err) return nil, nil, err } l2RelayedMessages = append(l2RelayedMessages, &orm.CrossMessage{ diff --git a/bridge-history-api/internal/logic/l2_fetcher.go b/bridge-history-api/internal/logic/l2_fetcher.go index ab1d0d6c04..ec13e70ba6 100644 --- a/bridge-history-api/internal/logic/l2_fetcher.go +++ b/bridge-history-api/internal/logic/l2_fetcher.go @@ -33,9 +33,10 @@ type L2FilterResult struct { // L2FetcherLogic the L2 fetcher logic type L2FetcherLogic struct { - cfg *config.LayerConfig + cfg *config.FetcherConfig client *ethclient.Client addressList []common.Address + gatewayList []common.Address parser *L2EventParser db *gorm.DB crossMessageOrm *orm.CrossMessage @@ -45,7 +46,7 @@ type L2FetcherLogic struct { } // NewL2FetcherLogic create L2 fetcher logic -func NewL2FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.Client) *L2FetcherLogic { +func NewL2FetcherLogic(cfg *config.FetcherConfig, db *gorm.DB, client *ethclient.Client) *L2FetcherLogic { addressList := []common.Address{ common.HexToAddress(cfg.ETHGatewayAddr), @@ -60,16 +61,34 @@ func NewL2FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.C common.HexToAddress(cfg.MessengerAddr), } + gatewayList := []common.Address{ + common.HexToAddress(cfg.ETHGatewayAddr), + + common.HexToAddress(cfg.StandardERC20GatewayAddr), + common.HexToAddress(cfg.CustomERC20GatewayAddr), + common.HexToAddress(cfg.WETHGatewayAddr), + common.HexToAddress(cfg.DAIGatewayAddr), + + common.HexToAddress(cfg.ERC721GatewayAddr), + common.HexToAddress(cfg.ERC1155GatewayAddr), + + common.HexToAddress(cfg.MessengerAddr), + + common.HexToAddress(cfg.GatewayRouterAddr), + } + // Optional erc20 gateways. if common.HexToAddress(cfg.USDCGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.USDCGatewayAddr)) + gatewayList = append(gatewayList, common.HexToAddress(cfg.USDCGatewayAddr)) } if common.HexToAddress(cfg.LIDOGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.LIDOGatewayAddr)) + gatewayList = append(gatewayList, common.HexToAddress(cfg.USDCGatewayAddr)) } - log.Info("L2 Fetcher configured with the following address list", "addresses", addressList) + log.Info("L2 Fetcher configured with the following address list", "addresses", addressList, "gateways", gatewayList) f := &L2FetcherLogic{ db: db, @@ -78,7 +97,8 @@ func NewL2FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.C cfg: cfg, client: client, addressList: addressList, - parser: NewL2EventParser(), + gatewayList: gatewayList, + parser: NewL2EventParser(cfg, client), } reg := prometheus.DefaultRegisterer @@ -127,42 +147,7 @@ func (f *L2FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, bl blockTimestampsMap[block.NumberU64()] = block.Time() for _, tx := range block.Transactions() { - txTo := tx.To() - if txTo == nil { - continue - } - toAddress := txTo.String() - - // GatewayRouter: L2 withdrawal. - if toAddress == f.cfg.GatewayRouterAddr { - 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, nil, receiptErr - } - - // Check if the transaction is failed - if receipt.Status == types.ReceiptStatusFailed { - signer := types.LatestSignerForChainID(new(big.Int).SetUint64(tx.ChainId().Uint64())) - sender, signerErr := signer.Sender(tx) - if signerErr != nil { - log.Error("get sender failed", "chain id", tx.ChainId().Uint64(), "tx hash", tx.Hash().String(), "err", signerErr) - return nil, nil, nil, signerErr - } - - l2RevertedUserTxs = append(l2RevertedUserTxs, &orm.CrossMessage{ - L2TxHash: tx.Hash().String(), - MessageType: int(orm.MessageTypeL2SentMessage), - Sender: sender.String(), - Receiver: (*tx.To()).String(), - L2BlockNumber: receipt.BlockNumber.Uint64(), - BlockTimestamp: block.Time(), - TxStatus: int(orm.TxStatusTypeSentTxReverted), - }) - } - } - - if tx.Type() == types.L1MessageTxType { + if tx.IsL1MessageTx() { receipt, receiptErr := f.client.TransactionReceipt(ctx, tx.Hash()) if receiptErr != nil { log.Error("Failed to get transaction receipt", "txHash", tx.Hash().String(), "err", receiptErr) @@ -179,6 +164,38 @@ func (f *L2FetcherLogic) getRevertedTxs(ctx context.Context, from, to uint64, bl MessageType: int(orm.MessageTypeL1SentMessage), }) } + continue + } + + // Gateways: L2 withdrawal. + if !isTransactionToGateway(tx, f.gatewayList) { + continue + } + + 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, nil, receiptErr + } + + // Check if the transaction is failed + if receipt.Status == types.ReceiptStatusFailed { + signer := types.LatestSignerForChainID(new(big.Int).SetUint64(tx.ChainId().Uint64())) + sender, signerErr := signer.Sender(tx) + if signerErr != nil { + log.Error("get sender failed", "chain id", tx.ChainId().Uint64(), "tx hash", tx.Hash().String(), "err", signerErr) + return nil, nil, nil, signerErr + } + + l2RevertedUserTxs = append(l2RevertedUserTxs, &orm.CrossMessage{ + L2TxHash: tx.Hash().String(), + MessageType: int(orm.MessageTypeL2SentMessage), + Sender: sender.String(), + Receiver: (*tx.To()).String(), + L2BlockNumber: receipt.BlockNumber.Uint64(), + BlockTimestamp: block.Time(), + TxStatus: int(orm.TxStatusTypeSentTxReverted), + }) } } } @@ -235,7 +252,7 @@ func (f *L2FetcherLogic) L2Fetcher(ctx context.Context, from, to uint64, lastBlo return false, 0, common.Hash{}, nil, err } - l2WithdrawMessages, l2RelayedMessages, err := f.parser.ParseL2EventLogs(eventLogs, blockTimestampsMap) + l2WithdrawMessages, l2RelayedMessages, err := f.parser.ParseL2EventLogs(ctx, eventLogs, blockTimestampsMap) if err != nil { log.Error("failed to parse L2 event logs", "from", from, "to", to, "err", err) return false, 0, common.Hash{}, nil, err @@ -279,3 +296,15 @@ func (f *L2FetcherLogic) updateMetrics(res L2FilterResult) { } } } + +func isTransactionToGateway(tx *types.Transaction, gatewayList []common.Address) bool { + if tx.To() == nil { + return false + } + for _, gateway := range gatewayList { + if *tx.To() == gateway { + return true + } + } + return false +} diff --git a/bridge-history-api/internal/orm/batch_event.go b/bridge-history-api/internal/orm/batch_event.go index d50fcb76a1..67135561f6 100644 --- a/bridge-history-api/internal/orm/batch_event.go +++ b/bridge-history-api/internal/orm/batch_event.go @@ -6,6 +6,7 @@ import ( "time" "gorm.io/gorm" + "gorm.io/gorm/clause" ) // BatchStatusType represents the type of batch status. @@ -89,19 +90,21 @@ func (c *BatchEvent) GetFinalizedBatchesLEBlockHeight(ctx context.Context, block } // InsertOrUpdateBatchEvents inserts a new batch event or updates an existing one based on the BatchStatusType. -func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvents []*BatchEvent, dbTX ...*gorm.DB) error { +func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvents []*BatchEvent) error { for _, l1BatchEvent := range l1BatchEvents { db := c.db - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] - } db = db.WithContext(ctx) db = db.Model(&BatchEvent{}) updateFields := make(map[string]interface{}) switch BatchStatusType(l1BatchEvent.BatchStatus) { case BatchStatusTypeCommitted: + // Use the clause to either insert or ignore on conflict + db = db.Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "batch_hash"}}, + DoNothing: true, + }) if err := db.Create(l1BatchEvent).Error; err != nil { - return fmt.Errorf("failed to insert batch event, error: %w", err) + return fmt.Errorf("failed to insert or ignore batch event, error: %w", err) } case BatchStatusTypeFinalized: db = db.Where("batch_index = ?", l1BatchEvent.BatchIndex) diff --git a/bridge-history-api/internal/orm/cross_message.go b/bridge-history-api/internal/orm/cross_message.go index 27a9f4c889..0ffe1d93b0 100644 --- a/bridge-history-api/internal/orm/cross_message.go +++ b/bridge-history-api/internal/orm/cross_message.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/google/uuid" "github.com/scroll-tech/go-ethereum/common" "gorm.io/gorm" "gorm.io/gorm/clause" @@ -47,9 +46,9 @@ const ( TxStatusTypeSent TxStatusType = iota TxStatusTypeSentTxReverted // Not track message hash, thus will not be processed again anymore. TxStatusTypeRelayed // Terminal status. - // FailedRelayedMessage event: encoded tx failed, cannot retry. e.g., https://sepolia.scrollscan.com/tx/0xfc7d3ea5ec8dc9b664a5a886c3b33d21e665355057601033481a439498efb79a - TxStatusTypeFailedRelayed // Terminal status. - // In some cases, user can retry with a larger gas limit. e.g., https://sepolia.scrollscan.com/tx/0x7323a7ba29492cb47d92206411be99b27896f2823cee0633a596b646b73f1b5b + // Retry: this often occurs due to an out of gas (OOG) issue if the transaction was initiated via the frontend. + TxStatusTypeFailedRelayed + // Retry: this often occurs due to an out of gas (OOG) issue if the transaction was initiated via the frontend. TxStatusTypeRelayTxReverted TxStatusTypeSkipped TxStatusTypeDropped // Terminal status. @@ -254,38 +253,27 @@ func (c *CrossMessage) GetTxsByAddress(ctx context.Context, sender string) ([]*C } // UpdateL1MessageQueueEventsInfo updates the information about L1 message queue events in the database. -func (c *CrossMessage) UpdateL1MessageQueueEventsInfo(ctx context.Context, l1MessageQueueEvents []*MessageQueueEvent, dbTX ...*gorm.DB) error { +func (c *CrossMessage) UpdateL1MessageQueueEventsInfo(ctx context.Context, l1MessageQueueEvents []*MessageQueueEvent) error { // update tx statuses. for _, l1MessageQueueEvent := range l1MessageQueueEvents { db := c.db - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] - } db = db.WithContext(ctx) db = db.Model(&CrossMessage{}) - // do not over-write terminal statuses. - db = db.Where("tx_status != ?", TxStatusTypeRelayed) - db = db.Where("tx_status != ?", TxStatusTypeFailedRelayed) - db = db.Where("tx_status != ?", TxStatusTypeDropped) txStatusUpdateFields := make(map[string]interface{}) switch l1MessageQueueEvent.EventType { case MessageQueueEventTypeQueueTransaction: - // only replayMessages or enforced txs (whose message hashes would not be found), sentMessages have been filtered out. - // replayMessage case: - // First SentMessage in L1: https://sepolia.etherscan.io/tx/0xbee4b631312448fcc2caac86e4dccf0a2ae0a88acd6c5fd8764d39d746e472eb - // Transaction reverted in L2: https://sepolia.scrollscan.com/tx/0xde6ef307a7da255888aad7a4c40a6b8c886e46a8a05883070bbf18b736cbfb8c - // replayMessage: https://sepolia.etherscan.io/tx/0xa5392891232bb32d98fcdbaca0d91b4d22ef2755380d07d982eebd47b147ce28 - // - // Note: update l1_tx_hash if the user calls replayMessage, cannot use queue index here, - // because in replayMessage, queue index != message nonce. - // Ref: https://github.com/scroll-tech/scroll/blob/v4.3.44/contracts/src/L1/L1ScrollMessenger.sol#L187-L190 - db = db.Where("message_hash = ?", l1MessageQueueEvent.MessageHash.String()) - txStatusUpdateFields["tx_status"] = TxStatusTypeSent // reset status to "sent". + continue case MessageQueueEventTypeDequeueTransaction: + // do not over-write terminal statuses. + db = db.Where("tx_status != ?", TxStatusTypeRelayed) + db = db.Where("tx_status != ?", TxStatusTypeDropped) db = db.Where("message_nonce = ?", l1MessageQueueEvent.QueueIndex) db = db.Where("message_type = ?", MessageTypeL1SentMessage) txStatusUpdateFields["tx_status"] = TxStatusTypeSkipped case MessageQueueEventTypeDropTransaction: + // do not over-write terminal statuses. + db = db.Where("tx_status != ?", TxStatusTypeRelayed) + db = db.Where("tx_status != ?", TxStatusTypeDropped) db = db.Where("message_nonce = ?", l1MessageQueueEvent.QueueIndex) db = db.Where("message_type = ?", MessageTypeL1SentMessage) txStatusUpdateFields["tx_status"] = TxStatusTypeDropped @@ -298,15 +286,22 @@ func (c *CrossMessage) UpdateL1MessageQueueEventsInfo(ctx context.Context, l1Mes // update tx hashes of replay and refund. for _, l1MessageQueueEvent := range l1MessageQueueEvents { db := c.db - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] - } db = db.WithContext(ctx) db = db.Model(&CrossMessage{}) txHashUpdateFields := make(map[string]interface{}) switch l1MessageQueueEvent.EventType { + case MessageQueueEventTypeDequeueTransaction: + continue case MessageQueueEventTypeQueueTransaction: - // only replayMessages or enforced txs (whose message hashes would not be found), sentMessages have been filtered out. + // only replayMessages or enforced txs (whose message hashes would not be found), sendMessages have been filtered out. + // replayMessage case: + // First SentMessage in L1: https://sepolia.etherscan.io/tx/0xbee4b631312448fcc2caac86e4dccf0a2ae0a88acd6c5fd8764d39d746e472eb + // Transaction reverted in L2: https://sepolia.scrollscan.com/tx/0xde6ef307a7da255888aad7a4c40a6b8c886e46a8a05883070bbf18b736cbfb8c + // replayMessage: https://sepolia.etherscan.io/tx/0xa5392891232bb32d98fcdbaca0d91b4d22ef2755380d07d982eebd47b147ce28 + // + // Note: update l1_tx_hash if the user calls replayMessage, cannot use queue index here, + // because in replayMessage, queue index != message nonce. + // Ref: https://github.com/scroll-tech/scroll/blob/v4.3.44/contracts/src/L1/L1ScrollMessenger.sol#L187-L190 db = db.Where("message_hash = ?", l1MessageQueueEvent.MessageHash.String()) txHashUpdateFields["l1_replay_tx_hash"] = l1MessageQueueEvent.TxHash.String() case MessageQueueEventTypeDropTransaction: @@ -314,11 +309,8 @@ func (c *CrossMessage) UpdateL1MessageQueueEventsInfo(ctx context.Context, l1Mes db = db.Where("message_type = ?", MessageTypeL1SentMessage) txHashUpdateFields["l1_refund_tx_hash"] = l1MessageQueueEvent.TxHash.String() } - // Check if there are fields to update to avoid empty update operation (skip message). - if len(txHashUpdateFields) > 0 { - if err := db.Updates(txHashUpdateFields).Error; err != nil { - return fmt.Errorf("failed to update tx hashes of replay and refund in L1 message queue events info, update fields: %v, error: %w", txHashUpdateFields, err) - } + if err := db.Updates(txHashUpdateFields).Error; err != nil { + return fmt.Errorf("failed to update tx hashes of replay and refund in L1 message queue events info, update fields: %v, error: %w", txHashUpdateFields, err) } } return nil @@ -362,14 +354,11 @@ func (c *CrossMessage) UpdateBatchIndexRollupStatusMerkleProofOfL2Messages(ctx c } // InsertOrUpdateL1Messages inserts or updates a list of L1 cross messages into the database. -func (c *CrossMessage) InsertOrUpdateL1Messages(ctx context.Context, messages []*CrossMessage, dbTX ...*gorm.DB) error { +func (c *CrossMessage) InsertOrUpdateL1Messages(ctx context.Context, messages []*CrossMessage) error { if len(messages) == 0 { return nil } db := c.db - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] - } db = db.WithContext(ctx) db = db.Model(&CrossMessage{}) // 'tx_status' column is not explicitly assigned during the update to prevent a later status from being overwritten back to "sent". @@ -384,18 +373,14 @@ func (c *CrossMessage) InsertOrUpdateL1Messages(ctx context.Context, messages [] } // InsertOrUpdateL2Messages inserts or updates a list of L2 cross messages into the database. -func (c *CrossMessage) InsertOrUpdateL2Messages(ctx context.Context, messages []*CrossMessage, dbTX ...*gorm.DB) error { +func (c *CrossMessage) InsertOrUpdateL2Messages(ctx context.Context, messages []*CrossMessage) error { if len(messages) == 0 { return nil } db := c.db - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] - } db = db.WithContext(ctx) db = db.Model(&CrossMessage{}) // 'tx_status' column is not explicitly assigned during the update to prevent a later status from being overwritten back to "sent". - // The merkle_proof is updated separately in batch status updates and hence is not included here. db = db.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "message_hash"}}, DoUpdates: clause.AssignmentColumns([]string{"sender", "receiver", "token_type", "l2_block_number", "l2_tx_hash", "l1_token_address", "l2_token_address", "token_ids", "token_amounts", "message_type", "block_timestamp", "message_from", "message_to", "message_value", "message_data", "message_nonce"}), @@ -406,31 +391,60 @@ func (c *CrossMessage) InsertOrUpdateL2Messages(ctx context.Context, messages [] return nil } -// InsertFailedGatewayRouterTxs inserts a list of transactions that failed to interact with the gateway router into the database. -// These failed transactions are only fetched once, so they are inserted without checking for duplicates. -// To resolve unique index confliction, a random UUID will be generated and used as the MessageHash. -func (c *CrossMessage) InsertFailedGatewayRouterTxs(ctx context.Context, messages []*CrossMessage, dbTX ...*gorm.DB) error { +// InsertFailedL2GatewayTxs inserts a list of transactions that failed to interact with the L2 gateways into the database. +// To resolve unique index confliction, L2 tx hash is used as the MessageHash. +// The OnConflict clause is used to prevent inserting same failed transactions multiple times. +func (c *CrossMessage) InsertFailedL2GatewayTxs(ctx context.Context, messages []*CrossMessage) error { if len(messages) == 0 { return nil } - db := c.db - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] + + for _, message := range messages { + message.MessageHash = message.L2TxHash } + db := c.db db = db.WithContext(ctx) db = db.Model(&CrossMessage{}) + db = db.Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "message_hash"}}, + DoNothing: true, + }) + + if err := db.Create(&messages).Error; err != nil { + return fmt.Errorf("failed to insert failed gateway router txs, error: %w", err) + } + return nil +} + +// InsertFailedL1GatewayTxs inserts a list of transactions that failed to interact with the L1 gateways into the database. +// To resolve unique index confliction, L1 tx hash is used as the MessageHash. +// The OnConflict clause is used to prevent inserting same failed transactions multiple times. +func (c *CrossMessage) InsertFailedL1GatewayTxs(ctx context.Context, messages []*CrossMessage) error { + if len(messages) == 0 { + return nil + } + for _, message := range messages { - message.MessageHash = uuid.New().String() + message.MessageHash = message.L1TxHash } - if err := db.Create(messages).Error; err != nil { + + db := c.db + db = db.WithContext(ctx) + db = db.Model(&CrossMessage{}) + db = db.Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "message_hash"}}, + DoNothing: true, + }) + + if err := db.Create(&messages).Error; err != nil { return fmt.Errorf("failed to insert failed gateway router txs, error: %w", err) } return nil } // InsertOrUpdateL2RelayedMessagesOfL1Deposits inserts or updates the database with a list of L2 relayed messages related to L1 deposits. -func (c *CrossMessage) InsertOrUpdateL2RelayedMessagesOfL1Deposits(ctx context.Context, l2RelayedMessages []*CrossMessage, dbTX ...*gorm.DB) error { +func (c *CrossMessage) InsertOrUpdateL2RelayedMessagesOfL1Deposits(ctx context.Context, l2RelayedMessages []*CrossMessage) error { if len(l2RelayedMessages) == 0 { return nil } @@ -459,7 +473,7 @@ func (c *CrossMessage) InsertOrUpdateL2RelayedMessagesOfL1Deposits(ctx context.C for _, msg := range mergedL2RelayedMessages { uniqueL2RelayedMessages = append(uniqueL2RelayedMessages, msg) } - // Do not update tx status of successfully or failed relayed messages, + // Do not update tx status of successfully relayed messages, // because if a message is handled, the later relayed message tx would be reverted. // ref: https://github.com/scroll-tech/scroll/blob/v4.3.44/contracts/src/L2/L2ScrollMessenger.sol#L102 // e.g., @@ -476,7 +490,6 @@ func (c *CrossMessage) InsertOrUpdateL2RelayedMessagesOfL1Deposits(ctx context.C clause.And( // do not over-write terminal statuses. clause.Neq{Column: "cross_message_v2.tx_status", Value: TxStatusTypeRelayed}, - clause.Neq{Column: "cross_message_v2.tx_status", Value: TxStatusTypeFailedRelayed}, clause.Neq{Column: "cross_message_v2.tx_status", Value: TxStatusTypeDropped}, ), }, @@ -489,7 +502,7 @@ func (c *CrossMessage) InsertOrUpdateL2RelayedMessagesOfL1Deposits(ctx context.C } // InsertOrUpdateL1RelayedMessagesOfL2Withdrawals inserts or updates the database with a list of L1 relayed messages related to L2 withdrawals. -func (c *CrossMessage) InsertOrUpdateL1RelayedMessagesOfL2Withdrawals(ctx context.Context, l1RelayedMessages []*CrossMessage, dbTX ...*gorm.DB) error { +func (c *CrossMessage) InsertOrUpdateL1RelayedMessagesOfL2Withdrawals(ctx context.Context, l1RelayedMessages []*CrossMessage) error { if len(l1RelayedMessages) == 0 { return nil } @@ -519,9 +532,6 @@ func (c *CrossMessage) InsertOrUpdateL1RelayedMessagesOfL2Withdrawals(ctx contex uniqueL1RelayedMessages = append(uniqueL1RelayedMessages, msg) } db := c.db - if len(dbTX) > 0 && dbTX[0] != nil { - db = dbTX[0] - } db = db.WithContext(ctx) db = db.Model(&CrossMessage{}) db = db.Clauses(clause.OnConflict{ @@ -532,7 +542,6 @@ func (c *CrossMessage) InsertOrUpdateL1RelayedMessagesOfL2Withdrawals(ctx contex clause.And( // do not over-write terminal statuses. clause.Neq{Column: "cross_message_v2.tx_status", Value: TxStatusTypeRelayed}, - clause.Neq{Column: "cross_message_v2.tx_status", Value: TxStatusTypeFailedRelayed}, clause.Neq{Column: "cross_message_v2.tx_status", Value: TxStatusTypeDropped}, ), }, diff --git a/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event_v2.sql b/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event_v2.sql index ba42500f32..4ffa4e3d55 100644 --- a/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event_v2.sql +++ b/bridge-history-api/internal/orm/migrate/migrations/00002_batch_event_v2.sql @@ -15,6 +15,7 @@ CREATE TABLE batch_event_v2 deleted_at TIMESTAMP(0) DEFAULT NULL ); +CREATE UNIQUE INDEX IF NOT EXISTS unique_idx_be_batch_hash ON batch_event_v2 (batch_hash); CREATE INDEX IF NOT EXISTS idx_be_l1_block_number ON batch_event_v2 (l1_block_number); CREATE INDEX IF NOT EXISTS idx_be_batch_index ON batch_event_v2 (batch_index); CREATE INDEX IF NOT EXISTS idx_be_batch_index_batch_hash ON batch_event_v2 (batch_index, batch_hash); diff --git a/common/version/version.go b/common/version/version.go index e56890807b..6749872e1e 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.3.56" +var tag = "v4.3.59" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/contracts/circomlib.d.ts b/contracts/circomlib.d.ts index 195e6df8e7..de593f544e 100644 --- a/contracts/circomlib.d.ts +++ b/contracts/circomlib.d.ts @@ -1 +1,3 @@ +declare module "circomlib/src/evmasm"; declare module "circomlib/src/poseidon_gencontract"; +declare module "circomlib/src/poseidon_constants"; diff --git a/contracts/integration-test/PoseidonHash.spec.ts b/contracts/integration-test/PoseidonHash.spec.ts new file mode 100644 index 0000000000..5746cb3f2e --- /dev/null +++ b/contracts/integration-test/PoseidonHash.spec.ts @@ -0,0 +1,97 @@ +/* eslint-disable node/no-missing-import */ +/* eslint-disable node/no-unpublished-import */ +import { expect } from "chai"; +import { randomBytes } from "crypto"; +import { BigNumber, Contract } from "ethers"; +import { ethers } from "hardhat"; +import fs from "fs"; + +import PoseidonWithoutDomain from "circomlib/src/poseidon_gencontract"; +import { generateABI, createCode } from "../scripts/poseidon"; + +describe("PoseidonHash.spec", async () => { + // test against with circomlib's implementation. + context("domain = zero", async () => { + let poseidonCircom: Contract; + let poseidon: Contract; + + beforeEach(async () => { + const [deployer] = await ethers.getSigners(); + + const PoseidonWithoutDomainFactory = new ethers.ContractFactory( + PoseidonWithoutDomain.generateABI(2), + PoseidonWithoutDomain.createCode(2), + deployer + ); + poseidonCircom = await PoseidonWithoutDomainFactory.deploy(); + await poseidonCircom.deployed(); + + const PoseidonWithDomainFactory = new ethers.ContractFactory(generateABI(2), createCode(2), deployer); + poseidon = await PoseidonWithDomainFactory.deploy(); + await poseidon.deployed(); + }); + + it("should succeed on zero inputs", async () => { + expect(await poseidonCircom["poseidon(uint256[2])"]([0, 0])).to.eq( + await poseidon["poseidon(uint256[2],uint256)"]([0, 0], 0) + ); + }); + + it("should succeed on random inputs", async () => { + for (let bytes = 1; bytes <= 32; ++bytes) { + for (let i = 0; i < 5; ++i) { + const a = randomBytes(bytes); + const b = randomBytes(bytes); + expect(await poseidonCircom["poseidon(uint256[2])"]([a, b])).to.eq( + await poseidon["poseidon(uint256[2],uint256)"]([a, b], 0) + ); + expect(await poseidonCircom["poseidon(uint256[2])"]([a, 0])).to.eq( + await poseidon["poseidon(uint256[2],uint256)"]([a, 0], 0) + ); + expect(await poseidonCircom["poseidon(uint256[2])"]([0, b])).to.eq( + await poseidon["poseidon(uint256[2],uint256)"]([0, b], 0) + ); + } + } + }); + }); + + // test against with scroll's go implementation. + context("domain = nonzero", async () => { + let poseidonCircom: Contract; + let poseidon: Contract; + + beforeEach(async () => { + const [deployer] = await ethers.getSigners(); + + const PoseidonWithoutDomainFactory = new ethers.ContractFactory( + PoseidonWithoutDomain.generateABI(2), + PoseidonWithoutDomain.createCode(2), + deployer + ); + poseidonCircom = await PoseidonWithoutDomainFactory.deploy(); + await poseidonCircom.deployed(); + + const PoseidonWithDomainFactory = new ethers.ContractFactory(generateABI(2), createCode(2), deployer); + poseidon = await PoseidonWithDomainFactory.deploy(); + await poseidon.deployed(); + }); + + it("should succeed on zero inputs", async () => { + expect(await poseidon["poseidon(uint256[2],uint256)"]([0, 0], 6)).to.eq( + BigNumber.from("17848312925884193353134534408113064827548730776291701343555436351962284922129") + ); + expect(await poseidon["poseidon(uint256[2],uint256)"]([0, 0], 7)).to.eq( + BigNumber.from("20994231331856095272861976502721128670019193481895476667943874333621461724676") + ); + }); + + it("should succeed on random inputs", async () => { + const lines = String(fs.readFileSync("./integration-test/testdata/poseidon_hash_with_domain.data")).split("\n"); + for (const line of lines) { + const [domain, a, b, hash] = line.split(" "); + expect(await poseidon["poseidon(uint256[2],uint256)"]([a, b], domain)).to.eq(BigNumber.from(hash)); + } + }); + }); +}); diff --git a/contracts/integration-test/ZkTrieVerifier.spec.ts b/contracts/integration-test/ZkTrieVerifier.spec.ts index ca9f1e3de5..f04242ab54 100644 --- a/contracts/integration-test/ZkTrieVerifier.spec.ts +++ b/contracts/integration-test/ZkTrieVerifier.spec.ts @@ -5,7 +5,9 @@ import { concat } from "ethers/lib/utils"; import { ethers } from "hardhat"; import { MockZkTrieVerifier } from "../typechain"; -import poseidonUnit from "circomlib/src/poseidon_gencontract"; +import { generateABI, createCode } from "../scripts/poseidon"; + +const chars = "0123456789abcdef"; interface ITestConfig { block: number; @@ -20,170 +22,245 @@ interface ITestConfig { const testcases: Array = [ { - block: 95216, - desc: "contract with storage", + // curl -H "content-type: application/json" -X POST --data '{"id":0,"jsonrpc":"2.0","method":"eth_getProof","params":["0x5300000000000000000000000000000000000004", ["0x8391082587ea494a8beba02cc40273f27e5477a967cd400736ac46950da0b378"], "0x1111ad"]}' https://rpc.scroll.io + block: 1118637, + desc: "WETH.balance[0xa7994f02237aed2c116a702a8f5322a1fb325b31]", account: "0x5300000000000000000000000000000000000004", - storage: "0x9505174b0709a2a1997fe9797cb89648a93f17ce0096cbc1a6ed52b73170b96a", - expectedRoot: "0x2dc794537b959b575dc216cd11389d802f9389fce7183278561a824aa8e950e2", - expectedValue: "0x00000000000000000000000000000000000000000000000111346048bf18a14a", + storage: "0x8391082587ea494a8beba02cc40273f27e5477a967cd400736ac46950da0b378", + expectedRoot: "0x1334a21a74914182745c1f5142e70b487262096784ae7669186657462c01b103", + expectedValue: "0x00000000000000000000000000000000000000000000000000006239b5a2c000", accountProof: [ - "0x001988ce414103e97cb80613adde47d5fe0611b30087d1cfcdb84284c42907467e24ac744be2edcb86cdfc42a9bbb7b2a270649161c3ce3a41d3ad5a26927d2c79", - "0x0028db7c407cab6652f1f194401bd87bda33c9a1723b4f93515bd5929cad02668123fa5a3e69136c8e03a62c805f89c9d3578a6f5fac4bb281fc4d7df12fbcc5db", - "0x000376d1bfe3d5c6afffb5707a34003209c57fbf15430daf0f8022b4df2bb947460ab4fda7be343efd34af2420e8e9d4268f436cb7700a005086df4eba083407c8", - "0x0025df09dd66dd9d8b5b1abb82cee9985a2addd12e7f5671c910e27644ccaf498c2a2d7021169172e380831f43a00f0a3bef8576c7c74ac98fd7e7b1ec443ac92e", - "0x00218d51f8e754bf89062007dd765b50b7385bbb4a57db258ac8dcf9ad69b6f4552ddc5a17cec74d8e8f06e16c0a6112023c34d6c001060bc783ab4d06a4a9801a", - "0x001166c2eedfbbb4568ec27c57b2729437c0c8c38161fad643f03f76fbd807e712286d86bfdceb6729daedb6f219dd0f6080386d9a2a8f9c1dcb89792c8754e125", - "0x0028fd666ed406e277f6496bcac13af8b303b58c74be937399095399f4dd141c6f2876f81684c2546ff90b221ba2fe1290e671770af08fd545868e3351401b1503", - "0x000b9245c7ccc1eab305d40cced5e8aac6c8ddb877451075185bb7a6c1a4973a5d2852ce761c8e417a5f604a6ef4196ec101014aa1d1e4c684d1b5b8cbec5c37b1", - "0x0019755e50ef22e13ae17cbc33d9e708ee9efc011941b3a920bc65da9825b04eb029a43488e5584b68d1a98a215f03f31e063734a3305600f9feed11607271d0d3", - "0x002e10cc0afbf5b336e6a6eeae0c863df7a7c2ba61c599618fb973aeff397918e523b18c08a19fa6bc964ae41c56af610ab43d948db94ad2543e9807a5a0f1d2f0", - "0x00247f3f0cebebf749e27c8ffd81e9919cab114bd3d75029e3260e99b6c7fe551d06a69531144f521b68d1a2c7450f5a20146efdaf7b47271782bb8746a023cf84", - "0x0029ad88f0ee7198edcae37ab88efb2a27ea8956d6b988264b227843c175743c4329916ead363e6adfc27f400977d2d9efb1f896616a18d71e2702ec8201b82c57", - "0x002a1de55ee84561850354085516a1101705f8240b8f1e1f9aea3a464650d637a52fad2de438ac5851b0e28508af90bd385dbcad5df8ea23ca78792f094ff7ca0d", - "0x001ba118afa1977f1fda1411cd1c7f145ab97a35b1e724060d5cfc3d58b27141ee2b0a8dbf3d494c6a1bf6456c4de00de8e2f0d9be0716a3ca78d4df28948f975b", - "0x0025bdbf508c1e3808415136bfdd6dfb548c33348d813882b0d405913405d575010c60f95c658dc8113f7c97935a35d78c23dba131c25866fc8d93920e318d2450", - "0x0007bc3ec4d80df884c4d87f4541ffa522046a4c52e6cccb9ff7376ff56149e5d21b87a56676f679f4b8b4478c8a3aa80a09127258cccd4aa373a5c7c2344d2d03", - "0x010aef26efde9e4bca477d460482bce3de3577f6e9a280dea6d3f9985b4151deab0508000000000000000000000000000000000000000000000000071d0000000000000000000000000000000000000000000000000000000000000013328350573dd32b38291529042b30b83bf20bfc7e18ab6a9755e2ea692d5a7644f896b0d629cf9740d72ccbc90dd6141deb3fab132f1ebc17ab963c612c7123d5a524d0158cc8291b081281272d79459760d885ea652024615d55b114b5872571b21aee99977b8681205300000000000000000000000000000000000004000000000000000000000000", + "0x0907d980105678a2007eb5683d850f36a9caafe6e7fd3279987d7a94a13a360d3a1478f9a4c1f8c755227ee3544929bb0d7cfa2d999a48493d048ff0250bb002ab", + "0x092b59a024f142555555c767842c4fcc3996686c57699791fcb10013f69ffd9b2507360087cb303767fd43f2650960621246a8d205d086e03d9c1626e4aaa5b143", + "0x091f876342916ac1d5a14ef40cfc5644452170b16d1b045877f303cd52322ba1e00ba09f36443c2a63fbd7ff8feeb2c84e99fde6db08fd8e4c67ad061c482ff276", + "0x09277b3069a4b944a45df222366aae727ec64efaf0a8ecb000645d0eea3a3fa93609b925158cc04f610f8c616369094683ca7a86239f49e97852aa286d148a3913", + "0x092fb789200a7324067934da8be91c48f86c4e6f35fed6d1ce8ae4d7051f480bc0074019222c788b139b6919dfbc9d0b51f274e0ed3ea03553b8db30392ac05ce4", + "0x092f79da8f9f2c3a3a3813580ff18d4619b95f54026b2f16ccbcca684d5e25e1f52912fa319d9a7ba537a52cc6571844b4d1aa99b8a78cea6f686a6279ade5dcae", + "0x09249d249bcf92a369bd7715ec63a4b29d706a5dbb304efd678a2e5d7982e7fa9b202e3225c1031d83ab62d78516a4cbdbf2b22842c57182e7cb0dbb4303ac38c5", + "0x0904837ebb85ceccab225d4d826fe57edca4b00862199b91082f65dfffa7669b90039c710273b02e60c2e74eb8b243721e852e0e56fa51668b6362fd920f817cb7", + "0x090a36f6aabc3768a05dd8f93667a0eb2e5b63d94b5ce27132fb38d13c56d49cb4249c2013daee90184ae285226271f150f6a8f74f2c85dbd0721c5f583e620b10", + "0x091b82f139a06af573e871fdd5f5ac18f17c568ffe1c9e271505b371ad7f0603e716b187804a49d2456a0baa7c2317c14d9aa7e58ad64df38bc6c1c7b86b072333", + "0x0929668e59dfc2e2aef10194f5d287d8396e1a897d68f106bdb12b9541c0bab71d2bf910dea11e3209b3feff88d630af46006e402e935bc84c559694d88c117733", + "0x0914231c92f09f56628c10603dc2d2120d9d11b27fa23753a14171127c3a1ee3dd0d6b9cbd11d031fe6e1b650023edc58aa580fa4f4aa1b30bf82e0e4c7a308bb9", + "0x0914c1dd24c520d96aac93b7ef3062526067f1b15a080c482abf449d3c2cde781b195eb63b5e328572090319310914d81b2ca8350b6e15dc9d13e878f8c28c9d52", + "0x0927cb93e3d9c144a5a3653c5cf2ed5940d64f461dd588cd192516ae7d855e9408166e85986d4c9836cd6cd822174ba9db9c7a043d73e86b5b2cfc0a2e082894c3", + "0x090858bf8a0119626fe9339bd92116a070ba1a66423b0f7d3f4666b6851fdea01400f7f51eb22df168c41162d7f18f9d97155d87da523b05a1dde54e7a30a98c31", + "0x0902776c1f5f93a95baea2e209ddb4a5e49dd1112a7f7d755a45addffe4a233dad0d8cc62b957d9b254fdc8199c720fcf8d5c65d14899911e991b4530710aca75e", + "0x091d7fde5c78c88bbf6082a20a185cde96a203ea0d29c829c1ab9322fc3ca0ae3100ef7cba868cac216d365a0232ad6227ab1ef3290166bc6c19b719b79dbc17fc", + "0x091690160269c53c6b74337a00d02cb40a88ea5eba06e1942088b619baee83279e12d96d62dda9c4b5897d58fea40b5825d87a5526dec37361ec7c93a3256ea76d", + "0x091bccb091cde3f8ca7cfda1df379c9bfa412908c41037ae4ec0a20ce984e2c9a51d02c109d2e6e25dc60f10b1bc3b3f97ca1ce1aa025ce4f3146de3979403b99e", + "0x0927083540af95e57acba69671a4a596f721432549b8760941f4251e0dd7a013a917cee0f60d333cf88e40ae8710fb1fd6e3920346a376b3ba6686a4b2020a043e", + "0x082170b57b8f05f6990eec62e74cdb303741f6c464a85d68582c19c51e53f490000a5029a62ddc14c9c07c549db300bd308b6367454966c94b8526f4ceed5693b2", + "0x0827a0b16ef333dcfe00610d19dc468b9e856f544c9b5e9b046357e0a38aedaeb90000000000000000000000000000000000000000000000000000000000000000", + "0x06126f891e8753e67c5cbfa2a67e9d71942eab3a88cde86e97a4af94ea0dde497821fb69ccdb00e6eaeaf7fc1e73630f39f846970b72ac801e396da0033fb0c247", + "0x0420e9fb498ff9c35246d527da24aa1710d2cc9b055ecf9a95a8a2a11d3d836cdf050800000000000000000000000000000000000000000000000016ef00000000000000000000000000000000000000000000000000000000000000600058d1a5ce14104d0dedcaecaab39b6e22c2608e40af67a71908e6e97bbf4a43c59c4537140c25a9e8c4073351c26b9831c1e5af153b9be4713a4af9edfdf32b58077b735e120f14136a7980da529d9e8d3a71433fc9dc5aa8c01e3a4eb60cb3a4f9cf9ca5c8e0be205300000000000000000000000000000000000004000000000000000000000000", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], storageProof: [ - "0x000a52b818e0a009930d62c17f2b1244179b7c14f8e1ae317fb3bfd3a3ba6060031b2a4aa2df31e79f926474987eea69aab84f4581cfd61b0338438110f6be145b", - "0x001684ff1ef6ea054c5a6a5cae45f9280dacfc10c6cde39d1f64a00ad3c77549fe1c14ff8a628c0244ba48d63610e5d0b514c1b7b60301b6f27f77a435caf8bd60", - "0x001a2ba0ad7d6447d3c2476aa2e6bd04ab552ac1840450ce11f338f58a80fcdf420df4b9fc89108a0a44d844d981abe44d5ab20a5a101d07e94d131f07bf83ba62", - "0x0007158ec8942174c68bde0ab3666eb29b3c5784693bbfcd21126789d98bbdd05409f0313df8ddc438abe4798854f30c9daa2274950ce833a2de21e09b8b2c11b2", - "0x000ab27b84c73e447618f030ad9d621b0d61cc783e7ae5671ffcd3ff479b5093fe173d6126fa71986aa679b5384a2dc25f3a15f806a546e933f9fda6ac0a3460d9", - "0x0024ca9a7c6b7bf77c7a7acdae9d8e551b08ec6adf30abb7d1c45a6bbd5058ea921802170d5cc7de7d294cf6c67b0ac0208fe76497803554fb5bba9f78721568eb", - "0x0018a60c68b26022ced26cce2be1af1d6b33f4c16596d1ba18d5f47fea98ae490b12e66678391e289de1cf981c122e765265b94f0669614d94847480a77c2d3b74", - "0x001a776d5e5902c9a073c86a71ee80d167d6e2eb92150df2afb3d87f18b2cce6f02af158ba1cfbc643b36c1e001b59473cc88663b44c8d70739a27b804ec387146", - "0x0012cd2c1070b0d2eb215eb760fba9b843bd5c732102ce9773701076b0e37a437e136901c4ddc1cdbef42f46af629296ca5965b41a53cce65237612cea27477076", - "0x002bf94aa1fcb474365039e949bbbeabe0162ffc490b1b63ffe0f84bf182a8bf16169fe345e742d176a80f6e733177736d93e40fc9fdd4866efa6cc45ad94e9577", - "0x001a2e6e1b585fa0564fc606c3d62c26d9a113d75430966ff3f500e450c762edeb24fb1e5456ed4313d9418a1b073ae8b3f852f0f8435752bbbe65d21726ddb873", - "0x002529704fb28f7d3f9d2f3e9d38b000b6bfc2a21cb0a1955797016536066307d70ba7397326ecf50b98153f9e3baa96608efdf7d772b1ff28649bef677860dba9", - "0x0022f4f22a1d85ac83a56e7031559cf874c78a2f2ee6b6b93625f588313964a6d0052f6c873c6417d409c2a5317b31449b36fb4faede558d03b448b06b4a198daa", - "0x0017167b295954b29f62d7347dab3158aedc8586d5aa233d3f69c14bc7fe31eb840000000000000000000000000000000000000000000000000000000000000000", - "0x002d7bed0c0f0318a6fc60f903f4a42841cc4fa431ddf1a97fc34f35d6a267434b2a1a818d75328089a9578143e31b1f535517e09ff50a728b100483e712c8bc9a", - "0x0126ae15b478408eb45ea8b6f61aad1345f2b6257efd1acc4a6024b26f664c98240101000000000000000000000000000000000000000000000000000111346048bf18a14a209505174b0709a2a1997fe9797cb89648a93f17ce0096cbc1a6ed52b73170b96a", + "0x09240ea2601c34d792a0a5a8a84d8e501cfdfdf2c10ef13ea560acac58661882dd1b3644d1d4f3e32fc78498a7ebeffac8c6a494ac6f36923ef1be476444c0d564", + "0x0912af3ac8f8ea443e6d89d071fccaa2b3c8462220c1c2921234f613b41594f08f2a170e61f5f436b536c155b438044cf0d0f24b94b4c034ad22b3eae824998243", + "0x0916011d547d7a54929c3515078f4f672c6b390ccdd4119f0776376910bc5a38da1a059ed9c504fadcc9f77e8a402175743bee1f5be27b7002b0f6c5b51070452c", + "0x09017285edc268d979eb410b46627e541afda16cdb3577ce04c15dc14cc6609c60143f0c01e71e99b2efbe3d8e62a2c812889aa9fd88dd4b0ed8eadcf1ec9b096a", + "0x0922901e65200b007ad8e1b972e90403b336e459e0cf9b9d68732da345b1b0f6872c9e3f3edacbd857b26d0a66a80aa56c6ebaa9849e9ea5a2b17fd59cabe138e4", + "0x091b77a00164a72880eec6c18fc043fa99f922e20bbee156e1ebfd3a358bee6bbb24d97cfaa234befe197a567476cade91b7d97a1017b8d5286dae4dddadffe1cd", + "0x09216f1c4d67a9a428885bb8d978ad369d2d69d4dcc1692c3a0c3ea05da7d6f0ac2d6dda722e76eb513c67718e7be0478851758be5547322473a53b5b2b67faf95", + "0x091f56c6f18ceb7077125df1ed17a42a85956090594125c1b182161de20f8af6aa2e36977412f9ea2ad2c0951153969eca8408317558ff1b6b4ad731726235f606", + "0x092ca197dda6c519d80296f4fcda2933df9608ec684ad000133259024041d070812d29b058a998cf7ffc647b2739041725d77889f58953799c6aba6d9e5b981fc8", + "0x091c25a87d321a09ad2a149d1a7eaa77727c7feffb4c39caf44f8edd4377f7bd0c16d1091494d3c90d301c1cb4596692798e78e4cc3d53c3a08e2641de43f9da18", + "0x092166058c98245eb85b08da1c569df11f86b00cc44212a9a8ee0d60556d05a8030942c68b535651e11af38264ecc89e5f79b66c3d9ce87233ad65d4894a3d1c3d", + "0x0908c3b13b7400630170baec7448c7ec99fa9100cad373e189e42aca121e2c8f450f9e40d92d98bb0b1286a18581591fddfa8637fc941c1630237293d69e5cb98f", + "0x091362d251bbd8b255d63cd91bcfc257b8fb3ea608ce652784e3db11b22ca86c0122a0068fa1f1d54f313bed9fd9209212af3f366e4ff28092bf42c4abebffe10a", + "0x081d67961bb431a9da78eb976fabd641e20fbf4b7e32eb3faac7dfb5abb50f1faf1438d77000c1cf96c9d61347e1351eb0200260ebe523e69f6e9f334ec86e6b58", + "0x0819324d2488778bdef23319a6832001ee85f578cc920670c81f3645f898a46ec62e00385c4416ca4ccbab237b13396e5e25e5da12101021c6a6f9ecfe7c7fed19", + "0x041421380c36ea8ef65a9bdb0202b06d1e03f52857cdfea3795463653eaa3dd7d80101000000000000000000000000000000000000000000000000000000006239b5a2c000208391082587ea494a8beba02cc40273f27e5477a967cd400736ac46950da0b378", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], }, { - block: 95216, - desc: "contract with empty storage node", - account: "0xb75d7e84517e1504c151b270255b087fd746d34c", + // curl -H "content-type: application/json" -X POST --data '{"id":0,"jsonrpc":"2.0","method":"eth_getProof","params":["0x5300000000000000000000000000000000000004", ["0x0000000000000000000000000000000000000000000000000000000000000002"], "0x1111ad"]}' https://rpc.scroll.io + block: 1118637, + desc: "WETH.totalSupply", + account: "0x5300000000000000000000000000000000000004", storage: "0x0000000000000000000000000000000000000000000000000000000000000002", - expectedRoot: "0x2dc794537b959b575dc216cd11389d802f9389fce7183278561a824aa8e950e2", + expectedRoot: "0x1334a21a74914182745c1f5142e70b487262096784ae7669186657462c01b103", + expectedValue: "0x0000000000000000000000000000000000000000000000600058d1a5ce14104d", + accountProof: [ + "0x0907d980105678a2007eb5683d850f36a9caafe6e7fd3279987d7a94a13a360d3a1478f9a4c1f8c755227ee3544929bb0d7cfa2d999a48493d048ff0250bb002ab", + "0x092b59a024f142555555c767842c4fcc3996686c57699791fcb10013f69ffd9b2507360087cb303767fd43f2650960621246a8d205d086e03d9c1626e4aaa5b143", + "0x091f876342916ac1d5a14ef40cfc5644452170b16d1b045877f303cd52322ba1e00ba09f36443c2a63fbd7ff8feeb2c84e99fde6db08fd8e4c67ad061c482ff276", + "0x09277b3069a4b944a45df222366aae727ec64efaf0a8ecb000645d0eea3a3fa93609b925158cc04f610f8c616369094683ca7a86239f49e97852aa286d148a3913", + "0x092fb789200a7324067934da8be91c48f86c4e6f35fed6d1ce8ae4d7051f480bc0074019222c788b139b6919dfbc9d0b51f274e0ed3ea03553b8db30392ac05ce4", + "0x092f79da8f9f2c3a3a3813580ff18d4619b95f54026b2f16ccbcca684d5e25e1f52912fa319d9a7ba537a52cc6571844b4d1aa99b8a78cea6f686a6279ade5dcae", + "0x09249d249bcf92a369bd7715ec63a4b29d706a5dbb304efd678a2e5d7982e7fa9b202e3225c1031d83ab62d78516a4cbdbf2b22842c57182e7cb0dbb4303ac38c5", + "0x0904837ebb85ceccab225d4d826fe57edca4b00862199b91082f65dfffa7669b90039c710273b02e60c2e74eb8b243721e852e0e56fa51668b6362fd920f817cb7", + "0x090a36f6aabc3768a05dd8f93667a0eb2e5b63d94b5ce27132fb38d13c56d49cb4249c2013daee90184ae285226271f150f6a8f74f2c85dbd0721c5f583e620b10", + "0x091b82f139a06af573e871fdd5f5ac18f17c568ffe1c9e271505b371ad7f0603e716b187804a49d2456a0baa7c2317c14d9aa7e58ad64df38bc6c1c7b86b072333", + "0x0929668e59dfc2e2aef10194f5d287d8396e1a897d68f106bdb12b9541c0bab71d2bf910dea11e3209b3feff88d630af46006e402e935bc84c559694d88c117733", + "0x0914231c92f09f56628c10603dc2d2120d9d11b27fa23753a14171127c3a1ee3dd0d6b9cbd11d031fe6e1b650023edc58aa580fa4f4aa1b30bf82e0e4c7a308bb9", + "0x0914c1dd24c520d96aac93b7ef3062526067f1b15a080c482abf449d3c2cde781b195eb63b5e328572090319310914d81b2ca8350b6e15dc9d13e878f8c28c9d52", + "0x0927cb93e3d9c144a5a3653c5cf2ed5940d64f461dd588cd192516ae7d855e9408166e85986d4c9836cd6cd822174ba9db9c7a043d73e86b5b2cfc0a2e082894c3", + "0x090858bf8a0119626fe9339bd92116a070ba1a66423b0f7d3f4666b6851fdea01400f7f51eb22df168c41162d7f18f9d97155d87da523b05a1dde54e7a30a98c31", + "0x0902776c1f5f93a95baea2e209ddb4a5e49dd1112a7f7d755a45addffe4a233dad0d8cc62b957d9b254fdc8199c720fcf8d5c65d14899911e991b4530710aca75e", + "0x091d7fde5c78c88bbf6082a20a185cde96a203ea0d29c829c1ab9322fc3ca0ae3100ef7cba868cac216d365a0232ad6227ab1ef3290166bc6c19b719b79dbc17fc", + "0x091690160269c53c6b74337a00d02cb40a88ea5eba06e1942088b619baee83279e12d96d62dda9c4b5897d58fea40b5825d87a5526dec37361ec7c93a3256ea76d", + "0x091bccb091cde3f8ca7cfda1df379c9bfa412908c41037ae4ec0a20ce984e2c9a51d02c109d2e6e25dc60f10b1bc3b3f97ca1ce1aa025ce4f3146de3979403b99e", + "0x0927083540af95e57acba69671a4a596f721432549b8760941f4251e0dd7a013a917cee0f60d333cf88e40ae8710fb1fd6e3920346a376b3ba6686a4b2020a043e", + "0x082170b57b8f05f6990eec62e74cdb303741f6c464a85d68582c19c51e53f490000a5029a62ddc14c9c07c549db300bd308b6367454966c94b8526f4ceed5693b2", + "0x0827a0b16ef333dcfe00610d19dc468b9e856f544c9b5e9b046357e0a38aedaeb90000000000000000000000000000000000000000000000000000000000000000", + "0x06126f891e8753e67c5cbfa2a67e9d71942eab3a88cde86e97a4af94ea0dde497821fb69ccdb00e6eaeaf7fc1e73630f39f846970b72ac801e396da0033fb0c247", + "0x0420e9fb498ff9c35246d527da24aa1710d2cc9b055ecf9a95a8a2a11d3d836cdf050800000000000000000000000000000000000000000000000016ef00000000000000000000000000000000000000000000000000000000000000600058d1a5ce14104d0dedcaecaab39b6e22c2608e40af67a71908e6e97bbf4a43c59c4537140c25a9e8c4073351c26b9831c1e5af153b9be4713a4af9edfdf32b58077b735e120f14136a7980da529d9e8d3a71433fc9dc5aa8c01e3a4eb60cb3a4f9cf9ca5c8e0be205300000000000000000000000000000000000004000000000000000000000000", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", + ], + storageProof: [ + "0x09240ea2601c34d792a0a5a8a84d8e501cfdfdf2c10ef13ea560acac58661882dd1b3644d1d4f3e32fc78498a7ebeffac8c6a494ac6f36923ef1be476444c0d564", + "0x0912af3ac8f8ea443e6d89d071fccaa2b3c8462220c1c2921234f613b41594f08f2a170e61f5f436b536c155b438044cf0d0f24b94b4c034ad22b3eae824998243", + "0x0916011d547d7a54929c3515078f4f672c6b390ccdd4119f0776376910bc5a38da1a059ed9c504fadcc9f77e8a402175743bee1f5be27b7002b0f6c5b51070452c", + "0x092293af71b7b9315c32d08f06e291b85e3b3dbba786dd31952369f666281aa21125ab35feae70aaca9349f6af48f7dcf2dee0324e4eae03e929963e7728b633a3", + "0x090607033a4b976c1e4683298d66b88a95ed45033ff43dea0670d84a8c42d35bf12562869385c0e70f561f18be4b78e7276b837f140a45ab12ffef1ba4ad5faecb", + "0x090abc5f713c2f58583114bb5081d00cbd01789d8efbd95e471b151c71c475142f0f52ad30f8a63288eb9dd12aca2a670de08c03f8384f55d730c943e1c472625b", + "0x0905156e8704d6195f6ae562aed2072f4e32422c6dfd4840ca354b9c4d2de5ce760fca52b1e0689ad374bae9fbea262a929f919695149a083fe6bacb806dc02fca", + "0x0917078d4c193a3fdbfe8ce3a235a0e1df89e626b5e91636097e299883fc2447892ad46eefbb27909544fe02c05e29760315749f6ce21c17c52158f5f5616c2dad", + "0x0917d02e5da8bdb969149c9327b247a6aaa479bcda4a03665da5103c10e616d2f40ccabdacdd25b34235d26e50e7af5d8d312a2cafdcadd41cc589a71a322f254c", + "0x090c62f5c476c1def8ed8a8c25ae54581690b39dfab4b0f3f78b93df96f626714328ea922a76a058087563bb5370664e9a1cebe3062f2d904bf5e3a018219d6563", + "0x091e481971f770e587b1f62f1da9ac4687abc5b2a23097fc38332e15ab957ca0ab0ec0a95c15313887e0d2f166c100deaf17f2ce50767680e6e5b2e3068801c0cd", + "0x0911799e186f1bd299dfa08c07404b9d28e2b179fb6ad523f1846872537b6db85f198b573ac1397048258de38b391fcc5e0c86a0f81f4ca607785fb37041ab8b4d", + "0x092053a028cf3bfcdabcb58985efc39f078cb0bcae4439528a0b6fe4b24bbdbd2c019a04a54e9e96077f3c2c39c1602a83387018b6357ea4c28e96764865d1c8f3", + "0x07303fad3e4628ccae4de1adb41996c9f38b22445b6525ff163b4c68cbde275b1a06111cae9b4d17b730d94f589e20c6ae2cb59bf0b40ad05bf58703ee6d46eac4", + "0x0606bc3fca1f1b3c877aa01a765c18db8b0d7f0bc50bd99f21223055bf1595c84d04fdc0fd416d8402fde743d908d032a20af6f2e65cdc6cc289f72c04f1c2476f", + "0x04020953ad52de135367a1ba2629636216ed5174cce5629d11b5d97fe733f07dcc010100000000000000000000000000000000000000000000000000600058d1a5ce14104d200000000000000000000000000000000000000000000000000000000000000002", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", + ], + }, + { + // curl -H "content-type: application/json" -X POST --data '{"id":0,"jsonrpc":"2.0","method":"eth_getProof","params":["0x5300000000000000000000000000000000000004", ["0x0000000000000000000000000000000000000000000000000000000000002222"], "0x1111ad"]}' https://rpc.scroll.io + block: 1118637, + desc: "random empty storage in WETH", + account: "0x5300000000000000000000000000000000000004", + storage: "0x0000000000000000000000000000000000000000000000000000000000002222", + expectedRoot: "0x1334a21a74914182745c1f5142e70b487262096784ae7669186657462c01b103", expectedValue: "0x0000000000000000000000000000000000000000000000000000000000000000", accountProof: [ - "0x001988ce414103e97cb80613adde47d5fe0611b30087d1cfcdb84284c42907467e24ac744be2edcb86cdfc42a9bbb7b2a270649161c3ce3a41d3ad5a26927d2c79", - "0x0028db7c407cab6652f1f194401bd87bda33c9a1723b4f93515bd5929cad02668123fa5a3e69136c8e03a62c805f89c9d3578a6f5fac4bb281fc4d7df12fbcc5db", - "0x0006801926f00b574e3a88162d192482fecba9918b77e133dd77587d9efaf5c7861712d244ac8ad4bc0bffe0dbe8ab261865c9a69b4b7769e9c188ec048460ce78", - "0x002f3161746c2c70c7cefb74c07bc16b28bd9011343f5c6f8756471cd0b184601a25d05d5447a572452964b3c20f40ef841bf313c958e82a6923584e20496df67f", - "0x000efef3e3e174da6f3f451b5a2652d2489fff449a217c10841e68e4a15995d6521c4b1552c592020fbc7219c5d67ff00bd630db8102ce5c6ca12bea29b80ba5e5", - "0x0019b4749b17792c0ad9f7b460a0faf35400da9423be38ac5c40e81c805acc72592c0b933e1c25d05db98d98fc4f04b27610b2ee88281126099aed42f27cd96b00", - "0x002b8d563c5041f28afa38da01b6ec9e7278250be79f7f55e2586955e75ab75fad2055ea72cd44209c41c94ddfb980fe5b007b3e997085bc1fe5b514f72f860c05", - "0x001335698617876fcc272740f765d53d53ee511dc9dc33965aaa0a5584f2f0fc02274c435ba9cc0fd5b897350de8cc1837d3a2baaa54ef3f9c66f689f20eddaf1a", - "0x0010f766b8dbe13e3f27f45da3ad7e5c31fd1c11c51f4f892851519182cdc9348921c10d83a16e057f99623dcd68ab28a78e48b655df756245631521d04e85e583", - "0x002bb5fce9df47073438d61ee438d900ab4ab01ac7f053e57c6ffe3e8f1746285016a600e6b7ee90281bbc3bd9b9523a663261cda2208ae98efcf76df8c965fb76", - "0x002cad2eb5194b59d880565b03cd667a842923c1310a60bd818685c8fe4120d86817ee8bfffdb490f78f23d6fb38bb1c27f10f877c5017b8b2c21ad14f23df0eab", - "0x001f064044ca94d6f30ef93ee1bb6ae35450acf1c8f5b113b0f0ff39e4b65cfb9a25141ae7fc30c69000991e65c626c1b12fb76bca02c68f8116d15698a5934b71", - "0x0014382fa3481f424cc33c39f77fd3df54c5951be347c629ab5baec238e46cab050b2b8bec8ebdbc97dd6c0ab867aae5746e51b69b7b8177c96dbc0c4531521d3e", - "0x0011941db7a46d1a3ddbd27a4a57a0ce1865b6e224552b233d9d545745489257f408c8e3a0a147e117dbb89827018a2df52d124cee29e82b15643e4877cabe4d06", - "0x0000d7b8f99e5f148297bf4bf7e5133f87dbdf1932dbb152e0cb14c472c7d26f26146c4f72b903bb98b0855c1ca5bef4bada14a773dcda341d10402004e999d757", - "0x0104eeb1fce36df4d3f6423137af3855d16bc936184295529c58682bb5217d64d905080000000000000000000000000000000000000000000000000867000000000000000130644e72e131a029b85045b68181585d2833e84879b96ea2850beb8e012d423615fd9926356a5b1f3a4599c7cccd6df3b45097b6527756e572b90fc8c40496f831f2125c021fb94759cb1993a2f07eae01792311e13f209441ff8969cf1eb8351cafbbe8f01ed4c292d9a27be523919a274441a076b20c7d713d192dbe6485c220b75d7e84517e1504c151b270255b087fd746d34c000000000000000000000000", + "0x0907d980105678a2007eb5683d850f36a9caafe6e7fd3279987d7a94a13a360d3a1478f9a4c1f8c755227ee3544929bb0d7cfa2d999a48493d048ff0250bb002ab", + "0x092b59a024f142555555c767842c4fcc3996686c57699791fcb10013f69ffd9b2507360087cb303767fd43f2650960621246a8d205d086e03d9c1626e4aaa5b143", + "0x091f876342916ac1d5a14ef40cfc5644452170b16d1b045877f303cd52322ba1e00ba09f36443c2a63fbd7ff8feeb2c84e99fde6db08fd8e4c67ad061c482ff276", + "0x09277b3069a4b944a45df222366aae727ec64efaf0a8ecb000645d0eea3a3fa93609b925158cc04f610f8c616369094683ca7a86239f49e97852aa286d148a3913", + "0x092fb789200a7324067934da8be91c48f86c4e6f35fed6d1ce8ae4d7051f480bc0074019222c788b139b6919dfbc9d0b51f274e0ed3ea03553b8db30392ac05ce4", + "0x092f79da8f9f2c3a3a3813580ff18d4619b95f54026b2f16ccbcca684d5e25e1f52912fa319d9a7ba537a52cc6571844b4d1aa99b8a78cea6f686a6279ade5dcae", + "0x09249d249bcf92a369bd7715ec63a4b29d706a5dbb304efd678a2e5d7982e7fa9b202e3225c1031d83ab62d78516a4cbdbf2b22842c57182e7cb0dbb4303ac38c5", + "0x0904837ebb85ceccab225d4d826fe57edca4b00862199b91082f65dfffa7669b90039c710273b02e60c2e74eb8b243721e852e0e56fa51668b6362fd920f817cb7", + "0x090a36f6aabc3768a05dd8f93667a0eb2e5b63d94b5ce27132fb38d13c56d49cb4249c2013daee90184ae285226271f150f6a8f74f2c85dbd0721c5f583e620b10", + "0x091b82f139a06af573e871fdd5f5ac18f17c568ffe1c9e271505b371ad7f0603e716b187804a49d2456a0baa7c2317c14d9aa7e58ad64df38bc6c1c7b86b072333", + "0x0929668e59dfc2e2aef10194f5d287d8396e1a897d68f106bdb12b9541c0bab71d2bf910dea11e3209b3feff88d630af46006e402e935bc84c559694d88c117733", + "0x0914231c92f09f56628c10603dc2d2120d9d11b27fa23753a14171127c3a1ee3dd0d6b9cbd11d031fe6e1b650023edc58aa580fa4f4aa1b30bf82e0e4c7a308bb9", + "0x0914c1dd24c520d96aac93b7ef3062526067f1b15a080c482abf449d3c2cde781b195eb63b5e328572090319310914d81b2ca8350b6e15dc9d13e878f8c28c9d52", + "0x0927cb93e3d9c144a5a3653c5cf2ed5940d64f461dd588cd192516ae7d855e9408166e85986d4c9836cd6cd822174ba9db9c7a043d73e86b5b2cfc0a2e082894c3", + "0x090858bf8a0119626fe9339bd92116a070ba1a66423b0f7d3f4666b6851fdea01400f7f51eb22df168c41162d7f18f9d97155d87da523b05a1dde54e7a30a98c31", + "0x0902776c1f5f93a95baea2e209ddb4a5e49dd1112a7f7d755a45addffe4a233dad0d8cc62b957d9b254fdc8199c720fcf8d5c65d14899911e991b4530710aca75e", + "0x091d7fde5c78c88bbf6082a20a185cde96a203ea0d29c829c1ab9322fc3ca0ae3100ef7cba868cac216d365a0232ad6227ab1ef3290166bc6c19b719b79dbc17fc", + "0x091690160269c53c6b74337a00d02cb40a88ea5eba06e1942088b619baee83279e12d96d62dda9c4b5897d58fea40b5825d87a5526dec37361ec7c93a3256ea76d", + "0x091bccb091cde3f8ca7cfda1df379c9bfa412908c41037ae4ec0a20ce984e2c9a51d02c109d2e6e25dc60f10b1bc3b3f97ca1ce1aa025ce4f3146de3979403b99e", + "0x0927083540af95e57acba69671a4a596f721432549b8760941f4251e0dd7a013a917cee0f60d333cf88e40ae8710fb1fd6e3920346a376b3ba6686a4b2020a043e", + "0x082170b57b8f05f6990eec62e74cdb303741f6c464a85d68582c19c51e53f490000a5029a62ddc14c9c07c549db300bd308b6367454966c94b8526f4ceed5693b2", + "0x0827a0b16ef333dcfe00610d19dc468b9e856f544c9b5e9b046357e0a38aedaeb90000000000000000000000000000000000000000000000000000000000000000", + "0x06126f891e8753e67c5cbfa2a67e9d71942eab3a88cde86e97a4af94ea0dde497821fb69ccdb00e6eaeaf7fc1e73630f39f846970b72ac801e396da0033fb0c247", + "0x0420e9fb498ff9c35246d527da24aa1710d2cc9b055ecf9a95a8a2a11d3d836cdf050800000000000000000000000000000000000000000000000016ef00000000000000000000000000000000000000000000000000000000000000600058d1a5ce14104d0dedcaecaab39b6e22c2608e40af67a71908e6e97bbf4a43c59c4537140c25a9e8c4073351c26b9831c1e5af153b9be4713a4af9edfdf32b58077b735e120f14136a7980da529d9e8d3a71433fc9dc5aa8c01e3a4eb60cb3a4f9cf9ca5c8e0be205300000000000000000000000000000000000004000000000000000000000000", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], storageProof: [ - "0x000c180cb3d57f72eb405dfc667d167967e4709cf3722a87b4c924f78a1d8fa9e926d16eb1f4902f8ac7a48fdf98274c9c4061f9f14f783e2fb41ef50c53d5f8ad", - "0x000f78c968ee196c478c91d12a48edfde6c630d40203652c6420ff5aa3619549a4297615606d62866169d509f77c9cb38751ae282cafdc27caf891585b383b4795", - "0x000798716960783afdcfd0749aa3b316d6e3d6ec2724853e629b42b5a9a10208e02e5f5fe3d5b8b823d3481aa1e738a1a24d6d1a63116e0003044672d73a7df2e4", - "0x0014748f61c4954d239225204b4611d66384f08ef03db3da82957fd590ee00b6c92b873e4bd217f8dfb0fa29bca1087ac7bc29db616a6830ba456091bab772ac06", - "0x000a1c900952239e98f5f1a3009e623bf6cf533d3b0d6d13d28d04f0496761927c0be199ff86f081ebb1c413e850450a4cce01dfd2c455156d7abde31385ae2ab8", - "0x00028d4e89bc6ce55b5e6bba0f2f3758dafcdb4722e6c1a06f6faa8bae065bc8ae0644641c0ac696c265b3ec90889e3842c9a7a5902f1a5e807c5767ed49106982", - "0x001e8434bf68ee6077d88efb5449ad286455a522e63a6bce5544cf785b77a5842d041a4e324bc47aa8ae42b56446f687758a8091986b6d760fd283a9e097a64e3a", - "0x00250bc6ba916a2acb3ce53053a88be40b815fa749d144dc709a7a46a08361e83c05b2b5b05f45324ab921e04ae1278371ebe1e092203259f4e5306eb46ad50f8c", - "0x0011c208e2c536c37674b1ecafff0261146c326c939544781da7062bbd0ac2fbca246f5225dc41e9fc17fe531f5bdc3325620e4003b3310a2cf7e31011b19c68a2", - "0x001dc8d4177945ac89a3c61977ed787e50c9d8a0c5d85dd6b1409ec11213b324e6228005b222573db7882205be776a5bd2183944b6fcf63af604e31b9285bd010e", - "0x0014ba74da33d2ca27e3f78bc1bd052c2b92176ce4136df751a8229051de383c2b0c8994f02704420f1f84963281364401d00f6d5aa9b6f52135bd96159c1c3b9b", - "0x00188c7ee45a6c28fa7ad49a86206b70764066b1888b0de90e4410d7132a641f8b0eecbba072e28ed6705379104e30dd2557c47b30be7dd5e8c893b8a641d02701", - "0x0010fb29a3bb8191eb03bd345ad1995bf6a57f09929f72dc8a9c42435c2eef734b1d565bfc8ae78d6c1496f2bdfeadff6890e8ddef4c6b730a5ec8575344800c90", - "0x001b2abe5a1352c492c3ac47d2ff93896977a99a0783eedadc6246efc9b4e78ab408291f4e9234e4662a365f40090e1b323e3448fa2f6cdc9c929477095499c323", - "0x00083b5711eb1cbba5e79c53227057d4987a22dd22b5ef715bf21f558917f48b17027f174fd4ca77e412ca65a7fbf6151e4473fa909ea384c7687b45f860d0103a", - "0x00100158ee54f61ba5b093a43a348cfd202c87ba1533af2b24fc2f068de89a8d15100f3cc72c206d05d44db4272bd67db89bc6e5c86d7c1b03b40395ec4661595c", - "0x002a15c17fcf2a10c6d1bcbd59ae262f80ad33518d499059a668e115045069ef012788a404ba41b5f8a96f0b294d0ba91e65b1bf58eee74adb8e55ca12f22fdccc", - "0x00031177585837e616bc830056a4bd12821c9c779096df361ebe1d77379e96ff9e0000000000000000000000000000000000000000000000000000000000000000", - "0x02", + "0x09240ea2601c34d792a0a5a8a84d8e501cfdfdf2c10ef13ea560acac58661882dd1b3644d1d4f3e32fc78498a7ebeffac8c6a494ac6f36923ef1be476444c0d564", + "0x092fa31ba6c9b8f291512a582ab446daf7aa3787e68f9628d08ec0db329027d9001af83d361b481ed4b943d988cb0191c350b8efc85cfceba74afb60783488d441", + "0x092c2ec2d967208cb5088400d826b52113d606435be011b6c9f721f293fb12242515681c9016eb1c222dcdbeeeb9fd3a504caba892f4c1832741a2b17a7305598a", + "0x090c7fe825c29bf5df80c7101ff8a372ba4f7b2ac37c16a3bbda38cc1e38e682460499b7e5d21d3784f496e747140f465eb1a39a019d2be8baf13a5e39f359a4ed", + "0x092bb11ebbc7cd1e565b86498aecab16842ab3fa852c7943cfbc49ee4bc593b2f308a78e1bc555e07d36d5c812af57c18f67199197a52ff74bc4e32ca6b7fadf32", + "0x092fd1e042080801034c6d6c79d462016c74b97dfbb1272cf606e638911a08f21c02434541eeed6d66002c69042f9354211e40518316a2d98cc0da0f19fb1ea013", + "0x09024bd491ec707bc3e8bea6b2754f37b1e85903061aefabd945537eef2f4d38b4136b925b004d29603c5e6195e073322d27f0c6ea3fa1ea5c5b248ff60dda594c", + "0x09269e1f468bd9bbde77a13562645a80a77d26d801781ca95d385bd59ee1b0890b03694bf9043190620265bf0bc3baa4d82cc82302ae0bbf33cfa48b0ec9d5ab25", + "0x0924d8bf62b2a725684847208dc021d5aee9f3c8f14c14786bc9f93232dfd3e068120bb7d022bbb159b4b84bb9e36cd2fcd89d761e265c1b88c8bdb9745a51cb22", + "0x092680f932920fd86de0b417cfdbeb2836a470213097ed5abb1a2b4deba8437f6825fd0ec614b97e6cfa4d50b08ad1e0fd8a5cd72db3a468128d1045d6a54e5e6e", + "0x0909e630914cee4db538057a0218a72288b88b2603aee0f805254b865a03de87c92ce46c1aa77ee8c42bb60c4175826f4dbb89d6282c01ff3de654c961599e66c3", + "0x091a17302d53ad1b7a4472d111fd27b35720d49ce27259b5e42f46339dddf235e82b973c29f44cf69b589f724d7d2fa54bf38b37bde3fc66c0d965a8c10df80caa", + "0x0916572156ae22ae2b0bc84ff41d16668be7163da26db2b13b86c218e0516c97a4131b584b7192464dde26060f66f678b03c8db8f64f1cd7a1f98a22a90cce5850", + "0x092c6ee2ca598c123445bbbd403ca3ab8a95ce2443f941ebdcf7bb035e2a3e38e22e8d5b222a1019b126f0ecf277c7fed881413e879cd4dc5df66634b6e9fb688d", + "0x0700000000000000000000000000000000000000000000000000000000000000002822301c27c0bd26a8f361545a09d509a2feed981accf780de30244f0300321d", + "0x05", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], }, { - block: 95216, - desc: "contract with no storage", - account: "0x9c0fc47d9346e2be1e24f6cef76149779fe52715", - storage: "0x0000000000000000000000000000000000000000000000000000000000000000", - expectedRoot: "0x2dc794537b959b575dc216cd11389d802f9389fce7183278561a824aa8e950e2", + // curl -H "content-type: application/json" -X POST --data '{"id":0,"jsonrpc":"2.0","method":"eth_getProof","params":["0x5300000000000000000000000000000000000044", ["0x0000000000000000000000000000000000000000000000000000000000000000"], "0x1111ad"]}' https://rpc.scroll.io + block: 1154766, + desc: "random empty storage in some contract", + account: "0x226D078166C78e00ce5E97d8f18CDc408512bb0F", + storage: "0x0000000000000000000000000000000000000000000000000000000000000001", + expectedRoot: "0x1e5cf13822e052084c315e944ca84f1ef375583e85e1508055123a182e415fab", expectedValue: "0x0000000000000000000000000000000000000000000000000000000000000000", accountProof: [ - "0x001988ce414103e97cb80613adde47d5fe0611b30087d1cfcdb84284c42907467e24ac744be2edcb86cdfc42a9bbb7b2a270649161c3ce3a41d3ad5a26927d2c79", - "0x0007af09eec4d7cc8903e99bd9fb9b8e57c30b0c3e34b17da769b01a9a1b943f391c4537228dbbfd7e7cce02123416bfdd61fb83577725516123b569eafcd8087d", - "0x0013a22efa6a843f6de1925fce2f6a83c7ed307182b16f661d0e7a8046561999393050830a440d2506adf42ccedece4e3aadc6bc80cea20fc1d8ed9e9c61597da0", - "0x001056a19427eac81b91de5db696812b3a0384bf41b37a12e9cbb7dc62404a102a1465c13c8d3721e137a64d9e5ba1267ac418339b3648bfab5a2a86f2343c2b4d", - "0x000794d2c0e19bc86772c2d1a43d46de87ad221847bddcfdffa19dbd34f3c3a9b507c5f198eb63c18640af5eff5480830147639cec070d276b778f21677d22ce32", - "0x000b23d93f98ec6e3536ffcab6afc6e2eb9b73aeb573d288723350366c05469e2e23837ffea9235351ee533af680d14011825e098f81ce3f8f59e9f08deff05e3d", - "0x002ad200ac8be8275ef12b8aeaec526d2b5255128968a2cd2ff775cab14e2ec4e907f2e9b849239e0e94332a50ac9d97320c56ca718c5e023cacd69f80b4c97c86", - "0x00284be135a2d7f5822a7949189b90696df39b1b183206c764576bf457df4fd1560204a9fc6c0dc199eecb404acfcabf4a633916fc94d2790dcd34959809c2195d", - "0x00270c2cd154aea3b575a1c7d47c62576bbdce6bbc7ccf5682e7962cf6cb77f0d317fdbac10917644860584c3057c750df695f529189f90910c30f114257719990", - "0x00174956df87889921e2a6ddb257fa84508fd7ea22c5a622b84378678e781a2289053dc6b3c4f91335b64f4b170bfe70bb5e2e316227b329d2b1205e7c62c4f755", - "0x002f9284ded18b8f281841094a93cb55b95884eec55d8eaa759c6175ddb2e037111c63bcee8ccf544fff55c3e502270e574d1f0b6265c4c7c6f42db5061b0120db", - "0x00065fdf05e66407d26a36a49d042c9c5e8cebab3baa2d3fd1ae6e673c3636cf7e2d9dbf3781e3f26f06fb503638a8bf00882f58dc83500338df4b7e08a290a5fb", - "0x00138987046c770f02f5d8e7d073f6c055536450fa55ccd2a23957598b6070297926f3a0b645072c5bd5c15cdcf03a4474e94d760e3a76fb8714b20b9d74608823", - "0x00280e7f8e278e02e43843aaba5a9a722a89af0ece06b5892284f825974e1c1984185be1fda9b5322a4c41023127eee438849ea23390e6c2d4d9abdedb5a1a43fc", - "0x00208f32072c6e20863710406ad34339da1124c639941e935818dd9ad9419849c91e0e37873df7eb190a2846789df889bbfd522200e2a41423ff9ab0acf2592be0", - "0x0005fb23491fabbc9b3eead71117b86a27952e8fd4b3380336ac3f479832e94bad109a1b6dca757696b8831d2529ffda29f37af36f92fec738376df77561491083", - "0x0028baee42b4a9a70b7ec1e50ea1a6817f812082a28598dca106aaecf2761fb63c06e5b589490c27f5cfc233890456ec47a7365ff2882a27c73968f4829d011b05", - "0x001708247f7a96b84cad27c31985cd39b6cc9435b4ec3f4db9aeed3311c213de651e2f271ae0fa011e5e6fccd121492400327efb915c95d85956a9cd27ceb4321a", - "0x0000000000000000000000000000000000000000000000000000000000000000002332e856217b3bab09901f1daa9ddc91edf56964e03675d260d00ffdf6e2e715", - "0x000571dce6fee951f457db89bae18abbd78b6b06504602a103133d2a38cabf5f5b1ecb13b03e3493e217c65da70baf4c4fad74808110658924869ba0e75d0871db", - "0x001738a6461148300d30699edb55d3b5bb62760aeb9384c07d61aa062c401f3a7d0000000000000000000000000000000000000000000000000000000000000000", - "0x000c14152707412177bbe1cfed882d7d7bdfca4e96be701a3c41bb3d254491f0bf0096ebc25015b9a40d4fe7490bda8ecb7f3a01e858d7833dce8f1993be4db07d", - "0x0117294cb69b0984b3a26d77eae252f9d8e438808bf276ee8c0c0546b7316c9bca05080000000000000000000000000000000000000000000000000ab1000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ed3aa0dd2cd363d4cea5d5283ec359f75be36a12ceddc7f80a58af9d39a418a02b6a0ff9eb34bf0e52f67047f95556a96c4f40822412da0c8bd0340996a754f4209c0fc47d9346e2be1e24f6cef76149779fe52715000000000000000000000000", + "0x09062c633f6d7c7a157025fef8ab1c313a7caadda3a64b23664741f9de3b0478fe27571cf9b45d5f4deddf5f0b5354a613998fdcbe9249bb7cde92fd45513c5a99", + "0x0920d6877efe14060018278754e91682430401880981fec1cd1b63610bed0c1e332a63aca7a8898b01983e2c53a7257310318da444fd6c8b705e488943205301a8", + "0x090f6dadd53bbc0f5fa4fa03961aff0bf252ae335e11c1836253b6bc214d66759010b10d80991219a66f1eb7e07169b4cec4fa74b04edbdc08c3f238dfdf1d2fac", + "0x0921ea10af71b5f3587ff9d42178a151427cbcde37b8bee6575463bf6b83110cca0520d5f97b44e7015453ec16d9c28980d2cec3df5c860eb8a455f49dcfa339be", + "0x092d19cf96a7c129aac6f72f780703a9ef3233fc5124d592baee751a3550dd692a02c962b87efbba5aeea4856c3df29c1ea540e1fbc7a74529d5dc793fe8e490d8", + "0x0922e20a087e600560007189ccc1a159e4fffeb1876a6de3772b7f450793a1c6620ada74791f3ecd25a650701578ef9661c64e75d836c681503e96228974a53903", + "0x0924839671b636ebb56cb9a2860a3edf2a2875774e84dfcf8546135189f808d724260ac8be541ff088a9a1d2468c4c6e2faa793009be553a3cbca003649ee511db", + "0x090cd8140d844f62e44ffe820c1b2b0d4aa8f0518c15ff61759d93d805cb017cb628d5b46a4c4ec0a10eb00155808890925050f7af2279b512c25005d963283262", + "0x0913c0698673b0be011485eba05c61ac41bf14fc960ce5dbb6f5a021809eabbb0e18adaf85a3724e1a644268b845f5014b39e574928b9a01bfcd25d6fe1cf03e8f", + "0x0912c2e7da4b091c52e0012e5c13baf07d9d9daed10a558262d2e700a7c823300e054dce1849561bbeede4368a3be06f5a2bae06bdb1bc2bcefdba84634fd1991c", + "0x090b3e9c665497a0f9c1d3f1448c6d9144a287eb0accf86fea6f443f51986df7130392814f078a19643081787478ec3a010e2757a574877a194136c529813cf7ae", + "0x09249a0e273abe79a0b99a55516e19213191b7f77ef34f8815edc4e1ede8711f7920615adbac1983d844c8a6ed50922562432c13d030069d8b3e92611b4fe39531", + "0x09199575893e55d92fafb3b067130b9b6b5a46e7f6fb2d0af412d12591632dfe961adffb9dd1e7490095aac94bc1fcaeb591f4ba907fe2b882c9f6d8f7ab3a1809", + "0x09259308e9398f029ebbe31a4b353f474622b4c96995b7365c3b13c392fcc3e7001be60286a497a3886aa9cff3ad6a5dc71504078eb7a44c43530b7b33eef4743f", + "0x090709a21aaf18a1eaea3b925ab36f47a82095aa3e9ddbc4f01463005c4b64f6af0554d854637fcbfd9b1a4c2474de343950569e4f855d66f2ee14fcfb19ee17f5", + "0x092d7319be75a70b8ea5f0acc6ab4a96971ec546f72b18bdc3e905ad6ea8a288f70626499aee389335559b1dd3cc8b6711f9fde0c517236190cba24fa87993877a", + "0x09081b165a51e3081fc2e3e27d6fdb81134b65284851798de62899db3065a8c1fc040c8dce92508a510c2c34fc2949910dd41247c9f247cd216c03d9bb9d2881b4", + "0x092a27c5be32e1ab6e85d1ac094bc1509d92285f45c63fca6dba9b14d485a94af326d44c1ff85666a4790182ddd7e51cbbe06af81d62082e6d79faec29a4501369", + "0x091a46df6ffd6b439ffcd1b57e9548f5c4db26ade9e984efc8a91a01ab22134d3c1617b504ac2015793c5dac16d379b5ca6cb70c14243491bb68535ee686a3a553", + "0x08180e90f9f9a4fd8065a5849539793bd9e9340b69770eff1716a733241e454c341641f913f1c32e2c652b876f902e5c2c8d51c482411ec44dae969bdc50264c42", + "0x06273c162ecb059cd86ec0a01033dd61c39f59ee0a13eb41a28c0b2d49a45f6f94081be344adea9f54587a832b9efef6fc9ec010d86ec5fb2b53b5ff8dbabc4924", + "0x040b792f5b15327fc37390341af919c991641846d380397e4c73cbb1298921a546050800000000000000000000000000000000000000000000000000fb0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000be74cc05824041ef286fd08582cdfacec7784a35af72f937acf64ade5073da10889249d61c3649abf8749bf686a73f708d67726fada3e071b03d4541da9156b20226d078166c78e00ce5e97d8f18cdc408512bb0f000000000000000000000000", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], storageProof: [ - "0x02", + "0x05", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], }, { - block: 95216, - desc: "EOA with balance", - account: "0x0384a6f7e2588bb251688f9ab8d10932a98e9f28", + // curl -H "content-type: application/json" -X POST --data '{"id":0,"jsonrpc":"2.0","method":"eth_getProof","params":["0xC73BfBD94fb1FD860997D4E76D116BDE0333BeEf", ["0x0000000000000000000000000000000000000000000000000000000000000000"], "0x2a7531"]}' https://sepolia-rpc.scroll.io + block: 2782513, + desc: "contract with only one storage entry", + account: "0xC73BfBD94fb1FD860997D4E76D116BDE0333BeEf", storage: "0x0000000000000000000000000000000000000000000000000000000000000000", - expectedRoot: "0x2dc794537b959b575dc216cd11389d802f9389fce7183278561a824aa8e950e2", - expectedValue: "0x0000000000000000000000000000000000000000000000000000000000000000", + expectedRoot: "0x13c6008daf17807163a056504e562d4adf13870306814b1a3877cda5297d5ae9", + expectedValue: "0x000000000000000000000000000000000000000000000000000000000000000c", accountProof: [ - "0x001988ce414103e97cb80613adde47d5fe0611b30087d1cfcdb84284c42907467e24ac744be2edcb86cdfc42a9bbb7b2a270649161c3ce3a41d3ad5a26927d2c79", - "0x0028db7c407cab6652f1f194401bd87bda33c9a1723b4f93515bd5929cad02668123fa5a3e69136c8e03a62c805f89c9d3578a6f5fac4bb281fc4d7df12fbcc5db", - "0x0006801926f00b574e3a88162d192482fecba9918b77e133dd77587d9efaf5c7861712d244ac8ad4bc0bffe0dbe8ab261865c9a69b4b7769e9c188ec048460ce78", - "0x002f3161746c2c70c7cefb74c07bc16b28bd9011343f5c6f8756471cd0b184601a25d05d5447a572452964b3c20f40ef841bf313c958e82a6923584e20496df67f", - "0x0007602275f17f6c339ec3febc879c2ca72efa782ff1888b04553f82333eb0e60c068c8e4fe6da32f7f80a4acb50b690a7204581e5e4b8e9e7daa115dfcb466ae1", - "0x000cb512d4ab158b5e7d5852cc7531788f11e64e5959cc1233d7a64eaaca36426116fea9120cf06c241843db50d81978b402281dfe15ba7d8a8c689bfbe0b31a1a", - "0x002eb4fff0642f7be6d8e95793d9371d606df48efd0b62a7eb01b0a9669307be2b0ee7d01463afc3dac441f66e675ba06fec67b692e3f7a46510d096836468a3cb", - "0x0003ea09dc5b0ca3ce2961d3200c09b837ea535447e3ba45e5583dbb4e9db48b2208abfec237c907584104b11444f55fa3fa7e6f6a5954817ecea6361516f0271b", - "0x001c654478a700ac0414f5cd8da557e04f9570939802c3963e801523f001ebb4d916d301b50f89760520da2a662b03a207e9372902153ba84ef0f5438472f466c6", - "0x0009f3b0d95ec5d88cfc2db19520f43d110d12c757a58ae7f578095de96e5d319d2c8f43a67b0c01008670f07eb53071b835f19cbb45d6e76281a083087217d988", - "0x000348f024d617f64de7be803547c109b98f833b090e8a3dea0c2bed201ce752c12a4fb71f098941741c42e156651d8a42632e3acbf6f14cd9763b50216af75d61", - "0x0029f85b49319fe7dfced69a258b1baf213d638fe3082b9a13f38e553e9d3269333054c4cb6d1e91bc2dfced1559b58cd6474ac6583a1fc5a2bef5eaa7b96ecea0", - "0x000a4d19e2ec5f98d9ccdc1e94d9334668b87ea451195f9a8319b98cfdb077c5ce1adc64852505188363c7e98b83501e876862d8ffbd8b4051f3cb6dde7f0e8afe", - "0x002568d5d87f19b2b3f2b7341ee61fb45f56dc76734beaa4f1a9865b80b9d9a7d500a191ba054a28841f25c34ad384817a2af2ebada6047517dbb2b6a1338e48c7", - "0x0027f6df1a3610c7447efd280fa6a949713456a1ba79b50dc7fb87c5cb3312b19311b3c9c4420874b02bdc1ea102dc77bb803c1a5042d565aea99054ae0eb816b2", - "0x0018a3d33e2c0d076ca4ddb093516d90cb8ba8b508e8d372d3a8a93aa9eef6079b138df6cb61c8f92dcbea8cd90ead1efa49f3a24f814c88a7bdca8fd83f4d0675", - "0x00268f3122e558d5084a1b3ffc293b67bd2436152fbee80566226d4a753b5b44c40b6d06e2f5f17009a7e146889c2f492b077a462d602e0e72f53373a154aa450e", - "0x0006c81bc9375fe1a0ebb75b151c8a321b85970c1a8a5aa7396a7076a4d6f26c8118a7e9e0987d7c6d0100180c9ba496db2b967f6acf7bc11d002314693416b3bf", - "0x011fb221b659992b8d98a645cb37666f934ded70f1f5d82dad67dace71d7191f8105080000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000d8d6f2b3da41cda2e0000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4702098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864200384a6f7e2588bb251688f9ab8d10932a98e9f28000000000000000000000000", + "0x09272d92cb48d19e41ef64be1da3e10026eb87d227132becb4fba0dd1451783de425f66c55ff0bec0b012e11d64aaaa6c322566d58cf45525cb05302132518f23d", + "0x0920908000907fe2260e41f8682510eee0572937459163ea1940c2eae8b2d5862e015e7c84f56f5948bfc9c242506d14f5c3c1b97bba1b262b40b108f5d7e69287", + "0x09078402c38a02e2b3dda819b761ca6448029f3dd42ae7876ac0dba0d762e3ddb818d80485f0a15f54f110aad9a98b00bdf9ccb56bbcb069552c7f6c10be1b9c15", + "0x09123243fe438606648fe3bcef5eb0165920315fb2b9316ce3ec0daac885577f190b84d9901fc150f52ed177f23ec31de4254b293c6eac2088009f3e13e3a08b78", + "0x09053c59663d3eafad212f58c4834090db4bfd0ba2b13d3108e0acade089a5da9229a75e0b30abc41d4fb252faf9f3aa8ef750b780247d83186cdc333635c25038", + "0x09163255ef0b1fdec7ec97c4e002cdeb6c963ca26d9d03ebdf78eb44dfdb57e4bd1fa9f68cc583c1e7019cc62133ede53e5636330de9a2c09e75f03760026e3729", + "0x09296d3cb1c4fd539ed015f2853649d20f5db111ce13c30b7e6efa4c9468741d1e0eea62adcf73aa5bdb4868cd776df429d26787f424beeda38f4ad19aa83e43e4", + "0x0908288df27fa423895de38ec5a52e809d99b683c5b32463501f5dad642b71387f0a3d37ae9df53b5cfdda0ac67765662e8a71a19b05d38f4a464596e129a35570", + "0x091a774fef4e8294fcca57d213846e51bfcf71249680e937e14248e532b47abd762ad72878f07f4abbba8bd13da9b75f681f35a748bb8fc078913e16a91bce783e", + "0x092799a146ba6b2bf4b6a24aef88c9590d9643d53f429438e348518a17af3d6e8d10e3b39898c3795c9386518438465581ca232445532fb549a8bddbdd6f4e0eed", + "0x0914c654d53c9f8656b784709decbd12ba786800a77c929f3b4255d59138b42dff282005f8997b73d64eeb112775885c4c08d2ee4e356cc2db58154dde48a0a1e4", + "0x091c71601a71f28ed0f6aeb59cf8a7bf29ce7dd3203352099920086e02007496260b811e85a0cd244d56f199b357d5c3a54f897fea21637698943679d07b33db8d", + "0x092a66de31cef7b4b195772a2b96edba3ca7d97a5bbe974d071c37f0d0ca0545be0be9ca0dd4c9d62ec3ba0a404713fefe6b62391ba3f6d283a47e83fdb18c3a4e", + "0x09093842042d196ae30784d31ed1526dd5d60cabe292eb5333e42936a2edbbaf1d237998efa424724063547c02cfa835ebfc24131315c34229b363f46fefda33ee", + "0x0911637da97122f89f421a4564d5328893ff4b5de123aecad06e07ea45d9622b87096a296e974b5eda0f2d35cb5531c4a55f3c1e181a8bb4a0b33399e7c93853d4", + "0x0921feeaba62a4ad78791d662737a3fa52a527dcd892f5d3af2cfbed4b6591d50f2fae639afb8ab4640a2d166616a4803442b26b9a8f5148a1c88adda1e2d911da", + "0x090ddbe424e9368f262ef80a144383fc4f518b27200f7a61a996a075b3b84ab5041c755907f230eea27d060fa827a5743c7046cd0dc7487047bc3a7d222d65d2d7", + "0x092d6e65349fd6751353b4b72fdd03d3ee4b1721efb434db76679c1c348b60fdc0177c7d961201138c98f85daf8a49b7a083a41e77dcd819d359b3db55c4a941a9", + "0x090b0d48518cb602b73a86bd7b2294d401e6ad4851e3c7549fc7d23eea017eadd72e3245236b50c7f256de16bae063df6221b8331443c9d3a79e867fd77dd85cee", + "0x07062bf32f202ec2afa65dfa84fffc76b5c05309768078544920f9b56d021606ce0b7371683425d088ad37f063ee847a9accac416314f1308cce69a8beeb2d2ab7", + "0x090ffc989b8556e69159e246cb74cf7a2e30df63e9b7dba76ede73996ab60d9799063ca19e1d436cea189d17c5d93b8da0fa11b3ee88de1030602d1e8087cbb3da", + "0x070000000000000000000000000000000000000000000000000000000000000000084f906a52b7da7bf35f3cc2431b40cfb90884c2ec0b579c9c096aea959509f7", + "0x0620b6c0072d699768c0b52df46b97dae979a14788ed54dad1d7ce67db6e036a07291784b726760c2d728e4084d95df6d1534e27284c8ae2eeb56a80210f37da2b", + "0x041245637ec55bae3c02f990e3cc3bf59cc05f515731cfa59ee55f8164953f8965050800000000000000000000000000000000000000000000000000ac000000000000000100000000000000000000000000000000000000000000000000000000000000000f68a43f5508e9c1f845406d9a507b612f97530746e59b93c8705f1a7cb0b93451e52f95aea13b1bc1f37dfbf797bfe7cea82a8c82da148f507e1ef2036fea8314b9fb07c4311e129d72b858c37b6bbe09c616f78416cb53d6e83360aff7b99c20c73bfbd94fb1fd860997d4e76d116bde0333beef000000000000000000000000", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], storageProof: [ - "0x02", + "0x041d3c5f8c36e5da873d45bfa1d2399a572ac77493ec089cbf88a37b9e9442842201010000000000000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000000", "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", ], }, @@ -195,13 +272,9 @@ describe("ZkTrieVerifier", async () => { beforeEach(async () => { const [deployer] = await ethers.getSigners(); - const Poseidon2Elements = new ethers.ContractFactory( - poseidonUnit.generateABI(2), - poseidonUnit.createCode(2), - deployer - ); + const PoseidonHashWithDomainFactory = new ethers.ContractFactory(generateABI(2), createCode(2), deployer); - const poseidon = await Poseidon2Elements.deploy(); + const poseidon = await PoseidonHashWithDomainFactory.deploy(); await poseidon.deployed(); const MockZkTrieVerifier = await ethers.getContractFactory("MockZkTrieVerifier", deployer); @@ -209,6 +282,17 @@ describe("ZkTrieVerifier", async () => { await verifier.deployed(); }); + const shouldRevert = async (test: ITestConfig, reason: string, extra?: string) => { + const proof = concat([ + `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, + ...test.accountProof, + `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, + ...test.storageProof, + extra || "0x", + ]); + await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).to.revertedWith(reason); + }; + for (const test of testcases) { it(`should succeed for block[${test.block}] desc[${test.desc}] account[${test.account}] storage[${test.storage}]`, async () => { const proof = concat([ @@ -224,193 +308,277 @@ describe("ZkTrieVerifier", async () => { }); } - it("should revert, when parent node invalid", async () => { + it("should revert, when InvalidBranchNodeType", async () => { const test = testcases[0]; - test.accountProof[0] = - "0x010a52b818e0a009930d62c17f2b1244179b7c14f8e1ae317fb3bfd3a3ba6060031b2a4aa2df31e79f926474987eea69aab84f4581cfd61b0338438110f6be145b"; - const proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid parent node"); + for (const i of [0, 1, test.accountProof.length - 3]) { + const correct = test.accountProof[i]; + const prefix = correct.slice(0, 4); + for (let b = 0; b < 16; ++b) { + if (b >= 6 && b < 10) continue; + test.accountProof[i] = test.accountProof[i].replace(prefix, "0x" + chars[b >> 4] + chars[b % 16]); + await shouldRevert(test, "InvalidBranchNodeType"); + test.accountProof[i] = correct; + } + } - test.accountProof[0] = - "0x000a52b818e0a009930d62c17f2b1244179b7c14f8e1ae317fb3bfd3a3ba6060031b2a4aa2df31e79f926474987eea69aab84f4581cfd61b0338438110f6be145b"; - test.storageProof[0] = - "0x010a52b818e0a009930d62c17f2b1244179b7c14f8e1ae317fb3bfd3a3ba6060031b2a4aa2df31e79f926474987eea69aab84f4581cfd61b0338438110f6be145b"; - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid parent node"); + for (const i of [0, 1, test.storageProof.length - 3]) { + const correct = test.storageProof[i]; + const prefix = correct.slice(0, 4); + for (let b = 0; b < 16; ++b) { + if (b >= 6 && b < 10) continue; + test.storageProof[i] = test.storageProof[i].replace(prefix, "0x" + chars[b >> 4] + chars[b % 16]); + await shouldRevert(test, "InvalidBranchNodeType"); + test.storageProof[i] = correct; + } + } }); - it("should revert, when hash mismatch", async () => { + it("should revert, when BranchHashMismatch", async () => { const test = testcases[0]; - test.accountProof[1] = - "0x0028db7c407cab6652f1f194401bd87bda33c9a1723b4f93515bd5929cad02668123fa5a3e69136c8e03a62c805f89c9d3578a6f5fac4bb281fc4d7df12fbcc5dc"; - const proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Hash mismatch"); + for (const i of [1, 2, test.accountProof.length - 3]) { + const correct = test.accountProof[i]; + for (const p of [40, 98]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.accountProof[i] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "BranchHashMismatch"); + test.accountProof[i] = correct; + } + } + } + + for (const i of [1, 2, test.storageProof.length - 3]) { + const correct = test.storageProof[i]; + for (const p of [40, 98]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.storageProof[i] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "BranchHashMismatch"); + test.storageProof[i] = correct; + } + } + } }); - it("should revert, when invalid proof magic bytes", async () => { + it("should revert, when InvalidAccountLeafNodeType", async () => { const test = testcases[0]; - test.accountProof[17] = - "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704448"; - const proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid ProofMagicBytes"); + const index = test.accountProof.length - 2; + const correct = test.accountProof[index]; + const prefix = correct.slice(0, 4); + for (let b = 0; b < 20; ++b) { + if (b === 4 || b === 5) continue; + test.accountProof[index] = test.accountProof[index].replace(prefix, "0x" + chars[b >> 4] + chars[b % 16]); + await shouldRevert(test, "InvalidAccountLeafNodeType"); + test.accountProof[index] = correct; + } }); - it("should revert, when invalid leaf node in account proof", async () => { + it("should revert, when AccountKeyMismatch", async () => { const test = testcases[0]; - // Invalid leaf node in account proof - test.accountProof[16] = - "0x000aef26efde9e4bca477d460482bce3de3577f6e9a280dea6d3f9985b4151deab0508000000000000000000000000000000000000000000000000071d0000000000000000000000000000000000000000000000000000000000000013328350573dd32b38291529042b30b83bf20bfc7e18ab6a9755e2ea692d5a7644f896b0d629cf9740d72ccbc90dd6141deb3fab132f1ebc17ab963c612c7123d5a524d0158cc8291b081281272d79459760d885ea652024615d55b114b5872571b21aee99977b8681205300000000000000000000000000000000000004000000000000000000000000"; - let proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid leaf node"); + const index = test.accountProof.length - 2; + const correct = test.accountProof[index]; + for (const p of [4, 10]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.accountProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "AccountKeyMismatch"); + test.accountProof[index] = correct; + } + } + }); - // Node key mismatch in account proof - test.accountProof[16] = - "0x010aef16efde9e4bca477d460482bce3de3577f6e9a280dea6d3f9985b4151deab0508000000000000000000000000000000000000000000000000071d0000000000000000000000000000000000000000000000000000000000000013328350573dd32b38291529042b30b83bf20bfc7e18ab6a9755e2ea692d5a7644f896b0d629cf9740d72ccbc90dd6141deb3fab132f1ebc17ab963c612c7123d5a524d0158cc8291b081281272d79459760d885ea652024615d55b114b5872571b21aee99977b8681205300000000000000000000000000000000000004000000000000000000000000"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Node key mismatch"); + it("should revert, when InvalidAccountCompressedFlag", async () => { + const test = testcases[0]; + const index = test.accountProof.length - 2; + const correct = test.accountProof[index]; + for (const replaced of ["01080000", "05010000"]) { + test.accountProof[index] = test.accountProof[index].replace("05080000", replaced); + await shouldRevert(test, "InvalidAccountCompressedFlag"); + test.accountProof[index] = correct; + } + }); - // Invalid leaf node hash in account proof - test.accountProof[16] = - "0x010aef26efde9e4bca477d460482bce3de3577f6e9a280dea6d3f9985b4151deab0508000000000000000000000000000000000000000000000000071e0000000000000000000000000000000000000000000000000000000000000013328350573dd32b38291529042b30b83bf20bfc7e18ab6a9755e2ea692d5a7644f896b0d629cf9740d72ccbc90dd6141deb3fab132f1ebc17ab963c612c7123d5a524d0158cc8291b081281272d79459760d885ea652024615d55b114b5872571b21aee99977b8681205300000000000000000000000000000000000004000000000000000000000000"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid leaf node hash"); + it("should revert, when InvalidAccountLeafNodeHash", async () => { + const test = testcases[0]; + const index = test.accountProof.length - 2; + const correct = test.accountProof[index]; + for (const p of [80, 112, 144, 176, 208]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.accountProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidAccountLeafNodeHash"); + test.accountProof[index] = correct; + } + } + }); - // Invalid KeyPreimage length in account proof - test.accountProof[16] = - "0x010aef26efde9e4bca477d460482bce3de3577f6e9a280dea6d3f9985b4151deab0508000000000000000000000000000000000000000000000000071d0000000000000000000000000000000000000000000000000000000000000013328350573dd32b38291529042b30b83bf20bfc7e18ab6a9755e2ea692d5a7644f896b0d629cf9740d72ccbc90dd6141deb3fab132f1ebc17ab963c612c7123d5a524d0158cc8291b081281272d79459760d885ea652024615d55b114b5872571b21aee99977b8681215300000000000000000000000000000000000004000000000000000000000000"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith( - "Invalid KeyPreimage length" - ); - - // Invalid KeyPreimage in account proof - test.accountProof[16] = - "0x010aef26efde9e4bca477d460482bce3de3577f6e9a280dea6d3f9985b4151deab0508000000000000000000000000000000000000000000000000071d0000000000000000000000000000000000000000000000000000000000000013328350573dd32b38291529042b30b83bf20bfc7e18ab6a9755e2ea692d5a7644f896b0d629cf9740d72ccbc90dd6141deb3fab132f1ebc17ab963c612c7123d5a524d0158cc8291b081281272d79459760d885ea652024615d55b114b5872571b21aee99977b8681205300000000000000000000000000000000000003000000000000000000000000"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid KeyPreimage"); + it("should revert, when InvalidAccountKeyPreimageLength", async () => { + const test = testcases[0]; + const index = test.accountProof.length - 2; + const correct = test.accountProof[index]; + for (const p of [396, 397]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.accountProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidAccountKeyPreimageLength"); + test.accountProof[index] = correct; + } + } }); - it("should revert, when storage root mismatch", async () => { + it("should revert, when InvalidAccountKeyPreimage", async () => { const test = testcases[0]; - test.storageProof[0] = - "0x000a52b818e0a009930d62c17f2b1244179b7c14f8e1ae317fb3bfd3a3ba6060031b2a4aa2df31e79f926474987eea69aab84f4581cfd61b0338438110f6be145c"; - const proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Storage root mismatch"); + const index = test.accountProof.length - 2; + const correct = test.accountProof[index]; + for (const p of [398, 438]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.accountProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidAccountKeyPreimage"); + test.accountProof[index] = correct; + } + } }); - it("should revert, when invalid leaf node in storage proof", async () => { + it("should revert, when InvalidProofMagicBytes", async () => { const test = testcases[0]; - // Invalid leaf node in account proof - test.storageProof[15] = - "0x0026ae15b478408eb45ea8b6f61aad1345f2b6257efd1acc4a6024b26f664c98240101000000000000000000000000000000000000000000000000000111346048bf18a14a209505174b0709a2a1997fe9797cb89648a93f17ce0096cbc1a6ed52b73170b96a"; - let proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid leaf node"); + let index = test.accountProof.length - 1; + let correct = test.accountProof[index]; + for (const p of [2, 32, 91]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.accountProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidProofMagicBytes"); + test.accountProof[index] = correct; + } + } - // Node key mismatch in account proof - test.storageProof[15] = - "0x0136ae15b478408eb45ea8b6f61aad1345f2b6257efd1acc4a6024b26f664c98240101000000000000000000000000000000000000000000000000000111346048bf18a14a209505174b0709a2a1997fe9797cb89648a93f17ce0096cbc1a6ed52b73170b96a"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Node key mismatch"); + index = test.storageProof.length - 1; + correct = test.storageProof[index]; + for (const p of [2, 32, 91]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.storageProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidProofMagicBytes"); + test.storageProof[index] = correct; + } + } + }); - // Invalid leaf node hash in account proof - test.storageProof[15] = - "0x0126ae15b478408eb45ea8b6f61aad1345f2b6257efd1acc4a6024b26f664c98240101000000000000000000000000000000000000000000000000000111446048bf18a14a209505174b0709a2a1997fe9797cb89648a93f17ce0096cbc1a6ed52b73170b96a"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid leaf node hash"); + it("should revert, when InvalidAccountLeafNodeHash", async () => { + const test = testcases[0]; + const correct = test.storageProof.slice(); + test.storageProof = [ + "0x05", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449", + ]; + await shouldRevert(test, "InvalidAccountLeafNodeHash"); + test.storageProof = correct; + }); - // Invalid KeyPreimage length in account proof - test.storageProof[15] = - "0x0126ae15b478408eb45ea8b6f61aad1345f2b6257efd1acc4a6024b26f664c98240101000000000000000000000000000000000000000000000000000111346048bf18a14a219505174b0709a2a1997fe9797cb89648a93f17ce0096cbc1a6ed52b73170b96a"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith( - "Invalid KeyPreimage length" - ); - - // Invalid KeyPreimage in account proof - test.storageProof[15] = - "0x0126ae15b478408eb45ea8b6f61aad1345f2b6257efd1acc4a6024b26f664c98240101000000000000000000000000000000000000000000000000000111346048bf18a14a209505174b0709a2a1997fe9797cb89648a93f17ce0096cbc1a6ed52b73170b97a"; - proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Invalid KeyPreimage"); + it("should revert, when InvalidStorageLeafNodeType", async () => { + const test = testcases[0]; + const index = test.storageProof.length - 2; + const correct = test.storageProof[index]; + const prefix = correct.slice(0, 4); + for (let b = 0; b < 20; ++b) { + if (b === 4 || b === 5) continue; + test.storageProof[index] = test.storageProof[index].replace(prefix, "0x" + chars[b >> 4] + chars[b % 16]); + await shouldRevert(test, "InvalidStorageLeafNodeType"); + test.storageProof[index] = correct; + } }); - it("should revert, when proof length mismatch", async () => { + it("should revert, when StorageKeyMismatch", async () => { const test = testcases[0]; - const proof = concat([ - `0x${test.accountProof.length.toString(16).padStart(2, "0")}`, - ...test.accountProof, - `0x${test.storageProof.length.toString(16).padStart(2, "0")}`, - ...test.storageProof, - "0x00", - ]); - await expect(verifier.verifyZkTrieProof(test.account, test.storage, proof)).revertedWith("Proof length mismatch"); + const index = test.storageProof.length - 2; + const correct = test.storageProof[index]; + for (const p of [4, 10]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.storageProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "StorageKeyMismatch"); + test.storageProof[index] = correct; + } + } + }); + + it("should revert, when InvalidStorageCompressedFlag", async () => { + const test = testcases[0]; + const index = test.storageProof.length - 2; + const correct = test.storageProof[index]; + for (const replaced of ["00010000", "01000000"]) { + test.storageProof[index] = test.storageProof[index].replace("01010000", replaced); + await shouldRevert(test, "InvalidStorageCompressedFlag"); + test.storageProof[index] = correct; + } + }); + + it("should revert, when InvalidStorageLeafNodeHash", async () => { + const test = testcases[0]; + const index = test.storageProof.length - 2; + const correct = test.storageProof[index]; + for (const p of [100, 132]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.storageProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidStorageLeafNodeHash"); + test.storageProof[index] = correct; + } + } + }); + + it("should revert, when InvalidStorageKeyPreimageLength", async () => { + const test = testcases[0]; + const index = test.storageProof.length - 2; + const correct = test.storageProof[index]; + for (const p of [140, 141]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.storageProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidStorageKeyPreimageLength"); + test.storageProof[index] = correct; + } + } + }); + + it("should revert, when InvalidStorageKeyPreimage", async () => { + const test = testcases[0]; + const index = test.storageProof.length - 2; + const correct = test.storageProof[index]; + for (const p of [142, 205]) { + const v = correct[p]; + for (let b = 0; b < 3; ++b) { + if (v === chars[b]) continue; + test.storageProof[index] = correct.slice(0, p) + chars[b] + correct.slice(p + 1); + await shouldRevert(test, "InvalidStorageKeyPreimage"); + test.storageProof[index] = correct; + } + } + }); + + it("should revert, when InvalidStorageEmptyLeafNodeHash", async () => { + const test = testcases[0]; + const index = test.storageProof.length - 2; + const correct = test.storageProof[index]; + test.storageProof[index] = "0x05"; + await shouldRevert(test, "InvalidStorageEmptyLeafNodeHash"); + test.storageProof[index] = correct; + }); + + it("should revert, when ProofLengthMismatch", async () => { + const test = testcases[0]; + await shouldRevert(test, "ProofLengthMismatch", "0x0000"); }); }); diff --git a/contracts/integration-test/testdata/poseidon_hash_with_domain.data b/contracts/integration-test/testdata/poseidon_hash_with_domain.data new file mode 100644 index 0000000000..0b877dc755 --- /dev/null +++ b/contracts/integration-test/testdata/poseidon_hash_with_domain.data @@ -0,0 +1,1154 @@ +6 0 0 17848312925884193353134534408113064827548730776291701343555436351962284922129 +6 63 63 17286103331600103585767161555381256046402899599234314287129103751067463292629 +6 0 63 18983952111277879196374592679765388250428396759848819880727626654011636179230 +6 63 0 14690039247305687499999325872545322096288151836581616112441065582983484442560 +6 18 18 14886119132848955634420839101830750513299311233260887510325258966259308028620 +6 0 18 633665573845290208906073174675508179720579418684041597379662431797826067512 +6 18 0 471071594757765224242595750640672720535774219791325564795146688484582784888 +6 62 62 16806009654065841196345990060655780633859196760058147141225814154039572464303 +6 0 62 4391466341587429900903455872273933210694126159055017138392348141307436923587 +6 62 0 6078856426770083769292700047033541481061793813372066507856605863200208328236 +6 30 30 9044124059490367585703569594649366178510106058117862341764374983418084390063 +6 0 30 4462168647812770697181765485265960835478405605595615752223024940695867334895 +6 30 0 19347919945780736011987607672482106281088545639175512447848257807389058709752 +6 165 165 2353709429392571619789851970113232216785565922613667436338216914183261426248 +6 0 165 10430659806198730770124331858804976104655381755284341008047764582794995977220 +6 165 0 5201660608295546072310996128934058410243861654094413762052330545941800928319 +6 75 75 14823471284772704808547818999984935326707738736421538148742541786058091433660 +6 0 75 20023708521860181839237760496916241430173504416893012613259240367902914757179 +6 75 0 11999318616263540697506732742545287338966559474574408243051610325357831718071 +6 58041 58041 19714449762954386365664209010383555288800681839836405724661178897215525481560 +6 0 58041 10818867850526562502260445829725038799340556161157968091417605032018416709127 +6 58041 0 9863308625509440829917020406107323053195025154288106028343907076318644801222 +6 26923 26923 11140311622090786565090101875648179852726239620951743057347509005833458831497 +6 0 26923 1954436883321412015559726567248568870211061748610776084655575229769314803278 +6 26923 0 17644576382905757706381475968429667455517328858834692504733561110486466034353 +6 62860 62860 5653882128700799903844820274735724821451278650821031412671186567950152484347 +6 0 62860 5534896356842931986772367055997240395478722006769590912512844905175188902060 +6 62860 0 8341554337108489113927851756891922379074028905745730039811118902303990807322 +6 979 979 9438966210233765593431887845984285952009618655830908901053524532317100714716 +6 0 979 6459739653028811813603234300688454949824198507254744079124693076281172414030 +6 979 0 5749508988681583018286930521649834313211313144500841811978281446154161009817 +6 12294 12294 18695133923650903247804841329202112693469694368136469111882387035394189486070 +6 0 12294 17356563297431265952616941570074969468696006517363138623108724289371940367694 +6 12294 0 1012923528057293631915586145735213898988176837452790981077137877572418834244 +6 32058 32058 743919728470565731670512783936916116849558191262287123047290739951074561004 +6 0 32058 12328941778137467198731822260785414139840964131387722833338461436585808509602 +6 32058 0 19325400099224040956353096488879258154566471117265732457309536370903946925868 +6 16263244 16263244 19604647010714207311562046788116190601442650280376907446713974410833259797953 +6 0 16263244 17152686418799728222438076178741110694970073617256358770586795488611109864347 +6 16263244 0 12666062152797307293513947005572816239112884394046002226652734494823655128944 +6 1533676 1533676 14695557825817115639836562450046955915480706939563501748953293183990223563729 +6 0 1533676 17131394996727311251016607252051690958383377733965862215302845221190751102274 +6 1533676 0 19442225058447286442100840484432319696649207590456832229076655525374125932406 +6 13603290 13603290 8963229530401581560774491161052876469968609415267820652513104184835679606249 +6 0 13603290 12993002539816752808822053526323848430333912270052879051588110131356966928773 +6 13603290 0 14182498815310609456785108724278381533546829077591035251393886504507517670203 +6 15651682 15651682 10827892793714260089176119042898403370375726351485742557869368916199765352882 +6 0 15651682 2616995267036979829484515988139499806014561030728837440139500927061898377481 +6 15651682 0 13107449477585397690880193735094680200978749961522633375958756799978866337562 +6 12042036 12042036 5271165068041324939203903863755895219069209918428159609196608007837493444024 +6 0 12042036 3321241574170647310544207811615059464212729421645021050814259102467220492235 +6 12042036 0 14864984164975804726127857985440047655856655203429137952921809491917739038306 +6 7199984 7199984 11469062530196007227217743258266874463727135609250478528991462795593825376263 +6 0 7199984 7430728014876618277049253792035702159745511271303820461515412868872752760412 +6 7199984 0 4819206998370418951204850358508249809271764701011673307972130239463558328602 +6 1626779438 1626779438 10507059625349664837267641390351789270471233831266052636201134673097094013468 +6 0 1626779438 21015108155359204611797211515203713319540485490969057722152475275324980911993 +6 1626779438 0 3675157416428779858799332980925783405284375752959629941267405796018068336922 +6 213030799 213030799 18832049227072506371979591060372650567014579397443848880218326316485647909543 +6 0 213030799 14314526225376326205709111423087765549150584351319138971347700248760542940236 +6 213030799 0 18154700578494140223474301604481626165064631021258520118047683443006018929571 +6 1005434716 1005434716 17358032945976665191573703790310667425127861829599917734214951036170747278681 +6 0 1005434716 21415661414376134702616563193569142156854758845826688570285156868291611094648 +6 1005434716 0 14797973277447517041457674449978547833789544517959773751623347186050903833700 +6 3206263896 3206263896 14895088701380951838674358292987735068675866639641499242222050363769020765102 +6 0 3206263896 15230145317270361597465767371459291014209248511383006049828073147823211577315 +6 3206263896 0 452401107047184161065124761341474848887450524489944374520657275679356922427 +6 1474091809 1474091809 9479429094055133397236829132964077542323625269292435587710509023378139458858 +6 0 1474091809 1029870821267115159633187177076336917590655229396554997400773858518706228932 +6 1474091809 0 2432028741784319790902454654914433583868189624303316899618182541412118339261 +6 2169570907 2169570907 12634898222083291539722578207805899282724122909290634563202517695290494777228 +6 0 2169570907 10446102699189687617933487859919277741443369418799611429862617783606248057272 +6 2169570907 0 18737867352695745488821130290611653065125378821443945316541842701784439199206 +6 944101405379 944101405379 21103433620075409808981113071509366893859268080181970160784635558365825194015 +6 0 944101405379 133507314959349266946909988889922069910592907269552586355692559090667348651 +6 944101405379 0 18959420794924449338862293427049024373347621315835549714634883599377933828806 +6 747045310764 747045310764 14530372433150295756049448859854853303831436983389107938192892018662734390339 +6 0 747045310764 19468961629493903467930557948671405606463066793807035094580228149763014566863 +6 747045310764 0 20828502391809205781663793507810808323380040313962551094744304501923366457210 +6 725071030512 725071030512 16968981025449199653173529380427350260644519658710807356688979233635427740693 +6 0 725071030512 461205499992181331960264175369827869852687961649219600052426130016193511434 +6 725071030512 0 19453917870585726096451083969417020955781311140951618879846794976238885804340 +6 698136735631 698136735631 11504290516817091529651336630036920565585250002598717304782746983429260200102 +6 0 698136735631 16018888192977848929805989951094029614833345030325361446385813440567672399537 +6 698136735631 0 20356572555347646960292472006654385027216676430296941472889233254432838400809 +6 709973890179 709973890179 7490328707491697382374882328722657820911117349665736726397528249159054598518 +6 0 709973890179 8214332415595477078804793752923893703515662874682712204969938890701223630416 +6 709973890179 0 15784734870820766516964525370467923005760853323110371871421672936919453326188 +6 1036010818815 1036010818815 18701021748425803713142053489405600346789353356103495141418065652426574895157 +6 0 1036010818815 11583264366005621453702601135451209506407158607916763584720995936841313701651 +6 1036010818815 0 18795190276699302070970186020305018669358923601442845978683748150232084411409 +6 120105725613308 120105725613308 10166769626686893496033288948115248302715608910913212944521075839451934485070 +6 0 120105725613308 14571141778864450823921619766699183642567429056772715616890518745791282540184 +6 120105725613308 0 1062169461391890740127298678992385088222021269524067726414630196362948061615 +6 116761439789140 116761439789140 18443016739097156765624597580555648280861707463895479780353847861697636325010 +6 0 116761439789140 7781211005902364579597893079097386111840264584370478441159152968707991269298 +6 116761439789140 0 14881797176956029712709584034305936668417583912907914123879380870626796839543 +6 149258471847412 149258471847412 190750393245518229102258555838500036433390250544199422609072908719483576960 +6 0 149258471847412 18385492741995731773576175928134731910487751110251269388669405402845481097917 +6 149258471847412 0 3514633715133393362515859961584429207324291253577918534502975942508441014851 +6 24701993873721 24701993873721 10561876181774014707050070979654865482441324732110632955563060363996617822357 +6 0 24701993873721 10263023223079112751266196464468556310039255088846503440828445458538119761452 +6 24701993873721 0 18786026124096704837191735744025393996552454876797706025116247962232727610071 +6 18226713176339 18226713176339 8811530097134742864308992391254914466712335049632101134273501767738096333268 +6 0 18226713176339 19823607782747479795533790660386205952482732498878660717894452796158981127830 +6 18226713176339 0 5340154969038632442304809836425536419016363185206999912864250132076535597740 +6 72372815122436 72372815122436 2432393068514638369013939158305856958860900007160818487722888938659686955413 +6 0 72372815122436 3057958009096454829805165653602459080463687973716758317591709892534275793706 +6 72372815122436 0 6808232954150374450652786713121540190432754593961240003469190235165491433417 +6 2728577820855916 2728577820855916 2540100706842764390397408309819766063576156342473330338923620482306990523175 +6 0 2728577820855916 19359498516836157447044740373883539044258839980508025800173492429350041406876 +6 2728577820855916 0 18255055010599004062679789273182791622882006038598258455680921814976645392342 +6 51438208550261591 51438208550261591 16321541529191217715961932480181570511714009124027362998026782133825208435443 +6 0 51438208550261591 14994636213705328731286590330002212534308713971470739496386357628373283086421 +6 51438208550261591 0 9698679561901545977657540904127930213643203564239662826759742145181095441192 +6 53924302390760309 53924302390760309 4293300195941306062918138625290614556663176949852147440549081771010120920974 +6 0 53924302390760309 16344471687088988664870656859007655575529020231097486987312774544291916125042 +6 53924302390760309 0 18988874393030048827922223257142140465604358395562738032782944945515630760739 +6 25982883163711118 25982883163711118 1335267917111290902788891656479763459156918626374260312073486288003805359241 +6 0 25982883163711118 4138045479178329531664337265926539345131810312657963991478520261124756561161 +6 25982883163711118 0 15487948843917685247431000339499382657043371466026546007019779287874902475320 +6 56660105319121048 56660105319121048 16828982377767494469838529561686488597707937729652751945472523530309667863194 +6 0 56660105319121048 627975076502141521444605341126355022914381085937513225876740778886786965487 +6 56660105319121048 0 16627267226662878084624942271594688186776322707889631088859004589751184562822 +6 13318136857750949 13318136857750949 1165586750880809369649988324878915054167499191385629651960657205855215497675 +6 0 13318136857750949 11448527802547576196667773116462929207112178613314856120683883315434262656263 +6 13318136857750949 0 21773607555700884363254261380624980766043984085009738684511406121868125837519 +6 13793991437684030813 13793991437684030813 7814683583371404356799298413296775354678802364137390222682619801317063026017 +6 0 13793991437684030813 7424757061022878724703755224520024485130470801165811946798553645927064611674 +6 13793991437684030813 0 13795019197785702560273341388172585557070677589831984714988691523221364806352 +6 8700404954773393146 8700404954773393146 16641289790881958730304856564641839272152353879351181295179628829909187028888 +6 0 8700404954773393146 19116980447094259401837489495312854811987953566262814084099514792561685103820 +6 8700404954773393146 0 7432353616753146005404252354484416272375015210613963005870980302705871982572 +6 10217420485608028411 10217420485608028411 14818223295242836183488114335358331756042101362443357217731168274210838008774 +6 0 10217420485608028411 13279926377036199906352445938019659553735622521880559157600945176852178742677 +6 10217420485608028411 0 7365051602122909324178813634654780198048306931845855552703262788050569120711 +6 14868200320233540080 14868200320233540080 1558395219319982583889288212694072800713052772753871767885618911492378355724 +6 0 14868200320233540080 16459574234554943845711856162070433177540735639507590666234230887528329577688 +6 14868200320233540080 0 18631019581847409420016752295933458486740113757144805269384798907531065043207 +6 12558270869497833710 12558270869497833710 8812656146809054157974234695692662495934392233204998287324351633371854855984 +6 0 12558270869497833710 15280709592177173110136474593145112569105333478610149310824346392779993606602 +6 12558270869497833710 0 3639202286127687420682466660050893030870295572869556547235633815534423357289 +6 5650410343137301043 5650410343137301043 17444368265722537321749620818521987669726457620499608115351416605509788780869 +6 0 5650410343137301043 19098834895461296521837464421357826830373913116430966734845926096548183054088 +6 5650410343137301043 0 8347422515549547149632966547552687727044931315075811548280810520758337857630 +6 3634718677057769607510 3634718677057769607510 8171082585651829676705392699151969452348436133658070514597641981076253912538 +6 0 3634718677057769607510 17405352003848950408267622855441660631571613996071871007948712228910036476823 +6 3634718677057769607510 0 6472920187590443043004828878417796775651670056764829005261417839111785931738 +6 906743155655826118526 906743155655826118526 7440121590270347396450433958074522619879273715049933396206350573265288759920 +6 0 906743155655826118526 14260850328572595899031787571466095480270639225949535644684583863050439224113 +6 906743155655826118526 0 13868431084701373944408801840257294127472552793683599348391208404799267455691 +6 1016942069775258233889 1016942069775258233889 1055145124812380548270298563096550394240182686413998917609804208952339783871 +6 0 1016942069775258233889 279097754679987472518876892894055105349421024476396409241301476555214427952 +6 1016942069775258233889 0 12056439181183685697833268530091402157751141589104723906571365184558848327731 +6 1772417340638181082547 1772417340638181082547 16825888813473181188248978510736680253674794647981256997519317904397185916395 +6 0 1772417340638181082547 5640339435067775905358613315576544981836913708365242200360360196539646248533 +6 1772417340638181082547 0 3575183844491712700230621296004863726655304830103401875160918503399226126207 +6 725354530695940600706 725354530695940600706 20688981141983320586154983966017123707722177043064856881362507289438221166649 +6 0 725354530695940600706 11556832016679870804566551730709957970609346774722487636048290028268826126986 +6 725354530695940600706 0 20676807131282133993752716839416681263083689683183820471817187360125092391671 +6 4310398967825989999873 4310398967825989999873 4494129940287435052177894723787667572683058871549294691203415149789176137093 +6 0 4310398967825989999873 2811187591029694210063495179104527384165040148610454481369163789862971340193 +6 4310398967825989999873 0 10600973294324310340721605883939396736157037716184705057046549217949798517737 +6 687391237980223946025423 687391237980223946025423 5294814287036307605067897932597094299507113620126367097972879402034716443921 +6 0 687391237980223946025423 20011150429541811545907476312379534790007125131505535123833402959378679914999 +6 687391237980223946025423 0 4044485973219037175282817563870444907552769008049452199792563508951156025031 +6 665942745762886148110339 665942745762886148110339 14484846496815990715238595731076076613908537157394670374729372179297487307258 +6 0 665942745762886148110339 17897633735845023589025542617406996954338061026208976928644106112224441245325 +6 665942745762886148110339 0 12847193012291195194405552308519802892103428523541189623880361590351375602307 +6 502666814161950209598677 502666814161950209598677 17505256609148228457637211602769860130412318349430585002345107301882499509960 +6 0 502666814161950209598677 1068689962011235237276638652524484923909282629687819885752175656284119979827 +6 502666814161950209598677 0 11159188149678148365652426388897703108660994647529672860102760877073499383266 +6 194550340526841400783946 194550340526841400783946 6280099194967103209466675793572676677131282527591382172368056203072943191983 +6 0 194550340526841400783946 6506184633901067831683598055898251718092561453663335160169286685659844298232 +6 194550340526841400783946 0 3158941899631672463897764384213781936388972083800464816538145020332722481652 +6 848378722500407886564826 848378722500407886564826 18171752349521701535522419784567959219400133781352661042320694005422614480505 +6 0 848378722500407886564826 11372590674747262942848353866273387993833692943026040641086858771406647047550 +6 848378722500407886564826 0 8179276504563950064163105101592269747933670108751501173207158218504702680937 +6 1030271112124938565070593 1030271112124938565070593 19399114193815993280279395051859773429946658479856360237660925411987725336960 +6 0 1030271112124938565070593 3181447652547497939648946384189949501503151709184216555307501202099274749712 +6 1030271112124938565070593 0 17684953139699009765050003487693633844224269456247941853932801820015154564837 +6 53638046375134878752357896 53638046375134878752357896 12524396444544096674710314885581331339329920816067843966336950604277965203312 +6 0 53638046375134878752357896 21644271645509310186062320036657336388947098966940720102820226420078265046401 +6 53638046375134878752357896 0 12310668175937094387790210851969402441679755185080697650858415216566439054926 +6 244340092955513670873661441 244340092955513670873661441 14441864192039568382156011174611597658694445325893814535790458496668934533437 +6 0 244340092955513670873661441 1550242929113815480158988100871415267969572474211758822685123594178877195369 +6 244340092955513670873661441 0 9744017242497015104332804479814475470946328383366472858621064124112647817628 +6 238227106516505656538016260 238227106516505656538016260 32850335566041106217494540724593475720175821102485615894561572406531295846 +6 0 238227106516505656538016260 13374797701811742728045450797594425837561318557012238459194743899694177410564 +6 238227106516505656538016260 0 879181642007825077069237359427180144755072366501939680232934971375077553093 +6 114517305074967330998834264 114517305074967330998834264 15749323701533881384665329505238121908677666647780980766112085603151154824313 +6 0 114517305074967330998834264 2926365833834875910752742237571966140350402826319257658700426440510382766292 +6 114517305074967330998834264 0 10032897788463808021744036265454261422500290227953461518531485406364861982391 +6 193917592529133645599122603 193917592529133645599122603 7116861151221112863253691455443045998884656970556532235885065899154621711383 +6 0 193917592529133645599122603 11526214878568379463834931661002666138839754881239781593126639805604856038275 +6 193917592529133645599122603 0 5125347598502433622819541367964087494549835299257723012162534015634327159262 +6 265059428212216284663762835 265059428212216284663762835 142528867994682490069695437569041109249873808108497859175294517897602846052 +6 0 265059428212216284663762835 3330239611215860482729999409646873454186907128166851362271350182146181976623 +6 265059428212216284663762835 0 15684796418797176514232767849814112987975032877137565125808688011188780840576 +6 62257582648276236259323021433 62257582648276236259323021433 21696943002633353329586638723362822759382619657130457779350056670023526675191 +6 0 62257582648276236259323021433 21186618162972201271454078206998704321260976731941665492766504820938013398323 +6 62257582648276236259323021433 0 4976841683727493814466514058805213538369160568747812898663960753223095147836 +6 32189801089172378300403667891 32189801089172378300403667891 13464961070272489780567637352683194433462896870939049006647536308747505058112 +6 0 32189801089172378300403667891 10553526949327551485239661589973947961228543166655992035506859399969532365790 +6 32189801089172378300403667891 0 18259934581738613798407264247029277200280933071858747638093799410120926849720 +6 47589881735711972442657796770 47589881735711972442657796770 14511899744559980425956969433768081264688044282677351149201918221872594880078 +6 0 47589881735711972442657796770 5280554719500217350475336990882480540518296377142804478822469159368800012299 +6 47589881735711972442657796770 0 12212470167221637044292935377627869279095904194385471100838920954559437572454 +6 8851827901566083204162231367 8851827901566083204162231367 17022198433339876841789962718234550078454868684790445686042049766052631417299 +6 0 8851827901566083204162231367 8713904322056288539953486553038336367537975530366550166916576646952349434767 +6 8851827901566083204162231367 0 15642005142881051719602352604902778757792060212752590487672052739358671698997 +6 19645021489798962002545563848 19645021489798962002545563848 4946425447061715289813485254360128107698135283324498446199966269334213307521 +6 0 19645021489798962002545563848 13947959474358731160430929475823517223909372241224251356737300041086486618010 +6 19645021489798962002545563848 0 10192871918472852689749473363687443922019883236570494146600018341449504678085 +6 8931998057568672949890022626 8931998057568672949890022626 2946372068763624230393164352563648350218659698295159886722628194176840736225 +6 0 8931998057568672949890022626 8678575126816394500430828905842686494368181070212902195913505749374256128275 +6 8931998057568672949890022626 0 2878958517764072409813442282888974022348455310017276232977096554527107420954 +6 17979744847836449202246625067227 17979744847836449202246625067227 14741518648115218032148487239859240840431896146097202692193135185518169308304 +6 0 17979744847836449202246625067227 2066396136444895205208977935189305967096155608908208530867460003299937226699 +6 17979744847836449202246625067227 0 13857462243084678505392929935410664811276126686007322237250882575003078658196 +6 13175477866112907743905896966449 13175477866112907743905896966449 13729518358660725404385558057843749916736385613749511349755280231629029897489 +6 0 13175477866112907743905896966449 18612327314405120397719298007342307462763315345057878246530314435693357331255 +6 13175477866112907743905896966449 0 16253286799075044922351172797553246006789958243410783655777070825825107280345 +6 3955624931433692042244844099355 3955624931433692042244844099355 4325276793682581384949441937083244718061267102083006514508445490907382010411 +6 0 3955624931433692042244844099355 5541219189624452615859153047925649819803697645996994826868131912871347736021 +6 3955624931433692042244844099355 0 6897768380809075063563483308330096768215862276022327329983173660626218394756 +6 3623192762428616881191380474013 3623192762428616881191380474013 19572280286489766021259452988878678431230207840105702013791895645019255239500 +6 0 3623192762428616881191380474013 9556289603298391737585807027782100541468623406967190483003614161120338556988 +6 3623192762428616881191380474013 0 10414323254896721810450954145622809226202499044679300722173242541051137397525 +6 423625103889994221509265191286 423625103889994221509265191286 3210518232353671813310928490697718237478699552353618585386288494189477479620 +6 0 423625103889994221509265191286 7845946684433042442621697918177746413602877395650622683530242053598565832480 +6 423625103889994221509265191286 0 11220665405148269833622753423138313882463282260928268056806515314213453908965 +6 14289419795992013913219918740680 14289419795992013913219918740680 9594681859637925108523631354379748870466513046533567395156612228293120315915 +6 0 14289419795992013913219918740680 6708453459877545481216305791359420934820816034439924708496132462929973969891 +6 14289419795992013913219918740680 0 11725572063428439141418269240099550445292853728539999321031378732830579568725 +6 1036322828666628607886026780814873 1036322828666628607886026780814873 13342645578606543438818569039382428395758160605530587386328481555073488523711 +6 0 1036322828666628607886026780814873 8232681509918386088557492041954382202088365013804101358522058528031176594364 +6 1036322828666628607886026780814873 0 15781681818802539933861174886242243833900590604825748212847092314471650932099 +6 1159161578203689308695581701602912 1159161578203689308695581701602912 1369587157976822756900480258912570999384583621047010629500805674527033643130 +6 0 1159161578203689308695581701602912 588956151031337152218749767379007008242569513674145353087022587277246233738 +6 1159161578203689308695581701602912 0 9000444689931024348240904206000199785498663498606629935932531189891868129480 +6 788168139141532568467587575302556 788168139141532568467587575302556 16929821042986991495556014903525678643683383861245945440376464655934515608280 +6 0 788168139141532568467587575302556 13097527999423218534769716580056190488378452482019884594765924170695312496532 +6 788168139141532568467587575302556 0 7797787944942286337325166965973503530593278803492248349842183059003056458487 +6 22301990107206922731751474147596 22301990107206922731751474147596 16482933222715719815136698598208222931397549927757951192395472429912215962239 +6 0 22301990107206922731751474147596 1868343632237923192751079026833353081136601386908317127623345432479167092672 +6 22301990107206922731751474147596 0 18634083383595446730763463074691763225767509140658439599284020512687796065107 +6 5016778496686906234416617967930536 5016778496686906234416617967930536 14607702353825605469122265613071303878879138284403792785451404429365681117242 +6 0 5016778496686906234416617967930536 11858380365903285153608289912603300584310578918385786917378216851294593187958 +6 5016778496686906234416617967930536 0 2717067946960217007919782037738381550900866504080504479301536146720356769482 +6 2476799328143028408429552196460489 2476799328143028408429552196460489 1747854937783946984621785124886671393285100588474795060065865395776090053265 +6 0 2476799328143028408429552196460489 6264187177122973378225028101881573464152517850554516236158113546553658630616 +6 2476799328143028408429552196460489 0 18531681696964323057246779441977380969970270887077868998767112303677751945956 +6 760438752558498058861159140213942116 760438752558498058861159140213942116 11789710271936131648168607821307420108267163010294866895426965720963930942364 +6 0 760438752558498058861159140213942116 2968361368687828092181374225570223668524339654784585492644807495422266931446 +6 760438752558498058861159140213942116 0 1735803251885871512586772832872024468296610514203094966501053915552950432169 +6 32762404308845926301014934100567895 32762404308845926301014934100567895 12989368016015441605350418329081680327519834482302966787779327603677135960934 +6 0 32762404308845926301014934100567895 12866225415311343059380572384323692126828094735359759486341867856925746896005 +6 32762404308845926301014934100567895 0 2505780742522496682850112167487181666624060077684351320971545713898589420832 +6 689880042748723018580316124825993919 689880042748723018580316124825993919 4567183875749764178343045846421577169310264955949293580190264546555162641913 +6 0 689880042748723018580316124825993919 18402872507729641173603055788141538123859928783098698848887769756282482387205 +6 689880042748723018580316124825993919 0 12420840892742919675496475319879788836350367305152977375771848429740255781949 +6 724725321422559357616218629417599386 724725321422559357616218629417599386 15380362505822271943109785944171269925569654324606297875988510827813369017641 +6 0 724725321422559357616218629417599386 3336235478407166759232081904130132676997469737358548804472472750195516442316 +6 724725321422559357616218629417599386 0 709185355865659060257258893487219602157212478347134666825013289133373613241 +6 110988444967792801341763937045393607 110988444967792801341763937045393607 18255778838955857442478913613383428601614008444023379950249992484444689497424 +6 0 110988444967792801341763937045393607 12895575920742894456393399710874620282592012114783517250649377007021333301019 +6 110988444967792801341763937045393607 0 2619257365170312675005713323701014335700434870933846250302691175215837677698 +6 843073778749609750927624425869459267 843073778749609750927624425869459267 10082151251031031285718456181909387285092340151591307666839905752442004291778 +6 0 843073778749609750927624425869459267 5645557454158445560841882293892144277128608930375212145413895259336124360682 +6 843073778749609750927624425869459267 0 12664204444383232322258889586410859751150553286158728939468469810810643922236 +6 336831537628931429782210448523125681809 336831537628931429782210448523125681809 10589350836461966200747369318854564774349844411699484058289656338022358774426 +6 0 336831537628931429782210448523125681809 18605255442725204778283667838161944456884993683789253019636211532488527677923 +6 336831537628931429782210448523125681809 0 18513821740737731002665086500966146235267954537957718232342614497516174238627 +6 295645844297087541514152137319884820247 295645844297087541514152137319884820247 4459192206435875968378482349654486823969172963939760129320173563035884513284 +6 0 295645844297087541514152137319884820247 21701313353817071993464585111651739273184645352356782660166630666116757347383 +6 295645844297087541514152137319884820247 0 18052905111221997945516138108427314511749314669036048981944172492770035787756 +6 317374169311517856818067300406944446917 317374169311517856818067300406944446917 5183930302666418625666979008034611218338895636743436508648622991142533626264 +6 0 317374169311517856818067300406944446917 9623016900864843531796783294738062997584808738004116010313332195499998097759 +6 317374169311517856818067300406944446917 0 7309263643057027985202510189520065164725351513924698648130573005457317222866 +6 229323746123379699149725519845957105448 229323746123379699149725519845957105448 18529803060864234666132825004945765333859609971475693210303435923534893340894 +6 0 229323746123379699149725519845957105448 10698000281566394201220850560506554282281838210198113101314857730669236194790 +6 229323746123379699149725519845957105448 0 13384166477545789045281971744089772164589891052466041714768179925851878404305 +6 308037972396171339351440980741287893110 308037972396171339351440980741287893110 6777747554809235641293688661389438117548920125186662703105080504198721541488 +6 0 308037972396171339351440980741287893110 253536259813917762902733150210472459546916870914216560965045686062525100142 +6 308037972396171339351440980741287893110 0 11609337913491283807107206190881247153085178727591461774726978757774884149741 +6 236630132470196203455997217648891592336 236630132470196203455997217648891592336 2296056349870146763389869479559448457242866470504412382199452758474782952111 +6 0 236630132470196203455997217648891592336 11401615457751411824086781707567289124781834658734484229079487696800980409996 +6 236630132470196203455997217648891592336 0 4512779879108586706963429380502725888283190695579299794245262768379638948389 +6 18301163948905144795772560915921851560590 18301163948905144795772560915921851560590 13124170819232004991617991870461581306060293801148970112361615870960056087040 +6 0 18301163948905144795772560915921851560590 4278900018516398794732795937154456302269390209094986771098557074528971067932 +6 18301163948905144795772560915921851560590 0 11003687537115818115382985104480003100664090656800977066737219738280437538578 +6 19764047644017523221027210652356886853677 19764047644017523221027210652356886853677 134186523727454299311843511121633016592077921354627327116896310551866454172 +6 0 19764047644017523221027210652356886853677 5362336451273715633644672957394077157691424126213850478245242595053667459636 +6 19764047644017523221027210652356886853677 0 9468966120879531261969892209564714210788584318584482629212735364872228216978 +6 54919901075952303673991667690961303238411 54919901075952303673991667690961303238411 18603116404922470887231494576157787874786048925763176426728212987244451148335 +6 0 54919901075952303673991667690961303238411 21454297887452376363400376601621374428128265210806948181478164413803205160827 +6 54919901075952303673991667690961303238411 0 11080671359986063207704302919282614094424595918889522650175271248393029365209 +6 16321920162870637829093066152949353662081 16321920162870637829093066152949353662081 3606113715083173840136597356633556687937333253143532379268632587582574788540 +6 0 16321920162870637829093066152949353662081 13948742374689214293941654990539170395206426414798372341854690337842267148995 +6 16321920162870637829093066152949353662081 0 12593314554859454143295518073328999173211622396983386478066230900666939877146 +6 17474320394886525054535747763588367419890 17474320394886525054535747763588367419890 6380015472470453764313544153251618714144382087681535733177845812877942082333 +6 0 17474320394886525054535747763588367419890 15680166674719681391710484152950163960509710294190862585161427491879985909740 +6 17474320394886525054535747763588367419890 0 15071615101319861314727665805099558991169952964265862130305224753693170015366 +6 69146136540108200244466260305158096901689 69146136540108200244466260305158096901689 1507687521470049341074557600923210293509391871599215797955594655077530864190 +6 0 69146136540108200244466260305158096901689 21666379955743961287979050084384831721285176610999918311284111012684540806458 +6 69146136540108200244466260305158096901689 0 2875676625985578084679576403804096485812726957100994804955381751784355045716 +6 21392079331004283852361408290899777295735790 21392079331004283852361408290899777295735790 21681768274898523467503084134515025060419354207649569714326600677782721035840 +6 0 21392079331004283852361408290899777295735790 10569167485819853022068513615230984857665012336830670294882138805754228443129 +6 21392079331004283852361408290899777295735790 0 5380522979265164855930319572840698785562394141176464836411477430126584300265 +6 17055659102617487920980483428225411818700082 17055659102617487920980483428225411818700082 3088325032001870360637868742607253266142843843520054674163500790019914548305 +6 0 17055659102617487920980483428225411818700082 1646282684059219220461265174480814102667362171686041267994784072077548322353 +6 17055659102617487920980483428225411818700082 0 13892299760357794469817027860828795502554978361644998225524338385691008717820 +6 10441712788412149152442268917788227069769779 10441712788412149152442268917788227069769779 2423701611908341097593998636908934280471023166285565241779923901374215999965 +6 0 10441712788412149152442268917788227069769779 3418957502875164351992835681739122769596478505876137157691800524680281319905 +6 10441712788412149152442268917788227069769779 0 134236874706806057026737138013980966380288930481677625339358758589042238962 +6 1240470578921937094127350881534164829722541 1240470578921937094127350881534164829722541 1721536276089075119136391104663600861372870256420712595523709299784737220895 +6 0 1240470578921937094127350881534164829722541 10488130464643906838310491041142373735743509735605587466862885961072775591218 +6 1240470578921937094127350881534164829722541 0 5365499526971174935124314308621945170753367455759470978009570684139198213122 +6 7147874991965697473617764346123326448337845 7147874991965697473617764346123326448337845 8909898004903390337696292382870630657888317621504383565280183077656878041504 +6 0 7147874991965697473617764346123326448337845 4023415826541603776948010994914928737863395105622656674676253468299144146987 +6 7147874991965697473617764346123326448337845 0 289082001715849186387774589697967508914300479451102247147285947272695211617 +6 5793299246260758596101274393737444635517759 5793299246260758596101274393737444635517759 13382436225372237327424425916334932259005090717222136221103681121092233027223 +6 0 5793299246260758596101274393737444635517759 17791069828242744062689953741118647418156061094793377633347249857217891334062 +6 5793299246260758596101274393737444635517759 0 5610163133124017444873495163717921588008590997472553777836248276452664106027 +6 3818134098977532788229779257165413251759632979 3818134098977532788229779257165413251759632979 12447361099475251353587450602818251748478825549351972570983737113183308185569 +6 0 3818134098977532788229779257165413251759632979 2121450760129180533080921229051618757805060335846033745946942325050878822705 +6 3818134098977532788229779257165413251759632979 0 4275050042410824707475739098384242913874297925811724753834850443984355668252 +6 4898200733558666210404372522725094403638890605 4898200733558666210404372522725094403638890605 12127884693598137968511330834149964345020137778464501447529887219996495582098 +6 0 4898200733558666210404372522725094403638890605 8313297998149460008221398520842089567745130857868946656403892268996128994756 +6 4898200733558666210404372522725094403638890605 0 2719629566420988859732629998119362180853602608852350530616495948968489388619 +6 4378489834964170683910402212717834783086985805 4378489834964170683910402212717834783086985805 5622626007290603935527659843746656483511983254599356907947801547979770286515 +6 0 4378489834964170683910402212717834783086985805 14652356190798979018951407444291860411764038477048274768484777344280948611906 +6 4378489834964170683910402212717834783086985805 0 13945492058685798208713541260560168703655217406277297974626078725929394472723 +6 5247751603670957356431303333911672713658088247 5247751603670957356431303333911672713658088247 2256531830939457349616266145442062137129218308675105734132928095287944828783 +6 0 5247751603670957356431303333911672713658088247 6593106125370696306396935068539140545393106848674621570036934809800696418868 +6 5247751603670957356431303333911672713658088247 0 3870726719444635073257056958402178896229594323929821585229834987448183075310 +6 770678005050279602379123633330312047075982365 770678005050279602379123633330312047075982365 5137336393608960656695067003132797603961259417028547264417577357851823349830 +6 0 770678005050279602379123633330312047075982365 14314428999708903300920906468763752393581036552272420540974427777166464147355 +6 770678005050279602379123633330312047075982365 0 18327346937230313852507217486173058209225944830805960787228342312999688393815 +6 907880915752861807719883735005658727311096613 907880915752861807719883735005658727311096613 11141868791430261871893839099117590932192961185046042794910412393037860132990 +6 0 907880915752861807719883735005658727311096613 6150740634379525106278917618264398482272497863238276120362979127776624599289 +6 907880915752861807719883735005658727311096613 0 5995348392905658491934822904835305589707614361953452024396213013472339628518 +6 146203095968306518409443005777446242512187404667 146203095968306518409443005777446242512187404667 14873667885130435263203022415701268779037503661358785872720714622382938218808 +6 0 146203095968306518409443005777446242512187404667 10729583616841892876257026306835298528844433246846901079496915353787957099705 +6 146203095968306518409443005777446242512187404667 0 6187459850667685210488067106912057862951220051792522686243401490753765110520 +6 1090966406750643427961350437692451748283081378400 1090966406750643427961350437692451748283081378400 5478527752992386051491072290273923093928436008304753198404666285453080816356 +6 0 1090966406750643427961350437692451748283081378400 8722294848687382289454335702937210765228006185475856672673107663662367519755 +6 1090966406750643427961350437692451748283081378400 0 14733675238068192929958787210633305182797716338860488521110272079997851927525 +6 270589307940428414500720421159410663489521553477 270589307940428414500720421159410663489521553477 4881581541398837419985177394397521883070634088384010464338829684611003183442 +6 0 270589307940428414500720421159410663489521553477 2619591332666523501750489643006961247725748784097633927755952405349611781510 +6 270589307940428414500720421159410663489521553477 0 419136820876142709088509935528252806610921213917646735280062461991546897250 +6 294193575031415470017342283676188361677938029361 294193575031415470017342283676188361677938029361 19205822791458842756351526457798139299536246230986842885758172050420833748319 +6 0 294193575031415470017342283676188361677938029361 11455515117562527951113838372532741753930271387987659753054820777420536196746 +6 294193575031415470017342283676188361677938029361 0 1414900053980959527473137736261975328383581275720741481779518115057983707847 +6 1379359144276133297932619629588680647433684111640 1379359144276133297932619629588680647433684111640 8895295173768296883994481182802252465915455578182352129712082528237926332560 +6 0 1379359144276133297932619629588680647433684111640 12613187961866371884463696600491071354535756286906940119898084354612227002263 +6 1379359144276133297932619629588680647433684111640 0 8489221067208059060443295189968469773256757130018385899045007475881124014229 +6 725526655599252673193913773466308663523829345773 725526655599252673193913773466308663523829345773 2292464607861525157806216223812624037769797708533615675081626785537132741775 +6 0 725526655599252673193913773466308663523829345773 18567000135855442552845286287635457262392859492980245677148695760952707739255 +6 725526655599252673193913773466308663523829345773 0 3838479158419408670207515378463632343238361733622188767473283572603915825233 +6 196748936827526785371619945279201302975157297455856 196748936827526785371619945279201302975157297455856 1535123455401869470515540312262435776927213205901138509172127927475107026079 +6 0 196748936827526785371619945279201302975157297455856 18525451697017034984997730534005311823044271449216283592125150501700343649364 +6 196748936827526785371619945279201302975157297455856 0 18136970826450134368084495739486073566792140209701266136049758277079001075713 +6 209598035249552029268599517624468916538775765040098 209598035249552029268599517624468916538775765040098 859176540615407941590433190438494815075750738846297666879048581165402996692 +6 0 209598035249552029268599517624468916538775765040098 18779913563925954394075216094148505411758952164881690436659740155363038206106 +6 209598035249552029268599517624468916538775765040098 0 21095576679683863163690147869518844782778721314571136070184972588138360243336 +6 193664650129972312232938003899205094615208397777003 193664650129972312232938003899205094615208397777003 109046154672543865301924239857997657292837600885968230584757725718300137534 +6 0 193664650129972312232938003899205094615208397777003 8218788626867516311963306630310980120173870672322246718920727002162269336743 +6 193664650129972312232938003899205094615208397777003 0 18607645761007344682780176310037720955491115492769120949157179425771254642492 +6 61497234713834754445898584947219352724409233818997 61497234713834754445898584947219352724409233818997 659345121643207960064612927399571710076326771737850574467115622861099348324 +6 0 61497234713834754445898584947219352724409233818997 14918356562237268049798507445695389693690904204393026654062516759836466205384 +6 61497234713834754445898584947219352724409233818997 0 18210002697414676553847456373548157545147562843261821828253608019312189580611 +6 323854589737268632901742849075562838140500664237146 323854589737268632901742849075562838140500664237146 18106633049655991438594191062128063508097974566507596482828452047619644807798 +6 0 323854589737268632901742849075562838140500664237146 5255900008691478776952635561250517579073687165844998339164178169273305195225 +6 323854589737268632901742849075562838140500664237146 0 17685769035785948851194005034220230782341225356716568414209138332390015430526 +6 359932730613597710903631743964349720841387445532016 359932730613597710903631743964349720841387445532016 11236905656634403651375883479057602362866158606745683840046961393657426188465 +6 0 359932730613597710903631743964349720841387445532016 10055697583314565553383006690336083474990284441781692109128224731220711293712 +6 359932730613597710903631743964349720841387445532016 0 6721308460867234832126801761809965564491680122716396236982619608252711405917 +6 13777786870145762879814062558953433822804934510781585 13777786870145762879814062558953433822804934510781585 1644844481285923185566196109742551975111699808173760281987233275616486231164 +6 0 13777786870145762879814062558953433822804934510781585 7826909821494326504137314194617950103627376278108007203907934360523188305123 +6 13777786870145762879814062558953433822804934510781585 0 19046988273735332427177136377974739803892884825339177415777939023665871939083 +6 89612037093011585065439976079923724293935979245589011 89612037093011585065439976079923724293935979245589011 12704722823564373257905467749123934865098042608629729310264794518379952875356 +6 0 89612037093011585065439976079923724293935979245589011 2887669043455083519480139364312236244675444474028698976432850602026136222178 +6 89612037093011585065439976079923724293935979245589011 0 13738312944276252335341556073168593765169495139860845213759806064483100832972 +6 69304942731505437250402871168159369515469543330375979 69304942731505437250402871168159369515469543330375979 21480556432669297476123527610102826462931438826983386669812235035192279773240 +6 0 69304942731505437250402871168159369515469543330375979 18339973617464288709852253095368061249370780216734002781498092056378675898252 +6 69304942731505437250402871168159369515469543330375979 0 11895278797110306786402979833395134158088265600065094847288817423865409837482 +6 11408414591911114114292470084897111680689799968822863 11408414591911114114292470084897111680689799968822863 3406790234776711882191369610595763568877144250758562490071785169598741451112 +6 0 11408414591911114114292470084897111680689799968822863 13753376195725201426114442795828710941178769898139633713048356928782020595309 +6 11408414591911114114292470084897111680689799968822863 0 11590824088933603584339583039547404732011018248229545084439878504681084947231 +6 48119459728544991158852009742954344890894407348893681 48119459728544991158852009742954344890894407348893681 16145387069196829003199398146247588966915371667066372157037403464914769123618 +6 0 48119459728544991158852009742954344890894407348893681 20473917029397180706104093755138235981267503554850997117712563749098253370192 +6 48119459728544991158852009742954344890894407348893681 0 334331603448992845372979143921134657442194706249091660467269285024615227722 +6 48683169953301396815470902798493840468012799210198306 48683169953301396815470902798493840468012799210198306 16954940727756039314253735590939904010109021573016258906641244014559920392232 +6 0 48683169953301396815470902798493840468012799210198306 3329505698727944686654467632508010056829974869315978963162011847838470231693 +6 48683169953301396815470902798493840468012799210198306 0 4373219234548837266614813170570287181257888429478003532820890719427513826079 +6 15028432188239383882403555440578569072878637499648093454 15028432188239383882403555440578569072878637499648093454 18818814233981593216639429667835602995441391675993722980433366019225542626386 +6 0 15028432188239383882403555440578569072878637499648093454 15656571711452585840280054060850046504810629140442844531929451625949199426139 +6 15028432188239383882403555440578569072878637499648093454 0 2795977899996261470285147708587541104457107740501962487054256486020784607583 +6 6708425935069406833517933117484271040804271338767966127 6708425935069406833517933117484271040804271338767966127 4990773428097471990674702149398920210742501067347819220164298085507616507860 +6 0 6708425935069406833517933117484271040804271338767966127 19177459685969623713616589124113637523779529213979410156573337681480861395359 +6 6708425935069406833517933117484271040804271338767966127 0 17837393401949969449374457835084034100135470715135627494179256816660886149474 +6 19793869944824429415954786004054772158779747149176971319 19793869944824429415954786004054772158779747149176971319 7636490828727120827715048390176556945740242218150171066685903876122921114724 +6 0 19793869944824429415954786004054772158779747149176971319 16259360556821956971584780791890478017090635353194994095461209024570793440194 +6 19793869944824429415954786004054772158779747149176971319 0 17693985829256374494235589730296411073691631029626396159550825137235750803982 +6 7615008726549103402254293002696670424207050128244707260 7615008726549103402254293002696670424207050128244707260 6937672683694147113205028831550633439940266576037615927196122396030542004824 +6 0 7615008726549103402254293002696670424207050128244707260 434138320137334154118842592606213479052270179165515438643180199975881083369 +6 7615008726549103402254293002696670424207050128244707260 0 18156476873857734567573812253409920476184936718842779742530599911060653325463 +6 12541953421521212743849764649282107793090375650912568360 12541953421521212743849764649282107793090375650912568360 6623846236914674245920307480093467813401787527661873460881083049972964296258 +6 0 12541953421521212743849764649282107793090375650912568360 13596447312616789183473640134201630238964719315744029496687061237751022121508 +6 12541953421521212743849764649282107793090375650912568360 0 5779363710676369463417195231765555694811367598058997873433450914889864628717 +6 21537176990036391320940381417378862643333236894331254716 21537176990036391320940381417378862643333236894331254716 9832295523909335438865756840246265198318238317042883020443847813975576827113 +6 0 21537176990036391320940381417378862643333236894331254716 1311871063680029326557750163151219879696166877655440563214702649832000513573 +6 21537176990036391320940381417378862643333236894331254716 0 393873038948945832203370953986155563396677987033861125381865399308568403609 +6 4826448105982877391542379247764928922487311990847524324261 4826448105982877391542379247764928922487311990847524324261 720686054950608575999774683986347960082518490262490040933822188095825828937 +6 0 4826448105982877391542379247764928922487311990847524324261 2358962644993704403454567138364021867125779566261448144754874409163845609369 +6 4826448105982877391542379247764928922487311990847524324261 0 757945955434083394694694937714792875079582208963614874223667681714934563154 +6 2765126747869699279184567703688730672290996928665849041224 2765126747869699279184567703688730672290996928665849041224 3286303841466016258536036655251240935395878990354805913340875671430147522672 +6 0 2765126747869699279184567703688730672290996928665849041224 1847008652808949162617606053432725828384111438705368445039050305659075563745 +6 2765126747869699279184567703688730672290996928665849041224 0 16714506065134345550609574182458700437472903654485977054442474050427125976345 +6 1036420455319619934936488449793824749824639680687769420754 1036420455319619934936488449793824749824639680687769420754 18371239343996568676403038833875501028305418497468027084975395230415836684800 +6 0 1036420455319619934936488449793824749824639680687769420754 8523093163241858580095590771341614992513750464150109288154771251276713568260 +6 1036420455319619934936488449793824749824639680687769420754 0 8779214761116700314143903066122233920550624619760308280851216254249952045489 +6 5340200850908719649542233360315843160883494932725359877663 5340200850908719649542233360315843160883494932725359877663 1870671992574900378246955623287352656829959591448139758516830711349285932031 +6 0 5340200850908719649542233360315843160883494932725359877663 15588083116728675079913397120625232349346132570904569881835707456049518585058 +6 5340200850908719649542233360315843160883494932725359877663 0 6982232498901556858077844517925628918575902194161169312125735837347873423178 +6 4093329837622807403461985826061133443396029046424118333980 4093329837622807403461985826061133443396029046424118333980 4506160901548666690445549800239388889433604451665924969201719497505087829994 +6 0 4093329837622807403461985826061133443396029046424118333980 15027118039347564523038977621490316541921665845680768583358184498861411814569 +6 4093329837622807403461985826061133443396029046424118333980 0 15778898337155788518713658899693788032291910346262541377710243805459478328751 +6 3034477151187995991431111608042324190438646554939408878625 3034477151187995991431111608042324190438646554939408878625 1960267442267764552399634355989024787738551761108476485938798427045598849983 +6 0 3034477151187995991431111608042324190438646554939408878625 12604208406320021176483521086222318337642168743249009877109890557127157254199 +6 3034477151187995991431111608042324190438646554939408878625 0 7341528222516247420072485420067563964472324568432148000832526463647812279940 +6 523528126231953926599483070936167970832977098828732777869950 523528126231953926599483070936167970832977098828732777869950 10726507104387326481243278886214445730225817007858241081814747109144161966165 +6 0 523528126231953926599483070936167970832977098828732777869950 13913500812649273852295741300769514461736580318548364677923399291008590207201 +6 523528126231953926599483070936167970832977098828732777869950 0 13341953983310576089188893864126404840692827589244264337722235904286668324302 +6 1078646908883835411459473142309093313826340867275063989097326 1078646908883835411459473142309093313826340867275063989097326 19792073484135798026007395832952392571153320133659474290926091492362388483618 +6 0 1078646908883835411459473142309093313826340867275063989097326 6416013601496846798659685502346435625604586793519177503478831952452169286671 +6 1078646908883835411459473142309093313826340867275063989097326 0 10589113067930752050252185700149448642316230360673511675286564161744723275703 +6 1526698652611597854996315504126372819700947459881450972046260 1526698652611597854996315504126372819700947459881450972046260 20465454168242341294926792649298193370025893503157994248918839893580422691489 +6 0 1526698652611597854996315504126372819700947459881450972046260 10416497797575099206330772990832351353902638472798909072441358527849662532329 +6 1526698652611597854996315504126372819700947459881450972046260 0 19644672611407672322423091575339065510063531954503297516411008354898605556500 +6 1018379703233271698525242374169794825799268770867640016515009 1018379703233271698525242374169794825799268770867640016515009 4967796560788904755123462862216856342358540862583688840993152301626652954728 +6 0 1018379703233271698525242374169794825799268770867640016515009 8541738574118847631904886305460350838195342552348273176183960290191107503886 +6 1018379703233271698525242374169794825799268770867640016515009 0 10295344183551317575452028186204597829528149004837697121348276992163915754048 +6 1532779503020224125698178123126425144734519194900769994355476 1532779503020224125698178123126425144734519194900769994355476 3661094385102073410972634685163601216560370858449028708707325538501446826684 +6 0 1532779503020224125698178123126425144734519194900769994355476 14126884435095322193149152265281199803018111334241185733928046826266430222979 +6 1532779503020224125698178123126425144734519194900769994355476 0 6169708435852949139757265030022356289220655736410119260625447641032242784150 +6 1331043380577363741435027117375264653890948461685003993184734 1331043380577363741435027117375264653890948461685003993184734 4573068927837329071439564713279074208348474486903353176524239740759128848449 +6 0 1331043380577363741435027117375264653890948461685003993184734 4573525012264753079916928369457693987769385254365142939972095460246204661695 +6 1331043380577363741435027117375264653890948461685003993184734 0 2912374184748500893156482561167758693277616753489128418153447681618387580150 +6 188859139257055387297987615947263309235341516058328005853084083 188859139257055387297987615947263309235341516058328005853084083 11843855189538968390104343384812382390473193730462373951035039521645591784473 +6 0 188859139257055387297987615947263309235341516058328005853084083 8448927482879017407747800774057835857402146971632789550108484564736732902712 +6 188859139257055387297987615947263309235341516058328005853084083 0 10518629801766290330874462871631562660498007916124079912408582727507521861360 +6 379776469920446571974676254280096085846554840018770235945269876 379776469920446571974676254280096085846554840018770235945269876 14993008262787242947556761566247068977580119061281289165826447166319412854361 +6 0 379776469920446571974676254280096085846554840018770235945269876 14408997376107399521158434311337450706515347553886761593899147621941898367587 +6 379776469920446571974676254280096085846554840018770235945269876 0 19119248861107626831280186757789742225988602955084041984623864101433174099138 +6 294225456577834725078479009114072190617302481691959249518074814 294225456577834725078479009114072190617302481691959249518074814 6158315092337736614823934658134035363730109944774528369239925793521732319848 +6 0 294225456577834725078479009114072190617302481691959249518074814 10175923812123319371062914470380564994102071316302026969626702479526944165606 +6 294225456577834725078479009114072190617302481691959249518074814 0 12096416577945959842497091782356024635611801544387437103025849391042454642025 +6 2758622564140515111922597342418011994343948047544636502389074 2758622564140515111922597342418011994343948047544636502389074 8608474778093659965036473519263079163994366999210072834887087985920480753276 +6 0 2758622564140515111922597342418011994343948047544636502389074 7100977313122632121880683104241680596080658740523442314300231785706873359050 +6 2758622564140515111922597342418011994343948047544636502389074 0 15745821692871218261168838257987316842828320870636989753443473135728044108786 +6 207303317919341550652106657462448169650185779471255617012452083 207303317919341550652106657462448169650185779471255617012452083 18793199271729395963329416800103432677358890825868200325734667012857151658037 +6 0 207303317919341550652106657462448169650185779471255617012452083 10086371190620890578675547782711292051687933848606178125273635483942703188583 +6 207303317919341550652106657462448169650185779471255617012452083 0 14783496932675756310869989329333597825035684506035390934739000780939545964873 +6 149679224638372073307516556038563213496811981278278780195301298 149679224638372073307516556038563213496811981278278780195301298 20638573276802045461302202936072017161217266385669021366666774674110844933161 +6 0 149679224638372073307516556038563213496811981278278780195301298 3882182171317605814125200675439312843313328102413455174740740607753580099132 +6 149679224638372073307516556038563213496811981278278780195301298 0 21632615654859390593273456127280385419474974834863483282405247726058299609703 +6 65737864876760663587172552216334797837135547686256629533886361384 65737864876760663587172552216334797837135547686256629533886361384 6191360516246570376456902065284650286883365427262723938707341231098924031170 +6 0 65737864876760663587172552216334797837135547686256629533886361384 17331360487455446512053582831488349190665042136401690079036903616720988203274 +6 65737864876760663587172552216334797837135547686256629533886361384 0 3813295355631236938637652264795525022668841663063400904119102501399584637793 +6 10747608900933650918469194946551423387487478578654011490082326311 10747608900933650918469194946551423387487478578654011490082326311 10908462366569385833013409358041724172843717888415551855448618607028412444897 +6 0 10747608900933650918469194946551423387487478578654011490082326311 17804090051199965849365855194028441327264688977229839912374320687148282796001 +6 10747608900933650918469194946551423387487478578654011490082326311 0 8660919422665606135379280949454054740115056361501839318361138309754445619994 +6 34694015305933395195240784276389141224007950892562673854331391607 34694015305933395195240784276389141224007950892562673854331391607 920720054440902678254985616744527430720143156482162131181265343048849832323 +6 0 34694015305933395195240784276389141224007950892562673854331391607 19056611947768495876920419562970914414855937289286601217320547520228161713765 +6 34694015305933395195240784276389141224007950892562673854331391607 0 8937318052399998275934517598025859410870904442280008925245374130170095550238 +6 5436541889689150384567921159482963541492620565897112340458830570 5436541889689150384567921159482963541492620565897112340458830570 4367973681510271174957439612359865440906764550832551766789970470527038269617 +6 0 5436541889689150384567921159482963541492620565897112340458830570 16927607975055589267308661104686380871936398613837627948543299552670616545627 +6 5436541889689150384567921159482963541492620565897112340458830570 0 17806225244827729412845864475815649645908213650222614638435789583402340565470 +6 80457913440472896623391178747950287240249765431490961708616967480 80457913440472896623391178747950287240249765431490961708616967480 21180814455494413418695526981344479341157325222166470713961108906198547508995 +6 0 80457913440472896623391178747950287240249765431490961708616967480 3553961710757547381277141342113415498499009554304237202745095728477470189826 +6 80457913440472896623391178747950287240249765431490961708616967480 0 10203463996725378847432602743131416894108379224416091086198385218927218790286 +6 7002646882497767383944296512524789486811815460010867792490795042 7002646882497767383944296512524789486811815460010867792490795042 2467642294276720894050152966179483281067884123552698146231186222647007909 +6 0 7002646882497767383944296512524789486811815460010867792490795042 2717306038129159077378820761524125557807245878362652889100252990462958674453 +6 7002646882497767383944296512524789486811815460010867792490795042 0 14438815198553971344242259591697352657912796422876408105241503486917455711739 +6 9960542110614378215522854903321333518500829386606688370270289751885 9960542110614378215522854903321333518500829386606688370270289751885 20036026891635923951702208013556683084210687524443390579506939283842528656289 +6 0 9960542110614378215522854903321333518500829386606688370270289751885 10247383916737922088942739255532532390225362722908179720003551930577859197540 +6 9960542110614378215522854903321333518500829386606688370270289751885 0 21800834416108737576858801764835999200675637278904833152440466789563350942525 +6 332935353245800454070494431790772106924676049772410160640512118475 332935353245800454070494431790772106924676049772410160640512118475 13420900808524969960714463701176303336026180755117738002168161204102691840496 +6 0 332935353245800454070494431790772106924676049772410160640512118475 8254583711689483077373332442428133959375856294523910816260206893710474580498 +6 332935353245800454070494431790772106924676049772410160640512118475 0 3590520253471756223215895828229086967870286781288240681241147309040174913514 +6 23163519598722741020297392844856474175805867240301760747871582353510 23163519598722741020297392844856474175805867240301760747871582353510 6302671647228592600827410307019782110728855586228746667706038706879253151696 +6 0 23163519598722741020297392844856474175805867240301760747871582353510 3330118575863258094519314762422953465542683402331674797662545885217109933296 +6 23163519598722741020297392844856474175805867240301760747871582353510 0 17229439275041115328181780963363163848041723153832730423794424762797622199118 +6 12731965885363235280546887867677832607959482555368182147456532390613 12731965885363235280546887867677832607959482555368182147456532390613 6107748385756754455148843547561405759217313001735769326164209527915504082152 +6 0 12731965885363235280546887867677832607959482555368182147456532390613 6665637435409790704005088033242536240508677566200482125416826178218763347331 +6 12731965885363235280546887867677832607959482555368182147456532390613 0 19309805907488623828749813758551814549467763548353870780514821470746171518839 +6 1720007252540685059898123979440999692276918662939203923391132631838 1720007252540685059898123979440999692276918662939203923391132631838 20956973583698369681191483228613700080893036078748040932669409424088694143172 +6 0 1720007252540685059898123979440999692276918662939203923391132631838 3273142398302882696556362855007058436807242111404436048288424693818065226566 +6 1720007252540685059898123979440999692276918662939203923391132631838 0 14336859234188686307581316129066114697783447257098397721691070692263452980856 +6 2786571407685282250339432408941098769314722565042259420426660352678 2786571407685282250339432408941098769314722565042259420426660352678 1325308261411071921115405738506640657592634266422912647733392925762179739627 +6 0 2786571407685282250339432408941098769314722565042259420426660352678 7264345255547517243842602014531456940787746609772727217073257541810558696523 +6 2786571407685282250339432408941098769314722565042259420426660352678 0 12780503975375554443675338315704691638261824214301466188503111935195962316359 +6 3697818691970681810631504055135993101777175177475475095554979931959089 3697818691970681810631504055135993101777175177475475095554979931959089 13834392841539548617497019564924064458961205276652895543540563955352828231986 +6 0 3697818691970681810631504055135993101777175177475475095554979931959089 3579797281919552929983566869317408954729773884999764534811020885335577772274 +6 3697818691970681810631504055135993101777175177475475095554979931959089 0 11455074180497785888837627931978299325069429678039015057280777573970879249865 +6 106019804102395935876870977650837156370735571186616027872412719848144 106019804102395935876870977650837156370735571186616027872412719848144 17935372074734936116526355839359099223596384981570759434157394576596924689595 +6 0 106019804102395935876870977650837156370735571186616027872412719848144 21086834272251230241198833943389109638024036158639910835580767986381360434302 +6 106019804102395935876870977650837156370735571186616027872412719848144 0 21537042025106520192476395062465488060983002407557878693869366766157423775612 +6 2222474423115968943986803770816898126000877759139030471524741360331582 2222474423115968943986803770816898126000877759139030471524741360331582 18064454019836812744755330947241194243344041821959393902428139654270651410822 +6 0 2222474423115968943986803770816898126000877759139030471524741360331582 21749970220415587405961081372303811981227982256995959569458440061065604031836 +6 2222474423115968943986803770816898126000877759139030471524741360331582 0 13745559025419399517701149745353851791831110545549737912548881240227784561072 +6 1175549400748842569359647968466776259326966462796234879511305439365865 1175549400748842569359647968466776259326966462796234879511305439365865 8254202731407877339958559002016215960907913996047120092865301309637807096563 +6 0 1175549400748842569359647968466776259326966462796234879511305439365865 5456928965894608391895265514297149999250480091226336195932231528415406392588 +6 1175549400748842569359647968466776259326966462796234879511305439365865 0 1368168856664812918511707725309584433773557531013064407765597201583162463220 +6 4299985571249736045648141970227205025098414582731906916907668210731689 4299985571249736045648141970227205025098414582731906916907668210731689 1811418849974495629375278426204779838692975245131685450798761243961399903973 +6 0 4299985571249736045648141970227205025098414582731906916907668210731689 19895952653371330649043622640035660001761251918832201041974069230156863364005 +6 4299985571249736045648141970227205025098414582731906916907668210731689 0 7373577254387958353701483242172751517995965838147828309266534302180045002860 +6 6448355797616026830323069082406072031149724610504210161685567857310029 6448355797616026830323069082406072031149724610504210161685567857310029 10885820519238183108518660594676182083220104824645685681274437104590722778370 +6 0 6448355797616026830323069082406072031149724610504210161685567857310029 9986924045997124744617107042984106582084014057884246407516851101582839351626 +6 6448355797616026830323069082406072031149724610504210161685567857310029 0 21599615603346166044370808320789866311188789359712434910810996915263858094594 +6 417005835657085590680740450059687863262191219489879215754921001041657516 417005835657085590680740450059687863262191219489879215754921001041657516 2997611037546070035879894178329666844912334242143907349423494950218444474582 +6 0 417005835657085590680740450059687863262191219489879215754921001041657516 3155988597995725437126665195755489050332736460671495513014062350496179161358 +6 417005835657085590680740450059687863262191219489879215754921001041657516 0 21857367631754487644591759878223013635490700875074744292883169206299868968682 +6 1169717354368838328734104647162847125629751421222345521562438237759682544 1169717354368838328734104647162847125629751421222345521562438237759682544 6402452044679185009997739904490123015770576415938799424897977568325799678763 +6 0 1169717354368838328734104647162847125629751421222345521562438237759682544 18572542858170259633581516812022131028126528180863322248818947805092958278634 +6 1169717354368838328734104647162847125629751421222345521562438237759682544 0 11144865562212414123705782136641096736282052883498693788700479601625855388566 +6 743177306527039602415665730273135717275137789264143269802740795408231211 743177306527039602415665730273135717275137789264143269802740795408231211 18231006310503957818507801380254503816608756765031841226265907234333922212201 +6 0 743177306527039602415665730273135717275137789264143269802740795408231211 17929423629788925637589036982330542102178195640722844262154182726807505558792 +6 743177306527039602415665730273135717275137789264143269802740795408231211 0 20685980741882866780437577518340485997574689988132028580422758548321976428459 +6 651165187186310287020524239080035902232290349173101083465832414316511626 651165187186310287020524239080035902232290349173101083465832414316511626 16842110140620953338450966666239469735982688561520787984396249190510606840917 +6 0 651165187186310287020524239080035902232290349173101083465832414316511626 15150010111789605492942658231199853477038244676139048083365810432746374813274 +6 651165187186310287020524239080035902232290349173101083465832414316511626 0 15957376188483147447942075633716502171535206637059539072552792093182606653177 +6 590236391075294664833702957068177405442451575764265582250962910589418182 590236391075294664833702957068177405442451575764265582250962910589418182 21536438669725193650039932287383977731745793822892757169841110993502679620229 +6 0 590236391075294664833702957068177405442451575764265582250962910589418182 19515702078124343882266724151718268739174511637383074093131726522610335884467 +6 590236391075294664833702957068177405442451575764265582250962910589418182 0 13600071580796008835770657430332104027928731695368317509696074865257215433562 +6 388981885503061965354485486392722501740647456817073704994651699674968671 388981885503061965354485486392722501740647456817073704994651699674968671 3663135388098680276369493491923208828891551340550873577429225996918150170154 +6 0 388981885503061965354485486392722501740647456817073704994651699674968671 19341575787266291066911434850714987798573886788169520398847502937963830869832 +6 388981885503061965354485486392722501740647456817073704994651699674968671 0 2281352867953170023553475472141985207189709827454995363686763103446256103740 +6 58594825100519138315769680293884362850415067192208348280546603840906112985 58594825100519138315769680293884362850415067192208348280546603840906112985 696402663832731782107957993513747326272610366859951913687435897784243817372 +6 0 58594825100519138315769680293884362850415067192208348280546603840906112985 19906440288334610518041830636152263899947417964852414324160285532901909533842 +6 58594825100519138315769680293884362850415067192208348280546603840906112985 0 1003818897315538948624554076875431345910658696701953751703663421637937151904 +6 44163148392407901304262680269300950553670805139975891092056358087756200504 44163148392407901304262680269300950553670805139975891092056358087756200504 4642593568371598082346389269046915960426769128338173225489112558283669187632 +6 0 44163148392407901304262680269300950553670805139975891092056358087756200504 3592286077441627926778526748013783505888801107604064046170454309929192667123 +6 44163148392407901304262680269300950553670805139975891092056358087756200504 0 362256280766062384642904441701982406008791311409568535021623430048040957760 +6 422430966944467267705740288246570068093173449747260656261678024479660573461 422430966944467267705740288246570068093173449747260656261678024479660573461 14001477472788131636354189103511903254468271624945999559143289174704673521217 +6 0 422430966944467267705740288246570068093173449747260656261678024479660573461 8212893580799348842453026760193831425991369466888783279611766490066302429771 +6 422430966944467267705740288246570068093173449747260656261678024479660573461 0 14501986263590130285006154473212958585074420099859205185541418058567289881869 +6 271425016321911257141631323152180272293994474904462323921110032920998337695 271425016321911257141631323152180272293994474904462323921110032920998337695 21099363577962638119379976076668442032720987183546303936588353056168019275020 +6 0 271425016321911257141631323152180272293994474904462323921110032920998337695 7923836762043959324765749919357527773156925824725053318209835651809822277553 +6 271425016321911257141631323152180272293994474904462323921110032920998337695 0 371915678982891536569815533993090551447940228078069219299386635994944922750 +6 215645532002590517161635984158960034717978608320680157057823696608565328872 215645532002590517161635984158960034717978608320680157057823696608565328872 15521172735031250276560411543753198988131015995513902186595850652156949548002 +6 0 215645532002590517161635984158960034717978608320680157057823696608565328872 13985554021085120109526695768522376927503887875457879607318662858549686892179 +6 215645532002590517161635984158960034717978608320680157057823696608565328872 0 8787675692812747552113220722276149492636731146771217574239397768797165351616 +6 283915863058293431615749207247139964307711053968026579104434546065627886279 283915863058293431615749207247139964307711053968026579104434546065627886279 4602697642429520631917992142799378255640258912855823751465203205811254201863 +6 0 283915863058293431615749207247139964307711053968026579104434546065627886279 7163964259766037876221194323835311295074825586073008146318490535771805291193 +6 283915863058293431615749207247139964307711053968026579104434546065627886279 0 16428924413994121584703246873768858630201290427888638032196534414827808325558 +6 12300734523270388670246672444614834379731277775212726108331475604581375120346 12300734523270388670246672444614834379731277775212726108331475604581375120346 297628351999710345327888841791587607549758472549702739184236549055065866359 +6 0 12300734523270388670246672444614834379731277775212726108331475604581375120346 19616963909650060427660144968802575954900454704479315665956570915356886949094 +6 12300734523270388670246672444614834379731277775212726108331475604581375120346 0 17989789670477071882730557888224796106383576352161749470436830641481868191789 +6 15269724289404893295498193386955893630382623708616443502066293341436262104121 15269724289404893295498193386955893630382623708616443502066293341436262104121 18375765713091621360604137816883916652435358819438573947411109620405889238369 +6 0 15269724289404893295498193386955893630382623708616443502066293341436262104121 2804723033934892573858728019783488399637285269072393844906024436471891337913 +6 15269724289404893295498193386955893630382623708616443502066293341436262104121 0 17055685666883135162612730072731476497742240527321201060164358530496976653895 +6 1989636574038449663126215279069746979357435042397506567806465823953706044281 1989636574038449663126215279069746979357435042397506567806465823953706044281 6514085784036495808557953110827477908425925900251180100831079754769677560160 +6 0 1989636574038449663126215279069746979357435042397506567806465823953706044281 20413000657117057043213713290437256494202173284218961387837150063624063179274 +6 1989636574038449663126215279069746979357435042397506567806465823953706044281 0 2734559320037755892234463682330473062102215026733229460356646591846241278661 +6 13005879071196222066607513418606997020748755442177934055567026969651385456375 13005879071196222066607513418606997020748755442177934055567026969651385456375 12230410876843420521734639782546843473755373842234271404241170499132804011110 +6 0 13005879071196222066607513418606997020748755442177934055567026969651385456375 7620115863478778746705864807155377634963134269255821052034661343323677044509 +6 13005879071196222066607513418606997020748755442177934055567026969651385456375 0 10722543694851645718895215511865555237299166510999261027474733965378693479119 +6 2946690020883835228481538034037667030112769571724324674467399801095540992292 2946690020883835228481538034037667030112769571724324674467399801095540992292 4067474577671719316015464098316347545463077122503268749967626644069312861602 +6 0 2946690020883835228481538034037667030112769571724324674467399801095540992292 16045383487971345541184842393061690041376143706101024183999280653293756496471 +6 2946690020883835228481538034037667030112769571724324674467399801095540992292 0 12961010641101550865817735568414298687961054284051067979355084261668802789286 +6 14304180984250378986789008586936766078328960697480840307508664252383718017758 14304180984250378986789008586936766078328960697480840307508664252383718017758 6381445802391264925774443611099377627677161642772635416481936373783237566631 +6 0 14304180984250378986789008586936766078328960697480840307508664252383718017758 2578668140147468113472599911638500703174737803051797602020792797952159447481 +6 14304180984250378986789008586936766078328960697480840307508664252383718017758 0 4840660717891500236417584684291569448530333418874526882694610669400538558677 +7 0 0 20994231331856095272861976502721128670019193481895476667943874333621461724676 +7 4 4 18747253005792370687204412166155555082728494699723704254497260141381952010296 +7 0 4 2400488805001498029992249792881524182981734765735511221733870421952905799209 +7 4 0 8962575652027094297962328171293921026023543664302668286792446712579907613985 +7 234 234 19840847724018688829631248704567425458369885596125311517565958332149746206549 +7 0 234 7647077254325846360228761400400447183802956603400736259761305343669192781551 +7 234 0 5971554597063703033342669006182794468530918901689658362623310148622899084680 +7 153 153 8995247250458630025985126106243062135297807525748150346698752524484376268767 +7 0 153 1181463912832023390392657781135948975578371684470840089941615615665638568692 +7 153 0 6371158747478815312779647206095682416177098856029625412506697112872074297211 +7 227 227 10672788219115858420967704607285845215613157277931563444434908072317363304474 +7 0 227 3370488400918499953451373233109428532375232110901000565406802818006153152654 +7 227 0 1164951604530306616691410182382673337353451481422050969754870099434448387414 +7 88 88 13878864873431015457104357203034782952508173739406327716544883038528082598034 +7 0 88 761687593273018801893990233442219345675142092939295956186499732210849957353 +7 88 0 17898106653705865795838568820539864356982558838828646298233516341393389776239 +7 151 151 21768699512360256455616064137171860457709808494221558896459806529897545128547 +7 0 151 13637732926922210161363070830498512330495158409582195086848586629239925798389 +7 151 0 14374480861587214833002551935765697143083074048821566642915804697735073286863 +7 58571 58571 11501605121155859310853121352207958010820723873654295431537555932551346062738 +7 0 58571 11136590024464160827169226344534873282403028641169608318260534039477818488204 +7 58571 0 9239011205517343007130793534600980688471873735179440046901071171730468388433 +7 31648 31648 17121181002961671572594644831294482945370393561993866723454567563351812795764 +7 0 31648 19440137037836551695169099138045612157128985390298265797716152358961627186304 +7 31648 0 20403740072397200263271466523525639044357004016566047518678410112501436211114 +7 47388 47388 12183906837958958539432276400104539534548286338212138229644040175283351654194 +7 0 47388 8436686469525355016219903389722614600061997839274346293195767093935554224580 +7 47388 0 13720176391983428567085361742228937179930718517422413150482255667000412907150 +7 63589 63589 16715565069671862591538334835228068490814329058636407564873212271956080750778 +7 0 63589 21705799488316615941881126823884313349294180529772285717285616168804039047240 +7 63589 0 1763815859854270413612510973763237998611297536830341820369459738294095403777 +7 57412 57412 13395412874808033415054082346263034723036320484035155535303585111004886428010 +7 0 57412 21138386022884871087603323282457273180949253343493374597659572037621519359620 +7 57412 0 13452004662033887503766924809808022942847317749231290943613083731740065337716 +7 65049 65049 6036162920981515854163798614361000265989891971639356821411640645723457490283 +7 0 65049 17794015705181992885866335340669912675016786749720960542879361998465548278832 +7 65049 0 639233810608654149346177001583304297002087733838769466322839463432660570923 +7 485188 485188 14362143765777067596610304500143829527962733318227923535340358070936153547601 +7 0 485188 19021038872147329892018587088423262537871158403316089025158122005788241907924 +7 485188 0 16320420245853737709525461232795823481687084390983621909132638418220617543461 +7 2012417 2012417 4511936612754982162798793982835043589715299013267266600938674597221748040921 +7 0 2012417 20575150304876244979458318055027801102477572476906307765358304288973172850662 +7 2012417 0 7202815050276323396764337563672408201819478614856718541282252251526166826569 +7 8060366 8060366 5087085889295615866569362950179878090977229239446901672515177225147322196829 +7 0 8060366 2028019722941384182739072046443493586201254832266708285597564565809790257672 +7 8060366 0 4395593208796781481571423147625722206582017278194039797188538989579640372945 +7 11959599 11959599 715720382591867841156398611136348957343356681310083516876730061002476701636 +7 0 11959599 14651807529044145135823662325058994618820126519510348520023112866623190931425 +7 11959599 0 10524052605478115813382293000764699710849766518201747728296047214632992369520 +7 4783486 4783486 842171142237026317291939900099104461968182289357363528795002301278100230098 +7 0 4783486 8632091819037651894151505039897509098887304383701671844831273123112160565662 +7 4783486 0 1997938373325945377817488338241443942705429388788184308188844677484365943082 +7 13036977 13036977 268580334288537350148272213042634369903055066444196269284604085089864710430 +7 0 13036977 1586940663934637916524503173121476877267127414788444239192971574311297879817 +7 13036977 0 3212243208380557285218054066483934385392118135860940721360838921197762745320 +7 2969942405 2969942405 17001355624328613463537575661833296563339053854233534412645907738563335109118 +7 0 2969942405 7526608629438762975683906225276541822072927091724803647591319326406414748719 +7 2969942405 0 14228346642553705378014515775030876408947547590617070553150294607765556290220 +7 3443873377 3443873377 4623795034630059707503186561607238755595958457119069347618503705864508389687 +7 0 3443873377 17251569540017994382938201708601451311980372575432343887116254772411649526958 +7 3443873377 0 2012737284805373448820280811703037430630030755300758957586688281932359195744 +7 2464471814 2464471814 10830694480452794652443565155303613344438630030405894304565972350260156061176 +7 0 2464471814 18523083543036755543695638965501099067860286999773603542973182700178720986943 +7 2464471814 0 8853423482456146771548092443743171227064778223919108726120329862403360296617 +7 1540288886 1540288886 6100340600459231297764636370454700432168353444514967427406615332679051232609 +7 0 1540288886 969955679535523384241701526702243438176518314972696038227423811979447727921 +7 1540288886 0 21201121515784354442529777406960980518332833007681678430162916007840060012678 +7 2103891132 2103891132 17480803491840706912383103684445409074281566719023187053571203271547844912565 +7 0 2103891132 19315612569427869995572362607239655506893029139308038019912932063932706852568 +7 2103891132 0 12414149659938180153304726487540546992671479358561966041559542225420426241106 +7 2357522259 2357522259 1702889757414274055848568366742159824256672051434804247115671234165554866250 +7 0 2357522259 7161767058949017099878914865276428656140803410121303472828348964010993951134 +7 2357522259 0 17232102879363528163831053837133279694873862968167205663516913745954523542259 +7 367014217626 367014217626 11040718564378049684510775315161888795571845431358249400828565305361265683157 +7 0 367014217626 12705744419040819622496664482061708950519778686113412322239060611017889317034 +7 367014217626 0 9611845218064166460729681155462332234506067016904660014351075628487230890721 +7 688260227335 688260227335 9512179666691432475143714639968418137602038741064665906754248954522868309300 +7 0 688260227335 2518179087967000688836074566963233729625923982434310009619189086506545959893 +7 688260227335 0 2539811799156992653235701874599293619686344127635202233963374169657403700500 +7 1004366944697 1004366944697 4850689725079295338462818442381927388321874470928551480716425284157435046734 +7 0 1004366944697 20447459919609205336175193112727876689314053240747897172815135505062973177095 +7 1004366944697 0 7372342250003067293321430056131084604326163944137328287547735815822240430767 +7 475419781036 475419781036 5257652089381645879129663152386390634065356344262825973904455967266337185222 +7 0 475419781036 794184745169763292790175318337919000963805675462347641978396299398055146118 +7 475419781036 0 8594815704178115975164699711479838728420956696197662075627463211049348630441 +7 266992368920 266992368920 6568973971285484864004710152475359034998635937938515645560093660519782228528 +7 0 266992368920 9767589041715191048261486138471537994619987395789627392447450656967250828250 +7 266992368920 0 6171118170174993069135806366310975297924084185581951026743323313595140575195 +7 883428569608 883428569608 10779233241447206331759254223118564789457500530979280557174900765592936071141 +7 0 883428569608 5500213097682541935449873682421771420007368054050177971247495094156825099540 +7 883428569608 0 7235352729329387586187922696113858436435913826883516277103953927745897489884 +7 268105795784720 268105795784720 953572357579253560624347297912132243163193799000164989807089196497645654485 +7 0 268105795784720 6166749164349150955784242841439930875221506920642393730317118232377323511966 +7 268105795784720 0 13890512617732097010212303285178804554156594872316610314065609413359816262857 +7 276528779969561 276528779969561 6297458196210601087322561304892251303141252889606850562128341990002124800437 +7 0 276528779969561 19211391068468388001796817126993237287876665821530933156192942518083158642392 +7 276528779969561 0 16897429954011971558167603657676409696428198280693617531598940368747778428620 +7 238495654056882 238495654056882 1633517828153388764820053045861317928973633002595076301036627599783722421385 +7 0 238495654056882 21115288378223996298169827477329531886819872791780094324971072564108545362886 +7 238495654056882 0 13382578131024356977166444018550270272556196585063928435759887605935395562591 +7 61988763516470 61988763516470 8730957831339229353465758293553312728527807288803050135583280252829176876301 +7 0 61988763516470 20815960903454562768991083885665716236441168678421019514718090607518033899484 +7 61988763516470 0 19943942532059234572917188610905600548718093613959366290970213942642530634790 +7 170860374887067 170860374887067 13912981796002009907483362495738476474422966517476439113986481274557508020110 +7 0 170860374887067 1649459314329257023860510360063626400126175928342119905462926181529590016416 +7 170860374887067 0 16243866934063127209744632671553697993880424415366487146507221184325865337513 +7 252731016750072 252731016750072 3288059636608095301116739125650616739885379710412925374623297584966038510560 +7 0 252731016750072 8843182132622008013602049994768974853977616890774972124105037958298242532550 +7 252731016750072 0 18626474193476762683608815176714564347833607418155104937773242912613261480320 +7 15131623571808088 15131623571808088 8346751259402906423525881768947606984955379080055922371168830490485659733210 +7 0 15131623571808088 8731667245947012493899066082321713819260955077422173220423890860433344085351 +7 15131623571808088 0 13172740582602362885864106040578843086355657305680304409103459874569504288548 +7 68342017051396278 68342017051396278 16310333061944106723399147024004088226456079072951702846339060261125992275110 +7 0 68342017051396278 18868670911261502728247273249855504974550291550155257741181917218953430123994 +7 68342017051396278 0 12904985628784858024173780200188642662798017474228702476001116887545498882201 +7 32758087064994775 32758087064994775 13259703148918042119698802603618070699487945216402563189127605586385803324037 +7 0 32758087064994775 4586555163239587541376728567544855216353737659515790204561931071973398014878 +7 32758087064994775 0 16638789004490201783697929278299570987429274640023141275507844503323888958607 +7 10290459809007179 10290459809007179 3476794936137336337932247403302897288920583785759903551440891366437036246546 +7 0 10290459809007179 18024121996151168718536614151051204346807785125227363379614764692275518695842 +7 10290459809007179 0 14351482996551415551684294704763794846822291507734210629469236162389574709383 +7 33852059636762458 33852059636762458 15156085759491157105785346047309330948529090988207135097353414057974912011143 +7 0 33852059636762458 8754289345015037063056382851556044590508116440463990266364195465810052635370 +7 33852059636762458 0 18269060255287520498228147060448327506605645082969704184539774341110461553821 +7 67024306002247360 67024306002247360 19176787189173498880416039065668908402710765051992917820153575226674236656914 +7 0 67024306002247360 1425890399318643841943447449718101776141584185470403017410463227225388708419 +7 67024306002247360 0 17261235297700275573029206124075958703412345561107594321674769385609809792195 +7 7697877582092852093 7697877582092852093 16017199000027041144702484850160793285784427845903097077033760083155223397442 +7 0 7697877582092852093 12250929944509244738437073597881620989537814270837586260086726576340050913358 +7 7697877582092852093 0 12731114758347912383188202347809448671672265455792752711750218218295277485150 +7 5975307584912439288 5975307584912439288 19660768676014473734910480790428933403015047987691644334411089068984296025273 +7 0 5975307584912439288 1024454748907598085640700997917712959093573322102023535187573207813606335625 +7 5975307584912439288 0 15016722149176515754254174633149330450726035267301087605350618385533070943854 +7 216413252971977072 216413252971977072 14129009540298939436553771862006407919427194266650028285474452043143635855602 +7 0 216413252971977072 6746746812024532478879323266293476364049588182182280287878660067435011957888 +7 216413252971977072 0 19509946104924111201533592646704741406989125054923285277498314801657531418109 +7 10118058039965178865 10118058039965178865 4961667750818317362613906480098144764865940952200841314417231566144388604547 +7 0 10118058039965178865 16456984820563072751418216506499409546021186437638075412155118429554757975271 +7 10118058039965178865 0 20310129503672875530840712791862096664732124716917467116857147363484101509977 +7 3398253591082185807 3398253591082185807 2866585678043681191801418047708843065748586221094318643123160009245649472315 +7 0 3398253591082185807 19235927092608872095598545632476642898799424689241872933650214437499050968480 +7 3398253591082185807 0 14731784191271969072023936623165640714725669494245982509338785261542590191182 +7 11816181387475277392 11816181387475277392 7507529811560891383119833269038363327870570578300943828629406616533906064971 +7 0 11816181387475277392 21583505949887346001928358348988407677862316822993175928085054591278009663494 +7 11816181387475277392 0 7529119780146250030817507375389314670692812778068344329325327717955912298983 +7 850325821179457636044 850325821179457636044 1810934949645347982857117114274851991906717479024581945008445297615974509467 +7 0 850325821179457636044 9133396776029133734010109462478603885777182998223486764200272014317767115609 +7 850325821179457636044 0 7151808909718888274829190260613894663353011001581754389005877942526288641889 +7 2696714211671326766495 2696714211671326766495 10855232832375676942136011201785869216450911537180125020015308175360576088484 +7 0 2696714211671326766495 17790646145250396999648098771641462707337869198290695053954476998562917838151 +7 2696714211671326766495 0 17368303818363144771123728148909988510528733986244676528736227834362679429867 +7 3210962441719726621752 3210962441719726621752 14900097616518782875704097170938702869793742674415649566588236720149534569719 +7 0 3210962441719726621752 2945026408625255433440383280416843682705066498507862319872696515019652593781 +7 3210962441719726621752 0 6492307898805461080585477962899391985964046654324295903148697422852076714577 +7 3643349156370341308485 3643349156370341308485 12218285618184670730139921094228351189193611375280589667911788701465231637468 +7 0 3643349156370341308485 6610013964778931715220097361790225173998769867019254678370862841583285111628 +7 3643349156370341308485 0 20993880848267768244689381975724224760195594402433742166826128532968177870747 +7 714398887623897303953 714398887623897303953 1947890037324317436105541480419926105573119744057338112654908531834622744303 +7 0 714398887623897303953 9250171830868995487101008998160323633299774277136146488375042035116487263760 +7 714398887623897303953 0 20710658857184460646105804329176325617873425672701563990962221822942852897755 +7 4155381412326020807079 4155381412326020807079 13747017189617435028454063980158222819917240053654544692967921939546530073551 +7 0 4155381412326020807079 5067116292666091337471076820708060612541130944690188914532717977374699426603 +7 4155381412326020807079 0 4693378272036878719624722412815669276301458585162792046960432756832956911676 +7 911327320967728747144055 911327320967728747144055 20890475546133535493049381170744919034977167707029807111350237750083984579527 +7 0 911327320967728747144055 7155555996640880755215437445834712984526144188625049622385823685862144983783 +7 911327320967728747144055 0 1629498579531074390096571700970054704019745742130253789244583389629272086542 +7 467263245370211100115855 467263245370211100115855 633018334186307844286976316388552866794705518340009163695633585415378543375 +7 0 467263245370211100115855 19144959015006621801562529972280523004149890876706152217119969724975388673418 +7 467263245370211100115855 0 4030266559249132954261912046040649101537063754129079100863670388803473990855 +7 655808701419179759572087 655808701419179759572087 15193662725799774406202633805967050193629118262548548313806561749300356412963 +7 0 655808701419179759572087 14174948084259026336263790593374764560472578317961854015920898507642685724948 +7 655808701419179759572087 0 21154637956515810300764167226442792210299244203689356223641877317007260338717 +7 881827210254710265650471 881827210254710265650471 5946648105609758166090565372717489104515861507163037074924629038554233944000 +7 0 881827210254710265650471 20264671080413214380050871233990845452238027730276365246834635045525178138553 +7 881827210254710265650471 0 5356570618825672294988222157811187715998020544943875753326413389475921621451 +7 1179345910946959076869363 1179345910946959076869363 9045714891022482295454414266854061374758275668898447462769564857730596708063 +7 0 1179345910946959076869363 566973038521198259975502647366313546247017164605900696749494632684398291912 +7 1179345910946959076869363 0 12350075266268428754580121954722167497555076228633847814135211948747070565444 +7 745595805947126835550922 745595805947126835550922 3390362717033749549800649594815874014208862412275592160946789713302092601377 +7 0 745595805947126835550922 20943612862447941260669509413388471165876673526077028656047808340008515494889 +7 745595805947126835550922 0 7205482901279616356635595091178559072059299003147038524686575821549263317738 +7 218045160747297365344236945 218045160747297365344236945 18154678298888134414332932070096509701801471380633054728068421440170005416380 +7 0 218045160747297365344236945 6448616951396927953642081304912276570150009084713717833456898385997359721426 +7 218045160747297365344236945 0 11755288913732347532600959281209990091851505193717681770431602230716897648006 +7 24522045935225286884884345 24522045935225286884884345 21008677376444730118469263120067425715104086844365455461318570898405493182762 +7 0 24522045935225286884884345 13611779439312328288823718815644118333982567820399207684170324761792752806474 +7 24522045935225286884884345 0 4138282441979988188255606662300966558557420101481335246476698922432148538027 +7 97890126453504581864170179 97890126453504581864170179 21342058337668672458619576742180773422104657867759526349240079019705905044925 +7 0 97890126453504581864170179 17418634697718841974418272439827866846339028308480592282270450839970210554914 +7 97890126453504581864170179 0 8406607281004358897383918507623266931645617140926177886799794177548111490158 +7 50931854333844930685489516 50931854333844930685489516 10024812569768923964667013717870803806712121414300824872650425768557722833570 +7 0 50931854333844930685489516 11722152073847885618958837371805572028356567605577953180114045716459743149754 +7 50931854333844930685489516 0 1706097638807749343442280561581206849922779591543343120319751939240126781058 +7 171559591456638013403638072 171559591456638013403638072 10746523416739685081471157955280879357728883314917230403523492742344351244018 +7 0 171559591456638013403638072 7513231523613194936135795762400901688956987970323783693656840961313957445977 +7 171559591456638013403638072 0 504183159896349979507213746083753423317922424654815331755546738677974361980 +7 6526009484058238909748655 6526009484058238909748655 5383668383545033275260133552900905794633559411112692979930910001662766692405 +7 0 6526009484058238909748655 17581643436020787108678110972170069674763939832585831509293646153468970693257 +7 6526009484058238909748655 0 2005826955808608105357594688138694252608835367216082196258651601254349791782 +7 12061923421319134047835817581 12061923421319134047835817581 1302802504045219209824135509047200441011902376057841118145209338375376503020 +7 0 12061923421319134047835817581 11768462971473265115043353542342495473621419773758724801012744277159997679187 +7 12061923421319134047835817581 0 9492716649293500053945980958431346785580193666634182857185951649397210785600 +7 79070805016387524901754510580 79070805016387524901754510580 10635032621931071429484041980958209262991511519885635925995971772161803665478 +7 0 79070805016387524901754510580 7969302250629248793658141602849697155831519655715412962963666059265601019156 +7 79070805016387524901754510580 0 11012698933324701291027626065736203005374535929907279271293023768239814608819 +7 61472585212647853537800001482 61472585212647853537800001482 5746369103013087051523185800323320571250789124261252451924587250888373011891 +7 0 61472585212647853537800001482 2795753558002648120066416989654041730243712742657079037391421975593713953123 +7 61472585212647853537800001482 0 1055642277915257165422842459064501139787969943794841353826955655421369581226 +7 61955482337934879172876116398 61955482337934879172876116398 16966133839960711799786667549242945241270780151358407614056353909162372339191 +7 0 61955482337934879172876116398 12032180790851391011873886991486299808706105674787352733570040701008081488605 +7 61955482337934879172876116398 0 14729411391718905525084476138800675046983446328076909184186859727805848017668 +7 7465023689022957439423768298 7465023689022957439423768298 1911506379704135985816289952354450030570687907032677271718575401136789017766 +7 0 7465023689022957439423768298 3157462528397357850522930094933941863032451637722690434806392603537547646671 +7 7465023689022957439423768298 0 8618452690342327196977883085727400989587397620483366622450361452024620221061 +7 56183431555817343915384150830 56183431555817343915384150830 13904998746874912568477424714122721272195801301911132763604253474247778523714 +7 0 56183431555817343915384150830 2712287335426548843440309213758022515541973134224854195863613359670138159891 +7 56183431555817343915384150830 0 9699039466412801863927137584892216150897024488877269855185533628403974767285 +7 11769744061594084440604515640355 11769744061594084440604515640355 17138355651884258593953784438868917934134993230646688018621673200383621231559 +7 0 11769744061594084440604515640355 21663566486324301550592824008096280679617307702985857904044395376713992365455 +7 11769744061594084440604515640355 0 163673036086048352150123025425169606966272295408291729768857056410925782096 +7 1959958078535868962721082190998 1959958078535868962721082190998 7808447674130004806126241281800275298724008015659828727294940605182687157015 +7 0 1959958078535868962721082190998 17947308648050599518141926616816311104521969502567575867307937920590534543548 +7 1959958078535868962721082190998 0 10676032156705526183824542663223157002680349693364409226714151156765869349959 +7 12232061141953593371921163503642 12232061141953593371921163503642 8958516657041031468950004222766813033935645272304200345256007684244149234133 +7 0 12232061141953593371921163503642 9515795738063628156729412480584542912808309132569388185277603124172325928438 +7 12232061141953593371921163503642 0 19434324445679897497863240438199360686970583665723673324820104377293965941114 +7 19960988147769851237222055447697 19960988147769851237222055447697 19516740004090641609373921843123905484823403526929251265096392886774336637338 +7 0 19960988147769851237222055447697 13697452656393352217954974033165859232205008633736434844981419475384106588191 +7 19960988147769851237222055447697 0 15383170821032983185322845064689044961685283943032523951626034625678116597607 +7 836903819861062467690819924272 836903819861062467690819924272 9264600368169122528698083189111758794834930183476516533097388431374349807586 +7 0 836903819861062467690819924272 2127615654889747625164555557314801557026223065829531870236701540895759065596 +7 836903819861062467690819924272 0 17183152315309836362311149245518712801936484735383307832475824257601832965619 +7 384319725957180300992859010706 384319725957180300992859010706 9264548776632015135876585721834228125363068855432875409145884336117153743933 +7 0 384319725957180300992859010706 8023153217202240953151181861336309347313476997930591287083863314461786044903 +7 384319725957180300992859010706 0 3880454614671360858592263427255855869697199829135665891826545474760684264614 +7 1932475943339967312129793763190817 1932475943339967312129793763190817 18031841505932144068315041289416869498819269873348731695053724440232826349806 +7 0 1932475943339967312129793763190817 18951640515495808138699058294432053299219102574645360738797426973147817291000 +7 1932475943339967312129793763190817 0 11273533787853413784326715785801155870529981362076302376934367636031466361471 +7 610439696815129482695774739209587 610439696815129482695774739209587 21294576649980853239316341479145925453873844276157349301523860159749435746575 +7 0 610439696815129482695774739209587 11867355915414792604894144304678368690863145804891021100906826506405852700692 +7 610439696815129482695774739209587 0 7388903020180474081431550211427630828172749120805926581629028883579546553691 +7 3787149410712295177878792169857892 3787149410712295177878792169857892 12668091136672104633775177326050815905283302892999902178300156090916303891325 +7 0 3787149410712295177878792169857892 7667372633411171783210455684663982990403479556626182864009420804965569090237 +7 3787149410712295177878792169857892 0 3825300170002551027739524563896996780253131778513081610938340384613925688429 +7 423949996454357483389660951725799 423949996454357483389660951725799 10265753970846521636452659989703739895064201472389772711478976956761709582284 +7 0 423949996454357483389660951725799 4709828461631159008970927381524478381998434058296323392519532322355100852901 +7 423949996454357483389660951725799 0 20187101404773777930994828998300448734024869332109704776615157475946575316020 +7 2920364823816801855046905974856322 2920364823816801855046905974856322 14707182831941364812047434190495547323184693981725641193310288664646738449895 +7 0 2920364823816801855046905974856322 676153090815432607712344049947303561973435916649767306761427328890635431047 +7 2920364823816801855046905974856322 0 20111409278560070705135944394734409831499157736307590335931126916740506123223 +7 4605609385664024730646690906940561 4605609385664024730646690906940561 18625228461930294447298053619323440529215628829049837754298570611668421084979 +7 0 4605609385664024730646690906940561 21181363599252524061682848164304559027011046743681814369927547111255773478753 +7 4605609385664024730646690906940561 0 19973069730874702546993080433193816018100943604668133094064662149503294027397 +7 653839462055493951241793095237800201 653839462055493951241793095237800201 9569987927778967031826284767088733837810187210831455802315659451842622923705 +7 0 653839462055493951241793095237800201 16515390426982164471539613868438272078494413327415859178481369096870428734761 +7 653839462055493951241793095237800201 0 10424062811553458032586522867760562550658817924390384155058873489751798783736 +7 666652131310030688057848245753204302 666652131310030688057848245753204302 5444904335324781665124783854434993372948012785502525181789583624333354961091 +7 0 666652131310030688057848245753204302 1460073014411137101305349667725571557986657098658789925078633781426402099755 +7 666652131310030688057848245753204302 0 8900423460954792121501984087202659724348351011244717906306864619476100407289 +7 1192350435342999182930464330615118438 1192350435342999182930464330615118438 18363856355067307976252527989552520018322852212900539975388583966692532671985 +7 0 1192350435342999182930464330615118438 10615128446566974569747786760576506100398101305667084815179158454490713628821 +7 1192350435342999182930464330615118438 0 7538247263591261820330622213701499681075750962970302110923821864484947294732 +7 364440556429458984901083262324218134 364440556429458984901083262324218134 21170497669340251793943226279094514418106578300873715183381715423170678220286 +7 0 364440556429458984901083262324218134 11534013076762365885666601294288143874067922109107615020159082874355673155454 +7 364440556429458984901083262324218134 0 4649917414621955998585795869876138327887207534541179799869121497157357746216 +7 773366488443620292022834639398137000 773366488443620292022834639398137000 2648277399766832187689033149803409792142037820699146553202119365614839422538 +7 0 773366488443620292022834639398137000 9996669420312159726253197271511432164765472164232943315007307670280889559713 +7 773366488443620292022834639398137000 0 4938851597037254182562280436463987545740518254444761349788584577557120593928 +7 1125844340888105386198157359361893269 1125844340888105386198157359361893269 19592848618130130196035076363341623565413939957786258440720631407172550020171 +7 0 1125844340888105386198157359361893269 20807898790249817780610458542826929221554060137644547960065680127980719464458 +7 1125844340888105386198157359361893269 0 16119393160459571808059675364311983803361980443416803772533647633553889684811 +7 336777852013281045953173947904746055564 336777852013281045953173947904746055564 17076284137460955125112496228581583659493415756937360563530221729666039457747 +7 0 336777852013281045953173947904746055564 6348852028130800944962601243490502783794349615458168415815370710896185182046 +7 336777852013281045953173947904746055564 0 18000797727285704865834797296493827636282667635240129357695835492846059272672 +7 136672384301875357812815697444352391864 136672384301875357812815697444352391864 18511047139730020717604776011963131061963127147632084674991837514958313477929 +7 0 136672384301875357812815697444352391864 18775542053006037171658517613648433536014425390837985554814525391354707974537 +7 136672384301875357812815697444352391864 0 19135135109256131751951075672065504489038939955707133184967752380263105513957 +7 74096832595191725222360602651747320764 74096832595191725222360602651747320764 15062072335821993794419746324379761301960783263802012336992468574511745511513 +7 0 74096832595191725222360602651747320764 17853662436260044943951641256377083771550916055250145054197035694793026079322 +7 74096832595191725222360602651747320764 0 5929934995004943846168304493398435142179979677851691693860778480816231143743 +7 303545207801252939054913100229146912298 303545207801252939054913100229146912298 1216017676662556145094930636106084222497128689606911392390654012671832727391 +7 0 303545207801252939054913100229146912298 2029461504776659573447305146333387978480216099762145629033184781715078778863 +7 303545207801252939054913100229146912298 0 13919068763680025710312696615306636051901888221271867326680512351704835073212 +7 78150906523588029665601061113619682175 78150906523588029665601061113619682175 1381264062005659361614371727044797180831444513438664013479203524482848366023 +7 0 78150906523588029665601061113619682175 20761494002814374101983833959655057982089082780587454600257761237708260298550 +7 78150906523588029665601061113619682175 0 3082581663713118877610034942548422456433831498306222983148045865351432629821 +7 306228989724981450180225344978560285690 306228989724981450180225344978560285690 20078078255504846156822904264105708583786047414583470661766428971789663177902 +7 0 306228989724981450180225344978560285690 9147803222301189826497534844715231841829747748939038840849890845154110991604 +7 306228989724981450180225344978560285690 0 18669124461876335364540910046875806102486306847880120945907763673632620441762 +7 80220964956923768546511561974942420978646 80220964956923768546511561974942420978646 11734917038390699785862331356963464072593019938085932375042574985142072566946 +7 0 80220964956923768546511561974942420978646 14502646061583219349067830077892984130590676541521248503098668649377467930903 +7 80220964956923768546511561974942420978646 0 207480467498562694786828810585956091522316912263959826990617579116914707221 +7 83114820859383843424716870542574437838881 83114820859383843424716870542574437838881 6491842521156864330438157350678957136867926940887131046023651645778685404432 +7 0 83114820859383843424716870542574437838881 4688842135982343099013001021833345386475776647409638471358463827287896451765 +7 83114820859383843424716870542574437838881 0 15571322701941329724363901745628422112547071242837864516665860731178037149404 +7 12677779678950859762755739149228220057426 12677779678950859762755739149228220057426 4746467882279956064509101249048768832441996085430396455202739455314820467055 +7 0 12677779678950859762755739149228220057426 8910603723699473625308464559756529753692149035987543713255221468332082350957 +7 12677779678950859762755739149228220057426 0 4772647089753514694245416800176633083171176496618392242438109247310587023539 +7 66361730564944866742624675210803105089120 66361730564944866742624675210803105089120 3954040981196929478071863595357602392465924710055557472769887069865395208320 +7 0 66361730564944866742624675210803105089120 5958297458484905859684856168531573790543035475992573141380545046617293772299 +7 66361730564944866742624675210803105089120 0 5508744720472769501136518219199672090058287017788139491029575423441417641738 +7 54785003186029088736126697012467624542500 54785003186029088736126697012467624542500 15604404239223554489805845645791820857188926738970119517325252455008474526553 +7 0 54785003186029088736126697012467624542500 13549672323304951726193757444810077202886921121040402410199927806949263758153 +7 54785003186029088736126697012467624542500 0 16986487793384829684565420351541703923860196871187541890939139987419478192924 +7 77675752274509501985761251130117903670260 77675752274509501985761251130117903670260 5585668392600860439518041631286741386760461970739975616853604152200889918322 +7 0 77675752274509501985761251130117903670260 20137908424372548619779398484303530845510824766881663744263324648609049483619 +7 77675752274509501985761251130117903670260 0 12122042647526686112360757057255142799525043249112618410362678713888955155956 +7 14559285341304636926758293787085554773261874 14559285341304636926758293787085554773261874 7031171866300484727390257743248652085789251779588511609883568027676197178096 +7 0 14559285341304636926758293787085554773261874 11115697702607548266423107004050970975539193359615537725089728788485294990452 +7 14559285341304636926758293787085554773261874 0 1027444010738443777926643843740382920029029390130760623907003171750368917152 +7 18820494380150631875759105472470815557645141 18820494380150631875759105472470815557645141 21414889370854318813762550202931222452583030087526621478441197873145393263317 +7 0 18820494380150631875759105472470815557645141 4181104772639808555088344869604134059224692352248208718594162599918455457010 +7 18820494380150631875759105472470815557645141 0 5615971192445727763242425315778230549091074806525054521840917442370995618999 +7 6149796273693798202443248169272226654630857 6149796273693798202443248169272226654630857 15490725342186756675716527706635519020196974946137482910061446865866753632910 +7 0 6149796273693798202443248169272226654630857 20507435382115056835137370931321482769938717712210606337082294413221375231372 +7 6149796273693798202443248169272226654630857 0 18309904409745781467526097547141395677233836366579400894273177809357516973248 +7 2547524368453373120125395586564263390260278 2547524368453373120125395586564263390260278 5637827685325284172830286699795527337622746028604414198476620094006246382270 +7 0 2547524368453373120125395586564263390260278 16936310212740378301503111302630592276839385308342211835513964259397894552770 +7 2547524368453373120125395586564263390260278 0 10489859967333847081169196430135748448306744664229014938995520548654706413000 +7 21952129252755735065037778684681780866715277 21952129252755735065037778684681780866715277 4031187428833372322025266429421699725062744517840909466268201507068174530409 +7 0 21952129252755735065037778684681780866715277 1421443181902385562772338940619468336212343635292474579787521958589956023499 +7 21952129252755735065037778684681780866715277 0 8948150059361468893957005441906617443093318540508854626314024772094768879403 +7 8380302287207060269812091071571863722099559 8380302287207060269812091071571863722099559 3890111933307584146850175150758974096819204010471974098015307476563790425492 +7 0 8380302287207060269812091071571863722099559 20261926376262906512932341077420376815208535142345188969797300461995501125253 +7 8380302287207060269812091071571863722099559 0 17126086955566537109870725539830967579514742128928073454342516651549178670962 +7 3530626645970210560010173045880777604300997701 3530626645970210560010173045880777604300997701 3281534994821398752538458286027478385525684113961664017890138559413144274316 +7 0 3530626645970210560010173045880777604300997701 936570016963913088039854824783797082746839480928944133876851327734853402761 +7 3530626645970210560010173045880777604300997701 0 9672785538773090105278367099804206206099633908167291425859400389847603365478 +7 4181765743007741806407141951059598011198121997 4181765743007741806407141951059598011198121997 1249025842961523087958757478114103792851807414874717455820565217852471878759 +7 0 4181765743007741806407141951059598011198121997 20455827160151358371294392114765394450322634030382806255175658940108419550698 +7 4181765743007741806407141951059598011198121997 0 1224196702107578276790275954723178482173355441480676991238073111282089783993 +7 2878549595822803610761344142643107794132464232 2878549595822803610761344142643107794132464232 349303146593160788014641149695957342018168329381407966428069019796522927091 +7 0 2878549595822803610761344142643107794132464232 6868962717077785916481113074928945331688677599277359873817569052439043955680 +7 2878549595822803610761344142643107794132464232 0 17786185275880785242000021056441794713976491680551039115452386317633221318926 +7 3912253615592984659548099740425676571057027410 3912253615592984659548099740425676571057027410 7589689713732511668140882374426663173824966542090818745902477366171487032251 +7 0 3912253615592984659548099740425676571057027410 20425884119737888375537163836140789082983581983041166148127914044594160235204 +7 3912253615592984659548099740425676571057027410 0 7494320822969028507965789703136500313589266466018083334921948822469347064096 +7 2449684460370649100702255039789615462477778616 2449684460370649100702255039789615462477778616 2855596619330039254128048979881647988329782474853635916210039128194038458607 +7 0 2449684460370649100702255039789615462477778616 14752503645363477335666223345333929350071004822240529451102303135999402080912 +7 2449684460370649100702255039789615462477778616 0 2293985257887516270785611461806372401657591347974693242864842655773274848794 +7 3936161308768608900908885495753546914373906329 3936161308768608900908885495753546914373906329 13512725144915191187762489449963452944442058375241994524032115731832426888872 +7 0 3936161308768608900908885495753546914373906329 20900589836216995876725458484133806921647419203636380618445039992505182901043 +7 3936161308768608900908885495753546914373906329 0 12384811682453449288378469937690619032264087515831521477896452637241841340211 +7 1314026903421240177218054411556991432988596183301 1314026903421240177218054411556991432988596183301 12486050962155233462744004233398446381708747173272804991212455725249829418989 +7 0 1314026903421240177218054411556991432988596183301 1580691663822969388936597546406869050636037456047606515762999280756146937886 +7 1314026903421240177218054411556991432988596183301 0 19071422650406750930557057360761681087765132233290394384644132889417003198357 +7 227837593837987129606941529416786612111127225544 227837593837987129606941529416786612111127225544 5421778255630300545724903444057847405678329387132661980428854730233471986919 +7 0 227837593837987129606941529416786612111127225544 12864098895677123969305375950148206122811366483045317961771387858483359236825 +7 227837593837987129606941529416786612111127225544 0 21340878580315606616320796067335746368014431444672718380145402339784059790152 +7 889974949056360359395658763633643269189042108464 889974949056360359395658763633643269189042108464 5304126368469391130432269883811987314806419741160612977563571734237969765638 +7 0 889974949056360359395658763633643269189042108464 10907191013498905391045984602694711962355306244340819179745784868148538227487 +7 889974949056360359395658763633643269189042108464 0 1665262641772048410139990021592106762849978612363778138568674658224300085421 +7 38153598881835967574629407513077522949850516365 38153598881835967574629407513077522949850516365 4608420777010931735341581337840278158501340037111433283934036351022624797067 +7 0 38153598881835967574629407513077522949850516365 230793395624911080182684350756166640691292041137842834702057816986689459331 +7 38153598881835967574629407513077522949850516365 0 1430454472490737867004164518848975745465852663875753909381257934069777942551 +7 1434893756014855990246071623088496493038523079615 1434893756014855990246071623088496493038523079615 15638653277339556312179417048242054260959383890934888920055816573365656753739 +7 0 1434893756014855990246071623088496493038523079615 2849432529398845400073776820855720429429048449082158361361113637806568441584 +7 1434893756014855990246071623088496493038523079615 0 13669696091945013325484462916973963925507729440553933540327755443449326246398 +7 1379705398060529471004162824082325091786876614434 1379705398060529471004162824082325091786876614434 3442207917519851831761616386426543469736183170542061913879559419137719823766 +7 0 1379705398060529471004162824082325091786876614434 19036909613229178338806340013253541428818189288178359977178544152596398309292 +7 1379705398060529471004162824082325091786876614434 0 21014205316224245185251266973381321190866057471916881889598309378726119940063 +7 126728268110396424903936561391870702270068656618385 126728268110396424903936561391870702270068656618385 15463531189827708447405973960081192932044141850032653836073940071650600517686 +7 0 126728268110396424903936561391870702270068656618385 12239135004552754048478297042954515739405136646199427594876218979633297116383 +7 126728268110396424903936561391870702270068656618385 0 16605223173457035360135575194838125209009892616905893175253542440881545946441 +7 135847959316337713875080304453649776579211134352801 135847959316337713875080304453649776579211134352801 14742571641506562725997383800695033219738618788769275951289549891105938709520 +7 0 135847959316337713875080304453649776579211134352801 19517299429412615595209846559345214682697075979909008315204156724215725678311 +7 135847959316337713875080304453649776579211134352801 0 7720822423492660801522763826209893674031735393863579108455783093400332755516 +7 343210389400620850128734241964197438365066535361364 343210389400620850128734241964197438365066535361364 8453199563338682209813510357062308832663868193259988952393295466285136102984 +7 0 343210389400620850128734241964197438365066535361364 9406293179439781274342822776008387643900471482945578492475452445778201212476 +7 343210389400620850128734241964197438365066535361364 0 12396861514824825849945254251730079580212108666909309754493133236092539444765 +7 249094987265047502574019562144644258488514356394152 249094987265047502574019562144644258488514356394152 14324241285621365667218648256324766395458047669317877455065713323685432616158 +7 0 249094987265047502574019562144644258488514356394152 5998798936375208960289788517850376566530235957562113399119182346837175830796 +7 249094987265047502574019562144644258488514356394152 0 17055503463200757328576404445952710039579937368769301428126231516906614170163 +7 179701302212406085969378994254321104305849480006512 179701302212406085969378994254321104305849480006512 12549623987421327997630362873670323044480702755727634292368311039292223916898 +7 0 179701302212406085969378994254321104305849480006512 17614844094663528840098989498914726233649569136654478048759035557521595015945 +7 179701302212406085969378994254321104305849480006512 0 13384983989128466222959066622007213952240924423303670886887759956367895183233 +7 213635611527811835084917546952121277048883657425941 213635611527811835084917546952121277048883657425941 19150531119815173333627286298840347110171518061611081473124925205413460202995 +7 0 213635611527811835084917546952121277048883657425941 911913226658128297422608861286732085725097865749593389403309073977521754975 +7 213635611527811835084917546952121277048883657425941 0 19245340711725556835968585643876108084173163428656941064482571326811360539182 +7 73296190539720074645892389997094505176564967199428304 73296190539720074645892389997094505176564967199428304 12233102472366966662490036904454561210722284904478346601881913294958164759406 +7 0 73296190539720074645892389997094505176564967199428304 15515420136332042572892173371838221475001542371637881634173697968888358037245 +7 73296190539720074645892389997094505176564967199428304 0 13263581283881992057241846004932976342728398589567896899951651305882469778129 +7 73443204751576137996666238736118219317384293842168887 73443204751576137996666238736118219317384293842168887 8035312752357380069004995363703036131151938995865412386216494376384186651673 +7 0 73443204751576137996666238736118219317384293842168887 14009155283798014183740064911407008195501954439942522771804830355225330012264 +7 73443204751576137996666238736118219317384293842168887 0 18183550898257050822835203011296782852364874875499029801733987439078444855600 +7 75346141797110845751499798607377671395550379587852787 75346141797110845751499798607377671395550379587852787 9599766123338477879059333997840768903452766866635813166737455886624095899697 +7 0 75346141797110845751499798607377671395550379587852787 2962616518331349691261648286597041547446608145264425679601375958811875299171 +7 75346141797110845751499798607377671395550379587852787 0 9447619049181019230493503968352947304194894842979290909790675932631127054138 +7 60471697093024325423309714208221210863756311378395733 60471697093024325423309714208221210863756311378395733 17348571902168880471511602233167687740727475248801058843207369968462591870612 +7 0 60471697093024325423309714208221210863756311378395733 13295533785265422358028514784270742253129124531079379146401885525483766825770 +7 60471697093024325423309714208221210863756311378395733 0 3794584065000485957462096712645111109888388997632843568402689709416553002378 +7 36778681574647414811885506899920601904220321426739615 36778681574647414811885506899920601904220321426739615 9387797632806525675436447580805775897406345294984609268214698994241417916018 +7 0 36778681574647414811885506899920601904220321426739615 14647815764764316589561023729138019474786343831762854909495915671904528249187 +7 36778681574647414811885506899920601904220321426739615 0 14207823044771008727150636651539822211108135611559024237714163199235481193528 +7 74341461027885224754932959824435427322423132583118384 74341461027885224754932959824435427322423132583118384 880465614411063189850154408036737629177024327809757605666371184131910776138 +7 0 74341461027885224754932959824435427322423132583118384 11600957954759362716423833259075512168148633725087951683030250149451166679694 +7 74341461027885224754932959824435427322423132583118384 0 138866565562433155360643872441317003002683943726073056999553294714318238232 +7 7695385699779130713497316032948858712104664779302187232 7695385699779130713497316032948858712104664779302187232 10115680038057183907243812654147838291263571122669248856918544295434879077996 +7 0 7695385699779130713497316032948858712104664779302187232 10541920562929644148407287117731118635950459663320066824518848997286950463574 +7 7695385699779130713497316032948858712104664779302187232 0 9476561245828397265477540460738445757061385267799836527460490822266330391737 +7 22769408045522038699946595093145906985103566531853678864 22769408045522038699946595093145906985103566531853678864 13546215693878164449079924096993611109214083172272520232760187687059786609592 +7 0 22769408045522038699946595093145906985103566531853678864 17673131758233210152551789819665353833129451550397773721269546300507704226177 +7 22769408045522038699946595093145906985103566531853678864 0 10403066839774261434409357707173922086412773601410916458669427623695207600174 +7 6888021322063264915588465093169606684392106173354408411 6888021322063264915588465093169606684392106173354408411 9745596821438241727935787206021946084148365557946441831690096822857659113606 +7 0 6888021322063264915588465093169606684392106173354408411 3064650484571206551530939099001206977131658957008022279663373445186571865360 +7 6888021322063264915588465093169606684392106173354408411 0 3663881766848095863702366789314011100616064321157070271868762223617597504508 +7 21951794056060737693629887525255151366087219521964486001 21951794056060737693629887525255151366087219521964486001 1805956036758013025643915464926179116529693731545755622883852989219070384789 +7 0 21951794056060737693629887525255151366087219521964486001 6836486116731025890658533636822987105916644203062298612692140549590783221145 +7 21951794056060737693629887525255151366087219521964486001 0 16399317006166553333639878797112717232396693165072586081095849659733507941655 +7 4481839468812829843982546398732157131593816927696954243 4481839468812829843982546398732157131593816927696954243 760388190738781454964921659422102538383413990120583344170981001891509084052 +7 0 4481839468812829843982546398732157131593816927696954243 12087025494238585257517425341495564323203437416296959198596475059283763614189 +7 4481839468812829843982546398732157131593816927696954243 0 1224883317073428354757171465998932032589611847085562315092579552777637220569 +7 703868896556918089428492247531385439597180971220512114 703868896556918089428492247531385439597180971220512114 19000727395560279612142641626379503646932316785457997887813476103339567756483 +7 0 703868896556918089428492247531385439597180971220512114 14366758938507922522414534781390963579463729946671733093907271685866051028379 +7 703868896556918089428492247531385439597180971220512114 0 12061541387141414010987077743590914676451400781786409091457288377611900130244 +7 3697842402077037627406658697214965693694719301115015263477 3697842402077037627406658697214965693694719301115015263477 19410283453110099953574830000760488373438715730407892511032937232843176225138 +7 0 3697842402077037627406658697214965693694719301115015263477 12246367295051549464824510038042523868383177674658906114924436408690424974457 +7 3697842402077037627406658697214965693694719301115015263477 0 6082567702390170501731350930641793719302115940755406452887763240719780289398 +7 3408977889599140561203371406564231369145216481691220834711 3408977889599140561203371406564231369145216481691220834711 4051286150147656759781082085601245994000228810489590032398897871044006578146 +7 0 3408977889599140561203371406564231369145216481691220834711 12727414310055064340090421502917905839956098863589431703327346794775681290317 +7 3408977889599140561203371406564231369145216481691220834711 0 10037599000877407086020511375526358793340754571075220785524604139809263497375 +7 1551674706602778625427900003188357108872225900307679292851 1551674706602778625427900003188357108872225900307679292851 15378742702097444167307471921937709125697707307279722238382931292902276295936 +7 0 1551674706602778625427900003188357108872225900307679292851 15035314978025734390721717454149922380501798047865327099870901392610411471158 +7 1551674706602778625427900003188357108872225900307679292851 0 15370909713202870104814864678542807933662123774516755605800417023140618783582 +7 2824652666497862771454697486721970714677743252036924756997 2824652666497862771454697486721970714677743252036924756997 15071908282891624185856333347638711247571599848433241946418953580622083442819 +7 0 2824652666497862771454697486721970714677743252036924756997 18340221730383864226830987906842055898363967140385977284559471939433745496864 +7 2824652666497862771454697486721970714677743252036924756997 0 13095363524555090526344227224838547170832433014769335342722571557821231899553 +7 123424453877070008201438892350302888041237151801771918252 123424453877070008201438892350302888041237151801771918252 19414822208351213491474032864548257067561414678806441885997920567698138523185 +7 0 123424453877070008201438892350302888041237151801771918252 4083302379503170790231989873883314006492816999606271230091268200665718621832 +7 123424453877070008201438892350302888041237151801771918252 0 9899939594871650873455378488919234272177271324101891924823177977092273545408 +7 5827319206658548511917635024732043045649861679339407262394 5827319206658548511917635024732043045649861679339407262394 19658470906268209988450700037054217610405594784731589142436307733344811841133 +7 0 5827319206658548511917635024732043045649861679339407262394 4990143961900574378657363689892877930673607328018682562339976450908923029047 +7 5827319206658548511917635024732043045649861679339407262394 0 11512772035136083557491070595625003912857214736161643886805897486503384914616 +7 934621944414725634188581240157401963554557110465638601479238 934621944414725634188581240157401963554557110465638601479238 9294122188580598402241753389342129688861755804794215915771987289072799702258 +7 0 934621944414725634188581240157401963554557110465638601479238 4923167010995310271583978038161265435998654987279640230012559911097321009650 +7 934621944414725634188581240157401963554557110465638601479238 0 19516826384655846213186623990567499098263431014270800890692000971828335363655 +7 1547022958903142990986230489894848553312796848975500181692948 1547022958903142990986230489894848553312796848975500181692948 2750634595161451698245560519330183720181422608974850450188405556735803626253 +7 0 1547022958903142990986230489894848553312796848975500181692948 15062484583115566599198512431736749321586485298096978181575205088376981469883 +7 1547022958903142990986230489894848553312796848975500181692948 0 20607919581835078554324581051470948639495369558438655575201351787592089366438 +7 834319305919447894018161867006850474576774935071378519987971 834319305919447894018161867006850474576774935071378519987971 11551078730726226108052686978661002233332575893192554651030622764664353446409 +7 0 834319305919447894018161867006850474576774935071378519987971 5682417706684098194311815220517103444554686080774543814024932862219689102320 +7 834319305919447894018161867006850474576774935071378519987971 0 17402839365135556159536231093077746515934634198268368859333277587142263203233 +7 1423985256945517096383950848322286392569148823865636583131238 1423985256945517096383950848322286392569148823865636583131238 20406237953205315335771325223208081737069010373795139627711743296912204131290 +7 0 1423985256945517096383950848322286392569148823865636583131238 7728725589495302896629712042459230330395090538012123833431077273530057558000 +7 1423985256945517096383950848322286392569148823865636583131238 0 16095189741167082142757396336529784021850756389451889230832021137837833423019 +7 78407278752470882460205057114503019490758026790955614647505 78407278752470882460205057114503019490758026790955614647505 17962432893951597799262279848489608670709287854569134971328573691151348914139 +7 0 78407278752470882460205057114503019490758026790955614647505 5675805654786663263086057556492839514913411419302562120691363972556313073129 +7 78407278752470882460205057114503019490758026790955614647505 0 15319842164380127179424855638653210402805813665036423519442284521418625242437 +7 1356510959043953332610177119199927897890935076806120728123218 1356510959043953332610177119199927897890935076806120728123218 14541997279361440729540949289616751641240354447358790448291966354498995810440 +7 0 1356510959043953332610177119199927897890935076806120728123218 3908142001953388872221689762597918543863723241005499295151849225484829963164 +7 1356510959043953332610177119199927897890935076806120728123218 0 11508447958259043063879242275736742404840784854331776536021889760184403784620 +7 45029946681010977501704472577235929022270187064854559562788025 45029946681010977501704472577235929022270187064854559562788025 12605378031700119547223380785832307009238668353830531150950745216726133356298 +7 0 45029946681010977501704472577235929022270187064854559562788025 19701148620761768995554093170318469842310838939976878285407082129113076165721 +7 45029946681010977501704472577235929022270187064854559562788025 0 10553182681208384387306622106974157893504916374163818256926139312103673461451 +7 71121772000017612837601795185741898103294121514978404279927022 71121772000017612837601795185741898103294121514978404279927022 13056923635744230603431529328109567536138229432685351119056791960736966986566 +7 0 71121772000017612837601795185741898103294121514978404279927022 15948035305600327249969062775469469346778456075017892195205924894417970192726 +7 71121772000017612837601795185741898103294121514978404279927022 0 3123056766797618383642351682793779001099101011746747741947965505111846755234 +7 351701134820991236904165396525910865019894306037934853000663900 351701134820991236904165396525910865019894306037934853000663900 11944160007575776331066387485555265450768035669619247248147091542533884579114 +7 0 351701134820991236904165396525910865019894306037934853000663900 1830268126198572650219830666368884192257416104591147649250193700238622863603 +7 351701134820991236904165396525910865019894306037934853000663900 0 8937958634325442801454293670513585183347753080393029551726950904995907728078 +7 184474093158212492748835145195920156492337429678208537608867061 184474093158212492748835145195920156492337429678208537608867061 5487178106459188549645395174932411843477829933717593455583355788435741813104 +7 0 184474093158212492748835145195920156492337429678208537608867061 16618979616136152797339359341015545034224035585852793732956285484211962227027 +7 184474093158212492748835145195920156492337429678208537608867061 0 10228900522461201729212214878225683375012684577195889503558741948749658190835 +7 199389399670695255063380293209033944893100685561421637939408420 199389399670695255063380293209033944893100685561421637939408420 17611843423185660448247082563434415821613861679331418645769888662758916553196 +7 0 199389399670695255063380293209033944893100685561421637939408420 10364847641840550769942656131600009656390619290521197147946379481405385358236 +7 199389399670695255063380293209033944893100685561421637939408420 0 6595036896144407838172469783469595492936711672415161184120678530465681471170 +7 229750663215959825861733302345183157474670810272599228330177204 229750663215959825861733302345183157474670810272599228330177204 1154460331149775781418097242353182180830788005044602952335412237304671248429 +7 0 229750663215959825861733302345183157474670810272599228330177204 14046916959330712203968764964794563033793107771470964326695652990881000447725 +7 229750663215959825861733302345183157474670810272599228330177204 0 7906955323817334541421309060705295359170523539324565627885382569995903848612 +7 36138769411830975130261653627209591763277042851294292451158065315 36138769411830975130261653627209591763277042851294292451158065315 16742323902510637532248251542153200045717085783939503801095530714259667297768 +7 0 36138769411830975130261653627209591763277042851294292451158065315 8457553111501611531655911641166993528678252467975120789823663466267361160402 +7 36138769411830975130261653627209591763277042851294292451158065315 0 20460027702772047680553536714732554783567700072203586829242088714869040292800 +7 68674301456209479167069519631088993013396933844528659309455875325 68674301456209479167069519631088993013396933844528659309455875325 16695493464523510060529666911112103326479365281509187587792916358196282766471 +7 0 68674301456209479167069519631088993013396933844528659309455875325 12461307782284093661798987829515658336860844280799914899569515030632206934622 +7 68674301456209479167069519631088993013396933844528659309455875325 0 18940935925937754646715457636493765102239442822878133147542526814271956490936 +7 66363118198215167119594897250200664868066119799832865536011772642 66363118198215167119594897250200664868066119799832865536011772642 15411416744514574718038114761114613419877670142389107693642880422338313469345 +7 0 66363118198215167119594897250200664868066119799832865536011772642 21073776859139110195711455362606099317001219618492179185480106253608693978941 +7 66363118198215167119594897250200664868066119799832865536011772642 0 683283937878502931071789940468476766583840144281618405031702122216783998094 +7 69836203276541210929265183980925376150898448337084015848203253156 69836203276541210929265183980925376150898448337084015848203253156 16256595328649527994225028331316048091563117045138417753838853762928294393207 +7 0 69836203276541210929265183980925376150898448337084015848203253156 1171442120486165116052098625258604680057294087299979688226274544274138496933 +7 69836203276541210929265183980925376150898448337084015848203253156 0 15938617260102706632247396358319229717389868202510170565008399901788080479531 +7 55192622182575869878545994120208993873054428775743878640903837432 55192622182575869878545994120208993873054428775743878640903837432 8604693103185337422987433980429608652488043403333105684356774517116454183560 +7 0 55192622182575869878545994120208993873054428775743878640903837432 4578090660836542999290179921430528936535069087707826186563502566668868587687 +7 55192622182575869878545994120208993873054428775743878640903837432 0 17012871559020341549127871225699276619839485196279270598551022310762030878147 +7 18887881242658620578146448353135118138755901290331992459374898034 18887881242658620578146448353135118138755901290331992459374898034 5775630818490431041021152941876402087526160628812458184998805977557271542749 +7 0 18887881242658620578146448353135118138755901290331992459374898034 4059112016984523541356862756931564347890622687854889831524564298328783416908 +7 18887881242658620578146448353135118138755901290331992459374898034 0 4337594860839002382835798668699314202978183979220787690268322719702987474609 +7 13727998743993022067091585713741680058436657881427703334898807217994 13727998743993022067091585713741680058436657881427703334898807217994 5568989375493051617477698311466733397787391237415221464123246523274696062227 +7 0 13727998743993022067091585713741680058436657881427703334898807217994 17175235976546040923671041956760302148196864370492278094330089764277884765052 +7 13727998743993022067091585713741680058436657881427703334898807217994 0 15942810308781160596069034474565268425710350460823031162887049878506718391348 +7 23796172715971093073357699487486537923828547572589267391764537117614 23796172715971093073357699487486537923828547572589267391764537117614 10953914693263478171623139488932430514582502756404725713352643484324137847745 +7 0 23796172715971093073357699487486537923828547572589267391764537117614 6334150116120491797663028758593017247188130066480252318103473244344533350133 +7 23796172715971093073357699487486537923828547572589267391764537117614 0 18267227790754564911593021086481030109708414260385526909522536105996711179623 +7 25315158770423470866216422107684867741081458254837718260226295119906 25315158770423470866216422107684867741081458254837718260226295119906 14689159082780978925296466860902037984024093077767095825285084221758558827764 +7 0 25315158770423470866216422107684867741081458254837718260226295119906 5874202063063153643675747083453277090015673213866694669492659554169311837776 +7 25315158770423470866216422107684867741081458254837718260226295119906 0 19556462308564981607100298207971759222616944735727758076866371771663990803139 +7 2751396850401847721435087813488835625726449489692218272943958999473 2751396850401847721435087813488835625726449489692218272943958999473 19654970331431656304868420110064275590199806991033862806114515490050596692057 +7 0 2751396850401847721435087813488835625726449489692218272943958999473 14097514386377238489227479702148010224625780122766758105787346085987739773666 +7 2751396850401847721435087813488835625726449489692218272943958999473 0 21701897288077722632586865426841177375214240049145084832682390643747378679453 +7 4726679854228678607116891203946687439096256191427148469354558748708 4726679854228678607116891203946687439096256191427148469354558748708 11176229475684495955644298218113458998011583263893985381296539865657190363981 +7 0 4726679854228678607116891203946687439096256191427148469354558748708 1554385768709884138931054078656716161001221867842965367704415570846343909699 +7 4726679854228678607116891203946687439096256191427148469354558748708 0 2280692254587099040074634071918921826674487434373335986219774712451292197260 +7 21923645819969958231927727449351889461235256259254185616800433207686 21923645819969958231927727449351889461235256259254185616800433207686 9257635470904326285299162740191087274937309602111782408351834749484194016732 +7 0 21923645819969958231927727449351889461235256259254185616800433207686 12500022997406385924701834503000208785249432191817553014469581415871002622988 +7 21923645819969958231927727449351889461235256259254185616800433207686 0 3672023344048451963282648609398372743380102799433215909930046980337480677628 +7 74754028719967603288528196534923919342068599432442735770922818504006 74754028719967603288528196534923919342068599432442735770922818504006 5336879744961096196092864130582549598617743109664360786370565141324205654468 +7 0 74754028719967603288528196534923919342068599432442735770922818504006 19534266739582153752654136789924338424850022871919461898234325545170871511592 +7 74754028719967603288528196534923919342068599432442735770922818504006 0 16234130647796498574868883834767886572016205023070527188973228479441899615082 +7 2363128381208062029215486018432384453572915619830251079500388882034401 2363128381208062029215486018432384453572915619830251079500388882034401 10635421932006451043929268992634878358272156777470774943009895758976684723906 +7 0 2363128381208062029215486018432384453572915619830251079500388882034401 10523234330232429653704698976152611654112508625303337518895360852557291952028 +7 2363128381208062029215486018432384453572915619830251079500388882034401 0 12730128737435722813038612482065170952861401752100183913557320188449383423276 +7 2673803014093303360151314563269070653483918709971604637459749945141832 2673803014093303360151314563269070653483918709971604637459749945141832 6926463524279374245022221424533092295107893947976993478163101530890797475151 +7 0 2673803014093303360151314563269070653483918709971604637459749945141832 10133965885212296304823798129572074112530763443008942085048437583617595258810 +7 2673803014093303360151314563269070653483918709971604637459749945141832 0 18579041453731680925892043308724174943654400665750167059216558125202972110076 +7 4257412346975243691011317996804337495829190921940247791126828810872039 4257412346975243691011317996804337495829190921940247791126828810872039 17089734331504906841255164465299509907833594785239872993783079785337874112611 +7 0 4257412346975243691011317996804337495829190921940247791126828810872039 8433635198958021614215816533701171127436393924271356236983382299978729560545 +7 4257412346975243691011317996804337495829190921940247791126828810872039 0 8047753191873803370445452913748966989666283396547464836466861831732088585857 +7 2819569840414721944057740991622082879555394487936542565235853217444479 2819569840414721944057740991622082879555394487936542565235853217444479 17908102847634749414343788897833986740710189236363386774483108426452511721196 +7 0 2819569840414721944057740991622082879555394487936542565235853217444479 21706375369263197966950391407522617161521340715645373731655393479459472173539 +7 2819569840414721944057740991622082879555394487936542565235853217444479 0 9836244084143634647246046990602984230634421046953991950938176186754462576745 +7 4772954372425665773719768664593404610022639318026998291054481500134865 4772954372425665773719768664593404610022639318026998291054481500134865 10954517090683367683533464313342938726503573820973307966555987468837296385242 +7 0 4772954372425665773719768664593404610022639318026998291054481500134865 18604915054851602435932902800331901819970151341507031365160489606246262528614 +7 4772954372425665773719768664593404610022639318026998291054481500134865 0 18736995903536546490323211614020810093945100419429137098246063650084423439124 +7 136025195348529212365158570413867106238380137585352279224082858028839133 136025195348529212365158570413867106238380137585352279224082858028839133 20992998996171113698647222998331862398219702891171051833077253814969262261804 +7 0 136025195348529212365158570413867106238380137585352279224082858028839133 16704968443233583864379672757477563938365982895841783032946502795866120352275 +7 136025195348529212365158570413867106238380137585352279224082858028839133 0 2656490097324286628807681103273357172719900421832247794168313913062897923498 +7 471989507385339122413559343959625507836052893966568845123046339748673691 471989507385339122413559343959625507836052893966568845123046339748673691 15496389748220708480042843693218545549409006685306260647037202048271153893060 +7 0 471989507385339122413559343959625507836052893966568845123046339748673691 21053914647315147831255576456547484625971550641392595120336461401368512484740 +7 471989507385339122413559343959625507836052893966568845123046339748673691 0 4451931153342694341202942843605284711947940846050418931461718644849207808397 +7 643140671154465353540324662247580773794269702663363305380990825114644303 643140671154465353540324662247580773794269702663363305380990825114644303 2908317455217254743041330014450841899602940465253188074145253501058336208299 +7 0 643140671154465353540324662247580773794269702663363305380990825114644303 14536398038163466659498657396595180289780053626817254139340296646136410852176 +7 643140671154465353540324662247580773794269702663363305380990825114644303 0 11206266484443482004920500319349923951603519693670856518633322270521536545348 +7 1367776378473849238099749435385941001765671420284950098267091157822212079 1367776378473849238099749435385941001765671420284950098267091157822212079 19014540575804805435073316472269945804644820713813681395365143704611442380730 +7 0 1367776378473849238099749435385941001765671420284950098267091157822212079 9784679001788328388319097836501843799944706551654470630070252869146498224126 +7 1367776378473849238099749435385941001765671420284950098267091157822212079 0 18809131884455186264046880579466842832250058321722736501727846964040023320453 +7 1377574423878361302434505079661845110322617973133269519390872180274079719 1377574423878361302434505079661845110322617973133269519390872180274079719 17424183330367483654426582731619486614887802222682362075506738617658308746148 +7 0 1377574423878361302434505079661845110322617973133269519390872180274079719 7894311119122524988426675240600547916022938666000447052232453859572155130055 +7 1377574423878361302434505079661845110322617973133269519390872180274079719 0 6414310157523396278548716427939779531068747726354461628623320055801880661037 +7 341858280027370902540401312182682656313285812002204885066314129660077851 341858280027370902540401312182682656313285812002204885066314129660077851 15131170439036962258075706728835681564568302009522138076622421294962471876023 +7 0 341858280027370902540401312182682656313285812002204885066314129660077851 1735878276054569698108329923239011861268293390559830694153295649306211663635 +7 341858280027370902540401312182682656313285812002204885066314129660077851 0 8120878459502619959419488806467206061355317089359644766199651917546660948212 +7 64547905471220192702391019007379342322611264661212270783366961435685870636 64547905471220192702391019007379342322611264661212270783366961435685870636 6938966987615470606764197594203663615403557259139617155236031063317994982857 +7 0 64547905471220192702391019007379342322611264661212270783366961435685870636 7751496671681777925097136588758465891413635470859086918162776058692080398401 +7 64547905471220192702391019007379342322611264661212270783366961435685870636 0 14662783712125903840109783670454916613684483415775763371721491399060125337493 +7 392718432754820352521043489090258225174418029226345884162735475070148026190 392718432754820352521043489090258225174418029226345884162735475070148026190 4161474917668373985749152521353114701441358512370548782303889203305979073135 +7 0 392718432754820352521043489090258225174418029226345884162735475070148026190 14054874045464981323162033064574558369406775546563235805290536851623895249048 +7 392718432754820352521043489090258225174418029226345884162735475070148026190 0 17291856607572488046267265938791760804689423931539530025712198999815096439058 +7 389901407064670479347319907272279310549878454312587224637071839048868256626 389901407064670479347319907272279310549878454312587224637071839048868256626 21039854477463782364096485356210274493257562394502411647828600635685676440235 +7 0 389901407064670479347319907272279310549878454312587224637071839048868256626 12497609036324352326720042110556199531647900906926838160387041318580574663426 +7 389901407064670479347319907272279310549878454312587224637071839048868256626 0 7496056596477953637866778142045377908791146616307462340622554813110117207989 +7 151728081964243712155292499435395729415238645275701427697772008463395182468 151728081964243712155292499435395729415238645275701427697772008463395182468 9347573713844361634539687505812929802620674960289407149985083445009781259195 +7 0 151728081964243712155292499435395729415238645275701427697772008463395182468 19953278382521741189441291924059781304290753939451192304528204505131928728814 +7 151728081964243712155292499435395729415238645275701427697772008463395182468 0 6418532858683888652956936992372039296983188559038355746517404775530456106432 +7 395651583548367851028829013987094760455393382042370361863926974146268754844 395651583548367851028829013987094760455393382042370361863926974146268754844 19593269055024257093674991825404204176978591419390172322464182219672871076143 +7 0 395651583548367851028829013987094760455393382042370361863926974146268754844 17273580071502263272537237250644155326721754116500930137095297793883907975630 +7 395651583548367851028829013987094760455393382042370361863926974146268754844 0 9027068886077164798136593789676730682073991684932483065174441988396916807818 +7 233049213894097817470586660641792089067825974697072651614874971657215614489 233049213894097817470586660641792089067825974697072651614874971657215614489 11590811007440831694950440191206800823796948636238907364313428056132975441592 +7 0 233049213894097817470586660641792089067825974697072651614874971657215614489 8436461224132581311118840478853798900005020088337949291330662045116910803838 +7 233049213894097817470586660641792089067825974697072651614874971657215614489 0 655170687338897547134494291079217476763288338399832694739494702050617171274 +7 15228093958148267250964162308475488471428689945169901896089336183553343849489 15228093958148267250964162308475488471428689945169901896089336183553343849489 16977709412943559986914862967200361478637218492609663827625753816786840562499 +7 0 15228093958148267250964162308475488471428689945169901896089336183553343849489 8854421832393573832340133388237702367966819391772102676614208300346685292334 +7 15228093958148267250964162308475488471428689945169901896089336183553343849489 0 18382142854419574293008142481350528723959590478779473793297637573268932023393 +7 19912432864139097364494806297184807858032361534918134187673311998114222038607 19912432864139097364494806297184807858032361534918134187673311998114222038607 18998248031119430354299106946584684521026227318298372871198872199946464636675 +7 0 19912432864139097364494806297184807858032361534918134187673311998114222038607 2543526340866321404210078552382803099195689760445673305399938505361973109627 +7 19912432864139097364494806297184807858032361534918134187673311998114222038607 0 7982383647465178398190824054388638788218816822505132476321220430390918655308 +7 7020219358573873117136020093605583475141095160011014247680181555885812525761 7020219358573873117136020093605583475141095160011014247680181555885812525761 3142326836352511003462323575902081944827923262793590320160809336077473604321 +7 0 7020219358573873117136020093605583475141095160011014247680181555885812525761 12591988469262117828073231728507584518251477915793126082315121530927236315950 +7 7020219358573873117136020093605583475141095160011014247680181555885812525761 0 4342462207957342989839772352162852661592601275552050311530265608700828270551 +7 9285405545275227910121788521455146172621717603335451261616309661038319278048 9285405545275227910121788521455146172621717603335451261616309661038319278048 2802066694180274358272688054778740661047555907622022451478535015698611221133 +7 0 9285405545275227910121788521455146172621717603335451261616309661038319278048 8962960612841104418073027735618194223130211504855887969314337136829747931437 +7 9285405545275227910121788521455146172621717603335451261616309661038319278048 0 6412535219948206370671891958515494672754231279424573663576055078426365274686 +7 3615518995053111145686827784937618023724774816194183726265452586134522239244 3615518995053111145686827784937618023724774816194183726265452586134522239244 18843569134454229480340485201638436261589188085899043260462368753654834229603 +7 0 3615518995053111145686827784937618023724774816194183726265452586134522239244 6264356954943354827372470263953901525983434880536676177315263190337406301184 +7 3615518995053111145686827784937618023724774816194183726265452586134522239244 0 6297204882724017617444387977415741183310572168569976031575924339225125094548 +7 10678224721557598063690364833172229961599167383270930809780552848090203180915 10678224721557598063690364833172229961599167383270930809780552848090203180915 7348141915647236382489226376648957201994023279203269650509777248966458751919 +7 0 10678224721557598063690364833172229961599167383270930809780552848090203180915 12288171311013424167911799696256744851095482647296018843840849232032324602510 +7 10678224721557598063690364833172229961599167383270930809780552848090203180915 0 4246320328592011563401202690977238599826712268354753358699722631548510251765 \ No newline at end of file diff --git a/contracts/scripts/ScrollChainCommitmentVerifier.deploy.ts b/contracts/scripts/ScrollChainCommitmentVerifier.deploy.ts index ebb8565c33..24dc639caf 100644 --- a/contracts/scripts/ScrollChainCommitmentVerifier.deploy.ts +++ b/contracts/scripts/ScrollChainCommitmentVerifier.deploy.ts @@ -2,7 +2,7 @@ import * as dotenv from "dotenv"; import { ethers } from "hardhat"; -import poseidonUnit from "circomlib/src/poseidon_gencontract"; +import { generateABI, createCode } from "../scripts/poseidon"; dotenv.config(); @@ -15,11 +15,7 @@ async function main() { let PoseidonUnit2Address = process.env.POSEIDON_UNIT2_ADDR; if (!PoseidonUnit2Address) { - const Poseidon2Elements = new ethers.ContractFactory( - poseidonUnit.generateABI(2), - poseidonUnit.createCode(2), - deployer - ); + const Poseidon2Elements = new ethers.ContractFactory(generateABI(2), createCode(2), deployer); const poseidon = await Poseidon2Elements.deploy(); console.log("Deploy PoseidonUnit2 contract, hash:", poseidon.deployTransaction.hash); @@ -28,7 +24,9 @@ async function main() { PoseidonUnit2Address = poseidon.address; } - const verifier = await ScrollChainCommitmentVerifier.deploy(PoseidonUnit2Address, L1ScrollChainAddress); + const verifier = await ScrollChainCommitmentVerifier.deploy(PoseidonUnit2Address, L1ScrollChainAddress, { + gasPrice: 1e9, + }); console.log("Deploy ScrollChainCommitmentVerifier contract, hash:", verifier.deployTransaction.hash); const receipt = await verifier.deployTransaction.wait(); console.log(`✅ Deploy ScrollChainCommitmentVerifier contract at: ${verifier.address}, gas used: ${receipt.gasUsed}`); diff --git a/contracts/scripts/foundry/DeployL2BridgeContracts.s.sol b/contracts/scripts/foundry/DeployL2BridgeContracts.s.sol index 408257ca56..1175a2b2e6 100644 --- a/contracts/scripts/foundry/DeployL2BridgeContracts.s.sol +++ b/contracts/scripts/foundry/DeployL2BridgeContracts.s.sol @@ -31,6 +31,8 @@ import {ScrollStandardERC20Factory} from "../../src/libraries/token/ScrollStanda contract DeployL2BridgeContracts is Script { uint256 L2_DEPLOYER_PRIVATE_KEY = vm.envUint("L2_DEPLOYER_PRIVATE_KEY"); + address L2_PROXY_ADMIN_ADDR = vm.envAddress("L2_PROXY_ADMIN_ADDR"); + address L1_TX_FEE_RECIPIENT_ADDR = vm.envAddress("L1_TX_FEE_RECIPIENT_ADDR"); address L1_WETH_ADDR = vm.envAddress("L1_WETH_ADDR"); address L2_WETH_ADDR = vm.envAddress("L2_WETH_ADDR"); @@ -58,6 +60,8 @@ contract DeployL2BridgeContracts is Script { address L2_WHITELIST_PREDEPLOY_ADDR = vm.envOr("L2_WHITELIST_PREDEPLOY_ADDR", address(0)); function run() external { + proxyAdmin = ProxyAdmin(L2_PROXY_ADMIN_ADDR); + vm.startBroadcast(L2_DEPLOYER_PRIVATE_KEY); // predeploys @@ -67,7 +71,6 @@ contract DeployL2BridgeContracts is Script { deployL2Whitelist(); // upgradable - deployProxyAdmin(); deployL2ScrollMessenger(); deployL2GatewayRouter(); deployScrollStandardERC20Factory(); @@ -131,12 +134,6 @@ contract DeployL2BridgeContracts is Script { logAddress("L2_WHITELIST_ADDR", address(whitelist)); } - function deployProxyAdmin() internal { - proxyAdmin = new ProxyAdmin(); - - logAddress("L2_PROXY_ADMIN_ADDR", address(proxyAdmin)); - } - function deployL2ScrollMessenger() internal { L2ScrollMessenger impl = new L2ScrollMessenger(L1_SCROLL_MESSENGER_PROXY_ADDR, address(queue)); diff --git a/contracts/scripts/foundry/InitializeL1BridgeContracts.s.sol b/contracts/scripts/foundry/InitializeL1BridgeContracts.s.sol index 5ba9122923..da4201e52f 100644 --- a/contracts/scripts/foundry/InitializeL1BridgeContracts.s.sol +++ b/contracts/scripts/foundry/InitializeL1BridgeContracts.s.sol @@ -78,15 +78,21 @@ contract InitializeL1BridgeContracts is Script { vm.startBroadcast(L1_DEPLOYER_PRIVATE_KEY); + // note: we use call upgrade(...) and initialize(...) instead of upgradeAndCall(...), + // otherwise the contract owner would become ProxyAdmin. + // initialize ScrollChain - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_SCROLL_CHAIN_PROXY_ADDR), - L1_SCROLL_CHAIN_IMPLEMENTATION_ADDR, - abi.encodeCall( - ScrollChain.initialize, - (L1_MESSAGE_QUEUE_PROXY_ADDR, L1_MULTIPLE_VERSION_ROLLUP_VERIFIER_ADDR, MAX_TX_IN_CHUNK) - ) + L1_SCROLL_CHAIN_IMPLEMENTATION_ADDR + ); + + ScrollChain(L1_SCROLL_CHAIN_PROXY_ADDR).initialize( + L1_MESSAGE_QUEUE_PROXY_ADDR, + L1_MULTIPLE_VERSION_ROLLUP_VERIFIER_ADDR, + MAX_TX_IN_CHUNK ); + ScrollChain(L1_SCROLL_CHAIN_PROXY_ADDR).addSequencer(L1_COMMIT_SENDER_ADDRESS); ScrollChain(L1_SCROLL_CHAIN_PROXY_ADDR).addProver(L1_FINALIZE_SENDER_ADDRESS); @@ -103,35 +109,32 @@ contract InitializeL1BridgeContracts is Script { L2GasPriceOracle(L2_GAS_PRICE_ORACLE_PROXY_ADDR).updateWhitelist(L1_WHITELIST_ADDR); // initialize L1MessageQueueWithGasPriceOracle - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_MESSAGE_QUEUE_PROXY_ADDR), - L1_MESSAGE_QUEUE_IMPLEMENTATION_ADDR, - abi.encodeCall( - L1MessageQueue.initialize, - ( - L1_SCROLL_MESSENGER_PROXY_ADDR, - L1_SCROLL_CHAIN_PROXY_ADDR, - L1_ENFORCED_TX_GATEWAY_PROXY_ADDR, - L2_GAS_PRICE_ORACLE_PROXY_ADDR, - MAX_L1_MESSAGE_GAS_LIMIT - ) - ) + L1_MESSAGE_QUEUE_IMPLEMENTATION_ADDR ); + + L1MessageQueueWithGasPriceOracle(L1_MESSAGE_QUEUE_PROXY_ADDR).initialize( + L1_SCROLL_MESSENGER_PROXY_ADDR, + L1_SCROLL_CHAIN_PROXY_ADDR, + L1_ENFORCED_TX_GATEWAY_PROXY_ADDR, + L2_GAS_PRICE_ORACLE_PROXY_ADDR, + MAX_L1_MESSAGE_GAS_LIMIT + ); + L1MessageQueueWithGasPriceOracle(L1_MESSAGE_QUEUE_PROXY_ADDR).initializeV2(); // initialize L1ScrollMessenger - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_SCROLL_MESSENGER_PROXY_ADDR), - L1_SCROLL_MESSENGER_IMPLEMENTATION_ADDR, - abi.encodeCall( - L1ScrollMessenger.initialize, - ( - L2_SCROLL_MESSENGER_PROXY_ADDR, - L1_FEE_VAULT_ADDR, - L1_SCROLL_CHAIN_PROXY_ADDR, - L1_MESSAGE_QUEUE_PROXY_ADDR - ) - ) + L1_SCROLL_MESSENGER_IMPLEMENTATION_ADDR + ); + + L1ScrollMessenger(payable(L1_SCROLL_MESSENGER_PROXY_ADDR)).initialize( + L2_SCROLL_MESSENGER_PROXY_ADDR, + L1_FEE_VAULT_ADDR, + L1_SCROLL_CHAIN_PROXY_ADDR, + L1_MESSAGE_QUEUE_PROXY_ADDR ); // initialize EnforcedTxGateway @@ -147,63 +150,72 @@ contract InitializeL1BridgeContracts is Script { ); // initialize L1CustomERC20Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_CUSTOM_ERC20_GATEWAY_PROXY_ADDR), - L1_CUSTOM_ERC20_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L1CustomERC20Gateway.initialize, - (L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR, L1_GATEWAY_ROUTER_PROXY_ADDR, L1_SCROLL_MESSENGER_PROXY_ADDR) - ) + L1_CUSTOM_ERC20_GATEWAY_IMPLEMENTATION_ADDR + ); + + L1CustomERC20Gateway(L1_CUSTOM_ERC20_GATEWAY_PROXY_ADDR).initialize( + L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR, + L1_GATEWAY_ROUTER_PROXY_ADDR, + L1_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L1ERC1155Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_ERC1155_GATEWAY_PROXY_ADDR), - L1_ERC1155_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall(L1ERC1155Gateway.initialize, (L2_ERC1155_GATEWAY_PROXY_ADDR, L1_SCROLL_MESSENGER_PROXY_ADDR)) + L1_ERC1155_GATEWAY_IMPLEMENTATION_ADDR + ); + + L1ERC1155Gateway(L1_ERC1155_GATEWAY_PROXY_ADDR).initialize( + L2_ERC1155_GATEWAY_PROXY_ADDR, + L1_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L1ERC721Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_ERC721_GATEWAY_PROXY_ADDR), - L1_ERC721_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall(L1ERC721Gateway.initialize, (L2_ERC721_GATEWAY_PROXY_ADDR, L1_SCROLL_MESSENGER_PROXY_ADDR)) + L1_ERC721_GATEWAY_IMPLEMENTATION_ADDR + ); + + L1ERC721Gateway(L1_ERC721_GATEWAY_PROXY_ADDR).initialize( + L2_ERC721_GATEWAY_PROXY_ADDR, + L1_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L1ETHGateway - proxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(L1_ETH_GATEWAY_PROXY_ADDR), - L1_ETH_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L1ETHGateway.initialize, - (L2_ETH_GATEWAY_PROXY_ADDR, L1_GATEWAY_ROUTER_PROXY_ADDR, L1_SCROLL_MESSENGER_PROXY_ADDR) - ) + proxyAdmin.upgrade(ITransparentUpgradeableProxy(L1_ETH_GATEWAY_PROXY_ADDR), L1_ETH_GATEWAY_IMPLEMENTATION_ADDR); + + L1ETHGateway(L1_ETH_GATEWAY_PROXY_ADDR).initialize( + L2_ETH_GATEWAY_PROXY_ADDR, + L1_GATEWAY_ROUTER_PROXY_ADDR, + L1_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L1StandardERC20Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_STANDARD_ERC20_GATEWAY_PROXY_ADDR), - L1_STANDARD_ERC20_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L1StandardERC20Gateway.initialize, - ( - L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR, - L1_GATEWAY_ROUTER_PROXY_ADDR, - L1_SCROLL_MESSENGER_PROXY_ADDR, - L2_SCROLL_STANDARD_ERC20_ADDR, - L2_SCROLL_STANDARD_ERC20_FACTORY_ADDR - ) - ) + L1_STANDARD_ERC20_GATEWAY_IMPLEMENTATION_ADDR + ); + + L1StandardERC20Gateway(L1_STANDARD_ERC20_GATEWAY_PROXY_ADDR).initialize( + L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR, + L1_GATEWAY_ROUTER_PROXY_ADDR, + L1_SCROLL_MESSENGER_PROXY_ADDR, + L2_SCROLL_STANDARD_ERC20_ADDR, + L2_SCROLL_STANDARD_ERC20_FACTORY_ADDR ); // initialize L1WETHGateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L1_WETH_GATEWAY_PROXY_ADDR), - L1_WETH_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L1WETHGateway.initialize, - (L2_WETH_GATEWAY_PROXY_ADDR, L1_GATEWAY_ROUTER_PROXY_ADDR, L1_SCROLL_MESSENGER_PROXY_ADDR) - ) + L1_WETH_GATEWAY_IMPLEMENTATION_ADDR + ); + + L1WETHGateway(payable(L1_WETH_GATEWAY_PROXY_ADDR)).initialize( + L2_WETH_GATEWAY_PROXY_ADDR, + L1_GATEWAY_ROUTER_PROXY_ADDR, + L1_SCROLL_MESSENGER_PROXY_ADDR ); // set WETH gateway in router diff --git a/contracts/scripts/foundry/InitializeL2BridgeContracts.s.sol b/contracts/scripts/foundry/InitializeL2BridgeContracts.s.sol index 4ba60064b8..ec1ba712ca 100644 --- a/contracts/scripts/foundry/InitializeL2BridgeContracts.s.sol +++ b/contracts/scripts/foundry/InitializeL2BridgeContracts.s.sol @@ -67,6 +67,9 @@ contract InitializeL2BridgeContracts is Script { vm.startBroadcast(deployerPrivateKey); + // note: we use call upgrade(...) and initialize(...) instead of upgradeAndCall(...), + // otherwise the contract owner would become ProxyAdmin. + // initialize L2MessageQueue L2MessageQueue(L2_MESSAGE_QUEUE_ADDR).initialize(L2_SCROLL_MESSENGER_PROXY_ADDR); @@ -77,12 +80,13 @@ contract InitializeL2BridgeContracts is Script { L1GasPriceOracle(L1_GAS_PRICE_ORACLE_ADDR).updateWhitelist(L2_WHITELIST_ADDR); // initialize L2ScrollMessenger - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L2_SCROLL_MESSENGER_PROXY_ADDR), - L2_SCROLL_MESSENGER_IMPLEMENTATION_ADDR, - abi.encodeCall(L2ScrollMessenger.initialize, (L1_SCROLL_MESSENGER_PROXY_ADDR)) + L2_SCROLL_MESSENGER_IMPLEMENTATION_ADDR ); + L2ScrollMessenger(payable(L2_SCROLL_MESSENGER_PROXY_ADDR)).initialize(L1_SCROLL_MESSENGER_PROXY_ADDR); + // initialize L2GatewayRouter L2GatewayRouter(L2_GATEWAY_ROUTER_PROXY_ADDR).initialize( L2_ETH_GATEWAY_PROXY_ADDR, @@ -90,62 +94,71 @@ contract InitializeL2BridgeContracts is Script { ); // initialize L2CustomERC20Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR), - L2_CUSTOM_ERC20_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L2CustomERC20Gateway.initialize, - (L1_CUSTOM_ERC20_GATEWAY_PROXY_ADDR, L2_GATEWAY_ROUTER_PROXY_ADDR, L2_SCROLL_MESSENGER_PROXY_ADDR) - ) + L2_CUSTOM_ERC20_GATEWAY_IMPLEMENTATION_ADDR + ); + + L2CustomERC20Gateway(L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR).initialize( + L1_CUSTOM_ERC20_GATEWAY_PROXY_ADDR, + L2_GATEWAY_ROUTER_PROXY_ADDR, + L2_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L2ERC1155Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L2_ERC1155_GATEWAY_PROXY_ADDR), - L2_ERC1155_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall(L2ERC1155Gateway.initialize, (L1_ERC1155_GATEWAY_PROXY_ADDR, L2_SCROLL_MESSENGER_PROXY_ADDR)) + L2_ERC1155_GATEWAY_IMPLEMENTATION_ADDR + ); + + L2ERC1155Gateway(L2_ERC1155_GATEWAY_PROXY_ADDR).initialize( + L1_ERC1155_GATEWAY_PROXY_ADDR, + L2_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L2ERC721Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L2_ERC721_GATEWAY_PROXY_ADDR), - L2_ERC721_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall(L2ERC721Gateway.initialize, (L1_ERC721_GATEWAY_PROXY_ADDR, L2_SCROLL_MESSENGER_PROXY_ADDR)) + L2_ERC721_GATEWAY_IMPLEMENTATION_ADDR + ); + + L2ERC721Gateway(L2_ERC721_GATEWAY_PROXY_ADDR).initialize( + L1_ERC721_GATEWAY_PROXY_ADDR, + L2_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L2ETHGateway - proxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(L2_ETH_GATEWAY_PROXY_ADDR), - L2_ETH_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L2ETHGateway.initialize, - (L1_ETH_GATEWAY_PROXY_ADDR, L2_GATEWAY_ROUTER_PROXY_ADDR, L2_SCROLL_MESSENGER_PROXY_ADDR) - ) + proxyAdmin.upgrade(ITransparentUpgradeableProxy(L2_ETH_GATEWAY_PROXY_ADDR), L2_ETH_GATEWAY_IMPLEMENTATION_ADDR); + + L2ETHGateway(L2_ETH_GATEWAY_PROXY_ADDR).initialize( + L1_ETH_GATEWAY_PROXY_ADDR, + L2_GATEWAY_ROUTER_PROXY_ADDR, + L2_SCROLL_MESSENGER_PROXY_ADDR ); // initialize L2StandardERC20Gateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR), - L2_STANDARD_ERC20_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L2StandardERC20Gateway.initialize, - ( - L1_STANDARD_ERC20_GATEWAY_PROXY_ADDR, - L2_GATEWAY_ROUTER_PROXY_ADDR, - L2_SCROLL_MESSENGER_PROXY_ADDR, - L2_SCROLL_STANDARD_ERC20_FACTORY_ADDR - ) - ) + L2_STANDARD_ERC20_GATEWAY_IMPLEMENTATION_ADDR + ); + + L2StandardERC20Gateway(L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR).initialize( + L1_STANDARD_ERC20_GATEWAY_PROXY_ADDR, + L2_GATEWAY_ROUTER_PROXY_ADDR, + L2_SCROLL_MESSENGER_PROXY_ADDR, + L2_SCROLL_STANDARD_ERC20_FACTORY_ADDR ); // initialize L2WETHGateway - proxyAdmin.upgradeAndCall( + proxyAdmin.upgrade( ITransparentUpgradeableProxy(L2_WETH_GATEWAY_PROXY_ADDR), - L2_WETH_GATEWAY_IMPLEMENTATION_ADDR, - abi.encodeCall( - L2WETHGateway.initialize, - (L1_WETH_GATEWAY_PROXY_ADDR, L2_GATEWAY_ROUTER_PROXY_ADDR, L2_SCROLL_MESSENGER_PROXY_ADDR) - ) + L2_WETH_GATEWAY_IMPLEMENTATION_ADDR + ); + + L2WETHGateway(payable(L2_WETH_GATEWAY_PROXY_ADDR)).initialize( + L1_WETH_GATEWAY_PROXY_ADDR, + L2_GATEWAY_ROUTER_PROXY_ADDR, + L2_SCROLL_MESSENGER_PROXY_ADDR ); // set WETH gateway in router diff --git a/contracts/scripts/poseidon.ts b/contracts/scripts/poseidon.ts new file mode 100644 index 0000000000..00883987a0 --- /dev/null +++ b/contracts/scripts/poseidon.ts @@ -0,0 +1,202 @@ +/* eslint-disable node/no-missing-import */ +import { ethers } from "ethers"; + +import Contract from "circomlib/src/evmasm"; +import * as constants from "circomlib/src/poseidon_constants"; + +const N_ROUNDS_F = 8; +const N_ROUNDS_P = [56, 57, 56, 60, 60, 63, 64, 63]; + +export function createCode(nInputs: number) { + if (nInputs < 1 || nInputs > 8) throw new Error("Invalid number of inputs. Must be 1<=nInputs<=8"); + const t = nInputs + 1; + const nRoundsF = N_ROUNDS_F; + const nRoundsP = N_ROUNDS_P[t - 2]; + + const C = new Contract(); + + function saveM() { + for (let i = 0; i < t; i++) { + for (let j = 0; j < t; j++) { + C.push(constants.M[t - 2][i][j]); + C.push((1 + i * t + j) * 32); + C.mstore(); + } + } + } + + function ark(r: number) { + // st, q + for (let i = 0; i < t; i++) { + C.dup(t); // q, st, q + C.push(constants.C[t - 2][r * t + i]); // K, q, st, q + C.dup(2 + i); // st[i], K, q, st, q + C.addmod(); // newSt[i], st, q + C.swap(1 + i); // xx, st, q + C.pop(); + } + } + + function sigma(p: number) { + // sq, q + C.dup(t); // q, st, q + C.dup(1 + p); // st[p] , q , st, q + C.dup(1); // q, st[p] , q , st, q + C.dup(0); // q, q, st[p] , q , st, q + C.dup(2); // st[p] , q, q, st[p] , q , st, q + C.dup(0); // st[p] , st[p] , q, q, st[p] , q , st, q + C.mulmod(); // st2[p], q, st[p] , q , st, q + C.dup(0); // st2[p], st2[p], q, st[p] , q , st, q + C.mulmod(); // st4[p], st[p] , q , st, q + C.mulmod(); // st5[p], st, q + C.swap(1 + p); + C.pop(); // newst, q + } + + function mix() { + C.label("mix"); + for (let i = 0; i < t; i++) { + for (let j = 0; j < t; j++) { + if (j === 0) { + C.dup(i + t); // q, newSt, oldSt, q + C.push((1 + i * t + j) * 32); + C.mload(); // M, q, newSt, oldSt, q + C.dup(2 + i + j); // oldSt[j], M, q, newSt, oldSt, q + C.mulmod(); // acc, newSt, oldSt, q + } else { + C.dup(1 + i + t); // q, acc, newSt, oldSt, q + C.push((1 + i * t + j) * 32); + C.mload(); // M, q, acc, newSt, oldSt, q + C.dup(3 + i + j); // oldSt[j], M, q, acc, newSt, oldSt, q + C.mulmod(); // aux, acc, newSt, oldSt, q + C.dup(2 + i + t); // q, aux, acc, newSt, oldSt, q + C.swap(2); // acc, aux, q, newSt, oldSt, q + C.addmod(); // acc, newSt, oldSt, q + } + } + } + for (let i = 0; i < t; i++) { + C.swap(t - i + (t - i - 1)); + C.pop(); + } + C.push(0); + C.mload(); + C.jmp(); + } + + // Check selector + C.push("0x0100000000000000000000000000000000000000000000000000000000"); + C.push(0); + C.calldataload(); + C.div(); + C.dup(0); + C.push(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(`poseidon(uint256[${nInputs}],uint256)`)).slice(0, 10)); // poseidon(uint256[n],uint256) + C.eq(); + C.swap(1); + C.push(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(`poseidon(bytes32[${nInputs}],bytes32)`)).slice(0, 10)); // poseidon(bytes32[n],bytes32) + C.eq(); + C.or(); + C.jmpi("start"); + C.invalid(); + + C.label("start"); + + saveM(); + + C.push("0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"); // q + + // Load t values from the call data. + // The function has a single array param param + // [Selector (4)] [item1 (32)] [item2 (32)] .... [doman (32)] + // Stack positions 0-nInputs. + for (let i = 0; i < nInputs; i++) { + C.push(0x04 + 0x20 * (nInputs - i - 1)); + C.calldataload(); + } + C.push(0x04 + 0x20 * nInputs); + C.calldataload(); + + for (let i = 0; i < nRoundsF + nRoundsP; i++) { + ark(i); + if (i < nRoundsF / 2 || i >= nRoundsP + nRoundsF / 2) { + for (let j = 0; j < t; j++) { + sigma(j); + } + } else { + sigma(0); + } + const strLabel = "aferMix" + i; + C._pushLabel(strLabel); + C.push(0); + C.mstore(); + C.jmp("mix"); + C.label(strLabel); + } + + C.push("0x00"); + C.mstore(); // Save it to pos 0; + C.push("0x20"); + C.push("0x00"); + C.return(); + + mix(); + + return C.createTxData(); +} + +export function generateABI(nInputs: number) { + return [ + { + constant: true, + inputs: [ + { + internalType: `bytes32[${nInputs}]`, + name: "input", + type: `bytes32[${nInputs}]`, + }, + { + internalType: "bytes32", + name: "domain", + type: "bytes32", + }, + ], + name: "poseidon", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + payable: false, + stateMutability: "pure", + type: "function", + }, + { + constant: true, + inputs: [ + { + internalType: `uint256[${nInputs}]`, + name: "input", + type: `uint256[${nInputs}]`, + }, + { + internalType: "uint256", + name: "domain", + type: "uint256", + }, + ], + name: "poseidon", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + payable: false, + stateMutability: "pure", + type: "function", + }, + ]; +} diff --git a/contracts/src/L1/rollup/ScrollChainCommitmentVerifier.sol b/contracts/src/L1/rollup/ScrollChainCommitmentVerifier.sol index 1c75c42203..df6d13dc91 100644 --- a/contracts/src/L1/rollup/ScrollChainCommitmentVerifier.sol +++ b/contracts/src/L1/rollup/ScrollChainCommitmentVerifier.sol @@ -2,7 +2,7 @@ pragma solidity =0.8.16; -import {ScrollChain} from "./ScrollChain.sol"; +import {IScrollChain} from "./IScrollChain.sol"; import {ZkTrieVerifier} from "../../libraries/verifier/ZkTrieVerifier.sol"; contract ScrollChainCommitmentVerifier { @@ -49,11 +49,11 @@ contract ScrollChainCommitmentVerifier { bytes32 storageKey, bytes calldata proof ) external view returns (bytes32 storageValue) { - require(ScrollChain(rollup).isBatchFinalized(batchIndex), "Batch not finalized"); + require(IScrollChain(rollup).isBatchFinalized(batchIndex), "Batch not finalized"); bytes32 computedStateRoot; (computedStateRoot, storageValue) = ZkTrieVerifier.verifyZkTrieProof(poseidon, account, storageKey, proof); - bytes32 expectedStateRoot = ScrollChain(rollup).finalizedStateRoots(batchIndex); + bytes32 expectedStateRoot = IScrollChain(rollup).finalizedStateRoots(batchIndex); require(computedStateRoot == expectedStateRoot, "Invalid inclusion proof"); } } diff --git a/contracts/src/libraries/verifier/ZkTrieVerifier.sol b/contracts/src/libraries/verifier/ZkTrieVerifier.sol index 92ec84f24a..16444c8b45 100644 --- a/contracts/src/libraries/verifier/ZkTrieVerifier.sol +++ b/contracts/src/libraries/verifier/ZkTrieVerifier.sol @@ -2,9 +2,7 @@ pragma solidity ^0.8.16; -interface PoseidonUnit2 { - function poseidon(uint256[2] memory) external view returns (uint256); -} +// solhint-disable no-inline-assembly library ZkTrieVerifier { /// @notice Internal function to validates a proof from eth_getProof. @@ -58,19 +56,20 @@ library ZkTrieVerifier { } } // compute poseidon hash of two uint256 - function poseidon_hash(hasher, v0, v1) -> r { + function poseidon_hash(hasher, v0, v1, domain) -> r { let x := mload(0x40) - // keccack256("poseidon(uint256[2])") - mstore(x, 0x29a5f2f600000000000000000000000000000000000000000000000000000000) + // keccack256("poseidon(uint256[2],uint256)") + mstore(x, 0xa717016c00000000000000000000000000000000000000000000000000000000) mstore(add(x, 0x04), v0) mstore(add(x, 0x24), v1) - let success := staticcall(gas(), hasher, x, 0x44, 0x20, 0x20) + mstore(add(x, 0x44), domain) + let success := staticcall(gas(), hasher, x, 0x64, 0x20, 0x20) require(success, "poseidon hash failed") r := mload(0x20) } // compute poseidon hash of 1 uint256 function hash_uint256(hasher, v) -> r { - r := poseidon_hash(hasher, shr(128, v), and(v, 0xffffffffffffffffffffffffffffffff)) + r := poseidon_hash(hasher, shr(128, v), and(v, 0xffffffffffffffffffffffffffffffff), 512) } // traverses the tree from the root to the node before the leaf. @@ -90,15 +89,16 @@ library ZkTrieVerifier { } { // must be a parent node with two children let nodeType := byte(0, calldataload(ptr)) + // 6 <= nodeType && nodeType < 10 + require(lt(sub(nodeType, 6), 4), "InvalidBranchNodeType") ptr := add(ptr, 1) - require(eq(nodeType, 0), "Invalid parent node") // load left/right child hash let childHashL := calldataload(ptr) ptr := add(ptr, 0x20) let childHashR := calldataload(ptr) ptr := add(ptr, 0x20) - let hash := poseidon_hash(hasher, childHashL, childHashR) + let hash := poseidon_hash(hasher, childHashL, childHashR, nodeType) // first item is considered the root node. // Otherwise verifies that the hash of the current node @@ -108,7 +108,7 @@ library ZkTrieVerifier { rootHash := hash } default { - require(eq(hash, expectedHash), "Hash mismatch") + require(eq(hash, expectedHash), "BranchHashMismatch") } // decide which path to walk based on key @@ -130,129 +130,132 @@ library ZkTrieVerifier { x := keccak256(x, 0x2d) require( eq(x, 0x950654da67865a81bc70e45f3230f5179f08e29c66184bf746f71050f117b3b8), - "Invalid ProofMagicBytes" + "InvalidProofMagicBytes" ) ptr := add(ptr, 0x2d) // skip ProofMagicBytes } - // shared variable names - let storageHash - // starting point - let ptr := proof.offset + function verifyAccountProof(hasher, _account, _ptr) -> ptr, storageRootHash, _stateRoot { + ptr := _ptr - // verify account proof - { let leafHash - let key := hash_uint256(poseidon, shl(96, account)) + let key := hash_uint256(hasher, shl(96, _account)) // `stateRoot` is a return value and must be checked by the caller - ptr, stateRoot, leafHash := walkTree(poseidon, key, ptr) + ptr, _stateRoot, leafHash := walkTree(hasher, key, ptr) - require(eq(1, byte(0, calldataload(ptr))), "Invalid leaf node") - ptr := add(ptr, 0x01) // skip NodeType - require(eq(calldataload(ptr), key), "Node key mismatch") - ptr := add(ptr, 0x20) // skip NodeKey - { - let valuePreimageLength := and(shr(224, calldataload(ptr)), 0xffff) - // @todo check CompressedFlag + switch byte(0, calldataload(ptr)) + case 4 { + // nonempty leaf node + ptr := add(ptr, 0x01) // skip NodeType + require(eq(calldataload(ptr), key), "AccountKeyMismatch") + ptr := add(ptr, 0x20) // skip NodeKey + require(eq(shr(224, calldataload(ptr)), 0x05080000), "InvalidAccountCompressedFlag") ptr := add(ptr, 0x04) // skip CompressedFlag - ptr := add(ptr, valuePreimageLength) // skip ValuePreimage - } - // compute value hash for State Account Leaf Node - { - let tmpHash1 := calldataload(ptr) - ptr := add(ptr, 0x20) // skip nonce/codesize/0 - tmpHash1 := poseidon_hash(poseidon, tmpHash1, calldataload(ptr)) + // compute value hash for State Account Leaf Node, details can be found in + // https://github.com/scroll-tech/mpt-circuit/blob/v0.7/spec/mpt-proof.md#account-segmenttypes + // [nonce||codesize||0, balance, storage_root, keccak codehash, poseidon codehash] + mstore(0x00, calldataload(ptr)) + ptr := add(ptr, 0x20) // skip nonce||codesize||0 + mstore(0x00, poseidon_hash(hasher, mload(0x00), calldataload(ptr), 1280)) ptr := add(ptr, 0x20) // skip balance - storageHash := calldataload(ptr) + storageRootHash := calldataload(ptr) ptr := add(ptr, 0x20) // skip StorageRoot - let tmpHash2 := hash_uint256(poseidon, calldataload(ptr)) + let tmpHash := hash_uint256(hasher, calldataload(ptr)) ptr := add(ptr, 0x20) // skip KeccakCodeHash - tmpHash2 := poseidon_hash(poseidon, storageHash, tmpHash2) - tmpHash2 := poseidon_hash(poseidon, tmpHash1, tmpHash2) - tmpHash2 := poseidon_hash(poseidon, tmpHash2, calldataload(ptr)) + tmpHash := poseidon_hash(hasher, storageRootHash, tmpHash, 1280) + tmpHash := poseidon_hash(hasher, mload(0x00), tmpHash, 1280) + tmpHash := poseidon_hash(hasher, tmpHash, calldataload(ptr), 1280) ptr := add(ptr, 0x20) // skip PoseidonCodeHash - tmpHash1 := poseidon_hash(poseidon, 1, key) - tmpHash1 := poseidon_hash(poseidon, tmpHash1, tmpHash2) + tmpHash := poseidon_hash(hasher, key, tmpHash, 4) + require(eq(leafHash, tmpHash), "InvalidAccountLeafNodeHash") - require(eq(leafHash, tmpHash1), "Invalid leaf node hash") + require(eq(0x20, byte(0, calldataload(ptr))), "InvalidAccountKeyPreimageLength") + ptr := add(ptr, 0x01) // skip KeyPreimage length + require(eq(shl(96, _account), calldataload(ptr)), "InvalidAccountKeyPreimage") + ptr := add(ptr, 0x20) // skip KeyPreimage + } + case 5 { + ptr := add(ptr, 0x01) // skip NodeType + } + default { + revertWith("InvalidAccountLeafNodeType") } - - require(eq(0x20, byte(0, calldataload(ptr))), "Invalid KeyPreimage length") - ptr := add(ptr, 0x01) // skip KeyPreimage length - require(eq(shl(96, account), calldataload(ptr)), "Invalid KeyPreimage") - ptr := add(ptr, 0x20) // skip KeyPreimage // compare ProofMagicBytes - ptr := checkProofMagicBytes(poseidon, ptr) + ptr := checkProofMagicBytes(hasher, ptr) } - // verify storage proof - { + function verifyStorageProof(hasher, _storageKey, storageRootHash, _ptr) -> ptr, _storageValue { + ptr := _ptr + let leafHash - let key := hash_uint256(poseidon, storageKey) - { - let rootHash - ptr, rootHash, leafHash := walkTree(poseidon, key, ptr) + let key := hash_uint256(hasher, _storageKey) + let rootHash + ptr, rootHash, leafHash := walkTree(hasher, key, ptr) - switch rootHash - case 0 { - // in the case that the leaf is the only element, then - // the hash of the leaf must match the value from the account leaf - require(eq(leafHash, storageHash), "Storage root mismatch") - } - default { - // otherwise the root hash of the storage tree - // must match the value from the account leaf - require(eq(rootHash, storageHash), "Storage root mismatch") - } + // The root hash of the storage tree must match the value from the account leaf. + // But when the leaf node is the same as the root node, the function `walkTree` will return + // `rootHash=0` and `leafHash=0`. In such case, we don't need to check the value of `rootHash`. + // And the value of `leafHash` should be the same as `storageRootHash`. + switch rootHash + case 0 { + leafHash := storageRootHash + } + default { + require(eq(rootHash, storageRootHash), "StorageRootMismatch") } switch byte(0, calldataload(ptr)) - case 1 { + case 4 { ptr := add(ptr, 0x01) // skip NodeType - require(eq(calldataload(ptr), key), "Node key mismatch") + require(eq(calldataload(ptr), key), "StorageKeyMismatch") ptr := add(ptr, 0x20) // skip NodeKey - { - let valuePreimageLength := and(shr(224, calldataload(ptr)), 0xffff) - // @todo check CompressedFlag - ptr := add(ptr, 0x04) // skip CompressedFlag - ptr := add(ptr, valuePreimageLength) // skip ValuePreimage - } - - storageValue := calldataload(ptr) + require(eq(shr(224, calldataload(ptr)), 0x01010000), "InvalidStorageCompressedFlag") + ptr := add(ptr, 0x04) // skip CompressedFlag + _storageValue := calldataload(ptr) ptr := add(ptr, 0x20) // skip StorageValue - mstore(0x00, hash_uint256(poseidon, storageValue)) - key := poseidon_hash(poseidon, 1, key) - mstore(0x00, poseidon_hash(poseidon, key, mload(0x00))) - require(eq(leafHash, mload(0x00)), "Invalid leaf node hash") + // compute leaf node hash and compare, details can be found in + // https://github.com/scroll-tech/mpt-circuit/blob/v0.7/spec/mpt-proof.md#storage-segmenttypes + mstore(0x00, hash_uint256(hasher, _storageValue)) + mstore(0x00, poseidon_hash(hasher, key, mload(0x00), 4)) + require(eq(leafHash, mload(0x00)), "InvalidStorageLeafNodeHash") - require(eq(0x20, byte(0, calldataload(ptr))), "Invalid KeyPreimage length") + require(eq(0x20, byte(0, calldataload(ptr))), "InvalidStorageKeyPreimageLength") ptr := add(ptr, 0x01) // skip KeyPreimage length - require(eq(storageKey, calldataload(ptr)), "Invalid KeyPreimage") + require(eq(_storageKey, calldataload(ptr)), "InvalidStorageKeyPreimage") ptr := add(ptr, 0x20) // skip KeyPreimage } - case 2 { + case 5 { ptr := add(ptr, 0x01) // skip NodeType - require(eq(leafHash, 0), "Invalid empty node hash") + require(eq(leafHash, 0), "InvalidStorageEmptyLeafNodeHash") } default { - revertWith("Invalid leaf node") + revertWith("InvalidStorageLeafNodeType") } // compare ProofMagicBytes - ptr := checkProofMagicBytes(poseidon, ptr) + ptr := checkProofMagicBytes(hasher, ptr) } + let storageRootHash + let ptr := proof.offset + + // check the correctness of account proof + ptr, storageRootHash, stateRoot := verifyAccountProof(poseidon, account, ptr) + + // check the correctness of storage proof + ptr, storageValue := verifyStorageProof(poseidon, storageKey, storageRootHash, ptr) + // the one and only boundary check // in case an attacker crafted a malicous payload // and succeeds in the prior verification steps // then this should catch any bogus accesses if iszero(eq(ptr, add(proof.offset, proof.length))) { - revertWith("Proof length mismatch") + revertWith("ProofLengthMismatch") } } }