mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
Compare commits
9 commits
master
...
fusaka-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3168b3e56 | ||
|
|
9859e6d62a | ||
|
|
18e79fdd7e | ||
|
|
4a4dc08ab1 | ||
|
|
404baa9b27 | ||
|
|
b58f8b3a5f | ||
|
|
8ec1db1a4a | ||
|
|
a3f2cb14a2 | ||
|
|
e96f887e73 |
1072 changed files with 44692 additions and 124199 deletions
|
|
@ -4,7 +4,6 @@ on:
|
|||
- "master"
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
linux-intel:
|
||||
|
|
@ -122,30 +121,9 @@ jobs:
|
|||
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
|
||||
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
|
||||
|
||||
keeper:
|
||||
name: Keeper Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.24
|
||||
cache: false
|
||||
|
||||
- name: Install cross toolchain
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -yq --no-install-suggests --no-install-recommends install gcc-multilib
|
||||
|
||||
- name: Build (amd64)
|
||||
run: |
|
||||
go run build/ci.go keeper -dlgo
|
||||
|
||||
windows:
|
||||
name: Windows Build
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: "win-11"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
|
@ -155,49 +133,22 @@ jobs:
|
|||
go-version: 1.24
|
||||
cache: false
|
||||
|
||||
- name: Install cross toolchain
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -yq --no-install-suggests --no-install-recommends install \
|
||||
gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 nsis
|
||||
# Note: gcc.exe only works properly if the corresponding bin/ directory is
|
||||
# contained in PATH.
|
||||
|
||||
- name: "Build (amd64)"
|
||||
run: |
|
||||
go run build/ci.go install -dlgo -os windows -arch amd64 -cc x86_64-w64-mingw32-gcc
|
||||
|
||||
- name: "Create/upload archive (amd64)"
|
||||
run: |
|
||||
go run build/ci.go archive -os windows -arch amd64 -type zip -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||
go run build/ci.go install -dlgo -arch amd64 -cc %GETH_CC%
|
||||
env:
|
||||
WINDOWS_SIGNING_KEY: ${{ secrets.WINDOWS_SIGNING_KEY }}
|
||||
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
|
||||
|
||||
- name: "Create/upload NSIS installer (amd64)"
|
||||
run: |
|
||||
go run build/ci.go nsis -arch amd64 -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||
rm -f build/bin/*
|
||||
env:
|
||||
WINDOWS_SIGNING_KEY: ${{ secrets.WINDOWS_SIGNING_KEY }}
|
||||
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
|
||||
PATH: 'C:\msys64\mingw64\bin;C:\Program Files (x86)\NSIS\;%PATH%'
|
||||
GETH_CC: 'C:\msys64\mingw64\bin\gcc.exe'
|
||||
|
||||
- name: "Build (386)"
|
||||
run: |
|
||||
go run build/ci.go install -dlgo -os windows -arch 386 -cc i686-w64-mingw32-gcc
|
||||
|
||||
- name: "Create/upload archive (386)"
|
||||
run: |
|
||||
go run build/ci.go archive -os windows -arch 386 -type zip -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||
go run build/ci.go install -dlgo -arch 386 -cc %GETH_CC%
|
||||
env:
|
||||
WINDOWS_SIGNING_KEY: ${{ secrets.WINDOWS_SIGNING_KEY }}
|
||||
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
|
||||
|
||||
- name: "Create/upload NSIS installer (386)"
|
||||
run: |
|
||||
go run build/ci.go nsis -arch 386 -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||
rm -f build/bin/*
|
||||
env:
|
||||
WINDOWS_SIGNING_KEY: ${{ secrets.WINDOWS_SIGNING_KEY }}
|
||||
AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }}
|
||||
PATH: 'C:\msys64\mingw32\bin;C:\Program Files (x86)\NSIS\;%PATH%'
|
||||
GETH_CC: 'C:\msys64\mingw32\bin\gcc.exe'
|
||||
|
||||
docker:
|
||||
name: Docker Image
|
||||
|
|
|
|||
10
.github/CODEOWNERS
vendored
10
.github/CODEOWNERS
vendored
|
|
@ -10,22 +10,24 @@ beacon/merkle/ @zsfelfoldi
|
|||
beacon/types/ @zsfelfoldi @fjl
|
||||
beacon/params/ @zsfelfoldi @fjl
|
||||
cmd/evm/ @MariusVanDerWijden @lightclient
|
||||
cmd/keeper/ @gballet
|
||||
core/state/ @rjl493456442
|
||||
crypto/ @gballet @jwasinger @fjl
|
||||
core/ @rjl493456442
|
||||
eth/ @rjl493456442
|
||||
eth/catalyst/ @MariusVanDerWijden @lightclient @fjl @jwasinger
|
||||
eth/tracers/ @s1na
|
||||
ethclient/ @fjl
|
||||
ethdb/ @rjl493456442
|
||||
event/ @fjl
|
||||
trie/ @rjl493456442 @gballet
|
||||
trie/ @rjl493456442
|
||||
triedb/ @rjl493456442
|
||||
internal/ethapi/ @fjl @lightclient
|
||||
core/tracing/ @s1na
|
||||
graphql/ @s1na
|
||||
internal/ethapi/ @fjl @s1na @lightclient
|
||||
internal/era/ @lightclient
|
||||
miner/ @MariusVanDerWijden @fjl @rjl493456442
|
||||
node/ @fjl
|
||||
p2p/ @fjl @zsfelfoldi
|
||||
rlp/ @fjl
|
||||
params/ @fjl @gballet @rjl493456442 @zsfelfoldi
|
||||
params/ @fjl @karalabe @gballet @rjl493456442 @zsfelfoldi
|
||||
rpc/ @fjl
|
||||
|
|
|
|||
29
.github/workflows/freebsd.yml
vendored
29
.github/workflows/freebsd.yml
vendored
|
|
@ -1,29 +0,0 @@
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- freebsd-github-action
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: FreeBSD-build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Test in FreeBSD
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
release: "15.0"
|
||||
usesh: true
|
||||
prepare: |
|
||||
pkg install -y go
|
||||
run: |
|
||||
freebsd-version
|
||||
uname -a
|
||||
go version
|
||||
go run ./build/ci.go test -p 8
|
||||
121
.github/workflows/go.yml
vendored
121
.github/workflows/go.yml
vendored
|
|
@ -1,25 +1,18 @@
|
|||
name: i386 linux tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
# Free runner capacity by cancelling superseded PR runs.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: [self-hosted-ghr, size-s-x64]
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
# Cache build tools to avoid downloading them each time
|
||||
- uses: actions/cache@v4
|
||||
|
|
@ -30,7 +23,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.25
|
||||
go-version: 1.23.0
|
||||
cache: false
|
||||
|
||||
- name: Run linters
|
||||
|
|
@ -39,107 +32,17 @@ jobs:
|
|||
go run build/ci.go check_generate
|
||||
go run build/ci.go check_baddeps
|
||||
|
||||
keeper:
|
||||
name: Keeper Builds
|
||||
needs: test
|
||||
runs-on: [self-hosted-ghr, size-l-x64]
|
||||
build:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25'
|
||||
go-version: 1.24.0
|
||||
cache: false
|
||||
|
||||
- name: Build
|
||||
run: go run build/ci.go keeper
|
||||
|
||||
test-32bit:
|
||||
name: "32bit tests"
|
||||
needs: test
|
||||
runs-on: [self-hosted-ghr, size-l-x64]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25'
|
||||
cache: false
|
||||
|
||||
- name: Install cross toolchain
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -yq --no-install-suggests --no-install-recommends install gcc-multilib
|
||||
|
||||
- name: Build
|
||||
run: go run build/ci.go test -arch 386 -short -p 8
|
||||
|
||||
test:
|
||||
name: Test
|
||||
needs: lint
|
||||
runs-on: [self-hosted-ghr, size-l-x64]
|
||||
strategy:
|
||||
matrix:
|
||||
go:
|
||||
- '1.25'
|
||||
- '1.24'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
cache: false
|
||||
|
||||
- name: Run tests
|
||||
run: go run build/ci.go test -p 8
|
||||
|
||||
windows:
|
||||
name: Windows ${{ matrix.arch }}
|
||||
needs: lint
|
||||
runs-on: [self-hosted, windows, x64]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: amd64
|
||||
mingw: 'C:\msys64\mingw64'
|
||||
test: true
|
||||
- arch: '386'
|
||||
mingw: 'C:\msys64\mingw32'
|
||||
test: false
|
||||
run: go test -short ./...
|
||||
env:
|
||||
GETH_MINGW: ${{ matrix.mingw }}
|
||||
GETH_CC: ${{ matrix.mingw }}\bin\gcc.exe
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25'
|
||||
cache: false
|
||||
|
||||
- name: Build
|
||||
shell: cmd
|
||||
run: |
|
||||
set PATH=%GETH_MINGW%\bin;%PATH%
|
||||
go run build/ci.go install -arch ${{ matrix.arch }} -cc %GETH_CC%
|
||||
|
||||
- name: Run tests
|
||||
if: matrix.test
|
||||
shell: cmd
|
||||
run: |
|
||||
set PATH=%GETH_MINGW%\bin;%PATH%
|
||||
go run build/ci.go test -arch ${{ matrix.arch }} -cc %GETH_CC% -short -p 8
|
||||
GOOS: linux
|
||||
GOARCH: 386
|
||||
|
|
|
|||
83
.github/workflows/validate_pr.yml
vendored
83
.github/workflows/validate_pr.yml
vendored
|
|
@ -1,83 +0,0 @@
|
|||
name: PR Format Validation
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, edited, synchronize]
|
||||
|
||||
jobs:
|
||||
validate-pr:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check for Spam PR
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const prTitle = context.payload.pull_request.title;
|
||||
const spamRegex = /^(feat|chore|fix)(\(.*\))?\s*:/i;
|
||||
|
||||
if (spamRegex.test(prTitle)) {
|
||||
// Leave a comment explaining why
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
body: `## PR Closed as Spam
|
||||
|
||||
This PR was automatically closed because the title format \`feat:\`, \`fix:\`, or \`chore:\` is commonly associated with spam contributions.
|
||||
|
||||
If this is a legitimate contribution, please:
|
||||
1. Review our contribution guidelines
|
||||
2. Use the correct PR title format: \`directory, ...: description\`
|
||||
3. Open a new PR with the proper title format
|
||||
|
||||
Thank you for your understanding.`
|
||||
});
|
||||
|
||||
// Close the PR
|
||||
await github.rest.pulls.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.payload.pull_request.number,
|
||||
state: 'closed'
|
||||
});
|
||||
|
||||
core.setFailed('PR closed as spam due to suspicious title format');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('✅ PR passed spam check');
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check PR Title Format
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const prTitle = context.payload.pull_request.title;
|
||||
const titleRegex = /^([\w\s,{}/.]+): .+/;
|
||||
|
||||
if (!titleRegex.test(prTitle)) {
|
||||
core.setFailed(`PR title "${prTitle}" does not match required format: directory, ...: description`);
|
||||
return;
|
||||
}
|
||||
|
||||
const match = prTitle.match(titleRegex);
|
||||
const dirPart = match[1];
|
||||
const directories = dirPart.split(',').map(d => d.trim());
|
||||
const missingDirs = [];
|
||||
for (const dir of directories) {
|
||||
const fullPath = path.join(process.env.GITHUB_WORKSPACE, dir);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
missingDirs.push(dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (missingDirs.length > 0) {
|
||||
core.setFailed(`The following directories in the PR title do not exist: ${missingDirs.join(', ')}`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('✅ PR title format is valid');
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -56,4 +56,3 @@ cmd/evm/evm
|
|||
cmd/geth/geth
|
||||
cmd/rlpdump/rlpdump
|
||||
cmd/workload/workload
|
||||
cmd/keeper/keeper
|
||||
|
|
|
|||
3
.mailmap
3
.mailmap
|
|
@ -48,9 +48,6 @@ Bas van Kervel <bas@ethdev.com> <bas-vk@users.noreply.github.com>
|
|||
Boqin Qin <bobbqqin@bupt.edu.cn>
|
||||
Boqin Qin <bobbqqin@bupt.edu.cn> <Bobbqqin@gmail.com>
|
||||
|
||||
Bosul Mun <bsbs8645@snu.ac.kr>
|
||||
Bosul Mun <bsbs8645@snu.ac.kr> <bosul.mun@ethereum.org>
|
||||
|
||||
Casey Detrio <cdetrio@gmail.com>
|
||||
|
||||
Charlotte <tqpcharlie@proton.me>
|
||||
|
|
|
|||
102
AGENTS.md
102
AGENTS.md
|
|
@ -1,102 +0,0 @@
|
|||
# AGENTS
|
||||
|
||||
## Guidelines
|
||||
|
||||
- **Keep changes minimal and focused.** Only modify code directly related to the task at hand. Do not refactor unrelated code, rename existing variables or functions for style, or bundle unrelated fixes into the same commit or PR.
|
||||
- **Do not add, remove, or update dependencies** unless the task explicitly requires it.
|
||||
|
||||
## Pre-Commit Checklist
|
||||
|
||||
Before every commit, run **all** of the following checks and ensure they pass:
|
||||
|
||||
### 1. Formatting
|
||||
|
||||
Before committing, always run `gofmt` and `goimports` on all modified files:
|
||||
|
||||
```sh
|
||||
gofmt -w <modified files>
|
||||
goimports -w <modified files>
|
||||
```
|
||||
|
||||
### 2. Build All Commands
|
||||
|
||||
Verify that all tools compile successfully:
|
||||
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
This builds all executables under `cmd/`, including `keeper` which has special build requirements.
|
||||
|
||||
### 3. Tests
|
||||
|
||||
While iterating during development, use `-short` for faster feedback:
|
||||
|
||||
```sh
|
||||
go run ./build/ci.go test -short
|
||||
```
|
||||
|
||||
Before committing, run the full test suite **without** `-short` to ensure all tests pass, including the Ethereum execution-spec tests and all state/block test permutations:
|
||||
|
||||
```sh
|
||||
go run ./build/ci.go test
|
||||
```
|
||||
|
||||
### 4. Linting
|
||||
|
||||
```sh
|
||||
go run ./build/ci.go lint
|
||||
```
|
||||
|
||||
This runs additional style checks. Fix any issues before committing.
|
||||
|
||||
### 5. Generated Code
|
||||
|
||||
```sh
|
||||
go run ./build/ci.go check_generate
|
||||
```
|
||||
|
||||
Ensures that all generated files (e.g., `gen_*.go`) are up to date. If this fails, first install the required code generators by running `make devtools`, then run the appropriate `go generate` commands and include the updated files in your commit.
|
||||
|
||||
### 6. Dependency Hygiene
|
||||
|
||||
```sh
|
||||
go run ./build/ci.go check_baddeps
|
||||
```
|
||||
|
||||
Verifies that no forbidden dependencies have been introduced.
|
||||
|
||||
## What to include in commits
|
||||
|
||||
Do not commit binaries, whether they are produced by the main build or byproducts of investigations.
|
||||
|
||||
## Commit Message Format
|
||||
|
||||
Commit messages must be prefixed with the package(s) they modify, followed by a short lowercase description:
|
||||
|
||||
```
|
||||
<package(s)>: description
|
||||
```
|
||||
|
||||
Examples:
|
||||
- `core/vm: fix stack overflow in PUSH instruction`
|
||||
- `eth, rpc: make trace configs optional`
|
||||
- `cmd/geth: add new flag for sync mode`
|
||||
|
||||
Use comma-separated package names when multiple areas are affected. Keep the description concise.
|
||||
|
||||
## Pull Request Title Format
|
||||
|
||||
PR titles follow the same convention as commit messages:
|
||||
|
||||
```
|
||||
<list of modified paths>: description
|
||||
```
|
||||
|
||||
Examples:
|
||||
- `core/vm: fix stack overflow in PUSH instruction`
|
||||
- `core, eth: add arena allocator support`
|
||||
- `cmd/geth, internal/ethapi: refactor transaction args`
|
||||
- `trie/archiver: streaming subtree archival to fix OOM`
|
||||
|
||||
Use the top-level package paths, comma-separated if multiple areas are affected. Only mention the directories with functional changes, interface changes that trickle all over the codebase should not generate an exhaustive list. The description should be a short, lowercase summary of the change.
|
||||
|
|
@ -4,7 +4,7 @@ ARG VERSION=""
|
|||
ARG BUILDNUM=""
|
||||
|
||||
# Build Geth in a stock Go builder container
|
||||
FROM golang:1.26-alpine AS builder
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ ARG VERSION=""
|
|||
ARG BUILDNUM=""
|
||||
|
||||
# Build Geth in a stock Go builder container
|
||||
FROM golang:1.26-alpine AS builder
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ https://pkg.go.dev/badge/github.com/ethereum/go-ethereum
|
|||
[](https://goreportcard.com/report/github.com/ethereum/go-ethereum)
|
||||
[](https://app.travis-ci.com/github/ethereum/go-ethereum)
|
||||
[](https://discord.gg/nthXNEv)
|
||||
[](https://x.com/go_ethereum)
|
||||
|
||||
Automated builds are available for stable releases and the unstable master branch. Binary
|
||||
archives are published at https://geth.ethereum.org/downloads/.
|
||||
|
|
@ -38,6 +37,7 @@ directory.
|
|||
| Command | Description |
|
||||
| :--------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI page](https://geth.ethereum.org/docs/fundamentals/command-line-options) for command line options. |
|
||||
| `clef` | Stand-alone signing tool, which can be used as a backend signer for `geth`. |
|
||||
| `devp2p` | Utilities to interact with nodes on the networking layer, without running a full blockchain. |
|
||||
| `abigen` | Source code generator to convert Ethereum contract definitions into easy-to-use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://docs.soliditylang.org/en/develop/abi-spec.html) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://geth.ethereum.org/docs/developers/dapp-developer/native-bindings) page for details. |
|
||||
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug run`). |
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ Audit reports are published in the `docs` folder: https://github.com/ethereum/go
|
|||
| Scope | Date | Report Link |
|
||||
| ------- | ------- | ----------- |
|
||||
| `geth` | 20170425 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2017-04-25_Geth-audit_Truesec.pdf) |
|
||||
| `clef` | 20180914 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2018-09-14_Clef-audit_NCC.pdf) |
|
||||
| `Discv5` | 20191015 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2019-10-15_Discv5_audit_LeastAuthority.pdf) |
|
||||
| `Discv5` | 20200124 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2020-01-24_DiscV5_audit_Cure53.pdf) |
|
||||
|
||||
|
|
@ -20,6 +21,7 @@ Audit reports are published in the `docs` folder: https://github.com/ethereum/go
|
|||
|
||||
To find out how to disclose a vulnerability in Ethereum visit [https://bounty.ethereum.org](https://bounty.ethereum.org) or email bounty@ethereum.org. Please read the [disclosure page](https://github.com/ethereum/go-ethereum/security/advisories?state=published) for more information about publicly disclosed security vulnerabilities.
|
||||
|
||||
Use the built-in `geth version-check` feature to check whether the software is affected by any known vulnerability. This command will fetch the latest [`vulnerabilities.json`](https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json) file which contains known security vulnerabilities concerning `geth`, and cross-check the data against its own version number.
|
||||
|
||||
The following key may be used to communicate sensitive information to developers.
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/log"
|
||||
)
|
||||
|
||||
var (
|
||||
intRegex = regexp.MustCompile(`(u)?int([0-9]*)`)
|
||||
)
|
||||
|
||||
func isKeyWord(arg string) bool {
|
||||
switch arg {
|
||||
case "break":
|
||||
|
|
@ -303,7 +299,7 @@ func bindBasicType(kind abi.Type) string {
|
|||
case abi.AddressTy:
|
||||
return "common.Address"
|
||||
case abi.IntTy, abi.UintTy:
|
||||
parts := intRegex.FindStringSubmatch(kind.String())
|
||||
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(kind.String())
|
||||
switch parts[2] {
|
||||
case "8", "16", "32", "64":
|
||||
return fmt.Sprintf("%sint%s", parts[1], parts[2])
|
||||
|
|
|
|||
|
|
@ -485,13 +485,13 @@ var bindTests = []struct {
|
|||
contract Defaulter {
|
||||
address public caller;
|
||||
|
||||
fallback() external payable {
|
||||
function() {
|
||||
caller = msg.sender;
|
||||
}
|
||||
}
|
||||
`,
|
||||
[]string{`608060405234801561000f575f80fd5b5061013d8061001d5f395ff3fe608060405260043610610021575f3560e01c8063fc9c8d391461006257610022565b5b335f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055005b34801561006d575f80fd5b5061007661008c565b60405161008391906100ee565b60405180910390f35b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100d8826100af565b9050919050565b6100e8816100ce565b82525050565b5f6020820190506101015f8301846100df565b9291505056fea26469706673582212201e9273ecfb1f534644c77f09a25c21baaba81cf1c444ebc071e12a225a23c72964736f6c63430008140033`},
|
||||
[]string{`[{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"caller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]`},
|
||||
[]string{`6060604052606a8060106000396000f360606040523615601d5760e060020a6000350463fc9c8d3981146040575b605e6000805473ffffffffffffffffffffffffffffffffffffffff191633179055565b606060005473ffffffffffffffffffffffffffffffffffffffff1681565b005b6060908152602090f3`},
|
||||
[]string{`[{"constant":true,"inputs":[],"name":"caller","outputs":[{"name":"","type":"address"}],"type":"function"}]`},
|
||||
`
|
||||
"math/big"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@
|
|||
package {{.Package}}
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"strings"
|
||||
"time"
|
||||
"errors"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
|
|
@ -29,8 +27,6 @@ var (
|
|||
_ = types.BloomLookup
|
||||
_ = event.NewSubscription
|
||||
_ = abi.ConvertType
|
||||
_ = time.Tick
|
||||
_ = context.Background
|
||||
)
|
||||
|
||||
{{$structs := .Structs}}
|
||||
|
|
@ -81,11 +77,7 @@ var (
|
|||
return common.Address{}, nil, nil, errors.New("GetABI returned nil")
|
||||
}
|
||||
{{range $pattern, $name := .Libraries}}
|
||||
{{decapitalise $name}}Addr, tx, _, _ := Deploy{{capitalise $name}}(auth, backend)
|
||||
ctx, _ := context.WithTimeout(context.Background(), 5 * time.Second)
|
||||
if err := bind.WaitAccepted(ctx, backend, tx); err != nil {
|
||||
return common.Address{}, nil, nil, err
|
||||
}
|
||||
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
|
||||
{{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:])
|
||||
{{end}}
|
||||
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
|
||||
|
|
|
|||
|
|
@ -59,11 +59,6 @@ var (
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *{{.Type}}) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// New{{.Type}} creates a new instance of {{.Type}}.
|
||||
func New{{.Type}}() *{{.Type}} {
|
||||
parsed, err := {{.Type}}MetaData.ParseABI()
|
||||
|
|
@ -188,11 +183,8 @@ var (
|
|||
// Solidity: {{.Original.String}}
|
||||
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Unpack{{.Normalized.Name}}Event(log *types.Log) (*{{$contract.Type}}{{.Normalized.Name}}, error) {
|
||||
event := "{{.Original.Name}}"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != {{ decapitalise $contract.Type}}.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new({{$contract.Type}}{{.Normalized.Name}})
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type CallbackParam struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *CallbackParam) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewCallbackParam creates a new instance of CallbackParam.
|
||||
func NewCallbackParam() *CallbackParam {
|
||||
parsed, err := CallbackParamMetaData.ParseABI()
|
||||
|
|
|
|||
10
accounts/abi/abigen/testdata/v2/crowdsale.go.txt
vendored
10
accounts/abi/abigen/testdata/v2/crowdsale.go.txt
vendored
|
|
@ -36,11 +36,6 @@ type Crowdsale struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Crowdsale) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewCrowdsale creates a new instance of Crowdsale.
|
||||
func NewCrowdsale() *Crowdsale {
|
||||
parsed, err := CrowdsaleMetaData.ParseABI()
|
||||
|
|
@ -365,11 +360,8 @@ func (CrowdsaleFundTransfer) ContractEventName() string {
|
|||
// Solidity: event FundTransfer(address backer, uint256 amount, bool isContribution)
|
||||
func (crowdsale *Crowdsale) UnpackFundTransferEvent(log *types.Log) (*CrowdsaleFundTransfer, error) {
|
||||
event := "FundTransfer"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != crowdsale.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(CrowdsaleFundTransfer)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
30
accounts/abi/abigen/testdata/v2/dao.go.txt
vendored
30
accounts/abi/abigen/testdata/v2/dao.go.txt
vendored
|
|
@ -36,11 +36,6 @@ type DAO struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *DAO) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewDAO creates a new instance of DAO.
|
||||
func NewDAO() *DAO {
|
||||
parsed, err := DAOMetaData.ParseABI()
|
||||
|
|
@ -611,11 +606,8 @@ func (DAOChangeOfRules) ContractEventName() string {
|
|||
// Solidity: event ChangeOfRules(uint256 minimumQuorum, uint256 debatingPeriodInMinutes, int256 majorityMargin)
|
||||
func (dAO *DAO) UnpackChangeOfRulesEvent(log *types.Log) (*DAOChangeOfRules, error) {
|
||||
event := "ChangeOfRules"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != dAO.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(DAOChangeOfRules)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -656,11 +648,8 @@ func (DAOMembershipChanged) ContractEventName() string {
|
|||
// Solidity: event MembershipChanged(address member, bool isMember)
|
||||
func (dAO *DAO) UnpackMembershipChangedEvent(log *types.Log) (*DAOMembershipChanged, error) {
|
||||
event := "MembershipChanged"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != dAO.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(DAOMembershipChanged)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -703,11 +692,8 @@ func (DAOProposalAdded) ContractEventName() string {
|
|||
// Solidity: event ProposalAdded(uint256 proposalID, address recipient, uint256 amount, string description)
|
||||
func (dAO *DAO) UnpackProposalAddedEvent(log *types.Log) (*DAOProposalAdded, error) {
|
||||
event := "ProposalAdded"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != dAO.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(DAOProposalAdded)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -750,11 +736,8 @@ func (DAOProposalTallied) ContractEventName() string {
|
|||
// Solidity: event ProposalTallied(uint256 proposalID, int256 result, uint256 quorum, bool active)
|
||||
func (dAO *DAO) UnpackProposalTalliedEvent(log *types.Log) (*DAOProposalTallied, error) {
|
||||
event := "ProposalTallied"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != dAO.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(DAOProposalTallied)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -797,11 +780,8 @@ func (DAOVoted) ContractEventName() string {
|
|||
// Solidity: event Voted(uint256 proposalID, bool position, address voter, string justification)
|
||||
func (dAO *DAO) UnpackVotedEvent(log *types.Log) (*DAOVoted, error) {
|
||||
event := "Voted"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != dAO.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(DAOVoted)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type DeeplyNestedArray struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *DeeplyNestedArray) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewDeeplyNestedArray creates a new instance of DeeplyNestedArray.
|
||||
func NewDeeplyNestedArray() *DeeplyNestedArray {
|
||||
parsed, err := DeeplyNestedArrayMetaData.ParseABI()
|
||||
|
|
|
|||
5
accounts/abi/abigen/testdata/v2/empty.go.txt
vendored
5
accounts/abi/abigen/testdata/v2/empty.go.txt
vendored
|
|
@ -36,11 +36,6 @@ type Empty struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Empty) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewEmpty creates a new instance of Empty.
|
||||
func NewEmpty() *Empty {
|
||||
parsed, err := EmptyMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -35,11 +35,6 @@ type EventChecker struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *EventChecker) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewEventChecker creates a new instance of EventChecker.
|
||||
func NewEventChecker() *EventChecker {
|
||||
parsed, err := EventCheckerMetaData.ParseABI()
|
||||
|
|
@ -77,11 +72,8 @@ func (EventCheckerDynamic) ContractEventName() string {
|
|||
// Solidity: event dynamic(string indexed idxStr, bytes indexed idxDat, string str, bytes dat)
|
||||
func (eventChecker *EventChecker) UnpackDynamicEvent(log *types.Log) (*EventCheckerDynamic, error) {
|
||||
event := "dynamic"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != eventChecker.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(EventCheckerDynamic)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -120,11 +112,8 @@ func (EventCheckerEmpty) ContractEventName() string {
|
|||
// Solidity: event empty()
|
||||
func (eventChecker *EventChecker) UnpackEmptyEvent(log *types.Log) (*EventCheckerEmpty, error) {
|
||||
event := "empty"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != eventChecker.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(EventCheckerEmpty)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -165,11 +154,8 @@ func (EventCheckerIndexed) ContractEventName() string {
|
|||
// Solidity: event indexed(address indexed addr, int256 indexed num)
|
||||
func (eventChecker *EventChecker) UnpackIndexedEvent(log *types.Log) (*EventCheckerIndexed, error) {
|
||||
event := "indexed"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != eventChecker.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(EventCheckerIndexed)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -210,11 +196,8 @@ func (EventCheckerMixed) ContractEventName() string {
|
|||
// Solidity: event mixed(address indexed addr, int256 num)
|
||||
func (eventChecker *EventChecker) UnpackMixedEvent(log *types.Log) (*EventCheckerMixed, error) {
|
||||
event := "mixed"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != eventChecker.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(EventCheckerMixed)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -255,11 +238,8 @@ func (EventCheckerUnnamed) ContractEventName() string {
|
|||
// Solidity: event unnamed(uint256 indexed arg0, uint256 indexed arg1)
|
||||
func (eventChecker *EventChecker) UnpackUnnamedEvent(log *types.Log) (*EventCheckerUnnamed, error) {
|
||||
event := "unnamed"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != eventChecker.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(EventCheckerUnnamed)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type Getter struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Getter) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewGetter creates a new instance of Getter.
|
||||
func NewGetter() *Getter {
|
||||
parsed, err := GetterMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type IdentifierCollision struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *IdentifierCollision) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewIdentifierCollision creates a new instance of IdentifierCollision.
|
||||
func NewIdentifierCollision() *IdentifierCollision {
|
||||
parsed, err := IdentifierCollisionMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -35,11 +35,6 @@ type InputChecker struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *InputChecker) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewInputChecker creates a new instance of InputChecker.
|
||||
func NewInputChecker() *InputChecker {
|
||||
parsed, err := InputCheckerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type Interactor struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Interactor) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewInteractor creates a new instance of Interactor.
|
||||
func NewInteractor() *Interactor {
|
||||
parsed, err := InteractorMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@ type NameConflict struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *NameConflict) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewNameConflict creates a new instance of NameConflict.
|
||||
func NewNameConflict() *NameConflict {
|
||||
parsed, err := NameConflictMetaData.ParseABI()
|
||||
|
|
@ -139,11 +134,8 @@ func (NameConflictLog) ContractEventName() string {
|
|||
// Solidity: event log(int256 msg, int256 _msg)
|
||||
func (nameConflict *NameConflict) UnpackLogEvent(log *types.Log) (*NameConflictLog, error) {
|
||||
event := "log"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != nameConflict.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(NameConflictLog)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type NumericMethodName struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *NumericMethodName) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewNumericMethodName creates a new instance of NumericMethodName.
|
||||
func NewNumericMethodName() *NumericMethodName {
|
||||
parsed, err := NumericMethodNameMetaData.ParseABI()
|
||||
|
|
@ -141,11 +136,8 @@ func (NumericMethodNameE1TestEvent) ContractEventName() string {
|
|||
// Solidity: event _1TestEvent(address _param)
|
||||
func (numericMethodName *NumericMethodName) UnpackE1TestEventEvent(log *types.Log) (*NumericMethodNameE1TestEvent, error) {
|
||||
event := "_1TestEvent"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != numericMethodName.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(NumericMethodNameE1TestEvent)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -35,11 +35,6 @@ type OutputChecker struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *OutputChecker) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewOutputChecker creates a new instance of OutputChecker.
|
||||
func NewOutputChecker() *OutputChecker {
|
||||
parsed, err := OutputCheckerMetaData.ParseABI()
|
||||
|
|
|
|||
15
accounts/abi/abigen/testdata/v2/overload.go.txt
vendored
15
accounts/abi/abigen/testdata/v2/overload.go.txt
vendored
|
|
@ -36,11 +36,6 @@ type Overload struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Overload) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewOverload creates a new instance of Overload.
|
||||
func NewOverload() *Overload {
|
||||
parsed, err := OverloadMetaData.ParseABI()
|
||||
|
|
@ -119,11 +114,8 @@ func (OverloadBar) ContractEventName() string {
|
|||
// Solidity: event bar(uint256 i)
|
||||
func (overload *Overload) UnpackBarEvent(log *types.Log) (*OverloadBar, error) {
|
||||
event := "bar"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != overload.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(OverloadBar)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -164,11 +156,8 @@ func (OverloadBar0) ContractEventName() string {
|
|||
// Solidity: event bar(uint256 i, uint256 j)
|
||||
func (overload *Overload) UnpackBar0Event(log *types.Log) (*OverloadBar0, error) {
|
||||
event := "bar0"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != overload.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(OverloadBar0)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type RangeKeyword struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *RangeKeyword) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewRangeKeyword creates a new instance of RangeKeyword.
|
||||
func NewRangeKeyword() *RangeKeyword {
|
||||
parsed, err := RangeKeywordMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type Slicer struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Slicer) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewSlicer creates a new instance of Slicer.
|
||||
func NewSlicer() *Slicer {
|
||||
parsed, err := SlicerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -41,11 +41,6 @@ type Structs struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Structs) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewStructs creates a new instance of Structs.
|
||||
func NewStructs() *Structs {
|
||||
parsed, err := StructsMetaData.ParseABI()
|
||||
|
|
|
|||
10
accounts/abi/abigen/testdata/v2/token.go.txt
vendored
10
accounts/abi/abigen/testdata/v2/token.go.txt
vendored
|
|
@ -36,11 +36,6 @@ type Token struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Token) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewToken creates a new instance of Token.
|
||||
func NewToken() *Token {
|
||||
parsed, err := TokenMetaData.ParseABI()
|
||||
|
|
@ -391,11 +386,8 @@ func (TokenTransfer) ContractEventName() string {
|
|||
// Solidity: event Transfer(address indexed from, address indexed to, uint256 value)
|
||||
func (token *Token) UnpackTransferEvent(log *types.Log) (*TokenTransfer, error) {
|
||||
event := "Transfer"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != token.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(TokenTransfer)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
15
accounts/abi/abigen/testdata/v2/tuple.go.txt
vendored
15
accounts/abi/abigen/testdata/v2/tuple.go.txt
vendored
|
|
@ -61,11 +61,6 @@ type Tuple struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Tuple) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewTuple creates a new instance of Tuple.
|
||||
func NewTuple() *Tuple {
|
||||
parsed, err := TupleMetaData.ParseABI()
|
||||
|
|
@ -198,11 +193,8 @@ func (TupleTupleEvent) ContractEventName() string {
|
|||
// Solidity: event TupleEvent((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e)
|
||||
func (tuple *Tuple) UnpackTupleEventEvent(log *types.Log) (*TupleTupleEvent, error) {
|
||||
event := "TupleEvent"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != tuple.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(TupleTupleEvent)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -242,11 +234,8 @@ func (TupleTupleEvent2) ContractEventName() string {
|
|||
// Solidity: event TupleEvent2((uint8,uint8)[] arg0)
|
||||
func (tuple *Tuple) UnpackTupleEvent2Event(log *types.Log) (*TupleTupleEvent2, error) {
|
||||
event := "TupleEvent2"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != tuple.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(TupleTupleEvent2)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type Tupler struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Tupler) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewTupler creates a new instance of Tupler.
|
||||
func NewTupler() *Tupler {
|
||||
parsed, err := TuplerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type Underscorer struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Underscorer) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewUnderscorer creates a new instance of Underscorer.
|
||||
func NewUnderscorer() *Underscorer {
|
||||
parsed, err := UnderscorerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ func (arguments Arguments) UnpackIntoMap(v map[string]any, data []byte) error {
|
|||
// Copy performs the operation go format -> provided struct.
|
||||
func (arguments Arguments) Copy(v any, values []any) error {
|
||||
// make sure the passed value is arguments pointer
|
||||
if reflect.Pointer != reflect.ValueOf(v).Kind() {
|
||||
if reflect.Ptr != reflect.ValueOf(v).Kind() {
|
||||
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
|
||||
}
|
||||
if len(values) == 0 {
|
||||
|
|
@ -165,7 +165,7 @@ func (arguments Arguments) copyTuple(v any, marshalledValues []any) error {
|
|||
}
|
||||
case reflect.Slice, reflect.Array:
|
||||
if value.Len() < len(marshalledValues) {
|
||||
return fmt.Errorf("abi: insufficient number of arguments for unpack, want %d, got %d", len(marshalledValues), value.Len())
|
||||
return fmt.Errorf("abi: insufficient number of arguments for unpack, want %d, got %d", len(arguments), value.Len())
|
||||
}
|
||||
for i := range nonIndexedArgs {
|
||||
if err := set(value.Index(i), reflect.ValueOf(marshalledValues[i])); err != nil {
|
||||
|
|
|
|||
|
|
@ -176,13 +176,6 @@ var (
|
|||
// ErrNoCodeAfterDeploy is returned by WaitDeployed if contract creation leaves
|
||||
// an empty contract behind.
|
||||
ErrNoCodeAfterDeploy = bind2.ErrNoCodeAfterDeploy
|
||||
|
||||
// ErrNoEventSignature is returned when a log entry has no topics.
|
||||
ErrNoEventSignature = bind2.ErrNoEventSignature
|
||||
|
||||
// ErrEventSignatureMismatch is returned when a log's topic[0] does not match
|
||||
// the expected event signature.
|
||||
ErrEventSignatureMismatch = bind2.ErrEventSignatureMismatch
|
||||
)
|
||||
|
||||
// ContractCaller defines the methods needed to allow operating with a contract on a read
|
||||
|
|
@ -273,12 +266,6 @@ func (m *MetaData) GetAbi() (*abi.ABI, error) {
|
|||
|
||||
// util.go
|
||||
|
||||
// WaitAccepted waits for a tx to be accepted into the pool.
|
||||
// It stops waiting when the context is canceled.
|
||||
func WaitAccepted(ctx context.Context, b ContractBackend, tx *types.Transaction) error {
|
||||
return bind2.WaitAccepted(ctx, b, tx.Hash())
|
||||
}
|
||||
|
||||
// WaitMined waits for tx to be mined on the blockchain.
|
||||
// It stops waiting when the context is canceled.
|
||||
func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*types.Receipt, error) {
|
||||
|
|
|
|||
|
|
@ -103,9 +103,6 @@ type ContractTransactor interface {
|
|||
|
||||
// PendingNonceAt retrieves the current pending nonce associated with an account.
|
||||
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
|
||||
|
||||
// TransactionByHash retrieves the transaction associated with the hash, if it exists in the pool.
|
||||
TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
|
||||
}
|
||||
|
||||
// DeployBackend wraps the operations needed by WaitMined and WaitDeployed.
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import (
|
|||
const basefeeWiggleMultiplier = 2
|
||||
|
||||
var (
|
||||
ErrNoEventSignature = errors.New("no event signature")
|
||||
ErrEventSignatureMismatch = errors.New("event signature mismatch")
|
||||
errNoEventSignature = errors.New("no event signature")
|
||||
errEventSignatureMismatch = errors.New("event signature mismatch")
|
||||
)
|
||||
|
||||
// SignerFn is a signer function callback when a contract requires a method to
|
||||
|
|
@ -150,11 +150,6 @@ func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller
|
|||
}
|
||||
}
|
||||
|
||||
// Address returns the deployment address of the contract.
|
||||
func (c *BoundContract) Address() common.Address {
|
||||
return c.address
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
|
|
@ -277,10 +272,8 @@ func (c *BoundContract) RawCreationTransact(opts *TransactOpts, calldata []byte)
|
|||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (c *BoundContract) Transfer(opts *TransactOpts) (*types.Transaction, error) {
|
||||
// Check if payable fallback or receive is defined
|
||||
if !c.abi.HasReceive() && !(c.abi.HasFallback() && c.abi.Fallback.IsPayable()) {
|
||||
return nil, fmt.Errorf("contract does not have a payable fallback or receive function")
|
||||
}
|
||||
// todo(rjl493456442) check the payable fallback or receive is defined
|
||||
// or not, reject invalid transaction at the first place
|
||||
return c.transact(opts, &c.address, nil)
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +313,7 @@ func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Add
|
|||
}
|
||||
}
|
||||
// create the transaction
|
||||
nonce, err := c.GetNonce(opts)
|
||||
nonce, err := c.getNonce(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -365,7 +358,7 @@ func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Addr
|
|||
}
|
||||
}
|
||||
// create the transaction
|
||||
nonce, err := c.GetNonce(opts)
|
||||
nonce, err := c.getNonce(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -402,7 +395,7 @@ func (c *BoundContract) estimateGasLimit(opts *TransactOpts, contract *common.Ad
|
|||
return c.transactor.EstimateGas(ensureContext(opts.Context), msg)
|
||||
}
|
||||
|
||||
func (c *BoundContract) GetNonce(opts *TransactOpts) (uint64, error) {
|
||||
func (c *BoundContract) getNonce(opts *TransactOpts) (uint64, error) {
|
||||
if opts.Nonce == nil {
|
||||
return c.transactor.PendingNonceAt(ensureContext(opts.Context), opts.From)
|
||||
} else {
|
||||
|
|
@ -536,10 +529,10 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]any)
|
|||
func (c *BoundContract) UnpackLog(out any, event string, log types.Log) error {
|
||||
// Anonymous events are not supported.
|
||||
if len(log.Topics) == 0 {
|
||||
return ErrNoEventSignature
|
||||
return errNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != c.abi.Events[event].ID {
|
||||
return ErrEventSignatureMismatch
|
||||
return errEventSignatureMismatch
|
||||
}
|
||||
if len(log.Data) > 0 {
|
||||
if err := c.abi.UnpackIntoInterface(out, event, log.Data); err != nil {
|
||||
|
|
@ -559,10 +552,10 @@ func (c *BoundContract) UnpackLog(out any, event string, log types.Log) error {
|
|||
func (c *BoundContract) UnpackLogIntoMap(out map[string]any, event string, log types.Log) error {
|
||||
// Anonymous events are not supported.
|
||||
if len(log.Topics) == 0 {
|
||||
return ErrNoEventSignature
|
||||
return errNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != c.abi.Events[event].ID {
|
||||
return ErrEventSignatureMismatch
|
||||
return errEventSignatureMismatch
|
||||
}
|
||||
if len(log.Data) > 0 {
|
||||
if err := c.abi.UnpackIntoMap(out, event, log.Data); err != nil {
|
||||
|
|
|
|||
|
|
@ -75,10 +75,6 @@ func (mt *mockTransactor) SendTransaction(ctx context.Context, tx *types.Transac
|
|||
return nil
|
||||
}
|
||||
|
||||
func (mt *mockTransactor) TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error) {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
type mockCaller struct {
|
||||
codeAtBlockNumber *big.Int
|
||||
callContractBlockNumber *big.Int
|
||||
|
|
|
|||
|
|
@ -158,10 +158,10 @@ func testLinkCase(tcInput linkTestCaseInput) error {
|
|||
overrideAddrs = make(map[rune]common.Address)
|
||||
)
|
||||
// generate deterministic addresses for the override set.
|
||||
rng := rand.New(rand.NewSource(42))
|
||||
rand.Seed(42)
|
||||
for contract := range tcInput.overrides {
|
||||
var addr common.Address
|
||||
rng.Read(addr[:])
|
||||
rand.Read(addr[:])
|
||||
overrideAddrs[contract] = addr
|
||||
overridesAddrs[addr] = struct{}{}
|
||||
}
|
||||
|
|
@ -329,7 +329,7 @@ func TestContractLinking(t *testing.T) {
|
|||
map[rune]struct{}{},
|
||||
},
|
||||
// two contracts ('a' and 'f') share some dependencies. contract 'a' is marked as an override. expect that any of
|
||||
// its dependencies that aren't shared with 'f' are not deployed.
|
||||
// its depdencies that aren't shared with 'f' are not deployed.
|
||||
linkTestCaseInput{map[rune][]rune{
|
||||
'a': {'b', 'c', 'd', 'e'},
|
||||
'f': {'g', 'c', 'd', 'h'}},
|
||||
|
|
|
|||
|
|
@ -43,11 +43,6 @@ type DB struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *DB) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewDB creates a new instance of DB.
|
||||
func NewDB() *DB {
|
||||
parsed, err := DBMetaData.ParseABI()
|
||||
|
|
@ -281,11 +276,8 @@ func (DBInsert) ContractEventName() string {
|
|||
// Solidity: event Insert(uint256 key, uint256 value, uint256 length)
|
||||
func (dB *DB) UnpackInsertEvent(log *types.Log) (*DBInsert, error) {
|
||||
event := "Insert"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != dB.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(DBInsert)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -326,11 +318,8 @@ func (DBKeyedInsert) ContractEventName() string {
|
|||
// Solidity: event KeyedInsert(uint256 indexed key, uint256 value)
|
||||
func (dB *DB) UnpackKeyedInsertEvent(log *types.Log) (*DBKeyedInsert, error) {
|
||||
event := "KeyedInsert"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != dB.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(DBKeyedInsert)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type C struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *C) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewC creates a new instance of C.
|
||||
func NewC() *C {
|
||||
parsed, err := CMetaData.ParseABI()
|
||||
|
|
@ -120,11 +115,8 @@ func (CBasic1) ContractEventName() string {
|
|||
// Solidity: event basic1(uint256 indexed id, uint256 data)
|
||||
func (c *C) UnpackBasic1Event(log *types.Log) (*CBasic1, error) {
|
||||
event := "basic1"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != c.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(CBasic1)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
@ -165,11 +157,8 @@ func (CBasic2) ContractEventName() string {
|
|||
// Solidity: event basic2(bool indexed flag, uint256 data)
|
||||
func (c *C) UnpackBasic2Event(log *types.Log) (*CBasic2, error) {
|
||||
event := "basic2"
|
||||
if len(log.Topics) == 0 {
|
||||
return nil, bind.ErrNoEventSignature
|
||||
}
|
||||
if log.Topics[0] != c.abi.Events[event].ID {
|
||||
return nil, bind.ErrEventSignatureMismatch
|
||||
return nil, errors.New("event signature mismatch")
|
||||
}
|
||||
out := new(CBasic2)
|
||||
if len(log.Data) > 0 {
|
||||
|
|
|
|||
|
|
@ -40,11 +40,6 @@ type C1 struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *C1) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewC1 creates a new instance of C1.
|
||||
func NewC1() *C1 {
|
||||
parsed, err := C1MetaData.ParseABI()
|
||||
|
|
@ -123,11 +118,6 @@ type C2 struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *C2) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewC2 creates a new instance of C2.
|
||||
func NewC2() *C2 {
|
||||
parsed, err := C2MetaData.ParseABI()
|
||||
|
|
@ -202,11 +192,6 @@ type L1 struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *L1) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewL1 creates a new instance of L1.
|
||||
func NewL1() *L1 {
|
||||
parsed, err := L1MetaData.ParseABI()
|
||||
|
|
@ -272,11 +257,6 @@ type L2 struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *L2) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewL2 creates a new instance of L2.
|
||||
func NewL2() *L2 {
|
||||
parsed, err := L2MetaData.ParseABI()
|
||||
|
|
@ -342,11 +322,6 @@ type L2b struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *L2b) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewL2b creates a new instance of L2b.
|
||||
func NewL2b() *L2b {
|
||||
parsed, err := L2bMetaData.ParseABI()
|
||||
|
|
@ -409,11 +384,6 @@ type L3 struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *L3) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewL3 creates a new instance of L3.
|
||||
func NewL3() *L3 {
|
||||
parsed, err := L3MetaData.ParseABI()
|
||||
|
|
@ -480,11 +450,6 @@ type L4 struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *L4) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewL4 creates a new instance of L4.
|
||||
func NewL4() *L4 {
|
||||
parsed, err := L4MetaData.ParseABI()
|
||||
|
|
@ -550,11 +515,6 @@ type L4b struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *L4b) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewL4b creates a new instance of L4b.
|
||||
func NewL4b() *L4b {
|
||||
parsed, err := L4bMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type C struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *C) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewC creates a new instance of C.
|
||||
func NewC() *C {
|
||||
parsed, err := CMetaData.ParseABI()
|
||||
|
|
@ -178,11 +173,6 @@ type C2 struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *C2) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewC2 creates a new instance of C2.
|
||||
func NewC2() *C2 {
|
||||
parsed, err := C2MetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@ type MyContract struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *MyContract) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewMyContract creates a new instance of MyContract.
|
||||
func NewMyContract() *MyContract {
|
||||
parsed, err := MyContractMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ package bind
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
|
|
@ -242,27 +241,3 @@ func DefaultDeployer(opts *TransactOpts, backend ContractBackend) DeployFn {
|
|||
return addr, tx, nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeployerWithNonceAssignment is basically identical to DefaultDeployer,
|
||||
// but it additionally tracks the nonce to enable automatic assignment.
|
||||
//
|
||||
// This is especially useful when deploying multiple contracts
|
||||
// from the same address — whether they are independent contracts
|
||||
// or part of a dependency chain that must be deployed in order.
|
||||
func DeployerWithNonceAssignment(opts *TransactOpts, backend ContractBackend) DeployFn {
|
||||
var pendingNonce int64
|
||||
if opts.Nonce != nil {
|
||||
pendingNonce = opts.Nonce.Int64()
|
||||
}
|
||||
return func(input []byte, deployer []byte) (common.Address, *types.Transaction, error) {
|
||||
if pendingNonce != 0 {
|
||||
opts.Nonce = big.NewInt(pendingNonce)
|
||||
}
|
||||
addr, tx, err := DeployContract(opts, deployer, backend, input)
|
||||
if err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
pendingNonce = int64(tx.Nonce() + 1)
|
||||
return addr, tx, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,14 +65,6 @@ func makeTestDeployer(backend simulated.Client) func(input, deployer []byte) (co
|
|||
return bind.DefaultDeployer(bind.NewKeyedTransactor(testKey, chainId), backend)
|
||||
}
|
||||
|
||||
// makeTestDeployerWithNonceAssignment is similar to makeTestDeployer,
|
||||
// but it returns a deployer that automatically tracks nonce,
|
||||
// enabling the deployment of multiple contracts from the same account.
|
||||
func makeTestDeployerWithNonceAssignment(backend simulated.Client) func(input, deployer []byte) (common.Address, *types.Transaction, error) {
|
||||
chainId, _ := backend.ChainID(context.Background())
|
||||
return bind.DeployerWithNonceAssignment(bind.NewKeyedTransactor(testKey, chainId), backend)
|
||||
}
|
||||
|
||||
// test that deploying a contract with library dependencies works,
|
||||
// verifying by calling method on the deployed contract.
|
||||
func TestDeploymentLibraries(t *testing.T) {
|
||||
|
|
@ -88,7 +80,7 @@ func TestDeploymentLibraries(t *testing.T) {
|
|||
Contracts: []*bind.MetaData{&nested_libraries.C1MetaData},
|
||||
Inputs: map[string][]byte{nested_libraries.C1MetaData.ID: constructorInput},
|
||||
}
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployerWithNonceAssignment(bindBackend.Client))
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployer(bindBackend.Client))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %+v\n", err)
|
||||
}
|
||||
|
|
@ -130,7 +122,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
|
|||
deploymentParams := &bind.DeploymentParams{
|
||||
Contracts: nested_libraries.C1MetaData.Deps,
|
||||
}
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployerWithNonceAssignment(bindBackend))
|
||||
res, err := bind.LinkAndDeploy(deploymentParams, makeTestDeployer(bindBackend))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %+v\n", err)
|
||||
}
|
||||
|
|
@ -310,7 +302,7 @@ done:
|
|||
t.Fatalf("expected e1Count of 2 from filter call. got %d", e1Count)
|
||||
}
|
||||
if e2Count != 1 {
|
||||
t.Fatalf("expected e2Count of 1 from filter call. got %d", e2Count)
|
||||
t.Fatalf("expected e2Count of 1 from filter call. got %d", e1Count)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -367,28 +359,3 @@ func TestErrors(t *testing.T) {
|
|||
t.Fatalf("bad unpacked error result: expected Arg4 to be false. got true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventUnpackEmptyTopics(t *testing.T) {
|
||||
c := events.NewC()
|
||||
|
||||
for _, log := range []*types.Log{
|
||||
{Topics: []common.Hash{}},
|
||||
{Topics: nil},
|
||||
} {
|
||||
_, err := c.UnpackBasic1Event(log)
|
||||
if err == nil {
|
||||
t.Fatal("expected error when unpacking event with empty topics, got nil")
|
||||
}
|
||||
if err != bind.ErrNoEventSignature {
|
||||
t.Fatalf("expected 'no event signature' error, got: %v", err)
|
||||
}
|
||||
|
||||
_, err = c.UnpackBasic2Event(log)
|
||||
if err == nil {
|
||||
t.Fatal("expected error when unpacking event with empty topics, got nil")
|
||||
}
|
||||
if err != bind.ErrNoEventSignature {
|
||||
t.Fatalf("expected 'no event signature' error, got: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,28 +75,3 @@ func WaitDeployed(ctx context.Context, b DeployBackend, hash common.Hash) (commo
|
|||
}
|
||||
return receipt.ContractAddress, err
|
||||
}
|
||||
|
||||
func WaitAccepted(ctx context.Context, d ContractBackend, txHash common.Hash) error {
|
||||
queryTicker := time.NewTicker(time.Second)
|
||||
defer queryTicker.Stop()
|
||||
logger := log.New("hash", txHash)
|
||||
for {
|
||||
_, _, err := d.TransactionByHash(ctx, txHash)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if errors.Is(err, ethereum.NotFound) { // TODO: check this is emitted
|
||||
logger.Trace("Transaction not yet accepted")
|
||||
} else {
|
||||
logger.Trace("Transaction submission failed", "err", err)
|
||||
}
|
||||
|
||||
// Wait for the next round.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-queryTicker.C:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,29 +100,22 @@ func TestWaitDeployed(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWaitDeployedCornerCases(t *testing.T) {
|
||||
var (
|
||||
backend = simulated.NewBackend(
|
||||
backend := simulated.NewBackend(
|
||||
types.GenesisAlloc{
|
||||
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
|
||||
},
|
||||
)
|
||||
head, _ = backend.Client().HeaderByNumber(t.Context(), nil) // Should be child's, good enough
|
||||
gasPrice = new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||
signer = types.LatestSigner(params.AllDevChainProtocolChanges)
|
||||
code = common.FromHex("6060604052600a8060106000396000f360606040526008565b00")
|
||||
ctx, cancel = context.WithCancel(t.Context())
|
||||
)
|
||||
defer backend.Close()
|
||||
|
||||
// 1. WaitDeploy on a transaction that does not deploy a contract, verify it
|
||||
// returns an error.
|
||||
tx := types.MustSignNewTx(testKey, signer, &types.LegacyTx{
|
||||
Nonce: 0,
|
||||
To: &common.Address{0x01},
|
||||
Gas: 300000,
|
||||
GasPrice: gasPrice,
|
||||
Data: code,
|
||||
})
|
||||
head, _ := backend.Client().HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
||||
|
||||
// Create a transaction to an account.
|
||||
code := "6060604052600a8060106000396000f360606040526008565b00"
|
||||
tx := types.NewTransaction(0, common.HexToAddress("0x01"), big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
|
||||
tx, _ = types.SignTx(tx, types.LatestSigner(params.AllDevChainProtocolChanges), testKey)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
if err := backend.Client().SendTransaction(ctx, tx); err != nil {
|
||||
t.Errorf("failed to send transaction: %q", err)
|
||||
}
|
||||
|
|
@ -131,22 +124,14 @@ func TestWaitDeployedCornerCases(t *testing.T) {
|
|||
t.Errorf("error mismatch: want %q, got %q, ", bind.ErrNoAddressInReceipt, err)
|
||||
}
|
||||
|
||||
// 2. Create a contract, but cancel the WaitDeploy before it is mined.
|
||||
tx = types.MustSignNewTx(testKey, signer, &types.LegacyTx{
|
||||
Nonce: 1,
|
||||
Gas: 300000,
|
||||
GasPrice: gasPrice,
|
||||
Data: code,
|
||||
})
|
||||
// Create a transaction that is not mined.
|
||||
tx = types.NewContractCreation(1, big.NewInt(0), 3000000, gasPrice, common.FromHex(code))
|
||||
tx, _ = types.SignTx(tx, types.LatestSigner(params.AllDevChainProtocolChanges), testKey)
|
||||
|
||||
// Wait in another thread so that we can quickly cancel it after submitting
|
||||
// the transaction.
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
_, err := bind.WaitDeployed(ctx, backend.Client(), tx.Hash())
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
t.Errorf("error mismatch: want %v, got %v", context.Canceled, err)
|
||||
contextCanceled := errors.New("context canceled")
|
||||
if _, err := bind.WaitDeployed(ctx, backend.Client(), tx.Hash()); err.Error() != contextCanceled.Error() {
|
||||
t.Errorf("error mismatch: want %q, got %q, ", contextCanceled, err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
@ -154,11 +139,4 @@ func TestWaitDeployedCornerCases(t *testing.T) {
|
|||
t.Errorf("failed to send transaction: %q", err)
|
||||
}
|
||||
cancel()
|
||||
|
||||
// Wait for goroutine to exit or for a timeout.
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(time.Second * 2):
|
||||
t.Fatalf("failed to cancel wait deploy")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func packElement(t Type, reflectValue reflect.Value) ([]byte, error) {
|
|||
switch t.T {
|
||||
case UintTy:
|
||||
// make sure to not pack a negative value into a uint type.
|
||||
if reflectValue.Kind() == reflect.Pointer {
|
||||
if reflectValue.Kind() == reflect.Ptr {
|
||||
val := new(big.Int).Set(reflectValue.Interface().(*big.Int))
|
||||
if val.Sign() == -1 {
|
||||
return nil, errInvalidSign
|
||||
|
|
@ -86,7 +86,7 @@ func packNum(value reflect.Value) []byte {
|
|||
return math.U256Bytes(new(big.Int).SetUint64(value.Uint()))
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return math.U256Bytes(big.NewInt(value.Int()))
|
||||
case reflect.Pointer:
|
||||
case reflect.Ptr:
|
||||
return math.U256Bytes(new(big.Int).Set(value.Interface().(*big.Int)))
|
||||
default:
|
||||
panic("abi: fatal error")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func ConvertType(in interface{}, proto interface{}) interface{} {
|
|||
// indirect recursively dereferences the value until it either gets the value
|
||||
// or finds a big.Int
|
||||
func indirect(v reflect.Value) reflect.Value {
|
||||
if v.Kind() == reflect.Pointer && v.Elem().Type() != reflect.TypeFor[big.Int]() {
|
||||
if v.Kind() == reflect.Ptr && v.Elem().Type() != reflect.TypeOf(big.Int{}) {
|
||||
return indirect(v.Elem())
|
||||
}
|
||||
return v
|
||||
|
|
@ -65,32 +65,32 @@ func reflectIntType(unsigned bool, size int) reflect.Type {
|
|||
if unsigned {
|
||||
switch size {
|
||||
case 8:
|
||||
return reflect.TypeFor[uint8]()
|
||||
return reflect.TypeOf(uint8(0))
|
||||
case 16:
|
||||
return reflect.TypeFor[uint16]()
|
||||
return reflect.TypeOf(uint16(0))
|
||||
case 32:
|
||||
return reflect.TypeFor[uint32]()
|
||||
return reflect.TypeOf(uint32(0))
|
||||
case 64:
|
||||
return reflect.TypeFor[uint64]()
|
||||
return reflect.TypeOf(uint64(0))
|
||||
}
|
||||
}
|
||||
switch size {
|
||||
case 8:
|
||||
return reflect.TypeFor[int8]()
|
||||
return reflect.TypeOf(int8(0))
|
||||
case 16:
|
||||
return reflect.TypeFor[int16]()
|
||||
return reflect.TypeOf(int16(0))
|
||||
case 32:
|
||||
return reflect.TypeFor[int32]()
|
||||
return reflect.TypeOf(int32(0))
|
||||
case 64:
|
||||
return reflect.TypeFor[int64]()
|
||||
return reflect.TypeOf(int64(0))
|
||||
}
|
||||
return reflect.TypeFor[*big.Int]()
|
||||
return reflect.TypeOf(&big.Int{})
|
||||
}
|
||||
|
||||
// mustArrayToByteSlice creates a new byte slice with the exact same size as value
|
||||
// and copies the bytes in value to the new slice.
|
||||
func mustArrayToByteSlice(value reflect.Value) reflect.Value {
|
||||
slice := reflect.ValueOf(make([]byte, value.Len()))
|
||||
slice := reflect.MakeSlice(reflect.TypeOf([]byte{}), value.Len(), value.Len())
|
||||
reflect.Copy(slice, value)
|
||||
return slice
|
||||
}
|
||||
|
|
@ -102,9 +102,9 @@ func mustArrayToByteSlice(value reflect.Value) reflect.Value {
|
|||
func set(dst, src reflect.Value) error {
|
||||
dstType, srcType := dst.Type(), src.Type()
|
||||
switch {
|
||||
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Pointer || dst.Elem().CanSet()):
|
||||
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Ptr || dst.Elem().CanSet()):
|
||||
return set(dst.Elem(), src)
|
||||
case dstType.Kind() == reflect.Pointer && dstType.Elem() != reflect.TypeFor[big.Int]():
|
||||
case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeOf(big.Int{}):
|
||||
return set(dst.Elem(), src)
|
||||
case srcType.AssignableTo(dstType) && dst.CanSet():
|
||||
dst.Set(src)
|
||||
|
|
@ -138,7 +138,7 @@ func setSlice(dst, src reflect.Value) error {
|
|||
}
|
||||
|
||||
func setArray(dst, src reflect.Value) error {
|
||||
if src.Kind() == reflect.Pointer {
|
||||
if src.Kind() == reflect.Ptr {
|
||||
return set(dst, indirect(src))
|
||||
}
|
||||
array := reflect.New(dst.Type()).Elem()
|
||||
|
|
|
|||
|
|
@ -204,12 +204,12 @@ func TestConvertType(t *testing.T) {
|
|||
var fields []reflect.StructField
|
||||
fields = append(fields, reflect.StructField{
|
||||
Name: "X",
|
||||
Type: reflect.TypeFor[*big.Int](),
|
||||
Type: reflect.TypeOf(new(big.Int)),
|
||||
Tag: "json:\"" + "x" + "\"",
|
||||
})
|
||||
fields = append(fields, reflect.StructField{
|
||||
Name: "Y",
|
||||
Type: reflect.TypeFor[*big.Int](),
|
||||
Type: reflect.TypeOf(new(big.Int)),
|
||||
Tag: "json:\"" + "y" + "\"",
|
||||
})
|
||||
val := reflect.New(reflect.StructOf(fields))
|
||||
|
|
|
|||
|
|
@ -75,11 +75,8 @@ func parseElementaryType(unescapedSelector string) (string, string, error) {
|
|||
parsedType = parsedType + string(rest[0])
|
||||
rest = rest[1:]
|
||||
}
|
||||
if len(rest) == 0 {
|
||||
return "", "", fmt.Errorf("failed to parse array: expected ']', got end of string")
|
||||
}
|
||||
if rest[0] != ']' {
|
||||
return "", "", fmt.Errorf("failed to parse array: expected ']', got %c", rest[0])
|
||||
if len(rest) == 0 || rest[0] != ']' {
|
||||
return "", "", fmt.Errorf("failed to parse array: expected ']', got %c", unescapedSelector[0])
|
||||
}
|
||||
parsedType = parsedType + string(rest[0])
|
||||
rest = rest[1:]
|
||||
|
|
|
|||
|
|
@ -238,9 +238,9 @@ func (t Type) GetType() reflect.Type {
|
|||
case UintTy:
|
||||
return reflectIntType(true, t.Size)
|
||||
case BoolTy:
|
||||
return reflect.TypeFor[bool]()
|
||||
return reflect.TypeOf(false)
|
||||
case StringTy:
|
||||
return reflect.TypeFor[string]()
|
||||
return reflect.TypeOf("")
|
||||
case SliceTy:
|
||||
return reflect.SliceOf(t.Elem.GetType())
|
||||
case ArrayTy:
|
||||
|
|
@ -248,15 +248,19 @@ func (t Type) GetType() reflect.Type {
|
|||
case TupleTy:
|
||||
return t.TupleType
|
||||
case AddressTy:
|
||||
return reflect.TypeFor[common.Address]()
|
||||
return reflect.TypeOf(common.Address{})
|
||||
case FixedBytesTy:
|
||||
return reflect.ArrayOf(t.Size, reflect.TypeFor[byte]())
|
||||
return reflect.ArrayOf(t.Size, reflect.TypeOf(byte(0)))
|
||||
case BytesTy:
|
||||
return reflect.TypeFor[[]byte]()
|
||||
case HashTy, FixedPointTy: // currently not used
|
||||
return reflect.TypeFor[[32]byte]()
|
||||
return reflect.SliceOf(reflect.TypeOf(byte(0)))
|
||||
case HashTy:
|
||||
// hashtype currently not used
|
||||
return reflect.ArrayOf(32, reflect.TypeOf(byte(0)))
|
||||
case FixedPointTy:
|
||||
// fixedpoint type currently not used
|
||||
return reflect.ArrayOf(32, reflect.TypeOf(byte(0)))
|
||||
case FunctionTy:
|
||||
return reflect.TypeFor[[24]byte]()
|
||||
return reflect.ArrayOf(24, reflect.TypeOf(byte(0)))
|
||||
default:
|
||||
panic("Invalid type")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
|
|||
return nil, fmt.Errorf("cannot marshal input to array, size is negative (%d)", size)
|
||||
}
|
||||
if start+32*size > len(output) {
|
||||
return nil, fmt.Errorf("abi: cannot marshal into go array: offset %d would go over slice boundary (len=%d)", start+32*size, len(output))
|
||||
return nil, fmt.Errorf("abi: cannot marshal into go array: offset %d would go over slice boundary (len=%d)", len(output), start+32*size)
|
||||
}
|
||||
|
||||
// this value will become our slice or our array, depending on the type
|
||||
|
|
|
|||
|
|
@ -910,7 +910,7 @@ func TestUnpackTuple(t *testing.T) {
|
|||
},
|
||||
},
|
||||
FieldT: T{
|
||||
big.NewInt(0).SetBits([]big.Word{}), big.NewInt(1),
|
||||
big.NewInt(0), big.NewInt(1),
|
||||
},
|
||||
A: big.NewInt(1),
|
||||
}
|
||||
|
|
@ -919,7 +919,7 @@ func TestUnpackTuple(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(ret, expected) {
|
||||
if reflect.DeepEqual(ret, expected) {
|
||||
t.Error("unexpected unpack value")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import (
|
|||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto/keccak"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
// Account represents an Ethereum account located at a specific location defined
|
||||
|
|
@ -196,7 +196,7 @@ func TextHash(data []byte) []byte {
|
|||
// This gives context to the signed message and prevents signing of transactions.
|
||||
func TextAndHash(data []byte) ([]byte, string) {
|
||||
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), data)
|
||||
hasher := keccak.NewLegacyKeccak256()
|
||||
hasher := sha3.NewLegacyKeccak256()
|
||||
hasher.Write([]byte(msg))
|
||||
return hasher.Sum(nil), msg
|
||||
}
|
||||
|
|
|
|||
1
accounts/external/backend.go
vendored
1
accounts/external/backend.go
vendored
|
|
@ -237,7 +237,6 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
|
|||
}
|
||||
if tx.Type() == types.BlobTxType {
|
||||
args.BlobHashes = tx.BlobHashes()
|
||||
args.BlobFeeCap = (*hexutil.Big)(tx.BlobGasFeeCap())
|
||||
sidecar := tx.BlobTxSidecar()
|
||||
if sidecar == nil {
|
||||
return nil, errors.New("blobs must be present for signing")
|
||||
|
|
|
|||
|
|
@ -68,27 +68,18 @@ func waitWatcherStart(ks *KeyStore) bool {
|
|||
|
||||
func waitForAccounts(wantAccounts []accounts.Account, ks *KeyStore) error {
|
||||
var list []accounts.Account
|
||||
haveAccounts := false
|
||||
haveChange := false
|
||||
for t0 := time.Now(); time.Since(t0) < 5*time.Second; time.Sleep(100 * time.Millisecond) {
|
||||
if !haveAccounts {
|
||||
list = ks.Accounts()
|
||||
haveAccounts = reflect.DeepEqual(list, wantAccounts)
|
||||
}
|
||||
if !haveChange {
|
||||
if reflect.DeepEqual(list, wantAccounts) {
|
||||
// ks should have also received change notifications
|
||||
select {
|
||||
case <-ks.changes:
|
||||
haveChange = true
|
||||
default:
|
||||
return errors.New("wasn't notified of new accounts")
|
||||
}
|
||||
}
|
||||
if haveAccounts && haveChange {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if haveAccounts {
|
||||
return errors.New("wasn't notified of new accounts")
|
||||
}
|
||||
return fmt.Errorf("\ngot %v\nwant %v", list, wantAccounts)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ func toISO8601(t time.Time) string {
|
|||
if name == "UTC" {
|
||||
tz = "Z"
|
||||
} else {
|
||||
tz = fmt.Sprintf("%+03d00", offset/3600)
|
||||
tz = fmt.Sprintf("%03d00", offset/3600)
|
||||
}
|
||||
return fmt.Sprintf("%04d-%02d-%02dT%02d-%02d-%02d.%09d%s",
|
||||
t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), tz)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
// Package keystore implements encrypted storage of secp256k1 private keys.
|
||||
//
|
||||
// Keys are stored as encrypted JSON files according to the Web3 Secret Storage specification.
|
||||
// See https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/ for more information.
|
||||
// See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.
|
||||
package keystore
|
||||
|
||||
import (
|
||||
|
|
@ -50,7 +50,7 @@ var (
|
|||
)
|
||||
|
||||
// KeyStoreType is the reflect type of a keystore backend.
|
||||
var KeyStoreType = reflect.TypeFor[*KeyStore]()
|
||||
var KeyStoreType = reflect.TypeOf(&KeyStore{})
|
||||
|
||||
// KeyStoreScheme is the protocol scheme prefixing account and wallet URLs.
|
||||
const KeyStoreScheme = "keystore"
|
||||
|
|
@ -99,10 +99,9 @@ func (ks *KeyStore) init(keydir string) {
|
|||
// TODO: In order for this finalizer to work, there must be no references
|
||||
// to ks. addressCache doesn't keep a reference but unlocked keys do,
|
||||
// so the finalizer will not trigger until all timed unlocks have expired.
|
||||
runtime.AddCleanup(ks, func(c *accountCache) {
|
||||
c.close()
|
||||
}, ks.cache)
|
||||
|
||||
runtime.SetFinalizer(ks, func(m *KeyStore) {
|
||||
m.cache.close()
|
||||
})
|
||||
// Create the initial list of wallets from the cache
|
||||
accs := ks.cache.accounts()
|
||||
ks.wallets = make([]accounts.Wallet, len(accs))
|
||||
|
|
@ -196,14 +195,11 @@ func (ks *KeyStore) Subscribe(sink chan<- accounts.WalletEvent) event.Subscripti
|
|||
// forces a manual refresh (only triggers for systems where the filesystem notifier
|
||||
// is not running).
|
||||
func (ks *KeyStore) updater() {
|
||||
ticker := time.NewTicker(walletRefreshCycle)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
// Wait for an account update or a refresh timeout
|
||||
select {
|
||||
case <-ks.changes:
|
||||
case <-ticker.C:
|
||||
case <-time.After(walletRefreshCycle):
|
||||
}
|
||||
// Run the wallet refresher
|
||||
ks.refreshWallets()
|
||||
|
|
@ -418,7 +414,6 @@ func (ks *KeyStore) Export(a accounts.Account, passphrase, newPassphrase string)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer zeroKey(key.PrivateKey)
|
||||
var N, P int
|
||||
if store, ok := ks.storage.(*keyStorePassphrase); ok {
|
||||
N, P = store.scryptN, store.scryptP
|
||||
|
|
@ -478,7 +473,6 @@ func (ks *KeyStore) Update(a accounts.Account, passphrase, newPassphrase string)
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer zeroKey(key.PrivateKey)
|
||||
return ks.storage.StoreKey(a.URL.Path, key, newPassphrase)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
This key store behaves as KeyStorePlain with the difference that
|
||||
the private key is encrypted and on disk uses another JSON encoding.
|
||||
|
||||
The crypto is documented at https://ethereum.org/en/developers/docs/data-structures-and-encoding/web3-secret-storage/
|
||||
The crypto is documented at https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -81,9 +81,6 @@ func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error
|
|||
*/
|
||||
passBytes := []byte(password)
|
||||
derivedKey := pbkdf2.Key(passBytes, passBytes, 2000, 16, sha256.New)
|
||||
if len(cipherText)%aes.BlockSize != 0 {
|
||||
return nil, errors.New("ciphertext must be a multiple of block size")
|
||||
}
|
||||
plainText, err := aesCBCDecrypt(derivedKey, cipherText, iv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//go:build (darwin && !ios && cgo) || freebsd || linux || netbsd || solaris
|
||||
// +build darwin,!ios,cgo freebsd linux netbsd solaris
|
||||
//go:build (darwin && !ios && cgo) || freebsd || (linux && !arm64) || netbsd || solaris
|
||||
// +build darwin,!ios,cgo freebsd linux,!arm64 netbsd solaris
|
||||
|
||||
package keystore
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//go:build (darwin && !cgo) || ios || windows || (!darwin && !freebsd && !linux && !netbsd && !solaris)
|
||||
// +build darwin,!cgo ios windows !darwin,!freebsd,!linux,!netbsd,!solaris
|
||||
//go:build (darwin && !cgo) || ios || (linux && arm64) || windows || (!darwin && !freebsd && !linux && !netbsd && !solaris)
|
||||
// +build darwin,!cgo ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris
|
||||
|
||||
// This is the fallback implementation of directory watching.
|
||||
// It is used on unsupported platforms.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package accounts
|
|||
|
||||
import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
|
|
@ -255,12 +254,13 @@ func merge(slice []Wallet, wallets ...Wallet) []Wallet {
|
|||
// drop is the counterpart of merge, which looks up wallets from within the sorted
|
||||
// cache and removes the ones specified.
|
||||
func drop(slice []Wallet, wallets ...Wallet) []Wallet {
|
||||
remove := make(map[URL]struct{}, len(wallets))
|
||||
for _, w := range wallets {
|
||||
remove[w.URL()] = struct{}{}
|
||||
for _, wallet := range wallets {
|
||||
n := sort.Search(len(slice), func(i int) bool { return slice[i].URL().Cmp(wallet.URL()) >= 0 })
|
||||
if n == len(slice) {
|
||||
// Wallet not found, may happen during startup
|
||||
continue
|
||||
}
|
||||
return slices.DeleteFunc(slice, func(w Wallet) bool {
|
||||
_, ok := remove[w.URL()]
|
||||
return ok
|
||||
})
|
||||
slice = append(slice[:n], slice[n+1:]...)
|
||||
}
|
||||
return slice
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func (hub *Hub) readPairings() error {
|
|||
}
|
||||
|
||||
func (hub *Hub) writePairings() error {
|
||||
pairingFile, err := os.OpenFile(filepath.Join(hub.datadir, "smartcards.json"), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
|
||||
pairingFile, err := os.OpenFile(filepath.Join(hub.datadir, "smartcards.json"), os.O_RDWR|os.O_CREATE, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -129,8 +129,11 @@ func (hub *Hub) writePairings() error {
|
|||
return err
|
||||
}
|
||||
|
||||
_, err = pairingFile.Write(pairingData)
|
||||
if _, err := pairingFile.Write(pairingData); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hub *Hub) pairing(wallet *Wallet) *smartcardPairing {
|
||||
|
|
|
|||
|
|
@ -300,10 +300,6 @@ func (s *SecureChannelSession) decryptAPDU(data []byte) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if len(data) == 0 || len(data)%aes.BlockSize != 0 {
|
||||
return nil, fmt.Errorf("invalid ciphertext length: %d", len(data))
|
||||
}
|
||||
|
||||
ret := make([]byte, len(data))
|
||||
|
||||
crypter := cipher.NewCBCDecrypter(a, s.iv)
|
||||
|
|
|
|||
|
|
@ -472,11 +472,6 @@ func (w *Wallet) selfDerive() {
|
|||
continue
|
||||
}
|
||||
pairing := w.Hub.pairing(w)
|
||||
if pairing == nil {
|
||||
w.lock.Unlock()
|
||||
reqc <- struct{}{}
|
||||
continue
|
||||
}
|
||||
|
||||
// Device lock obtained, derive the next batch of accounts
|
||||
var (
|
||||
|
|
@ -636,13 +631,13 @@ func (w *Wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
|
|||
}
|
||||
|
||||
if pin {
|
||||
if pairing := w.Hub.pairing(w); pairing != nil {
|
||||
pairing := w.Hub.pairing(w)
|
||||
pairing.Accounts[account.Address] = path
|
||||
if err := w.Hub.setPairing(w, pairing); err != nil {
|
||||
return accounts.Account{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return account, nil
|
||||
}
|
||||
|
||||
|
|
@ -779,11 +774,11 @@ func (w *Wallet) SignTxWithPassphrase(account accounts.Account, passphrase strin
|
|||
// It first checks for the address in the list of pinned accounts, and if it is
|
||||
// not found, attempts to parse the derivation path from the account's URL.
|
||||
func (w *Wallet) findAccountPath(account accounts.Account) (accounts.DerivationPath, error) {
|
||||
if pairing := w.Hub.pairing(w); pairing != nil {
|
||||
pairing := w.Hub.pairing(w)
|
||||
if path, ok := pairing.Accounts[account.Address]; ok {
|
||||
return path, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Look for the path in the URL
|
||||
if account.URL.Scheme != w.Hub.scheme {
|
||||
return nil, fmt.Errorf("scheme %s does not match wallet scheme %s", account.URL.Scheme, w.Hub.scheme)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/accounts"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/hid"
|
||||
"github.com/karalabe/hid"
|
||||
)
|
||||
|
||||
// LedgerScheme is the protocol scheme prefixing account and wallet URLs.
|
||||
|
|
@ -43,14 +43,6 @@ const refreshCycle = time.Second
|
|||
// trashing.
|
||||
const refreshThrottling = 500 * time.Millisecond
|
||||
|
||||
const (
|
||||
// deviceUsagePage identifies Ledger devices by HID usage page (0xffa0) on Windows and macOS.
|
||||
// See: https://github.com/LedgerHQ/ledger-live/blob/05a2980e838955a11a1418da638ef8ac3df4fb74/libs/ledgerjs/packages/hw-transport-node-hid-noevents/src/TransportNodeHid.ts
|
||||
deviceUsagePage = 0xffa0
|
||||
// deviceInterface identifies Ledger devices by USB interface number (0) on Linux.
|
||||
deviceInterface = 0
|
||||
)
|
||||
|
||||
// Hub is a accounts.Backend that can find and handle generic USB hardware wallets.
|
||||
type Hub struct {
|
||||
scheme string // Protocol scheme prefixing account and wallet URLs.
|
||||
|
|
@ -90,7 +82,6 @@ func NewLedgerHub() (*Hub, error) {
|
|||
0x0005, /* Ledger Nano S Plus */
|
||||
0x0006, /* Ledger Nano FTS */
|
||||
0x0007, /* Ledger Flex */
|
||||
0x0008, /* Ledger Nano Gen5 */
|
||||
|
||||
0x0000, /* WebUSB Ledger Blue */
|
||||
0x1000, /* WebUSB Ledger Nano S */
|
||||
|
|
@ -98,8 +89,7 @@ func NewLedgerHub() (*Hub, error) {
|
|||
0x5000, /* WebUSB Ledger Nano S Plus */
|
||||
0x6000, /* WebUSB Ledger Nano FTS */
|
||||
0x7000, /* WebUSB Ledger Flex */
|
||||
0x8000, /* WebUSB Ledger Nano Gen5 */
|
||||
}, deviceUsagePage, deviceInterface, newLedgerDriver)
|
||||
}, 0xffa0, 0, newLedgerDriver)
|
||||
}
|
||||
|
||||
// NewTrezorHubWithHID creates a new hardware wallet manager for Trezor devices.
|
||||
|
|
|
|||
|
|
@ -110,16 +110,6 @@ func (w *ledgerDriver) offline() bool {
|
|||
return w.version == [3]byte{0, 0, 0}
|
||||
}
|
||||
|
||||
func ledgerVersionLessThan(version [3]byte, major, minor, patch byte) bool {
|
||||
if version[0] != major {
|
||||
return version[0] < major
|
||||
}
|
||||
if version[1] != minor {
|
||||
return version[1] < minor
|
||||
}
|
||||
return version[2] < patch
|
||||
}
|
||||
|
||||
// Open implements usbwallet.driver, attempting to initialize the connection to the
|
||||
// Ledger hardware wallet. The Ledger does not require a user passphrase, so that
|
||||
// parameter is silently discarded.
|
||||
|
|
@ -176,19 +166,7 @@ func (w *ledgerDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
|
|||
return common.Address{}, nil, accounts.ErrWalletClosed
|
||||
}
|
||||
// Ensure the wallet is capable of signing the given transaction
|
||||
switch tx.Type() {
|
||||
case types.AccessListTxType, types.DynamicFeeTxType:
|
||||
if ledgerVersionLessThan(w.version, 1, 9, 0) {
|
||||
//lint:ignore ST1005 brand name displayed on the console
|
||||
return common.Address{}, nil, fmt.Errorf("Ledger version >= 1.9.0 required for EIP-2930/EIP-1559 signing (found version v%d.%d.%d)", w.version[0], w.version[1], w.version[2])
|
||||
}
|
||||
case types.SetCodeTxType:
|
||||
if ledgerVersionLessThan(w.version, 1, 17, 0) {
|
||||
//lint:ignore ST1005 brand name displayed on the console
|
||||
return common.Address{}, nil, fmt.Errorf("Ledger version >= 1.17.0 required for EIP-7702 signing (found version v%d.%d.%d)", w.version[0], w.version[1], w.version[2])
|
||||
}
|
||||
}
|
||||
if chainID != nil && ledgerVersionLessThan(w.version, 1, 0, 3) {
|
||||
if chainID != nil && w.version[0] <= 1 && w.version[1] <= 0 && w.version[2] <= 2 {
|
||||
//lint:ignore ST1005 brand name displayed on the console
|
||||
return common.Address{}, nil, fmt.Errorf("Ledger v%d.%d.%d doesn't support signing this transaction, please update to v1.0.3 at least", w.version[0], w.version[1], w.version[2])
|
||||
}
|
||||
|
|
@ -206,7 +184,7 @@ func (w *ledgerDriver) SignTypedMessage(path accounts.DerivationPath, domainHash
|
|||
return nil, accounts.ErrWalletClosed
|
||||
}
|
||||
// Ensure the wallet is capable of signing the given transaction
|
||||
if ledgerVersionLessThan(w.version, 1, 5, 0) {
|
||||
if w.version[0] < 1 && w.version[1] < 5 {
|
||||
//lint:ignore ST1005 brand name displayed on the console
|
||||
return nil, fmt.Errorf("Ledger version >= 1.5.0 required for EIP-712 signing (found version v%d.%d.%d)", w.version[0], w.version[1], w.version[2])
|
||||
}
|
||||
|
|
@ -356,41 +334,26 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
|||
err error
|
||||
)
|
||||
if chainID == nil {
|
||||
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
|
||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data()}); err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
} else {
|
||||
switch tx.Type() {
|
||||
case types.SetCodeTxType:
|
||||
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations()}); err != nil {
|
||||
if tx.Type() == types.DynamicFeeTxType {
|
||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
// append type to transaction
|
||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||
case types.BlobTxType:
|
||||
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList(), tx.BlobGasFeeCap(), tx.BlobHashes()}); err != nil {
|
||||
} else if tx.Type() == types.AccessListTxType {
|
||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
// append type to transaction
|
||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||
case types.DynamicFeeTxType:
|
||||
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasTipCap(), tx.GasFeeCap(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||
} else if tx.Type() == types.LegacyTxType {
|
||||
if txrlp, err = rlp.EncodeToBytes([]interface{}{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
// append type to transaction
|
||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||
case types.AccessListTxType:
|
||||
if txrlp, err = rlp.EncodeToBytes([]any{chainID, tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), tx.AccessList()}); err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
// append type to transaction
|
||||
txrlp = append([]byte{tx.Type()}, txrlp...)
|
||||
case types.LegacyTxType:
|
||||
if txrlp, err = rlp.EncodeToBytes([]any{tx.Nonce(), tx.GasPrice(), tx.Gas(), tx.To(), tx.Value(), tx.Data(), chainID, big.NewInt(0), big.NewInt(0)}); err != nil {
|
||||
return common.Address{}, nil, err
|
||||
}
|
||||
default:
|
||||
return common.Address{}, nil, fmt.Errorf("unsupported transaction type: %d", tx.Type())
|
||||
}
|
||||
}
|
||||
payload := append(path, txrlp...)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/hid"
|
||||
"github.com/karalabe/hid"
|
||||
)
|
||||
|
||||
// Maximum time between wallet health checks to detect USB unplugs.
|
||||
|
|
@ -632,7 +632,7 @@ func (w *wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID
|
|||
// data is not supported for Ledger wallets, so this method will always return
|
||||
// an error.
|
||||
func (w *wallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
|
||||
return w.SignText(account, text)
|
||||
return w.SignText(account, accounts.TextHash(text))
|
||||
}
|
||||
|
||||
// SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given
|
||||
|
|
|
|||
59
appveyor.yml
Normal file
59
appveyor.yml
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
clone_depth: 5
|
||||
version: "{branch}.{build}"
|
||||
|
||||
image:
|
||||
- Ubuntu
|
||||
- Visual Studio 2019
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- GETH_ARCH: amd64
|
||||
GETH_MINGW: 'C:\msys64\mingw64'
|
||||
- GETH_ARCH: 386
|
||||
GETH_MINGW: 'C:\msys64\mingw32'
|
||||
|
||||
install:
|
||||
- git submodule update --init --depth 1 --recursive
|
||||
- go version
|
||||
|
||||
for:
|
||||
# Linux has its own script without -arch and -cc.
|
||||
# The linux builder also runs lint.
|
||||
- matrix:
|
||||
only:
|
||||
- image: Ubuntu
|
||||
build_script:
|
||||
- go run build/ci.go lint
|
||||
- go run build/ci.go check_generate
|
||||
- go run build/ci.go check_baddeps
|
||||
- go run build/ci.go install -dlgo
|
||||
test_script:
|
||||
- go run build/ci.go test -dlgo -short
|
||||
|
||||
# linux/386 is disabled.
|
||||
- matrix:
|
||||
exclude:
|
||||
- image: Ubuntu
|
||||
GETH_ARCH: 386
|
||||
|
||||
# Windows builds for amd64 + 386.
|
||||
- matrix:
|
||||
only:
|
||||
- image: Visual Studio 2019
|
||||
environment:
|
||||
# We use gcc from MSYS2 because it is the most recent compiler version available on
|
||||
# AppVeyor. Note: gcc.exe only works properly if the corresponding bin/ directory is
|
||||
# contained in PATH.
|
||||
GETH_CC: '%GETH_MINGW%\bin\gcc.exe'
|
||||
PATH: '%GETH_MINGW%\bin;C:\Program Files (x86)\NSIS\;%PATH%'
|
||||
build_script:
|
||||
- 'echo %GETH_ARCH%'
|
||||
- 'echo %GETH_CC%'
|
||||
- '%GETH_CC% --version'
|
||||
- go run build/ci.go install -dlgo -arch %GETH_ARCH% -cc %GETH_CC%
|
||||
after_build:
|
||||
# Upload builds. Note that ci.go makes this a no-op PR builds.
|
||||
- go run build/ci.go archive -arch %GETH_ARCH% -type zip -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||
- go run build/ci.go nsis -arch %GETH_ARCH% -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
|
||||
test_script:
|
||||
- go run build/ci.go test -dlgo -arch %GETH_ARCH% -cc %GETH_CC% -short
|
||||
|
|
@ -32,7 +32,7 @@ var (
|
|||
testServer2 = testServer("testServer2")
|
||||
|
||||
testBlock1 = types.NewBeaconBlock(&deneb.BeaconBlock{
|
||||
Slot: 127,
|
||||
Slot: 123,
|
||||
Body: deneb.BeaconBlockBody{
|
||||
ExecutionPayload: deneb.ExecutionPayload{
|
||||
BlockNumber: 456,
|
||||
|
|
@ -41,7 +41,7 @@ var (
|
|||
},
|
||||
})
|
||||
testBlock2 = types.NewBeaconBlock(&deneb.BeaconBlock{
|
||||
Slot: 128,
|
||||
Slot: 124,
|
||||
Body: deneb.BeaconBlockBody{
|
||||
ExecutionPayload: deneb.ExecutionPayload{
|
||||
BlockNumber: 457,
|
||||
|
|
@ -49,14 +49,6 @@ var (
|
|||
},
|
||||
},
|
||||
})
|
||||
testFinal1 = types.NewExecutionHeader(&deneb.ExecutionPayloadHeader{
|
||||
BlockNumber: 395,
|
||||
BlockHash: zrntcommon.Hash32(common.HexToHash("abbe7625624bf8ddd84723709e2758956289465dd23475f02387e0854942666")),
|
||||
})
|
||||
testFinal2 = types.NewExecutionHeader(&deneb.ExecutionPayloadHeader{
|
||||
BlockNumber: 420,
|
||||
BlockHash: zrntcommon.Hash32(common.HexToHash("9182a6ef8723654de174283750932ccc092378549836bf4873657eeec474598")),
|
||||
})
|
||||
)
|
||||
|
||||
type testServer string
|
||||
|
|
@ -74,10 +66,9 @@ func TestBlockSync(t *testing.T) {
|
|||
ts.AddServer(testServer1, 1)
|
||||
ts.AddServer(testServer2, 1)
|
||||
|
||||
expHeadEvent := func(expHead *types.BeaconBlock, expFinal *types.ExecutionHeader) {
|
||||
expHeadBlock := func(expHead *types.BeaconBlock) {
|
||||
t.Helper()
|
||||
var expNumber, headNumber uint64
|
||||
var expFinalHash, finalHash common.Hash
|
||||
if expHead != nil {
|
||||
p, err := expHead.ExecutionPayload()
|
||||
if err != nil {
|
||||
|
|
@ -85,26 +76,19 @@ func TestBlockSync(t *testing.T) {
|
|||
}
|
||||
expNumber = p.NumberU64()
|
||||
}
|
||||
if expFinal != nil {
|
||||
expFinalHash = expFinal.BlockHash()
|
||||
}
|
||||
select {
|
||||
case event := <-headCh:
|
||||
headNumber = event.Block.NumberU64()
|
||||
finalHash = event.Finalized
|
||||
default:
|
||||
}
|
||||
if headNumber != expNumber {
|
||||
t.Errorf("Wrong head block, expected block number %d, got %d)", expNumber, headNumber)
|
||||
}
|
||||
if finalHash != expFinalHash {
|
||||
t.Errorf("Wrong finalized block, expected block hash %064x, got %064x)", expFinalHash[:], finalHash[:])
|
||||
}
|
||||
}
|
||||
|
||||
// no block requests expected until head tracker knows about a head
|
||||
ts.Run(1)
|
||||
expHeadEvent(nil, nil)
|
||||
expHeadBlock(nil)
|
||||
|
||||
// set block 1 as prefetch head, announced by server 2
|
||||
head1 := blockHeadInfo(testBlock1)
|
||||
|
|
@ -119,13 +103,12 @@ func TestBlockSync(t *testing.T) {
|
|||
ts.AddAllowance(testServer2, 1)
|
||||
ts.Run(3)
|
||||
// head block still not expected as the fetched block is not the validated head yet
|
||||
expHeadEvent(nil, nil)
|
||||
expHeadBlock(nil)
|
||||
|
||||
// set as validated head, expect no further requests but block 1 set as head block
|
||||
ht.validated.Header = testBlock1.Header()
|
||||
ht.finalized, ht.finalizedPayload = testBlock1.Header(), testFinal1
|
||||
ts.Run(4)
|
||||
expHeadEvent(testBlock1, testFinal1)
|
||||
expHeadBlock(testBlock1)
|
||||
|
||||
// set block 2 as prefetch head, announced by server 1
|
||||
head2 := blockHeadInfo(testBlock2)
|
||||
|
|
@ -143,26 +126,17 @@ func TestBlockSync(t *testing.T) {
|
|||
// expect req2 retry to server 2
|
||||
ts.Run(7, testServer2, sync.ReqBeaconBlock(head2.BlockRoot))
|
||||
// now head block should be unavailable again
|
||||
expHeadEvent(nil, nil)
|
||||
expHeadBlock(nil)
|
||||
|
||||
// valid response, now head block should be block 2 immediately as it is already validated
|
||||
// but head event is still not expected because an epoch boundary was crossed and the
|
||||
// expected finality update has not arrived yet
|
||||
ts.RequestEvent(request.EvResponse, ts.Request(7, 1), testBlock2)
|
||||
ts.Run(8)
|
||||
expHeadEvent(nil, nil)
|
||||
|
||||
// expected finality update arrived, now a head event is expected
|
||||
ht.finalized, ht.finalizedPayload = testBlock2.Header(), testFinal2
|
||||
ts.Run(9)
|
||||
expHeadEvent(testBlock2, testFinal2)
|
||||
expHeadBlock(testBlock2)
|
||||
}
|
||||
|
||||
type testHeadTracker struct {
|
||||
prefetch types.HeadInfo
|
||||
validated types.SignedHeader
|
||||
finalized types.Header
|
||||
finalizedPayload *types.ExecutionHeader
|
||||
}
|
||||
|
||||
func (h *testHeadTracker) PrefetchHead() types.HeadInfo {
|
||||
|
|
@ -177,14 +151,13 @@ func (h *testHeadTracker) ValidatedOptimistic() (types.OptimisticUpdate, bool) {
|
|||
}, h.validated.Header != (types.Header{})
|
||||
}
|
||||
|
||||
// TODO add test case for finality
|
||||
func (h *testHeadTracker) ValidatedFinality() (types.FinalityUpdate, bool) {
|
||||
if h.validated.Header == (types.Header{}) || h.finalizedPayload == nil {
|
||||
return types.FinalityUpdate{}, false
|
||||
}
|
||||
finalized := types.NewExecutionHeader(new(deneb.ExecutionPayloadHeader))
|
||||
return types.FinalityUpdate{
|
||||
Attested: types.HeaderWithExecProof{Header: h.finalized},
|
||||
Finalized: types.HeaderWithExecProof{Header: h.finalized, PayloadHeader: h.finalizedPayload},
|
||||
Attested: types.HeaderWithExecProof{Header: h.validated.Header},
|
||||
Finalized: types.HeaderWithExecProof{PayloadHeader: finalized},
|
||||
Signature: h.validated.Signature,
|
||||
SignatureSlot: h.validated.SignatureSlot,
|
||||
}, true
|
||||
}, h.validated.Header != (types.Header{})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,10 +87,6 @@ func (ec *engineClient) updateLoop(headCh <-chan types.ChainHeadEvent) {
|
|||
if status, err := ec.callForkchoiceUpdated(forkName, event); err == nil {
|
||||
log.Info("Successful ForkchoiceUpdated", "head", event.Block.Hash(), "status", status)
|
||||
} else {
|
||||
if err.Error() == "beacon syncer reorging" {
|
||||
log.Debug("Failed ForkchoiceUpdated", "head", event.Block.Hash(), "error", err)
|
||||
continue // ignore beacon syncer reorging errors, this error can occur if the blsync is skipping a block
|
||||
}
|
||||
log.Error("Failed ForkchoiceUpdated", "head", event.Block.Hash(), "error", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -105,16 +101,7 @@ func (ec *engineClient) callNewPayload(fork string, event types.ChainHeadEvent)
|
|||
params = []any{execData}
|
||||
)
|
||||
switch fork {
|
||||
case "altair", "bellatrix":
|
||||
method = "engine_newPayloadV1"
|
||||
case "capella":
|
||||
method = "engine_newPayloadV2"
|
||||
case "deneb":
|
||||
method = "engine_newPayloadV3"
|
||||
parentBeaconRoot := event.BeaconHead.ParentRoot
|
||||
blobHashes := collectBlobHashes(event.Block)
|
||||
params = append(params, blobHashes, parentBeaconRoot)
|
||||
default: // electra, fulu and above
|
||||
case "electra":
|
||||
method = "engine_newPayloadV4"
|
||||
parentBeaconRoot := event.BeaconHead.ParentRoot
|
||||
blobHashes := collectBlobHashes(event.Block)
|
||||
|
|
@ -123,6 +110,15 @@ func (ec *engineClient) callNewPayload(fork string, event types.ChainHeadEvent)
|
|||
hexRequests[i] = hexutil.Bytes(event.ExecRequests[i])
|
||||
}
|
||||
params = append(params, blobHashes, parentBeaconRoot, hexRequests)
|
||||
case "deneb":
|
||||
method = "engine_newPayloadV3"
|
||||
parentBeaconRoot := event.BeaconHead.ParentRoot
|
||||
blobHashes := collectBlobHashes(event.Block)
|
||||
params = append(params, blobHashes, parentBeaconRoot)
|
||||
case "capella":
|
||||
method = "engine_newPayloadV2"
|
||||
default:
|
||||
method = "engine_newPayloadV1"
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ec.rootCtx, time.Second*5)
|
||||
|
|
@ -149,12 +145,12 @@ func (ec *engineClient) callForkchoiceUpdated(fork string, event types.ChainHead
|
|||
|
||||
var method string
|
||||
switch fork {
|
||||
case "altair", "bellatrix":
|
||||
method = "engine_forkchoiceUpdatedV1"
|
||||
case "deneb", "electra":
|
||||
method = "engine_forkchoiceUpdatedV3"
|
||||
case "capella":
|
||||
method = "engine_forkchoiceUpdatedV2"
|
||||
default: // deneb, electra, fulu and above
|
||||
method = "engine_forkchoiceUpdatedV3"
|
||||
default:
|
||||
method = "engine_forkchoiceUpdatedV1"
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ec.rootCtx, time.Second*5)
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
// Copyright 2026 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package engine
|
||||
|
||||
import (
|
||||
"github.com/fjl/jsonw"
|
||||
)
|
||||
|
||||
// MarshalJSON implements json.Marshaler.
|
||||
func (list BlobAndProofListV1) MarshalJSON() ([]byte, error) {
|
||||
if list == nil {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
var b jsonw.Buffer
|
||||
b.Array(func() {
|
||||
for _, item := range list {
|
||||
marshalBlobAndProofV1(&b, item)
|
||||
}
|
||||
})
|
||||
return b.Output(), nil
|
||||
}
|
||||
|
||||
func marshalBlobAndProofV1(b *jsonw.Buffer, item *BlobAndProofV1) {
|
||||
if item == nil {
|
||||
b.Null()
|
||||
} else {
|
||||
b.Object(func() {
|
||||
b.Key("blob")
|
||||
b.HexBytes(item.Blob)
|
||||
b.Key("proof")
|
||||
b.HexBytes(item.Proof)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler.
|
||||
func (list BlobAndProofListV2) MarshalJSON() ([]byte, error) {
|
||||
if list == nil {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
var b jsonw.Buffer
|
||||
b.Array(func() {
|
||||
for _, item := range list {
|
||||
marshalBlobAndProofV2(&b, item)
|
||||
}
|
||||
})
|
||||
return b.Output(), nil
|
||||
}
|
||||
|
||||
func marshalBlobAndProofV2(b *jsonw.Buffer, item *BlobAndProofV2) {
|
||||
if item == nil {
|
||||
b.Null()
|
||||
} else {
|
||||
b.Object(func() {
|
||||
b.Key("blob")
|
||||
b.HexBytes(item.Blob)
|
||||
b.Key("proofs")
|
||||
appendHexBytesArray(b, item.CellProofs)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
// Copyright 2026 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package engine
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/fjl/jsonw"
|
||||
)
|
||||
|
||||
// marshalBlobsBundle writes BlobsBundle as JSON and appends it to buf.
|
||||
func marshalBlobsBundle(b *jsonw.Buffer, bundle *BlobsBundle) {
|
||||
if bundle == nil {
|
||||
b.Null()
|
||||
return
|
||||
}
|
||||
b.Object(func() {
|
||||
b.Key("commitments")
|
||||
appendHexBytesArray(b, bundle.Commitments)
|
||||
b.Key("proofs")
|
||||
appendHexBytesArray(b, bundle.Proofs)
|
||||
b.Key("blobs")
|
||||
appendHexBytesArray(b, bundle.Blobs)
|
||||
})
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler.
|
||||
func (e ExecutionPayloadEnvelope) MarshalJSON() ([]byte, error) {
|
||||
if e.ExecutionPayload == nil {
|
||||
return nil, errors.New("missing required field 'executionPayload' for ExecutionPayloadEnvelope")
|
||||
}
|
||||
|
||||
// Pre-marshal the execution payload using its gencodec MarshalJSON.
|
||||
payload, err := e.ExecutionPayload.MarshalJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Pre-marshal the witness.
|
||||
var witness []byte
|
||||
if e.Witness != nil {
|
||||
witness, err = json.Marshal(e.Witness)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Write the execution payload to the buffer
|
||||
var b jsonw.Buffer
|
||||
b.Object(func() {
|
||||
b.Key("executionPayload")
|
||||
b.RawValue(payload)
|
||||
|
||||
b.Key("blockValue")
|
||||
if e.BlockValue != nil {
|
||||
b.HexBigInt(e.BlockValue)
|
||||
} else {
|
||||
b.Null()
|
||||
}
|
||||
|
||||
b.Key("blobsBundle")
|
||||
marshalBlobsBundle(&b, e.BlobsBundle)
|
||||
|
||||
b.Key("executionRequests")
|
||||
if e.Requests == nil {
|
||||
b.Null()
|
||||
} else {
|
||||
appendHexBytesArray(&b, e.Requests)
|
||||
}
|
||||
|
||||
b.Key("shouldOverrideBuilder")
|
||||
b.Bool(e.Override)
|
||||
|
||||
if e.Witness != nil {
|
||||
b.Key("witness")
|
||||
b.RawValue(witness)
|
||||
}
|
||||
})
|
||||
return b.Output(), nil
|
||||
}
|
||||
|
||||
func appendHexBytesArray[T ~[]byte](b *jsonw.Buffer, slice []T) {
|
||||
b.Array(func() {
|
||||
for _, elem := range slice {
|
||||
b.HexBytes(elem)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
// Copyright 2026 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package engine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
)
|
||||
|
||||
func makeTestPayload() *ExecutableData {
|
||||
return &ExecutableData{
|
||||
ParentHash: common.HexToHash("0x01"),
|
||||
FeeRecipient: common.HexToAddress("0x02"),
|
||||
StateRoot: common.HexToHash("0x03"),
|
||||
ReceiptsRoot: common.HexToHash("0x04"),
|
||||
LogsBloom: make([]byte, 256),
|
||||
Random: common.HexToHash("0x05"),
|
||||
Number: 100,
|
||||
GasLimit: 1000000,
|
||||
GasUsed: 500000,
|
||||
Timestamp: 1234567890,
|
||||
ExtraData: []byte("extra"),
|
||||
BaseFeePerGas: big.NewInt(7),
|
||||
BlockHash: common.HexToHash("0x08"),
|
||||
Transactions: [][]byte{{0xaa, 0xbb}},
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalJSONRoundtrip(t *testing.T) {
|
||||
witness := hexutil.Bytes{0xde, 0xad}
|
||||
original := ExecutionPayloadEnvelope{
|
||||
ExecutionPayload: makeTestPayload(),
|
||||
BlockValue: big.NewInt(12345),
|
||||
BlobsBundle: &BlobsBundle{
|
||||
Commitments: []hexutil.Bytes{{0x01, 0x02}},
|
||||
Proofs: []hexutil.Bytes{{0x03, 0x04}},
|
||||
Blobs: []hexutil.Bytes{{0x05, 0x06}},
|
||||
},
|
||||
Requests: [][]byte{{0xaa}, {0xbb, 0xcc}},
|
||||
Override: true,
|
||||
Witness: &witness,
|
||||
}
|
||||
|
||||
data, err := original.MarshalJSON()
|
||||
if err != nil {
|
||||
t.Fatalf("MarshalJSON error: %v", err)
|
||||
}
|
||||
|
||||
var decoded ExecutionPayloadEnvelope
|
||||
if err := json.Unmarshal(data, &decoded); err != nil {
|
||||
t.Fatalf("UnmarshalJSON error: %v", err)
|
||||
}
|
||||
|
||||
if decoded.ExecutionPayload.Number != original.ExecutionPayload.Number {
|
||||
t.Error("ExecutionPayload.Number mismatch")
|
||||
}
|
||||
if decoded.BlockValue.Cmp(original.BlockValue) != 0 {
|
||||
t.Errorf("BlockValue mismatch: got %v, want %v", decoded.BlockValue, original.BlockValue)
|
||||
}
|
||||
if len(decoded.BlobsBundle.Blobs) != len(original.BlobsBundle.Blobs) {
|
||||
t.Error("BlobsBundle.Blobs length mismatch")
|
||||
}
|
||||
if len(decoded.Requests) != len(original.Requests) {
|
||||
t.Error("Requests length mismatch")
|
||||
}
|
||||
if decoded.Override != original.Override {
|
||||
t.Error("Override mismatch")
|
||||
}
|
||||
if !bytes.Equal(*decoded.Witness, *original.Witness) {
|
||||
t.Error("Witness mismatch")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalJSONNilPayload(t *testing.T) {
|
||||
env := ExecutionPayloadEnvelope{
|
||||
ExecutionPayload: nil,
|
||||
BlockValue: big.NewInt(1),
|
||||
}
|
||||
_, err := env.MarshalJSON()
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nil ExecutionPayload")
|
||||
}
|
||||
}
|
||||
|
||||
// TestExecutionPayloadEnvelopeFieldCoverage guards against structural drift.
|
||||
// If a field is added to or removed from ExecutionPayloadEnvelope, this test
|
||||
// fails, reminding the developer to update MarshalJSON in marshal_epe.go.
|
||||
func TestExecutionPayloadEnvelopeFieldCoverage(t *testing.T) {
|
||||
expected := []string{
|
||||
"ExecutionPayload",
|
||||
"BlockValue",
|
||||
"BlobsBundle",
|
||||
"Requests",
|
||||
"Override",
|
||||
"Witness",
|
||||
}
|
||||
typ := reflect.TypeOf(ExecutionPayloadEnvelope{})
|
||||
if typ.NumField() != len(expected) {
|
||||
t.Fatalf("ExecutionPayloadEnvelope has %d fields, expected %d — update MarshalJSON in marshal_epe.go",
|
||||
typ.NumField(), len(expected))
|
||||
}
|
||||
for i, name := range expected {
|
||||
if typ.Field(i).Name != name {
|
||||
t.Errorf("field %d: got %q, want %q — update MarshalJSON in marshal_epe.go",
|
||||
i, typ.Field(i).Name, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,6 @@ var (
|
|||
TooLargeRequest = &EngineAPIError{code: -38004, msg: "Too large request"}
|
||||
InvalidParams = &EngineAPIError{code: -32602, msg: "Invalid parameters"}
|
||||
UnsupportedFork = &EngineAPIError{code: -38005, msg: "Unsupported fork"}
|
||||
TooDeepReorg = &EngineAPIError{code: -38006, msg: "Too deep reorg"}
|
||||
|
||||
STATUS_INVALID = ForkChoiceResponse{PayloadStatus: PayloadStatusV1{Status: INVALID}, PayloadID: nil}
|
||||
STATUS_SYNCING = ForkChoiceResponse{PayloadStatus: PayloadStatusV1{Status: SYNCING}, PayloadID: nil}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ func (p PayloadAttributes) MarshalJSON() ([]byte, error) {
|
|||
SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"`
|
||||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
BeaconRoot *common.Hash `json:"parentBeaconBlockRoot"`
|
||||
SlotNumber *hexutil.Uint64 `json:"slotNumber"`
|
||||
TargetGasLimit *hexutil.Uint64 `json:"targetGasLimit"`
|
||||
}
|
||||
var enc PayloadAttributes
|
||||
enc.Timestamp = hexutil.Uint64(p.Timestamp)
|
||||
|
|
@ -30,8 +28,6 @@ func (p PayloadAttributes) MarshalJSON() ([]byte, error) {
|
|||
enc.SuggestedFeeRecipient = p.SuggestedFeeRecipient
|
||||
enc.Withdrawals = p.Withdrawals
|
||||
enc.BeaconRoot = p.BeaconRoot
|
||||
enc.SlotNumber = (*hexutil.Uint64)(p.SlotNumber)
|
||||
enc.TargetGasLimit = (*hexutil.Uint64)(p.TargetGasLimit)
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
|
|
@ -43,8 +39,6 @@ func (p *PayloadAttributes) UnmarshalJSON(input []byte) error {
|
|||
SuggestedFeeRecipient *common.Address `json:"suggestedFeeRecipient" gencodec:"required"`
|
||||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
BeaconRoot *common.Hash `json:"parentBeaconBlockRoot"`
|
||||
SlotNumber *hexutil.Uint64 `json:"slotNumber"`
|
||||
TargetGasLimit *hexutil.Uint64 `json:"targetGasLimit"`
|
||||
}
|
||||
var dec PayloadAttributes
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
|
|
@ -68,11 +62,5 @@ func (p *PayloadAttributes) UnmarshalJSON(input []byte) error {
|
|||
if dec.BeaconRoot != nil {
|
||||
p.BeaconRoot = dec.BeaconRoot
|
||||
}
|
||||
if dec.SlotNumber != nil {
|
||||
p.SlotNumber = (*uint64)(dec.SlotNumber)
|
||||
}
|
||||
if dec.TargetGasLimit != nil {
|
||||
p.TargetGasLimit = (*uint64)(dec.TargetGasLimit)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -34,8 +34,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
|||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||
BlockAccessList hexutil.Bytes `json:"blockAccessList,omitempty"`
|
||||
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
||||
ExecutionWitness *types.ExecutionWitness `json:"executionWitness,omitempty"`
|
||||
}
|
||||
var enc ExecutableData
|
||||
enc.ParentHash = e.ParentHash
|
||||
|
|
@ -60,8 +59,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
|||
enc.Withdrawals = e.Withdrawals
|
||||
enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed)
|
||||
enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas)
|
||||
enc.BlockAccessList = e.BlockAccessList
|
||||
enc.SlotNumber = (*hexutil.Uint64)(e.SlotNumber)
|
||||
enc.ExecutionWitness = e.ExecutionWitness
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
|
|
@ -85,8 +83,7 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
|||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||
BlockAccessList *hexutil.Bytes `json:"blockAccessList,omitempty"`
|
||||
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
||||
ExecutionWitness *types.ExecutionWitness `json:"executionWitness,omitempty"`
|
||||
}
|
||||
var dec ExecutableData
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
|
|
@ -160,11 +157,8 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
|||
if dec.ExcessBlobGas != nil {
|
||||
e.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||
}
|
||||
if dec.BlockAccessList != nil {
|
||||
e.BlockAccessList = *dec.BlockAccessList
|
||||
}
|
||||
if dec.SlotNumber != nil {
|
||||
e.SlotNumber = (*uint64)(dec.SlotNumber)
|
||||
if dec.ExecutionWitness != nil {
|
||||
e.ExecutionWitness = dec.ExecutionWitness
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -12,12 +12,37 @@ import (
|
|||
|
||||
var _ = (*executionPayloadEnvelopeMarshaling)(nil)
|
||||
|
||||
// MarshalJSON marshals as JSON.
|
||||
func (e ExecutionPayloadEnvelope) MarshalJSON() ([]byte, error) {
|
||||
type ExecutionPayloadEnvelope struct {
|
||||
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
|
||||
BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"`
|
||||
BlobsBundle *BlobsBundleV1 `json:"blobsBundle"`
|
||||
Requests []hexutil.Bytes `json:"executionRequests"`
|
||||
Override bool `json:"shouldOverrideBuilder"`
|
||||
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
||||
}
|
||||
var enc ExecutionPayloadEnvelope
|
||||
enc.ExecutionPayload = e.ExecutionPayload
|
||||
enc.BlockValue = (*hexutil.Big)(e.BlockValue)
|
||||
enc.BlobsBundle = e.BlobsBundle
|
||||
if e.Requests != nil {
|
||||
enc.Requests = make([]hexutil.Bytes, len(e.Requests))
|
||||
for k, v := range e.Requests {
|
||||
enc.Requests[k] = v
|
||||
}
|
||||
}
|
||||
enc.Override = e.Override
|
||||
enc.Witness = e.Witness
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals from JSON.
|
||||
func (e *ExecutionPayloadEnvelope) UnmarshalJSON(input []byte) error {
|
||||
type ExecutionPayloadEnvelope struct {
|
||||
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
|
||||
BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"`
|
||||
BlobsBundle *BlobsBundle `json:"blobsBundle"`
|
||||
BlobsBundle *BlobsBundleV1 `json:"blobsBundle"`
|
||||
Requests []hexutil.Bytes `json:"executionRequests"`
|
||||
Override *bool `json:"shouldOverrideBuilder"`
|
||||
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
package engine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"slices"
|
||||
|
|
@ -25,10 +24,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/types/bal"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
)
|
||||
|
||||
|
|
@ -37,33 +33,12 @@ import (
|
|||
type PayloadVersion byte
|
||||
|
||||
var (
|
||||
// PayloadV1 is the identifier of ExecutionPayloadV1 introduced in paris fork.
|
||||
// https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#executionpayloadv1
|
||||
PayloadV1 PayloadVersion = 0x1
|
||||
|
||||
// PayloadV2 is the identifier of ExecutionPayloadV2 introduced in shanghai fork.
|
||||
//
|
||||
// https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#executionpayloadv2
|
||||
// ExecutionPayloadV2 has the syntax of ExecutionPayloadV1 and appends a
|
||||
// single field: withdrawals.
|
||||
PayloadV2 PayloadVersion = 0x2
|
||||
|
||||
// PayloadV3 is the identifier of ExecutionPayloadV3 introduced in cancun fork.
|
||||
//
|
||||
// https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md#executionpayloadv3
|
||||
// ExecutionPayloadV3 has the syntax of ExecutionPayloadV2 and appends the new
|
||||
// fields: blobGasUsed and excessBlobGas.
|
||||
PayloadV3 PayloadVersion = 0x3
|
||||
|
||||
// PayloadV4 is the identifier of ExecutionPayloadV4 introduced in amsterdam fork.
|
||||
//
|
||||
// https://github.com/ethereum/execution-apis/blob/main/src/engine/amsterdam.md#executionpayloadv4
|
||||
// ExecutionPayloadV4 has the syntax of ExecutionPayloadV3 and appends the new
|
||||
// fields slotNumber and blockAccessList.
|
||||
PayloadV4 PayloadVersion = 0x4
|
||||
)
|
||||
|
||||
//go:generate go run github.com/fjl/gencodec -type PayloadAttributes -field-override payloadAttributesMarshaling -out pa_codec.go
|
||||
//go:generate go run github.com/fjl/gencodec -type PayloadAttributes -field-override payloadAttributesMarshaling -out gen_blockparams.go
|
||||
|
||||
// PayloadAttributes describes the environment context in which a block should
|
||||
// be built.
|
||||
|
|
@ -73,18 +48,14 @@ type PayloadAttributes struct {
|
|||
SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"`
|
||||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
BeaconRoot *common.Hash `json:"parentBeaconBlockRoot"`
|
||||
SlotNumber *uint64 `json:"slotNumber"`
|
||||
TargetGasLimit *uint64 `json:"targetGasLimit"`
|
||||
}
|
||||
|
||||
// JSON type overrides for PayloadAttributes.
|
||||
type payloadAttributesMarshaling struct {
|
||||
Timestamp hexutil.Uint64
|
||||
SlotNumber *hexutil.Uint64
|
||||
TargetGasLimit *hexutil.Uint64
|
||||
}
|
||||
|
||||
//go:generate go run github.com/fjl/gencodec -type ExecutableData -field-override executableDataMarshaling -out ed_codec.go
|
||||
//go:generate go run github.com/fjl/gencodec -type ExecutableData -field-override executableDataMarshaling -out gen_ed.go
|
||||
|
||||
// ExecutableData is the data necessary to execute an EL payload.
|
||||
type ExecutableData struct {
|
||||
|
|
@ -105,8 +76,7 @@ type ExecutableData struct {
|
|||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
BlobGasUsed *uint64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *uint64 `json:"excessBlobGas"`
|
||||
BlockAccessList []byte `json:"blockAccessList,omitempty"`
|
||||
SlotNumber *uint64 `json:"slotNumber,omitempty"`
|
||||
ExecutionWitness *types.ExecutionWitness `json:"executionWitness,omitempty"`
|
||||
}
|
||||
|
||||
// JSON type overrides for executableData.
|
||||
|
|
@ -121,8 +91,6 @@ type executableDataMarshaling struct {
|
|||
Transactions []hexutil.Bytes
|
||||
BlobGasUsed *hexutil.Uint64
|
||||
ExcessBlobGas *hexutil.Uint64
|
||||
SlotNumber *hexutil.Uint64
|
||||
BlockAccessList hexutil.Bytes
|
||||
}
|
||||
|
||||
// StatelessPayloadStatusV1 is the result of a stateless payload execution.
|
||||
|
|
@ -133,29 +101,18 @@ type StatelessPayloadStatusV1 struct {
|
|||
ValidationError *string `json:"validationError"`
|
||||
}
|
||||
|
||||
//go:generate go run github.com/fjl/gencodec -enc=false -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out epe_decode.go
|
||||
//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go
|
||||
|
||||
type ExecutionPayloadEnvelope struct {
|
||||
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
|
||||
BlockValue *big.Int `json:"blockValue" gencodec:"required"`
|
||||
BlobsBundle *BlobsBundle `json:"blobsBundle"`
|
||||
BlobsBundle *BlobsBundleV1 `json:"blobsBundle"`
|
||||
Requests [][]byte `json:"executionRequests"`
|
||||
Override bool `json:"shouldOverrideBuilder"`
|
||||
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
||||
}
|
||||
|
||||
// JSON type overrides for ExecutionPayloadEnvelope.
|
||||
type executionPayloadEnvelopeMarshaling struct {
|
||||
BlockValue *hexutil.Big
|
||||
Requests []hexutil.Bytes
|
||||
}
|
||||
|
||||
// BlobsBundle includes the marshalled sidecar data. Note this structure is
|
||||
// shared by BlobsBundleV1 and BlobsBundleV2 for the sake of simplicity.
|
||||
//
|
||||
// - BlobsBundleV1: proofs contain exactly len(blobs) kzg proofs.
|
||||
// - BlobsBundleV2: proofs contain exactly CELLS_PER_EXT_BLOB * len(blobs) cell proofs.
|
||||
type BlobsBundle struct {
|
||||
type BlobsBundleV1 struct {
|
||||
Commitments []hexutil.Bytes `json:"commitments"`
|
||||
Proofs []hexutil.Bytes `json:"proofs"`
|
||||
Blobs []hexutil.Bytes `json:"blobs"`
|
||||
|
|
@ -166,24 +123,17 @@ type BlobAndProofV1 struct {
|
|||
Proof hexutil.Bytes `json:"proof"`
|
||||
}
|
||||
|
||||
// BlobAndProofListV1 is a list of BlobAndProofV1 with a hand-rolled JSON marshaler
|
||||
// that avoids the overhead of encoding/json for large blob payloads.
|
||||
type BlobAndProofListV1 []*BlobAndProofV1
|
||||
|
||||
type BlobAndProofV2 struct {
|
||||
Blob hexutil.Bytes `json:"blob"`
|
||||
CellProofs []hexutil.Bytes `json:"proofs"` // proofs MUST contain exactly CELLS_PER_EXT_BLOB cell proofs.
|
||||
CellProofs []hexutil.Bytes `json:"proofs"`
|
||||
}
|
||||
|
||||
type BlobCellsAndProofsV1 struct {
|
||||
BlobCells []*hexutil.Bytes `json:"blob_cells"`
|
||||
Proofs []*hexutil.Bytes `json:"proofs"`
|
||||
// JSON type overrides for ExecutionPayloadEnvelope.
|
||||
type executionPayloadEnvelopeMarshaling struct {
|
||||
BlockValue *hexutil.Big
|
||||
Requests []hexutil.Bytes
|
||||
}
|
||||
|
||||
// BlobAndProofListV2 is a list of BlobAndProofV2 with a hand-rolled JSON marshaler
|
||||
// that avoids the overhead of encoding/json for large blob payloads.
|
||||
type BlobAndProofListV2 []*BlobAndProofV2
|
||||
|
||||
type PayloadStatusV1 struct {
|
||||
Status string `json:"status"`
|
||||
Witness *hexutil.Bytes `json:"witness,omitempty"`
|
||||
|
|
@ -245,7 +195,7 @@ func encodeTransactions(txs []*types.Transaction) [][]byte {
|
|||
return enc
|
||||
}
|
||||
|
||||
func DecodeTransactions(enc [][]byte) ([]*types.Transaction, error) {
|
||||
func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) {
|
||||
var txs = make([]*types.Transaction, len(enc))
|
||||
for i, encTx := range enc {
|
||||
var tx types.Transaction
|
||||
|
|
@ -283,7 +233,7 @@ func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, b
|
|||
// for stateless execution, so it skips checking if the executable data hashes to
|
||||
// the requested hash (stateless has to *compute* the root hash, it's not given).
|
||||
func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (*types.Block, error) {
|
||||
txs, err := DecodeTransactions(data.Transactions)
|
||||
txs, err := decodeTransactions(data.Transactions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -297,7 +247,7 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
|
|||
if data.BaseFeePerGas != nil && (data.BaseFeePerGas.Sign() == -1 || data.BaseFeePerGas.BitLen() > 256) {
|
||||
return nil, fmt.Errorf("invalid baseFeePerGas: %v", data.BaseFeePerGas)
|
||||
}
|
||||
var blobHashes = make([]common.Hash, 0, len(versionedHashes))
|
||||
var blobHashes = make([]common.Hash, 0, len(txs))
|
||||
for _, tx := range txs {
|
||||
blobHashes = append(blobHashes, tx.BlobHashes()...)
|
||||
}
|
||||
|
|
@ -306,7 +256,7 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
|
|||
}
|
||||
for i := 0; i < len(blobHashes); i++ {
|
||||
if blobHashes[i] != versionedHashes[i] {
|
||||
return nil, fmt.Errorf("invalid versionedHash at %v: %v blobHash: %v", i, versionedHashes[i], blobHashes[i])
|
||||
return nil, fmt.Errorf("invalid versionedHash at %v: %v blobHashes: %v", i, versionedHashes, blobHashes)
|
||||
}
|
||||
}
|
||||
// Only set withdrawalsRoot if it is non-nil. This allows CLs to use
|
||||
|
|
@ -324,16 +274,6 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
|
|||
requestsHash = &h
|
||||
}
|
||||
|
||||
// If Amsterdam is enabled, data.BlockAccessList is always non-nil,
|
||||
// even for empty blocks with no state transitions.
|
||||
//
|
||||
// If Amsterdam is not enabled yet, blockAccessListHash is expected
|
||||
// to be nil.
|
||||
var blockAccessListHash *common.Hash
|
||||
if data.BlockAccessList != nil {
|
||||
hash := crypto.Keccak256Hash(data.BlockAccessList)
|
||||
blockAccessListHash = &hash
|
||||
}
|
||||
header := &types.Header{
|
||||
ParentHash: data.ParentHash,
|
||||
UncleHash: types.EmptyUncleHash,
|
||||
|
|
@ -355,18 +295,11 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
|
|||
BlobGasUsed: data.BlobGasUsed,
|
||||
ParentBeaconRoot: beaconRoot,
|
||||
RequestsHash: requestsHash,
|
||||
SlotNumber: data.SlotNumber,
|
||||
BlockAccessListHash: blockAccessListHash,
|
||||
}
|
||||
body := types.Body{Transactions: txs, Uncles: nil, Withdrawals: data.Withdrawals}
|
||||
if data.BlockAccessList != nil {
|
||||
var accessList bal.BlockAccessList
|
||||
if err := rlp.DecodeBytes(data.BlockAccessList, &accessList); err != nil {
|
||||
return nil, fmt.Errorf("failed to decode BAL: %w", err)
|
||||
}
|
||||
return types.NewBlockWithHeader(header).WithBody(body).WithAccessListUnsafe(&accessList), nil
|
||||
}
|
||||
return types.NewBlockWithHeader(header).WithBody(body), nil
|
||||
return types.NewBlockWithHeader(header).
|
||||
WithBody(types.Body{Transactions: txs, Uncles: nil, Withdrawals: data.Withdrawals}).
|
||||
WithWitness(data.ExecutionWitness),
|
||||
nil
|
||||
}
|
||||
|
||||
// BlockToExecutableData constructs the ExecutableData structure by filling the
|
||||
|
|
@ -390,37 +323,22 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
|
|||
Withdrawals: block.Withdrawals(),
|
||||
BlobGasUsed: block.BlobGasUsed(),
|
||||
ExcessBlobGas: block.ExcessBlobGas(),
|
||||
SlotNumber: block.SlotNumber(),
|
||||
}
|
||||
if al := block.AccessList(); al != nil {
|
||||
var buf bytes.Buffer
|
||||
if err := rlp.Encode(&buf, al); err == nil {
|
||||
data.BlockAccessList = buf.Bytes()
|
||||
}
|
||||
ExecutionWitness: block.ExecutionWitness(),
|
||||
}
|
||||
|
||||
// Add blobs.
|
||||
bundle := BlobsBundle{
|
||||
bundle := BlobsBundleV1{
|
||||
Commitments: make([]hexutil.Bytes, 0),
|
||||
Blobs: make([]hexutil.Bytes, 0),
|
||||
Proofs: make([]hexutil.Bytes, 0),
|
||||
}
|
||||
for _, sidecar := range sidecars {
|
||||
for j := range sidecar.Blobs {
|
||||
bundle.Blobs = append(bundle.Blobs, sidecar.Blobs[j][:])
|
||||
bundle.Commitments = append(bundle.Commitments, sidecar.Commitments[j][:])
|
||||
bundle.Blobs = append(bundle.Blobs, hexutil.Bytes(sidecar.Blobs[j][:]))
|
||||
bundle.Commitments = append(bundle.Commitments, hexutil.Bytes(sidecar.Commitments[j][:]))
|
||||
}
|
||||
// - Before the Osaka fork, only version-0 blob transactions should be packed,
|
||||
// with the proof length equal to len(blobs).
|
||||
//
|
||||
// - After the Osaka fork, only version-1 blob transactions should be packed,
|
||||
// with the proof length equal to CELLS_PER_EXT_BLOB * len(blobs).
|
||||
//
|
||||
// Ideally, length validation should be performed based on the bundle version.
|
||||
// In practice, this is unnecessary because blob transaction filtering is
|
||||
// already done during payload construction.
|
||||
for _, proof := range sidecar.Proofs {
|
||||
bundle.Proofs = append(bundle.Proofs, proof[:])
|
||||
bundle.Proofs = append(bundle.Proofs, hexutil.Bytes(proof[:]))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -439,12 +357,6 @@ type ExecutionPayloadBody struct {
|
|||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
}
|
||||
|
||||
// ExecutionPayloadBodyV2 extends ExecutionPayloadBody with the block access list.
|
||||
type ExecutionPayloadBodyV2 struct {
|
||||
ExecutionPayloadBody
|
||||
BlockAccessList *hexutil.Bytes `json:"blockAccessList"`
|
||||
}
|
||||
|
||||
// Client identifiers to support ClientVersionV1.
|
||||
const (
|
||||
ClientCode = "GE"
|
||||
|
|
|
|||
|
|
@ -34,13 +34,21 @@ func TestBlobs(t *testing.T) {
|
|||
header := types.Header{}
|
||||
block := types.NewBlock(&header, &types.Body{}, nil, nil)
|
||||
|
||||
sidecarWithoutCellProofs := types.NewBlobTxSidecar(types.BlobSidecarVersion0, []kzg4844.Blob{*emptyBlob}, []kzg4844.Commitment{emptyBlobCommit}, []kzg4844.Proof{emptyBlobProof})
|
||||
sidecarWithoutCellProofs := &types.BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{*emptyBlob},
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: []kzg4844.Proof{emptyBlobProof},
|
||||
}
|
||||
env := BlockToExecutableData(block, common.Big0, []*types.BlobTxSidecar{sidecarWithoutCellProofs}, nil)
|
||||
if len(env.BlobsBundle.Proofs) != 1 {
|
||||
t.Fatalf("Expect 1 proof in blobs bundle, got %v", len(env.BlobsBundle.Proofs))
|
||||
}
|
||||
|
||||
sidecarWithCellProofs := types.NewBlobTxSidecar(types.BlobSidecarVersion0, []kzg4844.Blob{*emptyBlob}, []kzg4844.Commitment{emptyBlobCommit}, emptyCellProof)
|
||||
sidecarWithCellProofs := &types.BlobTxSidecar{
|
||||
Blobs: []kzg4844.Blob{*emptyBlob},
|
||||
Commitments: []kzg4844.Commitment{emptyBlobCommit},
|
||||
Proofs: emptyCellProof,
|
||||
}
|
||||
env = BlockToExecutableData(block, common.Big0, []*types.BlobTxSidecar{sidecarWithCellProofs}, nil)
|
||||
if len(env.BlobsBundle.Proofs) != 128 {
|
||||
t.Fatalf("Expect 128 proofs in blobs bundle, got %v", len(env.BlobsBundle.Proofs))
|
||||
|
|
|
|||
|
|
@ -69,10 +69,7 @@ func newCanonicalStore[T any](db ethdb.Iteratee, keyPrefix []byte) (*canonicalSt
|
|||
|
||||
// databaseKey returns the database key belonging to the given period.
|
||||
func (cs *canonicalStore[T]) databaseKey(period uint64) []byte {
|
||||
key := make([]byte, len(cs.keyPrefix)+8)
|
||||
copy(key, cs.keyPrefix)
|
||||
binary.BigEndian.PutUint64(key[len(cs.keyPrefix):], period)
|
||||
return key
|
||||
return binary.BigEndian.AppendUint64(append([]byte{}, cs.keyPrefix...), period)
|
||||
}
|
||||
|
||||
// add adds the given item to the database. It also ensures that the range remains
|
||||
|
|
|
|||
|
|
@ -182,12 +182,6 @@ func (s *CommitteeChain) Reset() {
|
|||
s.chainmu.Lock()
|
||||
defer s.chainmu.Unlock()
|
||||
|
||||
s.resetLocked()
|
||||
}
|
||||
|
||||
// ResetLocked resets the committee chain without locking. The caller should hold
|
||||
// the chainmu lock.
|
||||
func (s *CommitteeChain) resetLocked() {
|
||||
if err := s.rollback(0); err != nil {
|
||||
log.Error("Error writing batch into chain database", "error", err)
|
||||
}
|
||||
|
|
@ -207,22 +201,22 @@ func (s *CommitteeChain) CheckpointInit(bootstrap types.BootstrapData) error {
|
|||
}
|
||||
period := bootstrap.Header.SyncPeriod()
|
||||
if err := s.deleteFixedCommitteeRootsFrom(period + 2); err != nil {
|
||||
s.resetLocked()
|
||||
s.Reset()
|
||||
return err
|
||||
}
|
||||
if s.addFixedCommitteeRoot(period, bootstrap.CommitteeRoot) != nil {
|
||||
s.resetLocked()
|
||||
s.Reset()
|
||||
if err := s.addFixedCommitteeRoot(period, bootstrap.CommitteeRoot); err != nil {
|
||||
s.resetLocked()
|
||||
s.Reset()
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := s.addFixedCommitteeRoot(period+1, common.Hash(bootstrap.CommitteeBranch[0])); err != nil {
|
||||
s.resetLocked()
|
||||
s.Reset()
|
||||
return err
|
||||
}
|
||||
if err := s.addCommittee(period, bootstrap.Committee); err != nil {
|
||||
s.resetLocked()
|
||||
s.Reset()
|
||||
return err
|
||||
}
|
||||
s.changeCounter++
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ func (s *Scheduler) addEvent(event Event) {
|
|||
s.Trigger()
|
||||
}
|
||||
|
||||
// filterEvents sorts each Event either as a request event or a server event,
|
||||
// filterEvent sorts each Event either as a request event or a server event,
|
||||
// depending on its type. Request events are also sorted in a map based on the
|
||||
// module that originally initiated the request. It also ensures that no events
|
||||
// related to a server are returned before EvRegistered or after EvUnregistered.
|
||||
|
|
|
|||
|
|
@ -438,11 +438,14 @@ func (s *serverWithLimits) fail(desc string) {
|
|||
// failLocked calculates the dynamic failure delay and applies it.
|
||||
func (s *serverWithLimits) failLocked(desc string) {
|
||||
log.Debug("Server error", "description", desc)
|
||||
s.failureDelay *= 2
|
||||
now := s.clock.Now()
|
||||
if now > s.failureDelayEnd {
|
||||
s.failureDelay *= math.Pow(2, -float64(now-s.failureDelayEnd)/float64(maxFailureDelay))
|
||||
}
|
||||
s.failureDelay = max(min(s.failureDelay*2, float64(maxFailureDelay)), float64(minFailureDelay))
|
||||
if s.failureDelay < float64(minFailureDelay) {
|
||||
s.failureDelay = float64(minFailureDelay)
|
||||
}
|
||||
s.failureDelayEnd = now + mclock.AbsTime(s.failureDelay)
|
||||
s.delay(time.Duration(s.failureDelay))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ func (s *HeadSync) Process(requester request.Requester, events []request.Event)
|
|||
delete(s.serverHeads, event.Server)
|
||||
delete(s.unvalidatedOptimistic, event.Server)
|
||||
delete(s.unvalidatedFinality, event.Server)
|
||||
delete(s.reqFinalityEpoch, event.Server)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ const (
|
|||
ssNeedParent // cp header slot %32 != 0, need parent to check epoch boundary
|
||||
ssParentRequested // cp parent header requested
|
||||
ssPrintStatus // has all necessary info, print log message if init still not successful
|
||||
ssDone // log message printed, no more action required
|
||||
)
|
||||
|
||||
type serverState struct {
|
||||
|
|
@ -98,10 +99,7 @@ func (s *CheckpointInit) Process(requester request.Requester, events []request.E
|
|||
case ssDefault:
|
||||
if resp != nil {
|
||||
if checkpoint := resp.(*types.BootstrapData); checkpoint.Header.Hash() == common.Hash(req.(ReqCheckpointData)) {
|
||||
err := s.chain.CheckpointInit(*checkpoint)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
s.chain.CheckpointInit(*checkpoint)
|
||||
s.initialized = true
|
||||
return
|
||||
}
|
||||
|
|
@ -182,8 +180,7 @@ func (s *CheckpointInit) Process(requester request.Requester, events []request.E
|
|||
default:
|
||||
log.Error("blsync: checkpoint not available, but reported as finalized; specified checkpoint hash might be too old", "server", server.Name())
|
||||
}
|
||||
s.serverState[server] = serverState{state: ssDefault}
|
||||
requester.Fail(server, "checkpoint init failed")
|
||||
s.serverState[server] = serverState{state: ssDone}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type Value [32]byte
|
|||
// Values represent a series of merkle tree leaves/nodes.
|
||||
type Values []Value
|
||||
|
||||
var valueT = reflect.TypeFor[Value]()
|
||||
var valueT = reflect.TypeOf(Value{})
|
||||
|
||||
// UnmarshalJSON parses a merkle value in hex syntax.
|
||||
func (m *Value) UnmarshalJSON(input []byte) error {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
0x4bae4b97deda095724560012cab1f80a5221ce0a37a4b5236d8ab63f595f29d9
|
||||
0xd60e5310c5d52ced44cfb13be4e9f22a1e6a6dc56964c3cccd429182d26d72d0
|
||||
|
|
@ -1 +0,0 @@
|
|||
0xbb7a7f3c40d8ea0b450f91587db65d0f1c079669277e01a0426c8911702a863a
|
||||
|
|
@ -1 +1 @@
|
|||
0x2af778d703186526a1b6304b423f338f11556206f618643c3f7fa0d7b1ef5c9b
|
||||
0x02f0bb348b0d45f95a9b7e2bb5705768ad06548876cee03d880a2c9dabb1ff88
|
||||
|
|
@ -1 +1 @@
|
|||
0x48a89c9ea7ba19de2931797974cf8722344ab231c0edada278b108ef74125478
|
||||
0xa0dad451a230c01be6f2492980ec5bb412d8cf33351a75e8b172b5b84a5fd03a
|
||||
|
|
@ -20,7 +20,6 @@ import (
|
|||
"crypto/sha256"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
"slices"
|
||||
"sort"
|
||||
|
|
@ -38,7 +37,7 @@ import (
|
|||
// across signing different data structures.
|
||||
const syncCommitteeDomain = 7
|
||||
|
||||
var knownForks = []string{"GENESIS", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB", "ELECTRA", "FULU"}
|
||||
var knownForks = []string{"GENESIS", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB"}
|
||||
|
||||
// ClientConfig contains beacon light client configuration.
|
||||
type ClientConfig struct {
|
||||
|
|
@ -91,8 +90,12 @@ func (c *ChainConfig) AddFork(name string, epoch uint64, version []byte) *ChainC
|
|||
|
||||
// LoadForks parses the beacon chain configuration file (config.yaml) and extracts
|
||||
// the list of forks.
|
||||
func (c *ChainConfig) LoadForks(file []byte) error {
|
||||
config := make(map[string]any)
|
||||
func (c *ChainConfig) LoadForks(path string) error {
|
||||
file, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read beacon chain config file: %v", err)
|
||||
}
|
||||
config := make(map[string]string)
|
||||
if err := yaml.Unmarshal(file, &config); err != nil {
|
||||
return fmt.Errorf("failed to parse beacon chain config file: %v", err)
|
||||
}
|
||||
|
|
@ -103,45 +106,20 @@ func (c *ChainConfig) LoadForks(file []byte) error {
|
|||
epochs["GENESIS"] = 0
|
||||
|
||||
for key, value := range config {
|
||||
if value == nil {
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(key, "_FORK_VERSION") {
|
||||
name := key[:len(key)-len("_FORK_VERSION")]
|
||||
switch version := value.(type) {
|
||||
case int:
|
||||
versions[name] = new(big.Int).SetUint64(uint64(version)).FillBytes(make([]byte, 4))
|
||||
case int64:
|
||||
versions[name] = new(big.Int).SetUint64(uint64(version)).FillBytes(make([]byte, 4))
|
||||
case uint64:
|
||||
versions[name] = new(big.Int).SetUint64(version).FillBytes(make([]byte, 4))
|
||||
case string:
|
||||
v, err := hexutil.Decode(version)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to decode hex fork id %q in beacon chain config file: %v", version, err)
|
||||
}
|
||||
if v, err := hexutil.Decode(value); err == nil {
|
||||
versions[name] = v
|
||||
default:
|
||||
return fmt.Errorf("invalid fork version %q in beacon chain config file", version)
|
||||
} else {
|
||||
return fmt.Errorf("failed to decode hex fork id %q in beacon chain config file: %v", value, err)
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(key, "_FORK_EPOCH") {
|
||||
name := key[:len(key)-len("_FORK_EPOCH")]
|
||||
switch epoch := value.(type) {
|
||||
case int:
|
||||
epochs[name] = uint64(epoch)
|
||||
case int64:
|
||||
epochs[name] = uint64(epoch)
|
||||
case uint64:
|
||||
epochs[name] = epoch
|
||||
case string:
|
||||
v, err := strconv.ParseUint(epoch, 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse epoch number %q in beacon chain config file: %v", epoch, err)
|
||||
}
|
||||
if v, err := strconv.ParseUint(value, 10, 64); err == nil {
|
||||
epochs[name] = v
|
||||
default:
|
||||
return fmt.Errorf("invalid fork epoch %q in beacon chain config file", epoch)
|
||||
} else {
|
||||
return fmt.Errorf("failed to parse epoch number %q in beacon chain config file: %v", value, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
package params
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestChainConfig_LoadForks(t *testing.T) {
|
||||
const config = `
|
||||
GENESIS_FORK_VERSION: 0x00000000
|
||||
|
||||
ALTAIR_FORK_VERSION: 0x00000001
|
||||
ALTAIR_FORK_EPOCH: 1
|
||||
|
||||
EIP7928_FORK_VERSION: 0xb0000038
|
||||
EIP7928_FORK_EPOCH: 18446744073709551615
|
||||
|
||||
EIP7XXX_FORK_VERSION:
|
||||
EIP7XXX_FORK_EPOCH:
|
||||
|
||||
BLOB_SCHEDULE: []
|
||||
`
|
||||
c := &ChainConfig{}
|
||||
err := c.LoadForks([]byte(config))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, fork := range c.Forks {
|
||||
if fork.Name == "GENESIS" && (fork.Epoch != 0) {
|
||||
t.Errorf("unexpected genesis fork epoch %d", fork.Epoch)
|
||||
}
|
||||
if fork.Name == "ALTAIR" && (fork.Epoch != 1 || !bytes.Equal(fork.Version, []byte{0, 0, 0, 1})) {
|
||||
t.Errorf("unexpected altair fork epoch %d version %x", fork.Epoch, fork.Version)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue