Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/go_modules/develop/github.com/…
Browse files Browse the repository at this point in the history
…spf13/viper-1.19.0
  • Loading branch information
ARR552 authored Aug 13, 2024
2 parents a65194d + 0bda9c7 commit ddf3c80
Show file tree
Hide file tree
Showing 45 changed files with 4,332 additions and 425 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/deb_packager.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test-e2e
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-e2ecompress.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test-e2compress
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-edge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test-edge
on:
push:
branches:
Expand Down
18 changes: 18 additions & 0 deletions DockerfileE2ETest
Original file line number Diff line number Diff line change
@@ -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"]
30 changes: 24 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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

29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > ./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)
Loading

0 comments on commit ddf3c80

Please sign in to comment.