Skip to content

Commit dafd3d8

Browse files
authored
Merge pull request #182 from covalenthq/develop
Bsp-geth-DTM-RC:v1.6.0
2 parents a18a2bd + 2d2607f commit dafd3d8

File tree

770 files changed

+49299
-51697
lines changed

Some content is hidden

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

770 files changed

+49299
-51697
lines changed

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@v2
2020
with:
21-
go-version: 1.19
21+
go-version: 1.21.4
2222

2323
- name: Checkout code
2424
uses: actions/checkout@v2

.github/workflows/go.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: i386 linux tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: self-hosted
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: 1.21.4
19+
- name: Run tests
20+
run: go test ./...
21+
env:
22+
GOOS: linux
23+
GOARCH: 386

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828

2929
- name: Lint
3030
run: |
31-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2
32-
./bin/golangci-lint run
31+
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2
32+
# ./bin/golangci-lint run
3333
3434
# Optional: working directory, useful for monorepos
3535
# working-directory: somedir

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ scripts/
5555
logs/
5656
coverage.out
5757
coverage.txt
58-
logs/
58+
tests/spec-tests/

.golangci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ run:
1212
linters:
1313
disable-all: true
1414
enable:
15-
- goconst
1615
- goimports
1716
- gosimple
1817
- govet
@@ -39,9 +38,6 @@ linters:
3938
linters-settings:
4039
gofmt:
4140
simplify: true
42-
goconst:
43-
min-len: 3 # minimum length of string constant
44-
min-occurrences: 6 # minimum number of occurrences
4541

4642
issues:
4743
exclude-rules:

.travis.yml

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,14 @@ jobs:
99
- azure-osx
1010

1111
include:
12-
# This builder only tests code linters on latest version of Go
13-
- stage: lint
14-
os: linux
15-
dist: bionic
16-
go: 1.20.x
17-
env:
18-
- lint
19-
git:
20-
submodules: false # avoid cloning ethereum/tests
21-
script:
22-
- go run build/ci.go lint
23-
2412
# These builders create the Docker sub-images for multi-arch push and each
2513
# will attempt to push the multi-arch image if they are the last builder
2614
- stage: build
2715
if: type = push
2816
os: linux
2917
arch: amd64
3018
dist: bionic
31-
go: 1.20.x
19+
go: 1.21.x
3220
env:
3321
- docker
3422
services:
@@ -45,7 +33,7 @@ jobs:
4533
os: linux
4634
arch: arm64
4735
dist: bionic
48-
go: 1.20.x
36+
go: 1.21.x
4937
env:
5038
- docker
5139
services:
@@ -63,10 +51,9 @@ jobs:
6351
os: linux
6452
dist: bionic
6553
sudo: required
66-
go: 1.20.x
54+
go: 1.21.x
6755
env:
6856
- azure-linux
69-
- GO111MODULE=on
7057
git:
7158
submodules: false # avoid cloning ethereum/tests
7259
addons:
@@ -97,56 +84,51 @@ jobs:
9784
- stage: build
9885
if: type = push
9986
os: osx
100-
go: 1.20.x
87+
osx_image: xcode14.2
88+
go: 1.21.x
10189
env:
10290
- azure-osx
103-
- GO111MODULE=on
10491
git:
10592
submodules: false # avoid cloning ethereum/tests
10693
script:
10794
- go run build/ci.go install -dlgo
10895
- go run build/ci.go archive -type tar -signer OSX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
96+
- go run build/ci.go install -dlgo -arch arm64
97+
- go run build/ci.go archive -arch arm64 -type tar -signer OSX_SIGNING_KEY -signify SIGNIFY_KEY -upload gethstore/builds
10998

11099
# These builders run the tests
111100
- stage: build
112101
os: linux
113102
arch: amd64
114103
dist: bionic
115-
go: 1.20.x
116-
env:
117-
- GO111MODULE=on
104+
go: 1.21.x
118105
script:
119-
- go run build/ci.go test $TEST_PACKAGES
106+
- travis_wait 30 go run build/ci.go test $TEST_PACKAGES
120107

121108
- stage: build
122109
if: type = pull_request
123110
os: linux
124111
arch: arm64
125112
dist: bionic
126-
go: 1.19.x
127-
env:
128-
- GO111MODULE=on
113+
go: 1.20.x
129114
script:
130-
- go run build/ci.go test $TEST_PACKAGES
115+
- travis_wait 30 go run build/ci.go test $TEST_PACKAGES
131116

132117
- stage: build
133118
os: linux
134119
dist: bionic
135-
go: 1.19.x
136-
env:
137-
- GO111MODULE=on
120+
go: 1.20.x
138121
script:
139-
- go run build/ci.go test $TEST_PACKAGES
122+
- travis_wait 30 go run build/ci.go test $TEST_PACKAGES
140123

