Skip to content

Commit

Permalink
Merge pull request #593 from etclabscore/merge/foundation-release/1.13.5
Browse files Browse the repository at this point in the history
Merge/foundation release/1.13.5
  • Loading branch information
meowsbits authored Mar 11, 2024
2 parents aed6b58 + c70ec83 commit 0e5f9f6
Show file tree
Hide file tree
Showing 576 changed files with 20,577 additions and 19,576 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/audit-bootnodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'
id: go

- name: Check out code into the Go module directory
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/bench-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.16
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -36,9 +36,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.16
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -64,9 +64,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.16
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/bench-trie.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -36,9 +36,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -64,9 +64,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/bench-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -38,9 +38,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down Expand Up @@ -70,9 +70,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/evmc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'
id: go

- name: Check out code into the Go module directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-generate-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
steps:
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
- name: Checkout etclabscore/core-geth
uses: actions/checkout@v3

- name: Set up Go 1.19
- name: Set up Go 1.x
if: ${{ matrix.BUILD_OS_NAME != 'arm' }}
id: go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- name: Cache lookup (Linux/ARM)
uses: actions/cache@v3
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: '1.20'

- uses: actions/checkout@v2
with:
Expand All @@ -34,11 +34,11 @@ jobs:
name: Tests-CoreGeth
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- uses: actions/checkout@v2
with:
Expand All @@ -51,11 +51,11 @@ jobs:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ^1.19
go-version: '1.20'

- uses: actions/checkout@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ profile.cov
**/yarn-error.log
logs/

tests/spec-tests/


# Generated by tests, and will persist if tests are interrupted.
les/transactions.rlp

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=""
ARG BUILDNUM=""

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

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

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

GOBIN = ./build/bin
GO ?= latest
GORUN = env GO111MODULE=on go run
GORUN = go run
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

geth:
Expand Down Expand Up @@ -95,7 +95,7 @@ lint: ## Run linters.
$(GORUN) build/ci.go lint

clean: clean-evmc
env GO111MODULE=on go clean -cache
go clean -cache
rm -fr build/_workspace/pkg/ $(GOBIN)/*

mkdocs-serve: ## Serve generated documentation (during development)
Expand Down
66 changes: 54 additions & 12 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"io"
"math/big"

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

// panicSelector is a special function selector for panic reason unpacking.
var panicSelector = crypto.Keccak256([]byte("Panic(uint256)"))[:4]

// panicReasons map is for readable panic codes
// see this linkage for the deails
// https://docs.soliditylang.org/en/v0.8.21/control-structures.html#panic-via-assert-and-error-via-require
// the reason string list is copied from ether.js
// https://github.com/ethers-io/ethers.js/blob/fa3a883ff7c88611ce766f58bdd4b8ac90814470/src.ts/abi/interface.ts#L207-L218
var panicReasons = map[uint64]string{
0x00: "generic panic",
0x01: "assert(false)",
0x11: "arithmetic underflow or overflow",
0x12: "division or modulo by zero",
0x21: "enum overflow",
0x22: "invalid encoded storage byte array accessed",
0x31: "out-of-bounds array access; popping on an empty array",
0x32: "out-of-bounds access of an array or bytesN",
0x41: "out of memory",
0x51: "uninitialized function",
}

// UnpackRevert resolves the abi-encoded revert reason. According to the solidity
// spec https://solidity.readthedocs.io/en/latest/control-structures.html#revert,
// the provided revert reason is abi-encoded as if it were a call to a function
// `Error(string)`. So it's a special tool for it.
// the provided revert reason is abi-encoded as if it were a call to function
// `Error(string)` or `Panic(uint256)`. So it's a special tool for it.
func UnpackRevert(data []byte) (string, error) {
if len(data) < 4 {
return "", errors.New("invalid data for unpacking")
}
if !bytes.Equal(data[:4], revertSelector) {
switch {
case bytes.Equal(data[:4], revertSelector):
typ, err := NewType("string", "", nil)
if err != nil {
return "", err
}
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
if err != nil {
return "", err
}
return unpacked[0].(string), nil
case bytes.Equal(data[:4], panicSelector):
typ, err := NewType("uint256", "", nil)
if err != nil {
return "", err
}
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
if err != nil {
return "", err
}
pCode := unpacked[0].(*big.Int)
// uint64 safety check for future
// but the code is not bigger than MAX(uint64) now
if pCode.IsUint64() {
if reason, ok := panicReasons[pCode.Uint64()]; ok {
return reason, nil
}
}
return fmt.Sprintf("unknown panic code: %#x", pCode), nil
default:
return "", errors.New("invalid data for unpacking")
}
typ, err := NewType("string", "", nil)
if err != nil {
return "", err
}
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
if err != nil {
return "", err
}
return unpacked[0].(string), nil
}
2 changes: 2 additions & 0 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,8 @@ func TestUnpackRevert(t *testing.T) {
{"", "", errors.New("invalid data for unpacking")},
{"08c379a1", "", errors.New("invalid data for unpacking")},
{"08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d72657665727420726561736f6e00000000000000000000000000000000000000", "revert reason", nil},
{"4e487b710000000000000000000000000000000000000000000000000000000000000000", "generic panic", nil},
{"4e487b7100000000000000000000000000000000000000000000000000000000000000ff", "unknown panic code: 0xff", nil},
}
for index, c := range cases {
t.Run(fmt.Sprintf("case %d", index), func(t *testing.T) {
Expand Down
15 changes: 15 additions & 0 deletions accounts/abi/bind/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ var (
// on a backend that doesn't implement PendingContractCaller.
ErrNoPendingState = errors.New("backend does not support pending state")

// ErrNoBlockHashState is raised when attempting to perform a block hash action
// on a backend that doesn't implement BlockHashContractCaller.
ErrNoBlockHashState = errors.New("backend does not support block hash state")

// ErrNoCodeAfterDeploy is returned by WaitDeployed if contract creation leaves
// an empty contract behind.
ErrNoCodeAfterDeploy = errors.New("no contract code after deployment")
Expand Down Expand Up @@ -64,6 +68,17 @@ type PendingContractCaller interface {
PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)
}

// BlockHashContractCaller defines methods to perform contract calls on a specific block hash.
// Call will try to discover this interface when access to a block by hash is requested.
// If the backend does not support the block hash state, Call returns ErrNoBlockHashState.
type BlockHashContractCaller interface {
// CodeAtHash returns the code of the given account in the state at the specified block hash.
CodeAtHash(ctx context.Context, contract common.Address, blockHash common.Hash) ([]byte, error)

// CallContractAtHash executes an Ethereum contract all against the state at the specified block hash.
CallContractAtHash(ctx context.Context, call ethereum.CallMsg, blockHash common.Hash) ([]byte, error)
}

// ContractTransactor defines the methods needed to allow operating with a contract
// on a write only basis. Besides the transacting method, the remainder are helpers
// used when the user does not provide some needed values, but rather leaves it up
Expand Down
Loading

0 comments on commit 0e5f9f6

Please sign in to comment.