Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull from go-ethereum up to 2f24e25 (6 Mar 2019) #2

Closed
wants to merge 145 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
81801cc
core/state: more memory efficient preimage allocation (#16663)
atsushi-ishibashi Feb 7, 2019
26aea73
cmd, node, p2p/simulations: fix node account manager leak (#19004)
janos Feb 7, 2019
4097ba6
mobile: add ability to create transactions for deploying contracts (#…
derekg Feb 7, 2019
7c339ff
light: make transaction pool receiver names consistent (#19000)
Matthalp-zz Feb 7, 2019
6f714ed
light: make chain receiver names consistent (#18997)
Matthalp-zz Feb 7, 2019
2ac61a9
ethapi: default to use eip-155 protected transactions
holiman Feb 7, 2019
53b823a
contracts/*: golint updates for this or self warning
kielbarry Apr 30, 2018
159e991
contracts/chequebook: polishes and naked return removals
karalabe Feb 7, 2019
85b3b1c
Merge pull request #16619 from kielbarry/contractsgolint
karalabe Feb 7, 2019
d6225ab
cmd/utils, eth: relinquish GC cache to read cache in archive mode
karalabe Feb 5, 2019
7f55b0c
cmd/swarm: hashes command (#19008)
holisticode Feb 7, 2019
d212535
cmd/swarm/swarm-smoke: refactor generateEndpoints (#19006)
nonsense Feb 7, 2019
9fa4c3c
Merge pull request #18991 from karalabe/archive-write-cache
karalabe Feb 7, 2019
685eec3
Merge pull request #19012 from holiman/default155
karalabe Feb 7, 2019
33d0a0e
cmd/swarm/global-store: global store cmd (#19014)
janos Feb 7, 2019
41597c2
swarm: Debug API and HasChunks() API endpoint (#18980)
holisticode Feb 7, 2019
4f3d22f
swarm/storage/localstore: new localstore package (#19015)
janos Feb 7, 2019
da1efda
core: repro #18977
holiman Feb 4, 2019
940e317
core: fix pruner panic when importing low-diff-large-sidechain
karalabe Feb 8, 2019
0436412
Merge pull request #18988 from holiman/repro18977
karalabe Feb 8, 2019
0c10d37
swarm/network, swarm/storage: Preserve opentracing contexts (#19022)
nolash Feb 8, 2019
cde02e0
swarm/pss: transition to whisper v6 (#19023)
gluk256 Feb 8, 2019
27e3f96
swarm: CI race detector test adjustments (#19017)
frncmx Feb 8, 2019
6cb7d52
swarm/docker: add global-store and split docker images (#19038)
skylenet Feb 12, 2019
3de19c8
build: use SFTP for launchpad uploads (#19037)
fjl Feb 12, 2019
f48da43
common/fdlimit: cap on MacOS file limits, fixes #18994 (#19035)
holiman Feb 12, 2019
edf976e
.travis.yml: fix upload destination (#19043)
fjl Feb 12, 2019
75d292b
clef: external signing fixes + signing data (#19003)
holiman Feb 12, 2019
b5d471a
clef: bidirectional communication with UI (#19018)
holiman Feb 12, 2019
8771fbf
rpc: make stdio usable over custom channels (#19046)
holiman Feb 12, 2019
b30109d
swarm/pss: mutex lifecycle fixed (#19045)
gluk256 Feb 12, 2019
3d22a46
swarm/storage: fix HashExplore concurrency bug ethersphere#1211 (#19028)
holisticode Feb 12, 2019
555b365
accounts/abi/bind/backends: add TransactionByHash to SimulatedBackend…
Feb 12, 2019
d596bea
swarm: fix uptime gauge update goroutine leak by introducing cleanup …
acud Feb 13, 2019
3fd6db2
swarm: fix network/stream data races (#19051)
janos Feb 13, 2019
e9f70c9
clef: documentation generator + docs (#19020)
holiman Feb 13, 2019
3ee09ba
swarm/storage/netstore: add fetcher cancellation on shutdown (#19049)
acud Feb 14, 2019
e6c06a1
console, internal: enforce camel case variable names (#19059)
Matthalp-zz Feb 14, 2019
7d24a73
eth/tracers: enforce camel case variable names (#19057)
Matthalp-zz Feb 14, 2019
a8ddf7a
build: avoid dput and upload with sftp directly (#19067)
fjl Feb 14, 2019
325334f
light: enforce camel case variable names (#19054)
Matthalp-zz Feb 14, 2019
ba90a4a
common/fdlimit: fix windows build (#19068)
fjl Feb 14, 2019
dcc045f
vendor: update syscalls dependency
karalabe Feb 14, 2019
fab8c5a
Merge pull request #19072 from karalabe/update-syscalls
karalabe Feb 14, 2019
2af2472
swarm/network: Saturation check for healthy networks (#19071)
holisticode Feb 14, 2019
2b75fa9
core: enforce camel case variable names (#19058)
Matthalp-zz Feb 14, 2019
9d3ea8d
vendor: pull in upstream syscall fixes for non-linux/arm64
karalabe Feb 14, 2019
e26a119
console: prefer nil slices over zero-length slices (#19076)
Matthalp-zz Feb 14, 2019
fa87929
cmd: prefer nil slices over zero-length slices (#19077)
Matthalp-zz Feb 14, 2019
7f6b05a
Merge pull request #19087 from karalabe/ios-fix-take-2
karalabe Feb 15, 2019
5b8ae78
swarm/storage: fix influxdb gc metrics report (#19102)
acud Feb 15, 2019
4f85c2b
trie: fix error in node decoding (#19111)
holiman Feb 16, 2019
12ca3b1
swarm/pss: refactoring (#19110)
gluk256 Feb 17, 2019
50b872b
p2p, swarm: fix node up races by granular locking (#18976)
frncmx Feb 18, 2019
37e5a90
vendor: update bigcache
holiman Feb 18, 2019
75a9314
travis.yml: add launchpad SSH public key (#19115)
karalabe Feb 18, 2019
c0b9c76
build: explicitly force .xz compression (old debuild picks gzip) (#19…
karalabe Feb 18, 2019
b6ce358
Merge pull request #19114 from holiman/update_bigcache
karalabe Feb 18, 2019
62d7688
cmd/swarm/swarm-smoke: Trigger chunk debug on timeout (#19101)
holisticode Feb 18, 2019
df7c461
signer/core: remove unused function (#19099)
Matthalp-zz Feb 18, 2019
a1f366e
core/vm: update annotation (#19050)
needkane Feb 18, 2019
3930f37
core: remove unused function (#19097)
Matthalp-zz Feb 18, 2019
7b3e3d5
node: prefer nil slices over zero-length slices (#19083)
Matthalp-zz Feb 18, 2019
f57c80d
metrics: remove redundant type specifiers (#19090)
Matthalp-zz Feb 18, 2019
2a0e1bb
crypto/ecies: remove unused function (#19096)
Matthalp-zz Feb 18, 2019
3c62f96
eth: remove redundant parentheses (#19108)
Matthalp-zz Feb 18, 2019
d88c6ce
swarm: Reinstate Pss Protocol add call through swarm service (#19117)
nolash Feb 18, 2019
c5eccae
core/vm: remove unused constants
matthalp Feb 15, 2019
9c7e65c
accounts: fix typos from the `SignData` merge (#19119)
gballet Feb 19, 2019
4a090a1
accounts/abi: fix error message format (#19122)
htkao Feb 19, 2019
c283d9b
signer/core: handle JSON unmarshal error (#19123)
htkao Feb 19, 2019
26d3a8c
rpc: skip websocket origin check if there is no origin header
fjl Feb 19, 2019
d225624
rpc: fixup change to not verify websocket origin (#19128)
fjl Feb 19, 2019
f7f6a46
eth, node: use APPDATA env to support cygwin/msys correctly (#17786)
hackmod Feb 19, 2019
b5e5b35
crypto: fix build when CGO_ENABLED=0 (#19121)
jeremyschlatter Feb 19, 2019
bf42535
core: remove redundant parentheses (#19106)
Matthalp-zz Feb 19, 2019
f1537b7
p2p/discover: make maximum packet size a constant (#19061)
Matthalp-zz Feb 19, 2019
cf147c7
p2p/discover: remove unused function
fjl Feb 19, 2019
57f959a
p2p/enode: use localItemKey for local sequence number
fjl Feb 19, 2019
514a947
trie: prefer nil slices over zero-length slices (#19084)
Matthalp-zz Feb 19, 2019
8af6c9e
eth: extract check for tracing transaction in block file (#19107)
Matthalp-zz Feb 19, 2019
2e8a5e5
core/vm: remove unused constants (#19095)
karalabe Feb 19, 2019
d3ccedc
p2p/simulations: enforce camel case variable names (#19053)
Matthalp-zz Feb 19, 2019
f49f95e
accounts/abi: mutex lock in TransactionByHash and code cleanup (#19133)
Feb 20, 2019
ba2dfa5
swarm/network/stream: fix a goroutine leak in Registry (#19139)
janos Feb 20, 2019
460d206
swarm/network: Use actual remote peer ip in underlay (#19137)
nolash Feb 20, 2019
d36e974
swarm/network: Keep span across roundtrip (#19140)
nolash Feb 20, 2019
e38b227
Ci race detector handle failing tests (#19143)
frncmx Feb 20, 2019
9d5e10f
cmd/swarm/global-store: use kill instead interrupt in tests (#19142)
janos Feb 20, 2019
fbedf62
swarm/storage: fix loop bound for database cleanup (#19085)
Matthalp-zz Feb 21, 2019
628a0bd
common/fdlimit: Fix compilation error in freebsd, Raise() returns uin…
enriquefynn Feb 21, 2019
8577b5b
core: more tests for sidechain import, fixes #19105 (#19113)
holiman Feb 21, 2019
7fd0cca
core: remove unnecessary fields in logs, receipts and tx lookups (#17…
rjl493456442 Feb 21, 2019
b9808e3
swarm/version: bump to v0.3.12 unstable
karalabe Feb 21, 2019
836c846
swarm/network/master: protect SetNextBatch iterator after close (#19147)
janos Feb 21, 2019
c8da76e
swarm/shed: fix a deadlock in meter function (#19149)
janos Feb 21, 2019
1993227
.travis.yml: make build independent of repo name (#17607)
trung Feb 22, 2019
d9adcd3
travis.yml: add race detector job for Swarm (#19148)
frncmx Feb 22, 2019
02c2804
swarm: Fix localstore test deadlock with race detector (#19153)
janos Feb 22, 2019
64d10c0
swarm: mock store listings (#19157)
janos Feb 23, 2019
90b6cda
cmd,swarm: enforce camel case variable names (#19060)
Matthalp-zz Feb 24, 2019
4e87b44
swarm/pss: remove unused function (#19100)
Matthalp-zz Feb 24, 2019
81babe1
swarm/*: remove redundant type specifiers (#19089)
Matthalp-zz Feb 25, 2019
872370e
swarm/network/simulation: do not copy node mutex in UploadSnapshot (#…
janos Feb 25, 2019
7d881e4
rlp: added pooling of streams using sync (#19044)
MariusVanDerWijden Feb 25, 2019
f5f742d
containers/docker: nuke per the 1.8.0 deprecation note
karalabe Feb 25, 2019
badaf43
les: remove redundant type specifiers (#19091)
Matthalp-zz Feb 25, 2019
340a53a
swarm/pss: fix data race on HandshakeController.symKeyIndex (#19162)
janos Feb 26, 2019
c83ba9e
swarm/storage/localstore: fix tests for windows os (#19161)
janos Feb 26, 2019
647692f
build: bump PPA builders to Go 1.11
karalabe Feb 26, 2019
a42afa7
Merge pull request #19169 from karalabe/ppa-bump
karalabe Feb 26, 2019
c2b33a1
graphql: fix typos in comments (#19041)
rociiu Feb 26, 2019
c2003ed
les, les/flowcontrol: improved request serving and flow control (#18230)
zsfelfoldi Feb 26, 2019
6d652ce
Merge pull request #19164 from karalabe/nuke-old-containers
karalabe Feb 26, 2019
b7e0dec
travis, build: switch to NDK 19b, fix gomobile builds (#19171)
karalabe Feb 26, 2019
f023394
swarm/chunk: move chunk related declarations to chunk package (#19170)
janos Feb 26, 2019
7ebd2fa
vendor: update leveldb upstream which include a compaction fix (#19163)
rjl493456442 Feb 27, 2019
e43bc36
travis, appveyor, Dockerfile: upgrade to Go 1.12
SamuelMarks Feb 26, 2019
2b6158a
common/fdlimit: fix macos file descriptors for Go 1.12
karalabe Feb 27, 2019
505a49e
Merge pull request #19166 from SamuelMarks/go-1.12
karalabe Feb 27, 2019
62d9d63
swarm/network: WIP consider all nodes for healthy iteration (#19155)
nolash Feb 28, 2019
dd28ba3
node: require LocalAppData variable (#19132)
fjl Feb 28, 2019
dac7cbc
p2p/enode: use localItemKey for local sequence number (#19131)
karalabe Feb 28, 2019
1bc7f3f
core/types: fix receipt legacy decoding
karalabe Feb 28, 2019
39bd260
crypto/bn256/cloudflare: pull in upstream fix for Go 1.12 R18
karalabe Feb 28, 2019
0f41356
Merge pull request #19182 from karalabe/fix-legacy-receipt-decoding
karalabe Feb 28, 2019
3135765
Merge pull request #19183 from karalabe/bn256-arm64-go1.12-fix
karalabe Feb 28, 2019
509ea3e
build/deb: use custom cache for PPA builder
karalabe Feb 28, 2019
994326b
swarm: new snapshot files (#19185)
holisticode Feb 28, 2019
5c03baa
Merge pull request #19184 from karalabe/fix-ppa-go1.11-cache
karalabe Mar 1, 2019
696a65b
build/deb: fix PPA env var setting
karalabe Mar 1, 2019
0594deb
Merge pull request #19187 from karalabe/fix-ppa-go1.11-cache-2
karalabe Mar 1, 2019
94eca08
build: enable Ubuntu Disco Dingo PPA builds
karalabe Mar 1, 2019
4e9230e
swarm: enable p2p/discovery and disable dynamic dialling (#19189)
nonsense Mar 1, 2019
729bf36
whisper: Remove v5 (#18432)
gballet Mar 1, 2019
b797dd0
swarm/shed, swarm/storage/localstore: add LastPullSubscriptionChunk (…
janos Mar 2, 2019
f9aa1cd
Revert "swarm/network: Use actual remote peer ip in underlay (#19137)…
nonsense Mar 2, 2019
e2d322b
build: add clef to alltools and deb
holiman Mar 4, 2019
603a852
vendor: update leveldb (#19201)
rjl493456442 Mar 4, 2019
a1099bb
Merge pull request #19205 from holiman/alltools_clef
karalabe Mar 4, 2019
216bd2c
swarm/storage/localstore: fix testDB_collectGarbageWorker data race (…
janos Mar 4, 2019
81ed700
Enable longrunning tests to run (#19208)
holisticode Mar 5, 2019
34c85de
cmd/swarm/swarm-smoke: sliding window test should not time out (#19152)
acud Mar 5, 2019
15eee47
accounts: prefer nil slices over zero-length slices (#19079)
Matthalp-zz Mar 6, 2019
2f24e25
consensus/clique: fix test copy paste error, test what's documented
karalabe Mar 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
64 changes: 43 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ matrix:
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES

# These are the latest Go versions.
- os: linux
dist: trusty
sudo: required
Expand All @@ -26,8 +25,20 @@ matrix:
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES

# These are the latest Go versions.
- os: linux
dist: trusty
sudo: required
go: 1.12.x
script:
- sudo modprobe fuse
- sudo chmod 666 /dev/fuse
- sudo chown root:$USER /etc/fuse.conf
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES

- os: osx
go: 1.11.x
go: 1.12.x
script:
- echo "Increase the maximum number of open file descriptors on macOS"
- NOFILE=20480
Expand All @@ -44,7 +55,7 @@ matrix:
# This builder only tests code linters on latest version of Go
- os: linux
dist: trusty
go: 1.11.x
go: 1.12.x
env:
- lint
git:
Expand All @@ -53,10 +64,10 @@ matrix:
- go run build/ci.go lint

# This builder does the Ubuntu PPA upload
- if: type = push
- if: repo = ethereum/go-ethereum AND type = push
os: linux
dist: trusty
go: 1.11.x
go: 1.12.x
env:
- ubuntu-ppa
git:
Expand All @@ -68,15 +79,18 @@ matrix:
- debhelper
- dput
- fakeroot
- python-bzrlib
- python-paramiko
script:
- go run build/ci.go debsrc -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>" -upload ppa:ethereum/ethereum
- echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts
- go run build/ci.go debsrc -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>"

# This builder does the Linux Azure uploads
- if: type = push
- if: repo = ethereum/go-ethereum AND type = push
os: linux
dist: trusty
sudo: required
go: 1.11.x
go: 1.12.x
env:
- azure-linux
git:
Expand Down Expand Up @@ -106,12 +120,12 @@ matrix:
- go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds

# This builder does the Linux Azure MIPS xgo uploads
- if: type = push
- if: repo = ethereum/go-ethereum AND type = push
os: linux
dist: trusty
services:
- docker
go: 1.11.x
go: 1.12.x
env:
- azure-linux-mips
git:
Expand All @@ -134,7 +148,7 @@ matrix:
- go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds

# This builder does the Android Maven and Azure uploads
- if: type = push
- if: repo = ethereum/go-ethereum AND type = push
os: linux
dist: trusty
addons:
Expand All @@ -156,25 +170,24 @@ matrix:
git:
submodules: false # avoid cloning ethereum/tests
before_install:
- curl https://storage.googleapis.com/golang/go1.11.5.linux-amd64.tar.gz | tar -xz
- curl https://dl.google.com/go/go1.12.linux-amd64.tar.gz | tar -xz
- export PATH=`pwd`/go/bin:$PATH
- export GOROOT=`pwd`/go
- export GOPATH=$HOME/go
script:
# Build the Android archive and upload it to Maven Central and Azure
- curl https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip -o android-ndk-r17b.zip
- unzip -q android-ndk-r17b.zip && rm android-ndk-r17b.zip
- mv android-ndk-r17b $HOME
- export ANDROID_NDK=$HOME/android-ndk-r17b
- curl https://dl.google.com/android/repository/android-ndk-r19b-linux-x86_64.zip -o android-ndk-r19b.zip
- unzip -q android-ndk-r19b.zip && rm android-ndk-r19b.zip
- mv android-ndk-r19b $ANDROID_HOME/ndk-bundle

- mkdir -p $GOPATH/src/github.com/ethereum
- ln -s `pwd` $GOPATH/src/github.com/ethereum
- ln -s `pwd` $GOPATH/src/github.com/ethereum/go-ethereum
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -deploy https://oss.sonatype.org -upload gethstore/builds

# This builder does the OSX Azure, iOS CocoaPods and iOS Azure uploads
- if: type = push
- if: repo = ethereum/go-ethereum AND type = push
os: osx
go: 1.11.x
go: 1.12.x
env:
- azure-osx
- azure-ios
Expand All @@ -201,13 +214,22 @@ matrix:
- go run build/ci.go xcode -signer IOS_SIGNING_KEY -deploy trunk -upload gethstore/builds

# This builder does the Azure archive purges to avoid accumulating junk
- if: type = cron
- if: repo = ethereum/go-ethereum AND type = cron
os: linux
dist: trusty
go: 1.11.x
go: 1.12.x
env:
- azure-purge
git:
submodules: false # avoid cloning ethereum/tests
script:
- go run build/ci.go purge -store gethstore/builds -days 14

- name: Race Detector for Swarm
if: repo = ethersphere/go-ethereum
os: linux
dist: trusty
go: 1.12.x
git:
submodules: false # avoid cloning ethereum/tests
script: ./build/travis_keepalive.sh go test -v -timeout 20m -race ./swarm...
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.11-alpine as builder
FROM golang:1.12-alpine as builder

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

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.11-alpine as builder
FROM golang:1.12-alpine as builder

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

Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
// returns nil if none found
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
if len(sigdata) < 4 {
return nil, fmt.Errorf("data too short (% bytes) for abi method lookup", len(sigdata))
return nil, fmt.Errorf("data too short (%d bytes) for abi method lookup", len(sigdata))
}
for _, method := range abi.Methods {
if bytes.Equal(method.Id(), sigdata[:4]) {
Expand Down
19 changes: 19 additions & 0 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common
return receipt, nil
}

// TransactionByHash checks the pool of pending transactions in addition to the
// blockchain. The isPending return value indicates whether the transaction has been
// mined yet. Note that the transaction may not be part of the canonical chain even if
// it's not pending.
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
b.mu.Lock()
defer b.mu.Unlock()

tx := b.pendingBlock.Transaction(txHash)
if tx != nil {
return tx, true, nil
}
tx, _, _, _ = rawdb.ReadTransaction(b.database, txHash)
if tx != nil {
return tx, false, nil
}
return nil, false, ethereum.NotFound
}

// PendingCodeAt returns the code associated with an account in the pending state.
func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
b.mu.Lock()
Expand Down
82 changes: 82 additions & 0 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright 2019 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 backends_test

import (
"context"
"math/big"
"testing"

ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
)

func TestSimulatedBackend(t *testing.T) {
var gasLimit uint64 = 8000029
key, _ := crypto.GenerateKey() // nolint: gosec
auth := bind.NewKeyedTransactor(key)
genAlloc := make(core.GenesisAlloc)
genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)}

sim := backends.NewSimulatedBackend(genAlloc, gasLimit)

// should return an error if the tx is not found
txHash := common.HexToHash("2")
_, isPending, err := sim.TransactionByHash(context.Background(), txHash)

if isPending {
t.Fatal("transaction should not be pending")
}
if err != ethereum.NotFound {
t.Fatalf("err should be `ethereum.NotFound` but received %v", err)
}

// generate a transaction and confirm you can retrieve it
code := `6060604052600a8060106000396000f360606040526008565b00`
var gas uint64 = 3000000
tx := types.NewContractCreation(0, big.NewInt(0), gas, big.NewInt(1), common.FromHex(code))
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, key)

err = sim.SendTransaction(context.Background(), tx)
if err != nil {
t.Fatal("error sending transaction")
}

txHash = tx.Hash()
_, isPending, err = sim.TransactionByHash(context.Background(), txHash)
if err != nil {
t.Fatalf("error getting transaction with hash: %v", txHash.String())
}
if !isPending {
t.Fatal("transaction should have pending status")
}

sim.Commit()
tx, isPending, err = sim.TransactionByHash(context.Background(), txHash)
if err != nil {
t.Fatalf("error getting transaction with hash: %v", txHash.String())
}
if isPending {
t.Fatal("transaction should not have pending status")
}

}
16 changes: 16 additions & 0 deletions accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2019 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 bind_test

import (
Expand Down
4 changes: 2 additions & 2 deletions accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type Wallet interface {
// a password to decrypt the account, or a PIN code o verify the transaction),
// an AuthNeededError instance will be returned, containing infos for the user
// about which fields or actions are needed. The user may retry by providing
// the needed details via SignHashWithPassphrase, or by other means (e.g. unlock
// the needed details via SignDataWithPassphrase, or by other means (e.g. unlock
// the account in a keystore).
SignData(account Account, mimeType string, data []byte) ([]byte, error)

Expand All @@ -114,7 +114,7 @@ type Wallet interface {
// should never echo the mimetype or return the mimetype in the error-response
SignDataWithPassphrase(account Account, passphrase, mimeType string, data []byte) ([]byte, error)

// Signtext requests the wallet to sign the hash of a given piece of data, prefixed
// SignText requests the wallet to sign the hash of a given piece of data, prefixed
// by the Ethereum prefix scheme
// It looks up the account specified either solely via its address contained within,
// or optionally with the aid of any location metadata from the embedded URL field.
Expand Down
39 changes: 22 additions & 17 deletions accounts/external/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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/crypto"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -154,13 +153,31 @@ func (api *ExternalSigner) signHash(account accounts.Account, hash []byte) ([]by

// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
func (api *ExternalSigner) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
// TODO! Replace this with a call to clef SignData with correct mime-type for Clique, once we
// have that in place
return api.signHash(account, crypto.Keccak256(data))
var res hexutil.Bytes
var signAddress = common.NewMixedcaseAddress(account.Address)
if err := api.client.Call(&res, "account_signData",
mimeType,
&signAddress, // Need to use the pointer here, because of how MarshalJSON is defined
hexutil.Encode(data)); err != nil {
return nil, err
}
// If V is on 27/28-form, convert to to 0/1 for Clique
if mimeType == accounts.MimetypeClique && (res[64] == 27 || res[64] == 28) {
res[64] -= 27 // Transform V from 27/28 to 0/1 for Clique use
}
return res, nil
}

func (api *ExternalSigner) SignText(account accounts.Account, text []byte) ([]byte, error) {
return api.signHash(account, accounts.TextHash(text))
var res hexutil.Bytes
var signAddress = common.NewMixedcaseAddress(account.Address)
if err := api.client.Call(&res, "account_signData",
accounts.MimetypeTextPlain,
&signAddress, // Need to use the pointer here, because of how MarshalJSON is defined
hexutil.Encode(text)); err != nil {
return nil, err
}
return res, nil
}

func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
Expand Down Expand Up @@ -202,18 +219,6 @@ func (api *ExternalSigner) listAccounts() ([]common.Address, error) {
return res, nil
}

func (api *ExternalSigner) signCliqueBlock(a common.Address, rlpBlock hexutil.Bytes) (hexutil.Bytes, error) {
var sig hexutil.Bytes
if err := api.client.Call(&sig, "account_signData", core.ApplicationClique.Mime, a, rlpBlock); err != nil {
return nil, err
}
if sig[64] != 27 && sig[64] != 28 {
return nil, fmt.Errorf("invalid Ethereum signature (V is not 27 or 28)")
}
sig[64] -= 27 // Transform V from 27/28 to 0/1 for Clique use
return sig, nil
}

func (api *ExternalSigner) pingVersion() (string, error) {
var v string
if err := api.client.Call(&v, "account_version"); err != nil {
Expand Down
Loading