Skip to content

Commit dd70cf6

Browse files
colinlyguocolin
andauthored
feat: add scroll-node (#14)
Co-authored-by: colin <[email protected]>
1 parent 997f6ac commit dd70cf6

File tree

124 files changed

+80164
-669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+80164
-669
lines changed

.github/workflows/bridge.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Bridge
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- staging
8+
paths:
9+
- 'bridge/**'
10+
- '.github/workflows/bridge.yml'
11+
pull_request:
12+
branches:
13+
- main
14+
- staging
15+
paths:
16+
- 'bridge/**'
17+
- '.github/workflows/bridge.yml'
18+
19+
defaults:
20+
run:
21+
working-directory: 'bridge'
22+
23+
jobs:
24+
check:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Install Go
28+
uses: actions/setup-go@v2
29+
with:
30+
go-version: 1.18.x
31+
- name: Checkout code
32+
uses: actions/checkout@v2
33+
- name: Install Solc
34+
uses: pontem-network/get-solc@master
35+
- name: Install Geth Tools
36+
uses: gacts/install-geth-tools@v1
37+
- name: Lint
38+
run: |
39+
rm -rf $HOME/.cache/golangci-lint
40+
make mock_abi
41+
make lint
42+
goimports-lint:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Install Go
46+
uses: actions/setup-go@v2
47+
with:
48+
go-version: 1.18.x
49+
- name: Checkout code
50+
uses: actions/checkout@v2
51+
- name: Install goimports
52+
run: go install golang.org/x/tools/cmd/goimports
53+
- run: goimports -local scroll-tech/bridge/ -w .
54+
- run: go mod tidy
55+
# If there are any diffs from goimports or go mod tidy, fail.
56+
- name: Verify no changes from goimports and go mod tidy
57+
run: |
58+
if [ -n "$(git status --porcelain)" ]; then
59+
exit 1
60+
fi

.github/workflows/common.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Common
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- staging
8+
paths:
9+
- 'common/**'
10+
- '.github/workflows/common.yml'
11+
pull_request:
12+
branches:
13+
- main
14+
- staging
15+
paths:
16+
- 'common/**'
17+
- '.github/workflows/common.yml'
18+
19+
defaults:
20+
run:
21+
working-directory: 'common'
22+
23+
jobs:
24+
check:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Install Go
28+
uses: actions/setup-go@v2
29+
with:
30+
go-version: 1.18.x
31+
- name: Checkout code
32+
uses: actions/checkout@v2
33+
- name: Lint
34+
run: |
35+
rm -rf $HOME/.cache/golangci-lint
36+
make lint
37+
goimports-lint:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Install Go
41+
uses: actions/setup-go@v2
42+
with:
43+
go-version: 1.18.x
44+
- name: Checkout code
45+
uses: actions/checkout@v2
46+
- name: Install goimports
47+
run: go install golang.org/x/tools/cmd/goimports
48+
- run: goimports -local scroll-tech/common/ -w .
49+
- run: go mod tidy
50+
# If there are any diffs from goimports or go mod tidy, fail.
51+
- name: Verify no changes from goimports and go mod tidy
52+
run: |
53+
if [ -n "$(git status --porcelain)" ]; then
54+
exit 1
55+
fi

.github/workflows/coordinator.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Coordinator
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- staging
8+
paths:
9+
- 'coordinator/**'
10+
- '.github/workflows/coordinator.yml'
11+
pull_request:
12+
branches:
13+
- main
14+
- staging
15+
paths:
16+
- 'coordinator/**'
17+
- '.github/workflows/coordinator.yml'
18+
19+
defaults:
20+
run:
21+
working-directory: 'coordinator'
22+
23+
jobs:
24+
check:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Install Go
28+
uses: actions/setup-go@v2
29+
with:
30+
go-version: 1.18.x
31+
- name: Checkout code
32+
uses: actions/checkout@v2
33+
- name: Lint
34+
run: |
35+
rm -rf $HOME/.cache/golangci-lint
36+
make lint
37+
goimports-lint:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Install Go
41+
uses: actions/setup-go@v2
42+
with:
43+
go-version: 1.18.x
44+
- name: Checkout code
45+
uses: actions/checkout@v2
46+
- name: Install goimports
47+
run: go install golang.org/x/tools/cmd/goimports
48+
- run: goimports -local scroll-tech/coordinator/ -w .
49+
- run: go mod tidy
50+
# If there are any diffs from goimports or go mod tidy, fail.
51+
- name: Verify no changes from goimports and go mod tidy
52+
run: |
53+
if [ -n "$(git status --porcelain)" ]; then
54+
exit 1
55+
fi

.github/workflows/database.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Database
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- staging
8+
paths:
9+
- 'database/**'
10+
- '.github/workflows/database.yml'
11+
pull_request:
12+
branches:
13+
- main
14+
- staging
15+
paths:
16+
- 'database/**'
17+
- '.github/workflows/database.yml'
18+
19+
defaults:
20+
run:
21+
working-directory: 'database'
22+
23+
jobs:
24+
check:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Install Go
28+
uses: actions/setup-go@v2
29+
with:
30+
go-version: 1.18.x
31+
- name: Checkout code
32+
uses: actions/checkout@v2
33+
- name: Lint
34+
run: |
35+
rm -rf $HOME/.cache/golangci-lint
36+
make lint
37+
goimports-lint:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Install Go
41+
uses: actions/setup-go@v2
42+
with:
43+
go-version: 1.18.x
44+
- name: Checkout code
45+
uses: actions/checkout@v2
46+
- name: Install goimports
47+
run: go install golang.org/x/tools/cmd/goimports
48+
- run: goimports -local scroll-tech/database/ -w .
49+
- run: go mod tidy
50+
# If there are any diffs from goimports or go mod tidy, fail.
51+
- name: Verify no changes from goimports and go mod tidy
52+
run: |
53+
if [ -n "$(git status --porcelain)" ]; then
54+
exit 1
55+
fi

.github/workflows/roller.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Install Go
3333
uses: actions/setup-go@v2
3434
with:
35-
go-version: 1.17.x
35+
go-version: 1.18.x
3636
- name: Checkout code
3737
uses: actions/checkout@v2
3838
- name: Cache cargo registry
@@ -60,7 +60,7 @@ jobs:
6060
- name: Install Go
6161
uses: actions/setup-go@v2
6262
with:
63-
go-version: 1.17.x
63+
go-version: 1.18.x
6464
- name: Checkout code
6565
uses: actions/checkout@v2
6666
- name: Lint
@@ -73,11 +73,11 @@ jobs:
7373
- name: Install Go
7474
uses: actions/setup-go@v2
7575
with:
76-
go-version: 1.17.x
76+
go-version: 1.18.x
7777
- name: Checkout code
7878
uses: actions/checkout@v2
7979
- name: Install goimports
80-
run: go get golang.org/x/tools/cmd/goimports
80+
run: go install golang.org/x/tools/cmd/goimports
8181
- run: goimports -local scroll-tech/go-roller/ -w .
8282
- run: go mod tidy
8383
# If there are any diffs from goimports or go mod tidy, fail.

Jenkinsfile

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
imagePrefix = 'scrolltech'
2+
credentialDocker = 'dockerhub'
3+
4+
def boolean test_result = false
5+
6+
pipeline {
7+
agent any
8+
options {
9+
timeout (20)
10+
}
11+
tools {
12+
go 'go-1.18'
13+
}
14+
environment {
15+
GO111MODULE = 'on'
16+
}
17+
stages {
18+
stage('Build') {
19+
when {
20+
anyOf { changeset "bridge/**"; changeset "build/**"; changeset "coordinator/**"; changeset "common/**"; changeset "database/**" }
21+
}
22+
steps {
23+
//start to build project
24+
sh '''#!/bin/bash
25+
export PATH=/home/ubuntu/go/bin:$PATH
26+
make -C bridge mock_abi
27+
make -C bridge bridge
28+
make -C bridge docker
29+
make -C coordinator coordinator
30+
make -C coordinator docker
31+
'''
32+
}
33+
}
34+
stage('Test') {
35+
when {
36+
anyOf { changeset "bridge/**"; changeset "build/**"; changeset "coordinator/**"; changeset "common/**"; changeset "database/**" }
37+
}
38+
steps {
39+
sh "docker ps -aq | xargs -r docker stop"
40+
sh "docker container prune -f"
41+
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
42+
sh '''
43+
cd ./bridge
44+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/database
45+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/database/migrate
46+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/database/docker
47+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/abi
48+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/l1
49+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/l2
50+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/sender
51+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/common/docker
52+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/coordinator
53+
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/coordinator/verifier
54+
cd ..
55+
'''
56+
script {
57+
for (i in ['bridge', 'coordinator', 'database']) {
58+
sh "cd $i && go test -v -race -coverprofile=coverage.txt -covermode=atomic \$(go list ./... | grep -v 'database\\|l2\\|l1\\|common\\|coordinator')"
59+
}
60+
}
61+
62+
script { test_result = true }
63+
}
64+
}
65+
}
66+
stage('Docker') {
67+
when {
68+
anyOf { changeset "bridge/**"; changeset "build/**"; changeset "coordinator/**"; changeset "common/**"; changeset "database/**" }
69+
}
70+
steps {
71+
withCredentials([usernamePassword(credentialsId: "${credentialDocker}", passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) {
72+
script {
73+
if (test_result == true) {
74+
sh 'docker login --username=${dockerUser} --password=${dockerPassword}'
75+
for (i in ['bridge', 'coordinator']) {
76+
sh "docker build -t ${imagePrefix}/$i:${GIT_COMMIT} -f $i/Dockerfile ."
77+
sh "docker tag ${imagePrefix}/$i:${GIT_COMMIT} ${imagePrefix}/$i:latest"
78+
sh "docker push ${imagePrefix}/$i:${GIT_COMMIT}"
79+
sh "docker push ${imagePrefix}/$i:latest"
80+
sh "docker rmi ${imagePrefix}/$i:${GIT_COMMIT}"
81+
sh "docker rmi ${imagePrefix}/$i:latest"
82+
}
83+
}
84+
}
85+
}
86+
}
87+
}
88+
}
89+
post {
90+
always {
91+
cleanWs()
92+
slackSend(message: "${JOB_BASE_NAME} ${GIT_COMMIT} #${BUILD_NUMBER} deploy ${currentBuild.result}")
93+
}
94+
}
95+
}

bridge/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build/bin
2+
.idea
3+
contracts

bridge/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Build bridge in a stock Go builder container
2+
FROM scrolltech/go-builder:1.18 as builder
3+
4+
COPY ./ /
5+
6+
RUN cd /bridge/cmd && go build -v -p 4 -o bridge
7+
8+
# Pull bridge into a second stage deploy alpine container
9+
FROM alpine:latest
10+
11+
COPY --from=builder /bridge/cmd /bin/
12+
13+
EXPOSE 8645
14+
ENTRYPOINT ["bridge"]

0 commit comments

Comments
 (0)