Skip to content

Commit

Permalink
First implementation (#1)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* wip

* ci

* linter

* finish WIP

* fix gha

* fix gha

* fix gha
  • Loading branch information
ToniRamirezM authored Jan 12, 2024
1 parent c36a991 commit 509a587
Show file tree
Hide file tree
Showing 116 changed files with 48,644 additions and 19 deletions.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Report a bug
about: Something with Polygon zkEVM Eth Tx Manager is not working as expected
title: ''
labels: 'type:bug'
assignees: ''
---

#### System information

zkEVM Node version: `v0.0.X-RCXX`
OS & Version: `Windows/Linux/OSX`
Commit hash : (if `develop`)
Network: `Mainnet/Testnet`

#### Expected behaviour


#### Actual behaviour


#### Steps to reproduce the behaviour


#### Backtrace

````
[backtrace]
````

When submitting logs: please submit them as text and not screenshots.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Request a feature
about: Report a missing feature - e.g. as a step before submitting a PR
title: ''
labels: 'type:feature'
assignees: ''
---

# Rationale

Why should this feature exist?
What are the use-cases?

# Implementation

Do you have ideas regarding the implementation of this feature?
Are you willing to implement this feature?
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Ask a question
about: Something is unclear
title: ''
labels: 'type:question'
assignees: ''
---

This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
7 changes: 7 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Only run lint if .go files changed
git diff --cached --name-only | if grep --quiet ".*go$"
then
make lint
fi
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Closes #<issue number>.

### What does this PR do?

<!-- Describe your changes here- ideally you can get that description straight from
your descriptive commit message(s)! -->

### Reviewers

Main reviewers:

<!-- Main reviewers should do a full review. There should be 2 main reviewers, unless there is a good reason for not to do it -->

- @John
- @Doe

Codeowner reviewers:

<!-- Codeowners should review only the part of code that they own, they're added automatically as reviewers and it's good to let them know that they shouldn't do a full review -->

- @-Alice
- @-Bob
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint
on:
push:
branches:
- main
- master
- develop
- update-external-dependencies
- 'release/**'
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
- name: Checkout code
uses: actions/checkout@v3
- name: Lint
run: |
make install-linter
make lint
32 changes: 32 additions & 0 deletions .github/workflows/push-docker-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: true
tags: |
hermeznetwork/zkevm-ethtx-manager:main
33 changes: 33 additions & 0 deletions .github/workflows/push-docker-tagged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # this action will only run on tags that follow semver

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
hermeznetwork/zkevm-ethtx-manager:${{ github.ref_name }}
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # this action will only run on tags that follow semver
jobs:
releaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: Get packr
run: go install github.com/gobuffalo/packr/v2/[email protected]

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_RELEASE }}

- name: Get tag
uses: olegtarasov/[email protected]
id: tagName

- name: Put testnet and mainnet artifacts into a single zip
run: |
# TESTNET
mkdir -p testnet/config/environments/testnet
cp config/environments/testnet/* testnet/config/environments/testnet
cp docker-compose.yml testnet
sed -i 's/\/config\/environments\/${ZKEVM_NETWORK}/\/config\/environments\/testnet/g' testnet/docker-compose.yml
mv testnet/config/environments/testnet/example.env testnet
sed -i -e "s/image: zkevm-ethtx-manager/image: hermeznetwork\/zkevm-ethtx-manager:$GIT_TAG_NAME/g" testnet/docker-compose.yml
zip -r testnet.zip testnet
# MAINNET
mkdir -p mainnet/config/environments/mainnet
cp config/environments/mainnet/* mainnet/config/environments/mainnet
cp docker-compose.yml mainnet
sed -i 's/\/config\/environments\/${ZKEVM_NETWORK}/\/config\/environments\/mainnet/g' mainnet/docker-compose.yml
mv mainnet/config/environments/mainnet/example.env mainnet
sed -i -e "s/image: zkevm-ethtx-manager/image: hermeznetwork\/zkevm-ethtx-manager:$GIT_TAG_NAME/g" mainnet/docker-compose.yml
zip -r mainnet.zip mainnet
- name: Publish testnet and mainnet zip into release
uses: AButler/[email protected]
with:
files: 'testnet.zip;mainnet.zip'
repo-token: ${{ secrets.TOKEN_RELEASE }}
release-tag: ${{ steps.tagName.outputs.tag }}

33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Test
on:
push:
branches:
- main
- master
- develop
- update-external-dependencies
- 'release/**'
pull_request:

jobs:
test:
strategy:
matrix:
go-version: [ 1.21.x ]
goarch: [ "amd64" ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
env:
GOARCH: ${{ matrix.goarch }}

- name: Test
run: make test
working-directory: test
25 changes: 6 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
/dist/

# Test binary, built with `go test -c`
*.test
/test/*.bin

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
**/.DS_Store
.vscode
.idea/
.env
32 changes: 32 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
run:
timeout: 5m
skip-dirs:
- state/runtime/fakevm
- state/runtime/instrumentation
- test
- ci

linters:
enable:
- whitespace
- gosec
- gci
- misspell
- gomnd
- gofmt
- goimports
- revive
- unconvert

linters-settings:
revive:
rules:
- name: exported
arguments:
- disableStutteringCheck

issues:
include:
- EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
- EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
22 changes: 22 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .goreleaser.yaml
builds:
- main: ./cmd/
goos:
- linux
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
ldflags:
- -X github.com/0xPolygonHermez/zkevm-ethtx-manager.Version={{.Version}}
- -X github.com/0xPolygonHermez/zkevm-ethtx-manager.GitRev={{.Commit}}
- -X github.com/0xPolygonHermez/zkevm-ethtx-manager.BuildDate={{.Date}}
- -X github.com/0xPolygonHermez/zkevm-ethtx-manager.GitBranch={{.Branch}}
release:
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: true
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# CONTAINER FOR BUILDING BINARY
FROM golang:1.21 AS build

# INSTALL DEPENDENCIES
RUN go install github.com/gobuffalo/packr/v2/[email protected]
COPY go.mod go.sum /src/
RUN cd /src && go mod download

# BUILD BINARY
COPY . /src
RUN cd /src/db && packr2
RUN cd /src && make build

# CONTAINER FOR RUNNING BINARY
FROM alpine:3.18.4
COPY --from=build /src/dist/zkevm-ethtx-manager /app/zkevm-ethtx-manager
COPY --from=build /src/config/environments/testnet/ethtxmanager.config.toml /app/example.config.toml
RUN apk update && apk add postgresql15-client
EXPOSE 8123
CMD ["/bin/sh", "-c", "/app/zkevm-ethtx-manager run"]
Loading

0 comments on commit 509a587

Please sign in to comment.