Skip to content

Commit

Permalink
Upgrade go-ethereum dependency to 1.14.3 (Fantom-foundation#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
thaarok authored Jun 6, 2024
1 parent 1819a05 commit b4ea514
Show file tree
Hide file tree
Showing 74 changed files with 1,943 additions and 1,840 deletions.
6 changes: 3 additions & 3 deletions cmd/sonicd/fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"github.com/Fantom-foundation/go-opera/config"
"github.com/Fantom-foundation/go-opera/version"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"runtime"
"strings"
"testing"
Expand All @@ -30,7 +30,7 @@ func TestFakeNetFlag_NonValidator(t *testing.T) {
cli.SetTemplateFunc("goos", func() string { return runtime.GOOS })
cli.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
cli.SetTemplateFunc("gover", runtime.Version)
cli.SetTemplateFunc("version", func() string { return params.VersionWithCommit("", "") })
cli.SetTemplateFunc("version", func() string { return version.VersionWithCommit("", "") })
cli.SetTemplateFunc("niltime", genesisStart)
cli.SetTemplateFunc("apis", func() string { return ipcAPIs })
cli.ExpectExit()
Expand Down Expand Up @@ -60,7 +60,7 @@ func TestFakeNetFlag_Validator(t *testing.T) {
cli.SetTemplateFunc("goos", func() string { return runtime.GOOS })
cli.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
cli.SetTemplateFunc("gover", runtime.Version)
cli.SetTemplateFunc("version", func() string { return params.VersionWithCommit("", "") })
cli.SetTemplateFunc("version", func() string { return version.VersionWithCommit("", "") })
cli.SetTemplateFunc("niltime", genesisStart)
cli.SetTemplateFunc("apis", func() string { return ipcAPIs })
cli.ExpectExit()
Expand Down
25 changes: 10 additions & 15 deletions cmd/sonicd/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package main

import (
"fmt"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/diskusage"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/metrics"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/tracing"
"github.com/Fantom-foundation/go-opera/config"
"github.com/Fantom-foundation/go-opera/config/flags"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/params"
"github.com/Fantom-foundation/go-opera/version"
"os"
"os/signal"
"sort"
"syscall"
"time"

"github.com/Fantom-foundation/go-opera/cmd/sonicd/diskusage"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/metrics"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/tracing"
"github.com/Fantom-foundation/go-opera/config"
"github.com/Fantom-foundation/go-opera/config/flags"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/console/prompt"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
Expand Down Expand Up @@ -69,10 +69,9 @@ func initFlags() {
flags.MaxPendingPeersFlag,
flags.NATFlag,
flags.NoDiscoverFlag,
flags.DiscoveryV4Flag,
flags.DiscoveryV5Flag,
flags.NetrestrictFlag,
flags.IPrestrictFlag,
flags.PrivateNodeFlag,
flags.NodeKeyFileFlag,
flags.NodeKeyHexFlag,
}
Expand Down Expand Up @@ -158,14 +157,13 @@ func initFlags() {
// init the CLI app.
func initApp() {
discfilter.Enable()
config.OverrideParams()

initFlags()

app = cli.NewApp()
app.Name = "sonicd"
app.Usage = "the Sonic network client"
app.Version = params.VersionWithCommit(config.GitCommit, config.GitDate)
app.Version = version.VersionWithCommit(config.GitCommit, config.GitDate)
app.Action = lachesisMain
app.HideVersion = true // we have a command to print the version
app.Commands = []cli.Command{
Expand Down Expand Up @@ -268,10 +266,7 @@ func startNode(ctx *cli.Context, stack *node.Node) error {
stack.AccountManager().Subscribe(events)

// Create a client to interact with local opera node.
rpcClient, err := stack.Attach()
if err != nil {
return fmt.Errorf("failed to attach to self: %w", err)
}
rpcClient := stack.Attach()
ethClient := ethclient.NewClient(rpcClient)
go func() {
// Open any wallets already attached
Expand Down
13 changes: 7 additions & 6 deletions cmd/sonicd/misccmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package main

import (
"fmt"
"github.com/Fantom-foundation/go-opera/config"
"github.com/ethereum/go-ethereum/params"
"gopkg.in/urfave/cli.v1"
"github.com/Fantom-foundation/go-opera/version"
"os"
"runtime"

"github.com/Fantom-foundation/go-opera/config"
"gopkg.in/urfave/cli.v1"

"github.com/Fantom-foundation/go-opera/gossip"
)

var (
versionCommand = cli.Command{
Action: version,
Action: versionAction,
Name: "version",
Usage: "Print version numbers",
ArgsUsage: " ",
Expand All @@ -24,9 +25,9 @@ The output of this command is supposed to be machine-readable.
}
)

func version(ctx *cli.Context) error {
func versionAction(ctx *cli.Context) error {
fmt.Println(config.ClientIdentifier)
fmt.Println("Version:", params.VersionWithMeta())
fmt.Println("Version:", version.VersionWithMeta)
if config.GitCommit != "" {
fmt.Println("Git Commit:", config.GitCommit)
}
Expand Down
3 changes: 0 additions & 3 deletions cmd/sonicd/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package main

import (
"github.com/Fantom-foundation/go-opera/cmd/sonicd/cmdhelper"
"github.com/Fantom-foundation/go-opera/config"
"io"
"sort"

Expand All @@ -33,8 +32,6 @@ import (
var AppHelpFlagGroups = calcAppHelpFlagGroups()

func calcAppHelpFlagGroups() []cmdhelper.FlagGroup {
config.OverrideParams()

initFlags()
return []cmdhelper.FlagGroup{
{
Expand Down
18 changes: 12 additions & 6 deletions cmd/sonictool/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package main

import (
"fmt"

"github.com/Fantom-foundation/go-opera/config"
"github.com/ethereum/go-ethereum/accounts/keystore"

"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/node"
"gopkg.in/urfave/cli.v1"
)

Expand All @@ -31,7 +31,7 @@ func accountList(ctx *cli.Context) error {
if err != nil {
return err
}
stack, err := node.New(&cfg.Node)
stack, err := config.MakeNetworkStack(ctx, &cfg.Node)
if err != nil {
return fmt.Errorf("failed to create the protocol stack: %w", err)
}
Expand All @@ -54,12 +54,18 @@ func accountCreate(ctx *cli.Context) error {
if err := config.SetNodeConfig(ctx, &cfg.Node); err != nil {
return err
}
scryptN, scryptP, keydir, err := cfg.Node.AccountConfig()

keydir, err := cfg.Node.KeyDirConfig()
if err != nil {
return fmt.Errorf("failed to read configuration: %w", err)
}

scryptN := keystore.StandardScryptN
scryptP := keystore.StandardScryptP
if cfg.Node.UseLightweightKDF {
scryptN = keystore.LightScryptN
scryptP = keystore.LightScryptP
}

passwordList, err := config.MakePasswordList(ctx)
if err != nil {
return fmt.Errorf("failed to get password list: %w", err)
Expand Down Expand Up @@ -94,7 +100,7 @@ func accountUpdate(ctx *cli.Context) error {
if err != nil {
return err
}
stack, err := node.New(&cfg.Node)
stack, err := config.MakeNetworkStack(ctx, &cfg.Node)
if err != nil {
return fmt.Errorf("failed to create the protocol stack: %w", err)
}
Expand Down Expand Up @@ -130,7 +136,7 @@ func accountImport(ctx *cli.Context) error {
if err != nil {
return err
}
stack, err := node.New(&cfg.Node)
stack, err := config.MakeNetworkStack(ctx, &cfg.Node)
if err != nil {
return fmt.Errorf("failed to create the protocol stack: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/sonictool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"github.com/Fantom-foundation/go-opera/config"
"github.com/Fantom-foundation/go-opera/config/flags"
"github.com/Fantom-foundation/go-opera/version"
_ "github.com/Fantom-foundation/go-opera/version"
"github.com/ethereum/go-ethereum/params"
"gopkg.in/urfave/cli.v1"
"os"
"sort"
Expand All @@ -15,7 +15,7 @@ func main() {
app := cli.NewApp()
app.Name = "sonictool"
app.Usage = "the Sonic management tool"
app.Version = params.VersionWithCommit(config.GitCommit, config.GitDate)
app.Version = version.VersionWithCommit(config.GitCommit, config.GitDate)
app.Flags = []cli.Flag{
flags.DataDirFlag,
flags.CacheFlag,
Expand Down
13 changes: 7 additions & 6 deletions cmd/sonictool/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import (
"crypto/rand"
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strings"

"github.com/Fantom-foundation/go-opera/config"
"github.com/Fantom-foundation/go-opera/inter/validatorpk"
"github.com/Fantom-foundation/go-opera/valkeystore"
"github.com/Fantom-foundation/go-opera/valkeystore/encryption"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"gopkg.in/urfave/cli.v1"
"os"
"path"
"path/filepath"
"strings"
)

// validatorKeyCreate creates a new validator key into the keystore defined by the CLI flags.
Expand Down Expand Up @@ -47,7 +48,7 @@ func validatorKeyCreate(ctx *cli.Context) error {
Type: validatorpk.Types.Secp256k1,
}

_, _, keystoreDir, err := cfg.Node.AccountConfig()
keystoreDir, err := cfg.Node.KeyDirConfig()
if err != nil {
return fmt.Errorf("failed to setup account config: %w", err)
}
Expand Down Expand Up @@ -88,7 +89,7 @@ func validatorKeyConvert(ctx *cli.Context) error {
return err
}

_, _, keydir, _ := cfg.Node.AccountConfig()
keydir, _ := cfg.Node.KeyDirConfig()

pubkeyStr := ctx.Args().Get(1)
pubkey, err := validatorpk.FromString(pubkeyStr)
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
carmen "github.com/Fantom-foundation/Carmen/go/state"
"github.com/Fantom-foundation/go-opera/config/flags"
"github.com/Fantom-foundation/go-opera/gossip/evmstore"
"github.com/Fantom-foundation/go-opera/version"
"github.com/ethereum/go-ethereum/common/fdlimit"
"os"
"path"
Expand All @@ -20,7 +21,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/params"
"github.com/naoina/toml"
"github.com/syndtr/goleveldb/leveldb/opt"
"gopkg.in/urfave/cli.v1"
Expand Down Expand Up @@ -340,7 +340,7 @@ func MakeAllConfigs(ctx *cli.Context) (*Config, error) {
func DefaultNodeConfig() node.Config {
cfg := NodeDefaultConfig
cfg.Name = ClientIdentifier
cfg.Version = params.VersionWithCommit(GitCommit, GitDate)
cfg.Version = version.VersionWithCommit(GitCommit, GitDate)
cfg.HTTPModules = append(cfg.HTTPModules, "eth", "ftm", "dag", "abft", "web3")
cfg.WSModules = append(cfg.WSModules, "eth", "ftm", "dag", "abft", "web3")
cfg.IPCPath = "opera.ipc"
Expand Down
3 changes: 2 additions & 1 deletion config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var NodeDefaultConfig = node.Config{
WSModules: []string{},
GraphQLVirtualHosts: []string{"localhost"},
P2P: p2p.Config{
NoDiscovery: true, // disable discovery v4 by default
NoDiscovery: false, // enable discovery by default
DiscoveryV4: false, // disable discovery v4 by default
DiscoveryV5: true, // enable discovery v5 by default
ListenAddr: fmt.Sprintf(":%d", flags.ListenPortFlag.Value),
MaxPeers: 50,
Expand Down
Loading

0 comments on commit b4ea514

Please sign in to comment.