Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge branch 'upstream/master' into fix/schroedinger-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tzdybal committed May 3, 2018
2 parents 40a8e56 + b18a737 commit 5b7b2d7
Show file tree
Hide file tree
Showing 82 changed files with 54,152 additions and 112,359 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ deploy_steps: &deploy_steps
export PATH=$PATH:$HOME/.cargo/bin:$HOME/janusbin
cd $GOPATH/src/github.com/ethereumproject/go-ethereum
cp $GOPATH/bin/geth ./
export VERSION=`janus version -format TAG_OR_NIGHTLY`
./geth version | awk '/^Version: /{if (ENVIRON["VERSION"] != $2){printf "Expected: \"%s\", got \"%s\"\n",ENVIRON["VERSION"], $2; exit 1}}'
./scripts/deploy.sh gcloud-circleci.json.enc
unit_tests_steps: &unit_tests_steps
Expand Down
9 changes: 5 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,7 @@
name = "github.com/ethereumproject/benchmark"

[[constraint]]
branch = "master"
name = "github.com/fatih/color"
name = "github.com/fatih/color"
# TODO(tzdybal): monitor https://github.com/fatih/color/pull/87
source = "github.com/achilleas-k/color"
branch = "expose-colorised-stderr"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Linux Build Status](https://travis-ci.org/ethereumproject/go-ethereum.svg?branch=master)](https://travis-ci.org/ethereumproject/go-ethereum)
[![MacOS Build Status](https://circleci.com/gh/ethereumproject/go-ethereum/tree/master.svg?style=shield)](https://circleci.com/gh/ethereumproject/go-ethereum/tree/master)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/ethereumproject/go-ethereum?svg=true)](https://ci.appveyor.com/project/splix/go-ethereum)
[![Go Report Card](https://goreportcard.com/badge/github.com/ethereumproject/go-ethereum)](https://goreportcard.com/report/github.com/ethereumproject/go-ethereum)
[![API Reference](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
)](https://godoc.org/github.com/ethereumproject/go-ethereum)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereumproject/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
Expand Down Expand Up @@ -280,6 +281,7 @@ The external chain configuration file specifies valid settings for the following
| `genesis` | Determines __genesis state__. If running the node for the first time, it will write the genesis block. If configuring an existing chain database with a different genesis block, it will overwrite it. |
| `chainConfig` | Determines configuration for fork-based __protocol upgrades__, ie _EIP-150_, _EIP-155_, _EIP-160_, _ECIP-1010_, etc ;-). Subkeys are `forks` and `badHashes`. |
| `bootstrap` | _Optional_. Determines __bootstrap nodes__ in [enode format](https://github.com/ethereumproject/wiki/wiki/enode-url-format). |
| `include` | _Optional_. Other configuration files to include. Paths can be relative (to the config file with `include` field, or absolute). Each of configuration files has the same structure as "main" configuration. Included files are processed after the "main" configuration in the same order as specified in the array; values processed later overwrite the previously defined ones. |


*Fields `name`, `state.startingNonce`, and `consensus` are optional. Geth will panic if any required field is missing, invalid, or in conflict with another flag. This renders `--chain` __incompatible__ with `--testnet`. It remains __compatible__ with `--data-dir`.*
Expand Down
4 changes: 2 additions & 2 deletions accounts/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (ac *addrCache) find(a Account) (Account, error) {
return matches[i], nil
}
}
if (a.Address == common.Address{}) {
if a.Address.IsEmpty() {
return Account{}, ErrNoMatch
}
}
Expand Down Expand Up @@ -239,7 +239,7 @@ func (ac *addrCache) scan() ([]Account, error) {
switch {
case err != nil:
glog.V(logger.Debug).Infof("can't decode key %s: %v", path, err)
case (keyJSON.Address == common.Address{}):
case keyJSON.Address.IsEmpty():
glog.V(logger.Debug).Infof("can't decode key %s: missing or zero address", path)
default:
addrs = append(addrs, Account{Address: keyJSON.Address, File: path})
Expand Down
4 changes: 2 additions & 2 deletions accounts/cachedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (cdb *cacheDB) find(a Account) (Account, error) {
return acc, e
}
// no other possible way
if (a.Address == common.Address{}) {
if a.Address.IsEmpty() {
return Account{}, ErrNoMatch
}
}
Expand Down Expand Up @@ -498,7 +498,7 @@ func processKeyFile(wg *sync.WaitGroup, path string, fi os.FileInfo, i int, numF
case err != nil:
glog.V(logger.Debug).Infof("(%v/%v) can't decode key %s: %v", i, numFiles, path, err)
errs <- err
case (keyJSON.Address == common.Address{}):
case keyJSON.Address.IsEmpty():
glog.V(logger.Debug).Infof("(%v/%v) can't decode key %s: missing or zero address", i, numFiles, path)
errs <- fmt.Errorf("(%v/%v) can't decode key %s: missing or zero address", i, numFiles, path)
default:
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ build_script:
- go test -tags="sputnikvm deterministic" ./...
- schroedinger.exe -t 5 -f .\schroedinger-tests.txt
- go build -tags=sputnikvm -ldflags "-X main.Version=%VERSION%" github.com/ethereumproject/go-ethereum/cmd/geth
- .\geth.exe version | findstr %VERSION% || echo "Wrong version number, %VERSION% expected" && exit 1
- ps: >-
.\geth.exe version | Where {$_ -match "^Version: "} | %{$actual=($_ -split "\s+")[1];If($actual -ne $env:VERSION){"Expected: `"$env:VERSION`", got: `"$ACTUAL`""; exit 1}}
- 7z a geth-classic-win64-%VERSION%.zip geth.exe
before_deploy:
# Set up GCP upload.
Expand Down
6 changes: 4 additions & 2 deletions cmd/geth/accountcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ geth account import <keyfile>
Usage: "Build persistent account index",
Description: `
geth --index-accounts account index
geth account index
Create keystore directory index cache database (keystore/accounts.db),
which is relevant for use with large amounts of key files (>10,000).
Expand All @@ -197,7 +197,9 @@ geth --index-accounts account index
func accountIndex(ctx *cli.Context) error {
n := aliasableName(AccountsIndexFlag.Name, ctx)
if !ctx.GlobalBool(n) {
log.Fatalf("Use: $ geth --%v account index\n (missing '%v' flag)", n, n)
if e := ctx.GlobalSet(n, "true"); e != nil {
log.Fatal("err set flag", e)
}
}
am := MakeAccountManager(ctx)
errs := am.BuildIndexDB()
Expand Down
146 changes: 146 additions & 0 deletions cmd/geth/build_atxi_cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package main

import (
"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/core/types"
"github.com/ethereumproject/go-ethereum/ethdb"
"github.com/ethereumproject/go-ethereum/logger"
"github.com/ethereumproject/go-ethereum/logger/glog"
"gopkg.in/urfave/cli.v1"
"os"
"time"
)

var buildAddrTxIndexCommand = cli.Command{
Action: buildAddrTxIndexCmd,
Name: "atxi-build",
Usage: "Generate index for transactions by address",
Description: `
Builds an index for transactions by address.
The command is idempotent; it will not hurt to run multiple times on the same range.
If run without --start flag, the command makes use of a persistent placeholder, so you can
run the command on multiple occasions and pick up indexing progress where the last session
left off.
To enable address-transaction indexing during block sync and import, use the '--atxi' flag.
`,
Flags: []cli.Flag{
cli.IntFlag{
Name: "start",
Usage: "Block number at which to begin building index",
},
cli.IntFlag{
Name: "stop",
Usage: "Block number at which to stop building index",
},
cli.IntFlag{
Name: "step",
Usage: "Step increment for batching. Higher number requires more mem, but may be faster",
Value: 10000,
},
},
}

func buildAddrTxIndexCmd(ctx *cli.Context) error {

// Divide global cache availability equally between chaindata (pre-existing blockdata) and
// address-transaction database. This ratio is arbitrary and could potentially be optimized or delegated to be user configurable.
ethdb.SetCacheRatio("chaindata", 0.5)
ethdb.SetHandleRatio("chaindata", 1)
ethdb.SetCacheRatio("indexes", 0.5)
ethdb.SetHandleRatio("indexes", 1)

startIndex := uint64(ctx.Int("start"))
var stopIndex uint64

indexDb := MakeIndexDatabase(ctx)
if indexDb == nil {
glog.Fatalln("indexes db is nil")
}
defer indexDb.Close()

// Use persistent placeholder in case start not spec'd
if !ctx.IsSet("start") {
startIndex = core.GetATXIBookmark(indexDb)
}

bc, chainDB := MakeChain(ctx)
if bc == nil || chainDB == nil {
glog.Fatalln("bc or cdb is nil")
}
defer chainDB.Close()

stopIndex = uint64(ctx.Int("stop"))
if stopIndex == 0 {
stopIndex = bc.CurrentBlock().NumberU64()
if n := bc.CurrentFastBlock().NumberU64(); n > stopIndex {
stopIndex = n
}
}

if stopIndex < startIndex {
glog.Fatalln("start must be prior to (smaller than) or equal to stop, got start=", startIndex, "stop=", stopIndex)
}
if startIndex == stopIndex {
glog.D(logger.Error).Infoln("atxi is up to date, exiting")
os.Exit(0)
}

var block *types.Block
blockIndex := startIndex
block = bc.GetBlockByNumber(blockIndex)
if block == nil {
glog.Fatalln(blockIndex, "block is nil")
}

var inc = uint64(ctx.Int("step"))
startTime := time.Now()
totalTxCount := uint64(0)
glog.D(logger.Error).Infoln("Address/tx indexing (atxi) start:", startIndex, "stop:", stopIndex, "step:", inc, "| This may take a while.")
breaker := false
for i := startIndex; i <= stopIndex; i = i + inc {
if i+inc > stopIndex {
inc = stopIndex - i
breaker = true
}

stepStartTime := time.Now()

// It may seem weird to pass i, i+inc, and inc, but its just a "coincidence"
// The function could accepts a smaller step for batch putting (in this case, inc),
// or a larger stopBlock (i+inc), but this is just how this cmd is using the fn now
// We could mess around a little with exploring batch optimization...
txsCount, err := bc.WriteBlockAddrTxIndexesBatch(indexDb, i, i+inc, inc)
if err != nil {
return err
}
totalTxCount += uint64(txsCount)

if err := core.SetATXIBookmark(indexDb, i+inc); err != nil {
glog.Fatalln(err)
}

glog.D(logger.Error).Infof("atxi-build: block %d / %d txs: %d took: %v %.2f bps %.2f txps", i+inc, stopIndex, txsCount, time.Since(stepStartTime).Round(time.Millisecond), float64(inc)/time.Since(stepStartTime).Seconds(), float64(txsCount)/time.Since(stepStartTime).Seconds())
glog.V(logger.Info).Infof("atxi-build: block %d / %d txs: %d took: %v %.2f bps %.2f txps", i+inc, stopIndex, txsCount, time.Since(stepStartTime).Round(time.Millisecond), float64(inc)/time.Since(stepStartTime).Seconds(), float64(txsCount)/time.Since(stepStartTime).Seconds())

if breaker {
break
}
}

if err := core.SetATXIBookmark(indexDb, stopIndex); err != nil {
glog.Fatalln(err)
}

// Print summary
totalBlocksF := float64(stopIndex - startIndex)
totalTxsF := float64(totalTxCount)
took := time.Since(startTime)
glog.D(logger.Error).Infof(`Finished atxi-build in %v: %d blocks (~ %.2f blocks/sec), %d txs (~ %.2f txs/sec)`,
took.Round(time.Second),
stopIndex-startIndex,
totalBlocksF/took.Seconds(),
totalTxCount,
totalTxsF/took.Seconds(),
)
return nil
}
28 changes: 1 addition & 27 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"time"

"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/console"
"github.com/ethereumproject/go-ethereum/core"
"github.com/ethereumproject/go-ethereum/core/state"
"github.com/ethereumproject/go-ethereum/core/types"
Expand Down Expand Up @@ -58,12 +57,6 @@ var (
Aliases: []string{"upgradedb"},
Usage: "Upgrade chainblock database",
}
removedbCommand = cli.Command{
Action: removeDB,
Name: "remove-db",
Aliases: []string{"removedb"},
Usage: "Remove blockchain and state databases",
}
dumpCommand = cli.Command{
Action: dump,
Name: "dump",
Expand Down Expand Up @@ -105,7 +98,7 @@ var (
resetCommand = cli.Command{
Action: resetChaindata,
Name: "reset",
Usage: "Reset the chain database",
Usage: "Reset (remove) the chain database",
Description: `
Reset does a hard reset of the entire chain database.
This is a drastic and irreversible command, and should be used with caution.
Expand Down Expand Up @@ -171,25 +164,6 @@ func exportChain(ctx *cli.Context) error {
return nil
}

func removeDB(ctx *cli.Context) error {
confirm, err := console.Stdin.PromptConfirm("Remove local database?")
if err != nil {
log.Fatal(err)
}

if confirm {
fmt.Println("Removing chaindata...")
start := time.Now()

os.RemoveAll(filepath.Join(ctx.GlobalString(DataDirFlag.Name), "chaindata"))

fmt.Printf("Removed in %v\n", time.Since(start))
} else {
fmt.Println("Operation aborted")
}
return nil
}

func upgradeDB(ctx *cli.Context) error {
glog.Infoln("Upgrading blockchain database")

Expand Down
4 changes: 4 additions & 0 deletions cmd/geth/chainconfig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ teardown() {
@test "--chain kitty --bootnodes=enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303 | exit 0" {
mkdir -p $DATA_DIR/kitty
cp $BATS_TEST_DIRNAME/../../core/config/mainnet.json $DATA_DIR/kitty/chain.json
cp $BATS_TEST_DIRNAME/../../core/config/mainnet_genesis.json $DATA_DIR/kitty/kitty_genesis.json
cp $BATS_TEST_DIRNAME/../../core/config/mainnet_bootnodes.json $DATA_DIR/kitty/kitty_bootnodes.json
cp $BATS_TEST_DIRNAME/../../core/config/mainnet_genesis_alloc.csv $DATA_DIR/kitty/kitty_genesis_alloc.csv
sed -i.bak s/mainnet/kitty/ $DATA_DIR/kitty/chain.json
sed -i.bak s/mainnet/kitty/ $DATA_DIR/kitty/kitty_genesis.json
run $GETH_CMD --data-dir $DATA_DIR --chain kitty --bootnodes=enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303 --exec 'exit;' console
echo "$output"
[ "$status" -eq 0 ]
Expand Down
4 changes: 2 additions & 2 deletions cmd/geth/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func StartNode(stack *node.Node) {

// mlog
nodeInfo := stack.Server().NodeInfo()
cconf := cacheChainConfig
cconf := core.GetCacheChainConfig()
if cconf == nil {
Fatalf("Nil chain configuration")
}
Expand Down Expand Up @@ -636,7 +636,7 @@ func rollback(ctx *cli.Context) error {
func dumpChainConfig(ctx *cli.Context) error {

chainIdentity := mustMakeChainIdentity(ctx)
if !(chainIdentitiesMain[chainIdentity] || chainIdentitiesMorden[chainIdentity]) {
if !(core.ChainIdentitiesMain[chainIdentity] || core.ChainIdentitiesMorden[chainIdentity]) {
glog.Fatal("Dump config should only be used with default chain configurations (mainnet or morden).")
}

Expand Down
Loading

0 comments on commit 5b7b2d7

Please sign in to comment.