141124
# This builder does the Ubuntu PPA nightly uploads
142125
- stage: build
143126
if: type = cron || (type = push && tag ~= /^v[0-9]/)
144127
os: linux
145128
dist: bionic
146-
go: 1.20.x
129+
go: 1.21.x
147130
env:
148131
- ubuntu-ppa
149-
- GO111MODULE=on
150132
git:
151133
submodules: false # avoid cloning ethereum/tests
152134
addons:
@@ -167,10 +149,9 @@ jobs:
167149
if: type = cron
168150
os: linux
169151
dist: bionic
170-
go: 1.20.x
152+
go: 1.21.x
171153
env:
172154
- azure-purge
173-
- GO111MODULE=on
174155
git:
175156
submodules: false # avoid cloning ethereum/tests
176157
script:
@@ -181,8 +162,7 @@ jobs:
181162
if: type = cron
182163
os: linux
183164
dist: bionic
184-
go: 1.20.x
185-
env:
186-
- GO111MODULE=on
165+
go: 1.21.x
187166
script:
188-
- go run build/ci.go test -race -coverage $TEST_PACKAGES
167+
- travis_wait 30 go run build/ci.go test -race $TEST_PACKAGES
168+

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG USER=$USER
66

77

88
# Build Geth in a stock Go builder container
9-
FROM golang:1.20-alpine as builder
9+
FROM golang:1.21-alpine as builder
1010

1111
RUN apk add --no-cache gcc musl-dev linux-headers git
1212

Dockerfile.alltools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG VERSION=""
44
ARG BUILDNUM=""
55

66
# Build Geth in a stock Go builder container
7-
FROM golang:1.20-alpine as builder
7+
FROM golang:1.21-alpine as builder
88

99
RUN apk add --no-cache gcc musl-dev linux-headers git
1010

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
GOBIN = ./build/bin
88
GO ?= latest
9-
GORUN = env GO111MODULE=on go run
10-
U = $(USER)
9+
GORUN = go run
1110

1211
geth:
1312
$(GORUN) build/ci.go install ./cmd/geth
@@ -24,7 +23,7 @@ lint: ## Run linters.
2423
$(GORUN) build/ci.go lint
2524

2625
clean:
27-
env GO111MODULE=on go clean -cache
26+
go clean -cache
2827
rm -fr build/_workspace/pkg/ $(GOBIN)/*
2928

3029
run-geth-bsp:

accounts/abi/abi.go

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"errors"
2323
"fmt"
2424
"io"
25+
"math/big"
2526

2627
"github.com/ethereum/go-ethereum/common"
2728
"github.com/ethereum/go-ethereum/crypto"
@@ -246,24 +247,65 @@ func (abi *ABI) HasReceive() bool {
246247
// revertSelector is a special function selector for revert reason unpacking.
247248
var revertSelector = crypto.Keccak256([]byte("Error(string)"))[:4]
248249

250+
// panicSelector is a special function selector for panic reason unpacking.
251+
var panicSelector = crypto.Keccak256([]byte("Panic(uint256)"))[:4]
252+
253+
// panicReasons map is for readable panic codes
254+
// see this linkage for the details
255+
// https://docs.soliditylang.org/en/v0.8.21/control-structures.html#panic-via-assert-and-error-via-require
256+
// the reason string list is copied from ether.js
257+
// https://github.com/ethers-io/ethers.js/blob/fa3a883ff7c88611ce766f58bdd4b8ac90814470/src.ts/abi/interface.ts#L207-L218
258+
var panicReasons = map[uint64]string{
259+
0x00: "generic panic",
260+
0x01: "assert(false)",
261+
0x11: "arithmetic underflow or overflow",
262+
0x12: "division or modulo by zero",
263+
0x21: "enum overflow",
264+
0x22: "invalid encoded storage byte array accessed",
265+
0x31: "out-of-bounds array access; popping on an empty array",
266+
0x32: "out-of-bounds access of an array or bytesN",
267+
0x41: "out of memory",
268+
0x51: "uninitialized function",
269+
}
270+
249271
// UnpackRevert resolves the abi-encoded revert reason. According to the solidity
250272
// spec https://solidity.readthedocs.io/en/latest/control-structures.html#revert,
251-
// the provided revert reason is abi-encoded as if it were a call to a function
252-
// `Error(string)`. So it's a special tool for it.
273+
// the provided revert reason is abi-encoded as if it were a call to function
274+
// `Error(string)` or `Panic(uint256)`. So it's a special tool for it.
253275
func UnpackRevert(data []byte) (string, error) {
254276
if len(data) < 4 {
255277
return "", errors.New("invalid data for unpacking")
256278
}
257-
if !bytes.Equal(data[:4], revertSelector) {
279+
switch {
280+
case bytes.Equal(data[:4], revertSelector):
281+
typ, err := NewType("string", "", nil)
282+
if err != nil {
283+
return "", err
284+
}
285+
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
286+
if err != nil {
287+
return "", err
288+
}
289+
return unpacked[0].(string), nil
290+
case bytes.Equal(data[:4], panicSelector):
291+
typ, err := NewType("uint256", "", nil)
292+
if err != nil {
293+
return "", err
294+
}
295+
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
296+
if err != nil {
297+
return "", err
298+
}
299+
pCode := unpacked[0].(*big.Int)
300+
// uint64 safety check for future
301+
// but the code is not bigger than MAX(uint64) now
302+
if pCode.IsUint64() {
303+
if reason, ok := panicReasons[pCode.Uint64()]; ok {
304+
return reason, nil
305+
}
306+
}
307+
return fmt.Sprintf("unknown panic code: %#x", pCode), nil
308+
default:
258309
return "", errors.New("invalid data for unpacking")
259310
}
260-
typ, err := NewType("string", "", nil)
261-
if err != nil {
262-
return "", err
263-
}
264-
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
265-
if err != nil {
266-
return "", err
267-
}
268-
return unpacked[0].(string), nil
269311
}

0 commit comments

Comments
 (0)