Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Merge go-ethereum updates into 2.5.3 #69

Merged
merged 63 commits into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
03ec3fe
swarm/api: bug fix exact match for manifest
Oct 18, 2017
5aa3eac
eth/downloader: minor comments cleanup (#15495)
jtakalai Nov 16, 2017
4013e23
rpc: allow dumb empty requests for AWS health checks
karalabe Nov 16, 2017
448abb6
accounts/keystore: change modtime for test cases to be bigger than 1sec.
nonsense Nov 16, 2017
b645256
accounts/keystore: comments above time.Sleep
nonsense Nov 16, 2017
87f5b41
Merge pull request #15496 from karalabe/rpc-get-healthcheck
karalabe Nov 16, 2017
b019018
core/vm, internal/ethapi: tracer no full storage, nicer json output (…
karalabe Nov 16, 2017
c5b8569
rpc: disallow PUT and DELETE on HTTP (#15501)
Nov 17, 2017
3c6b9c5
rpc: minor cleanups to RPC PR
karalabe Nov 17, 2017
c8b7ea1
Merge pull request #15505 from karalabe/fix-rpc-pr
karalabe Nov 17, 2017
c7b0abf
Added output to clarify gas calculation in txpool.inspect
Nov 17, 2017
e39ca5e
Merge pull request #15506 from tsarpaul/master
karalabe Nov 17, 2017
2ab5c11
README: fix typo
Nov 17, 2017
0dbf55d
Merge pull request #15509 from tbm/typo
karalabe Nov 17, 2017
f5091e5
internal/ethapi: fix js tracer to properly decode addresses (#15297)
viktor32 Nov 18, 2017
8a79836
accounts: list, then subscribe (sub requires active reader)
karalabe Nov 20, 2017
6810674
accounts/keystore: lock file cache during scan, minor polish
karalabe Nov 20, 2017
0f184d3
Merge pull request #15526 from karalabe/accounts-new
karalabe Nov 20, 2017
e2b3a23
accounts/keystore: Ignore initial trigger of rescan-event
holiman Nov 20, 2017
7b95cca
Merge pull request #15527 from holiman/bump_watch
karalabe Nov 20, 2017
72ed186
eth, internal: Implement getModifiedAccountsBy(Hash|Number) using tri…
Arachnid Nov 20, 2017
b4f2e4d
.github: add CODEOWNERS (#15507)
fjl Nov 20, 2017
bedf6f4
cmd/geth: make geth account new faster with many keys (#15529)
holiman Nov 20, 2017
4bb3c89
params: release v1.7.3 stable
karalabe Nov 21, 2017
0056658
VERSION, params: begin 1.8.0 release cycle
karalabe Nov 21, 2017
8c78449
cmd/puppeth: reorganize stats reports to make it readable
karalabe Oct 19, 2017
7b258c9
cmd/puppeth: concurrent server dials and health checks
karalabe Oct 19, 2017
da3b9f8
cmd/puppeth: support deploying services with forced rebuilds
karalabe Oct 19, 2017
9e09525
cmd/puppeth: mount ethash dir from the host to cache DAGs
karalabe Oct 19, 2017
1e0c336
cmd/puppeth: etherchain light block explorer for PoW nets
karalabe Oct 20, 2017
b5cf603
cmd/puppeth: add support for deploying web wallets
karalabe Oct 23, 2017
51a86f6
cmd/faucet: protocol relative websockets, noauth mode
karalabe Oct 23, 2017
6eb38e0
cmd/puppeth: fix dashboard iframes, extend with new services
karalabe Oct 23, 2017
7abf968
cmd/puppeth: skip genesis custom extra-data
karalabe Oct 26, 2017
80be5e5
cmd/puppeth: store genesis locally to persist restarts
karalabe Oct 26, 2017
ffc12f6
cmd/puppeth: simplifications and pre-built docker images
karalabe Oct 27, 2017
327dcd3
cmd/faucet, cmd/puppeth: drop GitHub support at official request
karalabe Oct 29, 2017
7f40ae7
cmd/puppeth: switch over to upstream alltools docker image
karalabe Nov 13, 2017
b169a30
cmd/puppeth: fix unconvert linters
karalabe Nov 21, 2017
41ef34a
les: use modified default txpool config to avoid creating journal file
rjl493456442 Nov 21, 2017
049797d
Merge pull request #15521 from rjl493456442/clean_tx_journal
karalabe Nov 21, 2017
cc3ca63
build: fix typo in comment
zoenolan Nov 21, 2017
35801f9
Merge pull request #15538 from zoenolan/patch-1
karalabe Nov 23, 2017
a3a2c6b
cmd/puppeth: fix typos and review suggestions
karalabe Nov 23, 2017
f9569f3
Merge pull request #15390 from karalabe/puppeth-devcon3
karalabe Nov 24, 2017
edc3e0e
cmd/puppeth: fix typo in comment (#15539)
zoenolan Nov 24, 2017
9ff9d04
all: fix code comment typos (#15547)
ricardohsd Nov 24, 2017
989fb44
internal/ethapi: avoid recreating JavaScript tracer wrappers
karalabe Nov 24, 2017
5dea0f2
core/state: copy trie too, not just content
karalabe Nov 24, 2017
b0056f5
Merge pull request #15552 from karalabe/javascript-tracers-nowrap
karalabe Nov 24, 2017
f14047d
cmd, consensus, eth: split ethash related config to it own (#15520)
rjl493456442 Nov 24, 2017
0981d2e
Merge pull request #15498 from nonsense/account_cache_modtime_test_fix
karalabe Nov 24, 2017
f0ac925
Merge pull request #15329 from holisticode/exact-match-fix
karalabe Nov 24, 2017
de37e08
Merge pull request #15549 from karalabe/statedb-copy
karalabe Nov 24, 2017
e4c9fd2
cmd/utils: disallow --lightserv in light mode (#15514)
Nov 24, 2017
91553f9
Merge go-ethereum upstream into 2.5.3
5chdn Nov 27, 2017
c1b3fa0
Add UBI fork block to accepted protocol changes
5chdn Nov 27, 2017
989a999
Use gmc as account command
5chdn Nov 27, 2017
97baa19
Remove merge left-overs.
5chdn Nov 27, 2017
1845b6e
Prepare puppeth for ubi
5chdn Nov 27, 2017
2e26520
Prepare consensus for byzantium
5chdn Nov 27, 2017
a90078f
Remove merge left-overs :oops:
5chdn Dec 1, 2017
5cf14b6
Ignore git merge temp files
5chdn Dec 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

accounts/usbwallet @karalabe
consensus @karalabe
core/ @karalabe @holiman
eth/ @karalabe
mobile/ @karalabe
p2p/ @fjl @zsfelfoldi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ profile.cov
/dashboard/assets/node_modules
/dashboard/assets/stats.json
/dashboard/assets/public/bundle.js

# git merge
*.orig
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ instance for mining, run it with all your usual flags, extended by:
$ gmc <usual-flags> --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000
```

Which will start mining bocks and transactions on a single CPU thread, crediting all proceedings to
Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to
the account specified by `--etherbase`. You can further tune the mining by changing the default gas
limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`).

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.5.3
113 changes: 22 additions & 91 deletions accounts/keystore/account_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -75,13 +74,6 @@ type accountCache struct {
fileC fileCache
}

// fileCache is a cache of files seen during scan of keystore
type fileCache struct {
all *set.SetNonTS // list of all files
mtime time.Time // latest mtime seen
mu sync.RWMutex
}

func newAccountCache(keydir string) (*accountCache, chan struct{}) {
ac := &accountCache{
keydir: keydir,
Expand Down Expand Up @@ -236,66 +228,22 @@ func (ac *accountCache) close() {
ac.mu.Unlock()
}

// scanFiles performs a new scan on the given directory, compares against the already
// cached filenames, and returns file sets: new, missing , modified
func (fc *fileCache) scanFiles(keyDir string) (set.Interface, set.Interface, set.Interface, error) {
t0 := time.Now()
files, err := ioutil.ReadDir(keyDir)
t1 := time.Now()
if err != nil {
return nil, nil, nil, err
}
fc.mu.RLock()
prevMtime := fc.mtime
fc.mu.RUnlock()

filesNow := set.NewNonTS()
moddedFiles := set.NewNonTS()
var newMtime time.Time
for _, fi := range files {
modTime := fi.ModTime()
path := filepath.Join(keyDir, fi.Name())
if skipKeyFile(fi) {
log.Trace("Ignoring file on account scan", "path", path)
continue
}
filesNow.Add(path)
if modTime.After(prevMtime) {
moddedFiles.Add(path)
}
if modTime.After(newMtime) {
newMtime = modTime
}
}
t2 := time.Now()

fc.mu.Lock()
// Missing = previous - current
missing := set.Difference(fc.all, filesNow)
// New = current - previous
newFiles := set.Difference(filesNow, fc.all)
// Modified = modified - new
modified := set.Difference(moddedFiles, newFiles)
fc.all = filesNow
fc.mtime = newMtime
fc.mu.Unlock()
t3 := time.Now()
log.Debug("FS scan times", "list", t1.Sub(t0), "set", t2.Sub(t1), "diff", t3.Sub(t2))
return newFiles, missing, modified, nil
}

// scanAccounts checks if any changes have occurred on the filesystem, and
// updates the account cache accordingly
func (ac *accountCache) scanAccounts() error {
newFiles, missingFiles, modified, err := ac.fileC.scanFiles(ac.keydir)
t1 := time.Now()
// Scan the entire folder metadata for file changes
creates, deletes, updates, err := ac.fileC.scan(ac.keydir)
if err != nil {
log.Debug("Failed to reload keystore contents", "err", err)
return err
}
if creates.Size() == 0 && deletes.Size() == 0 && updates.Size() == 0 {
return nil
}
// Create a helper method to scan the contents of the key files
var (
buf = new(bufio.Reader)
keyJSON struct {
buf = new(bufio.Reader)
key struct {
Address string `json:"address"`
}
)
Expand All @@ -308,9 +256,9 @@ func (ac *accountCache) scanAccounts() error {
defer fd.Close()
buf.Reset(fd)
// Parse the address.
keyJSON.Address = ""
err = json.NewDecoder(buf).Decode(&keyJSON)
addr := common.HexToAddress(keyJSON.Address)
key.Address = ""
err = json.NewDecoder(buf).Decode(&key)
addr := common.HexToAddress(key.Address)
switch {
case err != nil:
log.Debug("Failed to decode keystore key", "path", path, "err", err)
Expand All @@ -321,47 +269,30 @@ func (ac *accountCache) scanAccounts() error {
}
return nil
}
// Process all the file diffs
start := time.Now()

for _, p := range newFiles.List() {
path, _ := p.(string)
a := readAccount(path)
if a != nil {
for _, p := range creates.List() {
if a := readAccount(p.(string)); a != nil {
ac.add(*a)
}
}
for _, p := range missingFiles.List() {
path, _ := p.(string)
ac.deleteByFile(path)
for _, p := range deletes.List() {
ac.deleteByFile(p.(string))
}

for _, p := range modified.List() {
path, _ := p.(string)
a := readAccount(path)
for _, p := range updates.List() {
path := p.(string)
ac.deleteByFile(path)
if a != nil {
if a := readAccount(path); a != nil {
ac.add(*a)
}
}

t2 := time.Now()
end := time.Now()

select {
case ac.notify <- struct{}{}:
default:
}
log.Trace("Handled keystore changes", "time", t2.Sub(t1))

log.Trace("Handled keystore changes", "time", end.Sub(start))
return nil
}

func skipKeyFile(fi os.FileInfo) bool {
// Skip editor backups and UNIX-style hidden files.
if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
return true
}
// Skip misc special files, directories (yes, symlinks too).
if fi.IsDir() || fi.Mode()&os.ModeType != 0 {
return true
}
return false
}
12 changes: 11 additions & 1 deletion accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestWatchNewFile(t *testing.T) {

// Ensure the watcher is started before adding any files.
ks.Accounts()
time.Sleep(200 * time.Millisecond)
time.Sleep(1000 * time.Millisecond)

// Move in the files.
wantAccounts := make([]accounts.Account, len(cachetestAccounts))
Expand Down Expand Up @@ -349,6 +349,9 @@ func TestUpdatedKeyfileContents(t *testing.T) {
return
}

// needed so that modTime of `file` is different to its current value after forceCopyFile
time.Sleep(1000 * time.Millisecond)

// Now replace file contents
if err := forceCopyFile(file, cachetestAccounts[1].URL.Path); err != nil {
t.Fatal(err)
Expand All @@ -362,6 +365,9 @@ func TestUpdatedKeyfileContents(t *testing.T) {
return
}

// needed so that modTime of `file` is different to its current value after forceCopyFile
time.Sleep(1000 * time.Millisecond)

// Now replace file contents again
if err := forceCopyFile(file, cachetestAccounts[2].URL.Path); err != nil {
t.Fatal(err)
Expand All @@ -374,6 +380,10 @@ func TestUpdatedKeyfileContents(t *testing.T) {
t.Error(err)
return
}

// needed so that modTime of `file` is different to its current value after ioutil.WriteFile
time.Sleep(1000 * time.Millisecond)

// Now replace file contents with crap
if err := ioutil.WriteFile(file, []byte("foo"), 0644); err != nil {
t.Fatal(err)
Expand Down
102 changes: 102 additions & 0 deletions accounts/keystore/file_cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2017 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 keystore

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"sync"
"time"

"github.com/ethereum/go-ethereum/log"
set "gopkg.in/fatih/set.v0"
)

// fileCache is a cache of files seen during scan of keystore.
type fileCache struct {
all *set.SetNonTS // Set of all files from the keystore folder
lastMod time.Time // Last time instance when a file was modified
mu sync.RWMutex
}

// scan performs a new scan on the given directory, compares against the already
// cached filenames, and returns file sets: creates, deletes, updates.
func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Interface, error) {
t0 := time.Now()

// List all the failes from the keystore folder
files, err := ioutil.ReadDir(keyDir)
if err != nil {
return nil, nil, nil, err
}
t1 := time.Now()

fc.mu.Lock()
defer fc.mu.Unlock()

// Iterate all the files and gather their metadata
all := set.NewNonTS()
mods := set.NewNonTS()

var newLastMod time.Time
for _, fi := range files {
// Skip any non-key files from the folder
path := filepath.Join(keyDir, fi.Name())
if skipKeyFile(fi) {
log.Trace("Ignoring file on account scan", "path", path)
continue
}
// Gather the set of all and fresly modified files
all.Add(path)

modified := fi.ModTime()
if modified.After(fc.lastMod) {
mods.Add(path)
}
if modified.After(newLastMod) {
newLastMod = modified
}
}
t2 := time.Now()

// Update the tracked files and return the three sets
deletes := set.Difference(fc.all, all) // Deletes = previous - current
creates := set.Difference(all, fc.all) // Creates = current - previous
updates := set.Difference(mods, creates) // Updates = modified - creates

fc.all, fc.lastMod = all, newLastMod
t3 := time.Now()

// Report on the scanning stats and return
log.Debug("FS scan times", "list", t1.Sub(t0), "set", t2.Sub(t1), "diff", t3.Sub(t2))
return creates, deletes, updates, nil
}

// skipKeyFile ignores editor backups, hidden files and folders/symlinks.
func skipKeyFile(fi os.FileInfo) bool {
// Skip editor backups and UNIX-style hidden files.
if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
return true
}
// Skip misc special files, directories (yes, symlinks too).
if fi.IsDir() || fi.Mode()&os.ModeType != 0 {
return true
}
return false
}
7 changes: 7 additions & 0 deletions accounts/keystore/keystore_passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ package keystore
import (
"bytes"
"crypto/aes"
crand "crypto/rand"
"crypto/sha256"
"encoding/hex"
"encoding/json"
Expand Down Expand Up @@ -90,6 +91,12 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string)
return key, nil
}

// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP}, crand.Reader, auth)
return a.Address, err
}

func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) error {
keyjson, err := EncryptKey(key, auth, ks.scryptN, ks.scryptP)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion accounts/keystore/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ func (w *watcher) loop() {
// When an event occurs, the reload call is delayed a bit so that
// multiple events arriving quickly only cause a single reload.
var (
debounce = time.NewTimer(0)
debounceDuration = 500 * time.Millisecond
rescanTriggered = false
debounce = time.NewTimer(0)
)
// Ignore initial trigger
if !debounce.Stop() {
<-debounce.C
}
defer debounce.Stop()
for {
select {
Expand Down
Loading