Skip to content

Commit 2fc7571

Browse files
feat: port cosmos patch to 1.16 (#7)
* Eric/add workflows (#5) * Add workflows * Don't change this * Merge patches onto upstream geth 1.15 (#4) * Merge patches onto upstream geth 1.15 * Fix test failures * Tests pass * Update go version in CI * Update go version in CI in all places * Problem: precompile address don't match (#6) Solution: - fix addresses and add validation rule * fix build * fix test --------- Co-authored-by: Eric Warehime <[email protected]>
1 parent dd1ebac commit 2fc7571

25 files changed

+1167
-120
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
7+
jobs:
8+
cleanup-runs:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: rokroskar/workflow-run-cleanup-action@master
12+
env:
13+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
14+
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
15+
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions/setup-go@v3
21+
with:
22+
go-version: 1.23
23+
check-latest: true
24+
- uses: technote-space/[email protected]
25+
id: git_diff
26+
with:
27+
PATTERNS: |
28+
**/**.go
29+
go.mod
30+
go.sum
31+
- run: |
32+
make build
33+
if: env.GIT_DIFF

.github/workflows/dependencies.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Dependency Review"
2+
on: pull_request
3+
4+
permissions:
5+
contents: read
6+
7+
jobs:
8+
dependency-review:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/setup-go@v3
12+
with:
13+
go-version: 1.23
14+
check-latest: true
15+
- name: "Checkout Repository"
16+
uses: actions/checkout@v3
17+
- uses: technote-space/[email protected]
18+
with:
19+
PATTERNS: |
20+
**/**.go
21+
go.mod
22+
go.sum
23+
- name: "Dependency Review"
24+
uses: actions/dependency-review-action@v3
25+
if: env.GIT_DIFF
26+
- name: "Go vulnerability check"
27+
run: make vulncheck
28+
if: env.GIT_DIFF

.github/workflows/lint.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Lint
2+
# Lint runs golangci-lint over the entire ethermint repository This workflow is
3+
# run on every pull request and push to main The `golangci` will pass without
4+
# running if no *.{go, mod, sum} files have been changed.
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- master
10+
jobs:
11+
golangci:
12+
name: Run golangci-lint
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
steps:
16+
# Required: setup-go, for all versions v3.0.0+ of golangci-lint
17+
- uses: actions/setup-go@v3
18+
with:
19+
go-version: 1.23
20+
check-latest: true
21+
- uses: actions/checkout@v3
22+
- uses: technote-space/[email protected]
23+
with:
24+
PATTERNS: |
25+
**/**.go
26+
go.mod
27+
go.sum
28+
- uses: golangci/[email protected]
29+
with:
30+
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
31+
version: latest
32+
args: --timeout 10m
33+
github-token: ${{ secrets.github_token }}
34+
# Check only if there are differences in the source code
35+
if: env.GIT_DIFF
36+
markdown-lint:
37+
name: Run markdown-lint
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 10
40+
steps:
41+
- uses: actions/checkout@v3
42+
- uses: technote-space/[email protected]
43+
with:
44+
PATTERNS: |
45+
docs/**/*.md
46+
x/**/*.md
47+
README.md
48+
- uses: nosborn/[email protected]
49+
with:
50+
files: .
51+
config_file: .markdownlint.yml
52+
ignore_path: .markdownlintignore
53+
# Check only if there are differences in the source code
54+
if: env.GIT_DIFF
55+
gomod2nix:
56+
name: Check gomod2nix.toml file is up to date
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/[email protected]
60+
- uses: cachix/install-nix-action@v18
61+
- uses: cachix/cachix-action@v12
62+
with:
63+
name: ethermint
64+
- uses: technote-space/[email protected]
65+
with:
66+
PATTERNS: |
67+
**/**.py
68+
- name: run gomod2nix
69+
run: |
70+
nix run -f ./nix gomod2nix
71+
git diff --no-ext-diff --exit-code
72+
if: env.GIT_DIFF

.github/workflows/markdown-links.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check Markdown links
2+
on:
3+
pull_request:
4+
paths:
5+
- '**.md'
6+
push:
7+
branches:
8+
- master
9+
paths:
10+
- '**.md'
11+
12+
jobs:
13+
markdown-link-check:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: technote-space/[email protected]
18+
id: git_diff
19+
with:
20+
PATTERNS: |
21+
**/**.md
22+
- uses: gaurav-nelson/github-action-markdown-link-check@master
23+
with:
24+
folder-path: "docs"
25+
check-modified-files-only: "yes"
26+
use-quiet-mode: "yes"
27+
base-branch: "main"
28+
config-file: "mlc_config.json"
29+
if: env.GIT_DIFF

.github/workflows/security.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Run Gosec
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
Gosec:
10+
permissions:
11+
security-events: write
12+
13+
runs-on: ubuntu-latest
14+
env:
15+
GO111MODULE: on
16+
steps:
17+
- name: Checkout Source
18+
uses: actions/checkout@v3
19+
- name: Get Diff
20+
uses: technote-space/[email protected]
21+
with:
22+
PATTERNS: |
23+
**/*.go
24+
go.mod
25+
go.sum
26+
- name: Run Gosec Security Scanner
27+
uses: cosmos/gosec@master
28+
with:
29+
# we let the report trigger content trigger a failure using the GitHub Security features.
30+
args: "-no-fail -fmt sarif -out results.sarif ./..."
31+
if: "env.GIT_DIFF_FILTERED != ''"
32+
- name: Upload SARIF file
33+
uses: github/codeql-action/upload-sarif@v2
34+
with:
35+
# Path to SARIF file relative to the root of the repository
36+
sarif_file: results.sarif
37+
if: "env.GIT_DIFF_FILTERED != ''"

.github/workflows/super-linter.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow executes several linters on changed files based on languages used in your code base whenever
2+
# you push a code or open a pull request.
3+
#
4+
# You can adjust the behavior by modifying this file.
5+
# For more information, see:
6+
# https://github.com/github/super-linter
7+
---
8+
name: Lint Code Base
9+
10+
on:
11+
push:
12+
branches: ["master"]
13+
pull_request:
14+
branches: ["master"]
15+
jobs:
16+
run-lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
with:
22+
# Full git history is needed to get a proper list of changed files within `super-linter`
23+
fetch-depth: 0
24+
25+
- name: Lint Code Base
26+
uses: github/super-linter@v4
27+
env:
28+
LINTER_RULES_PATH: /
29+
YAML_CONFIG_FILE: .yamllint
30+
VALIDATE_ALL_CODEBASE: false
31+
MARKDOWN_CONFIG_FILE: .markdownlint.yml
32+
PROTOBUF_CONFIG_FILE: .protolint.yml
33+
VALIDATE_NATURAL_LANGUAGE: false
34+
VALIDATE_OPENAPI: false
35+
VALIDATE_JSCPD: false
36+
VALIDATE_GO: false
37+
DEFAULT_BRANCH: "master"
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
- release/**
8+
9+
jobs:
10+
cleanup-runs:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: rokroskar/workflow-run-cleanup-action@master
14+
env:
15+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
16+
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
17+
18+
test-all:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/setup-go@v3
22+
with:
23+
go-version: 1.23
24+
check-latest: true
25+
- uses: actions/checkout@v3
26+
- uses: technote-space/[email protected]
27+
with:
28+
PATTERNS: |
29+
**/**.go
30+
go.mod
31+
go.sum
32+
- name: Test and Create Coverage Report
33+
run: |
34+
make test all
35+
if: env.GIT_DIFF

core/state_transition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
486486
// Execute the preparatory steps for state transition which includes:
487487
// - prepare accessList(post-berlin)
488488
// - reset transient storage(eip 1153)
489-
st.state.Prepare(rules, msg.From, st.evm.Context.Coinbase, msg.To, vm.ActivePrecompiles(rules), msg.AccessList)
489+
st.state.Prepare(rules, msg.From, st.evm.Context.Coinbase, msg.To, st.evm.ActivePrecompiles(), msg.AccessList)
490490

491491
var (
492492
ret []byte

core/vm/contract.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ type Contract struct {
4242
IsDeployment bool
4343
IsSystemCall bool
4444

45-
Gas uint64
46-
value *uint256.Int
45+
Gas uint64
46+
value *uint256.Int
47+
isPrecompile bool
4748
}
4849

4950
// NewContract returns a new contract environment for the execution of EVM.
@@ -62,6 +63,10 @@ func NewContract(caller common.Address, address common.Address, value *uint256.I
6263
}
6364

6465
func (c *Contract) validJumpdest(dest *uint256.Int) bool {
66+
if c.isPrecompile {
67+
return false
68+
}
69+
6570
udest, overflow := dest.Uint64WithOverflow()
6671
// PC cannot go beyond len(code) and certainly can't be bigger than 63bits.
6772
// Don't bother checking for JUMPDEST in that case.
@@ -78,6 +83,10 @@ func (c *Contract) validJumpdest(dest *uint256.Int) bool {
7883
// isCode returns true if the provided PC location is an actual opcode, as
7984
// opposed to a data-segment following a PUSHN operation.
8085
func (c *Contract) isCode(udest uint64) bool {
86+
if c.isPrecompile {
87+
return false
88+
}
89+
8190
// Do we already have an analysis laying around?
8291
if c.analysis != nil {
8392
return c.analysis.codeSegment(udest)
@@ -160,6 +169,9 @@ func (c *Contract) Value() *uint256.Int {
160169

161170
// SetCallCode sets the code of the contract,
162171
func (c *Contract) SetCallCode(hash common.Hash, code []byte) {
172+
if c.isPrecompile {
173+
return
174+
}
163175
c.Code = code
164176
c.CodeHash = hash
165177
}

0 commit comments

Comments
 (0)