Skip to content

Commit 0710425

Browse files
authored
Merge pull request #112 from mantlenetworkio/mantle-pectra
Mantle Pectra Upgrade
2 parents 36b2371 + 1710eea commit 0710425

File tree

173 files changed

+17843
-488
lines changed

Some content is hidden

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

173 files changed

+17843
-488
lines changed

.circleci/check-releases.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
LATEST_RELEASE=$(curl -s --fail -L \
5+
-H "Accept: application/vnd.github+json" \
6+
-H "X-GitHub-Api-Version: 2022-11-28" \
7+
https://api.github.com/repos/ethereum/go-ethereum/releases \
8+
| jq -r '(.[] | select(.draft==false) | select(.prerelease==false)).tag_name' | head -n 1)
9+
10+
echo "Detected latest go-ethereum release as ${LATEST_RELEASE}"
11+
12+
git remote add upstream https://github.com/ethereum/go-ethereum
13+
git fetch upstream > /dev/null
14+
15+
if git branch --contains "${LATEST_RELEASE}" 2>&1 | grep -e '^[ *]*optimism$' > /dev/null
16+
then
17+
echo "Up to date with latest release. Great job! 🎉"
18+
else
19+
echo "Release has not been merged"
20+
exit 1
21+
fi
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
DOCKER_REPO=$1
6+
GIT_TAG=$2
7+
GIT_SHA=$3
8+
9+
IMAGE_NAME="op-geth"
10+
IMAGE_TAG=$GIT_TAG
11+
12+
SOURCE_IMAGE_TAG="$DOCKER_REPO/$IMAGE_NAME:$GIT_SHA"
13+
TARGET_IMAGE_TAG="$DOCKER_REPO/$IMAGE_NAME:$IMAGE_TAG"
14+
TARGET_IMAGE_TAG_LATEST="$DOCKER_REPO/$IMAGE_NAME:latest"
15+
16+
echo "Checking if docker images exist for '$IMAGE_NAME'"
17+
echo ""
18+
tags=$(gcloud container images list-tags "$DOCKER_REPO/$IMAGE_NAME" --limit 1 --format json)
19+
if [ "$tags" = "[]" ]; then
20+
echo "No existing docker images were found for '$IMAGE_NAME'. The code tagged with '$GIT_TAG' may not have an associated dockerfile or docker build job."
21+
echo "If this service has a dockerfile, add a docker-publish job for it in the circleci config."
22+
echo ""
23+
echo "Exiting"
24+
exit 0
25+
fi
26+
27+
echo "Tagging $SOURCE_IMAGE_TAG with '$IMAGE_TAG'"
28+
gcloud container images add-tag -q "$SOURCE_IMAGE_TAG" "$TARGET_IMAGE_TAG"
29+
30+
# Do not tag with latest if the release is a release candidate.
31+
if [[ "$IMAGE_TAG" == *"rc"* ]]; then
32+
echo "Not tagging with 'latest' because the release is a release candidate."
33+
exit 0
34+
fi
35+
36+
echo "Tagging $SOURCE_IMAGE_TAG with 'latest'"
37+
gcloud container images add-tag -q "$SOURCE_IMAGE_TAG" "$TARGET_IMAGE_TAG_LATEST"

