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

Restore full sync mode #90

Merged
merged 15 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ func TestBindings(t *testing.T) {
t.Skip("go sdk not found for testing")
}
// Create a temporary workspace for the test suite
ws, err := ioutil.TempDir("", "")
ws, err := ioutil.TempDir("./", "")
if err != nil {
t.Fatalf("failed to create temporary workspace: %v", err)
}
Expand Down
9 changes: 1 addition & 8 deletions build/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ if [ ! -f "build/env.sh" ]; then
fi

# Create fake Go workspace if it doesn't exist yet.
workspace="$PWD/build/_workspace"
workspace="$GOPATH"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces dependency on GOPATH, doesn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good point! I had an old master in the branch, now it should be updated.

root="$PWD"
ethdir="$workspace/src/github.com/ledgerwatch"
if [ ! -L "$ethdir/turbo-geth" ]; then
mkdir -p "$ethdir"
cd "$ethdir"
ln -s ../../../../../. turbo-geth
cd "$root"
fi

# Set up the environment to use the workspace.
GOPATH="$workspace"
export GOPATH

# Run the command inside the workspace.
cd "$ethdir/turbo-geth"
PWD="$ethdir/turbo-geth"
Expand Down
2 changes: 1 addition & 1 deletion cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import (
"github.com/ledgerwatch/turbo-geth/signer/core"
"github.com/ledgerwatch/turbo-geth/signer/rules"
"github.com/ledgerwatch/turbo-geth/signer/storage"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

const legalWarning = `
Expand Down
2 changes: 1 addition & 1 deletion cmd/ethkey/changepassphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/ledgerwatch/turbo-geth/accounts/keystore"
"github.com/ledgerwatch/turbo-geth/cmd/utils"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var newPassphraseFlag = cli.StringFlag{
Expand Down
2 changes: 1 addition & 1 deletion cmd/ethkey/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/ledgerwatch/turbo-geth/cmd/utils"
"github.com/ledgerwatch/turbo-geth/crypto"
"github.com/pborman/uuid"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

type outputGenerate struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/ethkey/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/ledgerwatch/turbo-geth/accounts/keystore"
"github.com/ledgerwatch/turbo-geth/cmd/utils"
"github.com/ledgerwatch/turbo-geth/crypto"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

type outputInspect struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/ethkey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os"

"github.com/ledgerwatch/turbo-geth/cmd/utils"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/ethkey/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/ledgerwatch/turbo-geth/cmd/utils"
"github.com/ledgerwatch/turbo-geth/common"
"github.com/ledgerwatch/turbo-geth/crypto"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

type outputSign struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/ethkey/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/ledgerwatch/turbo-geth/cmd/utils"
"github.com/ledgerwatch/turbo-geth/console"
"github.com/ledgerwatch/turbo-geth/crypto"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

// promptPassphrase prompts the user for a passphrase. Set confirmation to true
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/ledgerwatch/turbo-geth/cmd/evm/internal/compiler"

cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var compileCommand = cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/disasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"

"github.com/ledgerwatch/turbo-geth/core/asm"
cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var disasmCommand = cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"os"

"github.com/ledgerwatch/turbo-geth/cmd/utils"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags)
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/ledgerwatch/turbo-geth/ethdb"
"github.com/ledgerwatch/turbo-geth/log"
"github.com/ledgerwatch/turbo-geth/params"
cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var runCommand = cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/staterunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/ledgerwatch/turbo-geth/log"
"github.com/ledgerwatch/turbo-geth/tests"

cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var stateTestCommand = cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/accountcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/ledgerwatch/turbo-geth/console"
"github.com/ledgerwatch/turbo-geth/crypto"
"github.com/ledgerwatch/turbo-geth/log"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/bugcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/ledgerwatch/turbo-geth/params"

"github.com/ledgerwatch/turbo-geth/cmd/utils"
cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var bugCommand = cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/ledgerwatch/turbo-geth/ethdb"
"github.com/ledgerwatch/turbo-geth/event"
"github.com/ledgerwatch/turbo-geth/log"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"reflect"
"unicode"

cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"

"github.com/ledgerwatch/turbo-geth/cmd/utils"
"github.com/ledgerwatch/turbo-geth/dashboard"
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/ledgerwatch/turbo-geth/console"
"github.com/ledgerwatch/turbo-geth/node"
"github.com/ledgerwatch/turbo-geth/rpc"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/ledgerwatch/turbo-geth/log"
"github.com/ledgerwatch/turbo-geth/metrics"
"github.com/ledgerwatch/turbo-geth/node"
cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/misccmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/ledgerwatch/turbo-geth/consensus/ethash"
"github.com/ledgerwatch/turbo-geth/eth"
"github.com/ledgerwatch/turbo-geth/params"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/monitorcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/ledgerwatch/turbo-geth/node"
"github.com/ledgerwatch/turbo-geth/rpc"
"github.com/gizak/termui"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/ledgerwatch/turbo-geth/cmd/utils"
"github.com/ledgerwatch/turbo-geth/internal/debug"
cli "gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

// AppHelpTemplate is the test template for the default, global app help topic.
Expand Down
32 changes: 16 additions & 16 deletions cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import (
"time"

"github.com/ledgerwatch/bolt"
chart "github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/util"

"github.com/ledgerwatch/turbo-geth/common"
. "github.com/ledgerwatch/turbo-geth/common/bucket"
"github.com/ledgerwatch/turbo-geth/consensus/ethash"
"github.com/ledgerwatch/turbo-geth/core"
"github.com/ledgerwatch/turbo-geth/core/rawdb"
Expand All @@ -31,6 +29,8 @@ import (
"github.com/ledgerwatch/turbo-geth/params"
"github.com/ledgerwatch/turbo-geth/rlp"
"github.com/ledgerwatch/turbo-geth/trie"
"github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/util"
)

var emptyCodeHash = crypto.Keccak256(nil)
Expand All @@ -47,7 +47,7 @@ func bucketList(db *bolt.DB) [][]byte {
bucketList := [][]byte{}
err := db.View(func(tx *bolt.Tx) error {
err := tx.ForEach(func(name []byte, b *bolt.Bucket) error {
if len(name) == 20 || bytes.Equal(name, []byte("AT")) {
if len(name) == 20 || bytes.Equal(name, AccountsBucket) {
n := make([]byte, len(name))
copy(n, name)
bucketList = append(bucketList, n)
Expand Down Expand Up @@ -320,7 +320,7 @@ func accountSavings(db *bolt.DB) (int, int) {
emptyRoots := 0
emptyCodes := 0
db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("AT"))
b := tx.Bucket(AccountsBucket)
c := b.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
if bytes.Contains(v, trie.EmptyRoot.Bytes()) {
Expand Down Expand Up @@ -462,7 +462,7 @@ func trieChart() {
StrokeColor: chart.DefaultStrokeColor,
StrokeWidth: 1.0,
},
Range: &chart.LogRange{
Range: &chart.ContinuousRange{
Min: thresholds[0],
Max: thresholds[len(thresholds)-1],
},
Expand Down Expand Up @@ -802,7 +802,7 @@ func testResolve() {
} else {
check(err)
}
//enc, _ := ethDb.GetAsOf(state.AccountsBucket, state.AccountsHistoryBucket, crypto.Keccak256(contract), 2701646)
//enc, _ := ethDb.GetAsOf(AccountsBucket, state.AccountsHistoryBucket, crypto.Keccak256(contract), 2701646)
//fmt.Printf("Account: %x\n", enc)
}

Expand Down Expand Up @@ -1031,14 +1031,14 @@ func loadAccount() {
blockSuffix := encodeTimestamp(blockNr)
accountBytes := common.FromHex(*account)
secKey := crypto.Keccak256(accountBytes)
accountData, err := ethDb.GetAsOf(state.AccountsBucket, state.AccountsHistoryBucket, secKey, blockNr+1)
accountData, err := ethDb.GetAsOf(AccountsBucket, AccountsHistoryBucket, secKey, blockNr+1)
check(err)
fmt.Printf("Account data: %x\n", accountData)
startkey := make([]byte, len(accountBytes)+32)
copy(startkey, accountBytes)
t := trie.New(common.Hash{})
count := 0
if err := ethDb.WalkAsOf(state.StorageBucket, state.StorageHistoryBucket, startkey, uint(len(accountBytes)*8), blockNr, func(k, v []byte) (bool, error) {
if err := ethDb.WalkAsOf(StorageBucket, StorageHistoryBucket, startkey, uint(len(accountBytes)*8), blockNr, func(k, v []byte) (bool, error) {
key := k[len(accountBytes):]
//fmt.Printf("%x: %x\n", key, v)
t.Update(key, v, blockNr)
Expand All @@ -1049,7 +1049,7 @@ func loadAccount() {
}
fmt.Printf("After %d updates, reconstructed storage root: %x\n", count, t.Hash())
var keys [][]byte
if err := ethDb.Walk(state.StorageHistoryBucket, accountBytes, uint(len(accountBytes)*8), func(k, v []byte) (bool, error) {
if err := ethDb.Walk(StorageHistoryBucket, accountBytes, uint(len(accountBytes)*8), func(k, v []byte) (bool, error) {
if !bytes.HasSuffix(k, blockSuffix) {
return true, nil
}
Expand All @@ -1061,11 +1061,11 @@ func loadAccount() {
}
fmt.Printf("%d keys updated\n", len(keys))
for _, k := range keys {
v, err := ethDb.GetAsOf(state.StorageBucket, state.StorageHistoryBucket, k, blockNr+1)
v, err := ethDb.GetAsOf(StorageBucket, StorageHistoryBucket, k, blockNr+1)
if err != nil {
fmt.Printf("for key %x err %v\n", k, err)
}
vOrig, err := ethDb.GetAsOf(state.StorageBucket, state.StorageHistoryBucket, k, blockNr)
vOrig, err := ethDb.GetAsOf(StorageBucket, StorageHistoryBucket, k, blockNr)
if err != nil {
fmt.Printf("for key %x err %v\n", k, err)
}
Expand Down Expand Up @@ -1232,7 +1232,7 @@ func readAccount() {
check(err)
accountBytes := common.FromHex(*account)
secKey := crypto.Keccak256(accountBytes)
v, _ := ethDb.Get(state.AccountsBucket, secKey)
v, _ := ethDb.Get(AccountsBucket, secKey)
fmt.Printf("%x:%x\n", secKey, v)
}

Expand All @@ -1244,16 +1244,16 @@ func repairCurrent() {
check(err)
defer currentDb.Close()
check(historyDb.Update(func(tx *bolt.Tx) error {
if err := tx.DeleteBucket(state.StorageBucket); err != nil {
if err := tx.DeleteBucket(StorageBucket); err != nil {
return err
}
newB, err := tx.CreateBucket(state.StorageBucket, true)
newB, err := tx.CreateBucket(StorageBucket, true)
if err != nil {
return err
}
count := 0
if err := currentDb.View(func(ctx *bolt.Tx) error {
b := ctx.Bucket(state.StorageBucket)
b := ctx.Bucket(StorageBucket)
c := b.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
newB.Put(k, v)
Expand Down
2 changes: 1 addition & 1 deletion cmd/p2psim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
"github.com/ledgerwatch/turbo-geth/p2p/simulations"
"github.com/ledgerwatch/turbo-geth/p2p/simulations/adapters"
"github.com/ledgerwatch/turbo-geth/rpc"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

var client *simulations.Client
Expand Down
2 changes: 1 addition & 1 deletion cmd/puppeth/puppeth.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

"github.com/ledgerwatch/turbo-geth/log"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli"
)

// main is just a boring entry point to set up the CLI app.
Expand Down
Loading