mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-11 23:18:07 -05:00
Compare commits
58 Commits
curie-test
...
v4.4.42
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72f88bae5e | ||
|
|
daca3ae6eb | ||
|
|
073e9e883c | ||
|
|
cce5c6c62e | ||
|
|
1ab9cf2de6 | ||
|
|
85e2e7ae94 | ||
|
|
04215f3e7b | ||
|
|
dd6206fd59 | ||
|
|
d163abeffc | ||
|
|
e22af03774 | ||
|
|
0fd7a877ce | ||
|
|
4e3a4a42c8 | ||
|
|
61ab085c82 | ||
|
|
a8e2551d79 | ||
|
|
cfa106291e | ||
|
|
bfb3c7d2b4 | ||
|
|
f14053ed0c | ||
|
|
0ff897a287 | ||
|
|
4e3dc52db3 | ||
|
|
8471838cd4 | ||
|
|
c812288250 | ||
|
|
e61a0c3473 | ||
|
|
470a8ed053 | ||
|
|
0737d5d3e3 | ||
|
|
86aed8e667 | ||
|
|
ab9c541409 | ||
|
|
16673e2b97 | ||
|
|
a2536d5613 | ||
|
|
5f31d28ced | ||
|
|
eada1d05fe | ||
|
|
2f39e37bc2 | ||
|
|
d454941c81 | ||
|
|
738c85759d | ||
|
|
27d627e318 | ||
|
|
8c3ecd395f | ||
|
|
33016b1d5d | ||
|
|
b824509773 | ||
|
|
94ac1cd63f | ||
|
|
4ffb9e6c68 | ||
|
|
874d3f2f8b | ||
|
|
b0242c2938 | ||
|
|
6638c0b829 | ||
|
|
6dd09feff8 | ||
|
|
75c81d5ce6 | ||
|
|
0c137d6b6c | ||
|
|
c65cdfceb9 | ||
|
|
71ab2006fb | ||
|
|
60a98fa876 | ||
|
|
661b68cf86 | ||
|
|
6eea9195fc | ||
|
|
e45838f3ac | ||
|
|
acd1432d44 | ||
|
|
6b11e20ca6 | ||
|
|
f12e8e3baf | ||
|
|
ba77a74743 | ||
|
|
1ddfe57e5b | ||
|
|
c48ae961a5 | ||
|
|
7059ad0ed4 |
138
.github/workflows/contracts.yml
vendored
138
.github/workflows/contracts.yml
vendored
@@ -1,138 +0,0 @@
|
||||
name: Contracts
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- staging
|
||||
- develop
|
||||
- alpha
|
||||
paths:
|
||||
- 'contracts/**'
|
||||
- '.github/workflows/contracts.yaml'
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
- ready_for_review
|
||||
paths:
|
||||
- 'contracts/**'
|
||||
- '.github/workflows/contracts.yaml'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: 'contracts'
|
||||
|
||||
jobs:
|
||||
foundry:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Foundry
|
||||
uses: foundry-rs/foundry-toolchain@v1
|
||||
with:
|
||||
version: nightly
|
||||
|
||||
- name: Setup LCOV
|
||||
uses: hrishikesh-kadam/setup-lcov@v1
|
||||
|
||||
- name: Install Node.js 18
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- name: Cache yarn dependencies
|
||||
uses: actions/cache@v2
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('contracts/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Cache node_modules
|
||||
id: npm_cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: node_modules
|
||||
key: node_modules-${{ hashFiles('contracts/yarn.lock') }}
|
||||
|
||||
- name: yarn install
|
||||
# if: steps.npm_cache.outputs.cache-hit != 'true'
|
||||
run: yarn install
|
||||
|
||||
- name: Compile with foundry
|
||||
run: forge build --evm-version cancun
|
||||
|
||||
- name: Run foundry tests
|
||||
run: forge test --evm-version cancun -vvv
|
||||
|
||||
- name: Run foundry coverage
|
||||
run : forge coverage --evm-version cancun --report lcov
|
||||
|
||||
- name : Prune coverage
|
||||
run : lcov --rc branch_coverage=1 --remove ./lcov.info -o ./lcov.info.pruned 'src/mocks/*' 'src/test/*' 'scripts/*' 'node_modules/*' 'lib/*'
|
||||
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
with:
|
||||
files: contracts/lcov.info.pruned
|
||||
flags: contracts
|
||||
|
||||
hardhat:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Node.js 18
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- name: Cache yarn dependencies
|
||||
uses: actions/cache@v2
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('contracts/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Cache node_modules
|
||||
id: npm_cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: node_modules
|
||||
key: node_modules-${{ hashFiles('contracts/yarn.lock') }}
|
||||
|
||||
- name: yarn install
|
||||
# if: steps.npm_cache.outputs.cache-hit != 'true'
|
||||
run: yarn install
|
||||
|
||||
- name: Compile with hardhat
|
||||
run: npx hardhat compile
|
||||
|
||||
- name: Run hardhat tests
|
||||
run: npx hardhat test
|
||||
41
.github/workflows/docker-coordinator-api-arm64.yml
vendored
Normal file
41
.github/workflows/docker-coordinator-api-arm64.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: Docker-coordinator-api-arm64
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "tag of this image (suffix -arm64 is added automatically)"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build-and-push-arm64-image:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- aarch64
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up QEMU
|
||||
run: |
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
docker buildx create --name multiarch --driver docker-container --use
|
||||
- name: Set up Docker Buildx
|
||||
id: 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 docker image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
platforms: linux/arm64
|
||||
context: .
|
||||
file: ./build/dockerfiles/coordinator-api.Dockerfile
|
||||
push: true
|
||||
tags: scrolltech/coordinator-api:${{inputs.tag}}-arm64
|
||||
95
.github/workflows/docker.yml
vendored
95
.github/workflows/docker.yml
vendored
@@ -9,51 +9,6 @@ env:
|
||||
AWS_REGION: us-west-2
|
||||
|
||||
jobs:
|
||||
event_watcher:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
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@v2
|
||||
- name: check repo and create it if not exist
|
||||
env:
|
||||
REPOSITORY: event-watcher
|
||||
run: |
|
||||
aws --region ${{ env.AWS_REGION }} ecr describe-repositories --repository-names ${{ env.REPOSITORY }} && : || aws --region ${{ env.AWS_REGION }} ecr create-repository --repository-name ${{ env.REPOSITORY }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
env:
|
||||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
||||
REPOSITORY: event-watcher
|
||||
IMAGE_TAG: ${{ github.ref_name }}
|
||||
with:
|
||||
context: .
|
||||
file: ./build/dockerfiles/event_watcher.Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:latest
|
||||
${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:latest
|
||||
|
||||
gas_oracle:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -91,7 +46,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./build/dockerfiles/gas_oracle.Dockerfile
|
||||
platforms: linux/amd64
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
@@ -136,7 +91,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./build/dockerfiles/rollup_relayer.Dockerfile
|
||||
platforms: linux/amd64
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
@@ -279,6 +234,51 @@ jobs:
|
||||
${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:latest
|
||||
|
||||
bridgehistoryapi-db-cli:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
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@v2
|
||||
- name: check repo and create it if not exist
|
||||
env:
|
||||
REPOSITORY: bridgehistoryapi-db-cli
|
||||
run: |
|
||||
aws --region ${{ env.AWS_REGION }} ecr describe-repositories --repository-names ${{ env.REPOSITORY }} && : || aws --region ${{ env.AWS_REGION }} ecr create-repository --repository-name ${{ env.REPOSITORY }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
env:
|
||||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
||||
REPOSITORY: bridgehistoryapi-db-cli
|
||||
IMAGE_TAG: ${{ github.ref_name }}
|
||||
with:
|
||||
context: .
|
||||
file: ./build/dockerfiles/bridgehistoryapi-db-cli.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:latest
|
||||
${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
${{ env.ECR_REGISTRY }}/${{ env.REPOSITORY }}:latest
|
||||
|
||||
coordinator-api:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -316,7 +316,6 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./build/dockerfiles/coordinator-api.Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
|
||||
253
.github/workflows/intermediate-docker.yml
vendored
253
.github/workflows/intermediate-docker.yml
vendored
@@ -4,32 +4,65 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
GO_VERSION:
|
||||
description: 'Go version'
|
||||
description: "Go version"
|
||||
required: true
|
||||
type: string
|
||||
default: '1.21'
|
||||
type: choice
|
||||
options:
|
||||
- "1.20"
|
||||
- "1.21"
|
||||
- "1.22"
|
||||
- "1.23"
|
||||
default: "1.21"
|
||||
RUST_VERSION:
|
||||
description: 'Rust toolchain version'
|
||||
description: "Rust toolchain version"
|
||||
required: true
|
||||
type: string
|
||||
default: 'nightly-2023-12-03'
|
||||
type: choice
|
||||
options:
|
||||
- nightly-2023-12-03
|
||||
- nightly-2022-12-10
|
||||
default: "nightly-2023-12-03"
|
||||
PYTHON_VERSION:
|
||||
description: 'Python version'
|
||||
description: "Python version"
|
||||
required: false
|
||||
type: string
|
||||
default: '3.10'
|
||||
type: choice
|
||||
options:
|
||||
- "3.10"
|
||||
default: "3.10"
|
||||
CUDA_VERSION:
|
||||
description: 'Cuda version'
|
||||
description: "Cuda version"
|
||||
required: false
|
||||
type: string
|
||||
default: '11.7.1'
|
||||
type: choice
|
||||
options:
|
||||
- "11.7.1"
|
||||
- "12.2.2"
|
||||
default: "11.7.1"
|
||||
CARGO_CHEF_TAG:
|
||||
description: "Cargo chef version"
|
||||
required: true
|
||||
default: "0.1.41"
|
||||
type: choice
|
||||
options:
|
||||
- 0.1.41
|
||||
BASE_IMAGE:
|
||||
description: "which intermediate image you want to update"
|
||||
required: true
|
||||
default: "go-alpine-builder"
|
||||
type: choice
|
||||
options:
|
||||
- cuda-go-rust-builder
|
||||
- go-rust-builder
|
||||
- go-alpine-builder
|
||||
- rust-builder
|
||||
- rust-alpine-builder
|
||||
- go-rust-alpine-builder
|
||||
- py-runner
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: 'build/dockerfiles/intermediate'
|
||||
working-directory: "build/dockerfiles/intermediate"
|
||||
|
||||
jobs:
|
||||
build-and-publish-cuda-go-rust-builder:
|
||||
build-and-publish-intermediate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -43,177 +76,37 @@ jobs:
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: set tag env
|
||||
run: |
|
||||
if [ ${{github.event.inputs.BASE_IMAGE}} == "cuda-go-rust-builder" ]; then
|
||||
echo "TAG=cuda-${{ github.event.inputs.CUDA_VERSION }}-go-${{ github.event.inputs.GO_VERSION }}-rust-${{ github.event.inputs.RUST_VERSION }}" >> $GITHUB_ENV
|
||||
elif [ ${{github.event.inputs.BASE_IMAGE}} == "go-rust-builder" ]; then
|
||||
echo "TAG=go-${{ github.event.inputs.GO_VERSION }}-rust-${{ github.event.inputs.RUST_VERSION }}" >> $GITHUB_ENV
|
||||
elif [ ${{github.event.inputs.BASE_IMAGE}} == "go-alpine-builder" ]; then
|
||||
echo "TAG=${{ github.event.inputs.GO_VERSION }}" >> $GITHUB_ENV
|
||||
elif [ ${{github.event.inputs.BASE_IMAGE}} == "rust-builder" ]; then
|
||||
echo "TAG=${{ github.event.inputs.RUST_VERSION }}" >> $GITHUB_ENV
|
||||
elif [ ${{github.event.inputs.BASE_IMAGE}} == "rust-alpine-builder" ]; then
|
||||
echo "TAG=${{ github.event.inputs.RUST_VERSION }}" >> $GITHUB_ENV
|
||||
elif [ ${{github.event.inputs.BASE_IMAGE}} == "go-rust-alpine-builder" ]; then
|
||||
echo "TAG=go-${{ github.event.inputs.GO_VERSION }}-rust-${{ github.event.inputs.RUST_VERSION }}" >> $GITHUB_ENV
|
||||
elif [ ${{github.event.inputs.BASE_IMAGE}} == "py-runner" ]; then
|
||||
echo "TAG=${{ github.event.inputs.PYTHON_VERSION }}" >> $GITHUB_ENV
|
||||
else
|
||||
echo "no BASE_IMAGE match"
|
||||
fi
|
||||
- name: Build image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: build/dockerfiles/intermediate/cuda-go-rust-builder.Dockerfile
|
||||
tags: scrolltech/cuda-go-rust-builder:cuda-${{ github.event.inputs.CUDA_VERSION }}-go-${{ github.event.inputs.GO_VERSION }}-rust-${{ github.event.inputs.RUST_VERSION }}
|
||||
build-args: |
|
||||
CUDA_VERSION: ${{ github.event.inputs.CUDA_VERSION }}
|
||||
GO_VERSION: ${{ github.event.inputs.GO_VERSION }}
|
||||
RUST_VERSION: ${{ github.event.inputs.RUST_VERSION }}
|
||||
|
||||
build-and-publish-go-rust-builder:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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 image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: build/dockerfiles/intermediate/go-rust-builder.Dockerfile
|
||||
file: build/dockerfiles/intermediate/${{ github.event.inputs.BASE_IMAGE }}.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: scrolltech/go-rust-builder:go-${{ github.event.inputs.GO_VERSION }}-rust-${{ github.event.inputs.RUST_VERSION }}
|
||||
tags: scrolltech/${{ github.event.inputs.BASE_IMAGE }}:${{ env.TAG }}
|
||||
build-args: |
|
||||
GO_VERSION: ${{ github.event.inputs.GO_VERSION }}
|
||||
RUST_VERSION: ${{ github.event.inputs.RUST_VERSION }}
|
||||
|
||||
build-and-publish-go-alpine-builder:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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 image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: build/dockerfiles/intermediate/go-alpine-builder.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: scrolltech/go-alpine-builder:${{ github.event.inputs.GO_VERSION }}
|
||||
build-args: |
|
||||
GO_VERSION: ${{ github.event.inputs.GO_VERSION }}
|
||||
RUST_VERSION: ${{ github.event.inputs.RUST_VERSION }}
|
||||
|
||||
build-and-publish-rust-builder:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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 image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: build/dockerfiles/intermediate/rust-builder.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: scrolltech/rust-builder:${{ github.event.inputs.RUST_VERSION }}
|
||||
build-args: |
|
||||
RUST_VERSION: ${{ github.event.inputs.RUST_VERSION }}
|
||||
|
||||
build-and-publish-rust-alpine-builder:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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 image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: build/dockerfiles/intermediate/rust-alpine-builder.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: scrolltech/rust-alpine-builder:${{ github.event.inputs.RUST_VERSION }}
|
||||
build-args: |
|
||||
RUST_VERSION: ${{ github.event.inputs.RUST_VERSION }}
|
||||
|
||||
build-and-publish-go-rust-alpine-builder:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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 image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: build/dockerfiles/intermediate/go-rust-alpine-builder.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: scrolltech/go-rust-alpine-builder:go-${{ github.event.inputs.GO_VERSION }}-rust-${{ github.event.inputs.RUST_VERSION }}
|
||||
build-args: |
|
||||
GO_VERSION: ${{ github.event.inputs.GO_VERSION }}
|
||||
RUST_VERSION: ${{ github.event.inputs.RUST_VERSION }}
|
||||
|
||||
build-and-publish-py-runner:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@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 image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: build/dockerfiles/intermediate/py-runner.Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: scrolltech/py-runner:${{ github.event.inputs.PYTHON_VERSION }}
|
||||
build-args: |
|
||||
CUDA_VERSION: ${{ github.event.inputs.CUDA_VERSION }}
|
||||
GO_VERSION: ${{ github.event.inputs.GO_VERSION }}
|
||||
RUST_VERSION: ${{ github.event.inputs.RUST_VERSION }}
|
||||
|
||||
CUDA_VERSION=${{ github.event.inputs.CUDA_VERSION }}
|
||||
GO_VERSION=${{ github.event.inputs.GO_VERSION }}
|
||||
RUST_VERSION=${{ github.event.inputs.RUST_VERSION }}
|
||||
PYTHON_VERSION=${{ github.event.inputs.PYTHON_VERSION }}
|
||||
CARGO_CHEF_TAG=${{ github.event.inputs.CARGO_CHEF_TAG }}
|
||||
|
||||
137
.github/workflows/prover.yml
vendored
137
.github/workflows/prover.yml
vendored
@@ -25,78 +25,75 @@ defaults:
|
||||
working-directory: 'prover'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
if: github.event.pull_request.draft == false
|
||||
skip_check:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.21.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Test
|
||||
run: |
|
||||
go test -tags="mock_prover" -v -coverprofile=coverage.txt ./...
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
with:
|
||||
flags: prover
|
||||
- id: skip_check
|
||||
uses: fkirc/skip-duplicate-actions@v5
|
||||
with:
|
||||
cancel_others: 'true'
|
||||
concurrent_skipping: 'same_content_newer'
|
||||
paths_ignore: '["**/README.md"]'
|
||||
|
||||
fmt:
|
||||
needs: [skip_check]
|
||||
if: |
|
||||
github.event.pull_request.draft == false &&
|
||||
(github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true')
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: nightly-2023-12-03
|
||||
components: rustfmt
|
||||
- name: Cargo cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: "prover -> target"
|
||||
- name: Cargo check
|
||||
run: cargo check --all-features
|
||||
- name: Cargo fmt
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
clippy:
|
||||
needs: [skip_check, fmt]
|
||||
if: |
|
||||
github.event.pull_request.draft == false &&
|
||||
(github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true')
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: nightly-2023-12-03
|
||||
components: clippy
|
||||
- name: Cargo cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: "prover -> target"
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-features --all-targets -- -D warnings
|
||||
|
||||
compile:
|
||||
if: github.event_name == 'push' # will only be triggered when pushing to main & staging & develop & alpha
|
||||
needs: [skip_check, clippy]
|
||||
if: |
|
||||
github.event.pull_request.draft == false &&
|
||||
(github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly-2023-12-03
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.21.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Cache cargo
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: "common/libzkp/impl -> target"
|
||||
- name: Test
|
||||
run: |
|
||||
make prover
|
||||
check:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.21.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Lint
|
||||
run: |
|
||||
rm -rf $HOME/.cache/golangci-lint
|
||||
make lint
|
||||
goimports-lint:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.21.x
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Install goimports
|
||||
run: go install golang.org/x/tools/cmd/goimports
|
||||
- run: goimports -local scroll-tech/prover/ -w .
|
||||
- run: go mod tidy
|
||||
# If there are any diffs from goimports or go mod tidy, fail.
|
||||
- name: Verify no changes from goimports and go mod tidy
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
exit 1
|
||||
fi
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: nightly-2023-12-03
|
||||
- name: Cache cargo
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: "prover -> target"
|
||||
- name: Test
|
||||
run: |
|
||||
make prover
|
||||
2
.github/workflows/rollup.yml
vendored
2
.github/workflows/rollup.yml
vendored
@@ -105,7 +105,7 @@ jobs:
|
||||
- name: Test rollup packages
|
||||
working-directory: 'rollup'
|
||||
run: |
|
||||
./run_test.sh
|
||||
make test
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
env:
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -4,6 +4,8 @@ assets/seed
|
||||
|
||||
# Built binaries
|
||||
build/bin
|
||||
verifier.test
|
||||
core.test
|
||||
|
||||
coverage.txt
|
||||
*.integration.txt
|
||||
@@ -20,3 +22,5 @@ coverage.txt
|
||||
# misc
|
||||
sftp-config.json
|
||||
*~
|
||||
|
||||
target
|
||||
|
||||
15
.gitmodules
vendored
15
.gitmodules
vendored
@@ -1,12 +1,3 @@
|
||||
[submodule "l2geth"]
|
||||
path = l2geth
|
||||
url = git@github.com:scroll-tech/go-ethereum.git
|
||||
[submodule "contracts/lib/ds-test"]
|
||||
path = contracts/lib/ds-test
|
||||
url = https://github.com/dapphub/ds-test
|
||||
[submodule "contracts/lib/forge-std"]
|
||||
path = contracts/lib/forge-std
|
||||
url = https://github.com/foundry-rs/forge-std
|
||||
[submodule "contracts/lib/solmate"]
|
||||
path = contracts/lib/solmate
|
||||
url = https://github.com/rari-capital/solmate
|
||||
[submodule "scroll-contracts"]
|
||||
path = scroll-contracts
|
||||
url = https://github.com/scroll-tech/scroll-contracts.git
|
||||
|
||||
14
Makefile
14
Makefile
@@ -1,36 +1,33 @@
|
||||
.PHONY: fmt dev_docker build_test_docker run_test_docker clean update
|
||||
|
||||
L2GETH_TAG=scroll-v5.3.0
|
||||
L2GETH_TAG=scroll-v5.5.1
|
||||
|
||||
help: ## Display this help message
|
||||
@grep -h \
|
||||
-E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
||||
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
update:
|
||||
update: ## Update dependencies
|
||||
go work sync
|
||||
cd $(PWD)/bridge-history-api/ && go get -u github.com/scroll-tech/go-ethereum@${L2GETH_TAG} && go mod tidy
|
||||
cd $(PWD)/common/ && go get -u github.com/scroll-tech/go-ethereum@${L2GETH_TAG}&& go mod tidy
|
||||
cd $(PWD)/coordinator/ && go get -u github.com/scroll-tech/go-ethereum@${L2GETH_TAG} && go mod tidy
|
||||
cd $(PWD)/database/ && go get -u github.com/scroll-tech/go-ethereum@${L2GETH_TAG} && go mod tidy
|
||||
cd $(PWD)/prover/ && go get -u github.com/scroll-tech/go-ethereum@${L2GETH_TAG}&& go mod tidy
|
||||
cd $(PWD)/rollup/ && go get -u github.com/scroll-tech/go-ethereum@${L2GETH_TAG} && go mod tidy
|
||||
cd $(PWD)/tests/integration-test/ && go get -u github.com/scroll-tech/go-ethereum@${L2GETH_TAG} && go mod tidy
|
||||
|
||||
lint: ## The code's format and security checks.
|
||||
lint: ## The code's format and security checks
|
||||
make -C rollup lint
|
||||
make -C common lint
|
||||
make -C coordinator lint
|
||||
make -C database lint
|
||||
make -C prover lint
|
||||
make -C bridge-history-api lint
|
||||
|
||||
fmt: ## format the code
|
||||
fmt: ## Format the code
|
||||
go work sync
|
||||
cd $(PWD)/bridge-history-api/ && go mod tidy
|
||||
cd $(PWD)/common/ && go mod tidy
|
||||
cd $(PWD)/coordinator/ && go mod tidy
|
||||
cd $(PWD)/database/ && go mod tidy
|
||||
cd $(PWD)/prover/ && go mod tidy
|
||||
cd $(PWD)/rollup/ && go mod tidy
|
||||
cd $(PWD)/tests/integration-test/ && go mod tidy
|
||||
|
||||
@@ -38,11 +35,10 @@ fmt: ## format the code
|
||||
goimports -local $(PWD)/common/ -w .
|
||||
goimports -local $(PWD)/coordinator/ -w .
|
||||
goimports -local $(PWD)/database/ -w .
|
||||
goimports -local $(PWD)/prover/ -w .
|
||||
goimports -local $(PWD)/rollup/ -w .
|
||||
goimports -local $(PWD)/tests/integration-test/ -w .
|
||||
|
||||
dev_docker: ## build docker images for development/testing usages
|
||||
dev_docker: ## Build docker images for development/testing usages
|
||||
docker pull postgres
|
||||
docker build -t scroll_l1geth ./common/testcontainers/docker/l1geth/
|
||||
docker build -t scroll_l2geth ./common/testcontainers/docker/l2geth/
|
||||
|
||||
22
README.md
22
README.md
@@ -1,7 +1,6 @@
|
||||
# Scroll Monorepo
|
||||
|
||||
[](https://github.com/scroll-tech/scroll/actions/workflows/rollup.yml)
|
||||
[](https://github.com/scroll-tech/scroll/actions/workflows/contracts.yml)
|
||||
[](https://github.com/scroll-tech/scroll/actions/workflows/bridge_history_api.yml)
|
||||
[](https://github.com/scroll-tech/scroll/actions/workflows/coordinator.yml)
|
||||
[](https://github.com/scroll-tech/scroll/actions/workflows/prover.yml)
|
||||
@@ -17,10 +16,9 @@
|
||||
├── <a href="./common/">common</a>: Common libraries and types
|
||||
├── <a href="./coordinator/">coordinator</a>: Prover coordinator service that dispatches proving tasks to provers
|
||||
├── <a href="./database">database</a>: Database client and schema definition
|
||||
├── <a href="./src">l2geth</a>: Scroll execution node
|
||||
├── <a href="./prover">prover</a>: Prover client that runs proof generation for zkEVM circuit and aggregation circuit
|
||||
├── <a href="./rollup">rollup</a>: Rollup-related services
|
||||
├── <a href="./rpc-gateway">rpc-gateway</a>: RPC gateway external repo
|
||||
├── <a href="https://github.com/scroll-tech/scroll-contracts.git">scroll-contracts</a>: solidity code for Scroll L1 bridge and rollup contracts and L2 bridge and pre-deployed contracts.
|
||||
└── <a href="./tests">tests</a>: Integration tests
|
||||
</pre>
|
||||
|
||||
@@ -46,30 +44,12 @@ make dev_docker
|
||||
Run the tests using the following commands:
|
||||
|
||||
```bash
|
||||
export LIBSCROLL_ZSTD_VERSION=v0.0.0-rc0-ubuntu20.04
|
||||
export SCROLL_LIB_PATH=/scroll/lib
|
||||
|
||||
sudo mkdir -p $SCROLL_LIB_PATH
|
||||
|
||||
sudo wget -O $SCROLL_LIB_PATH/libzktrie.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libzktrie.so
|
||||
sudo wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so
|
||||
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH
|
||||
export CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
|
||||
|
||||
go test -v -race -covermode=atomic scroll-tech/rollup/...
|
||||
|
||||
go test -tags="mock_verifier" -v -race -covermode=atomic scroll-tech/coordinator/...
|
||||
go test -v -race -covermode=atomic scroll-tech/database/...
|
||||
go test -v -race -covermode=atomic scroll-tech/common/...
|
||||
```
|
||||
|
||||
## Testing Contracts
|
||||
|
||||
You can find the unit tests in [`contracts/src/test/`](/contracts/src/test/), and integration tests in [`contracts/integration-test/`](/contracts/integration-test/).
|
||||
|
||||
See [`contracts`](/contracts) for more details on the contracts.
|
||||
|
||||
## License
|
||||
|
||||
Scroll Monorepo is licensed under the [MIT](./LICENSE) license.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -96,7 +96,7 @@ func action(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run event watcher cmd instance.
|
||||
// Run bridge-history-backend api cmd instance.
|
||||
func Run() {
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
_, _ = fmt.Fprintln(os.Stderr, err)
|
||||
|
||||
@@ -84,7 +84,7 @@ func action(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run event watcher cmd instance.
|
||||
// Run bridge-history-backend fetcher cmd instance.
|
||||
func Run() {
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
_, _ = fmt.Fprintln(os.Stderr, err)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"ScrollChainAddr": "0xa13BAF47339d63B743e7Da8741db5456DAc1E556",
|
||||
"GatewayRouterAddr": "0xF8B1378579659D8F7EE5f3C929c2f3E332E41Fd6",
|
||||
"MessageQueueAddr": "0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B",
|
||||
"BatchBridgeGatewayAddr": "0x0000000000000000000000000000000000000000"
|
||||
"BatchBridgeGatewayAddr": "0x5Bcfd99c34cf7E06fc756f6f5aE7400504852bc4"
|
||||
},
|
||||
"L2": {
|
||||
"confirmation": 0,
|
||||
@@ -39,7 +39,7 @@
|
||||
"PufferGatewayAddr": "0x9eBf2f33526CD571f8b2ad312492cb650870CFd6",
|
||||
"GatewayRouterAddr": "0x4C0926FF5252A435FD19e10ED15e5a249Ba19d79",
|
||||
"MessageQueueAddr": "0x5300000000000000000000000000000000000000",
|
||||
"BatchBridgeGatewayAddr": "0x0000000000000000000000000000000000000000"
|
||||
"BatchBridgeGatewayAddr": "0xa1a12158bE6269D7580C63eC5E609Cdc0ddD82bC"
|
||||
},
|
||||
"db": {
|
||||
"dsn": "postgres://postgres:123456@localhost:5444/test?sslmode=disable",
|
||||
|
||||
@@ -8,10 +8,10 @@ require (
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/pressly/goose/v3 v3.16.0
|
||||
github.com/prometheus/client_golang v1.19.0
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240426041101-a860446ebaea
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/urfave/cli/v2 v2.25.7
|
||||
golang.org/x/sync v0.6.0
|
||||
golang.org/x/sync v0.7.0
|
||||
gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ require (
|
||||
dario.cat/mergo v1.0.0 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.12.0 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.13.0 // indirect
|
||||
github.com/btcsuite/btcd v0.20.1-beta // indirect
|
||||
github.com/bytedance/sonic v1.10.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
@@ -36,7 +36,7 @@ require (
|
||||
github.com/docker/docker v26.1.0+incompatible // indirect
|
||||
github.com/docker/go-connections v0.5.0 // indirect
|
||||
github.com/edsrzf/mmap-go v1.0.0 // indirect
|
||||
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 // indirect
|
||||
github.com/ethereum/c-kzg-4844 v1.0.2 // indirect
|
||||
github.com/fjl/memsize v0.0.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
@@ -57,7 +57,7 @@ require (
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.2.4 // indirect
|
||||
github.com/huin/goupnp v1.3.0 // indirect
|
||||
github.com/iden3/go-iden3-crypto v0.0.15 // indirect
|
||||
github.com/iden3/go-iden3-crypto v0.0.16 // indirect
|
||||
github.com/jackc/pgx/v5 v5.5.4 // indirect
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
@@ -65,7 +65,6 @@ require (
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.4 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -90,29 +89,28 @@ require (
|
||||
github.com/rjeczalik/notify v0.9.1 // indirect
|
||||
github.com/rs/cors v1.7.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/scroll-tech/zktrie v0.8.2 // indirect
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240730031611-1b736159d5cb // indirect
|
||||
github.com/scroll-tech/zktrie v0.8.4 // indirect
|
||||
github.com/sethvargo/go-retry v0.2.4 // indirect
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
|
||||
github.com/status-im/keycard-go v0.2.0 // indirect
|
||||
github.com/supranational/blst v0.3.11 // indirect
|
||||
github.com/supranational/blst v0.3.12 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.14 // indirect
|
||||
github.com/tklauser/numcpus v0.8.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.5.0 // indirect
|
||||
golang.org/x/crypto v0.19.0 // indirect
|
||||
golang.org/x/mod v0.16.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/crypto v0.24.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.17.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
|
||||
@@ -23,8 +23,8 @@ github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHG
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA=
|
||||
github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
|
||||
github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
|
||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||
@@ -61,7 +61,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0q
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI=
|
||||
github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -87,8 +86,8 @@ github.com/elastic/go-sysinfo v1.11.1 h1:g9mwl05njS4r69TisC+vwHWTSKywZFYYUu3so3T
|
||||
github.com/elastic/go-sysinfo v1.11.1/go.mod h1:6KQb31j0QeWBDF88jIdWSxE8cwoOB9tO4Y4osN7Q70E=
|
||||
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
|
||||
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
|
||||
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 h1:B2mpK+MNqgPqk2/KNi1LbqwtZDy5F7iy0mynQiBr8VA=
|
||||
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4/go.mod h1:y4GA2JbAUama1S4QwYjC2hefgGLU8Ul0GMtL/ADMF1c=
|
||||
github.com/ethereum/c-kzg-4844 v1.0.2 h1:8tV84BCEiPeOkiVgW9mpYBeBUir2bkCNVqxPwwVeO+s=
|
||||
github.com/ethereum/c-kzg-4844 v1.0.2/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
|
||||
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
|
||||
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
@@ -176,8 +175,8 @@ github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXei
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
|
||||
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
|
||||
github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4=
|
||||
github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
|
||||
github.com/iden3/go-iden3-crypto v0.0.16 h1:zN867xiz6HgErXVIV/6WyteGcOukE9gybYTorBMEdsk=
|
||||
github.com/iden3/go-iden3-crypto v0.0.16/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
@@ -309,10 +308,12 @@ github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240426041101-a860446ebaea h1:CH1WXWrpEpLaP3N+bFs2a1xdE0+lRm1AuJQb5YvE6Ls=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240426041101-a860446ebaea/go.mod h1:i4VBgWoaW/y0D8MmQb7hSOulyw1dKhuiSFAbznwivCA=
|
||||
github.com/scroll-tech/zktrie v0.8.2 h1:UMuIfA+jdgWMLmTgTL64Emo+zzMOdcnH0+eYdDcshxQ=
|
||||
github.com/scroll-tech/zktrie v0.8.2/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240730031611-1b736159d5cb h1:uOKdmDT0LsuS3gfynEjR4zA3Ooh6p2Z3O+IMRj2r8LA=
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240730031611-1b736159d5cb/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6 h1:Q8YyvrcPIcXQwE4ucm4bqmPh6TP6IB1GUTXripf2WyQ=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6/go.mod h1:byf/mZ8jLYUCnUePTicjJWn+RvKdxDn7buS6glTnMwQ=
|
||||
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
|
||||
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
|
||||
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
||||
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||
github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec=
|
||||
@@ -339,14 +340,14 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
|
||||
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/supranational/blst v0.3.12 h1:Vfas2U2CFHhniv2QkUm2OVa1+pGTdqtpqm9NnhUUbZ8=
|
||||
github.com/supranational/blst v0.3.12/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||
github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU=
|
||||
github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY=
|
||||
github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY=
|
||||
github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
|
||||
@@ -369,8 +370,8 @@ github.com/ydb-platform/ydb-go-genproto v0.0.0-20231012155159-f85a672542fd h1:dz
|
||||
github.com/ydb-platform/ydb-go-genproto v0.0.0-20231012155159-f85a672542fd/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
|
||||
github.com/ydb-platform/ydb-go-sdk/v3 v3.54.2 h1:E0yUuuX7UmPxXm92+yQCjMveLFO3zfvYFIJVuAqsVRA=
|
||||
github.com/ydb-platform/ydb-go-sdk/v3 v3.54.2/go.mod h1:fjBLQ2TdQNl4bMjuWl9adoTGBypwUTPoGC+EqYqiIcU=
|
||||
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
|
||||
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
|
||||
@@ -383,21 +384,21 @@ golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
|
||||
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -414,20 +415,18 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
|
||||
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE=
|
||||
|
||||
@@ -141,7 +141,7 @@ func (c *L2MessageFetcher) fetchAndSaveEvents(confirmation uint64) {
|
||||
return
|
||||
}
|
||||
|
||||
if updateErr := c.eventUpdateLogic.UpdateL1BatchIndexAndStatus(c.ctx, c.l2SyncHeight); updateErr != nil {
|
||||
if updateErr := c.eventUpdateLogic.UpdateL2WithdrawMessageProofs(c.ctx, c.l2SyncHeight); updateErr != nil {
|
||||
log.Error("failed to update L1 batch index and status", "from", from, "to", to, "err", updateErr)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
@@ -125,6 +125,11 @@ func (b *EventUpdateLogic) L1InsertOrUpdate(ctx context.Context, l1FetcherResult
|
||||
}
|
||||
|
||||
func (b *EventUpdateLogic) updateL2WithdrawMessageInfos(ctx context.Context, batchIndex, startBlock, endBlock uint64) error {
|
||||
if startBlock > endBlock {
|
||||
log.Warn("start block is greater than end block", "start", startBlock, "end", endBlock)
|
||||
return nil
|
||||
}
|
||||
|
||||
l2WithdrawMessages, err := b.crossMessageOrm.GetL2WithdrawalsByBlockRange(ctx, startBlock, endBlock)
|
||||
if err != nil {
|
||||
log.Error("failed to get L2 withdrawals by batch index", "batch index", batchIndex, "err", err)
|
||||
@@ -147,8 +152,8 @@ func (b *EventUpdateLogic) updateL2WithdrawMessageInfos(ctx context.Context, bat
|
||||
}
|
||||
|
||||
if withdrawTrie.NextMessageNonce != l2WithdrawMessages[0].MessageNonce {
|
||||
log.Error("nonce mismatch", "expected next message nonce", withdrawTrie.NextMessageNonce, "actuall next message nonce", l2WithdrawMessages[0].MessageNonce)
|
||||
return fmt.Errorf("nonce mismatch")
|
||||
log.Error("nonce mismatch", "expected next message nonce", withdrawTrie.NextMessageNonce, "actual next message nonce", l2WithdrawMessages[0].MessageNonce)
|
||||
return errors.New("nonce mismatch")
|
||||
}
|
||||
|
||||
messageHashes := make([]common.Hash, len(l2WithdrawMessages))
|
||||
@@ -173,24 +178,42 @@ func (b *EventUpdateLogic) updateL2WithdrawMessageInfos(ctx context.Context, bat
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateL1BatchIndexAndStatus updates L1 finalized batch index and status
|
||||
func (b *EventUpdateLogic) UpdateL1BatchIndexAndStatus(ctx context.Context, height uint64) error {
|
||||
finalizedBatches, err := b.batchEventOrm.GetFinalizedBatchesLEBlockHeight(ctx, height)
|
||||
// UpdateL2WithdrawMessageProofs updates L2 withdrawal message proofs.
|
||||
func (b *EventUpdateLogic) UpdateL2WithdrawMessageProofs(ctx context.Context, height uint64) error {
|
||||
lastUpdatedFinalizedBlockHeight, err := b.batchEventOrm.GetLastUpdatedFinalizedBlockHeight(ctx)
|
||||
if err != nil {
|
||||
log.Error("failed to get batches >= block height", "error", err)
|
||||
log.Error("failed to get last updated finalized block height", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
finalizedBatches, err := b.batchEventOrm.GetUnupdatedFinalizedBatchesLEBlockHeight(ctx, height)
|
||||
if err != nil {
|
||||
log.Error("failed to get unupdated finalized batches >= block height", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
for _, finalizedBatch := range finalizedBatches {
|
||||
log.Info("update finalized batch info of L2 withdrawals", "index", finalizedBatch.BatchIndex, "start", finalizedBatch.StartBlockNumber, "end", finalizedBatch.EndBlockNumber)
|
||||
if updateErr := b.updateL2WithdrawMessageInfos(ctx, finalizedBatch.BatchIndex, finalizedBatch.StartBlockNumber, finalizedBatch.EndBlockNumber); updateErr != nil {
|
||||
log.Error("failed to update L2 withdraw message infos", "index", finalizedBatch.BatchIndex, "start", finalizedBatch.StartBlockNumber, "end", finalizedBatch.EndBlockNumber, "error", updateErr)
|
||||
log.Info("update finalized batch or bundle info of L2 withdrawals", "index", finalizedBatch.BatchIndex, "lastUpdatedFinalizedBlockHeight", lastUpdatedFinalizedBlockHeight, "start", finalizedBatch.StartBlockNumber, "end", finalizedBatch.EndBlockNumber)
|
||||
// This method is compatible with both "finalize by batch" and "finalize by bundle" modes:
|
||||
// - In "finalize by batch" mode, each batch emits a FinalizedBatch event.
|
||||
// - In "finalize by bundle" mode, all batches in the bundle emit only one FinalizedBatch event, using the last batch's index and hash.
|
||||
//
|
||||
// The method updates two types of information in L2 withdrawal messages:
|
||||
// 1. Withdraw proof generation:
|
||||
// - finalize by batch: Generates proofs for each batch.
|
||||
// - finalize by bundle: Generates proofs for the entire bundle at once.
|
||||
// 2. Batch index updating:
|
||||
// - finalize by batch: Updates the batch index for withdrawal messages in each processed batch.
|
||||
// - finalize by bundle: Updates the batch index for all withdrawal messages in the bundle, using the index of the last batch in the bundle.
|
||||
if updateErr := b.updateL2WithdrawMessageInfos(ctx, finalizedBatch.BatchIndex, lastUpdatedFinalizedBlockHeight+1, finalizedBatch.EndBlockNumber); updateErr != nil {
|
||||
log.Error("failed to update L2 withdraw message infos", "index", finalizedBatch.BatchIndex, "lastUpdatedFinalizedBlockHeight", lastUpdatedFinalizedBlockHeight, "start", finalizedBatch.StartBlockNumber, "end", finalizedBatch.EndBlockNumber, "error", updateErr)
|
||||
return updateErr
|
||||
}
|
||||
if dbErr := b.batchEventOrm.UpdateBatchEventStatus(ctx, finalizedBatch.BatchIndex); dbErr != nil {
|
||||
log.Error("failed to update batch event status as updated", "index", finalizedBatch.BatchIndex, "start", finalizedBatch.StartBlockNumber, "end", finalizedBatch.EndBlockNumber, "error", dbErr)
|
||||
log.Error("failed to update batch event status as updated", "index", finalizedBatch.BatchIndex, "lastUpdatedFinalizedBlockHeight", lastUpdatedFinalizedBlockHeight, "start", finalizedBatch.StartBlockNumber, "end", finalizedBatch.EndBlockNumber, "error", dbErr)
|
||||
return dbErr
|
||||
}
|
||||
lastUpdatedFinalizedBlockHeight = finalizedBatch.EndBlockNumber
|
||||
b.eventUpdateLogicL1FinalizeBatchEventL2BlockUpdateHeight.Set(float64(finalizedBatch.EndBlockNumber))
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -407,7 +407,7 @@ func (h *HistoryLogic) cacheTxsInfo(ctx context.Context, cacheKey string, txs []
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// The transactions are sorted, thus we set the score as their indices.
|
||||
// The transactions are sorted, thus we set the score as their index.
|
||||
for _, tx := range txs {
|
||||
txBytes, err := json.Marshal(tx)
|
||||
if err != nil {
|
||||
|
||||
@@ -320,6 +320,16 @@ func (e *L1EventParser) ParseL1MessageQueueEventLogs(logs []types.Log, l1Deposit
|
||||
QueueIndex: index,
|
||||
})
|
||||
}
|
||||
case backendabi.L1ResetDequeuedTransactionEventSig:
|
||||
event := backendabi.L1ResetDequeuedTransactionEvent{}
|
||||
if err := utils.UnpackLog(backendabi.IL1MessageQueueABI, &event, "ResetDequeuedTransaction", vlog); err != nil {
|
||||
log.Error("Failed to unpack ResetDequeuedTransaction event", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
l1MessageQueueEvents = append(l1MessageQueueEvents, &orm.MessageQueueEvent{
|
||||
EventType: btypes.MessageQueueEventTypeResetDequeuedTransaction,
|
||||
QueueIndex: event.StartIndex.Uint64(),
|
||||
})
|
||||
case backendabi.L1DropTransactionEventSig:
|
||||
event := backendabi.L1DropTransactionEvent{}
|
||||
if err := utils.UnpackLog(backendabi.IL1MessageQueueABI, &event, "DropTransaction", vlog); err != nil {
|
||||
|
||||
@@ -210,7 +210,7 @@ func (f *L1FetcherLogic) l1FetcherLogs(ctx context.Context, from, to uint64) ([]
|
||||
Topics: make([][]common.Hash, 1),
|
||||
}
|
||||
|
||||
query.Topics[0] = make([]common.Hash, 14)
|
||||
query.Topics[0] = make([]common.Hash, 15)
|
||||
query.Topics[0][0] = backendabi.L1DepositETHSig
|
||||
query.Topics[0][1] = backendabi.L1DepositERC20Sig
|
||||
query.Topics[0][2] = backendabi.L1DepositERC721Sig
|
||||
@@ -224,7 +224,8 @@ func (f *L1FetcherLogic) l1FetcherLogs(ctx context.Context, from, to uint64) ([]
|
||||
query.Topics[0][10] = backendabi.L1QueueTransactionEventSig
|
||||
query.Topics[0][11] = backendabi.L1DequeueTransactionEventSig
|
||||
query.Topics[0][12] = backendabi.L1DropTransactionEventSig
|
||||
query.Topics[0][13] = backendabi.L1BridgeBatchDepositSig
|
||||
query.Topics[0][13] = backendabi.L1ResetDequeuedTransactionEventSig
|
||||
query.Topics[0][14] = backendabi.L1BridgeBatchDepositSig
|
||||
|
||||
eventLogs, err := f.client.FilterLogs(ctx, query)
|
||||
if err != nil {
|
||||
@@ -339,6 +340,10 @@ func (f *L1FetcherLogic) updateMetrics(res L1FilterResult) {
|
||||
f.l1FetcherLogicFetchedTotal.WithLabelValues("L1_skip_message").Add(1)
|
||||
case btypes.MessageQueueEventTypeDropTransaction:
|
||||
f.l1FetcherLogicFetchedTotal.WithLabelValues("L1_drop_message").Add(1)
|
||||
// one ResetDequeuedTransaction event could indicate reset multiple skipped messages,
|
||||
// this metric only counts the number of events, not the number of skipped messages.
|
||||
case btypes.MessageQueueEventTypeResetDequeuedTransaction:
|
||||
f.l1FetcherLogicFetchedTotal.WithLabelValues("L1_reset_skipped_messages").Add(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,26 @@ func (c *BatchEvent) GetBatchEventSyncedHeightInDB(ctx context.Context) (uint64,
|
||||
return batch.L1BlockNumber, nil
|
||||
}
|
||||
|
||||
// GetFinalizedBatchesLEBlockHeight returns the finalized batches with end block <= given block height in db.
|
||||
func (c *BatchEvent) GetFinalizedBatchesLEBlockHeight(ctx context.Context, blockHeight uint64) ([]*BatchEvent, error) {
|
||||
// GetLastUpdatedFinalizedBlockHeight returns the last updated finalized block height in db.
|
||||
func (c *BatchEvent) GetLastUpdatedFinalizedBlockHeight(ctx context.Context) (uint64, error) {
|
||||
var batch BatchEvent
|
||||
db := c.db.WithContext(ctx)
|
||||
db = db.Model(&BatchEvent{})
|
||||
db = db.Where("batch_status = ?", btypes.BatchStatusTypeFinalized)
|
||||
db = db.Where("update_status = ?", btypes.UpdateStatusTypeUpdated)
|
||||
db = db.Order("batch_index desc")
|
||||
if err := db.First(&batch).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
// No finalized batch found, return genesis batch's end block number.
|
||||
return 0, nil
|
||||
}
|
||||
return 0, fmt.Errorf("failed to get last updated finalized block height, error: %w", err)
|
||||
}
|
||||
return batch.EndBlockNumber, nil
|
||||
}
|
||||
|
||||
// GetUnupdatedFinalizedBatchesLEBlockHeight returns the finalized batches with end block <= given block height in db.
|
||||
func (c *BatchEvent) GetUnupdatedFinalizedBatchesLEBlockHeight(ctx context.Context, blockHeight uint64) ([]*BatchEvent, error) {
|
||||
var batches []*BatchEvent
|
||||
db := c.db.WithContext(ctx)
|
||||
db = db.Model(&BatchEvent{})
|
||||
@@ -66,7 +84,7 @@ func (c *BatchEvent) GetFinalizedBatchesLEBlockHeight(ctx context.Context, block
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("failed to get batches >= block height, error: %w", err)
|
||||
return nil, fmt.Errorf("failed to get unupdated finalized batches >= block height, error: %w", err)
|
||||
}
|
||||
return batches, nil
|
||||
}
|
||||
@@ -92,6 +110,7 @@ func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvent
|
||||
db = db.Where("batch_index = ?", l1BatchEvent.BatchIndex)
|
||||
db = db.Where("batch_hash = ?", l1BatchEvent.BatchHash)
|
||||
updateFields["batch_status"] = btypes.BatchStatusTypeFinalized
|
||||
updateFields["l1_block_number"] = l1BatchEvent.L1BlockNumber
|
||||
if err := db.Updates(updateFields).Error; err != nil {
|
||||
return fmt.Errorf("failed to update batch event, error: %w", err)
|
||||
}
|
||||
|
||||
@@ -217,6 +217,12 @@ func (c *CrossMessage) UpdateL1MessageQueueEventsInfo(ctx context.Context, l1Mes
|
||||
db = db.Where("message_nonce = ?", l1MessageQueueEvent.QueueIndex)
|
||||
db = db.Where("message_type = ?", btypes.MessageTypeL1SentMessage)
|
||||
txStatusUpdateFields["tx_status"] = types.TxStatusTypeDropped
|
||||
case btypes.MessageQueueEventTypeResetDequeuedTransaction:
|
||||
db = db.Where("tx_status = ?", types.TxStatusTypeSkipped)
|
||||
// reset skipped messages that the nonce is greater than or equal to the queue index.
|
||||
db = db.Where("message_nonce >= ?", l1MessageQueueEvent.QueueIndex)
|
||||
db = db.Where("message_type = ?", btypes.MessageTypeL1SentMessage)
|
||||
txStatusUpdateFields["tx_status"] = types.TxStatusTypeSent
|
||||
}
|
||||
if err := db.Updates(txStatusUpdateFields).Error; err != nil {
|
||||
return fmt.Errorf("failed to update tx statuses of L1 message queue events, update fields: %v, error: %w", txStatusUpdateFields, err)
|
||||
@@ -230,7 +236,7 @@ func (c *CrossMessage) UpdateL1MessageQueueEventsInfo(ctx context.Context, l1Mes
|
||||
db = db.Model(&CrossMessage{})
|
||||
txHashUpdateFields := make(map[string]interface{})
|
||||
switch l1MessageQueueEvent.EventType {
|
||||
case btypes.MessageQueueEventTypeDequeueTransaction:
|
||||
case btypes.MessageQueueEventTypeDequeueTransaction, btypes.MessageQueueEventTypeResetDequeuedTransaction:
|
||||
continue
|
||||
case btypes.MessageQueueEventTypeQueueTransaction:
|
||||
// only replayMessages or enforced txs (whose message hashes would not be found), sendMessages have been filtered out.
|
||||
|
||||
@@ -70,6 +70,7 @@ const (
|
||||
MessageQueueEventTypeQueueTransaction
|
||||
MessageQueueEventTypeDequeueTransaction
|
||||
MessageQueueEventTypeDropTransaction
|
||||
MessageQueueEventTypeResetDequeuedTransaction
|
||||
)
|
||||
|
||||
// BatchStatusType represents the type of batch status.
|
||||
|
||||
@@ -38,7 +38,7 @@ func GetBlockNumber(ctx context.Context, client *ethclient.Client, confirmations
|
||||
// @todo: add unit test.
|
||||
func UnpackLog(c *abi.ABI, out interface{}, event string, log types.Log) error {
|
||||
if log.Topics[0] != c.Events[event].ID {
|
||||
return fmt.Errorf("event signature mismatch")
|
||||
return errors.New("event signature mismatch")
|
||||
}
|
||||
if len(log.Data) > 0 {
|
||||
if err := c.UnpackIntoInterface(out, event, log.Data); err != nil {
|
||||
@@ -66,32 +66,55 @@ func ComputeMessageHash(
|
||||
return common.BytesToHash(crypto.Keccak256(data))
|
||||
}
|
||||
|
||||
type commitBatchArgs struct {
|
||||
Version uint8
|
||||
ParentBatchHeader []byte
|
||||
Chunks [][]byte
|
||||
SkippedL1MessageBitmap []byte
|
||||
}
|
||||
|
||||
// GetBatchRangeFromCalldata find the block range from calldata, both inclusive.
|
||||
func GetBatchRangeFromCalldata(calldata []byte) (uint64, uint64, error) {
|
||||
method := backendabi.IScrollChainABI.Methods["commitBatch"]
|
||||
values, err := method.Inputs.Unpack(calldata[4:])
|
||||
if err != nil {
|
||||
// special case: import genesis batch
|
||||
method = backendabi.IScrollChainABI.Methods["importGenesisBatch"]
|
||||
_, err2 := method.Inputs.Unpack(calldata[4:])
|
||||
if err2 == nil {
|
||||
// genesis batch
|
||||
return 0, 0, nil
|
||||
}
|
||||
// none of "commitBatch" and "importGenesisBatch" match, give up
|
||||
return 0, 0, err
|
||||
func GetBatchRangeFromCalldata(txData []byte) (uint64, uint64, error) {
|
||||
const methodIDLength = 4
|
||||
if len(txData) < methodIDLength {
|
||||
return 0, 0, fmt.Errorf("transaction data is too short, length of tx data: %v, minimum length required: %v", len(txData), methodIDLength)
|
||||
}
|
||||
args := commitBatchArgs{}
|
||||
err = method.Inputs.Copy(&args, values)
|
||||
method, err := backendabi.IScrollChainABI.MethodById(txData[:methodIDLength])
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
return 0, 0, fmt.Errorf("failed to get method by ID, ID: %v, err: %w", txData[:methodIDLength], err)
|
||||
}
|
||||
values, err := method.Inputs.Unpack(txData[methodIDLength:])
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("failed to unpack transaction data using ABI, tx data: %v, err: %w", txData, err)
|
||||
}
|
||||
|
||||
var chunks [][]byte
|
||||
|
||||
if method.Name == "importGenesisBatch" {
|
||||
return 0, 0, nil
|
||||
} else if method.Name == "commitBatch" {
|
||||
type commitBatchArgs struct {
|
||||
Version uint8
|
||||
ParentBatchHeader []byte
|
||||
Chunks [][]byte
|
||||
SkippedL1MessageBitmap []byte
|
||||
}
|
||||
|
||||
var args commitBatchArgs
|
||||
if err = method.Inputs.Copy(&args, values); err != nil {
|
||||
return 0, 0, fmt.Errorf("failed to decode calldata into commitBatch args, values: %+v, err: %w", values, err)
|
||||
}
|
||||
|
||||
chunks = args.Chunks
|
||||
|
||||
} else if method.Name == "commitBatchWithBlobProof" {
|
||||
type commitBatchWithBlobProofArgs struct {
|
||||
Version uint8
|
||||
ParentBatchHeader []byte
|
||||
Chunks [][]byte
|
||||
SkippedL1MessageBitmap []byte
|
||||
BlobDataProof []byte
|
||||
}
|
||||
|
||||
var args commitBatchWithBlobProofArgs
|
||||
if err = method.Inputs.Copy(&args, values); err != nil {
|
||||
return 0, 0, fmt.Errorf("failed to decode calldata into commitBatchWithBlobProofArgs args, values: %+v, err: %w", values, err)
|
||||
}
|
||||
|
||||
chunks = args.Chunks
|
||||
}
|
||||
|
||||
var startBlock uint64
|
||||
@@ -100,14 +123,14 @@ func GetBatchRangeFromCalldata(calldata []byte) (uint64, uint64, error) {
|
||||
// decode blocks from chunk and assume that there's no empty chunk
|
||||
// | 1 byte | 60 bytes | ... | 60 bytes |
|
||||
// | num blocks | block 1 | ... | block n |
|
||||
if len(args.Chunks) == 0 {
|
||||
if len(chunks) == 0 {
|
||||
return 0, 0, errors.New("invalid chunks")
|
||||
}
|
||||
chunk := args.Chunks[0]
|
||||
chunk := chunks[0]
|
||||
block := chunk[1:61] // first block in chunk
|
||||
startBlock = binary.BigEndian.Uint64(block[0:8])
|
||||
|
||||
chunk = args.Chunks[len(args.Chunks)-1]
|
||||
chunk = chunks[len(chunks)-1]
|
||||
lastBlockIndex := int(chunk[0]) - 1
|
||||
block = chunk[1+lastBlockIndex*60 : 1+lastBlockIndex*60+60] // last block in chunk
|
||||
finishBlock = binary.BigEndian.Uint64(block[0:8])
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
||||
# Download Go dependencies
|
||||
FROM golang:1.21-alpine3.19 as base
|
||||
FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.mod* ./
|
||||
@@ -11,11 +11,13 @@ FROM base as builder
|
||||
|
||||
RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
cd /src/bridge-history-api/cmd/api && go build -v -p 4 -o /bin/bridgehistoryapi-api
|
||||
cd /src/bridge-history-api/cmd/api && CGO_LDFLAGS="-Wl,--no-as-needed -ldl" go build -v -p 4 -o /bin/bridgehistoryapi-api
|
||||
|
||||
# Pull bridgehistoryapi-api into a second stage deploy alpine container
|
||||
FROM alpine:latest
|
||||
# Pull bridgehistoryapi-api into a second stage deploy ubuntu container
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ENV CGO_LDFLAGS="-Wl,--no-as-needed -ldl"
|
||||
|
||||
COPY --from=builder /bin/bridgehistoryapi-api /bin/
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["bridgehistoryapi-api"]
|
||||
ENTRYPOINT ["bridgehistoryapi-api"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Download Go dependencies
|
||||
FROM golang:1.21-alpine3.19 as base
|
||||
FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.mod* ./
|
||||
@@ -11,11 +11,13 @@ FROM base as builder
|
||||
|
||||
RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
cd /src/bridge-history-api/cmd/fetcher && go build -v -p 4 -o /bin/bridgehistoryapi-fetcher
|
||||
cd /src/bridge-history-api/cmd/fetcher && CGO_LDFLAGS="-Wl,--no-as-needed -ldl" go build -v -p 4 -o /bin/bridgehistoryapi-fetcher
|
||||
|
||||
# Pull bridgehistoryapi-fetcher into a second stage deploy alpine container
|
||||
FROM alpine:latest
|
||||
# Pull bridgehistoryapi-fetcher into a second stage deploy ubuntu container
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ENV CGO_LDFLAGS="-Wl,--no-as-needed -ldl"
|
||||
|
||||
COPY --from=builder /bin/bridgehistoryapi-fetcher /bin/
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["bridgehistoryapi-fetcher"]
|
||||
ENTRYPOINT ["bridgehistoryapi-fetcher"]
|
||||
|
||||
@@ -13,7 +13,6 @@ RUN cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
COPY ./common/libzkp/impl .
|
||||
RUN cargo build --release
|
||||
RUN find ./ | grep libzktrie.so | xargs -I{} cp {} /app/target/release/
|
||||
|
||||
|
||||
# Download Go dependencies
|
||||
@@ -24,7 +23,6 @@ COPY ./rollup/go.* ./rollup/
|
||||
COPY ./common/go.* ./common/
|
||||
COPY ./coordinator/go.* ./coordinator/
|
||||
COPY ./database/go.* ./database/
|
||||
COPY ./prover/go.* ./prover/
|
||||
COPY ./tests/integration-test/go.* ./tests/integration-test/
|
||||
COPY ./bridge-history-api/go.* ./bridge-history-api/
|
||||
RUN go mod download -x
|
||||
@@ -35,12 +33,12 @@ FROM base as builder
|
||||
COPY . .
|
||||
RUN cp -r ./common/libzkp/interface ./coordinator/internal/logic/verifier/lib
|
||||
COPY --from=zkp-builder /app/target/release/libzkp.so ./coordinator/internal/logic/verifier/lib/
|
||||
COPY --from=zkp-builder /app/target/release/libzktrie.so ./coordinator/internal/logic/verifier/lib/
|
||||
RUN cd ./coordinator && make coordinator_api_skip_libzkp && mv ./build/bin/coordinator_api /bin/coordinator_api && mv internal/logic/verifier/lib /bin/
|
||||
RUN cd ./coordinator && CGO_LDFLAGS="-Wl,--no-as-needed -ldl" make coordinator_api_skip_libzkp && mv ./build/bin/coordinator_api /bin/coordinator_api && mv internal/logic/verifier/lib /bin/
|
||||
|
||||
# Pull coordinator into a second stage deploy alpine container
|
||||
# Pull coordinator into a second stage deploy ubuntu container
|
||||
FROM ubuntu:20.04
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/src/coordinator/internal/logic/verifier/lib
|
||||
ENV CGO_LDFLAGS="-Wl,--no-as-needed -ldl"
|
||||
# ENV CHAIN_ID=534353
|
||||
RUN mkdir -p /src/coordinator/internal/logic/verifier/lib
|
||||
COPY --from=builder /bin/lib /src/coordinator/internal/logic/verifier/lib
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Download Go dependencies
|
||||
FROM scrolltech/go-alpine-builder:1.21 as base
|
||||
FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.work* ./
|
||||
@@ -7,7 +7,6 @@ COPY ./rollup/go.* ./rollup/
|
||||
COPY ./common/go.* ./common/
|
||||
COPY ./coordinator/go.* ./coordinator/
|
||||
COPY ./database/go.* ./database/
|
||||
COPY ./prover/go.* ./prover/
|
||||
COPY ./tests/integration-test/go.* ./tests/integration-test/
|
||||
COPY ./bridge-history-api/go.* ./bridge-history-api/
|
||||
RUN go mod download -x
|
||||
@@ -16,10 +15,13 @@ RUN go mod download -x
|
||||
FROM base as builder
|
||||
RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
cd /src/coordinator/cmd/cron/ && go build -v -p 4 -o /bin/coordinator_cron
|
||||
cd /src/coordinator/cmd/cron/ && CGO_LDFLAGS="-Wl,--no-as-needed -ldl" go build -v -p 4 -o /bin/coordinator_cron
|
||||
|
||||
# Pull coordinator into a second stage deploy ubuntu container
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ENV CGO_LDFLAGS="-Wl,--no-as-needed -ldl"
|
||||
|
||||
# Pull coordinator into a second stage deploy alpine container
|
||||
FROM alpine:latest
|
||||
COPY --from=builder /bin/coordinator_cron /bin/
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["coordinator_cron"]
|
||||
ENTRYPOINT ["coordinator_cron"]
|
||||
|
||||
@@ -7,7 +7,6 @@ COPY ./rollup/go.* ./rollup/
|
||||
COPY ./common/go.* ./common/
|
||||
COPY ./coordinator/go.* ./coordinator/
|
||||
COPY ./database/go.* ./database/
|
||||
COPY ./prover/go.* ./prover/
|
||||
COPY ./tests/integration-test/go.* ./tests/integration-test/
|
||||
COPY ./bridge-history-api/go.* ./bridge-history-api/
|
||||
RUN go mod download -x
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
ARG LIBSCROLL_ZSTD_VERSION=v0.0.0-rc0-ubuntu20.04
|
||||
ARG SCROLL_LIB_PATH=/scroll/lib
|
||||
|
||||
# Download Go dependencies
|
||||
FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.work* ./
|
||||
COPY ./rollup/go.* ./rollup/
|
||||
COPY ./common/go.* ./common/
|
||||
COPY ./coordinator/go.* ./coordinator/
|
||||
COPY ./database/go.* ./database/
|
||||
COPY ./prover/go.* ./prover/
|
||||
COPY ./tests/integration-test/go.* ./tests/integration-test/
|
||||
COPY ./bridge-history-api/go.* ./bridge-history-api/
|
||||
RUN go mod download -x
|
||||
|
||||
# Build event_watcher
|
||||
FROM base as builder
|
||||
|
||||
ARG LIBSCROLL_ZSTD_VERSION
|
||||
ARG SCROLL_LIB_PATH
|
||||
|
||||
RUN mkdir -p $SCROLL_LIB_PATH
|
||||
|
||||
RUN apt-get -qq update && apt-get -qq install -y wget
|
||||
|
||||
RUN wget -O $SCROLL_LIB_PATH/libzktrie.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libzktrie.so
|
||||
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so
|
||||
|
||||
ENV LD_LIBRARY_PATH=$SCROLL_LIB_PATH
|
||||
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
|
||||
|
||||
RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
cd /src/rollup/cmd/event_watcher/ && go build -v -p 4 -o /bin/event_watcher
|
||||
|
||||
# Pull event_watcher into a second stage deploy alpine container
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ARG LIBSCROLL_ZSTD_VERSION
|
||||
ARG SCROLL_LIB_PATH
|
||||
|
||||
RUN mkdir -p $SCROLL_LIB_PATH
|
||||
|
||||
RUN apt-get -qq update && apt-get -qq install -y wget
|
||||
|
||||
RUN wget -O $SCROLL_LIB_PATH/libzktrie.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libzktrie.so
|
||||
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so
|
||||
|
||||
ENV LD_LIBRARY_PATH=$SCROLL_LIB_PATH
|
||||
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
|
||||
|
||||
COPY --from=builder /bin/event_watcher /bin/
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["event_watcher"]
|
||||
@@ -1,5 +0,0 @@
|
||||
assets/
|
||||
docs/
|
||||
l2geth/
|
||||
rpc-gateway/
|
||||
*target/*
|
||||
@@ -1,6 +1,3 @@
|
||||
ARG LIBSCROLL_ZSTD_VERSION=v0.0.0-rc0-ubuntu20.04
|
||||
ARG SCROLL_LIB_PATH=/scroll/lib
|
||||
|
||||
# Download Go dependencies
|
||||
FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base
|
||||
|
||||
@@ -10,7 +7,6 @@ COPY ./rollup/go.* ./rollup/
|
||||
COPY ./common/go.* ./common/
|
||||
COPY ./coordinator/go.* ./coordinator/
|
||||
COPY ./database/go.* ./database/
|
||||
COPY ./prover/go.* ./prover/
|
||||
COPY ./tests/integration-test/go.* ./tests/integration-test/
|
||||
COPY ./bridge-history-api/go.* ./bridge-history-api/
|
||||
RUN go mod download -x
|
||||
@@ -18,39 +14,17 @@ RUN go mod download -x
|
||||
# Build gas_oracle
|
||||
FROM base as builder
|
||||
|
||||
ARG LIBSCROLL_ZSTD_VERSION
|
||||
ARG SCROLL_LIB_PATH
|
||||
|
||||
RUN mkdir -p $SCROLL_LIB_PATH
|
||||
|
||||
RUN apt-get -qq update && apt-get -qq install -y wget
|
||||
|
||||
RUN wget -O $SCROLL_LIB_PATH/libzktrie.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libzktrie.so
|
||||
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so
|
||||
|
||||
ENV LD_LIBRARY_PATH=$SCROLL_LIB_PATH
|
||||
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
|
||||
|
||||
RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
cd /src/rollup/cmd/gas_oracle/ && go build -v -p 4 -o /bin/gas_oracle
|
||||
cd /src/rollup/cmd/gas_oracle/ && CGO_LDFLAGS="-ldl" go build -v -p 4 -o /bin/gas_oracle
|
||||
|
||||
# Pull gas_oracle into a second stage deploy alpine container
|
||||
# Pull gas_oracle into a second stage deploy ubuntu container
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ARG LIBSCROLL_ZSTD_VERSION
|
||||
ARG SCROLL_LIB_PATH
|
||||
RUN apt update && apt install ca-certificates -y
|
||||
|
||||
RUN mkdir -p $SCROLL_LIB_PATH
|
||||
|
||||
RUN apt-get -qq update && apt-get -qq install -y wget
|
||||
|
||||
RUN wget -O $SCROLL_LIB_PATH/libzktrie.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libzktrie.so
|
||||
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so
|
||||
|
||||
ENV LD_LIBRARY_PATH=$SCROLL_LIB_PATH
|
||||
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
|
||||
ENV CGO_LDFLAGS="-ldl"
|
||||
|
||||
COPY --from=builder /bin/gas_oracle /bin/
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["gas_oracle"]
|
||||
ENTRYPOINT ["gas_oracle"]
|
||||
|
||||
@@ -29,7 +29,14 @@ RUN cargo install cargo-chef --locked --version ${CARGO_CHEF_TAG} \
|
||||
# Install Go
|
||||
ARG GO_VERSION
|
||||
RUN rm -rf /usr/local/go
|
||||
RUN wget https://go.dev/dl/go${GO_VERSION}.1.linux-amd64.tar.gz
|
||||
RUN tar -C /usr/local -xzf go${GO_VERSION}.1.linux-amd64.tar.gz
|
||||
RUN rm go${GO_VERSION}.1.linux-amd64.tar.gz
|
||||
RUN if [ "$(uname -m)" = "x86_64" ]; then \
|
||||
echo amd64 >/tmp/arch; \
|
||||
elif [ "$(uname -m)" = "aarch64" ]; then \
|
||||
echo arm64 >/tmp/arch; \
|
||||
else \
|
||||
echo "Unsupported architecture"; exit 1; \
|
||||
fi
|
||||
RUN wget https://go.dev/dl/go${GO_VERSION}.1.linux-$(cat /tmp/arch).tar.gz
|
||||
RUN tar -C /usr/local -xzf go${GO_VERSION}.1.linux-$(cat /tmp/arch).tar.gz
|
||||
RUN rm go${GO_VERSION}.1.linux-$(cat /tmp/arch).tar.gz && rm /tmp/arch
|
||||
ENV PATH="/usr/local/go/bin:${PATH}"
|
||||
|
||||
@@ -25,7 +25,14 @@ RUN cargo install cargo-chef --locked --version ${CARGO_CHEF_TAG} \
|
||||
# Install Go
|
||||
ARG GO_VERSION
|
||||
RUN rm -rf /usr/local/go
|
||||
RUN wget https://go.dev/dl/go${GO_VERSION}.1.linux-amd64.tar.gz
|
||||
RUN tar -C /usr/local -xzf go${GO_VERSION}.1.linux-amd64.tar.gz
|
||||
RUN rm go${GO_VERSION}.1.linux-amd64.tar.gz
|
||||
RUN if [ "$(uname -m)" = "x86_64" ]; then \
|
||||
echo amd64 >/tmp/arch; \
|
||||
elif [ "$(uname -m)" = "aarch64" ]; then \
|
||||
echo arm64 >/tmp/arch; \
|
||||
else \
|
||||
echo "Unsupported architecture"; exit 1; \
|
||||
fi
|
||||
RUN wget https://go.dev/dl/go${GO_VERSION}.1.linux-$(cat /tmp/arch).tar.gz
|
||||
RUN tar -C /usr/local -xzf go${GO_VERSION}.1.linux-$(cat /tmp/arch).tar.gz
|
||||
RUN rm go${GO_VERSION}.1.linux-$(cat /tmp/arch).tar.gz && rm /tmp/arch
|
||||
ENV PATH="/usr/local/go/bin:${PATH}"
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
ARG LIBSCROLL_ZSTD_VERSION=v0.0.0-rc0-ubuntu20.04
|
||||
ARG SCROLL_LIB_PATH=/scroll/lib
|
||||
|
||||
# Download Go dependencies
|
||||
FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as base
|
||||
|
||||
@@ -10,7 +7,6 @@ COPY ./rollup/go.* ./rollup/
|
||||
COPY ./common/go.* ./common/
|
||||
COPY ./coordinator/go.* ./coordinator/
|
||||
COPY ./database/go.* ./database/
|
||||
COPY ./prover/go.* ./prover/
|
||||
COPY ./tests/integration-test/go.* ./tests/integration-test/
|
||||
COPY ./bridge-history-api/go.* ./bridge-history-api/
|
||||
RUN go mod download -x
|
||||
@@ -18,38 +14,16 @@ RUN go mod download -x
|
||||
# Build rollup_relayer
|
||||
FROM base as builder
|
||||
|
||||
ARG LIBSCROLL_ZSTD_VERSION
|
||||
ARG SCROLL_LIB_PATH
|
||||
|
||||
RUN mkdir -p $SCROLL_LIB_PATH
|
||||
|
||||
RUN apt-get -qq update && apt-get -qq install -y wget
|
||||
|
||||
RUN wget -O $SCROLL_LIB_PATH/libzktrie.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libzktrie.so
|
||||
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so
|
||||
|
||||
ENV LD_LIBRARY_PATH=$SCROLL_LIB_PATH
|
||||
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
|
||||
|
||||
RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
cd /src/rollup/cmd/rollup_relayer/ && go build -v -p 4 -o /bin/rollup_relayer
|
||||
cd /src/rollup/cmd/rollup_relayer/ && CGO_LDFLAGS="-ldl" go build -v -p 4 -o /bin/rollup_relayer
|
||||
|
||||
# Pull rollup_relayer into a second stage deploy alpine container
|
||||
# Pull rollup_relayer into a second stage deploy ubuntu container
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ARG LIBSCROLL_ZSTD_VERSION
|
||||
ARG SCROLL_LIB_PATH
|
||||
RUN apt update && apt install ca-certificates -y
|
||||
|
||||
RUN mkdir -p $SCROLL_LIB_PATH
|
||||
|
||||
RUN apt-get -qq update && apt-get -qq install -y wget
|
||||
|
||||
RUN wget -O $SCROLL_LIB_PATH/libzktrie.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libzktrie.so
|
||||
RUN wget -O $SCROLL_LIB_PATH/libscroll_zstd.so https://github.com/scroll-tech/da-codec/releases/download/$LIBSCROLL_ZSTD_VERSION/libscroll_zstd.so
|
||||
|
||||
ENV LD_LIBRARY_PATH=$SCROLL_LIB_PATH
|
||||
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
|
||||
ENV CGO_LDFLAGS="-ldl"
|
||||
|
||||
COPY --from=builder /bin/rollup_relayer /bin/
|
||||
WORKDIR /app
|
||||
|
||||
@@ -1,89 +1,50 @@
|
||||
package forks
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/big"
|
||||
"sort"
|
||||
|
||||
"github.com/scroll-tech/da-codec/encoding"
|
||||
"github.com/scroll-tech/go-ethereum/params"
|
||||
)
|
||||
|
||||
// CollectSortedForkHeights returns a sorted set of block numbers that one or more forks are activated on
|
||||
func CollectSortedForkHeights(config *params.ChainConfig) ([]uint64, map[uint64]bool, map[string]uint64) {
|
||||
type nameFork struct {
|
||||
name string
|
||||
block *big.Int
|
||||
// GetHardforkName returns the name of the hardfork active at the given block height and timestamp.
|
||||
// It checks the chain configuration to determine which hardfork is active.
|
||||
func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uint64) string {
|
||||
if !config.IsBernoulli(new(big.Int).SetUint64(blockHeight)) {
|
||||
return "homestead"
|
||||
} else if !config.IsCurie(new(big.Int).SetUint64(blockHeight)) {
|
||||
return "bernoulli"
|
||||
} else if !config.IsDarwin(blockTimestamp) {
|
||||
return "curie"
|
||||
} else {
|
||||
return "darwin"
|
||||
}
|
||||
|
||||
forkHeightNameMap := make(map[uint64]string)
|
||||
|
||||
for _, fork := range []nameFork{
|
||||
{name: "homestead", block: config.HomesteadBlock},
|
||||
{name: "daoFork", block: config.DAOForkBlock},
|
||||
{name: "eip150", block: config.EIP150Block},
|
||||
{name: "eip155", block: config.EIP155Block},
|
||||
{name: "eip158", block: config.EIP158Block},
|
||||
{name: "byzantium", block: config.ByzantiumBlock},
|
||||
{name: "constantinople", block: config.ConstantinopleBlock},
|
||||
{name: "petersburg", block: config.PetersburgBlock},
|
||||
{name: "istanbul", block: config.IstanbulBlock},
|
||||
{name: "muirGlacier", block: config.MuirGlacierBlock},
|
||||
{name: "berlin", block: config.BerlinBlock},
|
||||
{name: "london", block: config.LondonBlock},
|
||||
{name: "arrowGlacier", block: config.ArrowGlacierBlock},
|
||||
{name: "archimedes", block: config.ArchimedesBlock},
|
||||
{name: "shanghai", block: config.ShanghaiBlock},
|
||||
{name: "bernoulli", block: config.BernoulliBlock},
|
||||
{name: "curie", block: config.CurieBlock},
|
||||
} {
|
||||
if fork.block == nil {
|
||||
continue
|
||||
}
|
||||
height := fork.block.Uint64()
|
||||
|
||||
// only keep latest fork for at each height, discard the rest
|
||||
forkHeightNameMap[height] = fork.name
|
||||
}
|
||||
|
||||
forkHeightsMap := make(map[uint64]bool)
|
||||
forkNameHeightMap := make(map[string]uint64)
|
||||
|
||||
for height, name := range forkHeightNameMap {
|
||||
forkHeightsMap[height] = true
|
||||
forkNameHeightMap[name] = height
|
||||
}
|
||||
|
||||
var forkHeights []uint64
|
||||
for height := range forkHeightsMap {
|
||||
forkHeights = append(forkHeights, height)
|
||||
}
|
||||
sort.Slice(forkHeights, func(i, j int) bool {
|
||||
return forkHeights[i] < forkHeights[j]
|
||||
})
|
||||
return forkHeights, forkHeightsMap, forkNameHeightMap
|
||||
}
|
||||
|
||||
// BlocksUntilFork returns the number of blocks until the next fork
|
||||
// returns 0 if there is no fork scheduled for the future
|
||||
func BlocksUntilFork(blockHeight uint64, forkHeights []uint64) uint64 {
|
||||
for _, forkHeight := range forkHeights {
|
||||
if forkHeight > blockHeight {
|
||||
return forkHeight - blockHeight
|
||||
}
|
||||
// GetCodecVersion returns the encoding codec version for the given block height and timestamp.
|
||||
// It determines the appropriate codec version based on the active hardfork.
|
||||
func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uint64) encoding.CodecVersion {
|
||||
if !config.IsBernoulli(new(big.Int).SetUint64(blockHeight)) {
|
||||
return encoding.CodecV0
|
||||
} else if !config.IsCurie(new(big.Int).SetUint64(blockHeight)) {
|
||||
return encoding.CodecV1
|
||||
} else if !config.IsDarwin(blockTimestamp) {
|
||||
return encoding.CodecV2
|
||||
} else {
|
||||
return encoding.CodecV3
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// BlockRange returns the block range of the hard fork
|
||||
// Need ensure the forkHeights is incremental
|
||||
func BlockRange(currentForkHeight uint64, forkHeights []uint64) (from, to uint64) {
|
||||
to = math.MaxInt64
|
||||
for _, height := range forkHeights {
|
||||
if currentForkHeight < height {
|
||||
to = height
|
||||
return
|
||||
}
|
||||
from = height
|
||||
// GetMaxChunksPerBatch returns the maximum number of chunks allowed per batch for the given block height and timestamp.
|
||||
// This value may change depending on the active hardfork.
|
||||
func GetMaxChunksPerBatch(config *params.ChainConfig, blockHeight, blockTimestamp uint64) uint64 {
|
||||
if !config.IsBernoulli(new(big.Int).SetUint64(blockHeight)) {
|
||||
return 15
|
||||
} else if !config.IsCurie(new(big.Int).SetUint64(blockHeight)) {
|
||||
return 15
|
||||
} else if !config.IsDarwin(blockTimestamp) {
|
||||
return 45
|
||||
} else {
|
||||
return 45
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
package forks
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/params"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCollectSortedForkBlocks(t *testing.T) {
|
||||
l, m, n := CollectSortedForkHeights(¶ms.ChainConfig{
|
||||
ArchimedesBlock: big.NewInt(0),
|
||||
ShanghaiBlock: big.NewInt(3),
|
||||
BernoulliBlock: big.NewInt(3),
|
||||
CurieBlock: big.NewInt(4),
|
||||
})
|
||||
require.Equal(t, l, []uint64{
|
||||
0,
|
||||
3,
|
||||
4,
|
||||
})
|
||||
require.Equal(t, map[uint64]bool{
|
||||
3: true,
|
||||
4: true,
|
||||
0: true,
|
||||
}, m)
|
||||
require.Equal(t, map[string]uint64{
|
||||
"archimedes": 0,
|
||||
"bernoulli": 3,
|
||||
"curie": 4,
|
||||
}, n)
|
||||
}
|
||||
|
||||
func TestBlocksUntilFork(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
block uint64
|
||||
forks []uint64
|
||||
expected uint64
|
||||
}{
|
||||
"NoFork": {
|
||||
block: 44,
|
||||
forks: []uint64{},
|
||||
expected: 0,
|
||||
},
|
||||
"BeforeFork": {
|
||||
block: 0,
|
||||
forks: []uint64{1, 5},
|
||||
expected: 1,
|
||||
},
|
||||
"OnFork": {
|
||||
block: 1,
|
||||
forks: []uint64{1, 5},
|
||||
expected: 4,
|
||||
},
|
||||
"OnLastFork": {
|
||||
block: 5,
|
||||
forks: []uint64{1, 5},
|
||||
expected: 0,
|
||||
},
|
||||
"AfterFork": {
|
||||
block: 5,
|
||||
forks: []uint64{1, 5},
|
||||
expected: 0,
|
||||
},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
require.Equal(t, test.expected, BlocksUntilFork(test.block, test.forks))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlockRange(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
forkHeight uint64
|
||||
forkHeights []uint64
|
||||
expectedFrom uint64
|
||||
expectedTo uint64
|
||||
}{
|
||||
{
|
||||
name: "ToInfinite",
|
||||
forkHeight: 300,
|
||||
forkHeights: []uint64{100, 200, 300},
|
||||
expectedFrom: 300,
|
||||
expectedTo: math.MaxInt64,
|
||||
},
|
||||
{
|
||||
name: "To300",
|
||||
forkHeight: 200,
|
||||
forkHeights: []uint64{100, 200, 300},
|
||||
expectedFrom: 200,
|
||||
expectedTo: 300,
|
||||
},
|
||||
{
|
||||
name: "To200",
|
||||
forkHeight: 100,
|
||||
forkHeights: []uint64{100, 200, 300},
|
||||
expectedFrom: 100,
|
||||
expectedTo: 200,
|
||||
},
|
||||
{
|
||||
name: "To100",
|
||||
forkHeight: 0,
|
||||
forkHeights: []uint64{100, 200, 300},
|
||||
expectedFrom: 0,
|
||||
expectedTo: 100,
|
||||
},
|
||||
{
|
||||
name: "To200-1",
|
||||
forkHeight: 100,
|
||||
forkHeights: []uint64{100, 200},
|
||||
expectedFrom: 100,
|
||||
expectedTo: 200,
|
||||
},
|
||||
{
|
||||
name: "To2",
|
||||
forkHeight: 1,
|
||||
forkHeights: []uint64{1, 2},
|
||||
expectedFrom: 1,
|
||||
expectedTo: 2,
|
||||
},
|
||||
{
|
||||
name: "ToInfinite-1",
|
||||
forkHeight: 0,
|
||||
forkHeights: []uint64{0},
|
||||
expectedFrom: 0,
|
||||
expectedTo: math.MaxInt64,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
from, to := BlockRange(test.forkHeight, test.forkHeights)
|
||||
require.Equal(t, test.expectedFrom, from)
|
||||
require.Equal(t, test.expectedTo, to)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ go 1.21
|
||||
|
||||
require (
|
||||
github.com/Masterminds/semver/v3 v3.2.1
|
||||
github.com/bits-and-blooms/bitset v1.12.0
|
||||
github.com/bits-and-blooms/bitset v1.13.0
|
||||
github.com/docker/docker v26.1.0+incompatible
|
||||
github.com/gin-contrib/pprof v1.4.0
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
@@ -13,7 +13,8 @@ require (
|
||||
github.com/modern-go/reflect2 v1.0.2
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/prometheus/client_golang v1.19.0
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240426041101-a860446ebaea
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240730031611-1b736159d5cb
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/testcontainers/testcontainers-go v0.30.0
|
||||
github.com/testcontainers/testcontainers-go/modules/compose v0.30.0
|
||||
@@ -77,7 +78,7 @@ require (
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/edsrzf/mmap-go v1.0.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
|
||||
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 // indirect
|
||||
github.com/ethereum/c-kzg-4844 v1.0.2 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fjl/memsize v0.0.2 // indirect
|
||||
github.com/fsnotify/fsevents v0.1.1 // indirect
|
||||
@@ -119,7 +120,7 @@ require (
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.2.4 // indirect
|
||||
github.com/huin/goupnp v1.3.0 // indirect
|
||||
github.com/iden3/go-iden3-crypto v0.0.15 // indirect
|
||||
github.com/iden3/go-iden3-crypto v0.0.16 // indirect
|
||||
github.com/imdario/mergo v0.3.16 // indirect
|
||||
github.com/in-toto/in-toto-golang v0.5.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
@@ -182,7 +183,7 @@ require (
|
||||
github.com/rjeczalik/notify v0.9.1 // indirect
|
||||
github.com/rs/cors v1.7.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/scroll-tech/zktrie v0.8.2 // indirect
|
||||
github.com/scroll-tech/zktrie v0.8.4 // indirect
|
||||
github.com/secure-systems-lab/go-securesystemslib v0.4.0 // indirect
|
||||
github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002 // indirect
|
||||
github.com/shibumi/go-pathspec v1.3.0 // indirect
|
||||
@@ -194,12 +195,12 @@ require (
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.4.0 // indirect
|
||||
github.com/status-im/keycard-go v0.2.0 // indirect
|
||||
github.com/supranational/blst v0.3.11 // indirect
|
||||
github.com/supranational/blst v0.3.12 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
|
||||
github.com/theupdateframework/notary v0.7.0 // indirect
|
||||
github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.14 // indirect
|
||||
github.com/tklauser/numcpus v0.8.0 // indirect
|
||||
github.com/tonistiigi/fsutil v0.0.0-20230825212630-f09800878302 // indirect
|
||||
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect
|
||||
github.com/tonistiigi/vt100 v0.0.0-20230623042737-f9a4f7ef6531 // indirect
|
||||
@@ -210,7 +211,7 @@ require (
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.45.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
|
||||
@@ -229,17 +230,17 @@ require (
|
||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
||||
go.uber.org/mock v0.4.0 // indirect
|
||||
golang.org/x/arch v0.5.0 // indirect
|
||||
golang.org/x/crypto v0.19.0 // indirect
|
||||
golang.org/x/crypto v0.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect
|
||||
golang.org/x/mod v0.16.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/oauth2 v0.16.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/term v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
golang.org/x/term v0.21.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.17.0 // indirect
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||
|
||||
@@ -70,8 +70,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bitly/go-hostpool v0.1.0/go.mod h1:4gOCgp6+NZnVqlKyZ/iBZFTAJKembaVENUpMkpg42fw=
|
||||
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
|
||||
github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA=
|
||||
github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
|
||||
github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
|
||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||
@@ -212,8 +212,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 h1:B2mpK+MNqgPqk2/KNi1LbqwtZDy5F7iy0mynQiBr8VA=
|
||||
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4/go.mod h1:y4GA2JbAUama1S4QwYjC2hefgGLU8Ul0GMtL/ADMF1c=
|
||||
github.com/ethereum/c-kzg-4844 v1.0.2 h1:8tV84BCEiPeOkiVgW9mpYBeBUir2bkCNVqxPwwVeO+s=
|
||||
github.com/ethereum/c-kzg-4844 v1.0.2/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
|
||||
@@ -384,8 +384,8 @@ github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXei
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
|
||||
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
|
||||
github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4=
|
||||
github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
|
||||
github.com/iden3/go-iden3-crypto v0.0.16 h1:zN867xiz6HgErXVIV/6WyteGcOukE9gybYTorBMEdsk=
|
||||
github.com/iden3/go-iden3-crypto v0.0.16/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
|
||||
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
|
||||
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
|
||||
github.com/in-toto/in-toto-golang v0.5.0 h1:hb8bgwr0M2hGdDsLjkJ3ZqJ8JFLL/tgYdAxF/XEFBbY=
|
||||
@@ -633,10 +633,12 @@ github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240426041101-a860446ebaea h1:CH1WXWrpEpLaP3N+bFs2a1xdE0+lRm1AuJQb5YvE6Ls=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240426041101-a860446ebaea/go.mod h1:i4VBgWoaW/y0D8MmQb7hSOulyw1dKhuiSFAbznwivCA=
|
||||
github.com/scroll-tech/zktrie v0.8.2 h1:UMuIfA+jdgWMLmTgTL64Emo+zzMOdcnH0+eYdDcshxQ=
|
||||
github.com/scroll-tech/zktrie v0.8.2/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240730031611-1b736159d5cb h1:uOKdmDT0LsuS3gfynEjR4zA3Ooh6p2Z3O+IMRj2r8LA=
|
||||
github.com/scroll-tech/da-codec v0.0.0-20240730031611-1b736159d5cb/go.mod h1:D6XEESeNVJkQJlv3eK+FyR+ufPkgVQbJzERylQi53Bs=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6 h1:Q8YyvrcPIcXQwE4ucm4bqmPh6TP6IB1GUTXripf2WyQ=
|
||||
github.com/scroll-tech/go-ethereum v1.10.14-0.20240626125436-418bc6f728b6/go.mod h1:byf/mZ8jLYUCnUePTicjJWn+RvKdxDn7buS6glTnMwQ=
|
||||
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
|
||||
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
|
||||
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
|
||||
github.com/secure-systems-lab/go-securesystemslib v0.4.0/go.mod h1:FGBZgq2tXWICsxWQW1msNf49F0Pf2Op5Htayx335Qbs=
|
||||
github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002 h1:ka9QPuQg2u4LGipiZGsgkg3rJCo4iIUCy75FddM0GRQ=
|
||||
@@ -700,8 +702,8 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
|
||||
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/supranational/blst v0.3.12 h1:Vfas2U2CFHhniv2QkUm2OVa1+pGTdqtpqm9NnhUUbZ8=
|
||||
github.com/supranational/blst v0.3.12/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/testcontainers/testcontainers-go v0.30.0 h1:jmn/XS22q4YRrcMwWg0pAwlClzs/abopbsBzrepyc4E=
|
||||
@@ -714,10 +716,12 @@ github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4D
|
||||
github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw=
|
||||
github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375 h1:QB54BJwA6x8QU9nHY3xJSZR2kX9bgpZekRKGkLTmEXA=
|
||||
github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375/go.mod h1:xRroudyp5iVtxKqZCrA6n2TLFRBf8bmnjr1UD4x+z7g=
|
||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||
github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU=
|
||||
github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY=
|
||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||
github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY=
|
||||
github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tonistiigi/fsutil v0.0.0-20230825212630-f09800878302 h1:ZT8ibgassurSISJ1Pj26NsM3vY2jxFZn63Nd/TpHmRw=
|
||||
github.com/tonistiigi/fsutil v0.0.0-20230825212630-f09800878302/go.mod h1:9kMVqMyQ/Sx2df5LtnGG+nbrmiZzCS7V6gjW3oGHsvI=
|
||||
@@ -754,8 +758,9 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsr
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
|
||||
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
github.com/zmap/zcrypto v0.0.0-20230310154051-c8b263fd8300 h1:DZH5n7L3L8RxKdSyJHZt7WePgwdhHnPhQFdQSJaHF+o=
|
||||
github.com/zmap/zcrypto v0.0.0-20230310154051-c8b263fd8300/go.mod h1:mOd4yUMgn2fe2nV9KXsa9AyQBFZGzygVPovsZR+Rl5w=
|
||||
github.com/zmap/zlint/v3 v3.5.0 h1:Eh2B5t6VKgVH0DFmTwOqE50POvyDhUaU9T2mJOe1vfQ=
|
||||
@@ -815,8 +820,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o=
|
||||
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
|
||||
@@ -826,8 +831,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
|
||||
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -846,8 +851,8 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ=
|
||||
golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o=
|
||||
@@ -859,8 +864,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -901,21 +906,21 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
|
||||
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@@ -930,8 +935,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
|
||||
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
4
common/libzkp/.gitignore
vendored
Normal file
4
common/libzkp/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
outputs
|
||||
libzkp.so
|
||||
test_zkp_test/
|
||||
*log
|
||||
44
common/libzkp/e2e-test.sh
Normal file
44
common/libzkp/e2e-test.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
set -xeu
|
||||
set -o pipefail
|
||||
|
||||
export CHAIN_ID=534352
|
||||
export RUST_BACKTRACE=full
|
||||
export RUST_LOG=debug
|
||||
export RUST_MIN_STACK=100000000
|
||||
export PROVER_OUTPUT_DIR=test_zkp_test
|
||||
#export LD_LIBRARY_PATH=/:/usr/local/cuda/lib64
|
||||
|
||||
mkdir -p $PROVER_OUTPUT_DIR
|
||||
|
||||
REPO=$(realpath ../..)
|
||||
|
||||
function build_test_bins() {
|
||||
cd impl
|
||||
cargo build --release
|
||||
ln -f -s $(realpath target/release/libzkp.so) $REPO/prover/core/lib
|
||||
ln -f -s $(realpath target/release/libzkp.so) $REPO/coordinator/internal/logic/verifier/lib
|
||||
cd $REPO/prover
|
||||
go test -tags="gpu ffi" -timeout 0 -c core/prover_test.go
|
||||
cd $REPO/coordinator
|
||||
go test -tags="gpu ffi" -timeout 0 -c ./internal/logic/verifier
|
||||
cd $REPO/common/libzkp
|
||||
}
|
||||
|
||||
function build_test_bins_old() {
|
||||
cd $REPO
|
||||
cd prover
|
||||
make libzkp
|
||||
go test -tags="gpu ffi" -timeout 0 -c core/prover_test.go
|
||||
cd ..
|
||||
cd coordinator
|
||||
make libzkp
|
||||
go test -tags="gpu ffi" -timeout 0 -c ./internal/logic/verifier
|
||||
cd ..
|
||||
cd common/libzkp
|
||||
}
|
||||
|
||||
build_test_bins
|
||||
#rm -rf test_zkp_test/*
|
||||
#rm -rf prover.log verifier.log
|
||||
#$REPO/prover/core.test -test.v 2>&1 | tee prover.log
|
||||
$REPO/coordinator/verifier.test -test.v 2>&1 | tee verifier.log
|
||||
777
common/libzkp/impl/Cargo.lock
generated
777
common/libzkp/impl/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -13,8 +13,6 @@ halo2curves = { git = "https://github.com/scroll-tech/halo2curves", branch = "v0
|
||||
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
|
||||
ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
|
||||
ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
|
||||
#ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
|
||||
#ethers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
|
||||
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
|
||||
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
|
||||
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
|
||||
@@ -25,7 +23,11 @@ bls12_381 = { git = "https://github.com/scroll-tech/bls12_381", branch = "feat/i
|
||||
[dependencies]
|
||||
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
|
||||
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] }
|
||||
prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.10.3", default-features = false, features = ["parallel_syn", "scroll", "shanghai"] }
|
||||
|
||||
# curie
|
||||
prover_v3 = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.11.4", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] }
|
||||
# darwin
|
||||
prover_v4 = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.12.0", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] }
|
||||
|
||||
base64 = "0.13.0"
|
||||
env_logger = "0.9.0"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
.PHONY: help fmt clippy test test-ci test-all
|
||||
|
||||
build:
|
||||
@cargo build --release
|
||||
|
||||
fmt:
|
||||
@cargo fmt --all -- --check
|
||||
|
||||
|
||||
@@ -1,43 +1,14 @@
|
||||
use crate::{
|
||||
types::{CheckChunkProofsResponse, ProofResult},
|
||||
utils::{
|
||||
c_char_to_str, c_char_to_vec, file_exists, panic_catch, string_to_c_char, vec_to_c_char,
|
||||
OUTPUT_DIR,
|
||||
},
|
||||
};
|
||||
use crate::utils::{c_char_to_str, c_char_to_vec, panic_catch};
|
||||
use libc::c_char;
|
||||
use prover::{
|
||||
aggregator::{Prover, Verifier},
|
||||
consts::AGG_VK_FILENAME,
|
||||
utils::{chunk_trace_to_witness_block, init_env_and_log},
|
||||
BatchProof, BlockTrace, ChunkHash, ChunkProof,
|
||||
use prover_v3::BatchProof as BatchProofLoVersion;
|
||||
use prover_v4::{
|
||||
aggregator::Verifier as VerifierHiVersion, utils::init_env_and_log,
|
||||
BatchProof as BatchProofHiVersion, BundleProof,
|
||||
};
|
||||
use snark_verifier_sdk::verify_evm_calldata;
|
||||
use std::{cell::OnceCell, env, ptr::null};
|
||||
use std::{cell::OnceCell, env};
|
||||
|
||||
static mut PROVER: OnceCell<Prover> = OnceCell::new();
|
||||
static mut VERIFIER: OnceCell<Verifier> = OnceCell::new();
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn init_batch_prover(params_dir: *const c_char, assets_dir: *const c_char) {
|
||||
init_env_and_log("ffi_batch_prove");
|
||||
|
||||
let params_dir = c_char_to_str(params_dir);
|
||||
let assets_dir = c_char_to_str(assets_dir);
|
||||
|
||||
// TODO: add a settings in scroll-prover.
|
||||
env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir);
|
||||
|
||||
// VK file must exist, it is optional and logged as a warning in prover.
|
||||
if !file_exists(assets_dir, &AGG_VK_FILENAME) {
|
||||
panic!("{} must exist in folder {}", *AGG_VK_FILENAME, assets_dir);
|
||||
}
|
||||
|
||||
let prover = Prover::from_dirs(params_dir, assets_dir);
|
||||
|
||||
PROVER.set(prover).unwrap();
|
||||
}
|
||||
static mut VERIFIER: OnceCell<VerifierHiVersion> = OnceCell::new();
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
@@ -49,102 +20,9 @@ pub unsafe extern "C" fn init_batch_verifier(params_dir: *const c_char, assets_d
|
||||
|
||||
// TODO: add a settings in scroll-prover.
|
||||
env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir);
|
||||
let verifier = Verifier::from_dirs(params_dir, assets_dir);
|
||||
let verifier_hi = VerifierHiVersion::from_dirs(params_dir, assets_dir);
|
||||
|
||||
VERIFIER.set(verifier).unwrap();
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn get_batch_vk() -> *const c_char {
|
||||
let vk_result = panic_catch(|| PROVER.get_mut().unwrap().get_vk());
|
||||
|
||||
vk_result
|
||||
.ok()
|
||||
.flatten()
|
||||
.map_or(null(), |vk| string_to_c_char(base64::encode(vk)))
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn check_chunk_proofs(chunk_proofs: *const c_char) -> *const c_char {
|
||||
let check_result: Result<bool, String> = panic_catch(|| {
|
||||
let chunk_proofs = c_char_to_vec(chunk_proofs);
|
||||
let chunk_proofs = serde_json::from_slice::<Vec<ChunkProof>>(&chunk_proofs)
|
||||
.map_err(|e| format!("failed to deserialize chunk proofs: {e:?}"))?;
|
||||
|
||||
if chunk_proofs.is_empty() {
|
||||
return Err("provided chunk proofs are empty.".to_string());
|
||||
}
|
||||
|
||||
let prover_ref = PROVER.get().expect("failed to get reference to PROVER.");
|
||||
|
||||
let valid = prover_ref.check_chunk_proofs(&chunk_proofs);
|
||||
Ok(valid)
|
||||
})
|
||||
.unwrap_or_else(|e| Err(format!("unwind error: {e:?}")));
|
||||
|
||||
let r = match check_result {
|
||||
Ok(valid) => CheckChunkProofsResponse {
|
||||
ok: valid,
|
||||
error: None,
|
||||
},
|
||||
Err(err) => CheckChunkProofsResponse {
|
||||
ok: false,
|
||||
error: Some(err),
|
||||
},
|
||||
};
|
||||
|
||||
serde_json::to_vec(&r).map_or(null(), vec_to_c_char)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn gen_batch_proof(
|
||||
chunk_hashes: *const c_char,
|
||||
chunk_proofs: *const c_char,
|
||||
) -> *const c_char {
|
||||
let proof_result: Result<Vec<u8>, String> = panic_catch(|| {
|
||||
let chunk_hashes = c_char_to_vec(chunk_hashes);
|
||||
let chunk_proofs = c_char_to_vec(chunk_proofs);
|
||||
|
||||
let chunk_hashes = serde_json::from_slice::<Vec<ChunkHash>>(&chunk_hashes)
|
||||
.map_err(|e| format!("failed to deserialize chunk hashes: {e:?}"))?;
|
||||
let chunk_proofs = serde_json::from_slice::<Vec<ChunkProof>>(&chunk_proofs)
|
||||
.map_err(|e| format!("failed to deserialize chunk proofs: {e:?}"))?;
|
||||
|
||||
if chunk_hashes.len() != chunk_proofs.len() {
|
||||
return Err(format!("chunk hashes and chunk proofs lengths mismatch: chunk_hashes.len() = {}, chunk_proofs.len() = {}",
|
||||
chunk_hashes.len(), chunk_proofs.len()));
|
||||
}
|
||||
|
||||
let chunk_hashes_proofs = chunk_hashes
|
||||
.into_iter()
|
||||
.zip(chunk_proofs)
|
||||
.collect();
|
||||
|
||||
let proof = PROVER
|
||||
.get_mut()
|
||||
.expect("failed to get mutable reference to PROVER.")
|
||||
.gen_agg_evm_proof(chunk_hashes_proofs, None, OUTPUT_DIR.as_deref())
|
||||
.map_err(|e| format!("failed to generate proof: {e:?}"))?;
|
||||
|
||||
serde_json::to_vec(&proof).map_err(|e| format!("failed to serialize the proof: {e:?}"))
|
||||
})
|
||||
.unwrap_or_else(|e| Err(format!("unwind error: {e:?}")));
|
||||
|
||||
let r = match proof_result {
|
||||
Ok(proof_bytes) => ProofResult {
|
||||
message: Some(proof_bytes),
|
||||
error: None,
|
||||
},
|
||||
Err(err) => ProofResult {
|
||||
message: None,
|
||||
error: Some(err),
|
||||
},
|
||||
};
|
||||
|
||||
serde_json::to_vec(&r).map_or(null(), vec_to_c_char)
|
||||
VERIFIER.set(verifier_hi).unwrap();
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
@@ -154,41 +32,38 @@ pub unsafe extern "C" fn verify_batch_proof(
|
||||
fork_name: *const c_char,
|
||||
) -> c_char {
|
||||
let proof = c_char_to_vec(proof);
|
||||
let proof = serde_json::from_slice::<BatchProof>(proof.as_slice()).unwrap();
|
||||
let fork_name_str = c_char_to_str(fork_name);
|
||||
let fork_id = match fork_name_str {
|
||||
"" => 0,
|
||||
"shanghai" => 0,
|
||||
"bernoulli" => 1,
|
||||
"curie" => 3,
|
||||
"darwin" => 4,
|
||||
_ => {
|
||||
log::warn!("unexpected fork_name {fork_name_str}, treated as bernoulli");
|
||||
1
|
||||
log::warn!("unexpected fork_name {fork_name_str}, treated as darwin");
|
||||
4
|
||||
}
|
||||
};
|
||||
let verified = panic_catch(|| {
|
||||
if fork_id == 0 {
|
||||
// before upgrade#2(EIP4844)
|
||||
if fork_id == 3 {
|
||||
// As of upgrade #3 (Curie), we verify batch proofs on-chain (EVM).
|
||||
let proof = serde_json::from_slice::<BatchProofLoVersion>(proof.as_slice()).unwrap();
|
||||
verify_evm_calldata(
|
||||
include_bytes!("evm_verifier_fork_1.bin").to_vec(),
|
||||
include_bytes!("plonk_verifier_0.11.4.bin").to_vec(),
|
||||
proof.calldata(),
|
||||
)
|
||||
} else {
|
||||
VERIFIER.get().unwrap().verify_agg_evm_proof(proof)
|
||||
// Post upgrade #4 (Darwin), batch proofs are not EVM-verifiable. Instead they are
|
||||
// halo2 proofs meant to be bundled recursively.
|
||||
let proof = serde_json::from_slice::<BatchProofHiVersion>(proof.as_slice()).unwrap();
|
||||
VERIFIER.get().unwrap().verify_batch_proof(&proof)
|
||||
}
|
||||
});
|
||||
verified.unwrap_or(false) as c_char
|
||||
}
|
||||
|
||||
// This function is only used for debugging on Go side.
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn block_traces_to_chunk_info(block_traces: *const c_char) -> *const c_char {
|
||||
let block_traces = c_char_to_vec(block_traces);
|
||||
let block_traces = serde_json::from_slice::<Vec<BlockTrace>>(&block_traces).unwrap();
|
||||
|
||||
let witness_block = chunk_trace_to_witness_block(block_traces).unwrap();
|
||||
let chunk_info = ChunkHash::from_witness_block(&witness_block, false);
|
||||
|
||||
let chunk_info_bytes = serde_json::to_vec(&chunk_info).unwrap();
|
||||
vec_to_c_char(chunk_info_bytes)
|
||||
pub unsafe extern "C" fn verify_bundle_proof(proof: *const c_char) -> c_char {
|
||||
let proof = c_char_to_vec(proof);
|
||||
let proof = serde_json::from_slice::<BundleProof>(proof.as_slice()).unwrap();
|
||||
let verified = panic_catch(|| VERIFIER.get().unwrap().verify_bundle_proof(proof));
|
||||
verified.unwrap_or(false) as c_char
|
||||
}
|
||||
|
||||
@@ -1,107 +1,63 @@
|
||||
use crate::{
|
||||
types::ProofResult,
|
||||
utils::{
|
||||
c_char_to_str, c_char_to_vec, file_exists, panic_catch, string_to_c_char, vec_to_c_char,
|
||||
OUTPUT_DIR,
|
||||
},
|
||||
};
|
||||
use crate::utils::{c_char_to_str, c_char_to_vec, panic_catch};
|
||||
use libc::c_char;
|
||||
use prover::{
|
||||
consts::CHUNK_VK_FILENAME,
|
||||
utils::init_env_and_log,
|
||||
zkevm::{Prover, Verifier},
|
||||
BlockTrace, ChunkProof,
|
||||
use prover_v3::{zkevm::Verifier as VerifierLoVersion, ChunkProof as ChunkProofLoVersion};
|
||||
use prover_v4::{
|
||||
utils::init_env_and_log, zkevm::Verifier as VerifierHiVersion,
|
||||
ChunkProof as ChunkProofHiVersion,
|
||||
};
|
||||
use std::{cell::OnceCell, env, ptr::null};
|
||||
use std::{cell::OnceCell, env};
|
||||
|
||||
static mut PROVER: OnceCell<Prover> = OnceCell::new();
|
||||
static mut VERIFIER: OnceCell<Verifier> = OnceCell::new();
|
||||
static mut VERIFIER_LO_VERSION: OnceCell<VerifierLoVersion> = OnceCell::new();
|
||||
static mut VERIFIER_HI_VERSION: OnceCell<VerifierHiVersion> = OnceCell::new();
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn init_chunk_prover(params_dir: *const c_char, assets_dir: *const c_char) {
|
||||
init_env_and_log("ffi_chunk_prove");
|
||||
|
||||
let params_dir = c_char_to_str(params_dir);
|
||||
let assets_dir = c_char_to_str(assets_dir);
|
||||
|
||||
// TODO: add a settings in scroll-prover.
|
||||
env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir);
|
||||
|
||||
// VK file must exist, it is optional and logged as a warning in prover.
|
||||
if !file_exists(assets_dir, &CHUNK_VK_FILENAME) {
|
||||
panic!("{} must exist in folder {}", *CHUNK_VK_FILENAME, assets_dir);
|
||||
}
|
||||
|
||||
let prover = Prover::from_dirs(params_dir, assets_dir);
|
||||
|
||||
PROVER.set(prover).unwrap();
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn init_chunk_verifier(params_dir: *const c_char, assets_dir: *const c_char) {
|
||||
pub unsafe extern "C" fn init_chunk_verifier(
|
||||
params_dir: *const c_char,
|
||||
v3_assets_dir: *const c_char,
|
||||
v4_assets_dir: *const c_char,
|
||||
) {
|
||||
init_env_and_log("ffi_chunk_verify");
|
||||
|
||||
let params_dir = c_char_to_str(params_dir);
|
||||
let assets_dir = c_char_to_str(assets_dir);
|
||||
let v3_assets_dir = c_char_to_str(v3_assets_dir);
|
||||
let v4_assets_dir = c_char_to_str(v4_assets_dir);
|
||||
|
||||
// TODO: add a settings in scroll-prover.
|
||||
env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir);
|
||||
let verifier = Verifier::from_dirs(params_dir, assets_dir);
|
||||
env::set_var("SCROLL_PROVER_ASSETS_DIR", v3_assets_dir);
|
||||
let verifier_lo = VerifierLoVersion::from_dirs(params_dir, v3_assets_dir);
|
||||
env::set_var("SCROLL_PROVER_ASSETS_DIR", v4_assets_dir);
|
||||
let verifier_hi = VerifierHiVersion::from_dirs(params_dir, v4_assets_dir);
|
||||
|
||||
VERIFIER.set(verifier).unwrap();
|
||||
VERIFIER_LO_VERSION.set(verifier_lo).unwrap();
|
||||
VERIFIER_HI_VERSION.set(verifier_hi).unwrap();
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn get_chunk_vk() -> *const c_char {
|
||||
let vk_result = panic_catch(|| PROVER.get_mut().unwrap().get_vk());
|
||||
|
||||
vk_result
|
||||
.ok()
|
||||
.flatten()
|
||||
.map_or(null(), |vk| string_to_c_char(base64::encode(vk)))
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn gen_chunk_proof(block_traces: *const c_char) -> *const c_char {
|
||||
let proof_result: Result<Vec<u8>, String> = panic_catch(|| {
|
||||
let block_traces = c_char_to_vec(block_traces);
|
||||
let block_traces = serde_json::from_slice::<Vec<BlockTrace>>(&block_traces)
|
||||
.map_err(|e| format!("failed to deserialize block traces: {e:?}"))?;
|
||||
|
||||
let proof = PROVER
|
||||
.get_mut()
|
||||
.expect("failed to get mutable reference to PROVER.")
|
||||
.gen_chunk_proof(block_traces, None, None, OUTPUT_DIR.as_deref())
|
||||
.map_err(|e| format!("failed to generate proof: {e:?}"))?;
|
||||
|
||||
serde_json::to_vec(&proof).map_err(|e| format!("failed to serialize the proof: {e:?}"))
|
||||
})
|
||||
.unwrap_or_else(|e| Err(format!("unwind error: {e:?}")));
|
||||
|
||||
let r = match proof_result {
|
||||
Ok(proof_bytes) => ProofResult {
|
||||
message: Some(proof_bytes),
|
||||
error: None,
|
||||
},
|
||||
Err(err) => ProofResult {
|
||||
message: None,
|
||||
error: Some(err),
|
||||
},
|
||||
};
|
||||
|
||||
serde_json::to_vec(&r).map_or(null(), vec_to_c_char)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn verify_chunk_proof(proof: *const c_char) -> c_char {
|
||||
pub unsafe extern "C" fn verify_chunk_proof(
|
||||
proof: *const c_char,
|
||||
fork_name: *const c_char,
|
||||
) -> c_char {
|
||||
let proof = c_char_to_vec(proof);
|
||||
let proof = serde_json::from_slice::<ChunkProof>(proof.as_slice()).unwrap();
|
||||
|
||||
let verified = panic_catch(|| VERIFIER.get().unwrap().verify_chunk_proof(proof));
|
||||
let fork_name_str = c_char_to_str(fork_name);
|
||||
let fork_id = match fork_name_str {
|
||||
"curie" => 3,
|
||||
"darwin" => 4,
|
||||
_ => {
|
||||
log::warn!("unexpected fork_name {fork_name_str}, treated as darwin");
|
||||
4
|
||||
}
|
||||
};
|
||||
let verified = panic_catch(|| {
|
||||
if fork_id == 3 {
|
||||
let proof = serde_json::from_slice::<ChunkProofLoVersion>(proof.as_slice()).unwrap();
|
||||
VERIFIER_LO_VERSION.get().unwrap().verify_chunk_proof(proof)
|
||||
} else {
|
||||
let proof = serde_json::from_slice::<ChunkProofHiVersion>(proof.as_slice()).unwrap();
|
||||
VERIFIER_HI_VERSION.get().unwrap().verify_chunk_proof(proof)
|
||||
}
|
||||
});
|
||||
verified.unwrap_or(false) as c_char
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
common/libzkp/impl/src/plonk_verifier_0.11.4.bin
Normal file
BIN
common/libzkp/impl/src/plonk_verifier_0.11.4.bin
Normal file
Binary file not shown.
@@ -1,29 +1,9 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use std::{
|
||||
env,
|
||||
ffi::{CStr, CString},
|
||||
ffi::CStr,
|
||||
os::raw::c_char,
|
||||
panic::{catch_unwind, AssertUnwindSafe},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
// Only used for debugging.
|
||||
pub(crate) static OUTPUT_DIR: Lazy<Option<String>> =
|
||||
Lazy::new(|| env::var("PROVER_OUTPUT_DIR").ok());
|
||||
|
||||
/// # Safety
|
||||
#[no_mangle]
|
||||
pub extern "C" fn free_c_chars(ptr: *mut c_char) {
|
||||
if ptr.is_null() {
|
||||
log::warn!("Try to free an empty pointer!");
|
||||
return;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let _ = CString::from_raw(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn c_char_to_str(c: *const c_char) -> &'static str {
|
||||
let cstr = unsafe { CStr::from_ptr(c) };
|
||||
cstr.to_str().unwrap()
|
||||
@@ -34,21 +14,6 @@ pub(crate) fn c_char_to_vec(c: *const c_char) -> Vec<u8> {
|
||||
cstr.to_bytes().to_vec()
|
||||
}
|
||||
|
||||
pub(crate) fn string_to_c_char(string: String) -> *const c_char {
|
||||
CString::new(string).unwrap().into_raw()
|
||||
}
|
||||
|
||||
pub(crate) fn vec_to_c_char(bytes: Vec<u8>) -> *const c_char {
|
||||
CString::new(bytes).unwrap().into_raw()
|
||||
}
|
||||
|
||||
pub(crate) fn file_exists(dir: &str, filename: &str) -> bool {
|
||||
let mut path = PathBuf::from(dir);
|
||||
path.push(filename);
|
||||
|
||||
path.exists()
|
||||
}
|
||||
|
||||
pub(crate) fn panic_catch<F: FnOnce() -> R, R>(f: F) -> Result<R, String> {
|
||||
catch_unwind(AssertUnwindSafe(f)).map_err(|err| {
|
||||
if let Some(s) = err.downcast_ref::<String>() {
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
void init_batch_prover(char* params_dir, char* assets_dir);
|
||||
// BatchVerifier is used to:
|
||||
// - Verify a batch proof
|
||||
// - Verify a bundle proof
|
||||
void init_batch_verifier(char* params_dir, char* assets_dir);
|
||||
char* get_batch_vk();
|
||||
char* check_chunk_proofs(char* chunk_proofs);
|
||||
char* gen_batch_proof(char* chunk_hashes, char* chunk_proofs);
|
||||
|
||||
char verify_batch_proof(char* proof, char* fork_name);
|
||||
|
||||
void init_chunk_prover(char* params_dir, char* assets_dir);
|
||||
void init_chunk_verifier(char* params_dir, char* assets_dir);
|
||||
char* get_chunk_vk();
|
||||
char* gen_chunk_proof(char* block_traces);
|
||||
char verify_chunk_proof(char* proof);
|
||||
char verify_bundle_proof(char* proof);
|
||||
|
||||
char* block_traces_to_chunk_info(char* block_traces);
|
||||
void free_c_chars(char* ptr);
|
||||
void init_chunk_verifier(char* params_dir, char* v3_assets_dir, char* v4_assets_dir);
|
||||
char verify_chunk_proof(char* proof, char* fork_name);
|
||||
|
||||
@@ -2,6 +2,7 @@ package testcontainers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
@@ -114,7 +115,7 @@ func (t *TestcontainerApps) StartPoSL1Container() error {
|
||||
// GetPoSL1EndPoint returns the endpoint of the running PoS L1 endpoint
|
||||
func (t *TestcontainerApps) GetPoSL1EndPoint() (string, error) {
|
||||
if t.poSL1Container == nil {
|
||||
return "", fmt.Errorf("PoS L1 container is not running")
|
||||
return "", errors.New("PoS L1 container is not running")
|
||||
}
|
||||
contrainer, err := t.poSL1Container.ServiceContainer(context.Background(), "geth")
|
||||
if err != nil {
|
||||
@@ -135,7 +136,7 @@ func (t *TestcontainerApps) GetPoSL1Client() (*ethclient.Client, error) {
|
||||
// GetDBEndPoint returns the endpoint of the running postgres container
|
||||
func (t *TestcontainerApps) GetDBEndPoint() (string, error) {
|
||||
if t.postgresContainer == nil || !t.postgresContainer.IsRunning() {
|
||||
return "", fmt.Errorf("postgres is not running")
|
||||
return "", errors.New("postgres is not running")
|
||||
}
|
||||
return t.postgresContainer.ConnectionString(context.Background(), "sslmode=disable")
|
||||
}
|
||||
@@ -143,7 +144,7 @@ func (t *TestcontainerApps) GetDBEndPoint() (string, error) {
|
||||
// GetL2GethEndPoint returns the endpoint of the running L2Geth container
|
||||
func (t *TestcontainerApps) GetL2GethEndPoint() (string, error) {
|
||||
if t.l2GethContainer == nil || !t.l2GethContainer.IsRunning() {
|
||||
return "", fmt.Errorf("l2 geth is not running")
|
||||
return "", errors.New("l2 geth is not running")
|
||||
}
|
||||
endpoint, err := t.l2GethContainer.PortEndpoint(context.Background(), "8546/tcp", "ws")
|
||||
if err != nil {
|
||||
@@ -217,7 +218,7 @@ func findProjectRootDir() (string, error) {
|
||||
|
||||
parentDir := filepath.Dir(currentDir)
|
||||
if parentDir == currentDir {
|
||||
return "", fmt.Errorf("go.work file not found in any parent directory")
|
||||
return "", errors.New("go.work file not found in any parent directory")
|
||||
}
|
||||
|
||||
currentDir = parentDir
|
||||
|
||||
@@ -109,6 +109,10 @@ const (
|
||||
ProverTaskFailureTypeVerifiedFailed
|
||||
// ProverTaskFailureTypeServerError collect occur error
|
||||
ProverTaskFailureTypeServerError
|
||||
// ProverTaskFailureTypeObjectAlreadyVerified object(batch/chunk) already verified, may exists in test env when ENABLE_TEST_ENV_BYPASS_FEATURES is true
|
||||
ProverTaskFailureTypeObjectAlreadyVerified
|
||||
// ProverTaskFailureTypeReassignedByAdmin reassigned by admin, this value is used in admin-system and defined here for clarity
|
||||
ProverTaskFailureTypeReassignedByAdmin
|
||||
)
|
||||
|
||||
func (r ProverTaskFailureType) String() string {
|
||||
@@ -123,6 +127,10 @@ func (r ProverTaskFailureType) String() string {
|
||||
return "prover task failure verified failed"
|
||||
case ProverTaskFailureTypeServerError:
|
||||
return "prover task failure server exception"
|
||||
case ProverTaskFailureTypeObjectAlreadyVerified:
|
||||
return "prover task failure object already verified"
|
||||
case ProverTaskFailureTypeReassignedByAdmin:
|
||||
return "prover task failure reassigned by admin"
|
||||
default:
|
||||
return fmt.Sprintf("illegal prover task failure type (%d)", int32(r))
|
||||
}
|
||||
@@ -188,6 +196,31 @@ func (s ChunkProofsStatus) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// BatchProofsStatus describes the proving status of batches that belong to a bundle.
|
||||
type BatchProofsStatus int
|
||||
|
||||
const (
|
||||
// BatchProofsStatusUndefined represents an undefined batch proofs status
|
||||
BatchProofsStatusUndefined BatchProofsStatus = iota
|
||||
|
||||
// BatchProofsStatusPending means that some batches that belong to this bundle have not been proven
|
||||
BatchProofsStatusPending
|
||||
|
||||
// BatchProofsStatusReady means that all batches that belong to this bundle have been proven
|
||||
BatchProofsStatusReady
|
||||
)
|
||||
|
||||
func (s BatchProofsStatus) String() string {
|
||||
switch s {
|
||||
case BatchProofsStatusPending:
|
||||
return "BatchProofsStatusPending"
|
||||
case BatchProofsStatusReady:
|
||||
return "BatchProofsStatusReady"
|
||||
default:
|
||||
return fmt.Sprintf("Undefined BatchProofsStatus (%d)", int32(s))
|
||||
}
|
||||
}
|
||||
|
||||
// RollupStatus block_batch rollup_status (pending, committing, committed, commit_failed, finalizing, finalized, finalize_skipped, finalize_failed)
|
||||
type RollupStatus int
|
||||
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
package message
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||
"github.com/scroll-tech/go-ethereum/crypto"
|
||||
"github.com/scroll-tech/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
// AuthMsg is the first message exchanged from the Prover to the Sequencer.
|
||||
// It effectively acts as a registration, and makes the Prover identification
|
||||
// known to the Sequencer.
|
||||
type AuthMsg struct {
|
||||
// Message fields
|
||||
Identity *Identity `json:"message"`
|
||||
// Prover signature
|
||||
Signature string `json:"signature"`
|
||||
}
|
||||
|
||||
// Identity contains all the fields to be signed by the prover.
|
||||
type Identity struct {
|
||||
// ProverName the prover name
|
||||
ProverName string `json:"prover_name"`
|
||||
// ProverVersion the prover version
|
||||
ProverVersion string `json:"prover_version"`
|
||||
// Challenge unique challenge generated by manager
|
||||
Challenge string `json:"challenge"`
|
||||
// HardForkName the hard fork name
|
||||
HardForkName string `json:"hard_fork_name"`
|
||||
}
|
||||
|
||||
// SignWithKey auth message with private key and set public key in auth message's Identity
|
||||
func (a *AuthMsg) SignWithKey(priv *ecdsa.PrivateKey) error {
|
||||
// Hash identity content
|
||||
hash, err := a.Identity.Hash()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Sign register message
|
||||
sig, err := crypto.Sign(hash, priv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Signature = hexutil.Encode(sig)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify verifies the message of auth.
|
||||
func (a *AuthMsg) Verify() (bool, error) {
|
||||
hash, err := a.Identity.Hash()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
sig := common.FromHex(a.Signature)
|
||||
|
||||
pk, err := crypto.SigToPub(hash, sig)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return crypto.VerifySignature(crypto.CompressPubkey(pk), hash, sig[:len(sig)-1]), nil
|
||||
}
|
||||
|
||||
// PublicKey return public key from signature
|
||||
func (a *AuthMsg) PublicKey() (string, error) {
|
||||
hash, err := a.Identity.Hash()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sig := common.FromHex(a.Signature)
|
||||
// recover public key
|
||||
pk, err := crypto.SigToPub(hash, sig)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return common.Bytes2Hex(crypto.CompressPubkey(pk)), nil
|
||||
}
|
||||
|
||||
// Hash returns the hash of the auth message, which should be the message used
|
||||
// to construct the Signature.
|
||||
func (i *Identity) Hash() ([]byte, error) {
|
||||
byt, err := rlp.EncodeToBytes(i)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hash := crypto.Keccak256Hash(byt)
|
||||
return hash[:], nil
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package message
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||
"github.com/scroll-tech/go-ethereum/crypto"
|
||||
"github.com/scroll-tech/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
// LegacyAuthMsg is the old auth message exchanged from the Prover to the Sequencer.
|
||||
// It effectively acts as a registration, and makes the Prover identification
|
||||
// known to the Sequencer.
|
||||
type LegacyAuthMsg struct {
|
||||
// Message fields
|
||||
Identity *LegacyIdentity `json:"message"`
|
||||
// Prover signature
|
||||
Signature string `json:"signature"`
|
||||
}
|
||||
|
||||
// LegacyIdentity contains all the fields to be signed by the prover.
|
||||
type LegacyIdentity struct {
|
||||
// ProverName the prover name
|
||||
ProverName string `json:"prover_name"`
|
||||
// ProverVersion the prover version
|
||||
ProverVersion string `json:"prover_version"`
|
||||
// Challenge unique challenge generated by manager
|
||||
Challenge string `json:"challenge"`
|
||||
}
|
||||
|
||||
// SignWithKey auth message with private key and set public key in auth message's Identity
|
||||
func (a *LegacyAuthMsg) SignWithKey(priv *ecdsa.PrivateKey) error {
|
||||
// Hash identity content
|
||||
hash, err := a.Identity.Hash()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Sign register message
|
||||
sig, err := crypto.Sign(hash, priv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Signature = hexutil.Encode(sig)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify verifies the message of auth.
|
||||
func (a *LegacyAuthMsg) Verify() (bool, error) {
|
||||
hash, err := a.Identity.Hash()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
sig := common.FromHex(a.Signature)
|
||||
|
||||
pk, err := crypto.SigToPub(hash, sig)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return crypto.VerifySignature(crypto.CompressPubkey(pk), hash, sig[:len(sig)-1]), nil
|
||||
}
|
||||
|
||||
// PublicKey return public key from signature
|
||||
func (a *LegacyAuthMsg) PublicKey() (string, error) {
|
||||
hash, err := a.Identity.Hash()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sig := common.FromHex(a.Signature)
|
||||
// recover public key
|
||||
pk, err := crypto.SigToPub(hash, sig)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return common.Bytes2Hex(crypto.CompressPubkey(pk)), nil
|
||||
}
|
||||
|
||||
// Hash returns the hash of the auth message, which should be the message used
|
||||
// to construct the Signature.
|
||||
func (i *LegacyIdentity) Hash() ([]byte, error) {
|
||||
byt, err := rlp.EncodeToBytes(i)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hash := crypto.Keccak256Hash(byt)
|
||||
return hash[:], nil
|
||||
}
|
||||
@@ -1,28 +1,11 @@
|
||||
package message
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/scroll-tech/da-codec/encoding/codecv3"
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||
"github.com/scroll-tech/go-ethereum/crypto"
|
||||
"github.com/scroll-tech/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
// ProofFailureType the proof failure type
|
||||
type ProofFailureType int
|
||||
|
||||
const (
|
||||
// ProofFailureUndefined the undefined type proof failure type
|
||||
ProofFailureUndefined ProofFailureType = iota
|
||||
// ProofFailurePanic proof failure for prover panic
|
||||
ProofFailurePanic
|
||||
// ProofFailureNoPanic proof failure for no prover panic
|
||||
ProofFailureNoPanic
|
||||
)
|
||||
|
||||
// RespStatus represents status code from prover to scroll
|
||||
@@ -35,7 +18,7 @@ const (
|
||||
StatusProofError
|
||||
)
|
||||
|
||||
// ProofType represents the type of prover.
|
||||
// ProofType represents the type of task.
|
||||
type ProofType uint8
|
||||
|
||||
func (r ProofType) String() string {
|
||||
@@ -44,6 +27,8 @@ func (r ProofType) String() string {
|
||||
return "proof type chunk"
|
||||
case ProofTypeBatch:
|
||||
return "proof type batch"
|
||||
case ProofTypeBundle:
|
||||
return "proof type bundle"
|
||||
default:
|
||||
return fmt.Sprintf("illegal proof type: %d", r)
|
||||
}
|
||||
@@ -52,93 +37,14 @@ func (r ProofType) String() string {
|
||||
const (
|
||||
// ProofTypeUndefined is an unknown proof type
|
||||
ProofTypeUndefined ProofType = iota
|
||||
// ProofTypeChunk is default prover, it only generates zk proof from traces.
|
||||
// ProofTypeChunk generates a proof for a ZkEvm chunk, where the inputs are the execution traces for blocks contained in the chunk. ProofTypeChunk is the default proof type.
|
||||
ProofTypeChunk
|
||||
// ProofTypeBatch generates zk proof from other zk proofs and aggregate them into one proof.
|
||||
// ProofTypeBatch generates zk proof from chunk proofs
|
||||
ProofTypeBatch
|
||||
// ProofTypeBundle generates zk proof from batch proofs
|
||||
ProofTypeBundle
|
||||
)
|
||||
|
||||
// GenerateToken generates token
|
||||
func GenerateToken() (string, error) {
|
||||
b := make([]byte, 16)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hex.EncodeToString(b), nil
|
||||
}
|
||||
|
||||
// ProofMsg is the data structure sent to the coordinator.
|
||||
type ProofMsg struct {
|
||||
*ProofDetail `json:"zkProof"`
|
||||
// Prover signature
|
||||
Signature string `json:"signature"`
|
||||
|
||||
// Prover public key
|
||||
publicKey string
|
||||
}
|
||||
|
||||
// Sign signs the ProofMsg.
|
||||
func (a *ProofMsg) Sign(priv *ecdsa.PrivateKey) error {
|
||||
hash, err := a.ProofDetail.Hash()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sig, err := crypto.Sign(hash, priv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Signature = hexutil.Encode(sig)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify verifies ProofMsg.Signature.
|
||||
func (a *ProofMsg) Verify() (bool, error) {
|
||||
hash, err := a.ProofDetail.Hash()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
sig := common.FromHex(a.Signature)
|
||||
// recover public key
|
||||
if a.publicKey == "" {
|
||||
pk, err := crypto.SigToPub(hash, sig)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
a.publicKey = common.Bytes2Hex(crypto.CompressPubkey(pk))
|
||||
}
|
||||
|
||||
return crypto.VerifySignature(common.FromHex(a.publicKey), hash, sig[:len(sig)-1]), nil
|
||||
}
|
||||
|
||||
// PublicKey return public key from signature
|
||||
func (a *ProofMsg) PublicKey() (string, error) {
|
||||
if a.publicKey == "" {
|
||||
hash, err := a.ProofDetail.Hash()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sig := common.FromHex(a.Signature)
|
||||
// recover public key
|
||||
pk, err := crypto.SigToPub(hash, sig)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
a.publicKey = common.Bytes2Hex(crypto.CompressPubkey(pk))
|
||||
return a.publicKey, nil
|
||||
}
|
||||
|
||||
return a.publicKey, nil
|
||||
}
|
||||
|
||||
// TaskMsg is a wrapper type around db ProveTask type.
|
||||
type TaskMsg struct {
|
||||
UUID string `json:"uuid"`
|
||||
ID string `json:"id"`
|
||||
Type ProofType `json:"type,omitempty"`
|
||||
BatchTaskDetail *BatchTaskDetail `json:"batch_task_detail,omitempty"`
|
||||
ChunkTaskDetail *ChunkTaskDetail `json:"chunk_task_detail,omitempty"`
|
||||
}
|
||||
|
||||
// ChunkTaskDetail is a type containing ChunkTask detail.
|
||||
type ChunkTaskDetail struct {
|
||||
BlockHashes []common.Hash `json:"block_hashes"`
|
||||
@@ -146,30 +52,14 @@ type ChunkTaskDetail struct {
|
||||
|
||||
// BatchTaskDetail is a type containing BatchTask detail.
|
||||
type BatchTaskDetail struct {
|
||||
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
|
||||
ChunkProofs []*ChunkProof `json:"chunk_proofs"`
|
||||
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
|
||||
ChunkProofs []*ChunkProof `json:"chunk_proofs"`
|
||||
BatchHeader *codecv3.DABatch `json:"batch_header"`
|
||||
}
|
||||
|
||||
// ProofDetail is the message received from provers that contains zk proof, the status of
|
||||
// the proof generation succeeded, and an error message if proof generation failed.
|
||||
type ProofDetail struct {
|
||||
ID string `json:"id"`
|
||||
Type ProofType `json:"type,omitempty"`
|
||||
Status RespStatus `json:"status"`
|
||||
ChunkProof *ChunkProof `json:"chunk_proof,omitempty"`
|
||||
BatchProof *BatchProof `json:"batch_proof,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Hash return proofMsg content hash.
|
||||
func (z *ProofDetail) Hash() ([]byte, error) {
|
||||
byt, err := rlp.EncodeToBytes(z)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hash := crypto.Keccak256Hash(byt)
|
||||
return hash[:], nil
|
||||
// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.
|
||||
type BundleTaskDetail struct {
|
||||
BatchProofs []*BatchProof `json:"batch_proofs"`
|
||||
}
|
||||
|
||||
// ChunkInfo is for calculating pi_hash for chunk
|
||||
@@ -183,6 +73,12 @@ type ChunkInfo struct {
|
||||
TxBytes []byte `json:"tx_bytes"`
|
||||
}
|
||||
|
||||
// SubCircuitRowUsage tracing info added in v0.11.0rc8
|
||||
type SubCircuitRowUsage struct {
|
||||
Name string `json:"name"`
|
||||
RowNumber uint64 `json:"row_number"`
|
||||
}
|
||||
|
||||
// ChunkProof includes the proof info that are required for chunk verification and rollup.
|
||||
type ChunkProof struct {
|
||||
StorageTrace []byte `json:"storage_trace,omitempty"`
|
||||
@@ -191,21 +87,23 @@ type ChunkProof struct {
|
||||
Instances []byte `json:"instances"`
|
||||
Vk []byte `json:"vk"`
|
||||
// cross-reference between cooridinator computation and prover compution
|
||||
ChunkInfo *ChunkInfo `json:"chunk_info,omitempty"`
|
||||
GitVersion string `json:"git_version,omitempty"`
|
||||
ChunkInfo *ChunkInfo `json:"chunk_info,omitempty"`
|
||||
GitVersion string `json:"git_version,omitempty"`
|
||||
RowUsages []SubCircuitRowUsage `json:"row_usages,omitempty"`
|
||||
}
|
||||
|
||||
// BatchProof includes the proof info that are required for batch verification and rollup.
|
||||
type BatchProof struct {
|
||||
Protocol []byte `json:"protocol"`
|
||||
Proof []byte `json:"proof"`
|
||||
Instances []byte `json:"instances"`
|
||||
Vk []byte `json:"vk"`
|
||||
// cross-reference between cooridinator computation and prover compution
|
||||
GitVersion string `json:"git_version,omitempty"`
|
||||
BatchHash common.Hash `json:"batch_hash"`
|
||||
GitVersion string `json:"git_version,omitempty"`
|
||||
}
|
||||
|
||||
// SanityCheck checks whether an BatchProof is in a legal format
|
||||
// TODO: change to check Proof&Instance when upgrading to snark verifier v0.4
|
||||
// SanityCheck checks whether a BatchProof is in a legal format
|
||||
func (ap *BatchProof) SanityCheck() error {
|
||||
if ap == nil {
|
||||
return errors.New("agg_proof is nil")
|
||||
@@ -214,8 +112,51 @@ func (ap *BatchProof) SanityCheck() error {
|
||||
if len(ap.Proof) == 0 {
|
||||
return errors.New("proof not ready")
|
||||
}
|
||||
|
||||
if len(ap.Proof)%32 != 0 {
|
||||
return fmt.Errorf("proof buffer has wrong length, expected: 32, got: %d", len(ap.Proof))
|
||||
return fmt.Errorf("proof buffer length must be a multiple of 32, got: %d", len(ap.Proof))
|
||||
}
|
||||
|
||||
if len(ap.Instances) == 0 {
|
||||
return errors.New("instance not ready")
|
||||
}
|
||||
|
||||
if len(ap.Vk) == 0 {
|
||||
return errors.New("vk not ready")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BundleProof includes the proof info that are required for verification of a bundle of batch proofs.
|
||||
type BundleProof struct {
|
||||
Proof []byte `json:"proof"`
|
||||
Instances []byte `json:"instances"`
|
||||
Vk []byte `json:"vk"`
|
||||
// cross-reference between cooridinator computation and prover compution
|
||||
GitVersion string `json:"git_version,omitempty"`
|
||||
}
|
||||
|
||||
// SanityCheck checks whether a BundleProof is in a legal format
|
||||
func (ap *BundleProof) SanityCheck() error {
|
||||
if ap == nil {
|
||||
return errors.New("agg_proof is nil")
|
||||
}
|
||||
|
||||
if len(ap.Proof) == 0 {
|
||||
return errors.New("proof not ready")
|
||||
}
|
||||
|
||||
if len(ap.Proof)%32 != 0 {
|
||||
return fmt.Errorf("proof buffer length must be a multiple of 32, got: %d", len(ap.Proof))
|
||||
}
|
||||
|
||||
if len(ap.Instances) == 0 {
|
||||
return errors.New("instance not ready")
|
||||
}
|
||||
|
||||
if len(ap.Vk) == 0 {
|
||||
return errors.New("vk not ready")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
package message
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/crypto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAuthMessageSignAndVerify(t *testing.T) {
|
||||
privkey, err := crypto.GenerateKey()
|
||||
assert.NoError(t, err)
|
||||
|
||||
authMsg := &AuthMsg{
|
||||
Identity: &Identity{
|
||||
Challenge: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTEwMzgxNzUsIm9yaWdfaWF0IjoxNjkxMDM0NTc1fQ.HybBMsEJFhyZqtIa2iVcHUP7CEFttf708jmTMAImAWA",
|
||||
ProverName: "test",
|
||||
ProverVersion: "v1.0.0",
|
||||
},
|
||||
}
|
||||
assert.NoError(t, authMsg.SignWithKey(privkey))
|
||||
|
||||
// Check public key.
|
||||
pk, err := authMsg.PublicKey()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, common.Bytes2Hex(crypto.CompressPubkey(&privkey.PublicKey)), pk)
|
||||
|
||||
ok, err := authMsg.Verify()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, true, ok)
|
||||
|
||||
// Check public key is ok.
|
||||
pub, err := authMsg.PublicKey()
|
||||
assert.NoError(t, err)
|
||||
pubkey := crypto.CompressPubkey(&privkey.PublicKey)
|
||||
assert.Equal(t, pub, common.Bytes2Hex(pubkey))
|
||||
}
|
||||
|
||||
func TestGenerateToken(t *testing.T) {
|
||||
token, err := GenerateToken()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 32, len(token))
|
||||
}
|
||||
|
||||
func TestIdentityHash(t *testing.T) {
|
||||
identity := &Identity{
|
||||
Challenge: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTEwMzM0MTksIm9yaWdfaWF0IjoxNjkxMDI5ODE5fQ.EhkLZsj__rNPVC3ZDYBtvdh0nB8mmM_Hl82hObaIWOs",
|
||||
ProverName: "test",
|
||||
ProverVersion: "v1.0.0",
|
||||
}
|
||||
|
||||
hash, err := identity.Hash()
|
||||
assert.NoError(t, err)
|
||||
|
||||
expectedHash := "9b8b00f5655411ec1d68ba1666261281c5414aedbda932e5b6a9f7f1b114fdf2"
|
||||
assert.Equal(t, expectedHash, hex.EncodeToString(hash))
|
||||
}
|
||||
|
||||
func TestProofMessageSignVerifyPublicKey(t *testing.T) {
|
||||
privkey, err := crypto.GenerateKey()
|
||||
assert.NoError(t, err)
|
||||
|
||||
proofMsg := &ProofMsg{
|
||||
ProofDetail: &ProofDetail{
|
||||
ID: "testID",
|
||||
Type: ProofTypeChunk,
|
||||
Status: StatusOk,
|
||||
ChunkProof: &ChunkProof{
|
||||
StorageTrace: []byte("testStorageTrace"),
|
||||
Protocol: []byte("testProtocol"),
|
||||
Proof: []byte("testProof"),
|
||||
Instances: []byte("testInstance"),
|
||||
Vk: []byte("testVk"),
|
||||
ChunkInfo: nil,
|
||||
},
|
||||
Error: "testError",
|
||||
},
|
||||
}
|
||||
assert.NoError(t, proofMsg.Sign(privkey))
|
||||
|
||||
// Test when publicKey is not set.
|
||||
ok, err := proofMsg.Verify()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, true, ok)
|
||||
|
||||
// Test when publicKey is already set.
|
||||
ok, err = proofMsg.Verify()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, true, ok)
|
||||
}
|
||||
|
||||
func TestProofDetailHash(t *testing.T) {
|
||||
proofDetail := &ProofDetail{
|
||||
ID: "testID",
|
||||
Type: ProofTypeChunk,
|
||||
Status: StatusOk,
|
||||
ChunkProof: &ChunkProof{
|
||||
StorageTrace: []byte("testStorageTrace"),
|
||||
Protocol: []byte("testProtocol"),
|
||||
Proof: []byte("testProof"),
|
||||
Instances: []byte("testInstance"),
|
||||
Vk: []byte("testVk"),
|
||||
ChunkInfo: nil,
|
||||
},
|
||||
Error: "testError",
|
||||
}
|
||||
hash, err := proofDetail.Hash()
|
||||
assert.NoError(t, err)
|
||||
expectedHash := "d3b57cb84b0da8043373eeb3612806fb7248d6d1b6e089846ccf3ccce2d9f31c"
|
||||
assert.Equal(t, expectedHash, hex.EncodeToString(hash))
|
||||
}
|
||||
|
||||
func TestProveTypeString(t *testing.T) {
|
||||
proofTypeChunk := ProofType(1)
|
||||
assert.Equal(t, "proof type chunk", proofTypeChunk.String())
|
||||
|
||||
proofTypeBatch := ProofType(2)
|
||||
assert.Equal(t, "proof type batch", proofTypeBatch.String())
|
||||
|
||||
illegalProof := ProofType(3)
|
||||
assert.Equal(t, "illegal proof type: 3", illegalProof.String())
|
||||
}
|
||||
|
||||
func TestProofMsgPublicKey(t *testing.T) {
|
||||
privkey, err := crypto.GenerateKey()
|
||||
assert.NoError(t, err)
|
||||
|
||||
proofMsg := &ProofMsg{
|
||||
ProofDetail: &ProofDetail{
|
||||
ID: "testID",
|
||||
Type: ProofTypeChunk,
|
||||
Status: StatusOk,
|
||||
ChunkProof: &ChunkProof{
|
||||
StorageTrace: []byte("testStorageTrace"),
|
||||
Protocol: []byte("testProtocol"),
|
||||
Proof: []byte("testProof"),
|
||||
Instances: []byte("testInstance"),
|
||||
Vk: []byte("testVk"),
|
||||
ChunkInfo: nil,
|
||||
},
|
||||
Error: "testError",
|
||||
},
|
||||
}
|
||||
assert.NoError(t, proofMsg.Sign(privkey))
|
||||
|
||||
// Test when publicKey is not set.
|
||||
pk, err := proofMsg.PublicKey()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, common.Bytes2Hex(crypto.CompressPubkey(&privkey.PublicKey)), pk)
|
||||
|
||||
// Test when publicKey is already set.
|
||||
proofMsg.publicKey = common.Bytes2Hex(crypto.CompressPubkey(&privkey.PublicKey))
|
||||
pk, err = proofMsg.PublicKey()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, common.Bytes2Hex(crypto.CompressPubkey(&privkey.PublicKey)), pk)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -28,7 +29,7 @@ func LoadOrCreateKey(keystorePath string, keystorePassword string) (*ecdsa.Priva
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
} else if fi.IsDir() {
|
||||
return nil, fmt.Errorf("keystorePath cannot be a dir")
|
||||
return nil, errors.New("keystorePath cannot be a dir")
|
||||
}
|
||||
|
||||
keyjson, err := os.ReadFile(filepath.Clean(keystorePath))
|
||||
|
||||
@@ -12,12 +12,8 @@ import (
|
||||
type MockAppName string
|
||||
|
||||
var (
|
||||
// EventWatcherApp the name of mock event-watcher app.
|
||||
EventWatcherApp MockAppName = "event-watcher-test"
|
||||
// GasOracleApp the name of mock gas-oracle app.
|
||||
GasOracleApp MockAppName = "gas-oracle-test"
|
||||
// MessageRelayerApp the name of mock message-relayer app.
|
||||
MessageRelayerApp MockAppName = "message-relayer-test"
|
||||
// RollupRelayerApp the name of mock rollup-relayer app.
|
||||
RollupRelayerApp MockAppName = "rollup-relayer-test"
|
||||
|
||||
@@ -28,11 +24,6 @@ var (
|
||||
CoordinatorAPIApp MockAppName = "coordinator-api-test"
|
||||
// CoordinatorCronApp the name of mock coordinator cron app.
|
||||
CoordinatorCronApp MockAppName = "coordinator-cron-test"
|
||||
|
||||
// ChunkProverApp the name of mock chunk prover app.
|
||||
ChunkProverApp MockAppName = "chunkProver-test"
|
||||
// BatchProverApp the name of mock batch prover app.
|
||||
BatchProverApp MockAppName = "batchProver-test"
|
||||
)
|
||||
|
||||
// RegisterSimulation register initializer function for integration-test.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var tag = "v4.4.8"
|
||||
var tag = "v4.4.42"
|
||||
|
||||
var commit = func() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
### NOTE: DO NOT USE THIS FILE IF USING TESTNET'S .ENV
|
||||
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
|
||||
|
||||
RINKEBY_RPC=https://eth-rinkeby.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
|
||||
SCROLL_L1_RPC=https://prealpha.scroll.io/l1
|
||||
SCROLL_L2_RPC=https://prealpha.scroll.io/l2
|
||||
|
||||
RINKEBY_PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
|
||||
L1_DEPLOYER_PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
|
||||
L2_DEPLOYER_PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
|
||||
|
||||
CHAIN_ID_L2="5343541"
|
||||
@@ -1,4 +0,0 @@
|
||||
node_modules
|
||||
artifacts
|
||||
cache
|
||||
coverage
|
||||
@@ -1,24 +0,0 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: false,
|
||||
es2021: true,
|
||||
mocha: true,
|
||||
node: true,
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
extends: [
|
||||
"standard",
|
||||
"plugin:prettier/recommended",
|
||||
"plugin:node/recommended",
|
||||
],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
},
|
||||
rules: {
|
||||
"node/no-unsupported-features/es-syntax": [
|
||||
"error",
|
||||
{ ignores: ["modules"] },
|
||||
],
|
||||
},
|
||||
};
|
||||
17
contracts/.gitignore
vendored
17
contracts/.gitignore
vendored
@@ -1,17 +0,0 @@
|
||||
node_modules
|
||||
.env
|
||||
coverage
|
||||
coverage.json
|
||||
typechain
|
||||
|
||||
# Hardhat/Foundry files
|
||||
cache
|
||||
cache-hardhat
|
||||
artifacts
|
||||
broadcast
|
||||
|
||||
# logs
|
||||
*.log
|
||||
|
||||
# eslint
|
||||
.eslintcache
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
cd contracts
|
||||
yarn lint-staged
|
||||
@@ -1,3 +0,0 @@
|
||||
hardhat.config.ts
|
||||
scripts
|
||||
test
|
||||
@@ -1 +0,0 @@
|
||||
v18.15.0
|
||||
@@ -1,8 +0,0 @@
|
||||
node_modules
|
||||
artifacts
|
||||
cache
|
||||
coverage*
|
||||
gasReporterOutput.json
|
||||
src/libraries/verifier/ZkTrieVerifier.sol
|
||||
src/libraries/verifier/PatriciaMerkleTrieVerifier.sol
|
||||
src/L2/predeploys/L1BlockContainer.sol
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 2,
|
||||
"bracketSpacing": true,
|
||||
"overrides": [
|
||||
{
|
||||
"files": "src/**/*.sol",
|
||||
"options": {
|
||||
"printWidth": 120,
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"singleQuote": false,
|
||||
"bracketSpacing": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": "scripts/**/*.sol",
|
||||
"options": {
|
||||
"printWidth": 120,
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"singleQuote": false,
|
||||
"bracketSpacing": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
skipFiles: [
|
||||
'mocks',
|
||||
'test',
|
||||
'L2/predeploys/L1BlockContainer.sol',
|
||||
'libraries/verifier/ZkTrieVerifier.sol',
|
||||
'libraries/verifier/PatriciaMerkleTrieVerifier.sol'
|
||||
],
|
||||
istanbulReporter: ["lcov", "json"]
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": "solhint:recommended",
|
||||
"rules": {
|
||||
"compiler-version": ["error", "^0.8.0"],
|
||||
"func-visibility": ["warn", { "ignoreConstructors": true }]
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
node_modules
|
||||
@@ -1,78 +0,0 @@
|
||||
# Scroll Contracts
|
||||
|
||||
This directory contains the solidity code for Scroll L1 bridge and rollup contracts and L2 bridge and pre-deployed contracts. You can also find contract APIs and more details in the [`docs`](./docs) folder.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
<pre>
|
||||
├── <a href="./docs/">docs</a>: Documentation for the contracts
|
||||
├── <a href="./integration-test/">integration-test</a>: Hardhat integration tests
|
||||
├── <a href="./lib/">lib</a>: External libraries and testing tools
|
||||
├── <a href="./scripts">scripts</a>: Deployment scripts
|
||||
├── <a href="./src">src</a>
|
||||
│ ├── <a href="./src/gas-swap/">gas-swap</a>: Utility contract that allows gas payment in other tokens
|
||||
│ ├── <a href="./src/interfaces/">interfaces</a>: Common contract interfaces
|
||||
│ ├── <a href="./src/L1/">L1</a>: Contracts deployed on the L1 (Ethereum)
|
||||
│ │ ├── <a href="./src/L1/gateways/">gateways</a>: Gateway router and token gateway contracts
|
||||
│ │ ├── <a href="./src/L1/rollup/">rollup</a>: Rollup contracts for data availability and finalization
|
||||
│ │ ├── <a href="./src/L1/IL1ScrollMessenger.sol">IL1ScrollMessenger.sol</a>: L1 Scroll messenger interface
|
||||
│ │ └── <a href="./src/L1/L1ScrollMessenger.sol">L1ScrollMessenger.sol</a>: L1 Scroll messenger contract
|
||||
│ ├── <a href="./src/L2/">L2</a>: Contracts deployed on the L2 (Scroll)
|
||||
│ │ ├── <a href="./src/L2/gateways/">gateways</a>: Gateway router and token gateway contracts
|
||||
│ │ ├── <a href="./src/L2/predeploys/">predeploys</a>: Pre-deployed contracts on L2
|
||||
│ │ ├── <a href="./src/L2/IL2ScrollMessenger.sol">IL2ScrollMessenger.sol</a>: L2 Scroll messenger interface
|
||||
│ │ └── <a href="./src/L2/L2ScrollMessenger.sol">L2ScrollMessenger.sol</a>: L2 Scroll messenger contract
|
||||
│ ├── <a href="./src/libraries/">libraries</a>: Shared contract libraries
|
||||
│ ├── <a href="./src/misc/">misc</a>: Miscellaneous contracts
|
||||
│ ├── <a href="./src/mocks/">mocks</a>: Mock contracts used in the testing
|
||||
│ ├── <a href="./src/rate-limiter/">rate-limiter</a>: Rater limiter contract
|
||||
│ └── <a href="./src/test/">test</a>: Unit tests in solidity
|
||||
├── <a href="./foundry.toml">foundry.toml</a>: Foundry configuration
|
||||
├── <a href="./hardhat.config.ts">hardhat.config.ts</a>: Hardhat configuration
|
||||
├── <a href="./remappings.txt">remappings.txt</a>: Foundry dependency mappings
|
||||
...
|
||||
</pre>
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Node.js
|
||||
|
||||
First install [`Node.js`](https://nodejs.org/en) and [`npm`](https://www.npmjs.com/).
|
||||
Run the following command to install [`yarn`](https://classic.yarnpkg.com/en/):
|
||||
|
||||
```bash
|
||||
npm install --global yarn
|
||||
```
|
||||
|
||||
### Foundry
|
||||
|
||||
Install `foundryup`, the Foundry toolchain installer:
|
||||
|
||||
```bash
|
||||
curl -L https://foundry.paradigm.xyz | bash
|
||||
```
|
||||
|
||||
If you do not want to use the redirect, feel free to manually download the `foundryup` installation script from [here](https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup).
|
||||
|
||||
Then, run `foundryup` in a new terminal session or after reloading `PATH`.
|
||||
|
||||
Other ways to install Foundry can be found [here](https://github.com/foundry-rs/foundry#installation).
|
||||
|
||||
### Hardhat
|
||||
|
||||
Run the following command to install [Hardhat](https://hardhat.org/) and other dependencies.
|
||||
|
||||
```
|
||||
yarn install
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
- Run `git submodule update --init --recursive` to initialize git submodules.
|
||||
- Run `yarn prettier:solidity` to run linting in fix mode, will auto-format all solidity codes.
|
||||
- Run `yarn prettier` to run linting in fix mode, will auto-format all typescript codes.
|
||||
- Run `yarn prepare` to install the precommit linting hook.
|
||||
- Run `forge build` to compile contracts with foundry.
|
||||
- Run `npx hardhat compile` to compile with hardhat.
|
||||
- Run `forge test -vvv` to run foundry units tests. It will compile all contracts before running the unit tests.
|
||||
- Run `npx hardhat test` to run integration tests. It may not compile all contracts before running, it's better to run `npx hardhat compile` first.
|
||||
3
contracts/circomlib.d.ts
vendored
3
contracts/circomlib.d.ts
vendored
@@ -1,3 +0,0 @@
|
||||
declare module "circomlib/src/evmasm";
|
||||
declare module "circomlib/src/poseidon_gencontract";
|
||||
declare module "circomlib/src/poseidon_constants";
|
||||
@@ -1,16 +0,0 @@
|
||||
# Deployments
|
||||
|
||||
## local testnet
|
||||
|
||||
```bash
|
||||
# start local hardhat node
|
||||
npx hardhat node
|
||||
```
|
||||
|
||||
### layer 1
|
||||
|
||||
Contract addresses can be found in [deployments](./l1geth.json).
|
||||
|
||||
### layer 2
|
||||
|
||||
Contract addresses can be found in [deployments](./l2geth.json).
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"ProxyAdmin": null,
|
||||
"ZKRollup": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
},
|
||||
"L1ScrollMessenger": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
},
|
||||
"L1GatewayRouter": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
},
|
||||
"L1StandardERC20Gateway": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
},
|
||||
"L1WETHGateway": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"ProxyAdmin": null,
|
||||
"WETH": null,
|
||||
"Whitelist": null,
|
||||
"ScrollStandardERC20": null,
|
||||
"ScrollStandardERC20Factory": null,
|
||||
"L2ScrollMessenger": null,
|
||||
"L2GatewayRouter": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
},
|
||||
"L2StandardERC20Gateway": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
},
|
||||
"L2WETHGateway": {
|
||||
"implementation": null,
|
||||
"proxy": null
|
||||
}
|
||||
}
|
||||
@@ -1,599 +0,0 @@
|
||||
# L1ERC1155Gateway
|
||||
|
||||
|
||||
|
||||
> L1ERC1155Gateway
|
||||
|
||||
The `L1ERC1155Gateway` is used to deposit ERC1155 compatible NFT on layer 1 and finalize withdraw the NFTs from layer 2.
|
||||
|
||||
*The deposited NFTs are held in this gateway. On finalizing withdraw, the corresponding NFT will be transfer to the recipient directly. This will be changed if we have more specific scenarios.*
|
||||
|
||||
## Methods
|
||||
|
||||
### batchDepositERC1155
|
||||
|
||||
```solidity
|
||||
function batchDepositERC1155(address _token, uint256[] _tokenIds, uint256[] _amounts, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit a list of some ERC1155 NFT to caller's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### batchDepositERC1155
|
||||
|
||||
```solidity
|
||||
function batchDepositERC1155(address _token, address _to, uint256[] _tokenIds, uint256[] _amounts, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit a list of some ERC1155 NFT to a recipient's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### depositERC1155
|
||||
|
||||
```solidity
|
||||
function depositERC1155(address _token, address _to, uint256 _tokenId, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some ERC1155 NFT to a recipient's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _amount | uint256 | The amount of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### depositERC1155
|
||||
|
||||
```solidity
|
||||
function depositERC1155(address _token, uint256 _tokenId, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some ERC1155 NFT to caller's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _amount | uint256 | The amount of token to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### finalizeBatchWithdrawERC1155
|
||||
|
||||
```solidity
|
||||
function finalizeBatchWithdrawERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds, uint256[] _amounts) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 batch withdraw from layer 2 to layer 1 and send fund to recipient's account on layer 1. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC1155Gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenIds | uint256[] | The list of token ids to withdraw. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to withdraw. |
|
||||
|
||||
### finalizeWithdrawERC1155
|
||||
|
||||
```solidity
|
||||
function finalizeWithdrawERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId, uint256 _amount) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 withdraw from layer 2 to layer 1 and send fund to recipient's account on layer 1. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC1155Gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenId | uint256 | The token id to withdraw. |
|
||||
| _amount | uint256 | The amount of token to withdraw. |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _messenger) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of L1ERC1155Gateway.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of L2ERC1155Gateway in L2. |
|
||||
| _messenger | address | The address of L1ScrollMessenger in L1. |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### onDropMessage
|
||||
|
||||
```solidity
|
||||
function onDropMessage(bytes _message) external payable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _message | bytes | undefined |
|
||||
|
||||
### onERC1155BatchReceived
|
||||
|
||||
```solidity
|
||||
function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) external nonpayable returns (bytes4)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256[] | undefined |
|
||||
| _3 | uint256[] | undefined |
|
||||
| _4 | bytes | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes4 | undefined |
|
||||
|
||||
### onERC1155Received
|
||||
|
||||
```solidity
|
||||
function onERC1155Received(address, address, uint256, uint256, bytes) external nonpayable returns (bytes4)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256 | undefined |
|
||||
| _3 | uint256 | undefined |
|
||||
| _4 | bytes | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes4 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### supportsInterface
|
||||
|
||||
```solidity
|
||||
function supportsInterface(bytes4 interfaceId) external view returns (bool)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*See {IERC165-supportsInterface}.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| interfaceId | bytes4 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### tokenMapping
|
||||
|
||||
```solidity
|
||||
function tokenMapping(address) external view returns (address)
|
||||
```
|
||||
|
||||
Mapping from l1 token address to l2 token address for ERC1155 NFT.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### updateTokenMapping
|
||||
|
||||
```solidity
|
||||
function updateTokenMapping(address _l1Token, address _l2Token) external nonpayable
|
||||
```
|
||||
|
||||
Update layer 2 to layer 2 token mapping.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of ERC1155 token on layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### BatchDepositERC1155
|
||||
|
||||
```solidity
|
||||
event BatchDepositERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds, uint256[] _amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenIds | uint256[] | The list of token ids of the ERC1155 NFT to deposit on layer 1. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to deposit on layer 1. |
|
||||
|
||||
### BatchRefundERC1155
|
||||
|
||||
```solidity
|
||||
event BatchRefundERC1155(address indexed token, address indexed recipient, uint256[] tokenIds, uint256[] amounts)
|
||||
```
|
||||
|
||||
Emitted when some ERC1155 token is refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of the token in L1. |
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| tokenIds | uint256[] | The list of ids of token refunded. |
|
||||
| amounts | uint256[] | The list of amount of token refunded. |
|
||||
|
||||
### DepositERC1155
|
||||
|
||||
```solidity
|
||||
event DepositERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId, uint256 _amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenId | uint256 | The token id of the ERC1155 NFT to deposit on layer 1. |
|
||||
| _amount | uint256 | The number of token to deposit on layer 1. |
|
||||
|
||||
### FinalizeBatchWithdrawERC1155
|
||||
|
||||
```solidity
|
||||
event FinalizeBatchWithdrawERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds, uint256[] _amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch transferred to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1. |
|
||||
| _tokenIds | uint256[] | The list of token ids of the ERC1155 NFT to withdraw from layer 2. |
|
||||
| _amounts | uint256[] | The list of corresponding number of token to withdraw from layer 2. |
|
||||
|
||||
### FinalizeWithdrawERC1155
|
||||
|
||||
```solidity
|
||||
event FinalizeWithdrawERC1155(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId, uint256 _amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is transferred to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1. |
|
||||
| _tokenId | uint256 | The token id of the ERC1155 NFT to withdraw from layer 2. |
|
||||
| _amount | uint256 | The number of token to withdraw from layer 2. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### RefundERC1155
|
||||
|
||||
```solidity
|
||||
event RefundERC1155(address indexed token, address indexed recipient, uint256 tokenId, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when some ERC1155 token is refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of the token in L1. |
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| tokenId | uint256 | The id of token refunded. |
|
||||
| amount | uint256 | The amount of token refunded. |
|
||||
|
||||
### UpdateTokenMapping
|
||||
|
||||
```solidity
|
||||
event UpdateTokenMapping(address indexed l1Token, address indexed oldL2Token, address indexed newL2Token)
|
||||
```
|
||||
|
||||
Emitted when token mapping for ERC1155 token is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC1155 token in layer 1. |
|
||||
| oldL2Token `indexed` | address | The address of the old corresponding ERC1155 token in layer 2. |
|
||||
| newL2Token `indexed` | address | The address of the new corresponding ERC1155 token in layer 2. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,538 +0,0 @@
|
||||
# L1ERC721Gateway
|
||||
|
||||
|
||||
|
||||
> L1ERC721Gateway
|
||||
|
||||
The `L1ERC721Gateway` is used to deposit ERC721 compatible NFT on layer 1 and finalize withdraw the NFTs from layer 2.
|
||||
|
||||
*The deposited NFTs are held in this gateway. On finalizing withdraw, the corresponding NFT will be transfer to the recipient directly. This will be changed if we have more specific scenarios.*
|
||||
|
||||
## Methods
|
||||
|
||||
### batchDepositERC721
|
||||
|
||||
```solidity
|
||||
function batchDepositERC721(address _token, address _to, uint256[] _tokenIds, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit a list of some ERC721 NFT to a recipient's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### batchDepositERC721
|
||||
|
||||
```solidity
|
||||
function batchDepositERC721(address _token, uint256[] _tokenIds, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit a list of some ERC721 NFT to caller's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _tokenIds | uint256[] | The list of token ids to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### depositERC721
|
||||
|
||||
```solidity
|
||||
function depositERC721(address _token, address _to, uint256 _tokenId, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some ERC721 NFT to a recipient's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### depositERC721
|
||||
|
||||
```solidity
|
||||
function depositERC721(address _token, uint256 _tokenId, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some ERC721 NFT to caller's account on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of ERC721 NFT on layer 1. |
|
||||
| _tokenId | uint256 | The token id to deposit. |
|
||||
| _gasLimit | uint256 | Estimated gas limit required to complete the deposit on layer 2. |
|
||||
|
||||
### finalizeBatchWithdrawERC721
|
||||
|
||||
```solidity
|
||||
function finalizeBatchWithdrawERC721(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 batch withdraw from layer 2 to layer 1 and send NFT to recipient's account on layer 1.
|
||||
|
||||
*Requirements: - The function should only be called by L1ScrollMessenger. - The function should also only be called by L2ERC721Gateway on layer 2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenIds | uint256[] | The list of token ids to withdraw. |
|
||||
|
||||
### finalizeWithdrawERC721
|
||||
|
||||
```solidity
|
||||
function finalizeWithdrawERC721(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 withdraw from layer 2 to layer 1 and send NFT to recipient's account on layer 1.
|
||||
|
||||
*Requirements: - The function should only be called by L1ScrollMessenger. - The function should also only be called by L2ERC721Gateway on layer 2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding layer 1 token. |
|
||||
| _l2Token | address | The address of corresponding layer 2 token. |
|
||||
| _from | address | The address of account who withdraw the token on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1 to receive the token. |
|
||||
| _tokenId | uint256 | The token id to withdraw. |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _messenger) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of L1ERC721Gateway.
|
||||
|
||||
*The parameters `_counterpart` and `_messenger` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of L2ERC721Gateway in L2. |
|
||||
| _messenger | address | The address of L1ScrollMessenger in L1. |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### onDropMessage
|
||||
|
||||
```solidity
|
||||
function onDropMessage(bytes _message) external payable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _message | bytes | undefined |
|
||||
|
||||
### onERC721Received
|
||||
|
||||
```solidity
|
||||
function onERC721Received(address, address, uint256, bytes) external nonpayable returns (bytes4)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*See {IERC721Receiver-onERC721Received}. Always returns `IERC721Receiver.onERC721Received.selector`.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256 | undefined |
|
||||
| _3 | bytes | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes4 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### tokenMapping
|
||||
|
||||
```solidity
|
||||
function tokenMapping(address) external view returns (address)
|
||||
```
|
||||
|
||||
Mapping from l1 token address to l2 token address for ERC721 NFT.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### updateTokenMapping
|
||||
|
||||
```solidity
|
||||
function updateTokenMapping(address _l1Token, address _l2Token) external nonpayable
|
||||
```
|
||||
|
||||
Update layer 2 to layer 2 token mapping.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of ERC721 token on layer 1. |
|
||||
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### BatchDepositERC721
|
||||
|
||||
```solidity
|
||||
event BatchDepositERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenIds | uint256[] | The list of token ids of the ERC721 NFT to deposit on layer 1. |
|
||||
|
||||
### BatchRefundERC721
|
||||
|
||||
```solidity
|
||||
event BatchRefundERC721(address indexed token, address indexed recipient, uint256[] tokenIds)
|
||||
```
|
||||
|
||||
Emitted when a batch of ERC721 tokens are refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of the token in L1. |
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| tokenIds | uint256[] | The list of token ids of the ERC721 NFT refunded. |
|
||||
|
||||
### DepositERC721
|
||||
|
||||
```solidity
|
||||
event DepositERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is deposited to gateway on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 1. |
|
||||
| _to | address | The address of recipient on layer 2. |
|
||||
| _tokenId | uint256 | The token id of the ERC721 NFT to deposit on layer 1. |
|
||||
|
||||
### FinalizeBatchWithdrawERC721
|
||||
|
||||
```solidity
|
||||
event FinalizeBatchWithdrawERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256[] _tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch transferred to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1. |
|
||||
| _tokenIds | uint256[] | The list of token ids of the ERC721 NFT to withdraw from layer 2. |
|
||||
|
||||
### FinalizeWithdrawERC721
|
||||
|
||||
```solidity
|
||||
event FinalizeWithdrawERC721(address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is transferred to recipient on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| _l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| _from `indexed` | address | The address of sender on layer 2. |
|
||||
| _to | address | The address of recipient on layer 1. |
|
||||
| _tokenId | uint256 | The token id of the ERC721 NFT to withdraw from layer 2. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### RefundERC721
|
||||
|
||||
```solidity
|
||||
event RefundERC721(address indexed token, address indexed recipient, uint256 tokenId)
|
||||
```
|
||||
|
||||
Emitted when some ERC721 token is refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of the token in L1. |
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| tokenId | uint256 | The id of token refunded. |
|
||||
|
||||
### UpdateTokenMapping
|
||||
|
||||
```solidity
|
||||
event UpdateTokenMapping(address indexed l1Token, address indexed oldL2Token, address indexed newL2Token)
|
||||
```
|
||||
|
||||
Emitted when token mapping for ERC721 token is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC721 token in layer 1. |
|
||||
| oldL2Token `indexed` | address | The address of the old corresponding ERC721 token in layer 2. |
|
||||
| newL2Token `indexed` | address | The address of the new corresponding ERC721 token in layer 2. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,620 +0,0 @@
|
||||
# L1GatewayRouter
|
||||
|
||||
|
||||
|
||||
> L1GatewayRouter
|
||||
|
||||
The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens. All deposited tokens are routed to corresponding gateways.
|
||||
|
||||
*One can also use this contract to query L1/L2 token address mapping. In the future, ERC-721 and ERC-1155 tokens will be added to the router too.*
|
||||
|
||||
## Methods
|
||||
|
||||
### ERC20Gateway
|
||||
|
||||
```solidity
|
||||
function ERC20Gateway(address) external view returns (address)
|
||||
```
|
||||
|
||||
Mapping from ERC20 token address to corresponding L1ERC20Gateway.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### defaultERC20Gateway
|
||||
|
||||
```solidity
|
||||
function defaultERC20Gateway() external view returns (address)
|
||||
```
|
||||
|
||||
The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### depositERC20
|
||||
|
||||
```solidity
|
||||
function depositERC20(address _token, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a caller's account on L2.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### depositERC20
|
||||
|
||||
```solidity
|
||||
function depositERC20(address _token, address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a recipient's account on L2.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _to | address | The address of recipient's account on L2. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### depositERC20AndCall
|
||||
|
||||
```solidity
|
||||
function depositERC20AndCall(address _token, address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a recipient's account on L2 and call.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _to | address | The address of recipient's account on L2. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _data | bytes | Optional data to forward to recipient's account. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### depositETH
|
||||
|
||||
```solidity
|
||||
function depositETH(uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit ETH to caller's account in L2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### depositETH
|
||||
|
||||
```solidity
|
||||
function depositETH(address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit ETH to some recipient's account in L2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### depositETHAndCall
|
||||
|
||||
```solidity
|
||||
function depositETHAndCall(address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit ETH to some recipient's account in L2 and call the target contract.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _data | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### ethGateway
|
||||
|
||||
```solidity
|
||||
function ethGateway() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1ETHGateway.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### finalizeWithdrawERC20
|
||||
|
||||
```solidity
|
||||
function finalizeWithdrawERC20(address, address, address, address, uint256, bytes) external payable
|
||||
```
|
||||
|
||||
Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.
|
||||
|
||||
*Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | address | undefined |
|
||||
| _3 | address | undefined |
|
||||
| _4 | uint256 | undefined |
|
||||
| _5 | bytes | undefined |
|
||||
|
||||
### finalizeWithdrawETH
|
||||
|
||||
```solidity
|
||||
function finalizeWithdrawETH(address, address, uint256, bytes) external payable
|
||||
```
|
||||
|
||||
Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.
|
||||
|
||||
*This function should only be called by L1ScrollMessenger. This function should also only be called by L1ETHGateway in L2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256 | undefined |
|
||||
| _3 | bytes | undefined |
|
||||
|
||||
### gatewayInContext
|
||||
|
||||
```solidity
|
||||
function gatewayInContext() external view returns (address)
|
||||
```
|
||||
|
||||
The address of gateway in current execution context.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### getERC20Gateway
|
||||
|
||||
```solidity
|
||||
function getERC20Gateway(address _token) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding gateway address for given token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token to query. |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### getL2ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL2ERC20Address(address _l1Address) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l2 token address given l1 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Address | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _ethGateway, address _defaultERC20Gateway) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of L1GatewayRouter.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _ethGateway | address | The address of L1ETHGateway contract. |
|
||||
| _defaultERC20Gateway | address | The address of default ERC20 Gateway contract. |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### requestERC20
|
||||
|
||||
```solidity
|
||||
function requestERC20(address _sender, address _token, uint256 _amount) external nonpayable returns (uint256)
|
||||
```
|
||||
|
||||
Request ERC20 token transfer from users to gateways.
|
||||
|
||||
*All the gateways should have reentrancy guard to prevent potential attack though this function.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _sender | address | undefined |
|
||||
| _token | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### setDefaultERC20Gateway
|
||||
|
||||
```solidity
|
||||
function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external nonpayable
|
||||
```
|
||||
|
||||
Update the address of default ERC20 gateway contract.
|
||||
|
||||
*This function should only be called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _newDefaultERC20Gateway | address | undefined |
|
||||
|
||||
### setERC20Gateway
|
||||
|
||||
```solidity
|
||||
function setERC20Gateway(address[] _tokens, address[] _gateways) external nonpayable
|
||||
```
|
||||
|
||||
Update the mapping from token address to gateway address.
|
||||
|
||||
*This function should only be called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _tokens | address[] | The list of addresses of tokens to update. |
|
||||
| _gateways | address[] | The list of addresses of gateways to update. |
|
||||
|
||||
### setETHGateway
|
||||
|
||||
```solidity
|
||||
function setETHGateway(address _newEthGateway) external nonpayable
|
||||
```
|
||||
|
||||
Update the address of ETH gateway contract.
|
||||
|
||||
*This function should only be called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _newEthGateway | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### DepositERC20
|
||||
|
||||
```solidity
|
||||
event DepositERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone deposit ERC20 token from L1 to L2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of token will be deposited from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### DepositETH
|
||||
|
||||
```solidity
|
||||
event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone deposit ETH from L1 to L2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to `indexed` | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of ETH will be deposited from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### FinalizeWithdrawERC20
|
||||
|
||||
```solidity
|
||||
event FinalizeWithdrawERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of token withdrawn from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
### FinalizeWithdrawETH
|
||||
|
||||
```solidity
|
||||
event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to `indexed` | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of ETH withdrawn from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### RefundERC20
|
||||
|
||||
```solidity
|
||||
event RefundERC20(address indexed token, address indexed recipient, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when some ERC20 token is refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of the token in L1. |
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| amount | uint256 | The amount of token refunded to receiver. |
|
||||
|
||||
### RefundETH
|
||||
|
||||
```solidity
|
||||
event RefundETH(address indexed recipient, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when some ETH is refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| amount | uint256 | The amount of ETH refunded to receiver. |
|
||||
|
||||
### SetDefaultERC20Gateway
|
||||
|
||||
```solidity
|
||||
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway)
|
||||
```
|
||||
|
||||
Emitted when the address of default ERC20 Gateway is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| oldDefaultERC20Gateway `indexed` | address | The address of the old default ERC20 Gateway. |
|
||||
| newDefaultERC20Gateway `indexed` | address | The address of the new default ERC20 Gateway. |
|
||||
|
||||
### SetERC20Gateway
|
||||
|
||||
```solidity
|
||||
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway)
|
||||
```
|
||||
|
||||
Emitted when the `gateway` for `token` is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of token updated. |
|
||||
| oldGateway `indexed` | address | The corresponding address of the old gateway. |
|
||||
| newGateway `indexed` | address | The corresponding address of the new gateway. |
|
||||
|
||||
### SetETHGateway
|
||||
|
||||
```solidity
|
||||
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway)
|
||||
```
|
||||
|
||||
Emitted when the address of ETH Gateway is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| oldETHGateway `indexed` | address | The address of the old ETH Gateway. |
|
||||
| newEthGateway `indexed` | address | The address of the new ETH Gateway. |
|
||||
|
||||
|
||||
|
||||
@@ -1,627 +0,0 @@
|
||||
# L1ScrollMessenger
|
||||
|
||||
|
||||
|
||||
> L1ScrollMessenger
|
||||
|
||||
The `L1ScrollMessenger` contract can: 1. send messages from layer 1 to layer 2; 2. relay messages from layer 2 layer 1; 3. replay failed message by replacing the gas limit; 4. drop expired message due to sequencer problems.
|
||||
|
||||
*All deposited Ether (including `WETH` deposited throng `L1WETHGateway`) will locked in this contract.*
|
||||
|
||||
## Methods
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of counterpart ScrollMessenger contract in L1/L2.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### dropMessage
|
||||
|
||||
```solidity
|
||||
function dropMessage(address _from, address _to, uint256 _value, uint256 _messageNonce, bytes _message) external nonpayable
|
||||
```
|
||||
|
||||
Drop a skipped message.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _messageNonce | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
|
||||
### feeVault
|
||||
|
||||
```solidity
|
||||
function feeVault() external view returns (address)
|
||||
```
|
||||
|
||||
The address of fee vault, collecting cross domain messaging fee.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _feeVault, address _rollup, address _messageQueue) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of L1ScrollMessenger.
|
||||
|
||||
*The parameters `_counterpart`, `_rollup` and `_messageQueue` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of L2ScrollMessenger contract in L2. |
|
||||
| _feeVault | address | The address of fee vault, which will be used to collect relayer fee. |
|
||||
| _rollup | address | The address of ScrollChain contract. |
|
||||
| _messageQueue | address | The address of L1MessageQueue contract. |
|
||||
|
||||
### isL1MessageDropped
|
||||
|
||||
```solidity
|
||||
function isL1MessageDropped(bytes32) external view returns (bool)
|
||||
```
|
||||
|
||||
Mapping from L1 message hash to drop status.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes32 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### isL2MessageExecuted
|
||||
|
||||
```solidity
|
||||
function isL2MessageExecuted(bytes32) external view returns (bool)
|
||||
```
|
||||
|
||||
Mapping from L2 message hash to a boolean value indicating if the message has been successfully executed.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes32 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### maxReplayTimes
|
||||
|
||||
```solidity
|
||||
function maxReplayTimes() external view returns (uint256)
|
||||
```
|
||||
|
||||
The maximum number of times each L1 message can be replayed.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### messageQueue
|
||||
|
||||
```solidity
|
||||
function messageQueue() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1MessageQueue contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### messageSendTimestamp
|
||||
|
||||
```solidity
|
||||
function messageSendTimestamp(bytes32) external view returns (uint256)
|
||||
```
|
||||
|
||||
Mapping from L1 message hash to the timestamp when the message is sent.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes32 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### paused
|
||||
|
||||
```solidity
|
||||
function paused() external view returns (bool)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns true if the contract is paused, and false otherwise.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### prevReplayIndex
|
||||
|
||||
```solidity
|
||||
function prevReplayIndex(uint256) external view returns (uint256)
|
||||
```
|
||||
|
||||
Mapping from queue index to previous replay queue index.
|
||||
|
||||
*If a message `x` was replayed 3 times with index `q1`, `q2` and `q3`, the value of `prevReplayIndex` and `replayStates` will be `replayStates[hash(x)].lastIndex = q3`, `replayStates[hash(x)].times = 3`, `prevReplayIndex[q3] = q2`, `prevReplayIndex[q2] = q1`, `prevReplayIndex[q1] = x` and `prevReplayIndex[x]=nil`.The index `x` that `prevReplayIndex[x]=nil` is used as the termination of the list. Usually we use `0` to represent `nil`, but we cannot distinguish it with the first message with index zero. So a nonzero offset `1` is added to the value of `prevReplayIndex[x]` to avoid such situation.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### relayMessageWithProof
|
||||
|
||||
```solidity
|
||||
function relayMessageWithProof(address _from, address _to, uint256 _value, uint256 _nonce, bytes _message, IL1ScrollMessenger.L2MessageProof _proof) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _nonce | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
| _proof | IL1ScrollMessenger.L2MessageProof | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### replayMessage
|
||||
|
||||
```solidity
|
||||
function replayMessage(address _from, address _to, uint256 _value, uint256 _messageNonce, bytes _message, uint32 _newGasLimit, address _refundAddress) external payable
|
||||
```
|
||||
|
||||
Replay an existing message.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _messageNonce | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
| _newGasLimit | uint32 | undefined |
|
||||
| _refundAddress | address | undefined |
|
||||
|
||||
### replayStates
|
||||
|
||||
```solidity
|
||||
function replayStates(bytes32) external view returns (uint128 times, uint128 lastIndex)
|
||||
```
|
||||
|
||||
Mapping from L1 message hash to replay state.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes32 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| times | uint128 | undefined |
|
||||
| lastIndex | uint128 | undefined |
|
||||
|
||||
### rollup
|
||||
|
||||
```solidity
|
||||
function rollup() external view returns (address)
|
||||
```
|
||||
|
||||
The address of Rollup contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### sendMessage
|
||||
|
||||
```solidity
|
||||
function sendMessage(address _to, uint256 _value, bytes _message, uint256 _gasLimit, address _refundAddress) external payable
|
||||
```
|
||||
|
||||
Send cross chain message from L1 to L2 or L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
| _refundAddress | address | undefined |
|
||||
|
||||
### sendMessage
|
||||
|
||||
```solidity
|
||||
function sendMessage(address _to, uint256 _value, bytes _message, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Send cross chain message from L1 to L2 or L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### setPause
|
||||
|
||||
```solidity
|
||||
function setPause(bool _status) external nonpayable
|
||||
```
|
||||
|
||||
Pause the contract
|
||||
|
||||
*This function can only called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _status | bool | The pause status to update. |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### updateFeeVault
|
||||
|
||||
```solidity
|
||||
function updateFeeVault(address _newFeeVault) external nonpayable
|
||||
```
|
||||
|
||||
Update fee vault contract.
|
||||
|
||||
*This function can only called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _newFeeVault | address | The address of new fee vault contract. |
|
||||
|
||||
### updateMaxReplayTimes
|
||||
|
||||
```solidity
|
||||
function updateMaxReplayTimes(uint256 _newMaxReplayTimes) external nonpayable
|
||||
```
|
||||
|
||||
Update max replay times.
|
||||
|
||||
*This function can only called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _newMaxReplayTimes | uint256 | The new max replay times. |
|
||||
|
||||
### xDomainMessageSender
|
||||
|
||||
```solidity
|
||||
function xDomainMessageSender() external view returns (address)
|
||||
```
|
||||
|
||||
See {IScrollMessenger-xDomainMessageSender}
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### FailedRelayedMessage
|
||||
|
||||
```solidity
|
||||
event FailedRelayedMessage(bytes32 indexed messageHash)
|
||||
```
|
||||
|
||||
Emitted when a cross domain message is failed to relay.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| messageHash `indexed` | bytes32 | The hash of the message. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### Paused
|
||||
|
||||
```solidity
|
||||
event Paused(address account)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Emitted when the pause is triggered by `account`.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| account | address | undefined |
|
||||
|
||||
### RelayedMessage
|
||||
|
||||
```solidity
|
||||
event RelayedMessage(bytes32 indexed messageHash)
|
||||
```
|
||||
|
||||
Emitted when a cross domain message is relayed successfully.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| messageHash `indexed` | bytes32 | The hash of the message. |
|
||||
|
||||
### SentMessage
|
||||
|
||||
```solidity
|
||||
event SentMessage(address indexed sender, address indexed target, uint256 value, uint256 messageNonce, uint256 gasLimit, bytes message)
|
||||
```
|
||||
|
||||
Emitted when a cross domain message is sent.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| sender `indexed` | address | The address of the sender who initiates the message. |
|
||||
| target `indexed` | address | The address of target contract to call. |
|
||||
| value | uint256 | The amount of value passed to the target contract. |
|
||||
| messageNonce | uint256 | The nonce of the message. |
|
||||
| gasLimit | uint256 | The optional gas limit passed to L1 or L2. |
|
||||
| message | bytes | The calldata passed to the target contract. |
|
||||
|
||||
### Unpaused
|
||||
|
||||
```solidity
|
||||
event Unpaused(address account)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Emitted when the pause is lifted by `account`.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| account | address | undefined |
|
||||
|
||||
### UpdateFeeVault
|
||||
|
||||
```solidity
|
||||
event UpdateFeeVault(address _oldFeeVault, address _newFeeVault)
|
||||
```
|
||||
|
||||
Emitted when owner updates fee vault contract.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _oldFeeVault | address | The address of old fee vault contract. |
|
||||
| _newFeeVault | address | The address of new fee vault contract. |
|
||||
|
||||
### UpdateMaxReplayTimes
|
||||
|
||||
```solidity
|
||||
event UpdateMaxReplayTimes(uint256 oldMaxReplayTimes, uint256 newMaxReplayTimes)
|
||||
```
|
||||
|
||||
Emitted when the maximum number of times each message can be replayed is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| oldMaxReplayTimes | uint256 | The old maximum number of times each message can be replayed. |
|
||||
| newMaxReplayTimes | uint256 | The new maximum number of times each message can be replayed. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,423 +0,0 @@
|
||||
# L1StandardERC20Gateway
|
||||
|
||||
|
||||
|
||||
> L1StandardERC20Gateway
|
||||
|
||||
The `L1StandardERC20Gateway` is used to deposit standard ERC20 tokens on layer 1 and finalize withdraw the tokens from layer 2.
|
||||
|
||||
*The deposited ERC20 tokens are held in this gateway. On finalizing withdraw, the corresponding token will be transfer to the recipient directly. Any ERC20 that requires non-standard functionality should use a separate gateway.*
|
||||
|
||||
## Methods
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### depositERC20
|
||||
|
||||
```solidity
|
||||
function depositERC20(address _token, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a caller's account on L2.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### depositERC20
|
||||
|
||||
```solidity
|
||||
function depositERC20(address _token, address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a recipient's account on L2.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _to | address | The address of recipient's account on L2. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### depositERC20AndCall
|
||||
|
||||
```solidity
|
||||
function depositERC20AndCall(address _token, address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a recipient's account on L2 and call.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _to | address | The address of recipient's account on L2. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _data | bytes | Optional data to forward to recipient's account. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### finalizeWithdrawERC20
|
||||
|
||||
```solidity
|
||||
function finalizeWithdrawERC20(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _data) external payable
|
||||
```
|
||||
|
||||
Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.
|
||||
|
||||
*Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding L1 token. |
|
||||
| _l2Token | address | The address of corresponding L2 token. |
|
||||
| _from | address | The address of account who withdraw the token in L2. |
|
||||
| _to | address | The address of recipient in L1 to receive the token. |
|
||||
| _amount | uint256 | The amount of the token to withdraw. |
|
||||
| _data | bytes | Optional data to forward to recipient's account. |
|
||||
|
||||
### getL2ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL2ERC20Address(address _l1Token) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l2 token address given l1 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of l1 token. |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _router, address _messenger, address, address) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of L1StandardERC20Gateway.
|
||||
|
||||
*The parameters `_counterpart`, `_router`, `_messenger`, `_l2TokenImplementation` and `_l2TokenFactory` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of L2StandardERC20Gateway in L2. |
|
||||
| _router | address | The address of L1GatewayRouter in L1. |
|
||||
| _messenger | address | The address of L1ScrollMessenger in L1. |
|
||||
| _3 | address | undefined |
|
||||
| _4 | address | undefined |
|
||||
|
||||
### l2TokenFactory
|
||||
|
||||
```solidity
|
||||
function l2TokenFactory() external view returns (address)
|
||||
```
|
||||
|
||||
The address of ScrollStandardERC20Factory contract in L2.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### l2TokenImplementation
|
||||
|
||||
```solidity
|
||||
function l2TokenImplementation() external view returns (address)
|
||||
```
|
||||
|
||||
The address of ScrollStandardERC20 implementation in L2.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### onDropMessage
|
||||
|
||||
```solidity
|
||||
function onDropMessage(bytes _message) external payable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _message | bytes | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### DepositERC20
|
||||
|
||||
```solidity
|
||||
event DepositERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone deposit ERC20 token from L1 to L2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of token will be deposited from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### FinalizeWithdrawERC20
|
||||
|
||||
```solidity
|
||||
event FinalizeWithdrawERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of token withdrawn from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### RefundERC20
|
||||
|
||||
```solidity
|
||||
event RefundERC20(address indexed token, address indexed recipient, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when some ERC20 token is refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of the token in L1. |
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| amount | uint256 | The amount of token refunded to receiver. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,421 +0,0 @@
|
||||
# L1WETHGateway
|
||||
|
||||
|
||||
|
||||
> L1WETHGateway
|
||||
|
||||
The `L1WETHGateway` contract is used to deposit `WETH` token on layer 1 and finalize withdraw `WETH` from layer 2.
|
||||
|
||||
*The deposited WETH tokens are not held in the gateway. It will first be unwrapped as Ether and then the Ether will be sent to the `L1ScrollMessenger` contract. On finalizing withdraw, the Ether will be transferred from `L1ScrollMessenger`, then wrapped as WETH and finally transfer to recipient.*
|
||||
|
||||
## Methods
|
||||
|
||||
### WETH
|
||||
|
||||
```solidity
|
||||
function WETH() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1 WETH address.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### depositERC20
|
||||
|
||||
```solidity
|
||||
function depositERC20(address _token, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a caller's account on L2.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### depositERC20
|
||||
|
||||
```solidity
|
||||
function depositERC20(address _token, address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a recipient's account on L2.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _to | address | The address of recipient's account on L2. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### depositERC20AndCall
|
||||
|
||||
```solidity
|
||||
function depositERC20AndCall(address _token, address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Deposit some token to a recipient's account on L2 and call.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token in L1. |
|
||||
| _to | address | The address of recipient's account on L2. |
|
||||
| _amount | uint256 | The amount of token to transfer. |
|
||||
| _data | bytes | Optional data to forward to recipient's account. |
|
||||
| _gasLimit | uint256 | Gas limit required to complete the deposit on L2. |
|
||||
|
||||
### finalizeWithdrawERC20
|
||||
|
||||
```solidity
|
||||
function finalizeWithdrawERC20(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _data) external payable
|
||||
```
|
||||
|
||||
Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.
|
||||
|
||||
*Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | The address of corresponding L1 token. |
|
||||
| _l2Token | address | The address of corresponding L2 token. |
|
||||
| _from | address | The address of account who withdraw the token in L2. |
|
||||
| _to | address | The address of recipient in L1 to receive the token. |
|
||||
| _amount | uint256 | The amount of the token to withdraw. |
|
||||
| _data | bytes | Optional data to forward to recipient's account. |
|
||||
|
||||
### getL2ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL2ERC20Address(address) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l2 token address given l1 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _router, address _messenger) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of L1WETHGateway.
|
||||
|
||||
*The parameters `_counterpart`, `_router` and `_messenger` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of L2ETHGateway in L2. |
|
||||
| _router | address | The address of L1GatewayRouter in L1. |
|
||||
| _messenger | address | The address of L1ScrollMessenger in L1. |
|
||||
|
||||
### l2WETH
|
||||
|
||||
```solidity
|
||||
function l2WETH() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L2 WETH address.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### onDropMessage
|
||||
|
||||
```solidity
|
||||
function onDropMessage(bytes _message) external payable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _message | bytes | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### DepositERC20
|
||||
|
||||
```solidity
|
||||
event DepositERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone deposit ERC20 token from L1 to L2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of token will be deposited from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### FinalizeWithdrawERC20
|
||||
|
||||
```solidity
|
||||
event FinalizeWithdrawERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of token withdrawn from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### RefundERC20
|
||||
|
||||
```solidity
|
||||
event RefundERC20(address indexed token, address indexed recipient, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when some ERC20 token is refunded.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of the token in L1. |
|
||||
| recipient `indexed` | address | The address of receiver in L1. |
|
||||
| amount | uint256 | The amount of token refunded to receiver. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,545 +0,0 @@
|
||||
# L2ERC1155Gateway
|
||||
|
||||
|
||||
|
||||
> L2ERC1155Gateway
|
||||
|
||||
The `L2ERC1155Gateway` is used to withdraw ERC1155 compatible NFTs on layer 2 and finalize deposit the NFTs from layer 1.
|
||||
|
||||
*The withdrawn NFTs tokens will be burned directly. On finalizing deposit, the corresponding NFT will be minted and transferred to the recipient. This will be changed if we have more specific scenarios.*
|
||||
|
||||
## Methods
|
||||
|
||||
### batchWithdrawERC1155
|
||||
|
||||
```solidity
|
||||
function batchWithdrawERC1155(address _token, uint256[] _tokenIds, uint256[] _amounts, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Batch withdraw a list of ERC1155 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _tokenIds | uint256[] | undefined |
|
||||
| _amounts | uint256[] | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### batchWithdrawERC1155
|
||||
|
||||
```solidity
|
||||
function batchWithdrawERC1155(address _token, address _to, uint256[] _tokenIds, uint256[] _amounts, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Batch withdraw a list of ERC1155 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenIds | uint256[] | undefined |
|
||||
| _amounts | uint256[] | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### finalizeBatchDepositERC1155
|
||||
|
||||
```solidity
|
||||
function finalizeBatchDepositERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds, uint256[] _amounts) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC1155Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | undefined |
|
||||
| _l2Token | address | undefined |
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenIds | uint256[] | undefined |
|
||||
| _amounts | uint256[] | undefined |
|
||||
|
||||
### finalizeDepositERC1155
|
||||
|
||||
```solidity
|
||||
function finalizeDepositERC1155(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId, uint256 _amount) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC1155 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC1155Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | undefined |
|
||||
| _l2Token | address | undefined |
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenId | uint256 | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _messenger) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of `L2ERC1155Gateway`.
|
||||
|
||||
*The parameters `_counterpart` and `_messenger` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of `L1ERC1155Gateway` contract in L1. |
|
||||
| _messenger | address | The address of `L2ScrollMessenger` contract in L2. |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### onERC1155BatchReceived
|
||||
|
||||
```solidity
|
||||
function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) external nonpayable returns (bytes4)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256[] | undefined |
|
||||
| _3 | uint256[] | undefined |
|
||||
| _4 | bytes | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes4 | undefined |
|
||||
|
||||
### onERC1155Received
|
||||
|
||||
```solidity
|
||||
function onERC1155Received(address, address, uint256, uint256, bytes) external nonpayable returns (bytes4)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256 | undefined |
|
||||
| _3 | uint256 | undefined |
|
||||
| _4 | bytes | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes4 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### supportsInterface
|
||||
|
||||
```solidity
|
||||
function supportsInterface(bytes4 interfaceId) external view returns (bool)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*See {IERC165-supportsInterface}.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| interfaceId | bytes4 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### tokenMapping
|
||||
|
||||
```solidity
|
||||
function tokenMapping(address) external view returns (address)
|
||||
```
|
||||
|
||||
Mapping from layer 2 token address to layer 1 token address for ERC1155 NFT.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### updateTokenMapping
|
||||
|
||||
```solidity
|
||||
function updateTokenMapping(address _l2Token, address _l1Token) external nonpayable
|
||||
```
|
||||
|
||||
Update layer 2 to layer 1 token mapping.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Token | address | The address of corresponding ERC1155 token on layer 2. |
|
||||
| _l1Token | address | The address of ERC1155 token on layer 1. |
|
||||
|
||||
### withdrawERC1155
|
||||
|
||||
```solidity
|
||||
function withdrawERC1155(address _token, uint256 _tokenId, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw some ERC1155 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _tokenId | uint256 | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC1155
|
||||
|
||||
```solidity
|
||||
function withdrawERC1155(address _token, address _to, uint256 _tokenId, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw some ERC1155 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenId | uint256 | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### BatchWithdrawERC1155
|
||||
|
||||
```solidity
|
||||
event BatchWithdrawERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds, uint256[] amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch transferred to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 2. |
|
||||
| to | address | The address of recipient on layer 1. |
|
||||
| tokenIds | uint256[] | The list of token ids of the ERC1155 NFT to withdraw on layer 2. |
|
||||
| amounts | uint256[] | The list of corresponding amounts to withdraw. |
|
||||
|
||||
### FinalizeBatchDepositERC1155
|
||||
|
||||
```solidity
|
||||
event FinalizeBatchDepositERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds, uint256[] amounts)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is batch transferred to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 1. |
|
||||
| to | address | The address of recipient on layer 2. |
|
||||
| tokenIds | uint256[] | The list of token ids of the ERC1155 NFT deposited on layer 1. |
|
||||
| amounts | uint256[] | The list of corresponding amounts deposited. |
|
||||
|
||||
### FinalizeDepositERC1155
|
||||
|
||||
```solidity
|
||||
event FinalizeDepositERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is transferred to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 1. |
|
||||
| to | address | The address of recipient on layer 2. |
|
||||
| tokenId | uint256 | The token id of the ERC1155 NFT deposited on layer 1. |
|
||||
| amount | uint256 | The amount of token deposited. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### UpdateTokenMapping
|
||||
|
||||
```solidity
|
||||
event UpdateTokenMapping(address indexed l2Token, address indexed oldL1Token, address indexed newL1Token)
|
||||
```
|
||||
|
||||
Emitted when token mapping for ERC1155 token is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l2Token `indexed` | address | The address of corresponding ERC1155 token in layer 2. |
|
||||
| oldL1Token `indexed` | address | The address of the old corresponding ERC1155 token in layer 1. |
|
||||
| newL1Token `indexed` | address | The address of the new corresponding ERC1155 token in layer 1. |
|
||||
|
||||
### WithdrawERC1155
|
||||
|
||||
```solidity
|
||||
event WithdrawERC1155(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId, uint256 amount)
|
||||
```
|
||||
|
||||
Emitted when the ERC1155 NFT is transferred to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC1155 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC1155 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 2. |
|
||||
| to | address | The address of recipient on layer 1. |
|
||||
| tokenId | uint256 | The token id of the ERC1155 NFT to withdraw on layer 2. |
|
||||
| amount | uint256 | The amount of token to withdraw. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,486 +0,0 @@
|
||||
# L2ERC721Gateway
|
||||
|
||||
|
||||
|
||||
> L2ERC721Gateway
|
||||
|
||||
The `L2ERC721Gateway` is used to withdraw ERC721 compatible NFTs on layer 2 and finalize deposit the NFTs from layer 1.
|
||||
|
||||
*The withdrawn NFTs tokens will be burned directly. On finalizing deposit, the corresponding NFT will be minted and transferred to the recipient. This will be changed if we have more specific scenarios.*
|
||||
|
||||
## Methods
|
||||
|
||||
### batchWithdrawERC721
|
||||
|
||||
```solidity
|
||||
function batchWithdrawERC721(address _token, uint256[] _tokenIds, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Batch withdraw a list of ERC721 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _tokenIds | uint256[] | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### batchWithdrawERC721
|
||||
|
||||
```solidity
|
||||
function batchWithdrawERC721(address _token, address _to, uint256[] _tokenIds, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Batch withdraw a list of ERC721 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenIds | uint256[] | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### finalizeBatchDepositERC721
|
||||
|
||||
```solidity
|
||||
function finalizeBatchDepositERC721(address _l1Token, address _l2Token, address _from, address _to, uint256[] _tokenIds) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC721Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | undefined |
|
||||
| _l2Token | address | undefined |
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenIds | uint256[] | undefined |
|
||||
|
||||
### finalizeDepositERC721
|
||||
|
||||
```solidity
|
||||
function finalizeDepositERC721(address _l1Token, address _l2Token, address _from, address _to, uint256 _tokenId) external nonpayable
|
||||
```
|
||||
|
||||
Complete ERC721 deposit from layer 1 to layer 2 and send NFT to recipient's account on layer 2.
|
||||
|
||||
*Requirements: - The function should only be called by L2ScrollMessenger. - The function should also only be called by L1ERC721Gateway on layer 1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | undefined |
|
||||
| _l2Token | address | undefined |
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenId | uint256 | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _messenger) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of `L2ERC721Gateway`.
|
||||
|
||||
*The parameters `_counterpart` and `_messenger` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of `L1ERC721Gateway` contract in L1. |
|
||||
| _messenger | address | The address of `L2ScrollMessenger` contract in L2. |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### onERC721Received
|
||||
|
||||
```solidity
|
||||
function onERC721Received(address, address, uint256, bytes) external nonpayable returns (bytes4)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*See {IERC721Receiver-onERC721Received}. Always returns `IERC721Receiver.onERC721Received.selector`.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256 | undefined |
|
||||
| _3 | bytes | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes4 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### tokenMapping
|
||||
|
||||
```solidity
|
||||
function tokenMapping(address) external view returns (address)
|
||||
```
|
||||
|
||||
Mapping from layer 2 token address to layer 1 token address for ERC721 NFT.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### updateTokenMapping
|
||||
|
||||
```solidity
|
||||
function updateTokenMapping(address _l2Token, address _l1Token) external nonpayable
|
||||
```
|
||||
|
||||
Update layer 2 to layer 1 token mapping.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Token | address | The address of corresponding ERC721 token on layer 2. |
|
||||
| _l1Token | address | The address of ERC721 token on layer 1. |
|
||||
|
||||
### withdrawERC721
|
||||
|
||||
```solidity
|
||||
function withdrawERC721(address _token, uint256 _tokenId, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw some ERC721 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _tokenId | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC721
|
||||
|
||||
```solidity
|
||||
function withdrawERC721(address _token, address _to, uint256 _tokenId, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw some ERC721 NFT to caller's account on layer 1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _tokenId | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### BatchWithdrawERC721
|
||||
|
||||
```solidity
|
||||
event BatchWithdrawERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch transferred to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 2. |
|
||||
| to | address | The address of recipient on layer 1. |
|
||||
| tokenIds | uint256[] | The list of token ids of the ERC721 NFT to withdraw on layer 2. |
|
||||
|
||||
### FinalizeBatchDepositERC721
|
||||
|
||||
```solidity
|
||||
event FinalizeBatchDepositERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256[] tokenIds)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is batch transferred to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 1. |
|
||||
| to | address | The address of recipient on layer 2. |
|
||||
| tokenIds | uint256[] | The list of token ids of the ERC721 NFT deposited on layer 1. |
|
||||
|
||||
### FinalizeDepositERC721
|
||||
|
||||
```solidity
|
||||
event FinalizeDepositERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is transferred to recipient on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 1. |
|
||||
| to | address | The address of recipient on layer 2. |
|
||||
| tokenId | uint256 | The token id of the ERC721 NFT deposited on layer 1. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### UpdateTokenMapping
|
||||
|
||||
```solidity
|
||||
event UpdateTokenMapping(address indexed l2Token, address indexed oldL1Token, address indexed newL1Token)
|
||||
```
|
||||
|
||||
Emitted when token mapping for ERC721 token is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l2Token `indexed` | address | The address of corresponding ERC721 token in layer 2. |
|
||||
| oldL1Token `indexed` | address | The address of the old corresponding ERC721 token in layer 1. |
|
||||
| newL1Token `indexed` | address | The address of the new corresponding ERC721 token in layer 1. |
|
||||
|
||||
### WithdrawERC721
|
||||
|
||||
```solidity
|
||||
event WithdrawERC721(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 tokenId)
|
||||
```
|
||||
|
||||
Emitted when the ERC721 NFT is transferred to gateway on layer 2.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of ERC721 NFT on layer 1. |
|
||||
| l2Token `indexed` | address | The address of ERC721 NFT on layer 2. |
|
||||
| from `indexed` | address | The address of sender on layer 2. |
|
||||
| to | address | The address of recipient on layer 1. |
|
||||
| tokenId | uint256 | The token id of the ERC721 NFT to withdraw on layer 2. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,566 +0,0 @@
|
||||
# L2GatewayRouter
|
||||
|
||||
|
||||
|
||||
> L2GatewayRouter
|
||||
|
||||
The `L2GatewayRouter` is the main entry for withdrawing Ether and ERC20 tokens. All deposited tokens are routed to corresponding gateways.
|
||||
|
||||
*One can also use this contract to query L1/L2 token address mapping. In the future, ERC-721 and ERC-1155 tokens will be added to the router too.*
|
||||
|
||||
## Methods
|
||||
|
||||
### ERC20Gateway
|
||||
|
||||
```solidity
|
||||
function ERC20Gateway(address) external view returns (address)
|
||||
```
|
||||
|
||||
Mapping from L2 ERC20 token address to corresponding L2ERC20Gateway.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### defaultERC20Gateway
|
||||
|
||||
```solidity
|
||||
function defaultERC20Gateway() external view returns (address)
|
||||
```
|
||||
|
||||
The addess of default L2 ERC20 gateway, normally the L2StandardERC20Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### ethGateway
|
||||
|
||||
```solidity
|
||||
function ethGateway() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L2ETHGateway.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### finalizeDepositERC20
|
||||
|
||||
```solidity
|
||||
function finalizeDepositERC20(address, address, address, address, uint256, bytes) external payable
|
||||
```
|
||||
|
||||
Complete a deposit from L1 to L2 and send fund to recipient's account in L2.
|
||||
|
||||
*Make this function payable to handle WETH deposit/withdraw. The function should only be called by L2ScrollMessenger. The function should also only be called by L1ERC20Gateway in L1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | address | undefined |
|
||||
| _3 | address | undefined |
|
||||
| _4 | uint256 | undefined |
|
||||
| _5 | bytes | undefined |
|
||||
|
||||
### finalizeDepositETH
|
||||
|
||||
```solidity
|
||||
function finalizeDepositETH(address, address, uint256, bytes) external payable
|
||||
```
|
||||
|
||||
Complete ETH deposit from L1 to L2 and send fund to recipient's account in L2.
|
||||
|
||||
*This function should only be called by L2ScrollMessenger. This function should also only be called by L1GatewayRouter in L1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
| _1 | address | undefined |
|
||||
| _2 | uint256 | undefined |
|
||||
| _3 | bytes | undefined |
|
||||
|
||||
### getERC20Gateway
|
||||
|
||||
```solidity
|
||||
function getERC20Gateway(address _token) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding gateway address for given token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | The address of token to query. |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### getL1ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL1ERC20Address(address _l2Address) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l1 token address given l2 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Address | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### getL2ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL2ERC20Address(address) external pure returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l2 token address given l1 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _ethGateway, address _defaultERC20Gateway) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _ethGateway | address | undefined |
|
||||
| _defaultERC20Gateway | address | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### setDefaultERC20Gateway
|
||||
|
||||
```solidity
|
||||
function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external nonpayable
|
||||
```
|
||||
|
||||
Update the address of default ERC20 gateway contract.
|
||||
|
||||
*This function should only be called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _newDefaultERC20Gateway | address | The address to update. |
|
||||
|
||||
### setERC20Gateway
|
||||
|
||||
```solidity
|
||||
function setERC20Gateway(address[] _tokens, address[] _gateways) external nonpayable
|
||||
```
|
||||
|
||||
Update the mapping from token address to gateway address.
|
||||
|
||||
*This function should only be called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _tokens | address[] | The list of addresses of tokens to update. |
|
||||
| _gateways | address[] | The list of addresses of gateways to update. |
|
||||
|
||||
### setETHGateway
|
||||
|
||||
```solidity
|
||||
function setETHGateway(address _newEthGateway) external nonpayable
|
||||
```
|
||||
|
||||
Update the address of ETH gateway contract.
|
||||
|
||||
*This function should only be called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _newEthGateway | address | The address to update. |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### withdrawERC20
|
||||
|
||||
```solidity
|
||||
function withdrawERC20(address _token, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a caller's account on L1.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC20
|
||||
|
||||
```solidity
|
||||
function withdrawERC20(address _token, address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a recipient's account on L1.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC20AndCall
|
||||
|
||||
```solidity
|
||||
function withdrawERC20AndCall(address _token, address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a recipient's account on L1 and call.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _data | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawETH
|
||||
|
||||
```solidity
|
||||
function withdrawETH(address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw ETH to caller's account in L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawETH
|
||||
|
||||
```solidity
|
||||
function withdrawETH(uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw ETH to caller's account in L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawETHAndCall
|
||||
|
||||
```solidity
|
||||
function withdrawETHAndCall(address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw ETH to caller's account in L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _data | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### FinalizeDepositERC20
|
||||
|
||||
```solidity
|
||||
event FinalizeDepositERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ERC20 token is deposited from L1 to L2 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of token withdrawn from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### FinalizeDepositETH
|
||||
|
||||
```solidity
|
||||
event FinalizeDepositETH(address indexed from, address indexed to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ETH is deposited from L1 to L2 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to `indexed` | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of ETH deposited from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### SetDefaultERC20Gateway
|
||||
|
||||
```solidity
|
||||
event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway)
|
||||
```
|
||||
|
||||
Emitted when the address of default ERC20 Gateway is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| oldDefaultERC20Gateway `indexed` | address | The address of the old default ERC20 Gateway. |
|
||||
| newDefaultERC20Gateway `indexed` | address | The address of the new default ERC20 Gateway. |
|
||||
|
||||
### SetERC20Gateway
|
||||
|
||||
```solidity
|
||||
event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway)
|
||||
```
|
||||
|
||||
Emitted when the `gateway` for `token` is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | The address of token updated. |
|
||||
| oldGateway `indexed` | address | The corresponding address of the old gateway. |
|
||||
| newGateway `indexed` | address | The corresponding address of the new gateway. |
|
||||
|
||||
### SetETHGateway
|
||||
|
||||
```solidity
|
||||
event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway)
|
||||
```
|
||||
|
||||
Emitted when the address of ETH Gateway is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| oldETHGateway `indexed` | address | The address of the old ETH Gateway. |
|
||||
| newEthGateway `indexed` | address | The address of the new ETH Gateway. |
|
||||
|
||||
### WithdrawERC20
|
||||
|
||||
```solidity
|
||||
event WithdrawERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone withdraw ERC20 token from L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of token will be deposited from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
### WithdrawETH
|
||||
|
||||
```solidity
|
||||
event WithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone withdraw ETH from L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to `indexed` | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of ETH will be deposited from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
|
||||
|
||||
@@ -1,464 +0,0 @@
|
||||
# L2ScrollMessenger
|
||||
|
||||
|
||||
|
||||
> L2ScrollMessenger
|
||||
|
||||
The `L2ScrollMessenger` contract can: 1. send messages from layer 2 to layer 1; 2. relay messages from layer 1 layer 2; 3. drop expired message due to sequencer problems.
|
||||
|
||||
*It should be a predeployed contract on layer 2 and should hold infinite amount of Ether (Specifically, `uint256(-1)`), which can be initialized in Genesis Block.*
|
||||
|
||||
## Methods
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of counterpart ScrollMessenger contract in L1/L2.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### feeVault
|
||||
|
||||
```solidity
|
||||
function feeVault() external view returns (address)
|
||||
```
|
||||
|
||||
The address of fee vault, collecting cross domain messaging fee.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### isL1MessageExecuted
|
||||
|
||||
```solidity
|
||||
function isL1MessageExecuted(bytes32) external view returns (bool)
|
||||
```
|
||||
|
||||
Mapping from L1 message hash to a boolean value indicating if the message has been successfully executed.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes32 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### messageQueue
|
||||
|
||||
```solidity
|
||||
function messageQueue() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L2MessageQueue.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### messageSendTimestamp
|
||||
|
||||
```solidity
|
||||
function messageSendTimestamp(bytes32) external view returns (uint256)
|
||||
```
|
||||
|
||||
Mapping from L2 message hash to the timestamp when the message is sent.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes32 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### paused
|
||||
|
||||
```solidity
|
||||
function paused() external view returns (bool)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns true if the contract is paused, and false otherwise.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### relayMessage
|
||||
|
||||
```solidity
|
||||
function relayMessage(address _from, address _to, uint256 _value, uint256 _nonce, bytes _message) external nonpayable
|
||||
```
|
||||
|
||||
execute L1 => L2 message
|
||||
|
||||
*Make sure this is only called by privileged accounts.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _nonce | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### sendMessage
|
||||
|
||||
```solidity
|
||||
function sendMessage(address _to, uint256 _value, bytes _message, uint256 _gasLimit, address) external payable
|
||||
```
|
||||
|
||||
Send cross chain message from L1 to L2 or L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
| _4 | address | undefined |
|
||||
|
||||
### sendMessage
|
||||
|
||||
```solidity
|
||||
function sendMessage(address _to, uint256 _value, bytes _message, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Send cross chain message from L1 to L2 or L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _to | address | undefined |
|
||||
| _value | uint256 | undefined |
|
||||
| _message | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### setPause
|
||||
|
||||
```solidity
|
||||
function setPause(bool _status) external nonpayable
|
||||
```
|
||||
|
||||
Pause the contract
|
||||
|
||||
*This function can only called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _status | bool | The pause status to update. |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### updateFeeVault
|
||||
|
||||
```solidity
|
||||
function updateFeeVault(address _newFeeVault) external nonpayable
|
||||
```
|
||||
|
||||
Update fee vault contract.
|
||||
|
||||
*This function can only called by contract owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _newFeeVault | address | The address of new fee vault contract. |
|
||||
|
||||
### xDomainMessageSender
|
||||
|
||||
```solidity
|
||||
function xDomainMessageSender() external view returns (address)
|
||||
```
|
||||
|
||||
See {IScrollMessenger-xDomainMessageSender}
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### FailedRelayedMessage
|
||||
|
||||
```solidity
|
||||
event FailedRelayedMessage(bytes32 indexed messageHash)
|
||||
```
|
||||
|
||||
Emitted when a cross domain message is failed to relay.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| messageHash `indexed` | bytes32 | The hash of the message. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### Paused
|
||||
|
||||
```solidity
|
||||
event Paused(address account)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Emitted when the pause is triggered by `account`.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| account | address | undefined |
|
||||
|
||||
### RelayedMessage
|
||||
|
||||
```solidity
|
||||
event RelayedMessage(bytes32 indexed messageHash)
|
||||
```
|
||||
|
||||
Emitted when a cross domain message is relayed successfully.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| messageHash `indexed` | bytes32 | The hash of the message. |
|
||||
|
||||
### SentMessage
|
||||
|
||||
```solidity
|
||||
event SentMessage(address indexed sender, address indexed target, uint256 value, uint256 messageNonce, uint256 gasLimit, bytes message)
|
||||
```
|
||||
|
||||
Emitted when a cross domain message is sent.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| sender `indexed` | address | The address of the sender who initiates the message. |
|
||||
| target `indexed` | address | The address of target contract to call. |
|
||||
| value | uint256 | The amount of value passed to the target contract. |
|
||||
| messageNonce | uint256 | The nonce of the message. |
|
||||
| gasLimit | uint256 | The optional gas limit passed to L1 or L2. |
|
||||
| message | bytes | The calldata passed to the target contract. |
|
||||
|
||||
### Unpaused
|
||||
|
||||
```solidity
|
||||
event Unpaused(address account)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Emitted when the pause is lifted by `account`.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| account | address | undefined |
|
||||
|
||||
### UpdateFeeVault
|
||||
|
||||
```solidity
|
||||
event UpdateFeeVault(address _oldFeeVault, address _newFeeVault)
|
||||
```
|
||||
|
||||
Emitted when owner updates fee vault contract.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _oldFeeVault | address | The address of old fee vault contract. |
|
||||
| _newFeeVault | address | The address of new fee vault contract. |
|
||||
|
||||
### UpdateMaxFailedExecutionTimes
|
||||
|
||||
```solidity
|
||||
event UpdateMaxFailedExecutionTimes(uint256 oldMaxFailedExecutionTimes, uint256 newMaxFailedExecutionTimes)
|
||||
```
|
||||
|
||||
Emitted when the maximum number of times each message can fail in L2 is updated.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| oldMaxFailedExecutionTimes | uint256 | The old maximum number of times each message can fail in L2. |
|
||||
| newMaxFailedExecutionTimes | uint256 | The new maximum number of times each message can fail in L2. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,393 +0,0 @@
|
||||
# L2StandardERC20Gateway
|
||||
|
||||
|
||||
|
||||
> L2StandardERC20Gateway
|
||||
|
||||
The `L2StandardERC20Gateway` is used to withdraw standard ERC20 tokens on layer 2 and finalize deposit the tokens from layer 1.
|
||||
|
||||
*The withdrawn ERC20 tokens will be burned directly. On finalizing deposit, the corresponding token will be minted and transferred to the recipient. Any ERC20 that requires non-standard functionality should use a separate gateway.*
|
||||
|
||||
## Methods
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### finalizeDepositERC20
|
||||
|
||||
```solidity
|
||||
function finalizeDepositERC20(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _data) external payable
|
||||
```
|
||||
|
||||
Complete a deposit from L1 to L2 and send fund to recipient's account in L2.
|
||||
|
||||
*Make this function payable to handle WETH deposit/withdraw. The function should only be called by L2ScrollMessenger. The function should also only be called by L1ERC20Gateway in L1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | undefined |
|
||||
| _l2Token | address | undefined |
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _data | bytes | undefined |
|
||||
|
||||
### getL1ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL1ERC20Address(address _l2Token) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l1 token address given l2 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l2Token | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### getL2ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL2ERC20Address(address _l1Token) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l2 token address given l1 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _router, address _messenger, address) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of L2StandardERC20Gateway.
|
||||
|
||||
*The parameters `_counterpart`, `_router`, `_messenger` and `_tokenFactory` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of `L1StandardERC20Gateway` contract in L1. |
|
||||
| _router | address | The address of `L2GatewayRouter` contract in L2. |
|
||||
| _messenger | address | The address of `L2ScrollMessenger` contract in L2. |
|
||||
| _3 | address | undefined |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### tokenFactory
|
||||
|
||||
```solidity
|
||||
function tokenFactory() external view returns (address)
|
||||
```
|
||||
|
||||
The address of ScrollStandardERC20Factory.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### withdrawERC20
|
||||
|
||||
```solidity
|
||||
function withdrawERC20(address _token, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a caller's account on L1.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC20
|
||||
|
||||
```solidity
|
||||
function withdrawERC20(address _token, address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a recipient's account on L1.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC20AndCall
|
||||
|
||||
```solidity
|
||||
function withdrawERC20AndCall(address _token, address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a recipient's account on L1 and call.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _data | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### FinalizeDepositERC20
|
||||
|
||||
```solidity
|
||||
event FinalizeDepositERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ERC20 token is deposited from L1 to L2 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of token withdrawn from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### WithdrawERC20
|
||||
|
||||
```solidity
|
||||
event WithdrawERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone withdraw ERC20 token from L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of token will be deposited from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
@@ -1,409 +0,0 @@
|
||||
# L2WETHGateway
|
||||
|
||||
|
||||
|
||||
> L2WETHGateway
|
||||
|
||||
The `L2WETHGateway` contract is used to withdraw `WETH` token on layer 2 and finalize deposit `WETH` from layer 1.
|
||||
|
||||
*The WETH tokens are not held in the gateway. It will first be unwrapped as Ether and then the Ether will be sent to the `L2ScrollMessenger` contract. On finalizing deposit, the Ether will be transferred from `L2ScrollMessenger`, then wrapped as WETH and finally transfer to recipient.*
|
||||
|
||||
## Methods
|
||||
|
||||
### WETH
|
||||
|
||||
```solidity
|
||||
function WETH() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L2 WETH address.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### counterpart
|
||||
|
||||
```solidity
|
||||
function counterpart() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1/L2 Gateway contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### finalizeDepositERC20
|
||||
|
||||
```solidity
|
||||
function finalizeDepositERC20(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _data) external payable
|
||||
```
|
||||
|
||||
Complete a deposit from L1 to L2 and send fund to recipient's account in L2.
|
||||
|
||||
*Make this function payable to handle WETH deposit/withdraw. The function should only be called by L2ScrollMessenger. The function should also only be called by L1ERC20Gateway in L1.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token | address | undefined |
|
||||
| _l2Token | address | undefined |
|
||||
| _from | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _data | bytes | undefined |
|
||||
|
||||
### getL1ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL1ERC20Address(address) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l1 token address given l2 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### getL2ERC20Address
|
||||
|
||||
```solidity
|
||||
function getL2ERC20Address(address) external view returns (address)
|
||||
```
|
||||
|
||||
Return the corresponding l2 token address given l1 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### initialize
|
||||
|
||||
```solidity
|
||||
function initialize(address _counterpart, address _router, address _messenger) external nonpayable
|
||||
```
|
||||
|
||||
Initialize the storage of `L2WETHGateway`.
|
||||
|
||||
*The parameters `_counterpart`, `_router` and `_messenger` are no longer used.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _counterpart | address | The address of `L1WETHGateway` contract in L1. |
|
||||
| _router | address | The address of `L2GatewayRouter` contract in L2. |
|
||||
| _messenger | address | The address of `L2ScrollMessenger` contract in L2. |
|
||||
|
||||
### l1WETH
|
||||
|
||||
```solidity
|
||||
function l1WETH() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1 WETH address.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### messenger
|
||||
|
||||
```solidity
|
||||
function messenger() external view returns (address)
|
||||
```
|
||||
|
||||
The address of corresponding L1ScrollMessenger/L2ScrollMessenger contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### router
|
||||
|
||||
```solidity
|
||||
function router() external view returns (address)
|
||||
```
|
||||
|
||||
The address of L1GatewayRouter/L2GatewayRouter contract.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### withdrawERC20
|
||||
|
||||
```solidity
|
||||
function withdrawERC20(address _token, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a caller's account on L1.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC20
|
||||
|
||||
```solidity
|
||||
function withdrawERC20(address _token, address _to, uint256 _amount, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a recipient's account on L1.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
### withdrawERC20AndCall
|
||||
|
||||
```solidity
|
||||
function withdrawERC20AndCall(address _token, address _to, uint256 _amount, bytes _data, uint256 _gasLimit) external payable
|
||||
```
|
||||
|
||||
Withdraw of some token to a recipient's account on L1 and call.
|
||||
|
||||
*Make this function payable to send relayer fee in Ether.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _token | address | undefined |
|
||||
| _to | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _data | bytes | undefined |
|
||||
| _gasLimit | uint256 | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### FinalizeDepositERC20
|
||||
|
||||
```solidity
|
||||
event FinalizeDepositERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when ERC20 token is deposited from L1 to L2 and transfer to recipient.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L1. |
|
||||
| to | address | The address of recipient in L2. |
|
||||
| amount | uint256 | The amount of token withdrawn from L1 to L2. |
|
||||
| data | bytes | The optional calldata passed to recipient in L2. |
|
||||
|
||||
### Initialized
|
||||
|
||||
```solidity
|
||||
event Initialized(uint8 version)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Triggered when the contract has been initialized or reinitialized.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| version | uint8 | undefined |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### WithdrawERC20
|
||||
|
||||
```solidity
|
||||
event WithdrawERC20(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes data)
|
||||
```
|
||||
|
||||
Emitted when someone withdraw ERC20 token from L2 to L1.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| l1Token `indexed` | address | The address of the token in L1. |
|
||||
| l2Token `indexed` | address | The address of the token in L2. |
|
||||
| from `indexed` | address | The address of sender in L2. |
|
||||
| to | address | The address of recipient in L1. |
|
||||
| amount | uint256 | The amount of token will be deposited from L2 to L1. |
|
||||
| data | bytes | The optional calldata passed to recipient in L1. |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### ErrorCallerIsNotCounterpartGateway
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotCounterpartGateway()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the cross chain sender is not the counterpart gateway contract.*
|
||||
|
||||
|
||||
### ErrorCallerIsNotMessenger
|
||||
|
||||
```solidity
|
||||
error ErrorCallerIsNotMessenger()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the caller is not corresponding `L1ScrollMessenger` or `L2ScrollMessenger`.*
|
||||
|
||||
|
||||
### ErrorNotInDropMessageContext
|
||||
|
||||
```solidity
|
||||
error ErrorNotInDropMessageContext()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when ScrollMessenger is not dropping message.*
|
||||
|
||||
|
||||
### ErrorZeroAddress
|
||||
|
||||
```solidity
|
||||
error ErrorZeroAddress()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Thrown when the given address is `address(0)`.*
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,159 +0,0 @@
|
||||
# ScrollStandardERC20Factory
|
||||
|
||||
|
||||
|
||||
> ScrollStandardERC20Factory
|
||||
|
||||
The `ScrollStandardERC20Factory` is used to deploy `ScrollStandardERC20` for `L2StandardERC20Gateway`. It uses the `Clones` contract to deploy contract with minimum gas usage.
|
||||
|
||||
*The implementation of deployed token is non-upgradable. This design may be changed in the future.*
|
||||
|
||||
## Methods
|
||||
|
||||
### computeL2TokenAddress
|
||||
|
||||
```solidity
|
||||
function computeL2TokenAddress(address _gateway, address _l1Token) external view returns (address)
|
||||
```
|
||||
|
||||
Compute the corresponding l2 token address given l1 token address.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _gateway | address | The address of gateway contract. |
|
||||
| _l1Token | address | The address of l1 token. |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### deployL2Token
|
||||
|
||||
```solidity
|
||||
function deployL2Token(address _gateway, address _l1Token) external nonpayable returns (address)
|
||||
```
|
||||
|
||||
Deploy the corresponding l2 token address given l1 token address.
|
||||
|
||||
*This function should only be called by owner to avoid DDoS attack on StandardTokenBridge.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _gateway | address | The address of gateway contract. |
|
||||
| _l1Token | address | The address of l1 token. |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### implementation
|
||||
|
||||
```solidity
|
||||
function implementation() external view returns (address)
|
||||
```
|
||||
|
||||
The address of `ScrollStandardERC20` implementation.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Returns the address of the current owner.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### renounceOwnership
|
||||
|
||||
```solidity
|
||||
function renounceOwnership() external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.*
|
||||
|
||||
|
||||
### transferOwnership
|
||||
|
||||
```solidity
|
||||
function transferOwnership(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### DeployToken
|
||||
|
||||
```solidity
|
||||
event DeployToken(address indexed _l1Token, address indexed _l2Token)
|
||||
```
|
||||
|
||||
Emitted when a l2 token is deployed.
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _l1Token `indexed` | address | The address of the l1 token. |
|
||||
| _l2Token `indexed` | address | The address of the l2 token. |
|
||||
|
||||
### OwnershipTransferred
|
||||
|
||||
```solidity
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| previousOwner `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
[profile.default]
|
||||
src = 'src' # the source directory
|
||||
test = 'src/test' # the test directory
|
||||
script = 'scripts' # the script directory
|
||||
out = 'artifacts/src' # the output directory (for artifacts)
|
||||
libs = [] # a list of library directories
|
||||
remappings = [] # a list of remappings
|
||||
libraries = [] # a list of deployed libraries to link against
|
||||
cache = true # whether to cache builds or not
|
||||
force = true # whether to ignore the cache (clean build)
|
||||
# evm_version = 'london' # the evm version (by hardfork name)
|
||||
solc_version = '0.8.24' # override for the solc version (setting this ignores `auto_detect_solc`)
|
||||
optimizer = true # enable or disable the solc optimizer
|
||||
optimizer_runs = 200 # the number of optimizer runs
|
||||
verbosity = 2 # the verbosity of tests
|
||||
ignored_error_codes = [] # a list of ignored solc error codes
|
||||
fuzz_runs = 256 # the number of fuzz runs for tests
|
||||
ffi = false # whether to enable ffi or not
|
||||
sender = '0x00a329c0648769a73afac7f9381e08fb43dbea72' # the address of `msg.sender` in tests
|
||||
tx_origin = '0x00a329c0648769a73afac7f9381e08fb43dbea72' # the address of `tx.origin` in tests
|
||||
initial_balance = '0xffffffffffffffffffffffff' # the initial balance of the test contract
|
||||
block_number = 0 # the block number we are at in tests
|
||||
gas_limit = 9223372036854775807 # the gas limit in tests
|
||||
gas_price = 0 # the gas price (in wei) in tests
|
||||
block_base_fee_per_gas = 0 # the base fee (in wei) in tests
|
||||
block_coinbase = '0x0000000000000000000000000000000000000000' # the address of `block.coinbase` in tests
|
||||
block_timestamp = 0 # the value of `block.timestamp` in tests
|
||||
block_difficulty = 0 # the value of `block.difficulty` in tests
|
||||
|
||||
gas_reports = ["L2GasPriceOracle"]
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"blockHash": "0x3e721eda79f26bf40cd915aad0c85d501849215ad907d2e38acff524847300ab",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"baseFee": "0x3b9aca00",
|
||||
"stateRoot": "0x183cbfdab83f8884b7cfbe234cb99bbd654d4fb18bd9c9f01e94ebf859957739",
|
||||
"blockHeight": 0,
|
||||
"gasUsed": 0,
|
||||
"timestamp": "0x61bc34a0",
|
||||
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000004cb1ab63af5d8931ce09673ebd8ae2ce16fd6571adf5218f7ca8c80d90ff63af5fef486af57c20960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
import { HardhatUserConfig, subtask } from "hardhat/config";
|
||||
import * as toml from "toml";
|
||||
import "@nomicfoundation/hardhat-verify";
|
||||
import "@nomicfoundation/hardhat-ethers";
|
||||
import "@nomicfoundation/hardhat-chai-matchers";
|
||||
import "@typechain/hardhat";
|
||||
import "@primitivefi/hardhat-dodoc";
|
||||
import "hardhat-gas-reporter";
|
||||
import "solidity-coverage";
|
||||
import { readFileSync } from "fs";
|
||||
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const L1_DEPLOYER_PRIVATE_KEY = process.env.L1_DEPLOYER_PRIVATE_KEY || "1".repeat(64);
|
||||
const L2_DEPLOYER_PRIVATE_KEY = process.env.L2_DEPLOYER_PRIVATE_KEY || "1".repeat(64);
|
||||
|
||||
const SOLC_DEFAULT = "0.8.24";
|
||||
|
||||
// try use forge config
|
||||
let foundry: any;
|
||||
try {
|
||||
foundry = toml.parse(readFileSync("./foundry.toml").toString());
|
||||
foundry.default.solc = foundry.default["solc-version"] ? foundry.default["solc-version"] : SOLC_DEFAULT;
|
||||
} catch (error) {
|
||||
foundry = {
|
||||
default: {
|
||||
solc: SOLC_DEFAULT,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// prune forge style tests from hardhat paths
|
||||
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, __, runSuper) => {
|
||||
const paths = await runSuper();
|
||||
return paths.filter((p: string) => !p.endsWith(".t.sol")).filter((p: string) => !p.includes("test/mocks"));
|
||||
});
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: {
|
||||
version: foundry.default?.solc_version || SOLC_DEFAULT,
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: foundry.default?.optimizer || true,
|
||||
runs: foundry.default?.optimizer_runs || 200,
|
||||
},
|
||||
evmVersion: "cancun",
|
||||
},
|
||||
},
|
||||
networks: {
|
||||
ethereum: {
|
||||
url: "https://1rpc.io/eth",
|
||||
accounts: [L1_DEPLOYER_PRIVATE_KEY],
|
||||
},
|
||||
sepolia: {
|
||||
url: "https://1rpc.io/sepolia",
|
||||
accounts: [L1_DEPLOYER_PRIVATE_KEY],
|
||||
},
|
||||
scroll: {
|
||||
url: "https://rpc.scroll.io",
|
||||
accounts: [L2_DEPLOYER_PRIVATE_KEY],
|
||||
},
|
||||
scroll_sepolia: {
|
||||
url: "https://sepolia-rpc.scroll.io",
|
||||
accounts: [L2_DEPLOYER_PRIVATE_KEY],
|
||||
},
|
||||
},
|
||||
paths: {
|
||||
cache: "./cache-hardhat",
|
||||
sources: "./src",
|
||||
tests: "./integration-test",
|
||||
},
|
||||
typechain: {
|
||||
outDir: "./typechain",
|
||||
target: "ethers-v6",
|
||||
},
|
||||
gasReporter: {
|
||||
enabled: process.env.REPORT_GAS !== undefined,
|
||||
excludeContracts: ["src/test"],
|
||||
currency: "USD",
|
||||
},
|
||||
etherscan: {
|
||||
apiKey: {
|
||||
ethereum: process.env.ETHERSCAN_API_KEY || "",
|
||||
sepolia: process.env.ETHERSCAN_API_KEY || "",
|
||||
scroll: process.env.SCROLLSCAN_API_KEY || "",
|
||||
scroll_sepolia: process.env.SCROLLSCAN_API_KEY || "",
|
||||
},
|
||||
customChains: [
|
||||
{
|
||||
network: "scroll",
|
||||
chainId: 534352,
|
||||
urls: {
|
||||
apiURL: "https://api.scrollscan.com/api",
|
||||
browserURL: "https://www.scrollscan.com/",
|
||||
},
|
||||
},
|
||||
{
|
||||
network: "scroll_sepolia",
|
||||
chainId: 534351,
|
||||
urls: {
|
||||
apiURL: "https://api-sepolia.scrollscan.com/api",
|
||||
browserURL: "https://sepolia.scrollscan.com/",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
mocha: {
|
||||
timeout: 10000000,
|
||||
},
|
||||
dodoc: {
|
||||
runOnCompile: true,
|
||||
keepFileStructure: false,
|
||||
include: [
|
||||
"ScrollChain",
|
||||
"L1ScrollMessenger",
|
||||
"L2ScrollMessenger",
|
||||
"L1GatewayRouter",
|
||||
"L2GatewayRouter",
|
||||
"L1StandardERC20Gateway",
|
||||
"L2StandardERC20Gateway",
|
||||
"L1ERC721Gateway",
|
||||
"L2ERC721Gateway",
|
||||
"L1ERC1155Gateway",
|
||||
"L2ERC1155Gateway",
|
||||
"L1WETHGateway",
|
||||
"L2WETHGateway",
|
||||
"ScrollStandardERC20Factory",
|
||||
],
|
||||
outputDir: "docs/apis",
|
||||
exclude: [
|
||||
"IERC677Receiver",
|
||||
"IL1ScrollMessenger",
|
||||
"IL2ScrollMessenger",
|
||||
"IL1GatewayRouter",
|
||||
"IL2GatewayRouter",
|
||||
"IL1ERC721Gateway",
|
||||
"IL2ERC721Gateway",
|
||||
"IL1ERC1155Gateway",
|
||||
"IL2ERC1155Gateway",
|
||||
"IScrollStandardERC20Factory",
|
||||
"IScrollChain",
|
||||
"ScrollChainCommitmentVerifier",
|
||||
"WETH9",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,455 +0,0 @@
|
||||
/* eslint-disable node/no-unpublished-import */
|
||||
/* eslint-disable node/no-missing-import */
|
||||
import { HardhatEthersSigner, SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { BigNumberish, BytesLike, MaxUint256, ZeroAddress, getBytes } from "ethers";
|
||||
import { ethers } from "hardhat";
|
||||
|
||||
import { EnforcedTxGateway, L1MessageQueue, L2GasPriceOracle, MockCaller } from "../typechain";
|
||||
|
||||
describe("EnforcedTxGateway.spec", async () => {
|
||||
let deployer: HardhatEthersSigner;
|
||||
let feeVault: HardhatEthersSigner;
|
||||
let signer: HardhatEthersSigner;
|
||||
|
||||
let caller: MockCaller;
|
||||
let gateway: EnforcedTxGateway;
|
||||
let oracle: L2GasPriceOracle;
|
||||
let queue: L1MessageQueue;
|
||||
|
||||
const deployProxy = async (name: string, admin: string, args: any[]): Promise<string> => {
|
||||
const TransparentUpgradeableProxy = await ethers.getContractFactory("TransparentUpgradeableProxy", deployer);
|
||||
const Factory = await ethers.getContractFactory(name, deployer);
|
||||
const impl = args.length > 0 ? await Factory.deploy(...args) : await Factory.deploy();
|
||||
const proxy = await TransparentUpgradeableProxy.deploy(impl.getAddress(), admin, "0x");
|
||||
return proxy.getAddress();
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
[deployer, feeVault, signer] = await ethers.getSigners();
|
||||
|
||||
const ProxyAdmin = await ethers.getContractFactory("ProxyAdmin", deployer);
|
||||
const admin = await ProxyAdmin.deploy();
|
||||
|
||||
gateway = await ethers.getContractAt(
|
||||
"EnforcedTxGateway",
|
||||
await deployProxy("EnforcedTxGateway", await admin.getAddress(), []),
|
||||
deployer
|
||||
);
|
||||
|
||||
queue = await ethers.getContractAt(
|
||||
"L1MessageQueue",
|
||||
await deployProxy("L1MessageQueue", await admin.getAddress(), [
|
||||
deployer.address,
|
||||
deployer.address,
|
||||
await gateway.getAddress(),
|
||||
]),
|
||||
deployer
|
||||
);
|
||||
|
||||
oracle = await ethers.getContractAt(
|
||||
"L2GasPriceOracle",
|
||||
await deployProxy("L2GasPriceOracle", await admin.getAddress(), []),
|
||||
deployer
|
||||
);
|
||||
|
||||
const MockCaller = await ethers.getContractFactory("MockCaller", deployer);
|
||||
caller = await MockCaller.deploy();
|
||||
|
||||
await queue.initialize(ZeroAddress, ZeroAddress, ZeroAddress, oracle.getAddress(), 10000000);
|
||||
await gateway.initialize(queue.getAddress(), feeVault.address);
|
||||
await oracle.initialize(21000, 51000, 8, 16);
|
||||
|
||||
const Whitelist = await ethers.getContractFactory("Whitelist", deployer);
|
||||
const whitelist = await Whitelist.deploy(deployer.address);
|
||||
|
||||
await whitelist.updateWhitelistStatus([deployer.address], true);
|
||||
await oracle.updateWhitelist(whitelist.getAddress());
|
||||
await oracle.setL2BaseFee(1);
|
||||
});
|
||||
|
||||
context("auth", async () => {
|
||||
it("should initialize correctly", async () => {
|
||||
expect(await gateway.owner()).to.eq(deployer.address);
|
||||
expect(await gateway.messageQueue()).to.eq(await queue.getAddress());
|
||||
expect(await gateway.feeVault()).to.eq(feeVault.address);
|
||||
expect(await gateway.paused()).to.eq(false);
|
||||
});
|
||||
|
||||
it("should revert, when initialize again", async () => {
|
||||
await expect(gateway.initialize(ZeroAddress, ZeroAddress)).to.revertedWith(
|
||||
"Initializable: contract is already initialized"
|
||||
);
|
||||
});
|
||||
|
||||
context("#updateFeeVault", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(gateway.connect(signer).updateFeeVault(ZeroAddress)).to.revertedWith(
|
||||
"Ownable: caller is not the owner"
|
||||
);
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await gateway.feeVault()).to.eq(feeVault.address);
|
||||
await expect(gateway.updateFeeVault(deployer.address))
|
||||
.to.emit(gateway, "UpdateFeeVault")
|
||||
.withArgs(feeVault.address, deployer.address);
|
||||
expect(await gateway.feeVault()).to.eq(deployer.address);
|
||||
});
|
||||
});
|
||||
|
||||
context("#setPause", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(gateway.connect(signer).setPause(false)).to.revertedWith("Ownable: caller is not the owner");
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await gateway.paused()).to.eq(false);
|
||||
await expect(gateway.setPause(true)).to.emit(gateway, "Paused").withArgs(deployer.address);
|
||||
expect(await gateway.paused()).to.eq(true);
|
||||
await expect(gateway.setPause(false)).to.emit(gateway, "Unpaused").withArgs(deployer.address);
|
||||
expect(await gateway.paused()).to.eq(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context("#sendTransaction, by EOA", async () => {
|
||||
it("should revert, when contract is paused", async () => {
|
||||
await gateway.setPause(true);
|
||||
await expect(
|
||||
gateway.connect(signer)["sendTransaction(address,uint256,uint256,bytes)"](signer.address, 0, 0, "0x")
|
||||
).to.revertedWith("Pausable: paused");
|
||||
});
|
||||
|
||||
it("should revert, when call is not EOA", async () => {
|
||||
const calldata = gateway.interface.encodeFunctionData("sendTransaction(address,uint256,uint256,bytes)", [
|
||||
signer.address,
|
||||
0,
|
||||
0,
|
||||
"0x",
|
||||
]);
|
||||
await expect(caller.callTarget(gateway.getAddress(), calldata)).to.revertedWith(
|
||||
"Only EOA senders are allowed to send enforced transaction"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when insufficient value for fee", async () => {
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(signer)
|
||||
["sendTransaction(address,uint256,uint256,bytes)"](signer.address, 0, 1000000, "0x", { value: fee - 1n })
|
||||
).to.revertedWith("Insufficient value for fee");
|
||||
});
|
||||
|
||||
it("should revert, when failed to deduct the fee", async () => {
|
||||
await gateway.updateFeeVault(gateway.getAddress());
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(signer)
|
||||
["sendTransaction(address,uint256,uint256,bytes)"](signer.address, 0, 1000000, "0x", { value: fee })
|
||||
).to.revertedWith("Failed to deduct the fee");
|
||||
});
|
||||
|
||||
it("should succeed, no refund", async () => {
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
const feeVaultBalanceBefore = await ethers.provider.getBalance(feeVault.address);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(signer)
|
||||
["sendTransaction(address,uint256,uint256,bytes)"](deployer.address, 0, 1000000, "0x", { value: fee })
|
||||
)
|
||||
.to.emit(queue, "QueueTransaction")
|
||||
.withArgs(signer.address, deployer.address, 0, 0, 1000000, "0x");
|
||||
const feeVaultBalanceAfter = await ethers.provider.getBalance(feeVault.address);
|
||||
expect(feeVaultBalanceAfter - feeVaultBalanceBefore).to.eq(fee);
|
||||
});
|
||||
|
||||
it("should succeed, with refund", async () => {
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
const feeVaultBalanceBefore = await ethers.provider.getBalance(feeVault.address);
|
||||
const signerBalanceBefore = await ethers.provider.getBalance(signer.address);
|
||||
const tx = await gateway
|
||||
.connect(signer)
|
||||
["sendTransaction(address,uint256,uint256,bytes)"](deployer.address, 0, 1000000, "0x", { value: fee + 100n });
|
||||
await expect(tx)
|
||||
.to.emit(queue, "QueueTransaction")
|
||||
.withArgs(signer.address, deployer.address, 0, 0, 1000000, "0x");
|
||||
const receipt = await tx.wait();
|
||||
const feeVaultBalanceAfter = await ethers.provider.getBalance(feeVault.address);
|
||||
const signerBalanceAfter = await ethers.provider.getBalance(signer.address);
|
||||
expect(feeVaultBalanceAfter - feeVaultBalanceBefore).to.eq(fee);
|
||||
expect(signerBalanceBefore - signerBalanceAfter).to.eq(receipt!.gasUsed * receipt!.gasPrice + fee);
|
||||
});
|
||||
});
|
||||
|
||||
context("#sendTransaction, with signatures", async () => {
|
||||
const getSignature = async (
|
||||
signer: SignerWithAddress,
|
||||
target: string,
|
||||
value: BigNumberish,
|
||||
gasLimit: BigNumberish,
|
||||
data: BytesLike
|
||||
) => {
|
||||
const enforcedTx = {
|
||||
sender: signer.address,
|
||||
target,
|
||||
value,
|
||||
gasLimit,
|
||||
data: getBytes(data),
|
||||
nonce: await gateway.nonces(signer.address),
|
||||
deadline: MaxUint256,
|
||||
};
|
||||
|
||||
const domain = {
|
||||
name: "EnforcedTxGateway",
|
||||
version: "1",
|
||||
chainId: (await ethers.provider.getNetwork()).chainId,
|
||||
verifyingContract: await gateway.getAddress(),
|
||||
};
|
||||
|
||||
const types = {
|
||||
EnforcedTransaction: [
|
||||
{
|
||||
name: "sender",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
name: "value",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "gasLimit",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "data",
|
||||
type: "bytes",
|
||||
},
|
||||
{
|
||||
name: "nonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "deadline",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const signature = await signer.signTypedData(domain, types, enforcedTx);
|
||||
return signature;
|
||||
};
|
||||
|
||||
it("should revert, when contract is paused", async () => {
|
||||
await gateway.setPause(true);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
signer.address,
|
||||
0,
|
||||
0,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
"0x",
|
||||
ZeroAddress
|
||||
)
|
||||
).to.revertedWith("Pausable: paused");
|
||||
});
|
||||
|
||||
it("should revert, when signature expired", async () => {
|
||||
const timestamp = (await ethers.provider.getBlock("latest"))!.timestamp;
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
signer.address,
|
||||
0,
|
||||
0,
|
||||
"0x",
|
||||
timestamp - 1,
|
||||
"0x",
|
||||
ZeroAddress
|
||||
)
|
||||
).to.revertedWith("signature expired");
|
||||
});
|
||||
|
||||
it("should revert, when signature is wrong", async () => {
|
||||
const signature = await signer.signMessage("0x00");
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
signer.address,
|
||||
0,
|
||||
0,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
signature,
|
||||
ZeroAddress
|
||||
)
|
||||
).to.revertedWith("Incorrect signature");
|
||||
});
|
||||
|
||||
it("should revert, when insufficient value for fee", async () => {
|
||||
const signature = await getSignature(signer, signer.address, 0, 1000000, "0x");
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
signer.address,
|
||||
0,
|
||||
1000000,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
signature,
|
||||
signer.address,
|
||||
{ value: fee - 1n }
|
||||
)
|
||||
).to.revertedWith("Insufficient value for fee");
|
||||
});
|
||||
|
||||
it("should revert, when failed to deduct the fee", async () => {
|
||||
await gateway.updateFeeVault(gateway.getAddress());
|
||||
const signature = await getSignature(signer, signer.address, 0, 1000000, "0x");
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
signer.address,
|
||||
0,
|
||||
1000000,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
signature,
|
||||
signer.address,
|
||||
{ value: fee }
|
||||
)
|
||||
).to.revertedWith("Failed to deduct the fee");
|
||||
});
|
||||
|
||||
it("should succeed, no refund", async () => {
|
||||
const signature = await getSignature(signer, deployer.address, 0, 1000000, "0x");
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
const feeVaultBalanceBefore = await ethers.provider.getBalance(feeVault.address);
|
||||
expect(await gateway.nonces(signer.address)).to.eq(0);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
deployer.address,
|
||||
0,
|
||||
1000000,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
signature,
|
||||
signer.address,
|
||||
{ value: fee }
|
||||
)
|
||||
)
|
||||
.to.emit(queue, "QueueTransaction")
|
||||
.withArgs(signer.address, deployer.address, 0, 0, 1000000, "0x");
|
||||
expect(await gateway.nonces(signer.address)).to.eq(1);
|
||||
const feeVaultBalanceAfter = await ethers.provider.getBalance(feeVault.address);
|
||||
expect(feeVaultBalanceAfter - feeVaultBalanceBefore).to.eq(fee);
|
||||
|
||||
// use the same nonce to sign should fail
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
deployer.address,
|
||||
0,
|
||||
1000000,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
signature,
|
||||
signer.address,
|
||||
{ value: fee }
|
||||
)
|
||||
).to.revertedWith("Incorrect signature");
|
||||
});
|
||||
|
||||
it("should succeed, with refund", async () => {
|
||||
const signature = await getSignature(signer, deployer.address, 0, 1000000, "0x");
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
const feeVaultBalanceBefore = await ethers.provider.getBalance(feeVault.address);
|
||||
const signerBalanceBefore = await ethers.provider.getBalance(signer.address);
|
||||
expect(await gateway.nonces(signer.address)).to.eq(0);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
deployer.address,
|
||||
0,
|
||||
1000000,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
signature,
|
||||
signer.address,
|
||||
{ value: fee + 100n }
|
||||
)
|
||||
)
|
||||
.to.emit(queue, "QueueTransaction")
|
||||
.withArgs(signer.address, deployer.address, 0, 0, 1000000, "0x");
|
||||
expect(await gateway.nonces(signer.address)).to.eq(1);
|
||||
const feeVaultBalanceAfter = await ethers.provider.getBalance(feeVault.address);
|
||||
const signerBalanceAfter = await ethers.provider.getBalance(signer.address);
|
||||
expect(feeVaultBalanceAfter - feeVaultBalanceBefore).to.eq(fee);
|
||||
expect(signerBalanceAfter - signerBalanceBefore).to.eq(100n);
|
||||
|
||||
// use the same nonce to sign should fail
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
deployer.address,
|
||||
0,
|
||||
1000000,
|
||||
"0x",
|
||||
MaxUint256,
|
||||
signature,
|
||||
signer.address,
|
||||
{ value: fee + 100n }
|
||||
)
|
||||
).to.revertedWith("Incorrect signature");
|
||||
});
|
||||
|
||||
it("should revert, when refund failed", async () => {
|
||||
const signature = await getSignature(signer, signer.address, 0, 1000000, "0x1234");
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1000000);
|
||||
await expect(
|
||||
gateway
|
||||
.connect(deployer)
|
||||
["sendTransaction(address,address,uint256,uint256,bytes,uint256,bytes,address)"](
|
||||
signer.address,
|
||||
signer.address,
|
||||
0,
|
||||
1000000,
|
||||
"0x1234",
|
||||
MaxUint256,
|
||||
signature,
|
||||
gateway.getAddress(),
|
||||
{ value: fee + 100n }
|
||||
)
|
||||
).to.revertedWith("Failed to refund the fee");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,661 +0,0 @@
|
||||
/* eslint-disable node/no-missing-import */
|
||||
/* eslint-disable node/no-unpublished-import */
|
||||
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { BigNumberish, ContractTransactionResponse, MaxUint256, keccak256, toQuantity } from "ethers";
|
||||
import { ethers, network } from "hardhat";
|
||||
|
||||
import {
|
||||
ProxyAdmin,
|
||||
L1GatewayRouter,
|
||||
L2ScrollMessenger,
|
||||
L1ScrollMessenger,
|
||||
L1MessageQueueWithGasPriceOracle,
|
||||
L2GatewayRouter,
|
||||
} from "../typechain";
|
||||
|
||||
describe("GasOptimizationUpgrade.spec", async () => {
|
||||
const L1_ROUTER = "0xF8B1378579659D8F7EE5f3C929c2f3E332E41Fd6";
|
||||
const L2_ROUTER = "0x4C0926FF5252A435FD19e10ED15e5a249Ba19d79";
|
||||
const L1_MESSENGER = "0x6774Bcbd5ceCeF1336b5300fb5186a12DDD8b367";
|
||||
const L2_MESSENGER = "0x781e90f1c8Fc4611c9b7497C3B47F99Ef6969CbC";
|
||||
const L1_MESSAGE_QUEUE = "0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B";
|
||||
const L2_MESSAGE_QUEUE = "0x5300000000000000000000000000000000000000";
|
||||
const SCROLL_CHAIN = "0xa13BAF47339d63B743e7Da8741db5456DAc1E556";
|
||||
|
||||
let deployer: HardhatEthersSigner;
|
||||
|
||||
let proxyAdmin: ProxyAdmin;
|
||||
|
||||
const mockERC20Balance = async (tokenAddress: string, balance: bigint, slot: BigNumberish) => {
|
||||
const storageSlot = keccak256(
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(["address", "uint256"], [deployer.address, slot])
|
||||
);
|
||||
await ethers.provider.send("hardhat_setStorageAt", [tokenAddress, storageSlot, toQuantity(balance)]);
|
||||
const token = await ethers.getContractAt("MockERC20", tokenAddress, deployer);
|
||||
expect(await token.balanceOf(deployer.address)).to.eq(balance);
|
||||
};
|
||||
|
||||
const mockETHBalance = async (balance: bigint) => {
|
||||
await network.provider.send("hardhat_setBalance", [deployer.address, toQuantity(balance)]);
|
||||
expect(await ethers.provider.getBalance(deployer.address)).to.eq(balance);
|
||||
};
|
||||
|
||||
const showGasUsage = async (tx: ContractTransactionResponse, desc: string) => {
|
||||
const receipt = await tx.wait();
|
||||
console.log(`${desc}: GasUsed[${receipt!.gasUsed}]`);
|
||||
};
|
||||
|
||||
context("L1 upgrade", async () => {
|
||||
let forkBlock: number;
|
||||
let router: L1GatewayRouter;
|
||||
let messenger: L1ScrollMessenger;
|
||||
let queue: L1MessageQueueWithGasPriceOracle;
|
||||
|
||||
beforeEach(async () => {
|
||||
// fork network
|
||||
const provider = new ethers.JsonRpcProvider("https://rpc.ankr.com/eth");
|
||||
if (!forkBlock) {
|
||||
forkBlock = (await provider.getBlockNumber()) - 10;
|
||||
}
|
||||
await network.provider.request({
|
||||
method: "hardhat_reset",
|
||||
params: [
|
||||
{
|
||||
forking: {
|
||||
jsonRpcUrl: "https://rpc.ankr.com/eth",
|
||||
blockNumber: forkBlock,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
await network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
params: ["0x1100000000000000000000000000000000000011"],
|
||||
});
|
||||
|
||||
// mock eth balance
|
||||
deployer = await ethers.getSigner("0x1100000000000000000000000000000000000011");
|
||||
await mockETHBalance(ethers.parseEther("1000"));
|
||||
|
||||
// mock owner of proxy admin
|
||||
proxyAdmin = await ethers.getContractAt("ProxyAdmin", "0xEB803eb3F501998126bf37bB823646Ed3D59d072", deployer);
|
||||
await ethers.provider.send("hardhat_setStorageAt", [
|
||||
await proxyAdmin.getAddress(),
|
||||
"0x0",
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(["address"], [deployer.address]),
|
||||
]);
|
||||
expect(await proxyAdmin.owner()).to.eq(deployer.address);
|
||||
|
||||
router = await ethers.getContractAt("L1GatewayRouter", L1_ROUTER, deployer);
|
||||
messenger = await ethers.getContractAt("L1ScrollMessenger", L1_MESSENGER, deployer);
|
||||
queue = await ethers.getContractAt("L1MessageQueueWithGasPriceOracle", L1_MESSAGE_QUEUE, deployer);
|
||||
});
|
||||
|
||||
const upgradeL1 = async (proxy: string, impl: string) => {
|
||||
await proxyAdmin.upgrade(proxy, impl);
|
||||
const L1ScrollMessenger = await ethers.getContractFactory("L1ScrollMessenger", deployer);
|
||||
const L1MessageQueueWithGasPriceOracle = await ethers.getContractFactory(
|
||||
"L1MessageQueueWithGasPriceOracle",
|
||||
deployer
|
||||
);
|
||||
const ScrollChain = await ethers.getContractFactory("ScrollChain", deployer);
|
||||
await proxyAdmin.upgrade(
|
||||
L1_MESSENGER,
|
||||
(await L1ScrollMessenger.deploy(L2_MESSENGER, SCROLL_CHAIN, L1_MESSAGE_QUEUE)).getAddress()
|
||||
);
|
||||
await proxyAdmin.upgrade(
|
||||
L1_MESSAGE_QUEUE,
|
||||
(
|
||||
await L1MessageQueueWithGasPriceOracle.deploy(
|
||||
L1_MESSENGER,
|
||||
SCROLL_CHAIN,
|
||||
"0x72CAcBcfDe2d1e19122F8A36a4d6676cd39d7A5d"
|
||||
)
|
||||
).getAddress()
|
||||
);
|
||||
await queue.initializeV2();
|
||||
await proxyAdmin.upgrade(
|
||||
SCROLL_CHAIN,
|
||||
(await ScrollChain.deploy(534352, L1_MESSAGE_QUEUE, "0xA2Ab526e5C5491F10FC05A55F064BF9F7CEf32a0")).getAddress()
|
||||
);
|
||||
};
|
||||
|
||||
it.skip("should succeed on L1ETHGateway", async () => {
|
||||
const L1_GATEWAY = "0x7F2b8C31F88B6006c382775eea88297Ec1e3E905";
|
||||
const L2_GATEWAY = "0x6EA73e05AdC79974B931123675ea8F78FfdacDF0";
|
||||
const L1ETHGateway = await ethers.getContractFactory("L1ETHGateway", deployer);
|
||||
const impl = await L1ETHGateway.deploy(L2_GATEWAY, L1_ROUTER, L1_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L1ETHGateway", L1_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseEther("1");
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1e6);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn + fee }),
|
||||
"L1ETHGateway.depositETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn + fee }),
|
||||
"L1GatewayRouter.depositETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await messenger["sendMessage(address,uint256,bytes,uint256)"](deployer.address, amountIn, "0x", 1e6, {
|
||||
value: amountIn + fee,
|
||||
}),
|
||||
"L1ScrollMessenger.sendMessage before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL1(L1_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn + fee }),
|
||||
"L1ETHGateway.depositETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn + fee }),
|
||||
"L1GatewayRouter.depositETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await messenger["sendMessage(address,uint256,bytes,uint256)"](deployer.address, amountIn, "0x", 1e6, {
|
||||
value: amountIn + fee,
|
||||
}),
|
||||
"L1ScrollMessenger.sendMessage after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L1WETHGateway", async () => {
|
||||
const L1_WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
||||
const L2_WETH = "0x5300000000000000000000000000000000000004";
|
||||
const L1_GATEWAY = "0x7AC440cAe8EB6328de4fA621163a792c1EA9D4fE";
|
||||
const L2_GATEWAY = "0x7003E7B7186f0E6601203b99F7B8DECBfA391cf9";
|
||||
const L1WETHGateway = await ethers.getContractFactory("L1WETHGateway", deployer);
|
||||
const impl = await L1WETHGateway.deploy(L1_WETH, L2_WETH, L2_GATEWAY, L1_ROUTER, L1_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L1WETHGateway", L1_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseEther("1");
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1e6);
|
||||
const token = await ethers.getContractAt("MockERC20", L1_WETH, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 3);
|
||||
await token.approve(L1_GATEWAY, MaxUint256);
|
||||
await token.approve(L1_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_WETH, amountIn, 1e6, { value: fee }),
|
||||
"L1WETHGateway.depositERC20 WETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_WETH, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 WETH before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL1(L1_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_WETH, amountIn, 1e6, { value: fee }),
|
||||
"L1WETHGateway.depositERC20 WETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_WETH, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 WETH after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L1StandardERC20Gateway", async () => {
|
||||
const L1_USDT = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
|
||||
const L1_GATEWAY = "0xD8A791fE2bE73eb6E6cF1eb0cb3F36adC9B3F8f9";
|
||||
const L2_GATEWAY = "0xE2b4795039517653c5Ae8C2A9BFdd783b48f447A";
|
||||
const L1StandardERC20Gateway = await ethers.getContractFactory("L1StandardERC20Gateway", deployer);
|
||||
const impl = await L1StandardERC20Gateway.deploy(
|
||||
L2_GATEWAY,
|
||||
L1_ROUTER,
|
||||
L1_MESSENGER,
|
||||
"0xC7d86908ccf644Db7C69437D5852CedBC1aD3f69",
|
||||
"0x66e5312EDeEAef6e80759A0F789e7914Fb401484"
|
||||
);
|
||||
const gateway = await ethers.getContractAt("L1StandardERC20Gateway", L1_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 6);
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1e6);
|
||||
const token = await ethers.getContractAt("MockERC20", L1_USDT, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 2);
|
||||
await token.approve(L1_GATEWAY, MaxUint256);
|
||||
await token.approve(L1_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_USDT, amountIn, 1e6, { value: fee }),
|
||||
"L1StandardERC20Gateway.depositERC20 USDT before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_USDT, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 USDT before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL1(L1_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_USDT, amountIn, 1e6, { value: fee }),
|
||||
"L1StandardERC20Gateway.depositERC20 USDT after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_USDT, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 USDT after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L1CustomERC20Gateway", async () => {
|
||||
const L1_DAI = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
|
||||
const L1_GATEWAY = "0x67260A8B73C5B77B55c1805218A42A7A6F98F515";
|
||||
const L2_GATEWAY = "0xaC78dff3A87b5b534e366A93E785a0ce8fA6Cc62";
|
||||
const L1CustomERC20Gateway = await ethers.getContractFactory("L1CustomERC20Gateway", deployer);
|
||||
const impl = await L1CustomERC20Gateway.deploy(L2_GATEWAY, L1_ROUTER, L1_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L1CustomERC20Gateway", L1_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 18);
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1e6);
|
||||
const token = await ethers.getContractAt("MockERC20", L1_DAI, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 2);
|
||||
await token.approve(L1_GATEWAY, MaxUint256);
|
||||
await token.approve(L1_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_DAI, amountIn, 1e6, { value: fee }),
|
||||
"L1CustomERC20Gateway.depositERC20 DAI before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_DAI, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 DAI before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL1(L1_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_DAI, amountIn, 1e6, { value: fee }),
|
||||
"L1CustomERC20Gateway.depositERC20 DAI after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_DAI, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 DAI after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L1USDCGateway", async () => {
|
||||
const L1_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
||||
const L2_USDC = "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4";
|
||||
const L1_GATEWAY = "0xf1AF3b23DE0A5Ca3CAb7261cb0061C0D779A5c7B";
|
||||
const L2_GATEWAY = "0x33B60d5Dd260d453cAC3782b0bDC01ce84672142";
|
||||
const L1USDCGateway = await ethers.getContractFactory("L1USDCGateway", deployer);
|
||||
const impl = await L1USDCGateway.deploy(L1_USDC, L2_USDC, L2_GATEWAY, L1_ROUTER, L1_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L1USDCGateway", L1_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 6);
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1e6);
|
||||
const token = await ethers.getContractAt("MockERC20", L1_USDC, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 9);
|
||||
await token.approve(L1_GATEWAY, MaxUint256);
|
||||
await token.approve(L1_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_USDC, amountIn, 1e6, { value: fee }),
|
||||
"L1USDCGateway.depositERC20 USDC before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_USDC, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 USDC before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL1(L1_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_USDC, amountIn, 1e6, { value: fee }),
|
||||
"L1USDCGateway.depositERC20 USDC after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_USDC, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 USDC after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L1LidoGateway", async () => {
|
||||
const L1_WSTETH = "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
|
||||
const L2_WSTETH = "0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32";
|
||||
const L1_GATEWAY = "0x6625C6332c9F91F2D27c304E729B86db87A3f504";
|
||||
const L2_GATEWAY = "0x8aE8f22226B9d789A36AC81474e633f8bE2856c9";
|
||||
const L1LidoGateway = await ethers.getContractFactory("L1LidoGateway", deployer);
|
||||
const impl = await L1LidoGateway.deploy(L1_WSTETH, L2_WSTETH, L2_GATEWAY, L1_ROUTER, L1_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L1LidoGateway", L1_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 6);
|
||||
const fee = await queue.estimateCrossDomainMessageFee(1e6);
|
||||
const token = await ethers.getContractAt("MockERC20", L1_WSTETH, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 0);
|
||||
await token.approve(L1_GATEWAY, MaxUint256);
|
||||
await token.approve(L1_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_WSTETH, amountIn, 1e6, { value: fee }),
|
||||
"L1LidoGateway.depositERC20 wstETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_WSTETH, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 wstETH before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL1(L1_GATEWAY, await impl.getAddress());
|
||||
await gateway.initializeV2(deployer.address, deployer.address, deployer.address, deployer.address);
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["depositERC20(address,uint256,uint256)"](L1_WSTETH, amountIn, 1e6, { value: fee }),
|
||||
"L1LidoGateway.depositERC20 wstETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["depositERC20(address,uint256,uint256)"](L1_WSTETH, amountIn, 1e6, { value: fee }),
|
||||
"L1GatewayRouter.depositERC20 wstETH after upgrade"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
context("L2 upgrade", async () => {
|
||||
let forkBlock: number;
|
||||
let router: L2GatewayRouter;
|
||||
let messenger: L2ScrollMessenger;
|
||||
|
||||
beforeEach(async () => {
|
||||
// fork network
|
||||
const provider = new ethers.JsonRpcProvider("https://rpc.scroll.io");
|
||||
if (!forkBlock) {
|
||||
forkBlock = (await provider.getBlockNumber()) - 31;
|
||||
}
|
||||
await network.provider.request({
|
||||
method: "hardhat_reset",
|
||||
params: [
|
||||
{
|
||||
forking: {
|
||||
jsonRpcUrl: "https://rpc.scroll.io",
|
||||
blockNumber: forkBlock,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
await network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
params: ["0x1100000000000000000000000000000000000011"],
|
||||
});
|
||||
|
||||
// mock eth balance
|
||||
deployer = await ethers.getSigner("0x1100000000000000000000000000000000000011");
|
||||
await mockETHBalance(ethers.parseEther("1000"));
|
||||
|
||||
// mock owner of proxy admin
|
||||
proxyAdmin = await ethers.getContractAt("ProxyAdmin", "0xA76acF000C890b0DD7AEEf57627d9899F955d026", deployer);
|
||||
await ethers.provider.send("hardhat_setStorageAt", [
|
||||
await proxyAdmin.getAddress(),
|
||||
"0x0",
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(["address"], [deployer.address]),
|
||||
]);
|
||||
expect(await proxyAdmin.owner()).to.eq(deployer.address);
|
||||
|
||||
router = await ethers.getContractAt("L2GatewayRouter", L2_ROUTER, deployer);
|
||||
messenger = await ethers.getContractAt("L2ScrollMessenger", L2_MESSENGER, deployer);
|
||||
});
|
||||
|
||||
const upgradeL2 = async (proxy: string, impl: string) => {
|
||||
await proxyAdmin.upgrade(proxy, impl);
|
||||
const L2ScrollMessenger = await ethers.getContractFactory("L2ScrollMessenger", deployer);
|
||||
await proxyAdmin.upgrade(
|
||||
L2_MESSENGER,
|
||||
(await L2ScrollMessenger.deploy(L1_MESSENGER, L2_MESSAGE_QUEUE)).getAddress()
|
||||
);
|
||||
};
|
||||
|
||||
it.skip("should succeed on L2ETHGateway", async () => {
|
||||
const L1_GATEWAY = "0x7F2b8C31F88B6006c382775eea88297Ec1e3E905";
|
||||
const L2_GATEWAY = "0x6EA73e05AdC79974B931123675ea8F78FfdacDF0";
|
||||
const L2ETHGateway = await ethers.getContractFactory("L2ETHGateway", deployer);
|
||||
const impl = await L2ETHGateway.deploy(L1_GATEWAY, L2_ROUTER, L2_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L2ETHGateway", L2_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseEther("1");
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn }),
|
||||
"L2ETHGateway.withdrawETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn }),
|
||||
"L2GatewayRouter.withdrawETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await messenger["sendMessage(address,uint256,bytes,uint256)"](deployer.address, amountIn, "0x", 1e6, {
|
||||
value: amountIn,
|
||||
}),
|
||||
"L2ScrollMessenger.sendMessage before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL2(L2_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn }),
|
||||
"L2ETHGateway.withdrawETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawETH(uint256,uint256)"](amountIn, 1e6, { value: amountIn }),
|
||||
"L2GatewayRouter.withdrawETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await messenger["sendMessage(address,uint256,bytes,uint256)"](deployer.address, amountIn, "0x", 1e6, {
|
||||
value: amountIn,
|
||||
}),
|
||||
"L2ScrollMessenger.sendMessage after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L2WETHGateway", async () => {
|
||||
const L1_WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
||||
const L2_WETH = "0x5300000000000000000000000000000000000004";
|
||||
const L1_GATEWAY = "0x7AC440cAe8EB6328de4fA621163a792c1EA9D4fE";
|
||||
const L2_GATEWAY = "0x7003E7B7186f0E6601203b99F7B8DECBfA391cf9";
|
||||
const L2WETHGateway = await ethers.getContractFactory("L2WETHGateway", deployer);
|
||||
const impl = await L2WETHGateway.deploy(L2_WETH, L1_WETH, L1_GATEWAY, L2_ROUTER, L2_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L2WETHGateway", L2_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseEther("1");
|
||||
const token = await ethers.getContractAt("MockERC20", L2_WETH, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 0);
|
||||
await token.approve(L2_GATEWAY, MaxUint256);
|
||||
await token.approve(L2_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_WETH, amountIn, 1e6),
|
||||
"L2WETHGateway.withdrawERC20 WETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_WETH, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 WETH before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL2(L2_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_WETH, amountIn, 1e6),
|
||||
"L2WETHGateway.withdrawERC20 WETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_WETH, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 WETH after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L2StandardERC20Gateway", async () => {
|
||||
const L2_USDT = "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df";
|
||||
const L1_GATEWAY = "0xD8A791fE2bE73eb6E6cF1eb0cb3F36adC9B3F8f9";
|
||||
const L2_GATEWAY = "0xE2b4795039517653c5Ae8C2A9BFdd783b48f447A";
|
||||
const L2StandardERC20Gateway = await ethers.getContractFactory("L2StandardERC20Gateway", deployer);
|
||||
const impl = await L2StandardERC20Gateway.deploy(
|
||||
L1_GATEWAY,
|
||||
L2_ROUTER,
|
||||
L2_MESSENGER,
|
||||
"0x66e5312EDeEAef6e80759A0F789e7914Fb401484"
|
||||
);
|
||||
const gateway = await ethers.getContractAt("L2StandardERC20Gateway", L2_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 6);
|
||||
const token = await ethers.getContractAt("MockERC20", L2_USDT, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 51);
|
||||
await token.approve(L2_GATEWAY, MaxUint256);
|
||||
await token.approve(L2_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_USDT, amountIn, 1e6),
|
||||
"L2StandardERC20Gateway.withdrawERC20 USDT before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_USDT, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 USDT before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL2(L2_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_USDT, amountIn, 1e6),
|
||||
"L2StandardERC20Gateway.withdrawERC20 USDT after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_USDT, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 USDT after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L2CustomERC20Gateway", async () => {
|
||||
const L2_DAI = "0xcA77eB3fEFe3725Dc33bccB54eDEFc3D9f764f97";
|
||||
const L1_GATEWAY = "0x67260A8B73C5B77B55c1805218A42A7A6F98F515";
|
||||
const L2_GATEWAY = "0xaC78dff3A87b5b534e366A93E785a0ce8fA6Cc62";
|
||||
const L2CustomERC20Gateway = await ethers.getContractFactory("L2CustomERC20Gateway", deployer);
|
||||
const impl = await L2CustomERC20Gateway.deploy(L1_GATEWAY, L2_ROUTER, L2_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L2CustomERC20Gateway", L2_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 18);
|
||||
const token = await ethers.getContractAt("MockERC20", L2_DAI, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 51);
|
||||
await token.approve(L1_GATEWAY, MaxUint256);
|
||||
await token.approve(L1_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_DAI, amountIn, 1e6),
|
||||
"L2CustomERC20Gateway.withdrawERC20 DAI before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_DAI, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 DAI before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL2(L2_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_DAI, amountIn, 1e6),
|
||||
"L2CustomERC20Gateway.withdrawERC20 DAI after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_DAI, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 DAI after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L2USDCGateway", async () => {
|
||||
const L1_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
||||
const L2_USDC = "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4";
|
||||
const L1_GATEWAY = "0xf1AF3b23DE0A5Ca3CAb7261cb0061C0D779A5c7B";
|
||||
const L2_GATEWAY = "0x33B60d5Dd260d453cAC3782b0bDC01ce84672142";
|
||||
const L2USDCGateway = await ethers.getContractFactory("L2USDCGateway", deployer);
|
||||
const impl = await L2USDCGateway.deploy(L1_USDC, L2_USDC, L1_GATEWAY, L2_ROUTER, L2_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L2USDCGateway", L2_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 6);
|
||||
const token = await ethers.getContractAt("MockERC20", L2_USDC, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 9);
|
||||
await token.approve(L2_GATEWAY, MaxUint256);
|
||||
await token.approve(L2_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_USDC, amountIn, 1e6),
|
||||
"L2USDCGateway.withdrawERC20 USDC before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_USDC, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 USDC before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL2(L2_GATEWAY, await impl.getAddress());
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_USDC, amountIn, 1e6),
|
||||
"L2USDCGateway.withdrawERC20 USDC after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_USDC, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 USDC after upgrade"
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("should succeed on L2LidoGateway", async () => {
|
||||
const L1_WSTETH = "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
|
||||
const L2_WSTETH = "0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32";
|
||||
const L1_GATEWAY = "0x6625C6332c9F91F2D27c304E729B86db87A3f504";
|
||||
const L2_GATEWAY = "0x8aE8f22226B9d789A36AC81474e633f8bE2856c9";
|
||||
const L2LidoGateway = await ethers.getContractFactory("L2LidoGateway", deployer);
|
||||
const impl = await L2LidoGateway.deploy(L1_WSTETH, L2_WSTETH, L1_GATEWAY, L2_ROUTER, L2_MESSENGER);
|
||||
const gateway = await ethers.getContractAt("L2LidoGateway", L2_GATEWAY, deployer);
|
||||
const amountIn = ethers.parseUnits("1", 6);
|
||||
const token = await ethers.getContractAt("MockERC20", L2_WSTETH, deployer);
|
||||
await mockERC20Balance(await token.getAddress(), amountIn * 10n, 51);
|
||||
await token.approve(L2_GATEWAY, MaxUint256);
|
||||
await token.approve(L2_ROUTER, MaxUint256);
|
||||
|
||||
// before upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_WSTETH, amountIn, 1e6),
|
||||
"L2LidoGateway.withdrawERC20 wstETH before upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_WSTETH, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 wstETH before upgrade"
|
||||
);
|
||||
|
||||
// do upgrade
|
||||
await upgradeL2(L2_GATEWAY, await impl.getAddress());
|
||||
await gateway.initializeV2(deployer.address, deployer.address, deployer.address, deployer.address);
|
||||
|
||||
// after upgrade
|
||||
await showGasUsage(
|
||||
await gateway["withdrawERC20(address,uint256,uint256)"](L2_WSTETH, amountIn, 1e6),
|
||||
"L2LidoGateway.withdrawERC20 wstETH after upgrade"
|
||||
);
|
||||
await showGasUsage(
|
||||
await router["withdrawERC20(address,uint256,uint256)"](L2_WSTETH, amountIn, 1e6),
|
||||
"L2GatewayRouter.withdrawERC20 wstETH after upgrade"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,329 +0,0 @@
|
||||
/* eslint-disable node/no-unpublished-import */
|
||||
/* eslint-disable node/no-missing-import */
|
||||
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { MaxUint256, Signature, ZeroAddress, ZeroHash, toBigInt } from "ethers";
|
||||
import { ethers } from "hardhat";
|
||||
|
||||
import { GasSwap, ERC2771Forwarder, MockERC20, MockGasSwapTarget } from "../typechain";
|
||||
|
||||
describe("GasSwap.spec", async () => {
|
||||
let deployer: HardhatEthersSigner;
|
||||
let signer: HardhatEthersSigner;
|
||||
|
||||
let forwarder: ERC2771Forwarder;
|
||||
let swap: GasSwap;
|
||||
let target: MockGasSwapTarget;
|
||||
let token: MockERC20;
|
||||
|
||||
beforeEach(async () => {
|
||||
[deployer, signer] = await ethers.getSigners();
|
||||
|
||||
const ERC2771Forwarder = await ethers.getContractFactory("ERC2771Forwarder", deployer);
|
||||
forwarder = await ERC2771Forwarder.deploy("ERC2771Forwarder");
|
||||
|
||||
const GasSwap = await ethers.getContractFactory("GasSwap", deployer);
|
||||
swap = await GasSwap.deploy(forwarder.getAddress());
|
||||
|
||||
const MockGasSwapTarget = await ethers.getContractFactory("MockGasSwapTarget", deployer);
|
||||
target = await MockGasSwapTarget.deploy();
|
||||
|
||||
const MockERC20 = await ethers.getContractFactory("MockERC20", deployer);
|
||||
token = await MockERC20.deploy("x", "y", 18);
|
||||
});
|
||||
|
||||
context("auth", async () => {
|
||||
it("should initialize correctly", async () => {
|
||||
expect(await swap.owner()).to.eq(deployer.address);
|
||||
});
|
||||
|
||||
context("#updateFeeRatio", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(swap.connect(signer).updateFeeRatio(1)).to.revertedWith("Ownable: caller is not the owner");
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await swap.feeRatio()).to.eq(ZeroAddress);
|
||||
await expect(swap.updateFeeRatio(100)).to.emit(swap, "UpdateFeeRatio").withArgs(100);
|
||||
expect(await swap.feeRatio()).to.eq(100);
|
||||
});
|
||||
});
|
||||
|
||||
context("#updateApprovedTarget", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(swap.connect(signer).updateApprovedTarget(target.getAddress(), false)).to.revertedWith(
|
||||
"Ownable: caller is not the owner"
|
||||
);
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await swap.approvedTargets(target.getAddress())).to.eq(false);
|
||||
await expect(swap.updateApprovedTarget(target.getAddress(), true))
|
||||
.to.emit(swap, "UpdateApprovedTarget")
|
||||
.withArgs(await target.getAddress(), true);
|
||||
expect(await swap.approvedTargets(target.getAddress())).to.eq(true);
|
||||
await expect(swap.updateApprovedTarget(target.getAddress(), false))
|
||||
.to.emit(swap, "UpdateApprovedTarget")
|
||||
.withArgs(await target.getAddress(), false);
|
||||
expect(await swap.approvedTargets(target.getAddress())).to.eq(false);
|
||||
});
|
||||
});
|
||||
|
||||
context("#withdraw", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(swap.connect(signer).withdraw(ZeroAddress, 0)).to.revertedWith("Ownable: caller is not the owner");
|
||||
});
|
||||
|
||||
it("should succeed, when withdraw ETH", async () => {
|
||||
await deployer.sendTransaction({ to: swap.getAddress(), value: ethers.parseEther("1") });
|
||||
const balanceBefore = await ethers.provider.getBalance(deployer.address);
|
||||
const tx = await swap.withdraw(ZeroAddress, ethers.parseEther("1"));
|
||||
const receipt = await tx.wait();
|
||||
const balanceAfter = await ethers.provider.getBalance(deployer.address);
|
||||
expect(balanceAfter - balanceBefore).to.eq(ethers.parseEther("1") - receipt!.gasUsed * receipt!.gasPrice);
|
||||
});
|
||||
|
||||
it("should succeed, when withdraw token", async () => {
|
||||
await token.mint(swap.getAddress(), ethers.parseEther("1"));
|
||||
const balanceBefore = await token.balanceOf(deployer.address);
|
||||
await swap.withdraw(token.getAddress(), ethers.parseEther("1"));
|
||||
const balanceAfter = await token.balanceOf(deployer.address);
|
||||
expect(balanceAfter - balanceBefore).to.eq(ethers.parseEther("1"));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const permit = async (amount: bigint) => {
|
||||
const value = {
|
||||
owner: signer.address,
|
||||
spender: await swap.getAddress(),
|
||||
value: amount,
|
||||
nonce: await token.nonces(signer.address),
|
||||
deadline: MaxUint256,
|
||||
};
|
||||
|
||||
const domain = {
|
||||
name: await token.name(),
|
||||
version: "1",
|
||||
chainId: (await ethers.provider.getNetwork()).chainId,
|
||||
verifyingContract: await token.getAddress(),
|
||||
};
|
||||
|
||||
const types = {
|
||||
Permit: [
|
||||
{
|
||||
name: "owner",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
name: "spender",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
name: "value",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "nonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "deadline",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const signature = Signature.from(await signer.signTypedData(domain, types, value));
|
||||
return signature;
|
||||
};
|
||||
|
||||
context("swap", async () => {
|
||||
it("should revert, when target not approved", async () => {
|
||||
await expect(
|
||||
swap.swap(
|
||||
{
|
||||
token: token.getAddress(),
|
||||
value: 0,
|
||||
deadline: 0,
|
||||
r: ZeroHash,
|
||||
s: ZeroHash,
|
||||
v: 0,
|
||||
},
|
||||
{
|
||||
target: target.getAddress(),
|
||||
data: "0x",
|
||||
minOutput: 0,
|
||||
}
|
||||
)
|
||||
).to.revertedWith("target not approved");
|
||||
});
|
||||
|
||||
it("should revert, when insufficient output amount", async () => {
|
||||
const amountIn = ethers.parseEther("1");
|
||||
const amountOut = ethers.parseEther("2");
|
||||
await token.mint(signer.address, amountIn);
|
||||
await deployer.sendTransaction({ to: target.getAddress(), value: amountOut });
|
||||
const signature = await permit(amountIn);
|
||||
|
||||
await target.setToken(token.getAddress());
|
||||
await target.setAmountIn(amountIn);
|
||||
|
||||
await swap.updateApprovedTarget(target.getAddress(), true);
|
||||
await expect(
|
||||
swap.connect(signer).swap(
|
||||
{
|
||||
token: await token.getAddress(),
|
||||
value: amountIn,
|
||||
deadline: MaxUint256,
|
||||
r: signature.r,
|
||||
s: signature.s,
|
||||
v: signature.v,
|
||||
},
|
||||
{
|
||||
target: target.getAddress(),
|
||||
data: "0x8119c065",
|
||||
minOutput: amountOut + 1n,
|
||||
}
|
||||
)
|
||||
).to.revertedWith("insufficient output amount");
|
||||
});
|
||||
|
||||
for (const refundRatio of [0n, 1n, 5n]) {
|
||||
for (const feeRatio of ["0", "5", "50"]) {
|
||||
it(`should succeed, when swap by signer directly, with feeRatio[${feeRatio}%] refundRatio[${refundRatio}%]`, async () => {
|
||||
const amountIn = ethers.parseEther("1");
|
||||
const amountOut = ethers.parseEther("2");
|
||||
await token.mint(signer.address, amountIn);
|
||||
await deployer.sendTransaction({ to: target.getAddress(), value: amountOut });
|
||||
const signature = await permit(amountIn);
|
||||
|
||||
await target.setToken(token.getAddress());
|
||||
await target.setAmountIn(amountIn);
|
||||
await target.setRefund((amountIn * refundRatio) / 100n);
|
||||
|
||||
await swap.updateApprovedTarget(target.getAddress(), true);
|
||||
await swap.updateFeeRatio(ethers.parseEther(feeRatio) / 100n);
|
||||
const fee = (amountOut * toBigInt(feeRatio)) / 100n;
|
||||
|
||||
const balanceBefore = await ethers.provider.getBalance(signer.address);
|
||||
const tx = await swap.connect(signer).swap(
|
||||
{
|
||||
token: await token.getAddress(),
|
||||
value: amountIn,
|
||||
deadline: MaxUint256,
|
||||
r: signature.r,
|
||||
s: signature.s,
|
||||
v: signature.v,
|
||||
},
|
||||
{
|
||||
target: target.getAddress(),
|
||||
data: "0x8119c065",
|
||||
minOutput: amountOut - fee,
|
||||
}
|
||||
);
|
||||
const receipt = await tx.wait();
|
||||
const balanceAfter = await ethers.provider.getBalance(signer.address);
|
||||
expect(balanceAfter - balanceBefore).to.eq(amountOut - fee - receipt!.gasUsed * receipt!.gasPrice);
|
||||
expect(await token.balanceOf(signer.address)).to.eq((amountIn * refundRatio) / 100n);
|
||||
});
|
||||
|
||||
it(`should succeed, when swap by signer with forwarder, with feeRatio[${feeRatio}%] refundRatio[${refundRatio}%]`, async () => {
|
||||
const amountIn = ethers.parseEther("1");
|
||||
const amountOut = ethers.parseEther("2");
|
||||
await token.mint(signer.address, amountIn);
|
||||
await deployer.sendTransaction({ to: await target.getAddress(), value: amountOut });
|
||||
const permitSignature = await permit(amountIn);
|
||||
|
||||
await target.setToken(token.getAddress());
|
||||
await target.setAmountIn(amountIn);
|
||||
await target.setRefund((amountIn * refundRatio) / 100n);
|
||||
|
||||
await swap.updateApprovedTarget(target.getAddress(), true);
|
||||
await swap.updateFeeRatio(ethers.parseEther(feeRatio) / 100n);
|
||||
const fee = (amountOut * toBigInt(feeRatio)) / 100n;
|
||||
|
||||
const reqWithoutSignature = {
|
||||
from: signer.address,
|
||||
to: await swap.getAddress(),
|
||||
value: 0n,
|
||||
gas: 1000000,
|
||||
nonce: await forwarder.nonces(signer.address),
|
||||
deadline: 2000000000,
|
||||
data: swap.interface.encodeFunctionData("swap", [
|
||||
{
|
||||
token: await token.getAddress(),
|
||||
value: amountIn,
|
||||
deadline: MaxUint256,
|
||||
r: permitSignature.r,
|
||||
s: permitSignature.s,
|
||||
v: permitSignature.v,
|
||||
},
|
||||
{
|
||||
target: await target.getAddress(),
|
||||
data: "0x8119c065",
|
||||
minOutput: amountOut - fee,
|
||||
},
|
||||
]),
|
||||
};
|
||||
|
||||
const signature = await signer.signTypedData(
|
||||
{
|
||||
name: "ERC2771Forwarder",
|
||||
version: "1",
|
||||
chainId: (await ethers.provider.getNetwork()).chainId,
|
||||
verifyingContract: await forwarder.getAddress(),
|
||||
},
|
||||
{
|
||||
ForwardRequest: [
|
||||
{
|
||||
name: "from",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
name: "to",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
name: "value",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "gas",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "nonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
name: "deadline",
|
||||
type: "uint48",
|
||||
},
|
||||
{
|
||||
name: "data",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
},
|
||||
reqWithoutSignature
|
||||
);
|
||||
|
||||
const balanceBefore = await ethers.provider.getBalance(signer.address);
|
||||
await forwarder.execute({
|
||||
from: reqWithoutSignature.from,
|
||||
to: reqWithoutSignature.to,
|
||||
value: reqWithoutSignature.value,
|
||||
gas: reqWithoutSignature.gas,
|
||||
deadline: reqWithoutSignature.deadline,
|
||||
data: reqWithoutSignature.data,
|
||||
signature,
|
||||
});
|
||||
const balanceAfter = await ethers.provider.getBalance(signer.address);
|
||||
expect(balanceAfter - balanceBefore).to.eq(amountOut - fee);
|
||||
expect(await token.balanceOf(signer.address)).to.eq((amountIn * refundRatio) / 100n);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,233 +0,0 @@
|
||||
/* eslint-disable node/no-unpublished-import */
|
||||
/* eslint-disable node/no-missing-import */
|
||||
import { expect } from "chai";
|
||||
import { BigNumberish, ZeroHash, concat, encodeRlp, toBeHex, toBigInt } from "ethers";
|
||||
import { ethers } from "hardhat";
|
||||
|
||||
import { L1BlockContainer } from "../typechain";
|
||||
|
||||
interface IImportTestConfig {
|
||||
hash: string;
|
||||
parentHash: string;
|
||||
uncleHash: string;
|
||||
coinbase: string;
|
||||
stateRoot: string;
|
||||
transactionsRoot: string;
|
||||
receiptsRoot: string;
|
||||
logsBloom: string;
|
||||
difficulty: BigNumberish;
|
||||
blockHeight: number;
|
||||
gasLimit: BigNumberish;
|
||||
gasUsed: BigNumberish;
|
||||
blockTimestamp: number;
|
||||
extraData: string;
|
||||
mixHash: string;
|
||||
blockNonce: string;
|
||||
baseFee: BigNumberish;
|
||||
}
|
||||
|
||||
const testcases: Array<IImportTestConfig> = [
|
||||
{
|
||||
hash: "0x02250e97ef862444dd1d70acbe925c289bb2acf20a808cb8f4d1409d3adcfa1b",
|
||||
parentHash: "0x95e612b2a734f5a8c6aad3f6662b18f983ce8b653854d7c307bf999d9be323af",
|
||||
uncleHash: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
coinbase: "0x690b9a9e9aa1c9db991c7721a92d351db4fac990",
|
||||
stateRoot: "0x8d77db2a63cee63ae6d793f839a7513dfc50194f325b96a5326d724f5dc16320",
|
||||
transactionsRoot: "0xe4ce5f0e2fc5fd8a7ad55c2a31c522ded4054b89065c627d26230b45cd585fed",
|
||||
receiptsRoot: "0x10b2f34da3e6a1db9498ab36bb17b063763b8eb33492ccc621491b33bcb62bdd",
|
||||
logsBloom:
|
||||
"0x18b80159addab073ac340045c4ef982442653840c8074a50159bd9626ae0590740d07273d0c859005b634059c8ca9bb18364573e7ebe79a40aa08225942370c3dc6c0af2ea33cba07900961de2b011aabb8024270d4626d1028a2f0dcd780c60ce933b169b02c8c329c18b000aaf08c98245d8ad949e7d61102d5516489fa924f390c3a71642d7e6044c85a20952568d60cf24c38baff04c244b10eac87a6da8bb32c1535ea2613064a246d598c02444624a8d5a1b201a4270a7868a97aa4530838c2e7a192a88e329daf0334c728b7c057f684f1d28c07d0d2c1dc63868a1088010ae0b661073142e468ae062151e00e5108400e1a99c4111153828610874bb",
|
||||
difficulty: "0x0",
|
||||
blockHeight: 0xf766a8,
|
||||
gasLimit: "0x1c9c380",
|
||||
gasUsed: "0xe6f194",
|
||||
blockTimestamp: 0x639f69e3,
|
||||
extraData: "0x406275696c64657230783639",
|
||||
mixHash: "0xc1e37ce2b7ece4556ec87ea6d420a1a3610d49c58dfccec6998222fbf9cd64a2",
|
||||
blockNonce: "0x0000000000000000",
|
||||
baseFee: "0x2b96fa5cc",
|
||||
},
|
||||
{
|
||||
hash: "0x2da4bf7cef55d6207af2095db5543df16acbd95dc66eef02d9764277c5b0895d",
|
||||
parentHash: "0xde18012932b21820fbb48ef85b46774873383e75b062bc0c6a4761fbe87bad13",
|
||||
uncleHash: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
coinbase: "0x690b9a9e9aa1c9db991c7721a92d351db4fac990",
|
||||
stateRoot: "0x1f101f54c3df5630c9d45224c95d71a57479992e174cdbda0c4ada30e657a465",
|
||||
transactionsRoot: "0xc2b29438a5f55998879356cbc8006a90d2ba88a9841b3894c8da5840dd797f19",
|
||||
receiptsRoot: "0xbd3608b6af5464b446db44fd289a980f417447b31ff15dd6d48c72fc8f4fef8d",
|
||||
logsBloom:
|
||||
"0xd9e5f4f1e559388eb8193295ab2d3aab30c588d31e381c4060715d0a7ce607360b15d7a0d88e406c60135e0abcecd1d816c11f8cbbb2a80a9b4a00375d6cf356cb78f2934261ab09ea03df29dab5dbe4aefea506f7fd0eaa1a8b1fc8db5079613a49d80ca7e7997a20c7158399022c1dc9853f5b401b86587249fc96ca6fbc2dab1fdeb203ca258c94dd0bc821b38f9f60128591f3cd224c5c207b76b754e537bef8ebe731effae356235dd71bd7b5494bead124a8b5bb0ba02e46721d3ec3c20608880b1d35a17f6a1027d20c7b902e5d7b2ec8177b1aff9dcfbb4729d1e3201e78fa1b3c30e66a590cb5a7cac7afe0b0b1a6c94d5e39c9a20908358b805c81",
|
||||
difficulty: "0x0",
|
||||
blockHeight: 0xf766d8,
|
||||
gasLimit: "0x1c9c380",
|
||||
gasUsed: "0xf8adad",
|
||||
blockTimestamp: 0x639f6c23,
|
||||
extraData: "0x6275696c64657230783639",
|
||||
mixHash: "0x6066061b78b385483d960faa29ee40e79ea67769f5e697ecb70a0fce677804af",
|
||||
blockNonce: "0x0000000000000000",
|
||||
baseFee: "0x2aca8b608",
|
||||
},
|
||||
{
|
||||
hash: "0x4ddeee3e8d62e961080711e48d8083f164789e78cc90e4362c133063b566d64a",
|
||||
parentHash: "0x9d190c6d49352d628e321853967dd499d78c521daad73652ed1978db5652f58a",
|
||||
uncleHash: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
coinbase: "0xcd458d7f11023556cc9058f729831a038cb8df9c",
|
||||
stateRoot: "0x3620665f9d094aac16e0762b733e814f4e09177a232f85d406271b60e4f2b58f",
|
||||
transactionsRoot: "0x200f5acb65631c48c32c94ae95afe095134132939a01422da5c7c6d0e7f62cb3",
|
||||
receiptsRoot: "0xc140420782bc76ff326d18b13427c991e9434a554b9ae82bbf09cca7b6ae4036",
|
||||
logsBloom:
|
||||
"0x00a8cd20c1402037d2a51100c0895279410502288134d22313912bb7b42e504f850f417d9000000a41949b284b40210406019c0e28122d462c05c11120ac2c680800c0348066a23e7a9e042a9d20e4e0041114830d443160a46b5e02ec300d41330cf0652602140e1580b4c82d1228c000005be72c900f7152093d93ca4880062185952cacc6c8d1405a0c5823bb4284a04a44c92b41462c2420a870685438809a99850acc936c408c24e882a01517086a20a067a2e4e01a20e106078828706c7c00a0234e6830c80b911900291a134475208a4335ab0018a9048d4628186043303b722a79645a104c0e12a506404f45c428660a105d105010482852540b9a6b",
|
||||
difficulty: "0x2ae28b0d3154b6",
|
||||
blockHeight: 0xecb6fc,
|
||||
gasLimit: "0x1c9c30d",
|
||||
gasUsed: "0xb93955",
|
||||
blockTimestamp: 0x631d8207,
|
||||
extraData: "0x706f6f6c696e2e636f6d2050cabdd319bf3175",
|
||||
mixHash: "0x18d61005875e902e1bbba1045fd6701df170230c0ffb37f2e77fbc2051b987cf",
|
||||
blockNonce: "0xe8775f73466671e3",
|
||||
baseFee: "0x18c9de157",
|
||||
},
|
||||
];
|
||||
|
||||
function encodeHeader(test: IImportTestConfig): string {
|
||||
return encodeRlp([
|
||||
test.parentHash,
|
||||
test.uncleHash,
|
||||
test.coinbase,
|
||||
test.stateRoot,
|
||||
test.transactionsRoot,
|
||||
test.receiptsRoot,
|
||||
test.logsBloom,
|
||||
toBigInt(test.difficulty) === 0n ? "0x" : toBeHex(test.difficulty),
|
||||
toBeHex(test.blockHeight),
|
||||
toBeHex(test.gasLimit),
|
||||
toBeHex(test.gasUsed),
|
||||
toBeHex(test.blockTimestamp),
|
||||
test.extraData,
|
||||
test.mixHash,
|
||||
test.blockNonce,
|
||||
toBeHex(test.baseFee),
|
||||
]);
|
||||
}
|
||||
|
||||
describe("L1BlockContainer", async () => {
|
||||
let container: L1BlockContainer;
|
||||
|
||||
for (const test of testcases) {
|
||||
context(`import block[${test.hash}] height[${test.blockHeight}]`, async () => {
|
||||
beforeEach(async () => {
|
||||
const [deployer] = await ethers.getSigners();
|
||||
const L1BlockContainer = await ethers.getContractFactory("L1BlockContainer", deployer);
|
||||
container = await L1BlockContainer.deploy(deployer.address);
|
||||
|
||||
const Whitelist = await ethers.getContractFactory("Whitelist", deployer);
|
||||
const whitelist = await Whitelist.deploy(deployer.address);
|
||||
await whitelist.updateWhitelistStatus([deployer.address], true);
|
||||
|
||||
await container.updateWhitelist(whitelist.getAddress());
|
||||
});
|
||||
|
||||
it("should revert, when sender not allowed", async () => {
|
||||
const [, signer] = await ethers.getSigners();
|
||||
await container.initialize(
|
||||
test.parentHash,
|
||||
test.blockHeight - 1,
|
||||
test.blockTimestamp - 1,
|
||||
test.baseFee,
|
||||
test.stateRoot
|
||||
);
|
||||
|
||||
await expect(container.connect(signer).importBlockHeader(ZeroHash, "0x", false)).to.revertedWith(
|
||||
"Not whitelisted sender"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when block hash mismatch", async () => {
|
||||
await container.initialize(
|
||||
test.parentHash,
|
||||
test.blockHeight - 1,
|
||||
test.blockTimestamp - 1,
|
||||
test.baseFee,
|
||||
test.stateRoot
|
||||
);
|
||||
const headerRLP = encodeHeader(test);
|
||||
await expect(container.importBlockHeader(test.parentHash, headerRLP, false)).to.revertedWith(
|
||||
"Block hash mismatch"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when has extra bytes", async () => {
|
||||
await container.initialize(
|
||||
test.parentHash,
|
||||
test.blockHeight - 1,
|
||||
test.blockTimestamp - 1,
|
||||
test.baseFee,
|
||||
test.stateRoot
|
||||
);
|
||||
const headerRLP = encodeHeader(test);
|
||||
await expect(container.importBlockHeader(test.hash, concat([headerRLP, "0x00"]), false)).to.revertedWith(
|
||||
"Header RLP length mismatch"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when parent not imported", async () => {
|
||||
await container.initialize(
|
||||
ZeroHash,
|
||||
test.blockHeight - 1,
|
||||
test.blockTimestamp - 1,
|
||||
test.baseFee,
|
||||
test.stateRoot
|
||||
);
|
||||
const headerRLP = encodeHeader(test);
|
||||
await expect(container.importBlockHeader(test.hash, headerRLP, false)).to.revertedWith("Parent not imported");
|
||||
});
|
||||
|
||||
it("should revert, when block height mismatch", async () => {
|
||||
await container.initialize(
|
||||
test.parentHash,
|
||||
test.blockHeight,
|
||||
test.blockTimestamp - 1,
|
||||
test.baseFee,
|
||||
test.stateRoot
|
||||
);
|
||||
const headerRLP = encodeHeader(test);
|
||||
await expect(container.importBlockHeader(test.hash, headerRLP, false)).to.revertedWith("Block height mismatch");
|
||||
});
|
||||
|
||||
it("should revert, when parent block has larger timestamp", async () => {
|
||||
await container.initialize(
|
||||
test.parentHash,
|
||||
test.blockHeight - 1,
|
||||
test.blockTimestamp + 1,
|
||||
test.baseFee,
|
||||
test.stateRoot
|
||||
);
|
||||
const headerRLP = encodeHeader(test);
|
||||
await expect(container.importBlockHeader(test.hash, headerRLP, false)).to.revertedWith(
|
||||
"Parent block has larger timestamp"
|
||||
);
|
||||
});
|
||||
|
||||
it(`should succeed`, async () => {
|
||||
await container.initialize(
|
||||
test.parentHash,
|
||||
test.blockHeight - 1,
|
||||
test.blockTimestamp - 1,
|
||||
test.baseFee,
|
||||
test.stateRoot
|
||||
);
|
||||
expect(await container.latestBlockHash()).to.eq(test.parentHash);
|
||||
const headerRLP = encodeHeader(test);
|
||||
await expect(container.importBlockHeader(test.hash, headerRLP, false))
|
||||
.to.emit(container, "ImportBlock")
|
||||
.withArgs(test.hash, test.blockHeight, test.blockTimestamp, test.baseFee, test.stateRoot);
|
||||
expect(await container.getStateRoot(test.hash)).to.eq(test.stateRoot);
|
||||
expect(await container.getBlockTimestamp(test.hash)).to.eq(test.blockTimestamp);
|
||||
expect(await container.latestBlockHash()).to.eq(test.hash);
|
||||
expect(await container.latestBaseFee()).to.eq(test.baseFee);
|
||||
expect(await container.latestBlockNumber()).to.eq(test.blockHeight);
|
||||
expect(await container.latestBlockTimestamp()).to.eq(test.blockTimestamp);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,393 +0,0 @@
|
||||
/* eslint-disable node/no-unpublished-import */
|
||||
/* eslint-disable node/no-missing-import */
|
||||
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { ethers } from "hardhat";
|
||||
|
||||
import { L1MessageQueue, L2GasPriceOracle } from "../typechain";
|
||||
import {
|
||||
MaxUint256,
|
||||
ZeroAddress,
|
||||
concat,
|
||||
encodeRlp,
|
||||
getAddress,
|
||||
hexlify,
|
||||
keccak256,
|
||||
randomBytes,
|
||||
toBeHex,
|
||||
toBigInt,
|
||||
} from "ethers";
|
||||
|
||||
describe("L1MessageQueue", async () => {
|
||||
let deployer: HardhatEthersSigner;
|
||||
let scrollChain: HardhatEthersSigner;
|
||||
let messenger: HardhatEthersSigner;
|
||||
let gateway: HardhatEthersSigner;
|
||||
let signer: HardhatEthersSigner;
|
||||
|
||||
let oracle: L2GasPriceOracle;
|
||||
let queue: L1MessageQueue;
|
||||
|
||||
const deployProxy = async (name: string, admin: string, args: any[]): Promise<string> => {
|
||||
const TransparentUpgradeableProxy = await ethers.getContractFactory("TransparentUpgradeableProxy", deployer);
|
||||
const Factory = await ethers.getContractFactory(name, deployer);
|
||||
const impl = args.length > 0 ? await Factory.deploy(...args) : await Factory.deploy();
|
||||
const proxy = await TransparentUpgradeableProxy.deploy(impl.getAddress(), admin, "0x");
|
||||
return proxy.getAddress();
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
[deployer, scrollChain, messenger, gateway, signer] = await ethers.getSigners();
|
||||
|
||||
const ProxyAdmin = await ethers.getContractFactory("ProxyAdmin", deployer);
|
||||
const admin = await ProxyAdmin.deploy();
|
||||
|
||||
queue = await ethers.getContractAt(
|
||||
"L1MessageQueue",
|
||||
await deployProxy("L1MessageQueue", await admin.getAddress(), [
|
||||
messenger.address,
|
||||
scrollChain.address,
|
||||
gateway.address,
|
||||
]),
|
||||
deployer
|
||||
);
|
||||
|
||||
oracle = await ethers.getContractAt(
|
||||
"L2GasPriceOracle",
|
||||
await deployProxy("L2GasPriceOracle", await admin.getAddress(), []),
|
||||
deployer
|
||||
);
|
||||
|
||||
await oracle.initialize(21000, 50000, 8, 16);
|
||||
await queue.initialize(messenger.address, scrollChain.address, ZeroAddress, oracle.getAddress(), 10000000);
|
||||
});
|
||||
|
||||
context("auth", async () => {
|
||||
it("should initialize correctly", async () => {
|
||||
expect(await queue.owner()).to.eq(deployer.address);
|
||||
expect(await queue.messenger()).to.eq(messenger.address);
|
||||
expect(await queue.scrollChain()).to.eq(scrollChain.address);
|
||||
expect(await queue.enforcedTxGateway()).to.eq(gateway.address);
|
||||
expect(await queue.gasOracle()).to.eq(await oracle.getAddress());
|
||||
expect(await queue.maxGasLimit()).to.eq(10000000);
|
||||
});
|
||||
|
||||
it("should revert, when initialize again", async () => {
|
||||
await expect(queue.initialize(ZeroAddress, ZeroAddress, ZeroAddress, ZeroAddress, 0)).to.revertedWith(
|
||||
"Initializable: contract is already initialized"
|
||||
);
|
||||
});
|
||||
|
||||
context("#updateGasOracle", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(queue.connect(signer).updateGasOracle(ZeroAddress)).to.revertedWith(
|
||||
"Ownable: caller is not the owner"
|
||||
);
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await queue.gasOracle()).to.eq(await oracle.getAddress());
|
||||
await expect(queue.updateGasOracle(deployer.address))
|
||||
.to.emit(queue, "UpdateGasOracle")
|
||||
.withArgs(await oracle.getAddress(), deployer.address);
|
||||
expect(await queue.gasOracle()).to.eq(deployer.address);
|
||||
});
|
||||
});
|
||||
|
||||
context("#updateMaxGasLimit", async () => {
|
||||
it("should revert, when non-owner call", async () => {
|
||||
await expect(queue.connect(signer).updateMaxGasLimit(0)).to.revertedWith("Ownable: caller is not the owner");
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await queue.maxGasLimit()).to.eq(10000000);
|
||||
await expect(queue.updateMaxGasLimit(0)).to.emit(queue, "UpdateMaxGasLimit").withArgs(10000000, 0);
|
||||
expect(await queue.maxGasLimit()).to.eq(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context("#computeTransactionHash", async () => {
|
||||
it("should succeed", async () => {
|
||||
const sender = "0xb2a70fab1a45b1b9be443b6567849a1702bc1232";
|
||||
const target = "0xcb18150e4efefb6786130e289a5f61a82a5b86d7";
|
||||
const transactionType = "0x7E";
|
||||
|
||||
for (const nonce of [0n, 1n, 127n, 128n, 22334455n, MaxUint256]) {
|
||||
for (const value of [0n, 1n, 127n, 128n, 22334455n, MaxUint256]) {
|
||||
for (const gasLimit of [0n, 1n, 127n, 128n, 22334455n, MaxUint256]) {
|
||||
for (const dataLen of [0, 1, 2, 3, 4, 55, 56, 100]) {
|
||||
const tests = [randomBytes(dataLen)];
|
||||
if (dataLen === 1) {
|
||||
for (const byte of [0, 1, 127, 128]) {
|
||||
tests.push(Uint8Array.from([byte]));
|
||||
}
|
||||
}
|
||||
for (const data of tests) {
|
||||
const transactionPayload = encodeRlp([
|
||||
nonce === 0n ? "0x" : toBeHex(nonce),
|
||||
gasLimit === 0n ? "0x" : toBeHex(gasLimit),
|
||||
target,
|
||||
value === 0n ? "0x" : toBeHex(value),
|
||||
data,
|
||||
sender,
|
||||
]);
|
||||
const payload = concat([transactionType, transactionPayload]);
|
||||
const expectedHash = keccak256(payload);
|
||||
const computedHash = await queue.computeTransactionHash(sender, nonce, value, target, gasLimit, data);
|
||||
if (computedHash !== expectedHash) {
|
||||
console.log(hexlify(transactionPayload));
|
||||
console.log(nonce, gasLimit, target, value, data, sender);
|
||||
}
|
||||
expect(expectedHash).to.eq(computedHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
context("#appendCrossDomainMessage", async () => {
|
||||
it("should revert, when non-messenger call", async () => {
|
||||
await expect(queue.connect(signer).appendCrossDomainMessage(ZeroAddress, 0, "0x")).to.revertedWith(
|
||||
"Only callable by the L1ScrollMessenger"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when exceed maxGasLimit", async () => {
|
||||
await expect(queue.connect(messenger).appendCrossDomainMessage(ZeroAddress, 10000001, "0x")).to.revertedWith(
|
||||
"Gas limit must not exceed maxGasLimit"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when below intrinsic gas", async () => {
|
||||
await expect(queue.connect(messenger).appendCrossDomainMessage(ZeroAddress, 0, "0x")).to.revertedWith(
|
||||
"Insufficient gas limit, must be above intrinsic gas"
|
||||
);
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await queue.nextCrossDomainMessageIndex()).to.eq(0n);
|
||||
const sender = getAddress(
|
||||
toBeHex((toBigInt(messenger.address) + toBigInt("0x1111000000000000000000000000000000001111")) % 2n ** 160n)
|
||||
.slice(2)
|
||||
.padStart(40, "0")
|
||||
);
|
||||
const hash = await queue.computeTransactionHash(sender, 0, 0, signer.address, 100000, "0x01");
|
||||
await expect(queue.connect(messenger).appendCrossDomainMessage(signer.address, 100000, "0x01"))
|
||||
.to.emit(queue, "QueueTransaction")
|
||||
.withArgs(sender, signer.address, 0, 0, 100000, "0x01");
|
||||
expect(await queue.nextCrossDomainMessageIndex()).to.eq(1n);
|
||||
expect(await queue.getCrossDomainMessage(0)).to.eq(hash);
|
||||
});
|
||||
});
|
||||
|
||||
context("#appendEnforcedTransaction", async () => {
|
||||
it("should revert, when non-gateway call", async () => {
|
||||
await expect(
|
||||
queue.connect(signer).appendEnforcedTransaction(signer.address, ZeroAddress, 0, 0, "0x")
|
||||
).to.revertedWith("Only callable by the EnforcedTxGateway");
|
||||
});
|
||||
|
||||
it("should revert, when sender is not EOA", async () => {
|
||||
await expect(
|
||||
queue.connect(gateway).appendEnforcedTransaction(queue.getAddress(), ZeroAddress, 0, 0, "0x")
|
||||
).to.revertedWith("only EOA");
|
||||
});
|
||||
|
||||
it("should revert, when exceed maxGasLimit", async () => {
|
||||
await expect(
|
||||
queue.connect(gateway).appendEnforcedTransaction(signer.address, ZeroAddress, 0, 10000001, "0x")
|
||||
).to.revertedWith("Gas limit must not exceed maxGasLimit");
|
||||
});
|
||||
|
||||
it("should revert, when below intrinsic gas", async () => {
|
||||
await expect(
|
||||
queue.connect(gateway).appendEnforcedTransaction(signer.address, ZeroAddress, 0, 0, "0x")
|
||||
).to.revertedWith("Insufficient gas limit, must be above intrinsic gas");
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
expect(await queue.nextCrossDomainMessageIndex()).to.eq(0n);
|
||||
const sender = signer.address;
|
||||
const hash = await queue.computeTransactionHash(sender, 0, 200, signer.address, 100000, "0x01");
|
||||
await expect(
|
||||
queue.connect(gateway).appendEnforcedTransaction(signer.address, signer.address, 200, 100000, "0x01")
|
||||
)
|
||||
.to.emit(queue, "QueueTransaction")
|
||||
.withArgs(sender, signer.address, 200, 0, 100000, "0x01");
|
||||
expect(await queue.nextCrossDomainMessageIndex()).to.eq(1n);
|
||||
expect(await queue.getCrossDomainMessage(0)).to.eq(hash);
|
||||
});
|
||||
});
|
||||
|
||||
context("#popCrossDomainMessage", async () => {
|
||||
it("should revert, when non-scrollChain call", async () => {
|
||||
await expect(queue.connect(signer).popCrossDomainMessage(0, 0, 0)).to.revertedWith(
|
||||
"Only callable by the ScrollChain"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when pop too many messages", async () => {
|
||||
await expect(queue.connect(scrollChain).popCrossDomainMessage(0, 257, 0)).to.revertedWith(
|
||||
"pop too many messages"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when start index mismatch", async () => {
|
||||
await expect(queue.connect(scrollChain).popCrossDomainMessage(1, 256, 0)).to.revertedWith("start index mismatch");
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
// append 512 messages
|
||||
for (let i = 0; i < 256 * 2; i++) {
|
||||
await queue.connect(messenger).appendCrossDomainMessage(ZeroAddress, 1000000, "0x");
|
||||
}
|
||||
|
||||
// pop 50 messages with no skip
|
||||
await expect(queue.connect(scrollChain).popCrossDomainMessage(0, 50, 0))
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(0, 50, 0);
|
||||
for (let i = 0; i < 50; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(false);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
}
|
||||
expect(await queue.pendingQueueIndex()).to.eq(50);
|
||||
|
||||
// pop 10 messages all skip
|
||||
await expect(queue.connect(scrollChain).popCrossDomainMessage(50, 10, 1023))
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(50, 10, 1023);
|
||||
expect(await queue.pendingQueueIndex()).to.eq(60);
|
||||
for (let i = 50; i < 60; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(true);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
}
|
||||
|
||||
// pop 20 messages, skip first 5
|
||||
await expect(queue.connect(scrollChain).popCrossDomainMessage(60, 20, 31))
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(60, 20, 31);
|
||||
expect(await queue.pendingQueueIndex()).to.eq(80);
|
||||
for (let i = 60; i < 65; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(true);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
}
|
||||
for (let i = 65; i < 80; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(false);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
}
|
||||
|
||||
// pop 256 messages with random skip
|
||||
const bitmap = toBigInt("0x496525059c3f33758d17030403e45afe067b8a0ae1317cda0487fd2932cbea1a");
|
||||
const tx = await queue.connect(scrollChain).popCrossDomainMessage(80, 256, bitmap);
|
||||
await expect(tx).to.emit(queue, "DequeueTransaction").withArgs(80, 256, bitmap);
|
||||
console.log("gas used:", (await tx.wait())!.gasUsed.toString());
|
||||
for (let i = 80; i < 80 + 256; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(((bitmap >> toBigInt(i - 80)) & 1n) === 1n);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
}
|
||||
});
|
||||
|
||||
// @note skip this random benchmark tests
|
||||
for (const count1 of [1, 2, 128, 129, 256]) {
|
||||
for (const count2 of [1, 2, 128, 129, 256]) {
|
||||
for (const count3 of [1, 2, 128, 129, 256]) {
|
||||
it.skip(`should succeed on random tests, pop three times each with ${count1} ${count2} ${count3} msgs`, async () => {
|
||||
// append count1 + count2 + count3 messages
|
||||
for (let i = 0; i < count1 + count2 + count3; i++) {
|
||||
await queue.connect(messenger).appendCrossDomainMessage(ZeroAddress, 1000000, "0x");
|
||||
}
|
||||
|
||||
// first pop `count1` messages
|
||||
const bitmap1 = toBigInt(randomBytes(32));
|
||||
let tx = await queue.connect(scrollChain).popCrossDomainMessage(0, count1, bitmap1);
|
||||
await expect(tx)
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(0, count1, bitmap1 & ((1n << toBigInt(count1)) - 1n));
|
||||
for (let i = 0; i < count1; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(((bitmap1 >> toBigInt(i)) & 1n) === 1n);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
}
|
||||
|
||||
// then pop `count2` messages
|
||||
const bitmap2 = toBigInt(randomBytes(32));
|
||||
tx = await queue.connect(scrollChain).popCrossDomainMessage(count1, count2, bitmap2);
|
||||
await expect(tx)
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(count1, count2, bitmap2 & ((1n << toBigInt(count2)) - 1n));
|
||||
for (let i = 0; i < count2; i++) {
|
||||
expect(await queue.isMessageSkipped(i + count1)).to.eq(((bitmap2 >> toBigInt(i)) & 1n) === 1n);
|
||||
expect(await queue.isMessageDropped(i + count1)).to.eq(false);
|
||||
}
|
||||
|
||||
// last pop `count3` messages
|
||||
const bitmap3 = toBigInt(randomBytes(32));
|
||||
tx = await queue.connect(scrollChain).popCrossDomainMessage(count1 + count2, count3, bitmap3);
|
||||
await expect(tx)
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(count1 + count2, count3, bitmap3 & ((1n << toBigInt(count3)) - 1n));
|
||||
for (let i = 0; i < count3; i++) {
|
||||
expect(await queue.isMessageSkipped(i + count1 + count2)).to.eq(((bitmap3 >> toBigInt(i)) & 1n) === 1n);
|
||||
expect(await queue.isMessageDropped(i + count1 + count2)).to.eq(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
context("#dropCrossDomainMessage", async () => {
|
||||
it("should revert, when non-messenger call", async () => {
|
||||
await expect(queue.connect(signer).dropCrossDomainMessage(0)).to.revertedWith(
|
||||
"Only callable by the L1ScrollMessenger"
|
||||
);
|
||||
});
|
||||
|
||||
it("should revert, when drop non-skipped message", async () => {
|
||||
// append 10 messages
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await queue.connect(messenger).appendCrossDomainMessage(ZeroAddress, 1000000, "0x");
|
||||
}
|
||||
// pop 5 messages with no skip
|
||||
await expect(queue.connect(scrollChain).popCrossDomainMessage(0, 5, 0))
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(0, 5, 0);
|
||||
for (let i = 0; i < 5; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(false);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
}
|
||||
expect(await queue.pendingQueueIndex()).to.eq(5);
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await expect(queue.connect(messenger).dropCrossDomainMessage(i)).to.revertedWith("drop non-skipped message");
|
||||
}
|
||||
|
||||
// drop pending message
|
||||
for (let i = 6; i < 10; i++) {
|
||||
await expect(queue.connect(messenger).dropCrossDomainMessage(i)).to.revertedWith("cannot drop pending message");
|
||||
}
|
||||
});
|
||||
|
||||
it("should succeed", async () => {
|
||||
// append 10 messages
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await queue.connect(messenger).appendCrossDomainMessage(ZeroAddress, 1000000, "0x");
|
||||
}
|
||||
// pop 10 messages, all skipped
|
||||
await expect(queue.connect(scrollChain).popCrossDomainMessage(0, 10, 0x3ff))
|
||||
.to.emit(queue, "DequeueTransaction")
|
||||
.withArgs(0, 10, 0x3ff);
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(true);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(false);
|
||||
await expect(queue.connect(messenger).dropCrossDomainMessage(i)).to.emit(queue, "DropTransaction").withArgs(i);
|
||||
await expect(queue.connect(messenger).dropCrossDomainMessage(i)).to.revertedWith("message already dropped");
|
||||
expect(await queue.isMessageSkipped(i)).to.eq(true);
|
||||
expect(await queue.isMessageDropped(i)).to.eq(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user