diff --git a/.github/workflows/deb_packager.yml b/.github/workflows/deb_packager.yml new file mode 100644 index 000000000..5897ee6f3 --- /dev/null +++ b/.github/workflows/deb_packager.yml @@ -0,0 +1,84 @@ +name: deb_packager +# test + +on: + push: + branches: + - 'main' + paths: + - '**' + tags: + - 'v*.*.*' + - 'v*.*.*-*' + +jobs: + build: + permissions: + id-token: write + contents: write + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@master + with: + go-version: 1.22.x + # Variables + - name: Adding TAG to ENV + run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV + - name: adding version + run: | + NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' ) + echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV + + - name: build the binary + run: make build + + - name: making directory structure + run: mkdir -p packaging/deb/zkevm-bridge/usr/bin/ + - name: copying necessary binary for amd64 + run: cp -rp dist/zkevm-bridge packaging/deb/zkevm-bridge/usr/bin/zkevm-bridge + - name: create directory for service file + run: mkdir -p packaging/deb/zkevm-bridge/lib/systemd/system + - name: copy the service file + run: cp -rp packaging/systemd/zkevm-bridge.service packaging/deb/zkevm-bridge/lib/systemd/system/ + + + # Control file creation + - name: create control file + run: | + echo "Package: zkevm-bridge" >> packaging/deb/zkevm-bridge/DEBIAN/control + echo "Version: ${{ env.VERSION }}" >> packaging/deb/zkevm-bridge/DEBIAN/control + echo "Section: base" >> packaging/deb/zkevm-bridge/DEBIAN/control + echo "Priority: optional" >> packaging/deb/zkevm-bridge/DEBIAN/control + echo "Architecture: amd64" >> packaging/deb/zkevm-bridge/DEBIAN/control + echo "Maintainer: devops@polygon.technology" >> packaging/deb/zkevm-bridge/DEBIAN/control + echo "Description: zkevm-bridge binary package" >> packaging/deb/zkevm-bridge/DEBIAN/control + + - name: Creating package for binary for zkevm-bridge ${{ env.ARCH }} + run: cp -rp packaging/deb/zkevm-bridge packaging/deb/zkevm-bridge-${{ env.GIT_TAG }}-${{ env.ARCH }} + env: + ARCH: amd64 + + - name: Running package build + run: dpkg-deb --build --root-owner-group packaging/deb/zkevm-bridge-${{ env.GIT_TAG }}-${{ env.ARCH }} + env: + ARCH: amd64 + + - name: create checksum for the amd64 package + run: cd packaging/deb/ && sha256sum zkevm-bridge-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb > zkevm-bridge-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb.checksum + env: + ARCH: amd64 + + + - name: Release zkevm-bridge Packages + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.GIT_TAG }} + prerelease: true + files: | + packaging/deb/zkevm-bridge**.deb + packaging/deb/zkevm-bridge**.deb.checksum \ No newline at end of file diff --git a/.github/workflows/regression-tests.yml b/.github/workflows/regression-tests.yml new file mode 100644 index 000000000..831776b2b --- /dev/null +++ b/.github/workflows/regression-tests.yml @@ -0,0 +1,35 @@ +name: Regression Tests + +on: + pull_request: + types: [opened, synchronize] # Trigger on new PR and existing with new commits + branches: + - develop + + +jobs: + regression_tests: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Build image (with proposed code changes) locally + id: build + run: | + if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then + GITHUB_SHA_SHORT=$(jq -r .pull_request.head.sha "$GITHUB_EVENT_PATH" | cut -c 1-7) + echo $GITHUB_SHA_SHORT + echo "::set-output name=GITHUB_SHA_SHORT::$GITHUB_SHA_SHORT" + fi + - name: Run Regression Tests + uses: 0xPolygon/kurtosis-cdk@v0.1.9 + with: + zkevm_bridge_service: ${{ steps.build.outputs.GITHUB_SHA_SHORT }} + zkevm_agglayer: '0.1.4' + zkevm_bridge_ui: '0006445' + zkevm_dac: '0.0.7' + zkevm_node: '0.6.5-cdk' + kurtosis_cdk: 'v0.2.3' + kurtosis_cli: '0.89.3' + bake_time: 30 \ No newline at end of file diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index d99808f51..fe715d347 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -1,4 +1,4 @@ -name: Test +name: Test-e2e on: push: branches: diff --git a/.github/workflows/test-e2ecompress.yml b/.github/workflows/test-e2ecompress.yml index 624f99531..6061295da 100644 --- a/.github/workflows/test-e2ecompress.yml +++ b/.github/workflows/test-e2ecompress.yml @@ -1,4 +1,4 @@ -name: Test +name: Test-e2compress on: push: branches: diff --git a/.github/workflows/test-edge.yml b/.github/workflows/test-edge.yml index 7f933d128..957b134de 100644 --- a/.github/workflows/test-edge.yml +++ b/.github/workflows/test-edge.yml @@ -1,4 +1,4 @@ -name: Test +name: Test-edge on: push: branches: diff --git a/DockerfileE2ETest b/DockerfileE2ETest new file mode 100644 index 000000000..3562c4631 --- /dev/null +++ b/DockerfileE2ETest @@ -0,0 +1,18 @@ +# CONTAINER FOR BUILDING BINARY +FROM golang:1.21 AS build + +ENV CGO_ENABLED=0 + +# BUILD BINARY +COPY . /src +RUN cd /src && make build-test-e2e-real_network + +# CONTAINER FOR RUNNING BINARY +FROM alpine:3.16.0 AS ERC20 +COPY --from=build /src/dist/zkevm-bridge-e2e-real_network-erc20 /app/zkevm-bridge-e2e-real_network-erc20 +CMD ["/bin/sh", "-c", "/app/zkevm-bridge-e2e-real_network-erc20 -test.failfast -test.v"] + +# CONTAINER FOR RUNNING BINARY +FROM alpine:3.16.0 AS MSG +COPY --from=build /src/dist/zkevm-bridge-e2e-real_network-bridgemsg /app/zkevm-bridge-e2e-real_network-bridgemsg +CMD ["/bin/sh", "-c", "/app/zkevm-bridge-e2e-real_network-bridgemsg -test.failfast -test.v"] diff --git a/Makefile b/Makefile index 50dbee49e..0a47afb9d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include version.mk -DOCKER_COMPOSE := docker-compose -f docker-compose.yml +DOCKER_COMPOSE := docker compose -f docker-compose.yml DOCKER_COMPOSE_STATE_DB := zkevm-state-db DOCKER_COMPOSE_POOL_DB := zkevm-pool-db DOCKER_COMPOSE_RPC_DB := zkevm-rpc-db @@ -87,6 +87,18 @@ install-linter: ## Installs the linter build-docker: ## Builds a docker image with the zkevm bridge binary docker build -t zkevm-bridge-service -f ./Dockerfile . +.PHONY: build-docker-e2e-real_network +build-docker-e2e-real_network: build-docker-e2e-real_network-erc20 build-docker-e2e-real_network-msg ## Builds a docker image with the zkevm bridge binary for e2e tests with real network + + +.PHONY: build-docker-e2e-real_network-erc20 +build-docker-e2e-real_network-erc20: ## Builds a docker image with the zkevm bridge binary for e2e ERC20 tests with real network + docker build -f DockerfileE2ETest . -t bridge-e2e-realnetwork-erc20 --target ERC20 + +.PHONY: build-docker-e2e-real_network-msg +build-docker-e2e-real_network-msg: ## Builds a docker image with the zkevm bridge binary for e2e BridgeMessage tests with real network + docker build -f DockerfileE2ETest . -t bridge-e2e-realnetwork-msg --target MSG + .PHONY: run-db-node run-db-node: ## Runs the node database $(RUN_NODE_DB) @@ -264,6 +276,13 @@ test-e2ecompress: build-docker stop run ## Runs all tests checking race conditio sleep 3 trap '$(STOP)' EXIT; MallocNanoZone=0 go test -v -failfast -race -p 1 -timeout 2400s ./test/e2e/... -count 1 -tags='e2ecompress' +.PHONY: build-test-e2e-real_network +build-test-e2e-real_network: ## Build binary for e2e tests with real network + go test -c ./test/e2e/ -o dist/zkevm-bridge-e2e-real_network-erc20 -tags='e2e_real_network_erc20' + go test -c ./test/e2e/ -o dist/zkevm-bridge-e2e-real_network-bridgemsg -tags='e2e_real_network_msg' + ./dist/zkevm-bridge-e2e-real_network-erc20 -test.failfast -test.list Test + ./dist/zkevm-bridge-e2e-real_network-bridgemsg -test.failfast -test.list Test + .PHONY: validate validate: lint build test-full ## Validates the whole integrity of the code base @@ -285,14 +304,13 @@ generate-mocks: ## Generates mocks for the tests, using mockery tool mockery --name=storageInterface --dir=synchronizer --output=synchronizer --outpkg=synchronizer --structname=storageMock --filename=mock_storage.go ${COMMON_MOCKERY_PARAMS} mockery --name=bridgectrlInterface --dir=synchronizer --output=synchronizer --outpkg=synchronizer --structname=bridgectrlMock --filename=mock_bridgectrl.go ${COMMON_MOCKERY_PARAMS} mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=synchronizer --outpkg=synchronizer --structname=dbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS} - mockery --name=zkEVMClientInterface --dir=synchronizer --output=synchronizer --outpkg=synchronizer --structname=zkEVMClientMock --filename=mock_zkevmclient.go ${COMMON_MOCKERY_PARAMS} + mockery --name=bridgeServiceStorage --dir=server --output=server --outpkg=server --structname=bridgeServiceStorageMock --filename=mock_bridgeServiceStorage.go ${COMMON_MOCKERY_PARAMS} + rm -Rf claimtxman/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir claimtxman/ --output claimtxman/mocks --outpkg mock_txcompressor ${COMMON_MOCKERY_PARAMS} -.PHONY: generate-smart-contracts-bindings +.PHONY: generate-smartcontracts-bindings generate-smartcontracts-bindings: ## Generates the smart contracts bindings - @for contract in `ls -1 etherman/smartcontracts/json/*.json | xargs -l basename`; do \ - ./scripts/generate-smartcontracts-bindings.sh $${contract%.*}; \ - done + cd scripts && ./generate-smartcontracts-bindings.sh \ No newline at end of file diff --git a/README.md b/README.md index 9043b9e17..3ff667a6c 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,32 @@ to interact with the [bridge smart contract](https://github.com/0xPolygonHermez/ - [Running locally](docs/running_local.md) +## Running e2e test for real networks +There are a test for ERC20 L1->L2 and L2->L1. This test is for be run externally. +For this reason you can build execution docker: +``` +make build-docker-e2e-real_network +``` + +- To run you need to pass a configuration file as `test/config/bridge_network_e2e/cardona.toml` +- Example of usage: + +``` +#!/bin/bash +make build-docker-e2e-real_network +mkdir tmp +cat < ./tmp/test.toml +TestAddrPrivate= "${{ SECRET_PRIVATE_ADDR }}" +[ConnectionConfig] +L1NodeURL="${{ SECRET_L1URL }}" +L2NodeURL="${{ L2URL }}" +BridgeURL="${{ BRIDGEURL }}" +L1BridgeAddr="${{ BRIDGE_ADDR_L1 }}" +L2BridgeAddr="${{ BRIDGE_ADDR_L2 }}" +EOF +docker run --volume "./tmp/:/config/" --env BRIDGE_TEST_CONFIG_FILE=/config/test.toml bridge-e2e-realnetwork-erc20 +``` + +## Contact + +For more discussions, please head to the [R&D Discord](https://discord.gg/0xPolygonRnD) diff --git a/bridgectrl/pb/query.pb.go b/bridgectrl/pb/query.pb.go index d8bcb7fb1..837fcd61a 100644 --- a/bridgectrl/pb/query.pb.go +++ b/bridgectrl/pb/query.pb.go @@ -3,8 +3,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v3.12.4 +// protoc-gen-go v1.34.2 +// protoc v3.20.3 // source: query.proto package pb @@ -620,6 +620,69 @@ func (x *GetProofRequest) GetDepositCnt() uint64 { return 0 } +type GetProofByGERRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NetId uint32 `protobuf:"varint,1,opt,name=net_id,json=netId,proto3" json:"net_id,omitempty"` + DepositCnt uint64 `protobuf:"varint,2,opt,name=deposit_cnt,json=depositCnt,proto3" json:"deposit_cnt,omitempty"` + Ger string `protobuf:"bytes,3,opt,name=ger,proto3" json:"ger,omitempty"` +} + +func (x *GetProofByGERRequest) Reset() { + *x = GetProofByGERRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_query_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProofByGERRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProofByGERRequest) ProtoMessage() {} + +func (x *GetProofByGERRequest) ProtoReflect() protoreflect.Message { + mi := &file_query_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetProofByGERRequest.ProtoReflect.Descriptor instead. +func (*GetProofByGERRequest) Descriptor() ([]byte, []int) { + return file_query_proto_rawDescGZIP(), []int{7} +} + +func (x *GetProofByGERRequest) GetNetId() uint32 { + if x != nil { + return x.NetId + } + return 0 +} + +func (x *GetProofByGERRequest) GetDepositCnt() uint64 { + if x != nil { + return x.DepositCnt + } + return 0 +} + +func (x *GetProofByGERRequest) GetGer() string { + if x != nil { + return x.Ger + } + return "" +} + type GetTokenWrappedRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -632,7 +695,7 @@ type GetTokenWrappedRequest struct { func (x *GetTokenWrappedRequest) Reset() { *x = GetTokenWrappedRequest{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[7] + mi := &file_query_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -645,7 +708,7 @@ func (x *GetTokenWrappedRequest) String() string { func (*GetTokenWrappedRequest) ProtoMessage() {} func (x *GetTokenWrappedRequest) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[7] + mi := &file_query_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -658,7 +721,7 @@ func (x *GetTokenWrappedRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetTokenWrappedRequest.ProtoReflect.Descriptor instead. func (*GetTokenWrappedRequest) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{7} + return file_query_proto_rawDescGZIP(), []int{8} } func (x *GetTokenWrappedRequest) GetOrigTokenAddr() string { @@ -687,7 +750,7 @@ type GetBridgeRequest struct { func (x *GetBridgeRequest) Reset() { *x = GetBridgeRequest{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[8] + mi := &file_query_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -700,7 +763,7 @@ func (x *GetBridgeRequest) String() string { func (*GetBridgeRequest) ProtoMessage() {} func (x *GetBridgeRequest) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[8] + mi := &file_query_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -713,7 +776,7 @@ func (x *GetBridgeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBridgeRequest.ProtoReflect.Descriptor instead. func (*GetBridgeRequest) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{8} + return file_query_proto_rawDescGZIP(), []int{9} } func (x *GetBridgeRequest) GetNetId() uint32 { @@ -743,7 +806,7 @@ type GetClaimsRequest struct { func (x *GetClaimsRequest) Reset() { *x = GetClaimsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[9] + mi := &file_query_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -756,7 +819,7 @@ func (x *GetClaimsRequest) String() string { func (*GetClaimsRequest) ProtoMessage() {} func (x *GetClaimsRequest) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[9] + mi := &file_query_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -769,7 +832,7 @@ func (x *GetClaimsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetClaimsRequest.ProtoReflect.Descriptor instead. func (*GetClaimsRequest) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{9} + return file_query_proto_rawDescGZIP(), []int{10} } func (x *GetClaimsRequest) GetDestAddr() string { @@ -804,7 +867,7 @@ type CheckAPIResponse struct { func (x *CheckAPIResponse) Reset() { *x = CheckAPIResponse{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[10] + mi := &file_query_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -817,7 +880,7 @@ func (x *CheckAPIResponse) String() string { func (*CheckAPIResponse) ProtoMessage() {} func (x *CheckAPIResponse) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[10] + mi := &file_query_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -830,7 +893,7 @@ func (x *CheckAPIResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckAPIResponse.ProtoReflect.Descriptor instead. func (*CheckAPIResponse) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{10} + return file_query_proto_rawDescGZIP(), []int{11} } func (x *CheckAPIResponse) GetApi() string { @@ -852,7 +915,7 @@ type GetBridgesResponse struct { func (x *GetBridgesResponse) Reset() { *x = GetBridgesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[11] + mi := &file_query_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -865,7 +928,7 @@ func (x *GetBridgesResponse) String() string { func (*GetBridgesResponse) ProtoMessage() {} func (x *GetBridgesResponse) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[11] + mi := &file_query_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -878,7 +941,7 @@ func (x *GetBridgesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBridgesResponse.ProtoReflect.Descriptor instead. func (*GetBridgesResponse) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{11} + return file_query_proto_rawDescGZIP(), []int{12} } func (x *GetBridgesResponse) GetDeposits() []*Deposit { @@ -906,7 +969,7 @@ type GetProofResponse struct { func (x *GetProofResponse) Reset() { *x = GetProofResponse{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[12] + mi := &file_query_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -919,7 +982,7 @@ func (x *GetProofResponse) String() string { func (*GetProofResponse) ProtoMessage() {} func (x *GetProofResponse) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[12] + mi := &file_query_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -932,7 +995,7 @@ func (x *GetProofResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProofResponse.ProtoReflect.Descriptor instead. func (*GetProofResponse) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{12} + return file_query_proto_rawDescGZIP(), []int{13} } func (x *GetProofResponse) GetProof() *Proof { @@ -953,7 +1016,7 @@ type GetTokenWrappedResponse struct { func (x *GetTokenWrappedResponse) Reset() { *x = GetTokenWrappedResponse{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[13] + mi := &file_query_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -966,7 +1029,7 @@ func (x *GetTokenWrappedResponse) String() string { func (*GetTokenWrappedResponse) ProtoMessage() {} func (x *GetTokenWrappedResponse) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[13] + mi := &file_query_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -979,7 +1042,7 @@ func (x *GetTokenWrappedResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetTokenWrappedResponse.ProtoReflect.Descriptor instead. func (*GetTokenWrappedResponse) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{13} + return file_query_proto_rawDescGZIP(), []int{14} } func (x *GetTokenWrappedResponse) GetTokenwrapped() *TokenWrapped { @@ -1000,7 +1063,7 @@ type GetBridgeResponse struct { func (x *GetBridgeResponse) Reset() { *x = GetBridgeResponse{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[14] + mi := &file_query_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1013,7 +1076,7 @@ func (x *GetBridgeResponse) String() string { func (*GetBridgeResponse) ProtoMessage() {} func (x *GetBridgeResponse) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[14] + mi := &file_query_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1026,7 +1089,7 @@ func (x *GetBridgeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBridgeResponse.ProtoReflect.Descriptor instead. func (*GetBridgeResponse) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{14} + return file_query_proto_rawDescGZIP(), []int{15} } func (x *GetBridgeResponse) GetDeposit() *Deposit { @@ -1048,7 +1111,7 @@ type GetClaimsResponse struct { func (x *GetClaimsResponse) Reset() { *x = GetClaimsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_query_proto_msgTypes[15] + mi := &file_query_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1061,7 +1124,7 @@ func (x *GetClaimsResponse) String() string { func (*GetClaimsResponse) ProtoMessage() {} func (x *GetClaimsResponse) ProtoReflect() protoreflect.Message { - mi := &file_query_proto_msgTypes[15] + mi := &file_query_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1074,7 +1137,7 @@ func (x *GetClaimsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetClaimsResponse.ProtoReflect.Descriptor instead. func (*GetClaimsResponse) Descriptor() ([]byte, []int) { - return file_query_proto_rawDescGZIP(), []int{15} + return file_query_proto_rawDescGZIP(), []int{16} } func (x *GetClaimsResponse) GetClaims() []*Claim { @@ -1180,94 +1243,107 @@ var file_query_proto_rawDesc = []byte{ 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6e, 0x65, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x63, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x0a, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x43, 0x6e, 0x74, 0x22, 0x5b, 0x0a, 0x16, - 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x6f, 0x72, 0x69, 0x67, 0x5f, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x12, 0x19, - 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x5f, 0x6e, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x07, 0x6f, 0x72, 0x69, 0x67, 0x4e, 0x65, 0x74, 0x22, 0x4a, 0x0a, 0x10, 0x47, 0x65, 0x74, - 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, - 0x06, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6e, - 0x65, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, - 0x63, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x43, 0x6e, 0x74, 0x22, 0x5d, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x61, 0x69, - 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x73, - 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x65, - 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, - 0x69, 0x6d, 0x69, 0x74, 0x22, 0x24, 0x0a, 0x10, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x50, 0x49, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, 0x69, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x70, 0x69, 0x22, 0x61, 0x0a, 0x12, 0x47, 0x65, - 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x2e, 0x0a, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, - 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6e, 0x74, 0x22, 0x3a, 0x0a, - 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x26, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x10, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, - 0x6f, 0x66, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x56, 0x0a, 0x17, 0x47, 0x65, 0x74, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0c, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x77, 0x72, 0x61, - 0x70, 0x70, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, 0x72, 0x69, - 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, - 0x70, 0x65, 0x64, 0x52, 0x0c, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, - 0x64, 0x22, 0x41, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x07, 0x64, 0x65, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x22, 0x5a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x63, 0x6c, 0x61, - 0x69, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x72, 0x69, 0x64, - 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x06, 0x63, 0x6c, 0x61, - 0x69, 0x6d, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6e, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6e, 0x74, - 0x32, 0xd6, 0x04, 0x0a, 0x0d, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x51, 0x0a, 0x08, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x50, 0x49, 0x12, 0x1a, - 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, - 0x41, 0x50, 0x49, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x62, 0x72, 0x69, - 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x50, 0x49, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x06, 0x12, - 0x04, 0x2f, 0x61, 0x70, 0x69, 0x12, 0x67, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, - 0x67, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1d, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, - 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x62, 0x72, 0x69, 0x64, 0x67, - 0x65, 0x73, 0x2f, 0x7b, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x7d, 0x12, 0x5a, - 0x0a, 0x08, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x1a, 0x2e, 0x62, 0x72, 0x69, - 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x6d, 0x65, - 0x72, 0x6b, 0x6c, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x57, 0x0a, 0x09, 0x47, 0x65, - 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x12, 0x1b, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, 0x62, 0x72, 0x69, - 0x64, 0x67, 0x65, 0x12, 0x63, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x73, - 0x12, 0x1b, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, - 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, - 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x61, - 0x69, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x2f, 0x7b, 0x64, 0x65, - 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x7d, 0x12, 0x6f, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x12, 0x21, 0x2e, 0x62, 0x72, - 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, - 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, - 0x6e, 0x48, 0x65, 0x72, 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, 0x6d, 0x2d, 0x62, 0x72, - 0x69, 0x64, 0x67, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x62, 0x72, 0x69, - 0x64, 0x67, 0x65, 0x74, 0x72, 0x65, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x52, 0x0a, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x43, 0x6e, 0x74, 0x22, 0x60, 0x0a, 0x14, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x42, 0x79, 0x47, 0x45, 0x52, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6e, 0x65, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x63, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0a, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x43, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, + 0x67, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x67, 0x65, 0x72, 0x22, 0x5b, + 0x0a, 0x16, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x6f, 0x72, 0x69, 0x67, + 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, + 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x5f, 0x6e, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x07, 0x6f, 0x72, 0x69, 0x67, 0x4e, 0x65, 0x74, 0x22, 0x4a, 0x0a, 0x10, 0x47, + 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x15, 0x0a, 0x06, 0x6e, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x05, 0x6e, 0x65, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x5f, 0x63, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x64, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x43, 0x6e, 0x74, 0x22, 0x5d, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x6c, + 0x61, 0x69, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x64, + 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x64, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, + 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x24, 0x0a, 0x10, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, + 0x50, 0x49, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, + 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x70, 0x69, 0x22, 0x61, 0x0a, 0x12, + 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x08, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, 0x6e, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6e, 0x74, 0x22, + 0x3a, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x56, 0x0a, 0x17, 0x47, + 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0c, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x77, + 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, + 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x57, 0x72, + 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, 0x0c, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x77, 0x72, 0x61, 0x70, + 0x70, 0x65, 0x64, 0x22, 0x41, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x64, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x62, 0x72, 0x69, 0x64, + 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x07, 0x64, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x22, 0x5a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x61, + 0x69, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x63, + 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x72, + 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x06, 0x63, + 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x63, + 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, + 0x6e, 0x74, 0x32, 0xc3, 0x05, 0x0a, 0x0d, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x08, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x50, 0x49, + 0x12, 0x1a, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x41, 0x50, 0x49, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x62, + 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x50, + 0x49, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0c, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x06, 0x12, 0x04, 0x2f, 0x61, 0x70, 0x69, 0x12, 0x67, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x42, 0x72, + 0x69, 0x64, 0x67, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x62, 0x72, 0x69, + 0x64, 0x67, 0x65, 0x73, 0x2f, 0x7b, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x7d, + 0x12, 0x5a, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x1a, 0x2e, 0x62, + 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, + 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, + 0x6d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x6b, 0x0a, 0x0d, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x42, 0x79, 0x47, 0x45, 0x52, 0x12, 0x1f, 0x2e, + 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, + 0x6f, 0x66, 0x42, 0x79, 0x47, 0x45, 0x52, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, + 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, + 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x6d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x2d, 0x70, 0x72, 0x6f, + 0x6f, 0x66, 0x2d, 0x62, 0x79, 0x2d, 0x67, 0x65, 0x72, 0x12, 0x57, 0x0a, 0x09, 0x47, 0x65, 0x74, + 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x12, 0x1b, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x47, 0x65, 0x74, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x0f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x2f, 0x62, 0x72, 0x69, 0x64, + 0x67, 0x65, 0x12, 0x63, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x12, + 0x1b, 0x2e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, + 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, + 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x61, 0x69, + 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x15, 0x12, 0x13, 0x2f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x2f, 0x7b, 0x64, 0x65, 0x73, + 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x7d, 0x12, 0x6f, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x12, 0x21, 0x2e, 0x62, 0x72, 0x69, + 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x57, + 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, + 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x12, 0x0d, 0x2f, 0x74, 0x6f, 0x6b, 0x65, + 0x6e, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, + 0x48, 0x65, 0x72, 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, 0x6d, 0x2d, 0x62, 0x72, 0x69, + 0x64, 0x67, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x62, 0x72, 0x69, 0x64, + 0x67, 0x65, 0x74, 0x72, 0x65, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -1282,8 +1358,8 @@ func file_query_proto_rawDescGZIP() []byte { return file_query_proto_rawDescData } -var file_query_proto_msgTypes = make([]protoimpl.MessageInfo, 16) -var file_query_proto_goTypes = []interface{}{ +var file_query_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_query_proto_goTypes = []any{ (*TokenWrapped)(nil), // 0: bridge.v1.TokenWrapped (*Deposit)(nil), // 1: bridge.v1.Deposit (*Claim)(nil), // 2: bridge.v1.Claim @@ -1291,15 +1367,16 @@ var file_query_proto_goTypes = []interface{}{ (*CheckAPIRequest)(nil), // 4: bridge.v1.CheckAPIRequest (*GetBridgesRequest)(nil), // 5: bridge.v1.GetBridgesRequest (*GetProofRequest)(nil), // 6: bridge.v1.GetProofRequest - (*GetTokenWrappedRequest)(nil), // 7: bridge.v1.GetTokenWrappedRequest - (*GetBridgeRequest)(nil), // 8: bridge.v1.GetBridgeRequest - (*GetClaimsRequest)(nil), // 9: bridge.v1.GetClaimsRequest - (*CheckAPIResponse)(nil), // 10: bridge.v1.CheckAPIResponse - (*GetBridgesResponse)(nil), // 11: bridge.v1.GetBridgesResponse - (*GetProofResponse)(nil), // 12: bridge.v1.GetProofResponse - (*GetTokenWrappedResponse)(nil), // 13: bridge.v1.GetTokenWrappedResponse - (*GetBridgeResponse)(nil), // 14: bridge.v1.GetBridgeResponse - (*GetClaimsResponse)(nil), // 15: bridge.v1.GetClaimsResponse + (*GetProofByGERRequest)(nil), // 7: bridge.v1.GetProofByGERRequest + (*GetTokenWrappedRequest)(nil), // 8: bridge.v1.GetTokenWrappedRequest + (*GetBridgeRequest)(nil), // 9: bridge.v1.GetBridgeRequest + (*GetClaimsRequest)(nil), // 10: bridge.v1.GetClaimsRequest + (*CheckAPIResponse)(nil), // 11: bridge.v1.CheckAPIResponse + (*GetBridgesResponse)(nil), // 12: bridge.v1.GetBridgesResponse + (*GetProofResponse)(nil), // 13: bridge.v1.GetProofResponse + (*GetTokenWrappedResponse)(nil), // 14: bridge.v1.GetTokenWrappedResponse + (*GetBridgeResponse)(nil), // 15: bridge.v1.GetBridgeResponse + (*GetClaimsResponse)(nil), // 16: bridge.v1.GetClaimsResponse } var file_query_proto_depIdxs = []int32{ 1, // 0: bridge.v1.GetBridgesResponse.deposits:type_name -> bridge.v1.Deposit @@ -1310,17 +1387,19 @@ var file_query_proto_depIdxs = []int32{ 4, // 5: bridge.v1.BridgeService.CheckAPI:input_type -> bridge.v1.CheckAPIRequest 5, // 6: bridge.v1.BridgeService.GetBridges:input_type -> bridge.v1.GetBridgesRequest 6, // 7: bridge.v1.BridgeService.GetProof:input_type -> bridge.v1.GetProofRequest - 8, // 8: bridge.v1.BridgeService.GetBridge:input_type -> bridge.v1.GetBridgeRequest - 9, // 9: bridge.v1.BridgeService.GetClaims:input_type -> bridge.v1.GetClaimsRequest - 7, // 10: bridge.v1.BridgeService.GetTokenWrapped:input_type -> bridge.v1.GetTokenWrappedRequest - 10, // 11: bridge.v1.BridgeService.CheckAPI:output_type -> bridge.v1.CheckAPIResponse - 11, // 12: bridge.v1.BridgeService.GetBridges:output_type -> bridge.v1.GetBridgesResponse - 12, // 13: bridge.v1.BridgeService.GetProof:output_type -> bridge.v1.GetProofResponse - 14, // 14: bridge.v1.BridgeService.GetBridge:output_type -> bridge.v1.GetBridgeResponse - 15, // 15: bridge.v1.BridgeService.GetClaims:output_type -> bridge.v1.GetClaimsResponse - 13, // 16: bridge.v1.BridgeService.GetTokenWrapped:output_type -> bridge.v1.GetTokenWrappedResponse - 11, // [11:17] is the sub-list for method output_type - 5, // [5:11] is the sub-list for method input_type + 7, // 8: bridge.v1.BridgeService.GetProofByGER:input_type -> bridge.v1.GetProofByGERRequest + 9, // 9: bridge.v1.BridgeService.GetBridge:input_type -> bridge.v1.GetBridgeRequest + 10, // 10: bridge.v1.BridgeService.GetClaims:input_type -> bridge.v1.GetClaimsRequest + 8, // 11: bridge.v1.BridgeService.GetTokenWrapped:input_type -> bridge.v1.GetTokenWrappedRequest + 11, // 12: bridge.v1.BridgeService.CheckAPI:output_type -> bridge.v1.CheckAPIResponse + 12, // 13: bridge.v1.BridgeService.GetBridges:output_type -> bridge.v1.GetBridgesResponse + 13, // 14: bridge.v1.BridgeService.GetProof:output_type -> bridge.v1.GetProofResponse + 13, // 15: bridge.v1.BridgeService.GetProofByGER:output_type -> bridge.v1.GetProofResponse + 15, // 16: bridge.v1.BridgeService.GetBridge:output_type -> bridge.v1.GetBridgeResponse + 16, // 17: bridge.v1.BridgeService.GetClaims:output_type -> bridge.v1.GetClaimsResponse + 14, // 18: bridge.v1.BridgeService.GetTokenWrapped:output_type -> bridge.v1.GetTokenWrappedResponse + 12, // [12:19] is the sub-list for method output_type + 5, // [5:12] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name 5, // [5:5] is the sub-list for extension extendee 0, // [0:5] is the sub-list for field type_name @@ -1332,7 +1411,7 @@ func file_query_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*TokenWrapped); i { case 0: return &v.state @@ -1344,7 +1423,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Deposit); i { case 0: return &v.state @@ -1356,7 +1435,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Claim); i { case 0: return &v.state @@ -1368,7 +1447,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Proof); i { case 0: return &v.state @@ -1380,7 +1459,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*CheckAPIRequest); i { case 0: return &v.state @@ -1392,7 +1471,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*GetBridgesRequest); i { case 0: return &v.state @@ -1404,7 +1483,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*GetProofRequest); i { case 0: return &v.state @@ -1416,7 +1495,19 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*GetProofByGERRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_query_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*GetTokenWrappedRequest); i { case 0: return &v.state @@ -1428,7 +1519,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*GetBridgeRequest); i { case 0: return &v.state @@ -1440,7 +1531,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*GetClaimsRequest); i { case 0: return &v.state @@ -1452,7 +1543,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*CheckAPIResponse); i { case 0: return &v.state @@ -1464,7 +1555,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*GetBridgesResponse); i { case 0: return &v.state @@ -1476,7 +1567,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*GetProofResponse); i { case 0: return &v.state @@ -1488,7 +1579,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*GetTokenWrappedResponse); i { case 0: return &v.state @@ -1500,7 +1591,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[15].Exporter = func(v any, i int) any { switch v := v.(*GetBridgeResponse); i { case 0: return &v.state @@ -1512,7 +1603,7 @@ func file_query_proto_init() { return nil } } - file_query_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_query_proto_msgTypes[16].Exporter = func(v any, i int) any { switch v := v.(*GetClaimsResponse); i { case 0: return &v.state @@ -1531,7 +1622,7 @@ func file_query_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_query_proto_rawDesc, NumEnums: 0, - NumMessages: 16, + NumMessages: 17, NumExtensions: 0, NumServices: 1, }, diff --git a/bridgectrl/pb/query.pb.gw.go b/bridgectrl/pb/query.pb.gw.go index 171afedc3..47519dd41 100644 --- a/bridgectrl/pb/query.pb.gw.go +++ b/bridgectrl/pb/query.pb.gw.go @@ -50,7 +50,7 @@ func local_request_BridgeService_CheckAPI_0(ctx context.Context, marshaler runti } var ( - filter_BridgeService_GetBridges_0 = &utilities.DoubleArray{Encoding: map[string]int{"dest_addr": 0, "destAddr": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} + filter_BridgeService_GetBridges_0 = &utilities.DoubleArray{Encoding: map[string]int{"dest_addr": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_BridgeService_GetBridges_0(ctx context.Context, marshaler runtime.Marshaler, client BridgeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -155,6 +155,42 @@ func local_request_BridgeService_GetProof_0(ctx context.Context, marshaler runti } +var ( + filter_BridgeService_GetProofByGER_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_BridgeService_GetProofByGER_0(ctx context.Context, marshaler runtime.Marshaler, client BridgeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetProofByGERRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_BridgeService_GetProofByGER_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetProofByGER(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_BridgeService_GetProofByGER_0(ctx context.Context, marshaler runtime.Marshaler, server BridgeServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetProofByGERRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_BridgeService_GetProofByGER_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetProofByGER(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_BridgeService_GetBridge_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -192,7 +228,7 @@ func local_request_BridgeService_GetBridge_0(ctx context.Context, marshaler runt } var ( - filter_BridgeService_GetClaims_0 = &utilities.DoubleArray{Encoding: map[string]int{"dest_addr": 0, "destAddr": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} + filter_BridgeService_GetClaims_0 = &utilities.DoubleArray{Encoding: map[string]int{"dest_addr": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_BridgeService_GetClaims_0(ctx context.Context, marshaler runtime.Marshaler, client BridgeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -378,6 +414,31 @@ func RegisterBridgeServiceHandlerServer(ctx context.Context, mux *runtime.ServeM }) + mux.Handle("GET", pattern_BridgeService_GetProofByGER_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bridge.v1.BridgeService/GetProofByGER", runtime.WithHTTPPathPattern("/merkle-proof-by-ger")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_BridgeService_GetProofByGER_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_BridgeService_GetProofByGER_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_BridgeService_GetBridge_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -459,21 +520,21 @@ func RegisterBridgeServiceHandlerServer(ctx context.Context, mux *runtime.ServeM // RegisterBridgeServiceHandlerFromEndpoint is same as RegisterBridgeServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterBridgeServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -560,6 +621,28 @@ func RegisterBridgeServiceHandlerClient(ctx context.Context, mux *runtime.ServeM }) + mux.Handle("GET", pattern_BridgeService_GetProofByGER_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bridge.v1.BridgeService/GetProofByGER", runtime.WithHTTPPathPattern("/merkle-proof-by-ger")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_BridgeService_GetProofByGER_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_BridgeService_GetProofByGER_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_BridgeService_GetBridge_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -636,6 +719,8 @@ var ( pattern_BridgeService_GetProof_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"merkle-proof"}, "")) + pattern_BridgeService_GetProofByGER_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"merkle-proof-by-ger"}, "")) + pattern_BridgeService_GetBridge_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"bridge"}, "")) pattern_BridgeService_GetClaims_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"claims", "dest_addr"}, "")) @@ -650,6 +735,8 @@ var ( forward_BridgeService_GetProof_0 = runtime.ForwardResponseMessage + forward_BridgeService_GetProofByGER_0 = runtime.ForwardResponseMessage + forward_BridgeService_GetBridge_0 = runtime.ForwardResponseMessage forward_BridgeService_GetClaims_0 = runtime.ForwardResponseMessage diff --git a/bridgectrl/pb/query_grpc.pb.go b/bridgectrl/pb/query_grpc.pb.go index a2a2f8581..3b74706f2 100644 --- a/bridgectrl/pb/query_grpc.pb.go +++ b/bridgectrl/pb/query_grpc.pb.go @@ -1,10 +1,7 @@ -//* -// Bridge service. - // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v3.12.4 +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.20.3 // source: query.proto package pb @@ -21,15 +18,6 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const ( - BridgeService_CheckAPI_FullMethodName = "/bridge.v1.BridgeService/CheckAPI" - BridgeService_GetBridges_FullMethodName = "/bridge.v1.BridgeService/GetBridges" - BridgeService_GetProof_FullMethodName = "/bridge.v1.BridgeService/GetProof" - BridgeService_GetBridge_FullMethodName = "/bridge.v1.BridgeService/GetBridge" - BridgeService_GetClaims_FullMethodName = "/bridge.v1.BridgeService/GetClaims" - BridgeService_GetTokenWrapped_FullMethodName = "/bridge.v1.BridgeService/GetTokenWrapped" -) - // BridgeServiceClient is the client API for BridgeService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -41,6 +29,8 @@ type BridgeServiceClient interface { GetBridges(ctx context.Context, in *GetBridgesRequest, opts ...grpc.CallOption) (*GetBridgesResponse, error) // / Get the merkle proof for the specific deposit GetProof(ctx context.Context, in *GetProofRequest, opts ...grpc.CallOption) (*GetProofResponse, error) + // / Get the merkle proof for the specific deposit and GER + GetProofByGER(ctx context.Context, in *GetProofByGERRequest, opts ...grpc.CallOption) (*GetProofResponse, error) // / Get the specific deposit GetBridge(ctx context.Context, in *GetBridgeRequest, opts ...grpc.CallOption) (*GetBridgeResponse, error) // / Get claims for the specific smart contract address both in L1 and L2 @@ -59,7 +49,7 @@ func NewBridgeServiceClient(cc grpc.ClientConnInterface) BridgeServiceClient { func (c *bridgeServiceClient) CheckAPI(ctx context.Context, in *CheckAPIRequest, opts ...grpc.CallOption) (*CheckAPIResponse, error) { out := new(CheckAPIResponse) - err := c.cc.Invoke(ctx, BridgeService_CheckAPI_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/bridge.v1.BridgeService/CheckAPI", in, out, opts...) if err != nil { return nil, err } @@ -68,7 +58,7 @@ func (c *bridgeServiceClient) CheckAPI(ctx context.Context, in *CheckAPIRequest, func (c *bridgeServiceClient) GetBridges(ctx context.Context, in *GetBridgesRequest, opts ...grpc.CallOption) (*GetBridgesResponse, error) { out := new(GetBridgesResponse) - err := c.cc.Invoke(ctx, BridgeService_GetBridges_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/bridge.v1.BridgeService/GetBridges", in, out, opts...) if err != nil { return nil, err } @@ -77,7 +67,16 @@ func (c *bridgeServiceClient) GetBridges(ctx context.Context, in *GetBridgesRequ func (c *bridgeServiceClient) GetProof(ctx context.Context, in *GetProofRequest, opts ...grpc.CallOption) (*GetProofResponse, error) { out := new(GetProofResponse) - err := c.cc.Invoke(ctx, BridgeService_GetProof_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/bridge.v1.BridgeService/GetProof", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bridgeServiceClient) GetProofByGER(ctx context.Context, in *GetProofByGERRequest, opts ...grpc.CallOption) (*GetProofResponse, error) { + out := new(GetProofResponse) + err := c.cc.Invoke(ctx, "/bridge.v1.BridgeService/GetProofByGER", in, out, opts...) if err != nil { return nil, err } @@ -86,7 +85,7 @@ func (c *bridgeServiceClient) GetProof(ctx context.Context, in *GetProofRequest, func (c *bridgeServiceClient) GetBridge(ctx context.Context, in *GetBridgeRequest, opts ...grpc.CallOption) (*GetBridgeResponse, error) { out := new(GetBridgeResponse) - err := c.cc.Invoke(ctx, BridgeService_GetBridge_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/bridge.v1.BridgeService/GetBridge", in, out, opts...) if err != nil { return nil, err } @@ -95,7 +94,7 @@ func (c *bridgeServiceClient) GetBridge(ctx context.Context, in *GetBridgeReques func (c *bridgeServiceClient) GetClaims(ctx context.Context, in *GetClaimsRequest, opts ...grpc.CallOption) (*GetClaimsResponse, error) { out := new(GetClaimsResponse) - err := c.cc.Invoke(ctx, BridgeService_GetClaims_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/bridge.v1.BridgeService/GetClaims", in, out, opts...) if err != nil { return nil, err } @@ -104,7 +103,7 @@ func (c *bridgeServiceClient) GetClaims(ctx context.Context, in *GetClaimsReques func (c *bridgeServiceClient) GetTokenWrapped(ctx context.Context, in *GetTokenWrappedRequest, opts ...grpc.CallOption) (*GetTokenWrappedResponse, error) { out := new(GetTokenWrappedResponse) - err := c.cc.Invoke(ctx, BridgeService_GetTokenWrapped_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/bridge.v1.BridgeService/GetTokenWrapped", in, out, opts...) if err != nil { return nil, err } @@ -122,6 +121,8 @@ type BridgeServiceServer interface { GetBridges(context.Context, *GetBridgesRequest) (*GetBridgesResponse, error) // / Get the merkle proof for the specific deposit GetProof(context.Context, *GetProofRequest) (*GetProofResponse, error) + // / Get the merkle proof for the specific deposit and GER + GetProofByGER(context.Context, *GetProofByGERRequest) (*GetProofResponse, error) // / Get the specific deposit GetBridge(context.Context, *GetBridgeRequest) (*GetBridgeResponse, error) // / Get claims for the specific smart contract address both in L1 and L2 @@ -144,6 +145,9 @@ func (UnimplementedBridgeServiceServer) GetBridges(context.Context, *GetBridgesR func (UnimplementedBridgeServiceServer) GetProof(context.Context, *GetProofRequest) (*GetProofResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetProof not implemented") } +func (UnimplementedBridgeServiceServer) GetProofByGER(context.Context, *GetProofByGERRequest) (*GetProofResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProofByGER not implemented") +} func (UnimplementedBridgeServiceServer) GetBridge(context.Context, *GetBridgeRequest) (*GetBridgeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetBridge not implemented") } @@ -176,7 +180,7 @@ func _BridgeService_CheckAPI_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: BridgeService_CheckAPI_FullMethodName, + FullMethod: "/bridge.v1.BridgeService/CheckAPI", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BridgeServiceServer).CheckAPI(ctx, req.(*CheckAPIRequest)) @@ -194,7 +198,7 @@ func _BridgeService_GetBridges_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: BridgeService_GetBridges_FullMethodName, + FullMethod: "/bridge.v1.BridgeService/GetBridges", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BridgeServiceServer).GetBridges(ctx, req.(*GetBridgesRequest)) @@ -212,7 +216,7 @@ func _BridgeService_GetProof_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: BridgeService_GetProof_FullMethodName, + FullMethod: "/bridge.v1.BridgeService/GetProof", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BridgeServiceServer).GetProof(ctx, req.(*GetProofRequest)) @@ -220,6 +224,24 @@ func _BridgeService_GetProof_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _BridgeService_GetProofByGER_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProofByGERRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BridgeServiceServer).GetProofByGER(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bridge.v1.BridgeService/GetProofByGER", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BridgeServiceServer).GetProofByGER(ctx, req.(*GetProofByGERRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _BridgeService_GetBridge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetBridgeRequest) if err := dec(in); err != nil { @@ -230,7 +252,7 @@ func _BridgeService_GetBridge_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: BridgeService_GetBridge_FullMethodName, + FullMethod: "/bridge.v1.BridgeService/GetBridge", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BridgeServiceServer).GetBridge(ctx, req.(*GetBridgeRequest)) @@ -248,7 +270,7 @@ func _BridgeService_GetClaims_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: BridgeService_GetClaims_FullMethodName, + FullMethod: "/bridge.v1.BridgeService/GetClaims", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BridgeServiceServer).GetClaims(ctx, req.(*GetClaimsRequest)) @@ -266,7 +288,7 @@ func _BridgeService_GetTokenWrapped_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: BridgeService_GetTokenWrapped_FullMethodName, + FullMethod: "/bridge.v1.BridgeService/GetTokenWrapped", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BridgeServiceServer).GetTokenWrapped(ctx, req.(*GetTokenWrappedRequest)) @@ -293,6 +315,10 @@ var BridgeService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetProof", Handler: _BridgeService_GetProof_Handler, }, + { + MethodName: "GetProofByGER", + Handler: _BridgeService_GetProofByGER_Handler, + }, { MethodName: "GetBridge", Handler: _BridgeService_GetBridge_Handler, diff --git a/claimtxman/claimtxman.go b/claimtxman/claimtxman.go index 1d79175b4..3ea977e26 100644 --- a/claimtxman/claimtxman.go +++ b/claimtxman/claimtxman.go @@ -182,6 +182,10 @@ func (tm *ClaimTxManager) processDepositStatus(ger *etherman.GlobalExitRoot, dbT log.Errorf("error getting and updating L1DepositsStatus. Error: %v", err) return err } + if !tm.cfg.Enabled { + log.Infof("ClaimTxManager is disabled. No auto-claim") + return nil + } for _, deposit := range deposits { if tm.l2NetworkID != deposit.DestinationNetwork { log.Infof("Ignoring deposit: %d: dest_net: %d, we are:%d", deposit.DepositCount, deposit.DestinationNetwork, tm.l2NetworkID) @@ -223,6 +227,7 @@ func (tm *ClaimTxManager) processDepositStatus(ger *etherman.GlobalExitRoot, dbT log.Errorf("error BuildSendClaim tx for deposit %d. Error: %v", deposit.DepositCount, err) return err } + if err = tm.addClaimTx(deposit.DepositCount, tm.auth.From, tx.To(), nil, tx.Data(), ger.GlobalExitRoot, dbTx); err != nil { log.Errorf("error adding claim tx for deposit %d. Error: %v", deposit.DepositCount, err) return err diff --git a/claimtxman/mocks/bridge_service_interface.go b/claimtxman/mocks/bridge_service_interface.go index eb131b872..166705671 100644 --- a/claimtxman/mocks/bridge_service_interface.go +++ b/claimtxman/mocks/bridge_service_interface.go @@ -5,7 +5,10 @@ package mock_txcompressor import ( context "context" + common "github.com/ethereum/go-ethereum/common" + etherman "github.com/0xPolygonHermez/zkevm-bridge-service/etherman" + mock "github.com/stretchr/testify/mock" pgx "github.com/jackc/pgx/v4" @@ -24,47 +27,47 @@ func (_m *bridgeServiceInterface) EXPECT() *bridgeServiceInterface_Expecter { return &bridgeServiceInterface_Expecter{mock: &_m.Mock} } -// GetClaimProof provides a mock function with given fields: depositCnt, networkID, dbTx -func (_m *bridgeServiceInterface) GetClaimProof(depositCnt uint, networkID uint, dbTx pgx.Tx) (*etherman.GlobalExitRoot, [][32]byte, [][32]byte, error) { - ret := _m.Called(depositCnt, networkID, dbTx) +// GetClaimProofForCompressed provides a mock function with given fields: ger, depositCnt, networkID, dbTx +func (_m *bridgeServiceInterface) GetClaimProofForCompressed(ger common.Hash, depositCnt uint, networkID uint, dbTx pgx.Tx) (*etherman.GlobalExitRoot, [][32]byte, [][32]byte, error) { + ret := _m.Called(ger, depositCnt, networkID, dbTx) if len(ret) == 0 { - panic("no return value specified for GetClaimProof") + panic("no return value specified for GetClaimProofForCompressed") } var r0 *etherman.GlobalExitRoot var r1 [][32]byte var r2 [][32]byte var r3 error - if rf, ok := ret.Get(0).(func(uint, uint, pgx.Tx) (*etherman.GlobalExitRoot, [][32]byte, [][32]byte, error)); ok { - return rf(depositCnt, networkID, dbTx) + if rf, ok := ret.Get(0).(func(common.Hash, uint, uint, pgx.Tx) (*etherman.GlobalExitRoot, [][32]byte, [][32]byte, error)); ok { + return rf(ger, depositCnt, networkID, dbTx) } - if rf, ok := ret.Get(0).(func(uint, uint, pgx.Tx) *etherman.GlobalExitRoot); ok { - r0 = rf(depositCnt, networkID, dbTx) + if rf, ok := ret.Get(0).(func(common.Hash, uint, uint, pgx.Tx) *etherman.GlobalExitRoot); ok { + r0 = rf(ger, depositCnt, networkID, dbTx) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*etherman.GlobalExitRoot) } } - if rf, ok := ret.Get(1).(func(uint, uint, pgx.Tx) [][32]byte); ok { - r1 = rf(depositCnt, networkID, dbTx) + if rf, ok := ret.Get(1).(func(common.Hash, uint, uint, pgx.Tx) [][32]byte); ok { + r1 = rf(ger, depositCnt, networkID, dbTx) } else { if ret.Get(1) != nil { r1 = ret.Get(1).([][32]byte) } } - if rf, ok := ret.Get(2).(func(uint, uint, pgx.Tx) [][32]byte); ok { - r2 = rf(depositCnt, networkID, dbTx) + if rf, ok := ret.Get(2).(func(common.Hash, uint, uint, pgx.Tx) [][32]byte); ok { + r2 = rf(ger, depositCnt, networkID, dbTx) } else { if ret.Get(2) != nil { r2 = ret.Get(2).([][32]byte) } } - if rf, ok := ret.Get(3).(func(uint, uint, pgx.Tx) error); ok { - r3 = rf(depositCnt, networkID, dbTx) + if rf, ok := ret.Get(3).(func(common.Hash, uint, uint, pgx.Tx) error); ok { + r3 = rf(ger, depositCnt, networkID, dbTx) } else { r3 = ret.Error(3) } @@ -72,32 +75,33 @@ func (_m *bridgeServiceInterface) GetClaimProof(depositCnt uint, networkID uint, return r0, r1, r2, r3 } -// bridgeServiceInterface_GetClaimProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClaimProof' -type bridgeServiceInterface_GetClaimProof_Call struct { +// bridgeServiceInterface_GetClaimProofForCompressed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClaimProofForCompressed' +type bridgeServiceInterface_GetClaimProofForCompressed_Call struct { *mock.Call } -// GetClaimProof is a helper method to define mock.On call +// GetClaimProofForCompressed is a helper method to define mock.On call +// - ger common.Hash // - depositCnt uint // - networkID uint // - dbTx pgx.Tx -func (_e *bridgeServiceInterface_Expecter) GetClaimProof(depositCnt interface{}, networkID interface{}, dbTx interface{}) *bridgeServiceInterface_GetClaimProof_Call { - return &bridgeServiceInterface_GetClaimProof_Call{Call: _e.mock.On("GetClaimProof", depositCnt, networkID, dbTx)} +func (_e *bridgeServiceInterface_Expecter) GetClaimProofForCompressed(ger interface{}, depositCnt interface{}, networkID interface{}, dbTx interface{}) *bridgeServiceInterface_GetClaimProofForCompressed_Call { + return &bridgeServiceInterface_GetClaimProofForCompressed_Call{Call: _e.mock.On("GetClaimProofForCompressed", ger, depositCnt, networkID, dbTx)} } -func (_c *bridgeServiceInterface_GetClaimProof_Call) Run(run func(depositCnt uint, networkID uint, dbTx pgx.Tx)) *bridgeServiceInterface_GetClaimProof_Call { +func (_c *bridgeServiceInterface_GetClaimProofForCompressed_Call) Run(run func(ger common.Hash, depositCnt uint, networkID uint, dbTx pgx.Tx)) *bridgeServiceInterface_GetClaimProofForCompressed_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint), args[1].(uint), args[2].(pgx.Tx)) + run(args[0].(common.Hash), args[1].(uint), args[2].(uint), args[3].(pgx.Tx)) }) return _c } -func (_c *bridgeServiceInterface_GetClaimProof_Call) Return(_a0 *etherman.GlobalExitRoot, _a1 [][32]byte, _a2 [][32]byte, _a3 error) *bridgeServiceInterface_GetClaimProof_Call { +func (_c *bridgeServiceInterface_GetClaimProofForCompressed_Call) Return(_a0 *etherman.GlobalExitRoot, _a1 [][32]byte, _a2 [][32]byte, _a3 error) *bridgeServiceInterface_GetClaimProofForCompressed_Call { _c.Call.Return(_a0, _a1, _a2, _a3) return _c } -func (_c *bridgeServiceInterface_GetClaimProof_Call) RunAndReturn(run func(uint, uint, pgx.Tx) (*etherman.GlobalExitRoot, [][32]byte, [][32]byte, error)) *bridgeServiceInterface_GetClaimProof_Call { +func (_c *bridgeServiceInterface_GetClaimProofForCompressed_Call) RunAndReturn(run func(common.Hash, uint, uint, pgx.Tx) (*etherman.GlobalExitRoot, [][32]byte, [][32]byte, error)) *bridgeServiceInterface_GetClaimProofForCompressed_Call { _c.Call.Return(run) return _c } diff --git a/cmd/run.go b/cmd/run.go index 508d31997..23649dae7 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -41,6 +41,8 @@ func start(ctx *cli.Context) error { if err != nil { return err } + log.Infof("kzevmAddr = %s", c.NetworkConfig.PolygonZkEvmAddress.String()) + log.Infof("RollupManagerAddress = %s", c.NetworkConfig.PolygonRollupManagerAddress.String()) setupLog(c.Log) err = db.RunMigrations(c.SyncDB) if err != nil { @@ -55,11 +57,11 @@ func start(ctx *cli.Context) error { } networkID, err := l1Etherman.GetNetworkID(ctx.Context) - log.Infof("main network id: %d", networkID) if err != nil { log.Error(err) return err } + log.Infof("main network id: %d", networkID) var networkIDs = []uint{networkID} for _, client := range l2Ethermans { @@ -114,46 +116,29 @@ func start(ctx *cli.Context) error { go runSynchronizer(ctx.Context, 0, bridgeController, client, c.Synchronizer, storage, zkEVMClient, chExitRootEvent, chSynced) } - if c.ClaimTxManager.Enabled { - for i := 0; i < len(c.Etherman.L2URLs); i++ { - // we should match the orders of L2URLs between etherman and claimtxman - // since we are using the networkIDs in the same order - ctx := context.Background() - client, err := utils.NewClient(ctx, c.Etherman.L2URLs[i], c.NetworkConfig.L2PolygonBridgeAddresses[i]) - if err != nil { - log.Fatalf("error creating client for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) - } - nonceCache, err := claimtxman.NewNonceCache(ctx, client) - if err != nil { - log.Fatalf("error creating nonceCache for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) - } - auth, err := client.GetSignerFromKeystore(ctx, c.ClaimTxManager.PrivateKey) - if err != nil { - log.Fatalf("error creating signer for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) - } - - claimTxManager, err := claimtxman.NewClaimTxManager(ctx, c.ClaimTxManager, chExitRootEvent, chSynced, - c.Etherman.L2URLs[i], networkIDs[i+1], c.NetworkConfig.L2PolygonBridgeAddresses[i], bridgeService, storage, rollupID, l2Ethermans[i], nonceCache, auth) - if err != nil { - log.Fatalf("error creating claim tx manager for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) - } - go claimTxManager.Start() + for i := 0; i < len(c.Etherman.L2URLs); i++ { + // we should match the orders of L2URLs between etherman and claimtxman + // since we are using the networkIDs in the same order + ctx := context.Background() + client, err := utils.NewClient(ctx, c.Etherman.L2URLs[i], c.NetworkConfig.L2PolygonBridgeAddresses[i]) + if err != nil { + log.Fatalf("error creating client for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) } - } else { - log.Warn("ClaimTxManager not configured") - go func() { - for { - select { - case <-chExitRootEvent: - log.Debug("New GER received") - case netID := <-chSynced: - log.Debug("NetworkID synced: ", netID) - case <-ctx.Context.Done(): - log.Debug("Stopping goroutine that listen new GER updates") - return - } - } - }() + nonceCache, err := claimtxman.NewNonceCache(ctx, client) + if err != nil { + log.Fatalf("error creating nonceCache for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) + } + auth, err := client.GetSignerFromKeystore(ctx, c.ClaimTxManager.PrivateKey) + if err != nil { + log.Fatalf("error creating signer for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) + } + + claimTxManager, err := claimtxman.NewClaimTxManager(ctx, c.ClaimTxManager, chExitRootEvent, chSynced, + c.Etherman.L2URLs[i], networkIDs[i+1], c.NetworkConfig.L2PolygonBridgeAddresses[i], bridgeService, storage, rollupID, l2Ethermans[i], nonceCache, auth) + if err != nil { + log.Fatalf("error creating claim tx manager for L2 %s. Error: %v", c.Etherman.L2URLs[i], err) + } + go claimTxManager.Start() } // Wait for an in interrupt. diff --git a/docs/e2e-realnetwork-test.md b/docs/e2e-realnetwork-test.md new file mode 100644 index 000000000..d4c8f2af1 --- /dev/null +++ b/docs/e2e-realnetwork-test.md @@ -0,0 +1,25 @@ +# Test Real network using e2e Test +This suite is for test the bridge service running in a real network. +The included tests are: +- ERC20 L1->L2 expecting auto-claim +- ERC20 L2->L1 +- BridgeMessage L1->L2 +- BridgeMessage L2->L1 + +# Build docker +First you need to build the docker that include the tests. +`make build-docker-e2e-real_network-ERC20` +or +`make build-docker-e2e-real_network-MSG` + + +## Create a config file +Check the config example `test/config/bridge_network_e2e/cardona.toml` + +## Execute docker using the config file +- Create the config file in `/tmp/test.toml` +- Launch tests: + ``` + $ docker run --volume "./tmp/:/config/" --env BRIDGE_TEST_CONFIG_FILE=/config/test.toml bridge-e2e-realnetwork-erc20 + $docker run --volume "./tmp/:/config/" --env BRIDGE_TEST_CONFIG_FILE=/config/test.toml bridge-e2e-realnetwork-erc20 + ``` \ No newline at end of file diff --git a/etherman/etherman.go b/etherman/etherman.go index ec7614381..1dbe41bef 100644 --- a/etherman/etherman.go +++ b/etherman/etherman.go @@ -158,6 +158,9 @@ func NewClient(cfg Config, polygonBridgeAddr, polygonZkEVMGlobalExitRootAddress, return nil, err } log.Debug("rollupID: ", rollupID) + if rollupID == 0 { + return nil, fmt.Errorf("rollupID is 0, this is not allowed. Check the rollup contract (%s)", polygonZkEvmAddress.String()) + } var scAddresses []common.Address scAddresses = append(scAddresses, polygonZkEVMGlobalExitRootAddress, polygonBridgeAddr, polygonRollupManagerAddress) @@ -218,6 +221,7 @@ func (etherMan *Client) GetRollupInfoByBlockRange(ctx context.Context, fromBlock query := ethereum.FilterQuery{ FromBlock: new(big.Int).SetUint64(fromBlock), Addresses: etherMan.SCAddresses, + Topics: [][]common.Hash{{updateGlobalExitRootSignatureHash, updateL1InfoTreeSignatureHash, depositEventSignatureHash, claimEventSignatureHash, oldClaimEventSignatureHash, newWrappedTokenEventSignatureHash, verifyBatchesTrustedAggregatorSignatureHash, rollupManagerVerifyBatchesSignatureHash, addExistingRollupSignatureHash, createNewRollupSignatureHash}}, } if toBlock != nil { query.ToBlock = new(big.Int).SetUint64(*toBlock) @@ -408,10 +412,6 @@ func (etherMan *Client) updateL1InfoTreeEvent(ctx context.Context, vLog types.Lo } func (etherMan *Client) processUpdateGlobalExitRootEvent(ctx context.Context, mainnetExitRoot, rollupExitRoot common.Hash, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { - fullBlock, err := etherMan.EtherClient.BlockByHash(ctx, vLog.BlockHash) - if err != nil { - return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) - } var gExitRoot GlobalExitRoot gExitRoot.ExitRoots = make([]common.Hash, 0) gExitRoot.ExitRoots = append(gExitRoot.ExitRoots, mainnetExitRoot) @@ -420,7 +420,11 @@ func (etherMan *Client) processUpdateGlobalExitRootEvent(ctx context.Context, ma gExitRoot.BlockNumber = vLog.BlockNumber if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { - t := time.Unix(int64(fullBlock.Time()), 0) + fullBlock, err := etherMan.EtherClient.HeaderByHash(ctx, vLog.BlockHash) + if err != nil { + return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) + } + t := time.Unix(int64(fullBlock.Time), 0) block := prepareBlock(vLog, t, fullBlock) block.GlobalExitRoots = append(block.GlobalExitRoots, gExitRoot) *blocks = append(*blocks, block) @@ -457,11 +461,11 @@ func (etherMan *Client) depositEvent(ctx context.Context, vLog types.Log, blocks deposit.LeafType = d.LeafType if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { - fullBlock, err := etherMan.EtherClient.BlockByHash(ctx, vLog.BlockHash) + fullBlock, err := etherMan.EtherClient.HeaderByHash(ctx, vLog.BlockHash) if err != nil { return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) } - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time), 0), fullBlock) block.Deposits = append(block.Deposits, deposit) *blocks = append(*blocks, block) } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { @@ -513,11 +517,11 @@ func (etherMan *Client) claimEvent(ctx context.Context, vLog types.Log, blocks * claim.MainnetFlag = mainnetFlag if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { - fullBlock, err := etherMan.EtherClient.BlockByHash(ctx, vLog.BlockHash) + fullBlock, err := etherMan.EtherClient.HeaderByHash(ctx, vLog.BlockHash) if err != nil { return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) } - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time), 0), fullBlock) block.Claims = append(block.Claims, claim) *blocks = append(*blocks, block) } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { @@ -547,11 +551,11 @@ func (etherMan *Client) tokenWrappedEvent(ctx context.Context, vLog types.Log, b tokenWrapped.BlockNumber = vLog.BlockNumber if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { - fullBlock, err := etherMan.EtherClient.BlockByHash(ctx, vLog.BlockHash) + fullBlock, err := etherMan.EtherClient.HeaderByHash(ctx, vLog.BlockHash) if err != nil { return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) } - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time), 0), fullBlock) block.Tokens = append(block.Tokens, tokenWrapped) *blocks = append(*blocks, block) } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { @@ -568,11 +572,11 @@ func (etherMan *Client) tokenWrappedEvent(ctx context.Context, vLog types.Log, b return nil } -func prepareBlock(vLog types.Log, t time.Time, fullBlock *types.Block) Block { +func prepareBlock(vLog types.Log, t time.Time, fullBlock *types.Header) Block { var block Block block.BlockNumber = vLog.BlockNumber block.BlockHash = vLog.BlockHash - block.ParentHash = fullBlock.ParentHash() + block.ParentHash = fullBlock.ParentHash block.ReceivedAt = t return block } @@ -645,11 +649,11 @@ func (etherMan *Client) verifyBatches(ctx context.Context, vLog types.Log, block verifyBatch.Aggregator = aggregator if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { - fullBlock, err := etherMan.EtherClient.BlockByHash(ctx, vLog.BlockHash) + fullBlock, err := etherMan.EtherClient.HeaderByHash(ctx, vLog.BlockHash) if err != nil { return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) } - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time), 0), fullBlock) block.VerifiedBatches = append(block.VerifiedBatches, verifyBatch) *blocks = append(*blocks, block) } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { @@ -712,11 +716,11 @@ func (etherMan *Client) createNewRollupEvent(ctx context.Context, vLog types.Log } if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { - fullBlock, err := etherMan.EtherClient.BlockByHash(ctx, vLog.BlockHash) + fullBlock, err := etherMan.EtherClient.HeaderByHash(ctx, vLog.BlockHash) if err != nil { return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) } - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time), 0), fullBlock) block.ActivateEtrog = append(block.ActivateEtrog, true) *blocks = append(*blocks, block) } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { @@ -744,11 +748,11 @@ func (etherMan *Client) AddExistingRollupEvent(ctx context.Context, vLog types.L } if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { - fullBlock, err := etherMan.EtherClient.BlockByHash(ctx, vLog.BlockHash) + fullBlock, err := etherMan.EtherClient.HeaderByHash(ctx, vLog.BlockHash) if err != nil { return fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %v", vLog.BlockNumber, err) } - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time), 0), fullBlock) block.ActivateEtrog = append(block.ActivateEtrog, true) *blocks = append(*blocks, block) } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { diff --git a/etherman/smartcontracts/readme.md b/etherman/smartcontracts/readme.md index 669053c58..ada2917d5 100644 --- a/etherman/smartcontracts/readme.md +++ b/etherman/smartcontracts/readme.md @@ -4,7 +4,7 @@ The folder `generated_binding` have autogenerated files to use the contracts You can generate from root folder project invoking: ``` -make generate-smartcontracts-bindings +make generate-smartcontracts-bindings ``` ## Folder json diff --git a/go.mod b/go.mod index 9a45a47a9..1c8e27692 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/0xPolygonHermez/zkevm-bridge-service go 1.21 require ( - github.com/0xPolygonHermez/zkevm-node v0.6.8-RC8 + github.com/0xPolygonHermez/zkevm-node v0.7.3 github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df github.com/ethereum/go-ethereum v1.13.11 github.com/gobuffalo/packr/v2 v2.8.3 @@ -23,14 +23,14 @@ require ( go.uber.org/zap v1.27.0 golang.org/x/crypto v0.23.0 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa - google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 + google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.34.1 + google.golang.org/protobuf v1.34.2 ) require ( dario.cat/mergo v1.0.0 // indirect - github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240426122934-6f47d2485fc1 // indirect + github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect @@ -164,7 +164,7 @@ require ( golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.15.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 20a2e20f5..b0b99bda4 100644 --- a/go.sum +++ b/go.sum @@ -39,10 +39,10 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240426122934-6f47d2485fc1 h1:4wbCJOGcZ8BTuOfNFrcZ1cAVfTWaX1W9EYHaDx3imLc= -github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240426122934-6f47d2485fc1/go.mod h1:0QkAXcFa92mFJrCbN3UPUJGJYes851yEgYHLONnaosE= -github.com/0xPolygonHermez/zkevm-node v0.6.8-RC8 h1:lCykDArIsRmnJY3KfaQt1sR57pfcd6iNxFoZUJZMksE= -github.com/0xPolygonHermez/zkevm-node v0.6.8-RC8/go.mod h1:57LAvmJ5IEr911nXeg9UzQvJ7z/a0Jo4VdUdYtoZ0aQ= +github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3 h1:zJ06KCGLMDOap4slop/QmiMUO+VPsKSS3+944SY06ww= +github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3/go.mod h1:bv7DjATsczN2WvFt26jv34TWv6rfvYM1SqegrgrFwfI= +github.com/0xPolygonHermez/zkevm-node v0.7.3 h1:b4QRxkQ15ZvvXPx2aPRNplmB3Gc3xVsawY/7tcVsryc= +github.com/0xPolygonHermez/zkevm-node v0.7.3/go.mod h1:Emo75CnnaDOct2zJVuPnifJIONCK1CC1hddVjUO7bYI= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= @@ -1221,10 +1221,10 @@ google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= +google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 h1:MuYw1wJzT+ZkybKfaOXKp5hJiZDn2iHaXRw0mRYdHSc= +google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4/go.mod h1:px9SlOOZBg1wM1zdnr8jEL4CNGUBZ+ZKYtNPApNQc4c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 h1:9Xyg6I9IWQZhRVfCWjKK+l6kI0jHcPesVlMnT//aHNo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1260,8 +1260,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/packaging/deb/zkevm-bridge/DEBIAN/postinst b/packaging/deb/zkevm-bridge/DEBIAN/postinst new file mode 100755 index 000000000..5bc5bafec --- /dev/null +++ b/packaging/deb/zkevm-bridge/DEBIAN/postinst @@ -0,0 +1,12 @@ +#!/bin/bash +# This is a postinstallation script so the service can be configured and started when requested +# +sudo adduser --disabled-password --disabled-login --shell /usr/sbin/nologin --quiet --system --no-create-home --home /nonexistent zkevm-bridge +if [ -d "/opt/zkevm-bridge" ] +then + echo "Directory /opt/zkevm-bridge exists." +else + sudo mkdir -p /opt/zkevm-bridge + sudo chown -R zkevm-bridge /opt/zkevm-bridge +fi +sudo systemctl daemon-reload \ No newline at end of file diff --git a/packaging/deb/zkevm-bridge/DEBIAN/postrm b/packaging/deb/zkevm-bridge/DEBIAN/postrm new file mode 100755 index 000000000..054e4bd26 --- /dev/null +++ b/packaging/deb/zkevm-bridge/DEBIAN/postrm @@ -0,0 +1,8 @@ +#!/bin/bash +# +############### +# Remove zkevm-bridge installs +############## +sudo rm -rf /lib/systemd/system/zkevm-bridge.service +sudo deluser zkevm-bridge +sudo systemctl daemon-reload \ No newline at end of file diff --git a/packaging/systemd/zkevm-bridge.service b/packaging/systemd/zkevm-bridge.service new file mode 100644 index 000000000..6585b7442 --- /dev/null +++ b/packaging/systemd/zkevm-bridge.service @@ -0,0 +1,16 @@ +[Unit] + Description=zkevm-bridge + StartLimitIntervalSec=500 + StartLimitBurst=5 + +[Service] + Restart=on-failure + RestartSec=5s + ExecStart=/usr/bin/zkevm-bridge + Type=simple + KillSignal=SIGINT + User=zkevm-bridge + TimeoutStopSec=120 + +[Install] + WantedBy=multi-user.target \ No newline at end of file diff --git a/proto/src/proto/bridge/v1/query.proto b/proto/src/proto/bridge/v1/query.proto index 1ea216cd6..12210121c 100644 --- a/proto/src/proto/bridge/v1/query.proto +++ b/proto/src/proto/bridge/v1/query.proto @@ -32,6 +32,12 @@ service BridgeService { }; } + /// Get the merkle proof for the specific deposit and GER + rpc GetProofByGER(GetProofByGERRequest) returns (GetProofResponse) { + option (google.api.http) = { + get: "/merkle-proof-by-ger" + }; + } /// Get the specific deposit rpc GetBridge(GetBridgeRequest) returns (GetBridgeResponse) { option (google.api.http) = { @@ -120,6 +126,12 @@ message GetProofRequest { uint64 deposit_cnt = 2; } +message GetProofByGERRequest { + uint32 net_id = 1; + uint64 deposit_cnt = 2; + string ger = 3; +} + message GetTokenWrappedRequest { string orig_token_addr = 1; uint32 orig_net = 2; diff --git a/scripts/generate-smartcontracts-bindings.sh b/scripts/generate-smartcontracts-bindings.sh index 8164f3070..e18a7e3bf 100755 --- a/scripts/generate-smartcontracts-bindings.sh +++ b/scripts/generate-smartcontracts-bindings.sh @@ -19,4 +19,11 @@ gen() { abigen --bin ${OUTPUT_BASE_DIR}/bin/${package}.bin --abi ${OUTPUT_BASE_DIR}/abi/${package}.abi --pkg=${package} --out=${OUTPUT_BASE_DIR}/${package}/${package}.go } +gen_from_json(){ + local package=$1 + mkdir -p ${OUTPUT_BASE_DIR}/${package} + abigen --combined-json ${OUTPUT_BASE_DIR}/json/${package}.json --pkg=${package} --out=${OUTPUT_BASE_DIR}/${package}/${package}.go +} + +#gen_from_json pingreceiver gen claimcompressor \ No newline at end of file diff --git a/server/mock_bridgeServiceStorage.go b/server/mock_bridgeServiceStorage.go new file mode 100644 index 000000000..07dc148ae --- /dev/null +++ b/server/mock_bridgeServiceStorage.go @@ -0,0 +1,825 @@ +// Code generated by mockery. DO NOT EDIT. + +package server + +import ( + context "context" + + common "github.com/ethereum/go-ethereum/common" + + etherman "github.com/0xPolygonHermez/zkevm-bridge-service/etherman" + + mock "github.com/stretchr/testify/mock" + + pgx "github.com/jackc/pgx/v4" +) + +// bridgeServiceStorageMock is an autogenerated mock type for the bridgeServiceStorage type +type bridgeServiceStorageMock struct { + mock.Mock +} + +type bridgeServiceStorageMock_Expecter struct { + mock *mock.Mock +} + +func (_m *bridgeServiceStorageMock) EXPECT() *bridgeServiceStorageMock_Expecter { + return &bridgeServiceStorageMock_Expecter{mock: &_m.Mock} +} + +// Get provides a mock function with given fields: ctx, key, dbTx +func (_m *bridgeServiceStorageMock) Get(ctx context.Context, key []byte, dbTx pgx.Tx) ([][]byte, error) { + ret := _m.Called(ctx, key, dbTx) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 [][]byte + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []byte, pgx.Tx) ([][]byte, error)); ok { + return rf(ctx, key, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, []byte, pgx.Tx) [][]byte); ok { + r0 = rf(ctx, key, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([][]byte) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []byte, pgx.Tx) error); ok { + r1 = rf(ctx, key, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type bridgeServiceStorageMock_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - key []byte +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) Get(ctx interface{}, key interface{}, dbTx interface{}) *bridgeServiceStorageMock_Get_Call { + return &bridgeServiceStorageMock_Get_Call{Call: _e.mock.On("Get", ctx, key, dbTx)} +} + +func (_c *bridgeServiceStorageMock_Get_Call) Run(run func(ctx context.Context, key []byte, dbTx pgx.Tx)) *bridgeServiceStorageMock_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]byte), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_Get_Call) Return(_a0 [][]byte, _a1 error) *bridgeServiceStorageMock_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_Get_Call) RunAndReturn(run func(context.Context, []byte, pgx.Tx) ([][]byte, error)) *bridgeServiceStorageMock_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetClaim provides a mock function with given fields: ctx, index, networkID, dbTx +func (_m *bridgeServiceStorageMock) GetClaim(ctx context.Context, index uint, networkID uint, dbTx pgx.Tx) (*etherman.Claim, error) { + ret := _m.Called(ctx, index, networkID, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetClaim") + } + + var r0 *etherman.Claim + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint, uint, pgx.Tx) (*etherman.Claim, error)); ok { + return rf(ctx, index, networkID, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint, uint, pgx.Tx) *etherman.Claim); ok { + r0 = rf(ctx, index, networkID, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*etherman.Claim) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint, uint, pgx.Tx) error); ok { + r1 = rf(ctx, index, networkID, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetClaim_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClaim' +type bridgeServiceStorageMock_GetClaim_Call struct { + *mock.Call +} + +// GetClaim is a helper method to define mock.On call +// - ctx context.Context +// - index uint +// - networkID uint +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetClaim(ctx interface{}, index interface{}, networkID interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetClaim_Call { + return &bridgeServiceStorageMock_GetClaim_Call{Call: _e.mock.On("GetClaim", ctx, index, networkID, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetClaim_Call) Run(run func(ctx context.Context, index uint, networkID uint, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetClaim_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint), args[2].(uint), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetClaim_Call) Return(_a0 *etherman.Claim, _a1 error) *bridgeServiceStorageMock_GetClaim_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetClaim_Call) RunAndReturn(run func(context.Context, uint, uint, pgx.Tx) (*etherman.Claim, error)) *bridgeServiceStorageMock_GetClaim_Call { + _c.Call.Return(run) + return _c +} + +// GetClaimCount provides a mock function with given fields: ctx, destAddr, dbTx +func (_m *bridgeServiceStorageMock) GetClaimCount(ctx context.Context, destAddr string, dbTx pgx.Tx) (uint64, error) { + ret := _m.Called(ctx, destAddr, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetClaimCount") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, pgx.Tx) (uint64, error)); ok { + return rf(ctx, destAddr, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, string, pgx.Tx) uint64); ok { + r0 = rf(ctx, destAddr, dbTx) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, pgx.Tx) error); ok { + r1 = rf(ctx, destAddr, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetClaimCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClaimCount' +type bridgeServiceStorageMock_GetClaimCount_Call struct { + *mock.Call +} + +// GetClaimCount is a helper method to define mock.On call +// - ctx context.Context +// - destAddr string +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetClaimCount(ctx interface{}, destAddr interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetClaimCount_Call { + return &bridgeServiceStorageMock_GetClaimCount_Call{Call: _e.mock.On("GetClaimCount", ctx, destAddr, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetClaimCount_Call) Run(run func(ctx context.Context, destAddr string, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetClaimCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetClaimCount_Call) Return(_a0 uint64, _a1 error) *bridgeServiceStorageMock_GetClaimCount_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetClaimCount_Call) RunAndReturn(run func(context.Context, string, pgx.Tx) (uint64, error)) *bridgeServiceStorageMock_GetClaimCount_Call { + _c.Call.Return(run) + return _c +} + +// GetClaims provides a mock function with given fields: ctx, destAddr, limit, offset, dbTx +func (_m *bridgeServiceStorageMock) GetClaims(ctx context.Context, destAddr string, limit uint, offset uint, dbTx pgx.Tx) ([]*etherman.Claim, error) { + ret := _m.Called(ctx, destAddr, limit, offset, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetClaims") + } + + var r0 []*etherman.Claim + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, uint, uint, pgx.Tx) ([]*etherman.Claim, error)); ok { + return rf(ctx, destAddr, limit, offset, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, string, uint, uint, pgx.Tx) []*etherman.Claim); ok { + r0 = rf(ctx, destAddr, limit, offset, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*etherman.Claim) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, uint, uint, pgx.Tx) error); ok { + r1 = rf(ctx, destAddr, limit, offset, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetClaims_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClaims' +type bridgeServiceStorageMock_GetClaims_Call struct { + *mock.Call +} + +// GetClaims is a helper method to define mock.On call +// - ctx context.Context +// - destAddr string +// - limit uint +// - offset uint +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetClaims(ctx interface{}, destAddr interface{}, limit interface{}, offset interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetClaims_Call { + return &bridgeServiceStorageMock_GetClaims_Call{Call: _e.mock.On("GetClaims", ctx, destAddr, limit, offset, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetClaims_Call) Run(run func(ctx context.Context, destAddr string, limit uint, offset uint, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetClaims_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(uint), args[3].(uint), args[4].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetClaims_Call) Return(_a0 []*etherman.Claim, _a1 error) *bridgeServiceStorageMock_GetClaims_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetClaims_Call) RunAndReturn(run func(context.Context, string, uint, uint, pgx.Tx) ([]*etherman.Claim, error)) *bridgeServiceStorageMock_GetClaims_Call { + _c.Call.Return(run) + return _c +} + +// GetDeposit provides a mock function with given fields: ctx, depositCnt, networkID, dbTx +func (_m *bridgeServiceStorageMock) GetDeposit(ctx context.Context, depositCnt uint, networkID uint, dbTx pgx.Tx) (*etherman.Deposit, error) { + ret := _m.Called(ctx, depositCnt, networkID, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetDeposit") + } + + var r0 *etherman.Deposit + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint, uint, pgx.Tx) (*etherman.Deposit, error)); ok { + return rf(ctx, depositCnt, networkID, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint, uint, pgx.Tx) *etherman.Deposit); ok { + r0 = rf(ctx, depositCnt, networkID, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*etherman.Deposit) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint, uint, pgx.Tx) error); ok { + r1 = rf(ctx, depositCnt, networkID, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetDeposit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDeposit' +type bridgeServiceStorageMock_GetDeposit_Call struct { + *mock.Call +} + +// GetDeposit is a helper method to define mock.On call +// - ctx context.Context +// - depositCnt uint +// - networkID uint +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetDeposit(ctx interface{}, depositCnt interface{}, networkID interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetDeposit_Call { + return &bridgeServiceStorageMock_GetDeposit_Call{Call: _e.mock.On("GetDeposit", ctx, depositCnt, networkID, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetDeposit_Call) Run(run func(ctx context.Context, depositCnt uint, networkID uint, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetDeposit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint), args[2].(uint), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDeposit_Call) Return(_a0 *etherman.Deposit, _a1 error) *bridgeServiceStorageMock_GetDeposit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDeposit_Call) RunAndReturn(run func(context.Context, uint, uint, pgx.Tx) (*etherman.Deposit, error)) *bridgeServiceStorageMock_GetDeposit_Call { + _c.Call.Return(run) + return _c +} + +// GetDepositCount provides a mock function with given fields: ctx, destAddr, dbTx +func (_m *bridgeServiceStorageMock) GetDepositCount(ctx context.Context, destAddr string, dbTx pgx.Tx) (uint64, error) { + ret := _m.Called(ctx, destAddr, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetDepositCount") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, pgx.Tx) (uint64, error)); ok { + return rf(ctx, destAddr, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, string, pgx.Tx) uint64); ok { + r0 = rf(ctx, destAddr, dbTx) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, pgx.Tx) error); ok { + r1 = rf(ctx, destAddr, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetDepositCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDepositCount' +type bridgeServiceStorageMock_GetDepositCount_Call struct { + *mock.Call +} + +// GetDepositCount is a helper method to define mock.On call +// - ctx context.Context +// - destAddr string +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetDepositCount(ctx interface{}, destAddr interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetDepositCount_Call { + return &bridgeServiceStorageMock_GetDepositCount_Call{Call: _e.mock.On("GetDepositCount", ctx, destAddr, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetDepositCount_Call) Run(run func(ctx context.Context, destAddr string, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetDepositCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDepositCount_Call) Return(_a0 uint64, _a1 error) *bridgeServiceStorageMock_GetDepositCount_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDepositCount_Call) RunAndReturn(run func(context.Context, string, pgx.Tx) (uint64, error)) *bridgeServiceStorageMock_GetDepositCount_Call { + _c.Call.Return(run) + return _c +} + +// GetDepositCountByRoot provides a mock function with given fields: ctx, root, network, dbTx +func (_m *bridgeServiceStorageMock) GetDepositCountByRoot(ctx context.Context, root []byte, network uint8, dbTx pgx.Tx) (uint, error) { + ret := _m.Called(ctx, root, network, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetDepositCountByRoot") + } + + var r0 uint + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []byte, uint8, pgx.Tx) (uint, error)); ok { + return rf(ctx, root, network, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, []byte, uint8, pgx.Tx) uint); ok { + r0 = rf(ctx, root, network, dbTx) + } else { + r0 = ret.Get(0).(uint) + } + + if rf, ok := ret.Get(1).(func(context.Context, []byte, uint8, pgx.Tx) error); ok { + r1 = rf(ctx, root, network, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetDepositCountByRoot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDepositCountByRoot' +type bridgeServiceStorageMock_GetDepositCountByRoot_Call struct { + *mock.Call +} + +// GetDepositCountByRoot is a helper method to define mock.On call +// - ctx context.Context +// - root []byte +// - network uint8 +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetDepositCountByRoot(ctx interface{}, root interface{}, network interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetDepositCountByRoot_Call { + return &bridgeServiceStorageMock_GetDepositCountByRoot_Call{Call: _e.mock.On("GetDepositCountByRoot", ctx, root, network, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetDepositCountByRoot_Call) Run(run func(ctx context.Context, root []byte, network uint8, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetDepositCountByRoot_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]byte), args[2].(uint8), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDepositCountByRoot_Call) Return(_a0 uint, _a1 error) *bridgeServiceStorageMock_GetDepositCountByRoot_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDepositCountByRoot_Call) RunAndReturn(run func(context.Context, []byte, uint8, pgx.Tx) (uint, error)) *bridgeServiceStorageMock_GetDepositCountByRoot_Call { + _c.Call.Return(run) + return _c +} + +// GetDeposits provides a mock function with given fields: ctx, destAddr, limit, offset, dbTx +func (_m *bridgeServiceStorageMock) GetDeposits(ctx context.Context, destAddr string, limit uint, offset uint, dbTx pgx.Tx) ([]*etherman.Deposit, error) { + ret := _m.Called(ctx, destAddr, limit, offset, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetDeposits") + } + + var r0 []*etherman.Deposit + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, uint, uint, pgx.Tx) ([]*etherman.Deposit, error)); ok { + return rf(ctx, destAddr, limit, offset, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, string, uint, uint, pgx.Tx) []*etherman.Deposit); ok { + r0 = rf(ctx, destAddr, limit, offset, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*etherman.Deposit) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, uint, uint, pgx.Tx) error); ok { + r1 = rf(ctx, destAddr, limit, offset, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetDeposits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDeposits' +type bridgeServiceStorageMock_GetDeposits_Call struct { + *mock.Call +} + +// GetDeposits is a helper method to define mock.On call +// - ctx context.Context +// - destAddr string +// - limit uint +// - offset uint +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetDeposits(ctx interface{}, destAddr interface{}, limit interface{}, offset interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetDeposits_Call { + return &bridgeServiceStorageMock_GetDeposits_Call{Call: _e.mock.On("GetDeposits", ctx, destAddr, limit, offset, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetDeposits_Call) Run(run func(ctx context.Context, destAddr string, limit uint, offset uint, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetDeposits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(uint), args[3].(uint), args[4].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDeposits_Call) Return(_a0 []*etherman.Deposit, _a1 error) *bridgeServiceStorageMock_GetDeposits_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetDeposits_Call) RunAndReturn(run func(context.Context, string, uint, uint, pgx.Tx) ([]*etherman.Deposit, error)) *bridgeServiceStorageMock_GetDeposits_Call { + _c.Call.Return(run) + return _c +} + +// GetExitRootByGER provides a mock function with given fields: ctx, ger, dbTx +func (_m *bridgeServiceStorageMock) GetExitRootByGER(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*etherman.GlobalExitRoot, error) { + ret := _m.Called(ctx, ger, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetExitRootByGER") + } + + var r0 *etherman.GlobalExitRoot + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.Hash, pgx.Tx) (*etherman.GlobalExitRoot, error)); ok { + return rf(ctx, ger, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, common.Hash, pgx.Tx) *etherman.GlobalExitRoot); ok { + r0 = rf(ctx, ger, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*etherman.GlobalExitRoot) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.Hash, pgx.Tx) error); ok { + r1 = rf(ctx, ger, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetExitRootByGER_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetExitRootByGER' +type bridgeServiceStorageMock_GetExitRootByGER_Call struct { + *mock.Call +} + +// GetExitRootByGER is a helper method to define mock.On call +// - ctx context.Context +// - ger common.Hash +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetExitRootByGER(ctx interface{}, ger interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetExitRootByGER_Call { + return &bridgeServiceStorageMock_GetExitRootByGER_Call{Call: _e.mock.On("GetExitRootByGER", ctx, ger, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetExitRootByGER_Call) Run(run func(ctx context.Context, ger common.Hash, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetExitRootByGER_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetExitRootByGER_Call) Return(_a0 *etherman.GlobalExitRoot, _a1 error) *bridgeServiceStorageMock_GetExitRootByGER_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetExitRootByGER_Call) RunAndReturn(run func(context.Context, common.Hash, pgx.Tx) (*etherman.GlobalExitRoot, error)) *bridgeServiceStorageMock_GetExitRootByGER_Call { + _c.Call.Return(run) + return _c +} + +// GetLatestExitRoot provides a mock function with given fields: ctx, isRollup, dbTx +func (_m *bridgeServiceStorageMock) GetLatestExitRoot(ctx context.Context, isRollup bool, dbTx pgx.Tx) (*etherman.GlobalExitRoot, error) { + ret := _m.Called(ctx, isRollup, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetLatestExitRoot") + } + + var r0 *etherman.GlobalExitRoot + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, bool, pgx.Tx) (*etherman.GlobalExitRoot, error)); ok { + return rf(ctx, isRollup, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, bool, pgx.Tx) *etherman.GlobalExitRoot); ok { + r0 = rf(ctx, isRollup, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*etherman.GlobalExitRoot) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, bool, pgx.Tx) error); ok { + r1 = rf(ctx, isRollup, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetLatestExitRoot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestExitRoot' +type bridgeServiceStorageMock_GetLatestExitRoot_Call struct { + *mock.Call +} + +// GetLatestExitRoot is a helper method to define mock.On call +// - ctx context.Context +// - isRollup bool +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetLatestExitRoot(ctx interface{}, isRollup interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetLatestExitRoot_Call { + return &bridgeServiceStorageMock_GetLatestExitRoot_Call{Call: _e.mock.On("GetLatestExitRoot", ctx, isRollup, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetLatestExitRoot_Call) Run(run func(ctx context.Context, isRollup bool, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetLatestExitRoot_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(bool), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetLatestExitRoot_Call) Return(_a0 *etherman.GlobalExitRoot, _a1 error) *bridgeServiceStorageMock_GetLatestExitRoot_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetLatestExitRoot_Call) RunAndReturn(run func(context.Context, bool, pgx.Tx) (*etherman.GlobalExitRoot, error)) *bridgeServiceStorageMock_GetLatestExitRoot_Call { + _c.Call.Return(run) + return _c +} + +// GetRollupExitLeavesByRoot provides a mock function with given fields: ctx, root, dbTx +func (_m *bridgeServiceStorageMock) GetRollupExitLeavesByRoot(ctx context.Context, root common.Hash, dbTx pgx.Tx) ([]etherman.RollupExitLeaf, error) { + ret := _m.Called(ctx, root, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetRollupExitLeavesByRoot") + } + + var r0 []etherman.RollupExitLeaf + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.Hash, pgx.Tx) ([]etherman.RollupExitLeaf, error)); ok { + return rf(ctx, root, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, common.Hash, pgx.Tx) []etherman.RollupExitLeaf); ok { + r0 = rf(ctx, root, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]etherman.RollupExitLeaf) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, common.Hash, pgx.Tx) error); ok { + r1 = rf(ctx, root, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRollupExitLeavesByRoot' +type bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call struct { + *mock.Call +} + +// GetRollupExitLeavesByRoot is a helper method to define mock.On call +// - ctx context.Context +// - root common.Hash +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetRollupExitLeavesByRoot(ctx interface{}, root interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call { + return &bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call{Call: _e.mock.On("GetRollupExitLeavesByRoot", ctx, root, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call) Run(run func(ctx context.Context, root common.Hash, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call) Return(_a0 []etherman.RollupExitLeaf, _a1 error) *bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call) RunAndReturn(run func(context.Context, common.Hash, pgx.Tx) ([]etherman.RollupExitLeaf, error)) *bridgeServiceStorageMock_GetRollupExitLeavesByRoot_Call { + _c.Call.Return(run) + return _c +} + +// GetRoot provides a mock function with given fields: ctx, depositCnt, network, dbTx +func (_m *bridgeServiceStorageMock) GetRoot(ctx context.Context, depositCnt uint, network uint, dbTx pgx.Tx) ([]byte, error) { + ret := _m.Called(ctx, depositCnt, network, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetRoot") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint, uint, pgx.Tx) ([]byte, error)); ok { + return rf(ctx, depositCnt, network, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint, uint, pgx.Tx) []byte); ok { + r0 = rf(ctx, depositCnt, network, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint, uint, pgx.Tx) error); ok { + r1 = rf(ctx, depositCnt, network, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetRoot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRoot' +type bridgeServiceStorageMock_GetRoot_Call struct { + *mock.Call +} + +// GetRoot is a helper method to define mock.On call +// - ctx context.Context +// - depositCnt uint +// - network uint +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetRoot(ctx interface{}, depositCnt interface{}, network interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetRoot_Call { + return &bridgeServiceStorageMock_GetRoot_Call{Call: _e.mock.On("GetRoot", ctx, depositCnt, network, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetRoot_Call) Run(run func(ctx context.Context, depositCnt uint, network uint, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetRoot_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint), args[2].(uint), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetRoot_Call) Return(_a0 []byte, _a1 error) *bridgeServiceStorageMock_GetRoot_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetRoot_Call) RunAndReturn(run func(context.Context, uint, uint, pgx.Tx) ([]byte, error)) *bridgeServiceStorageMock_GetRoot_Call { + _c.Call.Return(run) + return _c +} + +// GetTokenWrapped provides a mock function with given fields: ctx, originalNetwork, originalTokenAddress, dbTx +func (_m *bridgeServiceStorageMock) GetTokenWrapped(ctx context.Context, originalNetwork uint, originalTokenAddress common.Address, dbTx pgx.Tx) (*etherman.TokenWrapped, error) { + ret := _m.Called(ctx, originalNetwork, originalTokenAddress, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetTokenWrapped") + } + + var r0 *etherman.TokenWrapped + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint, common.Address, pgx.Tx) (*etherman.TokenWrapped, error)); ok { + return rf(ctx, originalNetwork, originalTokenAddress, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint, common.Address, pgx.Tx) *etherman.TokenWrapped); ok { + r0 = rf(ctx, originalNetwork, originalTokenAddress, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*etherman.TokenWrapped) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint, common.Address, pgx.Tx) error); ok { + r1 = rf(ctx, originalNetwork, originalTokenAddress, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// bridgeServiceStorageMock_GetTokenWrapped_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTokenWrapped' +type bridgeServiceStorageMock_GetTokenWrapped_Call struct { + *mock.Call +} + +// GetTokenWrapped is a helper method to define mock.On call +// - ctx context.Context +// - originalNetwork uint +// - originalTokenAddress common.Address +// - dbTx pgx.Tx +func (_e *bridgeServiceStorageMock_Expecter) GetTokenWrapped(ctx interface{}, originalNetwork interface{}, originalTokenAddress interface{}, dbTx interface{}) *bridgeServiceStorageMock_GetTokenWrapped_Call { + return &bridgeServiceStorageMock_GetTokenWrapped_Call{Call: _e.mock.On("GetTokenWrapped", ctx, originalNetwork, originalTokenAddress, dbTx)} +} + +func (_c *bridgeServiceStorageMock_GetTokenWrapped_Call) Run(run func(ctx context.Context, originalNetwork uint, originalTokenAddress common.Address, dbTx pgx.Tx)) *bridgeServiceStorageMock_GetTokenWrapped_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint), args[2].(common.Address), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *bridgeServiceStorageMock_GetTokenWrapped_Call) Return(_a0 *etherman.TokenWrapped, _a1 error) *bridgeServiceStorageMock_GetTokenWrapped_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *bridgeServiceStorageMock_GetTokenWrapped_Call) RunAndReturn(run func(context.Context, uint, common.Address, pgx.Tx) (*etherman.TokenWrapped, error)) *bridgeServiceStorageMock_GetTokenWrapped_Call { + _c.Call.Return(run) + return _c +} + +// newBridgeServiceStorageMock creates a new instance of bridgeServiceStorageMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newBridgeServiceStorageMock(t interface { + mock.TestingT + Cleanup(func()) +}) *bridgeServiceStorageMock { + mock := &bridgeServiceStorageMock{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/service.go b/server/service.go index bce33121a..0a0a891c9 100644 --- a/server/service.go +++ b/server/service.go @@ -131,6 +131,7 @@ func (s *bridgeService) getRollupExitProof(rollupIndex uint, root common.Hash, d // Get leaves given the root leaves, err := s.storage.GetRollupExitLeavesByRoot(ctx, root, dbTx) if err != nil { + err = fmt.Errorf("error getting leaves by ger: %s, error: %w", root.String(), err) return nil, common.Hash{}, err } // Compute Siblings @@ -144,7 +145,11 @@ func (s *bridgeService) getRollupExitProof(rollupIndex uint, root common.Hash, d if err != nil { return nil, common.Hash{}, err } else if root != r { - return nil, common.Hash{}, fmt.Errorf("error checking calculated root: %s, %s", root.String(), r.String()) + log.Warnf("error checking calculated root: required: %s, calculated:%s", root.String(), r.String()) + return nil, common.Hash{}, fmt.Errorf("error checking calculated root: required:%s, calculated: %s", root.String(), r.String()) + } + if len(siblings) == 0 || len(ls) == 0 { + return nil, common.Hash{}, fmt.Errorf("no siblings found for root: %s", root.String()) } return siblings, ls[rollupIndex], nil } @@ -202,6 +207,62 @@ func (s *bridgeService) GetClaimProof(depositCnt, networkID uint, dbTx pgx.Tx) ( return globalExitRoot, merkleProof, rollupMerkleProof, nil } +// GetClaimProofbyGER returns the merkle proof to claim the given deposit. +func (s *bridgeService) GetClaimProofbyGER(depositCnt, networkID uint, GER common.Hash, dbTx pgx.Tx) (*etherman.GlobalExitRoot, [][bridgectrl.KeyLen]byte, [][bridgectrl.KeyLen]byte, error) { + ctx := context.Background() + + if dbTx == nil { // if the call comes from the rest API + deposit, err := s.storage.GetDeposit(ctx, depositCnt, networkID, nil) + if err != nil { + err = fmt.Errorf("error getting deposit %d for network: %d. Err: %w", depositCnt, networkID, err) + return nil, nil, nil, err + } + + if !deposit.ReadyForClaim { + log.Warnf("Deposit not ready for claim. Deposit: %d, Network: %d", depositCnt, networkID) + //return nil, nil, nil, gerror.ErrDepositNotSynced + } + } + + tID, err := s.getNetworkID(networkID) + if err != nil { + err = fmt.Errorf("error getting network: %d. Err: %w", networkID, err) + return nil, nil, nil, err + } + globalExitRoot, err := s.storage.GetExitRootByGER(ctx, GER, dbTx) + if err != nil { + err = fmt.Errorf("error getting GlobalExitRoot data for GER: %s. Err: %w", GER.String(), err) + return nil, nil, nil, err + } + + var ( + merkleProof [][bridgectrl.KeyLen]byte + rollupMerkleProof [][bridgectrl.KeyLen]byte + rollupLeaf common.Hash + ) + if networkID == 0 { // Mainnet + merkleProof, err = s.getProof(depositCnt, globalExitRoot.ExitRoots[tID], dbTx) + if err != nil { + log.Errorf("error getting merkleProof. Error: %w", err) + return nil, nil, nil, fmt.Errorf("getting the proof failed (MAINNET), error: %v, network: %d", err, networkID) + } + rollupMerkleProof = emptyProof() + } else { // Rollup + rollupMerkleProof, rollupLeaf, err = s.getRollupExitProof(s.rollupID-1, globalExitRoot.ExitRoots[tID], dbTx) + if err != nil { + log.Errorf("error getting rollupProof. Error: %w", err) + return nil, nil, nil, fmt.Errorf("getting the rollupexit proof failed, error: %v, network: %d", err, networkID) + } + merkleProof, err = s.getProof(depositCnt, rollupLeaf, dbTx) + if err != nil { + log.Errorf("error getting merkleProof. Error: %w", err) + return nil, nil, nil, fmt.Errorf("getting the proof failed (ROLLUP), error: %v, network: %d", err, networkID) + } + } + + return globalExitRoot, merkleProof, rollupMerkleProof, nil +} + // GetClaimProofForCompressed returns the merkle proof to claim the given deposit. func (s *bridgeService) GetClaimProofForCompressed(ger common.Hash, depositCnt, networkID uint, dbTx pgx.Tx) (*etherman.GlobalExitRoot, [][bridgectrl.KeyLen]byte, [][bridgectrl.KeyLen]byte, error) { ctx := context.Background() @@ -463,3 +524,31 @@ func (s *bridgeService) GetTokenWrapped(ctx context.Context, req *pb.GetTokenWra }, }, nil } + +func (s *bridgeService) GetProofByGER(ctx context.Context, req *pb.GetProofByGERRequest) (*pb.GetProofResponse, error) { + ger := common.HexToHash(req.Ger) + globalExitRoot, merkleProof, rollupMerkleProof, err := s.GetClaimProofbyGER(uint(req.DepositCnt), uint(req.NetId), ger, nil) + if err != nil { + return nil, err + } + var ( + proof []string + rollupProof []string + ) + if len(proof) != len(rollupProof) { + return nil, fmt.Errorf("proofs have different lengths. MerkleProof: %d. RollupMerkleProof: %d", len(merkleProof), len(rollupMerkleProof)) + } + for i := 0; i < len(merkleProof); i++ { + proof = append(proof, "0x"+hex.EncodeToString(merkleProof[i][:])) + rollupProof = append(rollupProof, "0x"+hex.EncodeToString(rollupMerkleProof[i][:])) + } + + return &pb.GetProofResponse{ + Proof: &pb.Proof{ + RollupMerkleProof: rollupProof, + MerkleProof: proof, + MainExitRoot: globalExitRoot.ExitRoots[0].Hex(), + RollupExitRoot: globalExitRoot.ExitRoots[1].Hex(), + }, + }, nil +} diff --git a/server/service_test.go b/server/service_test.go new file mode 100644 index 000000000..84cc60a35 --- /dev/null +++ b/server/service_test.go @@ -0,0 +1,34 @@ +package server + +import ( + "testing" + + "github.com/0xPolygonHermez/zkevm-bridge-service/etherman" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func TestGetClaimProofbyGER(t *testing.T) { + cfg := Config{ + CacheSize: 32, + } + mockStorage := newBridgeServiceStorageMock(t) + sut := NewBridgeService(cfg, 32, []uint{0, 1}, mockStorage, 1) + depositCnt := uint(0) + networkID := uint(0) + GER := common.Hash{} + deposit := ðerman.Deposit{} + mockStorage.EXPECT().GetDeposit(mock.Anything, depositCnt, networkID, mock.Anything).Return(deposit, nil) + exitRoot := etherman.GlobalExitRoot{ + ExitRoots: []common.Hash{{}, {}}, + } + mockStorage.EXPECT().GetExitRootByGER(mock.Anything, GER, mock.Anything).Return(&exitRoot, nil) + node := [][]byte{{}, {}} + mockStorage.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).Return(node, nil) + smtProof, smtRollupProof, globaExitRoot, err := sut.GetClaimProofbyGER(depositCnt, networkID, GER, nil) + require.NoError(t, err) + require.NotNil(t, smtProof) + require.NotNil(t, smtRollupProof) + require.NotNil(t, globaExitRoot) +} diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index 4984ffd0c..1d5be65ae 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -182,7 +182,7 @@ func (s *ClientSynchronizer) Sync() error { // Stop function stops the synchronizer func (s *ClientSynchronizer) Stop() { - log.Info("Stopping synchronizer and cancelling context") + log.Infof("NetworkID: %d, Stopping synchronizer and cancelling context", s.networkID) s.cancelCtx() } @@ -247,19 +247,25 @@ func (s *ClientSynchronizer) syncBlocks(lastBlockSynced *etherman.Block) (*ether } log.Debugf("NetworkID: %d, after checkReorg: no reorg detected", s.networkID) - var fromBlock uint64 - if lastBlockSynced.BlockNumber > 0 { + fromBlock := lastBlockSynced.BlockNumber + 1 + if s.synced { fromBlock = lastBlockSynced.BlockNumber } toBlock := fromBlock + s.cfg.SyncChunkSize for { if toBlock > lastKnownBlock.Uint64() { - log.Debug("Setting toBlock to the lastKnownBlock: ", lastKnownBlock) + log.Debugf("NetworkID: %d, Setting toBlock to the lastKnownBlock: %s", s.networkID, lastKnownBlock.String()) toBlock = lastKnownBlock.Uint64() + if !s.synced { + log.Infof("NetworkID %d Synced!", s.networkID) + waitDuration = s.cfg.SyncInterval.Duration + s.synced = true + s.chSynced <- s.networkID + } } if fromBlock > toBlock { - log.Debug("FromBlock is higher than toBlock. Skipping...") + log.Debugf("NetworkID: %d, FromBlock is higher than toBlock. Skipping...", s.networkID) return lastBlockSynced, nil } @@ -279,54 +285,56 @@ func (s *ClientSynchronizer) syncBlocks(lastBlockSynced *etherman.Block) (*ether blocks = append([]etherman.Block{{}}, blocks...) } } else if fromBlock < s.genBlockNumber { - err := fmt.Errorf("NetworkID: %d. fromBlock %d is lower than the genesisBlockNumber %d", s.networkID, fromBlock, s.genBlockNumber) + err := fmt.Errorf("networkID: %d. fromBlock %d is lower than the genesisBlockNumber %d", s.networkID, fromBlock, s.genBlockNumber) log.Warn(err) return lastBlockSynced, err } - var initBlockReceived *etherman.Block - if len(blocks) != 0 { - initBlockReceived = &blocks[0] - // First position of the array must be deleted - blocks = removeBlockElement(blocks, 0) - } else { - // Reorg detected - log.Infof("NetworkID: %d, reorg detected in block %d while querying GetRollupInfoByBlockRange. Rolling back to at least the previous block", s.networkID, fromBlock) - prevBlock, err := s.storage.GetPreviousBlock(s.ctx, s.networkID, 1, nil) - if errors.Is(err, gerror.ErrStorageNotFound) { - log.Warnf("networkID: %d, error checking reorg: previous block not found in db: %v", s.networkID, err) - prevBlock = ðerman.Block{} - } else if err != nil { - log.Errorf("networkID: %d, error getting previousBlock from db. Error: %v", s.networkID, err) - return lastBlockSynced, err - } - blockReorged, err := s.checkReorg(prevBlock, nil) - if err != nil { - log.Errorf("networkID: %d, error checking reorgs in previous blocks. Error: %v", s.networkID, err) - return lastBlockSynced, err - } - if blockReorged == nil { - blockReorged = prevBlock + if s.synced { + var initBlockReceived *etherman.Block + if len(blocks) != 0 { + initBlockReceived = &blocks[0] + // First position of the array must be deleted + blocks = removeBlockElement(blocks, 0) + } else { + // Reorg detected + log.Infof("NetworkID: %d, reorg detected in block %d while querying GetRollupInfoByBlockRange. Rolling back to at least the previous block", s.networkID, fromBlock) + prevBlock, err := s.storage.GetPreviousBlock(s.ctx, s.networkID, 1, nil) + if errors.Is(err, gerror.ErrStorageNotFound) { + log.Warnf("networkID: %d, error checking reorg: previous block not found in db: %v", s.networkID, err) + prevBlock = ðerman.Block{} + } else if err != nil { + log.Errorf("networkID: %d, error getting previousBlock from db. Error: %v", s.networkID, err) + return lastBlockSynced, err + } + blockReorged, err := s.checkReorg(prevBlock, nil) + if err != nil { + log.Errorf("networkID: %d, error checking reorgs in previous blocks. Error: %v", s.networkID, err) + return lastBlockSynced, err + } + if blockReorged == nil { + blockReorged = prevBlock + } + err = s.resetState(blockReorged.BlockNumber) + if err != nil { + log.Errorf("networkID: %d, error resetting the state to a previous block. Retrying... Err: %v", s.networkID, err) + return lastBlockSynced, fmt.Errorf("error resetting the state to a previous block") + } + return blockReorged, nil } - err = s.resetState(blockReorged.BlockNumber) + // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange + block, err := s.checkReorg(lastBlockSynced, initBlockReceived) if err != nil { - log.Errorf("networkID: %d, error resetting the state to a previous block. Retrying... Err: %v", s.networkID, err) - return lastBlockSynced, fmt.Errorf("error resetting the state to a previous block") + log.Errorf("networkID: %d, error checking reorgs. Retrying... Err: %v", s.networkID, err) + return lastBlockSynced, fmt.Errorf("networkID: %d, error checking reorgs", s.networkID) } - return blockReorged, nil - } - // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange - block, err := s.checkReorg(lastBlockSynced, initBlockReceived) - if err != nil { - log.Errorf("networkID: %d, error checking reorgs. Retrying... Err: %v", s.networkID, err) - return lastBlockSynced, fmt.Errorf("networkID: %d, error checking reorgs", s.networkID) - } - if block != nil { - err = s.resetState(block.BlockNumber) - if err != nil { - log.Errorf("networkID: %d, error resetting the state to a previous block. Retrying... Err: %v", s.networkID, err) - return lastBlockSynced, fmt.Errorf("networkID: %d, error resetting the state to a previous block", s.networkID) + if block != nil { + err = s.resetState(block.BlockNumber) + if err != nil { + log.Errorf("networkID: %d, error resetting the state to a previous block. Retrying... Err: %v", s.networkID, err) + return lastBlockSynced, fmt.Errorf("networkID: %d, error resetting the state to a previous block", s.networkID) + } + return block, nil } - return block, nil } err = s.processBlockRange(blocks, order) @@ -348,9 +356,15 @@ func (s *ClientSynchronizer) syncBlocks(lastBlockSynced *etherman.Block) (*ether s.chSynced <- s.networkID } break + } else if !s.synced { + fromBlock = toBlock + 1 + toBlock = fromBlock + s.cfg.SyncChunkSize + log.Debugf("NetworkID: %d, not synced yet. Avoid check the same interval. New interval: from block %d, to block %d", s.networkID, fromBlock, toBlock) + } else { + fromBlock = lastBlockSynced.BlockNumber + toBlock = toBlock + s.cfg.SyncChunkSize + log.Debugf("NetworkID: %d, synced!. New interval: from block %d, to block %d", s.networkID, fromBlock, toBlock) } - fromBlock = lastBlockSynced.BlockNumber - toBlock = toBlock + s.cfg.SyncChunkSize } return lastBlockSynced, nil @@ -417,7 +431,7 @@ func (s *ClientSynchronizer) processBlockRange(blocks []etherman.Block, order ma } case etherman.ActivateEtrogOrder: // this is activated when the bridge detects the CreateNewRollup or the AddExistingRollup event from the rollupManager - log.Info("Event received. Activating LxLyEtrog...") + log.Infof("NetworkID: %d, Event received. Activating LxLyEtrog...", s.networkID) } } err = s.storage.Commit(s.ctx, dbTx) @@ -585,20 +599,13 @@ func (s *ClientSynchronizer) checkReorg(latestStoredBlock, syncedBlock *etherman } func (s *ClientSynchronizer) processVerifyBatch(verifyBatch etherman.VerifiedBatch, blockID uint64, dbTx pgx.Tx) error { - if verifyBatch.RollupID == s.etherMan.GetRollupID()-1 { - // Just check that the calculated RollupExitRoot is fine - network, err := s.bridgeCtrl.GetNetworkID(s.networkID) - if err != nil { - log.Errorf("networkID: %d, error getting NetworkID. Error: %v", s.networkID, err) - rollbackErr := s.storage.Rollback(s.ctx, dbTx) - if rollbackErr != nil { - log.Errorf("networkID: %d, error rolling back state. BlockNumber: %d, rollbackErr: %v, error : %s", - s.networkID, verifyBatch.BlockNumber, rollbackErr, err.Error()) - return rollbackErr - } - return err + if verifyBatch.RollupID == s.etherMan.GetRollupID() { + if verifyBatch.LocalExitRoot == (common.Hash{}) { + log.Debugf("networkID: %d, skipping empty local exit root in verifyBatch event. VerifyBatch: %+v", s.networkID, verifyBatch) + return nil } - ok, err := s.storage.CheckIfRootExists(s.ctx, verifyBatch.LocalExitRoot.Bytes(), network, dbTx) + // Just check that the calculated RollupExitRoot is fine + ok, err := s.storage.CheckIfRootExists(s.ctx, verifyBatch.LocalExitRoot.Bytes(), uint8(verifyBatch.RollupID), dbTx) if err != nil { log.Errorf("networkID: %d, error Checking if root exists. Error: %v", s.networkID, err) rollbackErr := s.storage.Rollback(s.ctx, dbTx) diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 5b3928db9..c9a36228d 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/0xPolygonHermez/zkevm-bridge-service/etherman" + "github.com/0xPolygonHermez/zkevm-bridge-service/log" "github.com/0xPolygonHermez/zkevm-bridge-service/utils/gerror" cfgTypes "github.com/0xPolygonHermez/zkevm-node/config/types" rpcTypes "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" @@ -24,6 +25,69 @@ type mocks struct { ZkEVMClient *zkEVMClientMock } +func NewSynchronizerTest( + parentCtx context.Context, + storage interface{}, + bridge bridgectrlInterface, + ethMan ethermanInterface, + zkEVMClient zkEVMClientInterface, + genBlockNumber uint64, + chExitRootEvent chan *etherman.GlobalExitRoot, + chSynced chan uint, + cfg Config) (Synchronizer, error) { + ctx, cancel := context.WithCancel(parentCtx) + networkID, err := ethMan.GetNetworkID(ctx) + if err != nil { + log.Fatal("error getting networkID. Error: ", err) + } + ger, err := storage.(storageInterface).GetLatestL1SyncedExitRoot(ctx, nil) + if err != nil { + if err == gerror.ErrStorageNotFound { + ger.ExitRoots = []common.Hash{{}, {}} + } else { + log.Fatal("error getting last L1 synced exitroot. Error: ", err) + } + } + + // Read db to see if the LxLy is already activated + isActivated, err := storage.(storageInterface).IsLxLyActivated(ctx, nil) + if err != nil { + log.Fatal("error checking if LxLyEtrog is activated. Error: ", err) + } + if isActivated { + log.Info("LxLyEtrog already activated") + } + if networkID == 0 { + return &ClientSynchronizer{ + bridgeCtrl: bridge, + storage: storage.(storageInterface), + etherMan: ethMan, + ctx: ctx, + cancelCtx: cancel, + genBlockNumber: genBlockNumber, + cfg: cfg, + networkID: networkID, + chExitRootEvent: chExitRootEvent, + chSynced: chSynced, + zkEVMClient: zkEVMClient, + l1RollupExitRoot: ger.ExitRoots[1], + synced: true, + }, nil + } + return &ClientSynchronizer{ + bridgeCtrl: bridge, + storage: storage.(storageInterface), + etherMan: ethMan, + ctx: ctx, + cancelCtx: cancel, + genBlockNumber: genBlockNumber, + cfg: cfg, + chSynced: chSynced, + networkID: networkID, + synced: true, + }, nil +} + func TestSyncGer(t *testing.T) { setupMocks := func(m *mocks) Synchronizer { genBlockNumber := uint64(0) @@ -38,7 +102,7 @@ func TestSyncGer(t *testing.T) { chEvent := make(chan *etherman.GlobalExitRoot) chSynced := make(chan uint) parentCtx := context.Background() - sync, err := NewSynchronizer(parentCtx, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) + sync, err := NewSynchronizerTest(parentCtx, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) require.NoError(t, err) go func() { @@ -204,7 +268,7 @@ func TestReorg(t *testing.T) { m.Storage.On("IsLxLyActivated", ctx, nil).Return(true, nil).Once() chEvent := make(chan *etherman.GlobalExitRoot) chSynced := make(chan uint) - sync, err := NewSynchronizer(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) + sync, err := NewSynchronizerTest(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) require.NoError(t, err) go func() { @@ -326,10 +390,16 @@ func TestReorg(t *testing.T) { Return(nil). Once() + ger := common.Hash{} + m.ZkEVMClient. + On("GetLatestGlobalExitRoot", ctx). + Return(ger, nil). + Once() + m.Etherman. On("HeaderByNumber", ctx, n). Return(ethHeader3bis, nil). - Twice() + Once() m.Etherman. On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). @@ -416,9 +486,12 @@ func TestReorg(t *testing.T) { m.Storage. On("Commit", ctx, m.DbTx). Return(nil). + Run(func(args mock.Arguments) { + sync.Stop() + }). Once() - ger := common.HexToHash("0x01") + ger = common.HexToHash("0x01") m.ZkEVMClient. On("GetLatestGlobalExitRoot", ctx). Return(ger, nil). @@ -443,9 +516,6 @@ func TestReorg(t *testing.T) { m.Storage. On("AddTrustedGlobalExitRoot", ctx, fullGer, nil). Return(true, nil). - Run(func(args mock.Arguments) { - sync.Stop() - }). Once() return sync @@ -480,7 +550,7 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { m.Storage.On("IsLxLyActivated", ctx, nil).Return(true, nil).Once() chEvent := make(chan *etherman.GlobalExitRoot) chSynced := make(chan uint) - sync, err := NewSynchronizer(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) + sync, err := NewSynchronizerTest(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) require.NoError(t, err) go func() { @@ -583,10 +653,16 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { Return(nil). Once() + ger := common.Hash{} + m.ZkEVMClient. + On("GetLatestGlobalExitRoot", ctx). + Return(ger, nil). + Once() + m.Etherman. On("HeaderByNumber", ctx, n). Return(ethHeader3, nil). - Twice() + Once() m.Etherman. On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). @@ -606,7 +682,7 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { Return(blocks, order, nil). Once() - ger := common.HexToHash("0x01") + ger = common.HexToHash("0x01") m.ZkEVMClient. On("GetLatestGlobalExitRoot", ctx). Return(ger, nil). @@ -668,7 +744,7 @@ func TestRegularReorg(t *testing.T) { m.Storage.On("IsLxLyActivated", ctx, nil).Return(true, nil).Once() chEvent := make(chan *etherman.GlobalExitRoot) chSynced := make(chan uint) - sync, err := NewSynchronizer(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) + sync, err := NewSynchronizerTest(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) require.NoError(t, err) go func() { @@ -761,10 +837,16 @@ func TestRegularReorg(t *testing.T) { Return(nil). Once() + ger := common.Hash{} + m.ZkEVMClient. + On("GetLatestGlobalExitRoot", ctx). + Return(ger, nil). + Once() + m.Etherman. On("HeaderByNumber", ctx, n). Return(ethHeader2bis, nil). - Twice() + Once() m.Etherman. On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). @@ -844,7 +926,7 @@ func TestRegularReorg(t *testing.T) { Return(nil). Once() - ger := common.HexToHash("0x01") + ger = common.HexToHash("0x01") m.ZkEVMClient. On("GetLatestGlobalExitRoot", ctx). Return(ger, nil). @@ -906,7 +988,7 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { m.Storage.On("IsLxLyActivated", ctx, nil).Return(true, nil).Once() chEvent := make(chan *etherman.GlobalExitRoot) chSynced := make(chan uint) - sync, err := NewSynchronizer(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) + sync, err := NewSynchronizerTest(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) require.NoError(t, err) go func() { @@ -1028,10 +1110,16 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { Return(nil). Once() + ger := common.Hash{} + m.ZkEVMClient. + On("GetLatestGlobalExitRoot", ctx). + Return(ger, nil). + Once() + m.Etherman. On("HeaderByNumber", ctx, n). Return(ethHeader3, nil). - Twice() + Once() m.Etherman. On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). @@ -1078,7 +1166,7 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { Return(nil). Once() - ger := common.HexToHash("0x01") + ger = common.HexToHash("0x01") m.ZkEVMClient. On("GetLatestGlobalExitRoot", ctx). Return(ger, nil). @@ -1140,7 +1228,7 @@ func TestCallFromEmptyBlockAndReorg(t *testing.T) { m.Storage.On("IsLxLyActivated", ctx, nil).Return(true, nil).Once() chEvent := make(chan *etherman.GlobalExitRoot) chSynced := make(chan uint) - sync, err := NewSynchronizer(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) + sync, err := NewSynchronizerTest(parentContext, m.Storage, m.BridgeCtrl, m.Etherman, m.ZkEVMClient, genBlockNumber, chEvent, chSynced, cfg) require.NoError(t, err) go func() { @@ -1258,10 +1346,16 @@ func TestCallFromEmptyBlockAndReorg(t *testing.T) { Return(nil). Once() + ger := common.Hash{} + m.ZkEVMClient. + On("GetLatestGlobalExitRoot", ctx). + Return(ger, nil). + Once() + m.Etherman. On("HeaderByNumber", mock.Anything, n). Return(ethHeader2bis, nil). - Twice() + Once() m.Etherman. On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). @@ -1300,7 +1394,7 @@ func TestCallFromEmptyBlockAndReorg(t *testing.T) { Return(nil). Once() - ger := common.HexToHash("0x01") + ger = common.HexToHash("0x01") m.ZkEVMClient. On("GetLatestGlobalExitRoot", ctx). Return(ger, nil). diff --git a/test/config/bridge_network_e2e/cardona.toml b/test/config/bridge_network_e2e/cardona.toml new file mode 100644 index 000000000..6167f2330 --- /dev/null +++ b/test/config/bridge_network_e2e/cardona.toml @@ -0,0 +1,15 @@ +# You must set +# 2. TestAddrPrivate +# 3. L1NodeURL + + +TestAddrPrivate="set private key" + +[ConnectionConfig] +L1NodeURL="https://eth-sepolia.g.alchemy.com/v2/" +L2NodeURL="https://rpc.cardona.zkevm-rpc.com" +BridgeURL="https://bridge-api.cardona.zkevm-rpc.com" +L1BridgeAddr="0x528e26b25a34a4a5d0dbda1d57d318153d2ed582" +L2BridgeAddr="0x528e26b25a34a4a5d0dbda1d57d318153d2ed582" + + diff --git a/test/e2e/bridge_network_bridge_msg_test.go b/test/e2e/bridge_network_bridge_msg_test.go new file mode 100644 index 000000000..48aa89b2e --- /dev/null +++ b/test/e2e/bridge_network_bridge_msg_test.go @@ -0,0 +1,176 @@ +//go:build e2e_real_network_msg +// +build e2e_real_network_msg + +package e2e + +import ( + "context" + "fmt" + "math/big" + "testing" + "time" + + "github.com/0xPolygonHermez/zkevm-bridge-service/log" + "github.com/0xPolygonHermez/zkevm-bridge-service/test/mocksmartcontracts/BridgeMessageReceiver" + "github.com/0xPolygonHermez/zkevm-bridge-service/test/mocksmartcontracts/PingReceiver" + "github.com/0xPolygonHermez/zkevm-bridge-service/test/operations" + "github.com/0xPolygonHermez/zkevm-bridge-service/utils" + ops "github.com/0xPolygonHermez/zkevm-node/test/operations" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" +) + +func newMetadata(starting byte) []byte { + var res []byte + for i := 0; i < 32; i++ { + res = append(res, starting+byte(i)) + } + return res +} +func TestMessageTransferL1toL2(t *testing.T) { + if testing.Short() { + t.Skip() + } + log.Infof("Starting test bridge_message L1 -> L2") + ctx := context.TODO() + testData, err := NewBridge2e2TestData(ctx, nil) + require.NoError(t, err) + balances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + log.Infof("MSG [L1->L2] balances: %s", balances.String()) + log.Infof("MSG [L1->L2] deploying contract to L2 to recieve message") + contractDeployedAdrr, pingContract, blockDeployed, err := deployBridgeMessagePingReceiver(ctx, testData.auth[operations.L2], testData.L2Client, testData.cfg.ConnectionConfig.L2BridgeAddr) + //contractDeployedAdrr, pingContract, blockDeployed, err := deployBridgeMessagePingReceiver2(ctx, testData.cfg.TestL2AddrPrivate, testData.L2Client, testData.cfg.ConnectionConfig.L2BridgeAddr) + + require.NoError(t, err) + log.Infof("MSG [L1->L2] Setting to PingReceiver Contract the sender of the message, if not is refused") + log.Infof("MSG [L1->L2] deployed contract to recieve message: %s", contractDeployedAdrr.String()) + tx, err := pingContract.SetSender(testData.auth[operations.L2], testData.auth[operations.L1].From) + require.NoError(t, err) + log.Infof("MSG [L1->L2] SetSender(%s) tx: %s", testData.cfg.ConnectionConfig.L2BridgeAddr, tx.Hash().String()) + log.Infof("MSG [L1->L2] send BridgeMessage to L1 bridge metadata:") + amount := new(big.Int).SetUint64(1000000000000004444) + + txAssetHash := assetMsgL1ToL2(ctx, testData, t, contractDeployedAdrr, amount, newMetadata(1)) + log.Infof("MSG [L1->L2] txAssetHash: %s", txAssetHash.String()) + log.Infof("MSG [L1->L2] waitDepositToBeReadyToClaim") + deposit, err := waitDepositToBeReadyToClaim(ctx, testData, txAssetHash, maxTimeToClaimReady, contractDeployedAdrr.String()) + require.NoError(t, err) + log.Infof("MSG [L2->L1] manualClaimDeposit") + err = manualClaimDepositL2(ctx, testData, deposit) + require.NoError(t, err) + checkThatPingReceivedIsEmitted(ctx, t, blockDeployed, pingContract) +} + +func TestMessageTransferL2toL1(t *testing.T) { + if testing.Short() { + t.Skip() + } + log.Infof("Starting test bridge_message L2 -> L1") + ctx := context.TODO() + testData, err := NewBridge2e2TestData(ctx, nil) + require.NoError(t, err) + log.Infof("MSG [L2->L1] deploying contract to L1 to recieve message") + v, err := testData.L1Client.Bridge.NetworkID(nil) + require.NoError(t, err) + log.Infof("MSG [L2->L1] L1 Network ID: %d", v) + //contractDeployedAdrr, _, err := deployBridgeMessageReceiver(ctx, testData.auth[operations.L2], testData.L2Client) + contractDeployedAdrr, pingContract, blockDeployed, err := deployBridgeMessagePingReceiver(ctx, testData.auth[operations.L1], testData.L1Client, testData.cfg.ConnectionConfig.L1BridgeAddr) + require.NoError(t, err) + log.Infof("MSG [L2->L1] deployed contract to recieve message: %s", contractDeployedAdrr.String()) + log.Infof("MSG [L2->L1] Setting to PingReceiver Contract the sender of the message, if not is refused") + tx, err := pingContract.SetSender(testData.auth[operations.L1], testData.auth[operations.L2].From) + require.NoError(t, err) + log.Infof("MSG [L2->L1] SetSender(%s) tx: %s", testData.auth[operations.L2].From, tx.Hash().String()) + + log.Infof("MSG [L2->L1] send BridgeMessage to L1 bridge metadata: ") + amount := new(big.Int).SetUint64(1000000000000005555) + txAssetHash := assetMsgL2ToL1(ctx, testData, t, contractDeployedAdrr, amount, newMetadata(4)) + log.Infof("MSG [L2->L1] txAssetHash: %s", txAssetHash.String()) + log.Infof("MSG [L2->L1] waitDepositToBeReadyToClaim") + deposit, err := waitDepositToBeReadyToClaim(ctx, testData, txAssetHash, maxTimeToClaimReady, contractDeployedAdrr.String()) + require.NoError(t, err) + log.Infof("MSG [L2->L1] manualClaimDeposit") + err = manualClaimDepositL1(ctx, testData, deposit) + require.NoError(t, err) + checkThatPingReceivedIsEmitted(ctx, t, blockDeployed, pingContract) +} + +func checkThatPingReceivedIsEmitted(ctx context.Context, t *testing.T, blockDeployed uint64, pingContract *PingReceiver.PingReceiver) { + query := bind.FilterOpts{Start: blockDeployed, End: nil, Context: ctx} + eventIterator, err := pingContract.FilterPingReceived(&query) + if err != nil { + log.Errorf("Error filtering events: %s", err.Error()) + } + if !eventIterator.Next() { + log.Errorf("Error getting event, something fails") + require.Fail(t, "Fail to retrieve the event PingReceived, something fails") + } +} + +func assetMsgL1ToL2(ctx context.Context, testData *bridge2e2TestData, t *testing.T, destAddr common.Address, amount *big.Int, metadata []byte) common.Hash { + destNetworkId, err := testData.L2Client.Bridge.NetworkID(nil) + require.NoError(t, err) + auth := testData.auth[operations.L1] + log.Infof("MSG [L1->L2] L2 Network ID: %d. BridgeMessage(destContract: %s) metadata:%+v from L1 -> L2 (from addr=%s)\n", destNetworkId, destAddr.String(), metadata, auth.From.String()) + txHash, err := assetMsgGeneric(ctx, testData.L1Client, destNetworkId, auth, destAddr, amount, metadata) + require.NoError(t, err) + return txHash +} + +func assetMsgL2ToL1(ctx context.Context, testData *bridge2e2TestData, t *testing.T, destAddr common.Address, amount *big.Int, metadata []byte) common.Hash { + destNetworkId, err := testData.L1Client.Bridge.NetworkID(nil) + require.NoError(t, err) + auth := testData.auth[operations.L2] + log.Infof("MSG [L2->L1] L1 Network ID: %d. L2->BridgeMessage(destContract: %s) metadata:%+v from L2 -> L1 (from addr=%s)\n", destNetworkId, destAddr.String(), metadata, auth.From.String()) + txHash, err := assetMsgGeneric(ctx, testData.L2Client, destNetworkId, auth, destAddr, amount, metadata) + require.NoError(t, err) + return txHash +} + +func assetMsgGeneric(ctx context.Context, client *utils.Client, destNetwork uint32, auth *bind.TransactOpts, destAddr common.Address, amount *big.Int, metadata []byte) (common.Hash, error) { + auth.GasLimit = 500000 + auth.Value = amount + tx, err := client.Bridge.BridgeMessage(auth, destNetwork, destAddr, true, metadata) + if err != nil { + return common.Hash{}, err + } + fmt.Println("Tx: ", tx.Hash().Hex()) + err = ops.WaitTxToBeMined(ctx, client.Client, tx, 60*time.Second) + return tx.Hash(), err +} +func checkEventOfBridgeMessageReceiver(t *testing.T, pingContract *PingReceiver.PingReceiver, blockDeployed uint64, timeNow uint32) { + +} + +func deployBridgeMessageReceiver(ctx context.Context, auth *bind.TransactOpts, backend *utils.Client) (common.Address, *BridgeMessageReceiver.BridgeMessageReceiver, error) { + const txMinedTimeoutLimit = 60 * time.Second + addr, tx, contractBinded, err := BridgeMessageReceiver.DeployBridgeMessageReceiver(auth, backend) + if err != nil { + return common.Address{}, nil, err + } + err = ops.WaitTxToBeMined(ctx, backend, tx, txMinedTimeoutLimit) + + return addr, contractBinded, err +} +func deployBridgeMessagePingReceiver(ctx context.Context, auth *bind.TransactOpts, backend *utils.Client, bridgeAddr common.Address) (common.Address, *PingReceiver.PingReceiver, uint64, error) { + const txMinedTimeoutLimit = 60 * time.Second + log.Infof("Deploying PingReceiver contract using ath.From: %s", auth.From.String()) + addr, tx, contractBinded, err := PingReceiver.DeployPingReceiver(auth, backend, bridgeAddr) + if err != nil { + log.Errorf("Error deploying PingReceiver contract: %s", err.Error()) + return common.Address{}, nil, 0, err + } + err = ops.WaitTxToBeMined(ctx, backend, tx, txMinedTimeoutLimit) + if err != nil { + log.Errorf("Error deploying PingReceiver contract:WaitTxToBeMined: %s", err.Error()) + return common.Address{}, nil, 0, err + } + receipt, err := backend.TransactionReceipt(ctx, tx.Hash()) + if err != nil { + log.Errorf("Error deploying PingReceiver contract:TransactionReceipt: %s", err.Error()) + return common.Address{}, nil, 0, err + } + return addr, contractBinded, receipt.BlockNumber.Uint64(), nil +} diff --git a/test/e2e/bridge_network_erc20_test.go b/test/e2e/bridge_network_erc20_test.go new file mode 100644 index 000000000..66c5d174a --- /dev/null +++ b/test/e2e/bridge_network_erc20_test.go @@ -0,0 +1,152 @@ +//go:build e2e_real_network_erc20 +// +build e2e_real_network_erc20 + +package e2e + +import ( + "context" + "fmt" + "math/big" + "testing" + "time" + + "github.com/0xPolygonHermez/zkevm-bridge-service/log" + "github.com/0xPolygonHermez/zkevm-bridge-service/test/operations" + "github.com/0xPolygonHermez/zkevm-bridge-service/utils" + erc20 "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/pol" + ops "github.com/0xPolygonHermez/zkevm-node/test/operations" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" +) + +func TestERC20TransferL1toL2(t *testing.T) { + if testing.Short() { + t.Skip() + } + log.Infof("Starting test ERC20 L1 -> L2") + ctx := context.TODO() + testData, err := NewBridge2e2TestData(ctx, nil) + require.NoError(t, err) + balances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + log.Infof("ERC20 [L1->L2] balances: %s", balances.String()) + + log.Infof("ERC20 [L1->L2] Deploy token") + tokenAddr, err := deployToken(ctx, testData.L1Client, testData.auth[operations.L1], testData.cfg.ConnectionConfig.L1BridgeAddr) + require.NoError(t, err) + log.Infof("ERC20 [L1->L2] L1: Token Addr: ", tokenAddr.Hex()) + + // Do Asset L1 -> L2 + amount := big.NewInt(143210000000001234) // 0.14321 ETH + log.Infof("ERC20 [L1->L2] assetERC20L2ToL1") + txAssetHash := assetERC20L1ToL2(ctx, testData, t, tokenAddr, amount) + log.Infof("ERC20 [L1->L2] assetERC20L2ToL1 txAssetHash: %s ", txAssetHash.String()) + log.Infof("ERC20 [L1->L2] waitToAutoClaim") + //waitToAutoClaim(t, ctx, testData, txAssetHash, maxTimeToClaimReady) + deposit, err := waitDepositToBeReadyToClaim(ctx, testData, txAssetHash, maxTimeToClaimReady, testData.auth[operations.L1].From.String()) + require.NoError(t, err) + err = waitToAutoClaimTx(t, ctx, testData, deposit, 60*time.Second) + if err != nil { + log.Errorf("ERC20 [L1->L2] Doing manual claim") + err = manualClaimDepositL2(ctx, testData, deposit) + require.NoError(t, err) + } +} + +func TestERC20TransferL2toL1(t *testing.T) { + if testing.Short() { + t.Skip() + } + log.Infof("Starting test ERC20 L2->L1") + + ctx := context.TODO() + testData, err := NewBridge2e2TestData(ctx, nil) + require.NoError(t, err) + balances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + log.Infof("ERC20 [L1->L2] balances: %s", balances.String()) + + tokenAddr, err := deployToken(ctx, testData.L2Client, testData.auth[operations.L2], testData.cfg.ConnectionConfig.L2BridgeAddr) + require.NoError(t, err) + log.Infof("ERC20 [L2->L1] L2: Token Addr: ", tokenAddr.Hex()) + log.Infof("ERC20 [L2->L1] assetERC20L2ToL1") + txAssetHash := assetERC20L2ToL1(ctx, testData, t, tokenAddr, big.NewInt(133330000000001234)) + log.Infof("ERC20 [L2->L1] ERC20 L2->L1 txAssetHash: %s ", txAssetHash.String()) + deposit, err := waitDepositToBeReadyToClaim(ctx, testData, txAssetHash, maxTimeToClaimReady, testData.auth[operations.L2].From.String()) + require.NoError(t, err) + log.Infof("ERC20 [L2->L1] manualClaimDeposit") + err = manualClaimDepositL1(ctx, testData, deposit) + require.NoError(t, err) +} + +func deployToken(ctx context.Context, client *utils.Client, auth *bind.TransactOpts, bridgeAddr common.Address) (common.Address, error) { + tokenAddr, _, err := client.DeployERC20(ctx, "A COIN", "ACO", auth) + if err != nil { + return tokenAddr, err + } + log.Info("Token Addr: ", tokenAddr.Hex()) + amountTokens := new(big.Int).SetUint64(1000000000000000000) + err = client.ApproveERC20(ctx, tokenAddr, bridgeAddr, amountTokens, auth) + if err != nil { + return tokenAddr, err + } + err = client.MintERC20(ctx, tokenAddr, amountTokens, auth) + if err != nil { + return tokenAddr, err + } + erc20Balance, err := getAccountTokenBalance(ctx, auth, client, tokenAddr, nil) + if err != nil { + return tokenAddr, err + } + log.Info("ERC20 Balance: ", erc20Balance.String()) + return tokenAddr, nil +} + +func getAccountTokenBalance(ctx context.Context, auth *bind.TransactOpts, client *utils.Client, tokenAddr common.Address, account *common.Address) (*big.Int, error) { + + if account == nil { + account = &auth.From + } + erc20Token, err := erc20.NewPol(tokenAddr, client) + if err != nil { + return big.NewInt(0), nil + } + balance, err := erc20Token.BalanceOf(&bind.CallOpts{Pending: false}, *account) + if err != nil { + return big.NewInt(0), nil + } + return balance, nil +} + +func assetERC20L1ToL2(ctx context.Context, testData *bridge2e2TestData, t *testing.T, tokenAddr common.Address, amount *big.Int) common.Hash { + l2NetworkId, err := testData.L2Client.Bridge.NetworkID(nil) + require.NoError(t, err) + auth := testData.auth[operations.L1] + fmt.Printf("L1->L2 Network ID: %d. Asset ERC20(%s) %+v from L1 -> L2 (addr=%s)\n", l2NetworkId, tokenAddr.String(), amount, auth.From.String()) + txHash, err := assetERC20Generic(ctx, testData.L1Client, l2NetworkId, auth, tokenAddr, amount) + require.NoError(t, err) + return txHash +} + +func assetERC20L2ToL1(ctx context.Context, testData *bridge2e2TestData, t *testing.T, tokenAddr common.Address, amount *big.Int) common.Hash { + destNetworkId, err := testData.L1Client.Bridge.NetworkID(nil) + require.NoError(t, err) + auth := testData.auth[operations.L2] + fmt.Printf("L2->L1 Network ID: %d. Asset ERC20(%s) %+v from L2 -> L1 (addr=%s)\n", destNetworkId, tokenAddr.String(), amount, auth.From.String()) + txHash, err := assetERC20Generic(ctx, testData.L2Client, destNetworkId, auth, tokenAddr, amount) + require.NoError(t, err) + return txHash +} + +func assetERC20Generic(ctx context.Context, client *utils.Client, destNetwork uint32, auth *bind.TransactOpts, tokenAddr common.Address, amount *big.Int) (common.Hash, error) { + destAddr := auth.From + auth.GasLimit = 500000 + tx, err := client.Bridge.BridgeAsset(auth, destNetwork, destAddr, amount, tokenAddr, true, []byte{}) + if err != nil { + return common.Hash{}, err + } + fmt.Println("Tx: ", tx.Hash().Hex()) + err = ops.WaitTxToBeMined(ctx, client.Client, tx, 60*time.Second) + return tx.Hash(), err +} diff --git a/test/e2e/bridge_network_eth_test.go b/test/e2e/bridge_network_eth_test.go new file mode 100644 index 000000000..09d372c66 --- /dev/null +++ b/test/e2e/bridge_network_eth_test.go @@ -0,0 +1,100 @@ +//go:build e2e_real_network_eth +// +build e2e_real_network_eth + +package e2e + +import ( + "context" + "fmt" + "math/big" + "testing" + + "github.com/0xPolygonHermez/zkevm-bridge-service/test/operations" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" +) + +func TestCLaimAlreadyClaimedDepositL2toL1(t *testing.T) { + if testing.Short() { + t.Skip() + } + ctx := context.TODO() + testData, err := NewBridge2e2TestData(ctx, nil) + require.NoError(t, err) + checkBridgeServiceIsAliveAndExpectedVersion(t, testData) + showCurrentStatus(t, ctx, testData) + require.NoError(t, err) + ethInitialBalances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + fmt.Println("ETH Balance ", ethInitialBalances.String()) + checkBridgeServiceIsAliveAndExpectedVersion(t, testData) + txAssetHash := common.HexToHash("0x099252f808424cd7779f8b43038600efd47cdfdde6c077e0c1089ef742aaab36") + deposit, err := waitDepositByTxHash(ctx, testData, txAssetHash, maxTimeToClaimReady) + require.NoError(t, err) + fmt.Println("Deposit: ", deposit) + + err = manualClaimDeposit(ctx, testData, deposit) + if !isAlreadyClaimedError(err) { + require.NoError(t, err) + } + ethFinalBalances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + fmt.Println("ETH Initial Balance ", ethFinalBalances.String()) + fmt.Println("ETH Final Balance ", ethFinalBalances.String()) +} + +// ETH L1 -> L2 +// Bridge Service (L1): BridgeAsset +// - Bridge do the autoclaim ( Claim -> L2/Bridge Contract) +// - Find the autoclaim tx +// - done +func TestEthTransferL1toL2(t *testing.T) { + if testing.Short() { + t.Skip() + } + ctx := context.TODO() + testData, err := NewBridge2e2TestData(ctx, nil) + require.NoError(t, err) + checkBridgeServiceIsAliveAndExpectedVersion(t, testData) + + ethInitialBalances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + fmt.Println("ETH Balance ", ethInitialBalances.String()) + chainL2, err := testData.L2Client.ChainID(ctx) + require.NoError(t, err) + fmt.Println("Chain ID L2: ", chainL2.String()) + auth := testData.auth[operations.L1] + + //amount := big.NewInt(12345678) + //amount := ethInitialBalances.balanceL1.Div(ethInitialBalances.balanceL1, big.NewInt(4)) + amount := big.NewInt(143210000000001234) // 0.14321 ETH + txAssetHash := assetEthL1ToL2(ctx, testData, t, auth, amount) + waitToAutoClaim(t, ctx, testData, txAssetHash, maxTimeToAutoClaim) + ethFinalBalances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + fmt.Println("AFTER ETH Balance ", ethFinalBalances.String()) + //checkFinalBalanceL1toL2(t, ctx, testData, ethInitialBalances, amount) +} + +// This case we need to do manually the claim of the asset +func TestEthTransferL2toL1(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.TODO() + testData, err := NewBridge2e2TestData(ctx, nil) + require.NoError(t, err) + + checkBridgeServiceIsAliveAndExpectedVersion(t, testData) + showCurrentStatus(t, ctx, testData) + ethInitialBalances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + fmt.Println("ETH Balance ", ethInitialBalances.String()) + amount := big.NewInt(12344321) + txAssetHash := assetEthL2ToL1(ctx, testData, t, amount) + deposit, err := waitDepositToBeReadyToClaim(ctx, testData, txAssetHash, maxTimeToClaimReady) + require.NoError(t, err) + err = manualClaimDeposit(ctx, testData, deposit) + require.NoError(t, err) +} diff --git a/test/e2e/bridge_network_shared.go b/test/e2e/bridge_network_shared.go new file mode 100644 index 000000000..e749574c5 --- /dev/null +++ b/test/e2e/bridge_network_shared.go @@ -0,0 +1,497 @@ +//go:build e2e_real_network_eth || e2e_real_network_erc20 || e2e_real_network_msg +// +build e2e_real_network_eth e2e_real_network_erc20 e2e_real_network_msg + +package e2e + +import ( + "context" + "errors" + "fmt" + "math/big" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/0xPolygonHermez/zkevm-bridge-service/bridgectrl/pb" + "github.com/0xPolygonHermez/zkevm-bridge-service/etherman" + "github.com/0xPolygonHermez/zkevm-bridge-service/log" + "github.com/0xPolygonHermez/zkevm-bridge-service/test/client" + "github.com/0xPolygonHermez/zkevm-bridge-service/test/operations" + "github.com/0xPolygonHermez/zkevm-bridge-service/utils" + ops "github.com/0xPolygonHermez/zkevm-node/test/operations" + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rpc" + "github.com/mitchellh/mapstructure" + "github.com/spf13/viper" + "github.com/stretchr/testify/require" +) + +type bridge2e2TestConfig struct { + ConnectionConfig client.Config + ChainID int + TestL1AddrPrivate string + TestL2AddrPrivate string +} + +const ( + // Tipically the time to auto-claim is 15min (L1->L2) + maxTimeToAutoClaim = 60 * time.Minute + // Tipically the time to claim a deposit is 1 hours (L2 -> L1) + maxTimeToClaimReady = 120 * time.Minute + timeBetweenCheckClaim = 60 * time.Second + mtHeight = 32 +) + +type bridge2e2TestData struct { + // This client is used to interact with the L1 bridge contract + L1Client *utils.Client + L2Client *utils.Client + l1BridgeService *client.RestClient + cfg bridge2e2TestConfig + auth map[operations.NetworkSID]*bind.TransactOpts +} + +type ethBalances struct { + balanceL1 *big.Int + balanceL2 *big.Int +} + +func TestReadConfig(t *testing.T) { + cfg, err := readTestConfig() + require.NoError(t, err) + require.NotNil(t, cfg) +} + +func readTestConfig() (*bridge2e2TestConfig, error) { + configFilePath := os.Getenv("BRIDGE_TEST_CONFIG_FILE") + if configFilePath == "" { + log.Infof("BRIDGE_TEST_CONFIG_FILE env var not set") + configFilePath = "../config/bridge_network_e2e/cardona.toml" + } + log.Infof("Reading config file from path: %s", configFilePath) + dirName, fileName := filepath.Split(configFilePath) + + fileExtension := strings.TrimPrefix(filepath.Ext(fileName), ".") + fileNameWithoutExtension := strings.TrimSuffix(fileName, "."+fileExtension) + + viper.AddConfigPath(dirName) + viper.SetConfigName(fileNameWithoutExtension) + viper.SetConfigType(fileExtension) + viper.AutomaticEnv() + replacer := strings.NewReplacer(".", "_") + viper.SetEnvKeyReplacer(replacer) + viper.SetEnvPrefix("BRIDGE_TEST") + err := viper.ReadInConfig() + if err != nil { + _, ok := err.(viper.ConfigFileNotFoundError) + if ok { + log.Infof("config file not found in path: ", configFilePath) + } else { + log.Infof("error reading config file: ", err) + return nil, err + } + } + decodeHooks := []viper.DecoderConfigOption{ + // this allows arrays to be decoded from env var separated by ",", example: MY_VAR="value1,value2,value3" + viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(mapstructure.TextUnmarshallerHookFunc(), mapstructure.StringToSliceHookFunc(","))), + } + cfg := bridge2e2TestConfig{} + err = viper.Unmarshal(&cfg, decodeHooks...) + return &cfg, err +} + +func (e *ethBalances) String() string { + return fmt.Sprintf("Eth Balance: L1: %s, L2: %s", e.balanceL1.String(), e.balanceL2.String()) +} + +func NewBridge2e2TestData(ctx context.Context, cfg *bridge2e2TestConfig) (*bridge2e2TestData, error) { + var err error + if cfg == nil { + cfg, err = readTestConfig() + if err != nil { + return nil, err + } + } + + l1Client, err := utils.NewClient(ctx, cfg.ConnectionConfig.L1NodeURL, cfg.ConnectionConfig.L1BridgeAddr) + if err != nil { + return nil, fmt.Errorf("Error connecting L1 url: %s Err:%w", cfg.ConnectionConfig.L1NodeURL, err) + } + l2Client, err := utils.NewClient(ctx, cfg.ConnectionConfig.L2NodeURL, cfg.ConnectionConfig.L2BridgeAddr) + if err != nil { + return nil, fmt.Errorf("Error connecting L2 url: %s Err:%w", cfg.ConnectionConfig.L2NodeURL, err) + } + l1BridgeService := client.NewRestClient(cfg.ConnectionConfig.BridgeURL) + + L1auth, err := l1Client.GetSigner(ctx, cfg.TestL1AddrPrivate) + if err != nil { + return nil, fmt.Errorf("Error auth from L1: Err:%w", err) + } + /* + if cfg.TestAddr == "" { + cfg.TestAddr = L1auth.From.String() + } else { + if cfg.TestAddr != L1auth.From.String() { + return nil, fmt.Errorf("TestAddr: %s is different from the one in the private key: %s", cfg.TestAddr, L1auth.From.String()) + } + } + */ + L2auth, err := l2Client.GetSigner(ctx, cfg.TestL2AddrPrivate) + if err != nil { + return nil, fmt.Errorf("Error auth from L2: Err:%w", err) + } + return &bridge2e2TestData{ + L1Client: l1Client, + L2Client: l2Client, + l1BridgeService: l1BridgeService, + cfg: *cfg, + auth: map[operations.NetworkSID]*bind.TransactOpts{ + operations.L1: L1auth, + operations.L2: L2auth, + }, + }, nil +} + +func getBalance(ctx context.Context, client *utils.Client, privateKey string, account *common.Address) (*big.Int, error) { + auth, err := client.GetSigner(ctx, privateKey) + if err != nil { + return big.NewInt(0), nil + } + + if account == nil { + account = &auth.From + } + balance, err := client.BalanceAt(ctx, *account, nil) + if err != nil { + return big.NewInt(0), nil + } + return balance, nil +} + +func isAlreadyClaimedError(err error) bool { + exectionRevertedMsg := "execution reverted" + if rpcErr, ok := err.(rpc.DataError); ok { + if rpcErr.Error() != exectionRevertedMsg { + return false + } + revertData := rpcErr.ErrorData() + + fmt.Println("Revert Data: ", revertData) + if revertData == "0x646cf558" { + fmt.Println("Revert Data: AlreadyClaimed()") + return true + } + } + return false +} + +func checkBridgeServiceIsAliveAndExpectedVersion(t *testing.T, testData *bridge2e2TestData) { + version, err := testData.l1BridgeService.GetVersion() + require.NoError(t, err) + require.Equal(t, "v1", version, "bridge service version is not as expected, so I can't execute test") +} + +func showCurrentStatus(t *testing.T, ctx context.Context, testData *bridge2e2TestData) { + chainL2, err := testData.L2Client.ChainID(ctx) + require.NoError(t, err) + fmt.Println("Chain ID L2: ", chainL2.String()) + + deposits, _, err := testData.l1BridgeService.GetBridges(testData.auth[operations.L1].From.String(), 0, 10) + require.NoError(t, err) + for _, deposit := range deposits { + fmt.Println("Deposit: ", deposit) + } +} + +func manualClaimDepositL1(ctx context.Context, testData *bridge2e2TestData, deposit *pb.Deposit) error { + return manualClaimDeposit(ctx, testData, deposit, true) +} + +func manualClaimDepositL2(ctx context.Context, testData *bridge2e2TestData, deposit *pb.Deposit) error { + return manualClaimDeposit(ctx, testData, deposit, false) +} + +func manualClaimDeposit(ctx context.Context, testData *bridge2e2TestData, deposit *pb.Deposit, L1 bool) error { + proof, err := testData.l1BridgeService.GetMerkleProof(deposit.NetworkId, deposit.DepositCnt) + if err != nil { + log.Fatal("error: ", err) + } + log.Debug("deposit: ", deposit) + log.Debug("mainnetExitRoot: ", proof.MainExitRoot) + log.Debug("rollupExitRoot: ", proof.RollupExitRoot) + + smtProof := convertMerkleProof(proof.MerkleProof) + printMkerkleProof(smtProof, "smtProof: ") + smtRollupProof := convertMerkleProof(proof.RollupMerkleProof) + printMkerkleProof(smtRollupProof, "smtRollupProof: ") + + ger := ðerman.GlobalExitRoot{ + ExitRoots: []common.Hash{common.HexToHash(proof.MainExitRoot), common.HexToHash(proof.RollupExitRoot)}, + } + if L1 { + log.Infof(" L1.Claim()") + err = testData.L1Client.SendClaim(ctx, deposit, smtProof, smtRollupProof, ger, testData.auth[operations.L1]) + } else { + log.Infof(" L2.Claim()") + err = testData.L2Client.SendClaim(ctx, deposit, smtProof, smtRollupProof, ger, testData.auth[operations.L2]) + } + return err +} + +func generateGlobalIndex(deposit *pb.Deposit, rollupID uint) *big.Int { + mainnetFlag := deposit.NetworkId == 0 + rollupIndex := rollupID - 1 + localExitRootIndex := uint(deposit.DepositCnt) + globalIndex := etherman.GenerateGlobalIndex(mainnetFlag, rollupIndex, localExitRootIndex) + return globalIndex +} + +func convertMerkleProof(mkProof []string) [mtHeight][32]byte { + var smtProof [mtHeight][32]byte + for i := 0; i < len(mkProof); i++ { + smtProof[i] = common.HexToHash(mkProof[i]) + } + return smtProof +} + +func printMkerkleProof(mkProof [mtHeight][32]byte, title string) { + for i := 0; i < len(mkProof); i++ { + fmt.Println(title, "[", i, "]", mkProof[i]) + } +} + +func waitDepositByTxHash(ctx context.Context, testData *bridge2e2TestData, asssetTxHash common.Hash, timeout time.Duration) (*pb.Deposit, error) { + startTime := time.Now() + for true { + fmt.Println("Waiting to deposit fo assetTx: ", asssetTxHash.Hex(), "...") + deposits, _, err := testData.l1BridgeService.GetBridges(testData.auth[operations.L1].From.String(), 0, 10) + if err != nil { + return nil, err + } + + for _, deposit := range deposits { + depositHash := common.HexToHash(deposit.TxHash) + if depositHash == asssetTxHash { + fmt.Println("Found Deposit: ", deposit) + return deposit, nil + } + } + if time.Since(startTime) > timeout { + return nil, fmt.Errorf("Timeout waiting for deposit for txHash: %s", asssetTxHash.Hex()) + } + fmt.Println("Sleeping ", timeBetweenCheckClaim.String(), "Elapsed time: ", time.Since(startTime)) + time.Sleep(timeBetweenCheckClaim) + } + return nil, nil +} +func getcurrentBalance(ctx context.Context, testData *bridge2e2TestData) (*ethBalances, error) { + balanceL1, err := getBalance(ctx, testData.L1Client, testData.cfg.TestL1AddrPrivate, nil) + if err != nil { + return nil, err + } + balanceL2, err := getBalance(ctx, testData.L2Client, testData.cfg.TestL2AddrPrivate, nil) + if err != nil { + return nil, err + } + result := ðBalances{ + balanceL1: balanceL1, + balanceL2: balanceL2, + } + return result, nil +} + +func checkFinalBalanceL1toL2(t *testing.T, ctx context.Context, testData *bridge2e2TestData, initialBalance *ethBalances, amount *big.Int) { + ethFinalBalances, err := getcurrentBalance(ctx, testData) + require.NoError(t, err) + + finalBalanceL1 := ethFinalBalances.balanceL1 + finalBalanceL2 := ethFinalBalances.balanceL2 + + fmt.Println("Final Balance L1: ", finalBalanceL1.String(), " L2:", finalBalanceL2.String()) + require.Equal(t, initialBalance.balanceL1.Sub(initialBalance.balanceL1, amount).String(), finalBalanceL1.String()) + require.Equal(t, initialBalance.balanceL2.Add(initialBalance.balanceL2, amount).String(), finalBalanceL2.String()) +} + +func assetEthL1ToL2(ctx context.Context, testData *bridge2e2TestData, t *testing.T, auth *bind.TransactOpts, amount *big.Int) common.Hash { + l2NetworkId, err := testData.L2Client.Bridge.NetworkID(nil) + require.NoError(t, err) + + fmt.Printf("L2 Network ID: %d. Moving %+v from L1 -> L2 (addr=%s)\n", l2NetworkId, amount, auth.From.String()) + txHash, err := assetEthGeneric(ctx, testData.L1Client, l2NetworkId, auth, amount) + require.NoError(t, err) + return txHash +} + +func assetEthL2ToL1(ctx context.Context, testData *bridge2e2TestData, t *testing.T, amount *big.Int) common.Hash { + destNetworkId, err := testData.L1Client.Bridge.NetworkID(nil) + require.NoError(t, err) + fmt.Printf("L1 Network ID: %d. Moving %+v from L2- > L1 (addr=%s)\n", destNetworkId, amount, testData.auth[operations.L2].From.String()) + txHash, err := assetEthGeneric(ctx, testData.L2Client, destNetworkId, testData.auth[operations.L2], amount) + require.NoError(t, err) + return txHash +} + +func assetEthGeneric(ctx context.Context, client *utils.Client, destNetwork uint32, auth *bind.TransactOpts, amount *big.Int) (common.Hash, error) { + destAddr := auth.From + auth.Value = amount + tx, err := client.Bridge.BridgeAsset(auth, destNetwork, destAddr, amount, common.Address{}, true, []byte{}) + if err != nil { + return common.Hash{}, err + } + fmt.Println("Tx: ", tx.Hash().Hex()) + err = ops.WaitTxToBeMined(ctx, client.Client, tx, 60*time.Second) + return tx.Hash(), err +} + +func waitDepositToBeReadyToClaim(ctx context.Context, testData *bridge2e2TestData, asssetTxHash common.Hash, timeout time.Duration, destAddr string) (*pb.Deposit, error) { + startTime := time.Now() + if len(destAddr) < 1 { + destAddr = testData.auth[operations.L1].From.String() + } + for true { + fmt.Println("Waiting to deposit (", destAddr, ") fo assetTx: ", asssetTxHash.Hex(), "...") + deposits, _, err := testData.l1BridgeService.GetBridges(destAddr, 0, 100) + if err != nil { + return nil, err + } + + for _, deposit := range deposits { + depositHash := common.HexToHash(deposit.TxHash) + if depositHash == asssetTxHash { + fmt.Println("Deposit found: ", deposit, " ready:", deposit.ReadyForClaim) + + if deposit.ReadyForClaim { + fmt.Println("Found claim! Claim Is ready Elapsed time: ", time.Since(startTime)) + return deposit, nil + } + } + } + if time.Since(startTime) > timeout { + return nil, fmt.Errorf("Timeout waiting for deposit to be ready to be claimed") + } + fmt.Println("Sleeping ", timeBetweenCheckClaim.String(), "Elapsed time: ", time.Since(startTime)) + time.Sleep(timeBetweenCheckClaim) + } + return nil, nil +} + +func waitToAutoClaim(t *testing.T, ctx context.Context, testData *bridge2e2TestData, asssetTxHash common.Hash, timeout time.Duration) { + startTime := time.Now() + deposit, err := waitDepositToBeReadyToClaim(ctx, testData, asssetTxHash, timeout, testData.auth[operations.L1].From.String()) + require.NoError(t, err) + emptyHash := common.Hash{} + claimTxHash := common.HexToHash(deposit.ClaimTxHash) + if claimTxHash != emptyHash { + fmt.Println("Found claim! Claim Tx Hash: ", claimTxHash.Hex()) + // The claim from L1 -> L2 is done by the bridge service to L2 + receipt, err := waitTxToBeMinedByTxHash(ctx, testData.L2Client, claimTxHash, 60*time.Second) + require.NoError(t, err) + fmt.Println("Receipt: ", receipt, " Elapsed time: ", time.Since(startTime)) + return + } + require.Fail(t, "No auto-claim done, deposit:", deposit) +} + +func waitToAutoClaimTx(t *testing.T, ctx context.Context, testData *bridge2e2TestData, deposit *pb.Deposit, timeout time.Duration) error { + startTime := time.Now() + emptyHash := common.Hash{} + claimTxHash := common.HexToHash(deposit.ClaimTxHash) + if claimTxHash != emptyHash { + log.Debugf("Found claim! Claim Tx Hash: ", claimTxHash.Hex()) + // The claim from L1 -> L2 is done by the bridge service to L2 + receipt, err := waitTxToBeMinedByTxHash(ctx, testData.L2Client, claimTxHash, 60*time.Second) + if err != nil { + return err + } + log.Debug("Receipt: ", receipt, " Elapsed time: ", time.Since(startTime)) + return nil + } + return fmt.Errorf("No auto-claim tx, deposit: %+v", deposit) + +} + +func waitToAutoClaim2(t *testing.T, ctx context.Context, testData *bridge2e2TestData, asssetTxHash common.Hash, timeout time.Duration) { + startTime := time.Now() + for true { + fmt.Println("Waiting to deposit fo assetTx: ", asssetTxHash.Hex(), "...") + deposits, _, err := testData.l1BridgeService.GetBridges(testData.auth[operations.L1].From.String(), 0, 10) + require.NoError(t, err) + + for _, deposit := range deposits { + depositHash := common.HexToHash(deposit.TxHash) + if depositHash == asssetTxHash { + fmt.Println("Deposit: ", deposit, " Elapsed time: ", time.Since(startTime)) + claimTxHash := common.HexToHash(deposit.ClaimTxHash) + emptyHash := common.Hash{} + + if claimTxHash != emptyHash { + fmt.Println("Found claim! Claim Tx Hash: ", claimTxHash.Hex()) + // The claim from L1 -> L2 is done by the bridge service to L2 + receipt, err := waitTxToBeMinedByTxHash(ctx, testData.L2Client, claimTxHash, 60*time.Second) + require.NoError(t, err) + fmt.Println("Receipt: ", receipt, " Elapsed time: ", time.Since(startTime)) + return + } + if deposit.ReadyForClaim && claimTxHash == emptyHash { + log.Warnf("Deposit is ready for claim but no claim tx hash found,maybe autoclaim is disabled?. Deposit: %+v", deposit) + } + } + } + if time.Since(startTime) > timeout { + require.Fail(t, "Timeout waiting for deposit to be automatically claimed by Bridge Service") + } + fmt.Println("Sleeping ", timeBetweenCheckClaim.String(), "Elapsed time: ", time.Since(startTime)) + time.Sleep(timeBetweenCheckClaim) + } +} + +// WaitMined waits for tx to be mined on the blockchain. +// It stops waiting when the context is canceled. +func waitMinedByTxHash(ctx context.Context, client *utils.Client, txHash common.Hash) (*types.Receipt, error) { + queryTicker := time.NewTicker(time.Second) + defer queryTicker.Stop() + + for { + receipt, err := client.TransactionReceipt(ctx, txHash) + if err == nil { + return receipt, nil + } + + if errors.Is(err, ethereum.NotFound) { + log.Debug("Transaction not yet mined") + } else { + log.Debug("Receipt retrieval failed", "err", err) + } + + // Wait for the next round. + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-queryTicker.C: + } + } +} + +// WaitTxToBeMined waits until a tx has been mined or the given timeout expires. +func waitTxToBeMinedByTxHash(parentCtx context.Context, client *utils.Client, txHash common.Hash, timeout time.Duration) (*types.Receipt, error) { + ctx, cancel := context.WithTimeout(parentCtx, timeout) + defer cancel() + receipt, err := waitMinedByTxHash(ctx, client, txHash) + if errors.Is(err, context.DeadlineExceeded) { + return nil, err + } else if err != nil { + log.Errorf("error waiting tx %s to be mined: %w", txHash, err) + return nil, err + } + if receipt.Status == types.ReceiptStatusFailed { + reason := " reverted " + return nil, fmt.Errorf("transaction has failed, reason: %s, receipt: %+v. txHash:%s", reason, receipt, txHash.Hex()) + } + log.Debug("Transaction successfully mined: ", txHash) + return receipt, nil +} diff --git a/test/e2e/bridge_test.go b/test/e2e/bridge_test.go index c0bd34de1..ae61ba893 100644 --- a/test/e2e/bridge_test.go +++ b/test/e2e/bridge_test.go @@ -10,7 +10,10 @@ import ( "time" "github.com/0xPolygonHermez/zkevm-bridge-service/bridgectrl" + "github.com/0xPolygonHermez/zkevm-bridge-service/bridgectrl/pb" "github.com/0xPolygonHermez/zkevm-bridge-service/db" + "github.com/0xPolygonHermez/zkevm-bridge-service/etherman" + "github.com/0xPolygonHermez/zkevm-bridge-service/log" "github.com/0xPolygonHermez/zkevm-bridge-service/server" "github.com/0xPolygonHermez/zkevm-bridge-service/test/operations" "github.com/ethereum/go-ethereum/common" @@ -68,27 +71,29 @@ func TestE2E(t *testing.T) { // Check initial globalExitRoot. Must fail because at the beginning, no globalExitRoot event is thrown. globalExitRootSMC, err := opsman.GetCurrentGlobalExitRootFromSmc(ctx) require.NoError(t, err) - t.Logf("initial globalExitRootSMC: %+v,", globalExitRootSMC) + log.Debugf("initial globalExitRootSMC: %+v,", globalExitRootSMC) // Send L1 deposit var destNetwork uint32 = 1 amount := new(big.Int).SetUint64(10000000000000000000) tokenAddr := common.Address{} // This means is eth destAddr := common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4") - + initL1Balance, err := opsman.CheckAccountBalance(ctx, operations.L1, &destAddr) + require.NoError(t, err) + log.Debugf("Initial L1 Balance: %v", initL1Balance) l1Balance, err := opsman.CheckAccountBalance(ctx, operations.L1, &l1BridgeAddr) require.NoError(t, err) - t.Logf("L1 Bridge Balance: %v", l1Balance) + log.Debugf("L1 Bridge Balance: %v", l1Balance) err = opsman.SendL1Deposit(ctx, tokenAddr, amount, destNetwork, &destAddr) require.NoError(t, err) l1Balance, err = opsman.CheckAccountBalance(ctx, operations.L1, &l1BridgeAddr) require.NoError(t, err) - t.Logf("L1 Bridge Balance: %v", l1Balance) + log.Debugf("L1 Bridge Balance: %v", l1Balance) // Check globalExitRoot globalExitRoot2, err := opsman.GetTrustedGlobalExitRootSynced(ctx) require.NoError(t, err) - t.Logf("Before deposit global exit root: %v", globalExitRootSMC) - t.Logf("After deposit global exit root: %v", globalExitRoot2) + log.Debugf("Before deposit global exit root: %v", globalExitRootSMC) + log.Debugf("After deposit global exit root: %v", globalExitRoot2) require.NotEqual(t, globalExitRootSMC.ExitRoots[0], globalExitRoot2.ExitRoots[0]) require.Equal(t, globalExitRootSMC.ExitRoots[1], globalExitRoot2.ExitRoots[1]) // Get Bridge Info By DestAddr @@ -97,9 +102,10 @@ func TestE2E(t *testing.T) { // Check L2 funds balance, err := opsman.CheckAccountBalance(ctx, operations.L2, &destAddr) require.NoError(t, err) - initL2Balance := big.NewInt(0) - require.Equal(t, 0, balance.Cmp(initL2Balance)) - t.Log("Deposit: ", deposits[0]) + log.Debugf("Initial L2 Balance: %v", balance) + initL2Balance := balance + //require.Equal(t, 0, balance.Cmp(initL2Balance)) + log.Debug("Deposit: ", deposits[0], " waiting to be auto-claimed") // Check the claim tx err = opsman.CheckL2Claim(ctx, uint(deposits[0].DestNet), uint(deposits[0].DepositCnt)) require.NoError(t, err) @@ -107,7 +113,9 @@ func TestE2E(t *testing.T) { balance2, err := opsman.CheckAccountBalance(ctx, operations.L2, &destAddr) require.NoError(t, err) require.NotEqual(t, balance, balance2) - require.Equal(t, amount, balance2) + + //require.Equal(t, amount, balance2) + require.Equal(t, 0, balance2.Sub(balance2, initL2Balance).Cmp(amount)) // Check globalExitRoot globalExitRoot3, err := opsman.GetCurrentGlobalExitRootFromSmc(ctx) @@ -117,31 +125,39 @@ func TestE2E(t *testing.T) { amount = new(big.Int).SetUint64(1000000000000000000) l2Balance, err := opsman.CheckAccountBalance(ctx, operations.L2, &l2BridgeAddr) require.NoError(t, err) - t.Logf("L2 Bridge Balance: %v", l2Balance) + log.Debugf("L2 Bridge Balance: %v", l2Balance) err = opsman.SendL2Deposit(ctx, tokenAddr, amount, destNetwork, &destAddr) require.NoError(t, err) l2Balance, err = opsman.CheckAccountBalance(ctx, operations.L2, &l2BridgeAddr) require.NoError(t, err) - t.Logf("L2 Bridge Balance: %v", l2Balance) + log.Debugf("L2 Bridge Balance: %v", l2Balance) // Get Bridge Info By DestAddr deposits, err = opsman.GetBridgeInfoByDestAddr(ctx, &destAddr) require.NoError(t, err) - t.Log("Deposit 2: ", deposits[0]) + log.Debugf("Deposit 2: ", deposits[0]) // Check globalExitRoot globalExitRoot4, err := opsman.GetLatestGlobalExitRootFromL1(ctx) require.NoError(t, err) - t.Logf("Global3 %+v: ", globalExitRoot3) - t.Logf("Global4 %+v: ", globalExitRoot4) + log.Debugf("Global3 %+v: ", globalExitRoot3) + log.Debugf("Global4 %+v: ", globalExitRoot4) require.NotEqual(t, globalExitRoot3.ExitRoots[1], globalExitRoot4.ExitRoots[1]) require.Equal(t, globalExitRoot3.ExitRoots[0], globalExitRoot4.ExitRoots[0]) // Check L1 funds balance, err = opsman.CheckAccountBalance(ctx, operations.L1, &destAddr) require.NoError(t, err) - require.Equal(t, 0, big.NewInt(0).Cmp(balance)) + //require.Equal(t, 0, big.NewInt(0).Cmp(balance)) + require.Equal(t, 0, balance.Sub(balance, initL1Balance).Cmp(big.NewInt(0))) // Get the claim data smtProof, smtRollupProof, globaExitRoot, err := opsman.GetClaimData(ctx, uint(deposits[0].NetworkId), uint(deposits[0].DepositCnt)) require.NoError(t, err) + testClaimParams := testClaimByGERParams{ + resultOriginal: claimResult{smtProof, smtRollupProof, globaExitRoot}, + opsman: opsman, + deposit: deposits[0], + } + testClaimByGER(t, ctx, testClaimParams) + // Claim funds in L1 err = opsman.SendL1Claim(ctx, deposits[0], smtProof, smtRollupProof, globaExitRoot) require.NoError(t, err) @@ -149,11 +165,36 @@ func TestE2E(t *testing.T) { // Check L1 funds to see if the amount has been increased balance, err = opsman.CheckAccountBalance(ctx, operations.L1, &destAddr) require.NoError(t, err) - require.Equal(t, big.NewInt(1000000000000000000), balance) + require.Equal(t, big.NewInt(1000000000000000000), balance.Sub(balance, initL1Balance)) // Check L2 funds to see that the amount has been reduced balance, err = opsman.CheckAccountBalance(ctx, operations.L2, &destAddr) require.NoError(t, err) - require.True(t, big.NewInt(9000000000000000000).Cmp(balance) > 0) + require.True(t, big.NewInt(9000000000000000000).Cmp(balance.Sub(balance, initL2Balance)) > 0) + + // TESTING ClaimByGER + ////////////////////////////// + log.Debugf("Sending another L2Deposit to generate a new globalExitRoot and get ClaimByGER") + err = opsman.SendL2Deposit(ctx, tokenAddr, amount, destNetwork, &destAddr) + require.NoError(t, err) + // Get Bridge Info By DestAddr + require.NoError(t, err) + log.Debugf("There are a new GER, I'm checking to generate claim for previous deposit with previous GER") + testClaimParams = testClaimByGERParams{ + resultOriginal: claimResult{smtProof, smtRollupProof, globaExitRoot}, + opsman: opsman, + deposit: deposits[0], + useGER: nil, // nil means use the one in resultOriginal + } + testClaimByGER(t, ctx, testClaimParams) + // Claim funds in L1 + deposits2, err := opsman.GetBridgeInfoByDestAddr(ctx, &destAddr) + + smtProof, smtRollupProof, globaExitRoot, err = opsman.GetClaimData(ctx, uint(deposits2[0].NetworkId), uint(deposits2[0].DepositCnt)) + require.NoError(t, err) + + err = opsman.SendL1Claim(ctx, deposits2[0], smtProof, smtRollupProof, globaExitRoot) + require.NoError(t, err) + }) t.Run("L1-L2 token bridge", func(t *testing.T) { @@ -165,7 +206,7 @@ func TestE2E(t *testing.T) { // Check initial globalExitRoot. globalExitRootSMC, err := opsman.GetCurrentGlobalExitRootFromSmc(ctx) require.NoError(t, err) - t.Logf("initial globalExitRootSMC: %+v,", globalExitRootSMC) + log.Debugf("initial globalExitRootSMC: %+v,", globalExitRootSMC) // Send L1 deposit var destNetwork uint32 = 1 amount1 := new(big.Int).SetUint64(1000000000000000000) @@ -203,8 +244,8 @@ func TestE2E(t *testing.T) { // Check globalExitRoot globalExitRoot2, err := opsman.GetTrustedGlobalExitRootSynced(ctx) require.NoError(t, err) - t.Logf("Before deposits global exit root: %v", globalExitRootSMC) - t.Logf("After deposits global exit root: %v", globalExitRoot2) + log.Debugf("Before deposits global exit root: %v", globalExitRootSMC) + log.Debugf("After deposits global exit root: %v", globalExitRoot2) require.NotEqual(t, globalExitRootSMC.ExitRoots[0], globalExitRoot2.ExitRoots[0]) require.Equal(t, globalExitRootSMC.ExitRoots[1], globalExitRoot2.ExitRoots[1]) @@ -243,7 +284,7 @@ func TestE2E(t *testing.T) { // Check initial globalExitRoot. globalExitRootSMC, err := opsman.GetCurrentGlobalExitRootFromSmc(ctx) require.NoError(t, err) - t.Logf("initial globalExitRootSMC: %+v,", globalExitRootSMC) + log.Debugf("initial globalExitRootSMC: %+v,", globalExitRootSMC) // Send L2 deposit var destNetwork uint32 = 0 amount := new(big.Int).SetUint64(10000000000000000000) @@ -264,8 +305,8 @@ func TestE2E(t *testing.T) { // Check globalExitRoot globalExitRoot2, err := opsman.GetLatestGlobalExitRootFromL1(ctx) require.NoError(t, err) - t.Logf("Before deposit global exit root: %v", globalExitRootSMC) - t.Logf("After deposit global exit root: %v", globalExitRoot2) + log.Debugf("Before deposit global exit root: %v", globalExitRootSMC) + log.Debugf("After deposit global exit root: %v", globalExitRoot2) require.Equal(t, globalExitRootSMC.ExitRoots[0], globalExitRoot2.ExitRoots[0]) require.NotEqual(t, globalExitRootSMC.ExitRoots[1], globalExitRoot2.ExitRoots[1]) // Get Bridge Info By DestAddr @@ -281,7 +322,7 @@ func TestE2E(t *testing.T) { smtProof, smtRollupProof, globaExitRoot, err := opsman.GetClaimData(ctx, uint(deposits[0].NetworkId), uint(deposits[0].DepositCnt)) require.NoError(t, err) // Claim funds in L1 - t.Logf("globalExitRoot: %+v", globaExitRoot) + log.Debugf("globalExitRoot: %+v", globaExitRoot) err = opsman.SendL1Claim(ctx, deposits[0], smtProof, smtRollupProof, globaExitRoot) require.NoError(t, err) // Get tokenWrappedAddr @@ -311,8 +352,8 @@ func TestE2E(t *testing.T) { // Check globalExitRoot globalExitRoot4, err := opsman.GetTrustedGlobalExitRootSynced(ctx) require.NoError(t, err) - t.Logf("Global3 %+v: ", globalExitRoot3) - t.Logf("Global4 %+v: ", globalExitRoot4) + log.Debugf("Global3 %+v: ", globalExitRoot3) + log.Debugf("Global4 %+v: ", globalExitRoot4) require.NotEqual(t, globalExitRoot3.ExitRoots[0], globalExitRoot4.ExitRoots[0]) // Check L2 funds balance, err = opsman.CheckAccountTokenBalance(ctx, operations.L2, tokenAddr, &destAddr) @@ -337,7 +378,7 @@ func TestE2E(t *testing.T) { // Check initial globalExitRoot. globalExitRootSMC, err := opsman.GetCurrentGlobalExitRootFromSmc(ctx) require.NoError(t, err) - t.Logf("initial globalExitRootSMC: %+v,", globalExitRootSMC) + log.Debugf("initial globalExitRootSMC: %+v,", globalExitRootSMC) // Send L1 deposit var destNetwork uint32 = 1 amount := new(big.Int).SetUint64(10000000000000000000) @@ -355,8 +396,8 @@ func TestE2E(t *testing.T) { // Check globalExitRoot globalExitRoot2, err := opsman.GetTrustedGlobalExitRootSynced(ctx) require.NoError(t, err) - t.Logf("Before deposit global exit root: %v", globalExitRootSMC) - t.Logf("After deposit global exit root: %v", globalExitRoot2) + log.Debugf("Before deposit global exit root: %v", globalExitRootSMC) + log.Debugf("After deposit global exit root: %v", globalExitRoot2) require.NotEqual(t, globalExitRootSMC.ExitRoots[0], globalExitRoot2.ExitRoots[0]) require.Equal(t, globalExitRootSMC.ExitRoots[1], globalExitRoot2.ExitRoots[1]) // Get Bridge Info By DestAddr @@ -392,8 +433,8 @@ func TestE2E(t *testing.T) { // Check globalExitRoot globalExitRoot4, err := opsman.GetLatestGlobalExitRootFromL1(ctx) require.NoError(t, err) - t.Logf("Global3 %+v: ", globalExitRoot3) - t.Logf("Global4 %+v: ", globalExitRoot4) + log.Debugf("Global3 %+v: ", globalExitRoot3) + log.Debugf("Global4 %+v: ", globalExitRoot4) require.NotEqual(t, globalExitRoot3.ExitRoots[1], globalExitRoot4.ExitRoots[1]) require.Equal(t, globalExitRoot3.ExitRoots[0], globalExitRoot4.ExitRoots[0]) // Check L1 funds @@ -426,7 +467,7 @@ func TestE2E(t *testing.T) { // Check initial globalExitRoot. globalExitRootSMC, err := opsman.GetCurrentGlobalExitRootFromSmc(ctx) require.NoError(t, err) - t.Logf("initial globalExitRootSMC: %+v,", globalExitRootSMC) + log.Debugf("initial globalExitRootSMC: %+v,", globalExitRootSMC) // Send L1 deposit var destNetwork uint32 = 1 amount1 := new(big.Int).SetUint64(1000000000000000000) @@ -454,8 +495,8 @@ func TestE2E(t *testing.T) { // Check globalExitRoot globalExitRoot2, err := opsman.GetTrustedGlobalExitRootSynced(ctx) require.NoError(t, err) - t.Logf("Before deposits global exit root: %v", globalExitRootSMC) - t.Logf("After deposits global exit root: %v", globalExitRoot2) + log.Debugf("Before deposits global exit root: %v", globalExitRootSMC) + log.Debugf("After deposits global exit root: %v", globalExitRoot2) require.NotEqual(t, globalExitRootSMC.ExitRoots[0], globalExitRoot2.ExitRoots[0]) require.Equal(t, globalExitRootSMC.ExitRoots[1], globalExitRoot2.ExitRoots[1]) // Get Bridge Info By DestAddr @@ -481,12 +522,6 @@ func TestE2E(t *testing.T) { require.NoError(t, err) t.Log("Balance tokenWrapped: ", balance) - // Check the claim tx - err = opsman.CheckL2Claim(ctx, uint(deposits[0].DestNet), uint(deposits[0].DepositCnt)) - require.NoError(t, err) - balance, err = opsman.CheckAccountTokenBalance(ctx, "l2", tokenWrapped.WrappedTokenAddress, &destAddr) - require.NoError(t, err) - // Check the claim tx err = opsman.CheckL2Claim(ctx, uint(deposits[0].DestNet), uint(deposits[0].DepositCnt)) require.NoError(t, err) @@ -536,7 +571,7 @@ func TestE2E(t *testing.T) { smtProof, smtRollupProof, globaExitRoot, err = opsman.GetClaimData(ctx, uint(deposits[0].NetworkId), uint(deposits[0].DepositCnt)) require.NoError(t, err) // Claim a bridge message in L1 - t.Logf("globalExitRoot: %+v", globaExitRoot) + log.Debugf("globalExitRoot: %+v", globaExitRoot) err = opsman.SendL1Claim(ctx, deposits[0], smtProof, smtRollupProof, globaExitRoot) require.NoError(t, err) }) @@ -579,8 +614,45 @@ func TestE2E(t *testing.T) { smtProof, smtRollupProof, globaExitRoot, err := opsman.GetClaimData(ctx, uint(deposits[0].NetworkId), uint(deposits[0].DepositCnt)) require.NoError(t, err) // Claim a bridge message in L1 - t.Logf("globalExitRoot: %+v", globaExitRoot) + log.Debugf("globalExitRoot: %+v", globaExitRoot) err = opsman.SendL1Claim(ctx, deposits[0], smtProof, smtRollupProof, globaExitRoot) require.NoError(t, err) }) } + +const mtProofHeight = 32 + +type claimResult struct { + smtProof [mtProofHeight][bridgectrl.KeyLen]byte + smtRollupProof [mtProofHeight][bridgectrl.KeyLen]byte + globaExitRoot *etherman.GlobalExitRoot +} + +type testClaimByGERParams struct { + resultOriginal claimResult + opsman *operations.Manager + deposit *pb.Deposit + useGER *common.Hash +} + +func calculateGlobalExitRoot(ger *etherman.GlobalExitRoot) common.Hash { + return bridgectrl.Hash(ger.ExitRoots[0], ger.ExitRoots[1]) +} + +func testClaimByGER(t *testing.T, ctx context.Context, params testClaimByGERParams) { + var ger common.Hash + if params.useGER != nil { + ger = *params.useGER + } else { + ger = calculateGlobalExitRoot(params.resultOriginal.globaExitRoot) + } + + log.Debugf("GetClaimDataByGER: network: %d deposit_cnt:%d GER:%s", + uint(params.deposit.NetworkId), uint(params.deposit.DepositCnt), ger.String()) + log.Debugf("Checking same claim as GetClaim") + smtProofByGer, smtRollupProofByGer, globaExitRootByGer, err := params.opsman.GetClaimDataByGER(ctx, uint(params.deposit.NetworkId), uint(params.deposit.DepositCnt), ger) + require.NoError(t, err) + require.Equal(t, params.resultOriginal.globaExitRoot, globaExitRootByGer) + require.Equal(t, params.resultOriginal.smtProof, smtProofByGer) + require.Equal(t, params.resultOriginal.smtRollupProof, smtRollupProofByGer) +} diff --git a/test/mocksmartcontracts/PingReceiver.sol b/test/mocksmartcontracts/PingReceiver.sol new file mode 100644 index 000000000..d81494533 --- /dev/null +++ b/test/mocksmartcontracts/PingReceiver.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: AGPL-3.0 + +pragma solidity >=0.8.17; + +import "./polygonZKEVMContracts/interfaces/IBridgeMessageReceiver.sol"; +import "./polygonZKEVMContracts/interfaces/IPolygonZkEVMBridge.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; + +/** + * ZkEVMNFTBridge is an example contract to use the message layer of the PolygonZkEVMBridge to bridge NFTs + */ +contract PingReceiver is IBridgeMessageReceiver, Ownable { + // Global Exit Root address + IPolygonZkEVMBridge public immutable polygonZkEVMBridge; + + // Current network identifier + uint32 public immutable networkID; + + // Address in the other network that will send the message + address public pingSender; + + // Value sent from the other network + uint256 public pingValue; + + /** + * @param _polygonZkEVMBridge Polygon zkevm bridge address + */ + constructor(IPolygonZkEVMBridge _polygonZkEVMBridge) { + polygonZkEVMBridge = _polygonZkEVMBridge; + networkID = polygonZkEVMBridge.networkID(); + } + + /** + * @dev Emitted when a message is received from another network + */ + event PingReceived(uint256 pingValue); + + /** + * @dev Emitted when change the sender + */ + event SetSender(address newPingSender); + + /** + * @notice Set the sender of the message + * @param newPingSender Address of the sender in the other network + */ + function setSender(address newPingSender) external onlyOwner { + pingSender = newPingSender; + emit SetSender(newPingSender); + } + + /** + * @notice Verify merkle proof and withdraw tokens/ether + * @param originAddress Origin address that the message was sended + * @param originNetwork Origin network that the message was sended ( not usefull for this contract) + * @param data Abi encoded metadata + */ + function onMessageReceived( + address originAddress, + uint32 originNetwork, + bytes memory data + ) external payable override { + // Can only be called by the bridge + require( + msg.sender == address(polygonZkEVMBridge), + "PingReceiver::onMessageReceived: Not PolygonZkEVMBridge" + ); + + // Can only be called by the sender on the other network + require( + pingSender == originAddress, + "PingReceiver::onMessageReceived: Not ping Sender" + ); + + // Decode data + pingValue = abi.decode(data, (uint256)); + + emit PingReceived(pingValue); + } +} diff --git a/test/mocksmartcontracts/PingReceiver/PingReceiver.go b/test/mocksmartcontracts/PingReceiver/PingReceiver.go new file mode 100644 index 000000000..2cebfc6e4 --- /dev/null +++ b/test/mocksmartcontracts/PingReceiver/PingReceiver.go @@ -0,0 +1,863 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package PingReceiver + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// PingReceiverMetaData contains all meta data concerning the PingReceiver contract. +var PingReceiverMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"contractIPolygonZkEVMBridge\",\"name\":\"_polygonZkEVMBridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"pingValue\",\"type\":\"uint256\"}],\"name\":\"PingReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newPingSender\",\"type\":\"address\"}],\"name\":\"SetSender\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"networkID\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"originAddress\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"originNetwork\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"onMessageReceived\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pingSender\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pingValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"polygonZkEVMBridge\",\"outputs\":[{\"internalType\":\"contractIPolygonZkEVMBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newPingSender\",\"type\":\"address\"}],\"name\":\"setSender\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60c060405234801561001057600080fd5b5060405161097b38038061097b83398101604081905261002f91610107565b610038336100b7565b6001600160a01b03811660808190526040805163bab161bf60e01b8152905163bab161bf9160048082019260209290919082900301816000875af1158015610084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100a89190610137565b63ffffffff1660a0525061015d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561011957600080fd5b81516001600160a01b038116811461013057600080fd5b9392505050565b60006020828403121561014957600080fd5b815163ffffffff8116811461013057600080fd5b60805160a0516107f3610188600039600061018401526000818160c2015261024001526107f36000f3fe6080604052600436106100965760003560e01c8063ba2b0ff611610069578063ced32b0c1161004e578063ced32b0c146101bb578063f2fde38b146101db578063ffa8d9dc146101fb57600080fd5b8063ba2b0ff61461014e578063bab161bf1461017257600080fd5b80631806b5f21461009b5780635d43792c146100b0578063715018a61461010e5780638da5cb5b14610123575b600080fd5b6100ae6100a9366004610687565b610228565b005b3480156100bc57600080fd5b506100e47f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561011a57600080fd5b506100ae6103ed565b34801561012f57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100e4565b34801561015a57600080fd5b5061016460025481565b604051908152602001610105565b34801561017e57600080fd5b506101a67f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff9091168152602001610105565b3480156101c757600080fd5b506100ae6101d6366004610782565b610401565b3480156101e757600080fd5b506100ae6101f6366004610782565b610482565b34801561020757600080fd5b506001546100e49073ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f7420506f6c79676f6e5a6b45564d42726964676500000000000000000060648201526084015b60405180910390fd5b60015473ffffffffffffffffffffffffffffffffffffffff84811691161461039c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f742070696e672053656e6465720000000000000000000000000000000060648201526084016102e9565b808060200190518101906103b091906107a4565b60028190556040519081527f51c4f05cea43f3d4604f77fd5a656743088090aa726deb5e3a9f670d8da75d659060200160405180910390a1505050565b6103f5610539565b6103ff60006105ba565b565b610409610539565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f3f61e183128e8b0775a132afd07eb6b4d74e1e66d7de3c5fbb7a6349b1207b669060200160405180910390a150565b61048a610539565b73ffffffffffffffffffffffffffffffffffffffff811661052d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102e9565b610536816105ba565b50565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102e9565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461065357600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561069c57600080fd5b6106a58461062f565b9250602084013563ffffffff811681146106be57600080fd5b9150604084013567ffffffffffffffff808211156106db57600080fd5b818601915086601f8301126106ef57600080fd5b81358181111561070157610701610658565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074757610747610658565b8160405282815289602084870101111561076057600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079457600080fd5b61079d8261062f565b9392505050565b6000602082840312156107b657600080fd5b505191905056fea2646970667358221220f7a6343b3726f685cbf1f60341761a53a0484ae48391492386c86ccaa585ea9964736f6c63430008110033", +} + +// PingReceiverABI is the input ABI used to generate the binding from. +// Deprecated: Use PingReceiverMetaData.ABI instead. +var PingReceiverABI = PingReceiverMetaData.ABI + +// PingReceiverBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use PingReceiverMetaData.Bin instead. +var PingReceiverBin = PingReceiverMetaData.Bin + +// DeployPingReceiver deploys a new Ethereum contract, binding an instance of PingReceiver to it. +func DeployPingReceiver(auth *bind.TransactOpts, backend bind.ContractBackend, _polygonZkEVMBridge common.Address) (common.Address, *types.Transaction, *PingReceiver, error) { + parsed, err := PingReceiverMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(PingReceiverBin), backend, _polygonZkEVMBridge) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &PingReceiver{PingReceiverCaller: PingReceiverCaller{contract: contract}, PingReceiverTransactor: PingReceiverTransactor{contract: contract}, PingReceiverFilterer: PingReceiverFilterer{contract: contract}}, nil +} + +// PingReceiver is an auto generated Go binding around an Ethereum contract. +type PingReceiver struct { + PingReceiverCaller // Read-only binding to the contract + PingReceiverTransactor // Write-only binding to the contract + PingReceiverFilterer // Log filterer for contract events +} + +// PingReceiverCaller is an auto generated read-only Go binding around an Ethereum contract. +type PingReceiverCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PingReceiverTransactor is an auto generated write-only Go binding around an Ethereum contract. +type PingReceiverTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PingReceiverFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type PingReceiverFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PingReceiverSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type PingReceiverSession struct { + Contract *PingReceiver // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PingReceiverCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type PingReceiverCallerSession struct { + Contract *PingReceiverCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// PingReceiverTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type PingReceiverTransactorSession struct { + Contract *PingReceiverTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PingReceiverRaw is an auto generated low-level Go binding around an Ethereum contract. +type PingReceiverRaw struct { + Contract *PingReceiver // Generic contract binding to access the raw methods on +} + +// PingReceiverCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type PingReceiverCallerRaw struct { + Contract *PingReceiverCaller // Generic read-only contract binding to access the raw methods on +} + +// PingReceiverTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type PingReceiverTransactorRaw struct { + Contract *PingReceiverTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewPingReceiver creates a new instance of PingReceiver, bound to a specific deployed contract. +func NewPingReceiver(address common.Address, backend bind.ContractBackend) (*PingReceiver, error) { + contract, err := bindPingReceiver(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &PingReceiver{PingReceiverCaller: PingReceiverCaller{contract: contract}, PingReceiverTransactor: PingReceiverTransactor{contract: contract}, PingReceiverFilterer: PingReceiverFilterer{contract: contract}}, nil +} + +// NewPingReceiverCaller creates a new read-only instance of PingReceiver, bound to a specific deployed contract. +func NewPingReceiverCaller(address common.Address, caller bind.ContractCaller) (*PingReceiverCaller, error) { + contract, err := bindPingReceiver(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &PingReceiverCaller{contract: contract}, nil +} + +// NewPingReceiverTransactor creates a new write-only instance of PingReceiver, bound to a specific deployed contract. +func NewPingReceiverTransactor(address common.Address, transactor bind.ContractTransactor) (*PingReceiverTransactor, error) { + contract, err := bindPingReceiver(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &PingReceiverTransactor{contract: contract}, nil +} + +// NewPingReceiverFilterer creates a new log filterer instance of PingReceiver, bound to a specific deployed contract. +func NewPingReceiverFilterer(address common.Address, filterer bind.ContractFilterer) (*PingReceiverFilterer, error) { + contract, err := bindPingReceiver(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &PingReceiverFilterer{contract: contract}, nil +} + +// bindPingReceiver binds a generic wrapper to an already deployed contract. +func bindPingReceiver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := PingReceiverMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PingReceiver *PingReceiverRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PingReceiver.Contract.PingReceiverCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PingReceiver *PingReceiverRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PingReceiver.Contract.PingReceiverTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PingReceiver *PingReceiverRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PingReceiver.Contract.PingReceiverTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PingReceiver *PingReceiverCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PingReceiver.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PingReceiver *PingReceiverTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PingReceiver.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PingReceiver *PingReceiverTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PingReceiver.Contract.contract.Transact(opts, method, params...) +} + +// NetworkID is a free data retrieval call binding the contract method 0xbab161bf. +// +// Solidity: function networkID() view returns(uint32) +func (_PingReceiver *PingReceiverCaller) NetworkID(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _PingReceiver.contract.Call(opts, &out, "networkID") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// NetworkID is a free data retrieval call binding the contract method 0xbab161bf. +// +// Solidity: function networkID() view returns(uint32) +func (_PingReceiver *PingReceiverSession) NetworkID() (uint32, error) { + return _PingReceiver.Contract.NetworkID(&_PingReceiver.CallOpts) +} + +// NetworkID is a free data retrieval call binding the contract method 0xbab161bf. +// +// Solidity: function networkID() view returns(uint32) +func (_PingReceiver *PingReceiverCallerSession) NetworkID() (uint32, error) { + return _PingReceiver.Contract.NetworkID(&_PingReceiver.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_PingReceiver *PingReceiverCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PingReceiver.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_PingReceiver *PingReceiverSession) Owner() (common.Address, error) { + return _PingReceiver.Contract.Owner(&_PingReceiver.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_PingReceiver *PingReceiverCallerSession) Owner() (common.Address, error) { + return _PingReceiver.Contract.Owner(&_PingReceiver.CallOpts) +} + +// PingSender is a free data retrieval call binding the contract method 0xffa8d9dc. +// +// Solidity: function pingSender() view returns(address) +func (_PingReceiver *PingReceiverCaller) PingSender(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PingReceiver.contract.Call(opts, &out, "pingSender") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// PingSender is a free data retrieval call binding the contract method 0xffa8d9dc. +// +// Solidity: function pingSender() view returns(address) +func (_PingReceiver *PingReceiverSession) PingSender() (common.Address, error) { + return _PingReceiver.Contract.PingSender(&_PingReceiver.CallOpts) +} + +// PingSender is a free data retrieval call binding the contract method 0xffa8d9dc. +// +// Solidity: function pingSender() view returns(address) +func (_PingReceiver *PingReceiverCallerSession) PingSender() (common.Address, error) { + return _PingReceiver.Contract.PingSender(&_PingReceiver.CallOpts) +} + +// PingValue is a free data retrieval call binding the contract method 0xba2b0ff6. +// +// Solidity: function pingValue() view returns(uint256) +func (_PingReceiver *PingReceiverCaller) PingValue(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PingReceiver.contract.Call(opts, &out, "pingValue") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PingValue is a free data retrieval call binding the contract method 0xba2b0ff6. +// +// Solidity: function pingValue() view returns(uint256) +func (_PingReceiver *PingReceiverSession) PingValue() (*big.Int, error) { + return _PingReceiver.Contract.PingValue(&_PingReceiver.CallOpts) +} + +// PingValue is a free data retrieval call binding the contract method 0xba2b0ff6. +// +// Solidity: function pingValue() view returns(uint256) +func (_PingReceiver *PingReceiverCallerSession) PingValue() (*big.Int, error) { + return _PingReceiver.Contract.PingValue(&_PingReceiver.CallOpts) +} + +// PolygonZkEVMBridge is a free data retrieval call binding the contract method 0x5d43792c. +// +// Solidity: function polygonZkEVMBridge() view returns(address) +func (_PingReceiver *PingReceiverCaller) PolygonZkEVMBridge(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PingReceiver.contract.Call(opts, &out, "polygonZkEVMBridge") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// PolygonZkEVMBridge is a free data retrieval call binding the contract method 0x5d43792c. +// +// Solidity: function polygonZkEVMBridge() view returns(address) +func (_PingReceiver *PingReceiverSession) PolygonZkEVMBridge() (common.Address, error) { + return _PingReceiver.Contract.PolygonZkEVMBridge(&_PingReceiver.CallOpts) +} + +// PolygonZkEVMBridge is a free data retrieval call binding the contract method 0x5d43792c. +// +// Solidity: function polygonZkEVMBridge() view returns(address) +func (_PingReceiver *PingReceiverCallerSession) PolygonZkEVMBridge() (common.Address, error) { + return _PingReceiver.Contract.PolygonZkEVMBridge(&_PingReceiver.CallOpts) +} + +// OnMessageReceived is a paid mutator transaction binding the contract method 0x1806b5f2. +// +// Solidity: function onMessageReceived(address originAddress, uint32 originNetwork, bytes data) payable returns() +func (_PingReceiver *PingReceiverTransactor) OnMessageReceived(opts *bind.TransactOpts, originAddress common.Address, originNetwork uint32, data []byte) (*types.Transaction, error) { + return _PingReceiver.contract.Transact(opts, "onMessageReceived", originAddress, originNetwork, data) +} + +// OnMessageReceived is a paid mutator transaction binding the contract method 0x1806b5f2. +// +// Solidity: function onMessageReceived(address originAddress, uint32 originNetwork, bytes data) payable returns() +func (_PingReceiver *PingReceiverSession) OnMessageReceived(originAddress common.Address, originNetwork uint32, data []byte) (*types.Transaction, error) { + return _PingReceiver.Contract.OnMessageReceived(&_PingReceiver.TransactOpts, originAddress, originNetwork, data) +} + +// OnMessageReceived is a paid mutator transaction binding the contract method 0x1806b5f2. +// +// Solidity: function onMessageReceived(address originAddress, uint32 originNetwork, bytes data) payable returns() +func (_PingReceiver *PingReceiverTransactorSession) OnMessageReceived(originAddress common.Address, originNetwork uint32, data []byte) (*types.Transaction, error) { + return _PingReceiver.Contract.OnMessageReceived(&_PingReceiver.TransactOpts, originAddress, originNetwork, data) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_PingReceiver *PingReceiverTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PingReceiver.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_PingReceiver *PingReceiverSession) RenounceOwnership() (*types.Transaction, error) { + return _PingReceiver.Contract.RenounceOwnership(&_PingReceiver.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_PingReceiver *PingReceiverTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _PingReceiver.Contract.RenounceOwnership(&_PingReceiver.TransactOpts) +} + +// SetSender is a paid mutator transaction binding the contract method 0xced32b0c. +// +// Solidity: function setSender(address newPingSender) returns() +func (_PingReceiver *PingReceiverTransactor) SetSender(opts *bind.TransactOpts, newPingSender common.Address) (*types.Transaction, error) { + return _PingReceiver.contract.Transact(opts, "setSender", newPingSender) +} + +// SetSender is a paid mutator transaction binding the contract method 0xced32b0c. +// +// Solidity: function setSender(address newPingSender) returns() +func (_PingReceiver *PingReceiverSession) SetSender(newPingSender common.Address) (*types.Transaction, error) { + return _PingReceiver.Contract.SetSender(&_PingReceiver.TransactOpts, newPingSender) +} + +// SetSender is a paid mutator transaction binding the contract method 0xced32b0c. +// +// Solidity: function setSender(address newPingSender) returns() +func (_PingReceiver *PingReceiverTransactorSession) SetSender(newPingSender common.Address) (*types.Transaction, error) { + return _PingReceiver.Contract.SetSender(&_PingReceiver.TransactOpts, newPingSender) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_PingReceiver *PingReceiverTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _PingReceiver.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_PingReceiver *PingReceiverSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _PingReceiver.Contract.TransferOwnership(&_PingReceiver.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_PingReceiver *PingReceiverTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _PingReceiver.Contract.TransferOwnership(&_PingReceiver.TransactOpts, newOwner) +} + +// PingReceiverOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the PingReceiver contract. +type PingReceiverOwnershipTransferredIterator struct { + Event *PingReceiverOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PingReceiverOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PingReceiverOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PingReceiverOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PingReceiverOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PingReceiverOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PingReceiverOwnershipTransferred represents a OwnershipTransferred event raised by the PingReceiver contract. +type PingReceiverOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_PingReceiver *PingReceiverFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*PingReceiverOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _PingReceiver.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &PingReceiverOwnershipTransferredIterator{contract: _PingReceiver.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_PingReceiver *PingReceiverFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *PingReceiverOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _PingReceiver.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PingReceiverOwnershipTransferred) + if err := _PingReceiver.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_PingReceiver *PingReceiverFilterer) ParseOwnershipTransferred(log types.Log) (*PingReceiverOwnershipTransferred, error) { + event := new(PingReceiverOwnershipTransferred) + if err := _PingReceiver.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PingReceiverPingReceivedIterator is returned from FilterPingReceived and is used to iterate over the raw logs and unpacked data for PingReceived events raised by the PingReceiver contract. +type PingReceiverPingReceivedIterator struct { + Event *PingReceiverPingReceived // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PingReceiverPingReceivedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PingReceiverPingReceived) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PingReceiverPingReceived) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PingReceiverPingReceivedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PingReceiverPingReceivedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PingReceiverPingReceived represents a PingReceived event raised by the PingReceiver contract. +type PingReceiverPingReceived struct { + PingValue *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterPingReceived is a free log retrieval operation binding the contract event 0x51c4f05cea43f3d4604f77fd5a656743088090aa726deb5e3a9f670d8da75d65. +// +// Solidity: event PingReceived(uint256 pingValue) +func (_PingReceiver *PingReceiverFilterer) FilterPingReceived(opts *bind.FilterOpts) (*PingReceiverPingReceivedIterator, error) { + + logs, sub, err := _PingReceiver.contract.FilterLogs(opts, "PingReceived") + if err != nil { + return nil, err + } + return &PingReceiverPingReceivedIterator{contract: _PingReceiver.contract, event: "PingReceived", logs: logs, sub: sub}, nil +} + +// WatchPingReceived is a free log subscription operation binding the contract event 0x51c4f05cea43f3d4604f77fd5a656743088090aa726deb5e3a9f670d8da75d65. +// +// Solidity: event PingReceived(uint256 pingValue) +func (_PingReceiver *PingReceiverFilterer) WatchPingReceived(opts *bind.WatchOpts, sink chan<- *PingReceiverPingReceived) (event.Subscription, error) { + + logs, sub, err := _PingReceiver.contract.WatchLogs(opts, "PingReceived") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PingReceiverPingReceived) + if err := _PingReceiver.contract.UnpackLog(event, "PingReceived", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParsePingReceived is a log parse operation binding the contract event 0x51c4f05cea43f3d4604f77fd5a656743088090aa726deb5e3a9f670d8da75d65. +// +// Solidity: event PingReceived(uint256 pingValue) +func (_PingReceiver *PingReceiverFilterer) ParsePingReceived(log types.Log) (*PingReceiverPingReceived, error) { + event := new(PingReceiverPingReceived) + if err := _PingReceiver.contract.UnpackLog(event, "PingReceived", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PingReceiverSetSenderIterator is returned from FilterSetSender and is used to iterate over the raw logs and unpacked data for SetSender events raised by the PingReceiver contract. +type PingReceiverSetSenderIterator struct { + Event *PingReceiverSetSender // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PingReceiverSetSenderIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PingReceiverSetSender) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PingReceiverSetSender) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PingReceiverSetSenderIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PingReceiverSetSenderIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PingReceiverSetSender represents a SetSender event raised by the PingReceiver contract. +type PingReceiverSetSender struct { + NewPingSender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSetSender is a free log retrieval operation binding the contract event 0x3f61e183128e8b0775a132afd07eb6b4d74e1e66d7de3c5fbb7a6349b1207b66. +// +// Solidity: event SetSender(address newPingSender) +func (_PingReceiver *PingReceiverFilterer) FilterSetSender(opts *bind.FilterOpts) (*PingReceiverSetSenderIterator, error) { + + logs, sub, err := _PingReceiver.contract.FilterLogs(opts, "SetSender") + if err != nil { + return nil, err + } + return &PingReceiverSetSenderIterator{contract: _PingReceiver.contract, event: "SetSender", logs: logs, sub: sub}, nil +} + +// WatchSetSender is a free log subscription operation binding the contract event 0x3f61e183128e8b0775a132afd07eb6b4d74e1e66d7de3c5fbb7a6349b1207b66. +// +// Solidity: event SetSender(address newPingSender) +func (_PingReceiver *PingReceiverFilterer) WatchSetSender(opts *bind.WatchOpts, sink chan<- *PingReceiverSetSender) (event.Subscription, error) { + + logs, sub, err := _PingReceiver.contract.WatchLogs(opts, "SetSender") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PingReceiverSetSender) + if err := _PingReceiver.contract.UnpackLog(event, "SetSender", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSetSender is a log parse operation binding the contract event 0x3f61e183128e8b0775a132afd07eb6b4d74e1e66d7de3c5fbb7a6349b1207b66. +// +// Solidity: event SetSender(address newPingSender) +func (_PingReceiver *PingReceiverFilterer) ParseSetSender(log types.Log) (*PingReceiverSetSender, error) { + event := new(PingReceiverSetSender) + if err := _PingReceiver.contract.UnpackLog(event, "SetSender", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/test/mocksmartcontracts/abi/PingReceiver.abi b/test/mocksmartcontracts/abi/PingReceiver.abi new file mode 100644 index 000000000..ebc2e5f2b --- /dev/null +++ b/test/mocksmartcontracts/abi/PingReceiver.abi @@ -0,0 +1,179 @@ + [ + { + "inputs": [ + { + "internalType": "contract IPolygonZkEVMBridge", + "name": "_polygonZkEVMBridge", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "pingValue", + "type": "uint256" + } + ], + "name": "PingReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newPingSender", + "type": "address" + } + ], + "name": "SetSender", + "type": "event" + }, + { + "inputs": [], + "name": "networkID", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "originAddress", + "type": "address" + }, + { + "internalType": "uint32", + "name": "originNetwork", + "type": "uint32" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "onMessageReceived", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pingSender", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pingValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "polygonZkEVMBridge", + "outputs": [ + { + "internalType": "contract IPolygonZkEVMBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPingSender", + "type": "address" + } + ], + "name": "setSender", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/test/mocksmartcontracts/bin/PingReceiver.bin b/test/mocksmartcontracts/bin/PingReceiver.bin new file mode 100644 index 000000000..0dece813a --- /dev/null +++ b/test/mocksmartcontracts/bin/PingReceiver.bin @@ -0,0 +1 @@ +0x60c060405234801561001057600080fd5b5060405161097b38038061097b83398101604081905261002f91610107565b610038336100b7565b6001600160a01b03811660808190526040805163bab161bf60e01b8152905163bab161bf9160048082019260209290919082900301816000875af1158015610084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100a89190610137565b63ffffffff1660a0525061015d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561011957600080fd5b81516001600160a01b038116811461013057600080fd5b9392505050565b60006020828403121561014957600080fd5b815163ffffffff8116811461013057600080fd5b60805160a0516107f3610188600039600061018401526000818160c2015261024001526107f36000f3fe6080604052600436106100965760003560e01c8063ba2b0ff611610069578063ced32b0c1161004e578063ced32b0c146101bb578063f2fde38b146101db578063ffa8d9dc146101fb57600080fd5b8063ba2b0ff61461014e578063bab161bf1461017257600080fd5b80631806b5f21461009b5780635d43792c146100b0578063715018a61461010e5780638da5cb5b14610123575b600080fd5b6100ae6100a9366004610687565b610228565b005b3480156100bc57600080fd5b506100e47f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561011a57600080fd5b506100ae6103ed565b34801561012f57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100e4565b34801561015a57600080fd5b5061016460025481565b604051908152602001610105565b34801561017e57600080fd5b506101a67f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff9091168152602001610105565b3480156101c757600080fd5b506100ae6101d6366004610782565b610401565b3480156101e757600080fd5b506100ae6101f6366004610782565b610482565b34801561020757600080fd5b506001546100e49073ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f7420506f6c79676f6e5a6b45564d42726964676500000000000000000060648201526084015b60405180910390fd5b60015473ffffffffffffffffffffffffffffffffffffffff84811691161461039c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f742070696e672053656e6465720000000000000000000000000000000060648201526084016102e9565b808060200190518101906103b091906107a4565b60028190556040519081527f51c4f05cea43f3d4604f77fd5a656743088090aa726deb5e3a9f670d8da75d659060200160405180910390a1505050565b6103f5610539565b6103ff60006105ba565b565b610409610539565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f3f61e183128e8b0775a132afd07eb6b4d74e1e66d7de3c5fbb7a6349b1207b669060200160405180910390a150565b61048a610539565b73ffffffffffffffffffffffffffffffffffffffff811661052d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102e9565b610536816105ba565b50565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102e9565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461065357600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561069c57600080fd5b6106a58461062f565b9250602084013563ffffffff811681146106be57600080fd5b9150604084013567ffffffffffffffff808211156106db57600080fd5b818601915086601f8301126106ef57600080fd5b81358181111561070157610701610658565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074757610747610658565b8160405282815289602084870101111561076057600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079457600080fd5b61079d8261062f565b9392505050565b6000602082840312156107b657600080fd5b505191905056fea2646970667358221220f7a6343b3726f685cbf1f60341761a53a0484ae48391492386c86ccaa585ea9964736f6c63430008110033 \ No newline at end of file diff --git a/test/mocksmartcontracts/json/PingReceiver.json b/test/mocksmartcontracts/json/PingReceiver.json new file mode 100644 index 000000000..14f356373 --- /dev/null +++ b/test/mocksmartcontracts/json/PingReceiver.json @@ -0,0 +1,188 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "PingReceiver", + "sourceName": "contracts/PingReceiver.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IPolygonZkEVMBridge", + "name": "_polygonZkEVMBridge", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "pingValue", + "type": "uint256" + } + ], + "name": "PingReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newPingSender", + "type": "address" + } + ], + "name": "SetSender", + "type": "event" + }, + { + "inputs": [], + "name": "networkID", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "originAddress", + "type": "address" + }, + { + "internalType": "uint32", + "name": "originNetwork", + "type": "uint32" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "onMessageReceived", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pingSender", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pingValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "polygonZkEVMBridge", + "outputs": [ + { + "internalType": "contract IPolygonZkEVMBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPingSender", + "type": "address" + } + ], + "name": "setSender", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60c060405234801561001057600080fd5b5060405161097b38038061097b83398101604081905261002f91610107565b610038336100b7565b6001600160a01b03811660808190526040805163bab161bf60e01b8152905163bab161bf9160048082019260209290919082900301816000875af1158015610084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100a89190610137565b63ffffffff1660a0525061015d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561011957600080fd5b81516001600160a01b038116811461013057600080fd5b9392505050565b60006020828403121561014957600080fd5b815163ffffffff8116811461013057600080fd5b60805160a0516107f3610188600039600061018401526000818160c2015261024001526107f36000f3fe6080604052600436106100965760003560e01c8063ba2b0ff611610069578063ced32b0c1161004e578063ced32b0c146101bb578063f2fde38b146101db578063ffa8d9dc146101fb57600080fd5b8063ba2b0ff61461014e578063bab161bf1461017257600080fd5b80631806b5f21461009b5780635d43792c146100b0578063715018a61461010e5780638da5cb5b14610123575b600080fd5b6100ae6100a9366004610687565b610228565b005b3480156100bc57600080fd5b506100e47f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561011a57600080fd5b506100ae6103ed565b34801561012f57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100e4565b34801561015a57600080fd5b5061016460025481565b604051908152602001610105565b34801561017e57600080fd5b506101a67f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff9091168152602001610105565b3480156101c757600080fd5b506100ae6101d6366004610782565b610401565b3480156101e757600080fd5b506100ae6101f6366004610782565b610482565b34801561020757600080fd5b506001546100e49073ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f7420506f6c79676f6e5a6b45564d42726964676500000000000000000060648201526084015b60405180910390fd5b60015473ffffffffffffffffffffffffffffffffffffffff84811691161461039c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f742070696e672053656e6465720000000000000000000000000000000060648201526084016102e9565b808060200190518101906103b091906107a4565b60028190556040519081527f51c4f05cea43f3d4604f77fd5a656743088090aa726deb5e3a9f670d8da75d659060200160405180910390a1505050565b6103f5610539565b6103ff60006105ba565b565b610409610539565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f3f61e183128e8b0775a132afd07eb6b4d74e1e66d7de3c5fbb7a6349b1207b669060200160405180910390a150565b61048a610539565b73ffffffffffffffffffffffffffffffffffffffff811661052d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102e9565b610536816105ba565b50565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102e9565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461065357600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561069c57600080fd5b6106a58461062f565b9250602084013563ffffffff811681146106be57600080fd5b9150604084013567ffffffffffffffff808211156106db57600080fd5b818601915086601f8301126106ef57600080fd5b81358181111561070157610701610658565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074757610747610658565b8160405282815289602084870101111561076057600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079457600080fd5b61079d8261062f565b9392505050565b6000602082840312156107b657600080fd5b505191905056fea2646970667358221220f7a6343b3726f685cbf1f60341761a53a0484ae48391492386c86ccaa585ea9964736f6c63430008110033", + "deployedBytecode": "0x6080604052600436106100965760003560e01c8063ba2b0ff611610069578063ced32b0c1161004e578063ced32b0c146101bb578063f2fde38b146101db578063ffa8d9dc146101fb57600080fd5b8063ba2b0ff61461014e578063bab161bf1461017257600080fd5b80631806b5f21461009b5780635d43792c146100b0578063715018a61461010e5780638da5cb5b14610123575b600080fd5b6100ae6100a9366004610687565b610228565b005b3480156100bc57600080fd5b506100e47f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561011a57600080fd5b506100ae6103ed565b34801561012f57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100e4565b34801561015a57600080fd5b5061016460025481565b604051908152602001610105565b34801561017e57600080fd5b506101a67f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff9091168152602001610105565b3480156101c757600080fd5b506100ae6101d6366004610782565b610401565b3480156101e757600080fd5b506100ae6101f6366004610782565b610482565b34801561020757600080fd5b506001546100e49073ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f7420506f6c79676f6e5a6b45564d42726964676500000000000000000060648201526084015b60405180910390fd5b60015473ffffffffffffffffffffffffffffffffffffffff84811691161461039c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f50696e6752656365697665723a3a6f6e4d65737361676552656365697665643a60448201527f204e6f742070696e672053656e6465720000000000000000000000000000000060648201526084016102e9565b808060200190518101906103b091906107a4565b60028190556040519081527f51c4f05cea43f3d4604f77fd5a656743088090aa726deb5e3a9f670d8da75d659060200160405180910390a1505050565b6103f5610539565b6103ff60006105ba565b565b610409610539565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f3f61e183128e8b0775a132afd07eb6b4d74e1e66d7de3c5fbb7a6349b1207b669060200160405180910390a150565b61048a610539565b73ffffffffffffffffffffffffffffffffffffffff811661052d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016102e9565b610536816105ba565b50565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102e9565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461065357600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561069c57600080fd5b6106a58461062f565b9250602084013563ffffffff811681146106be57600080fd5b9150604084013567ffffffffffffffff808211156106db57600080fd5b818601915086601f8301126106ef57600080fd5b81358181111561070157610701610658565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074757610747610658565b8160405282815289602084870101111561076057600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079457600080fd5b61079d8261062f565b9392505050565b6000602082840312156107b657600080fd5b505191905056fea2646970667358221220f7a6343b3726f685cbf1f60341761a53a0484ae48391492386c86ccaa585ea9964736f6c63430008110033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/test/mocksmartcontracts/readme.md b/test/mocksmartcontracts/readme.md new file mode 100644 index 000000000..5629c727b --- /dev/null +++ b/test/mocksmartcontracts/readme.md @@ -0,0 +1,4 @@ +# Contracts + +### PingReceiver +- Original code: [PingReceiver.sol](https://github.com/0xPolygonHermez/code-examples/blob/main/pingPongExample/contracts/PingReceiver.sol) diff --git a/test/mocksmartcontracts/script.sh b/test/mocksmartcontracts/script.sh index 0e01b46a7..1517e2dcf 100755 --- a/test/mocksmartcontracts/script.sh +++ b/test/mocksmartcontracts/script.sh @@ -10,12 +10,14 @@ gen() { abigen --bin bin/${package}.bin --abi abi/${package}.abi --pkg=${package} --out=${package}/${package}.go } + compilegen() { local package=$1 - docker run --rm --user $(id -u) -v "${dir}:/contracts" ethereum/solc:0.8.20-alpine - "/contracts/${package}.sol" -o "/contracts/${package}" --abi --bin --overwrite --optimize --evm-version shangai + docker run --rm --user $(id -u) -v "${dir}:/contracts" ethereum/solc:0.8.20-alpine - "/contracts/${package}.sol" -o "/contracts/${package}" --abi --bin --overwrite --optimize --evm-version paris abigen --bin ${package}/${package}.bin --abi ${package}/${package}.abi --pkg=${package} --out=${package}/${package}.go } +gen PingReceiver gen polygonzkevmbridge compilegen BridgeMessageReceiver \ No newline at end of file diff --git a/test/operations/interfaces.go b/test/operations/interfaces.go index 39ccb664e..32541f612 100644 --- a/test/operations/interfaces.go +++ b/test/operations/interfaces.go @@ -39,4 +39,5 @@ type StorageInterface interface { type BridgeServiceInterface interface { GetBridges(ctx context.Context, req *pb.GetBridgesRequest) (*pb.GetBridgesResponse, error) GetProof(ctx context.Context, req *pb.GetProofRequest) (*pb.GetProofResponse, error) + GetProofByGER(ctx context.Context, req *pb.GetProofByGERRequest) (*pb.GetProofResponse, error) } diff --git a/test/operations/manager.go b/test/operations/manager.go index f80809533..b31359911 100644 --- a/test/operations/manager.go +++ b/test/operations/manager.go @@ -554,6 +554,34 @@ func (m *Manager) CheckAccountTokenBalance(ctx context.Context, network NetworkS return balance, nil } +// GetClaimDataByGER gets the claim data by ger +func (m *Manager) GetClaimDataByGER(ctx context.Context, networkID, depositCount uint, ger common.Hash) ([mtHeight][bridgectrl.KeyLen]byte, [mtHeight][bridgectrl.KeyLen]byte, *etherman.GlobalExitRoot, error) { + res, err := m.bridgeService.GetProofByGER(context.Background(), &pb.GetProofByGERRequest{ + NetId: uint32(networkID), + DepositCnt: uint64(depositCount), + Ger: ger.String(), + }) + if err != nil { + return [mtHeight][32]byte{}, [mtHeight][32]byte{}, nil, err + } + merkleproof := [mtHeight][bridgectrl.KeyLen]byte{} + rollupMerkleProof := [mtHeight][bridgectrl.KeyLen]byte{} + for i, p := range res.Proof.MerkleProof { + var proof [bridgectrl.KeyLen]byte + copy(proof[:], common.FromHex(p)) + merkleproof[i] = proof + var rollupProof [bridgectrl.KeyLen]byte + copy(rollupProof[:], common.FromHex(res.Proof.RollupMerkleProof[i])) + rollupMerkleProof[i] = rollupProof + } + return merkleproof, rollupMerkleProof, ðerman.GlobalExitRoot{ + ExitRoots: []common.Hash{ + common.HexToHash(res.Proof.MainExitRoot), + common.HexToHash(res.Proof.RollupExitRoot), + }, + }, nil +} + // GetClaimData gets the claim data func (m *Manager) GetClaimData(ctx context.Context, networkID, depositCount uint) ([mtHeight][bridgectrl.KeyLen]byte, [mtHeight][bridgectrl.KeyLen]byte, *etherman.GlobalExitRoot, error) { res, err := m.bridgeService.GetProof(context.Background(), &pb.GetProofRequest{ diff --git a/utils/client.go b/utils/client.go index c7182d08d..aa29fc4e3 100644 --- a/utils/client.go +++ b/utils/client.go @@ -17,6 +17,7 @@ import ( zkevmtypes "github.com/0xPolygonHermez/zkevm-node/config/types" "github.com/0xPolygonHermez/zkevm-node/encoding" "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmbridge" + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmglobalexitroot" "github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/ERC20" ops "github.com/0xPolygonHermez/zkevm-node/test/operations" "github.com/ethereum/go-ethereum" @@ -42,7 +43,9 @@ const ( type Client struct { // Client ethclient *ethclient.Client - Bridge *polygonzkevmbridge.Polygonzkevmbridge + Bridge *polygonzkevmbridge.Polygonzkevmbridge + BridgeSCAddr common.Address + NodeURL string } // NewClient creates client. @@ -56,8 +59,10 @@ func NewClient(ctx context.Context, nodeURL string, bridgeSCAddr common.Address) br, err = polygonzkevmbridge.NewPolygonzkevmbridge(bridgeSCAddr, client) } return &Client{ - Client: client, - Bridge: br, + Client: client, + Bridge: br, + BridgeSCAddr: bridgeSCAddr, + NodeURL: nodeURL, }, err } @@ -208,7 +213,8 @@ func (c *Client) BuildSendClaim(ctx context.Context, deposit *etherman.Deposit, localExitRootIndex := deposit.DepositCount globalIndex := etherman.GenerateGlobalIndex(mainnetFlag, rollupIndex, localExitRootIndex) if deposit.LeafType == uint8(LeafTypeAsset) { - tx, err = c.Bridge.ClaimAsset(&opts, smtProof, smtRollupProof, globalIndex, globalExitRoot.ExitRoots[0], globalExitRoot.ExitRoots[1], uint32(deposit.OriginalNetwork), deposit.OriginalAddress, uint32(deposit.DestinationNetwork), deposit.DestinationAddress, deposit.Amount, deposit.Metadata) + tx, err = c.Bridge.ClaimAsset(&opts, smtProof, smtRollupProof, + globalIndex, globalExitRoot.ExitRoots[0], globalExitRoot.ExitRoots[1], uint32(deposit.OriginalNetwork), deposit.OriginalAddress, uint32(deposit.DestinationNetwork), deposit.DestinationAddress, deposit.Amount, deposit.Metadata) } else if deposit.LeafType == uint8(LeafTypeMessage) { tx, err = c.Bridge.ClaimMessage(&opts, smtProof, smtRollupProof, globalIndex, globalExitRoot.ExitRoots[0], globalExitRoot.ExitRoots[1], uint32(deposit.OriginalNetwork), deposit.OriginalAddress, uint32(deposit.DestinationNetwork), deposit.DestinationAddress, deposit.Amount, deposit.Metadata) } @@ -233,7 +239,8 @@ func (c *Client) SendClaim(ctx context.Context, deposit *pb.Deposit, smtProof [m ) globalIndex, _ := big.NewInt(0).SetString(deposit.GlobalIndex, 0) if deposit.LeafType == LeafTypeAsset { - tx, err = c.Bridge.ClaimAsset(auth, smtProof, smtRollupProof, globalIndex, globalExitRoot.ExitRoots[0], globalExitRoot.ExitRoots[1], deposit.OrigNet, common.HexToAddress(deposit.OrigAddr), deposit.DestNet, common.HexToAddress(deposit.DestAddr), amount, common.FromHex(deposit.Metadata)) + metadata := common.FromHex(deposit.Metadata) + tx, err = c.Bridge.ClaimAsset(auth, smtProof, smtRollupProof, globalIndex, globalExitRoot.ExitRoots[0], globalExitRoot.ExitRoots[1], deposit.OrigNet, common.HexToAddress(deposit.OrigAddr), deposit.DestNet, common.HexToAddress(deposit.DestAddr), amount, metadata) } else if deposit.LeafType == LeafTypeMessage { tx, err = c.Bridge.ClaimMessage(auth, smtProof, smtRollupProof, globalIndex, globalExitRoot.ExitRoots[0], globalExitRoot.ExitRoots[1], deposit.OrigNet, common.HexToAddress(deposit.OrigAddr), deposit.DestNet, common.HexToAddress(deposit.DestAddr), amount, common.FromHex(deposit.Metadata)) } @@ -255,3 +262,30 @@ func (c *Client) SendClaim(ctx context.Context, deposit *pb.Deposit, smtProof [m func WaitTxToBeMined(ctx context.Context, client *ethclient.Client, tx *types.Transaction, timeout time.Duration) error { return ops.WaitTxToBeMined(ctx, client, tx, timeout) } + +func (c *Client) GetGlobalExitRootFromSmc(ctx context.Context) (*etherman.GlobalExitRoot, error) { + br, err := polygonzkevmbridge.NewPolygonzkevmbridge(c.BridgeSCAddr, c.Client) + if err != nil { + return nil, err + } + GlobalExitRootManAddr, err := br.GlobalExitRootManager(&bind.CallOpts{Pending: false}) + if err != nil { + return nil, err + } + globalManager, err := polygonzkevmglobalexitroot.NewPolygonzkevmglobalexitroot(GlobalExitRootManAddr, c.Client) + if err != nil { + return nil, err + } + gMainnet, err := globalManager.LastMainnetExitRoot(&bind.CallOpts{Pending: false}) + if err != nil { + return nil, err + } + gRollup, err := globalManager.LastRollupExitRoot(&bind.CallOpts{Pending: false}) + if err != nil { + return nil, err + } + result := etherman.GlobalExitRoot{ + ExitRoots: []common.Hash{gMainnet, gRollup}, + } + return &result, nil +}