.circleci/config.yml

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
version: 2.1
2+
3+
orbs:
4+
gcp-cli: circleci/gcp-cli@3.0.1
5+
slack: circleci/slack@4.10.1
6+
7+
commands:
8+
gcp-oidc-authenticate:
9+
description: "Authenticate with GCP using a CircleCI OIDC token."
10+
parameters:
11+
project_id:
12+
type: env_var_name
13+
default: GCP_PROJECT_ID
14+
workload_identity_pool_id:
15+
type: env_var_name
16+
default: GCP_WIP_ID
17+
workload_identity_pool_provider_id:
18+
type: env_var_name
19+
default: GCP_WIP_PROVIDER_ID
20+
service_account_email:
21+
type: env_var_name
22+
default: GCP_SERVICE_ACCOUNT_EMAIL
23+
gcp_cred_config_file_path:
24+
type: string
25+
default: /home/circleci/gcp_cred_config.json
26+
oidc_token_file_path:
27+
type: string
28+
default: /home/circleci/oidc_token.json
29+
steps:
30+
- run:
31+
name: "Create OIDC credential configuration"
32+
command: |
33+
# Store OIDC token in temp file
34+
echo $CIRCLE_OIDC_TOKEN > << parameters.oidc_token_file_path >>
35+
# Create a credential configuration for the generated OIDC ID Token
36+
gcloud iam workload-identity-pools create-cred-config \
37+
"projects/${<< parameters.project_id >>}/locations/global/workloadIdentityPools/${<< parameters.workload_identity_pool_id >>}/providers/${<< parameters.workload_identity_pool_provider_id >>}"\
38+
--output-file="<< parameters.gcp_cred_config_file_path >>" \
39+
--service-account="${<< parameters.service_account_email >>}" \
40+
--credential-source-file=<< parameters.oidc_token_file_path >>
41+
- run:
42+
name: "Authenticate with GCP using OIDC"
43+
command: |
44+
# Configure gcloud to leverage the generated credential configuration
45+
gcloud auth login --brief --cred-file "<< parameters.gcp_cred_config_file_path >>"
46+
# Configure ADC
47+
echo "export GOOGLE_APPLICATION_CREDENTIALS='<< parameters.gcp_cred_config_file_path >>'" | tee -a "$BASH_ENV"
48+
jobs:
49+
docker-release:
50+
environment:
51+
DOCKER_BUILDKIT: 1
52+
parameters:
53+
docker_name:
54+
description: Docker image name
55+
type: string
56+
default: "op-geth"
57+
docker_tags:
58+
description: Docker image tags as csv
59+
type: string
60+
registry:
61+
description: Docker registry
62+
type: string
63+
default: "us-docker.pkg.dev"
64+
repo:
65+
description: Docker repo
66+
type: string
67+
default: "oplabs-tools-artifacts/images"
68+
push_tags:
69+
description: Push release push tags
70+
type: boolean
71+
default: false
72+
machine:
73+
image: ubuntu-2204:2022.07.1
74+
resource_class: xlarge
75+
steps:
76+
- gcp-cli/install
77+
- gcp-oidc-authenticate
78+
- checkout
79+
- run:
80+
name: Configure Docker
81+
command: |
82+
gcloud auth configure-docker <<parameters.registry>>
83+
- run:
84+
name: Build and push
85+
command: |
86+
RAW_TAGS="<<parameters.docker_tags>>"
87+
if [ "$CIRCLE_BRANCH" = "optimism" ]; then
88+
RAW_TAGS="$RAW_TAGS,optimism"
89+
fi
90+
IMAGE_BASE="<<parameters.registry>>/<<parameters.repo>>/<<parameters.docker_name>>"
91+
DOCKER_TAGS=$(echo -ne "$RAW_TAGS" | sed "s/,/\n/g" | sed "s/[^a-zA-Z0-9\n.]/-/g" | sed -e "s|^|-t ${IMAGE_BASE}:|")
92+
docker context create buildx-build
93+
docker buildx create --use buildx-build
94+
docker buildx build --push \
95+
$(echo -ne $DOCKER_TAGS | tr '\n' ' ') \
96+
--platform=linux/arm64,linux/amd64 \
97+
--build-arg VERSION=$CIRCLE_TAG \
98+
--build-arg COMMIT=$CIRCLE_SHA \
99+
--build-arg BUILDNUM=$CIRCLE_BUILD_NUM \
100+
--progress plain \
101+
-f Dockerfile .
102+
- when:
103+
condition:
104+
equal: [ true, <<parameters.push_tags>> ]
105+
steps:
106+
- run:
107+
name: Tag
108+
command: |
109+
./.circleci/ci-docker-tag-op-geth-release.sh <<parameters.registry>>/<<parameters.repo>> $CIRCLE_TAG $CIRCLE_SHA1
110+
build-geth:
111+
docker:
112+
- image: cimg/go:1.19
113+
resource_class: xlarge
114+
steps:
115+
- checkout
116+
- run:
117+
command: go run build/ci.go install
118+
unit-test:
119+
resource_class: xlarge
120+
docker:
121+
- image: cimg/go:1.19
122+
steps:
123+
- checkout
124+
- run:
125+
command: go run build/ci.go test
126+
lint-geth:
127+
resource_class: medium
128+
docker:
129+
- image: cimg/go:1.19
130+
steps:
131+
- checkout
132+
- run:
133+
command: go run build/ci.go lint
134+
check-releases:
135+
docker:
136+
- image: cimg/go:1.19
137+
steps:
138+
- checkout
139+
- run:
140+
command: .circleci/check-releases.sh
141+
- slack/notify:
142+
channel: C03N11M0BBN
143+
branch_pattern: optimism
144+
event: fail
145+
template: basic_fail_1
146+
147+
148+
workflows:
149+
main:
150+
jobs:
151+
- build-geth:
152+
name: Build geth
153+
- unit-test:
154+
name: Run unit tests for geth
155+
- lint-geth:
156+
name: Run linter over geth
157+
- docker-release:
158+
name: Push to Docker
159+
docker_tags: <<pipeline.git.revision>>
160+
context:
161+
- oplabs-gcr
162+
release:
163+
jobs:
164+
- hold:
165+
type: approval
166+
filters:
167+
tags:
168+
only: /^v.*/
169+
branches:
170+
ignore: /.*/
171+
- docker-release:
172+
name: Push to Docker (release)
173+
filters:
174+
tags:
175+
only: /^v.*/
176+
branches:
177+
ignore: /.*/
178+
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.tag>>
179+
push_tags: true
180+
context:
181+
- oplabs-gcr-release
182+
requires:
183+
- hold
184+
scheduled:
185+
triggers:
186+
- schedule:
187+
# run daily
188+
cron: "0 0 * * *"
189+
filters:
190+
branches:
191+
only: [ "optimism" ]
192+
jobs:
193+
- check-releases:
194+
name: Check for new upstream releases
195+
context: slack
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check Docker Build
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- develop
7+
- 'release/**'
8+
paths:
9+
- '**'
10+
jobs:
11+
CheckDockerBuild:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@main
16+
with:
17+
submodules: recursive
18+
token: ${{ secrets.PAT }}
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
- name: Checking Docker Build
22+
run: |
23+
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
24+
response=$(curl -H 'authorization: Bearer ${{ secrets.PAT }}' -H "Accept: application/vnd.github.v3+json" -s -X GET -G $URL)
25+
UPDATEFILE_DIR=$(echo "${response}" | jq -r '.[] | .filename')
26+
echo $UPDATEFILE_DIR
27+
cmd="docker build -f Dockerfile -t test:v1 ."
28+
echo -e "\e[32m$cmd\e[0m"
29+
$cmd
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check Make Build
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- develop
7+
- 'release/**'
8+
paths:
9+
- '**'
10+
jobs:
11+
CheckMakeBuild:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@main
16+
with:
17+
submodules: recursive
18+
token: ${{ secrets.PAT }}
19+
- name: Setup Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version: '1.20'
23+
- name: Checking Make Build
24+
run: |
25+
sudo apt update
26+
sudo apt install -y build-essential coreutils libuv1 libudev-dev libusb-1.0-0-dev
27+
make geth

.github/workflows/pages.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build and publish forkdiff github-pages
2+
permissions:
3+
contents: write
4+
on:
5+
push:
6+
branches:
7+
- optimism
8+
jobs:
9+
deploy:
10+
concurrency: ci-${{ github.ref }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 1000 # make sure to fetch the old commit we diff against
17+
18+
- name: Build forkdiff
19+
uses: "docker://protolambda/forkdiff:latest"
20+
with:
21+
args: -repo=/github/workspace -fork=/github/workspace/fork.yaml -out=/github/workspace/index.html
22+
23+
- name: Build pages
24+
run: |
25+
mkdir -p tmp/pages
26+
mv index.html tmp/pages/index.html
27+
touch tmp/pages/.nojekyll
28+
if [ "$GITHUB_REPOSITORY" == "ethereum-optimism/op-geth" ]; then
29+
echo "op-geth.optimism.io" > tmp/pages/CNAME
30+
fi;
31+
- name: Deploy
32+
uses: JamesIves/github-pages-deploy-action@v4
33+
with:
34+
folder: tmp/pages
35+
clean: true

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
/geth*.zip.sig
3131
/geth*.zip.asc
3232

33+
vendor
3334

3435
# travis
3536
profile.tmp
@@ -55,4 +56,5 @@ cmd/ethkey/ethkey
5556
cmd/evm/evm
5657
cmd/geth/geth
5758
cmd/rlpdump/rlpdump
58-
cmd/workload/workload
59+
cmd/workload/workload
60+
cmd/geth/op_geth*

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
1919
# Pull Geth into a second stage deploy alpine container
2020
FROM alpine:latest
2121

22-
RUN apk add --no-cache ca-certificates
22+
RUN apk add --no-cache ca-certificates jq
2323
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
24+
COPY entrypoint.sh /app/entrypoint.sh
2425

2526
EXPOSE 8545 8546 30303 30303/udp
26-
ENTRYPOINT ["geth"]
27+
28+
WORKDIR /app
29+
30+
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"]
2731

2832
# Add some metadata labels to help programmatic image consumption
2933
ARG COMMIT=""

0 commit comments

Comments
 (0)