Skip to content

Commit

Permalink
Merge pull request #8 from Ethersocial/gesn-0.4.1-geth-1.9.6-base
Browse files Browse the repository at this point in the history
Gesn 0.4.1 release
  • Loading branch information
hackmod committed Dec 3, 2019
2 parents 7c4ce15 + 838df3e commit 9515d8d
Show file tree
Hide file tree
Showing 165 changed files with 13,634 additions and 1,021 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
@@ -1,6 +1,6 @@
Hi there,

please note that this is an issue tracker reserved for bug reports and feature requests.
Please note that this is an issue tracker reserved for bug reports and feature requests.

For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.

Expand Down
22 changes: 11 additions & 11 deletions .travis.yml
Expand Up @@ -18,15 +18,15 @@ jobs:
- stage: build
os: linux
dist: xenial
go: 1.10.x
go: 1.11.x
script:
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES

- stage: build
os: linux
dist: xenial
go: 1.11.x
go: 1.12.x
script:
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES
Expand All @@ -35,14 +35,14 @@ jobs:
- stage: build
os: linux
dist: xenial
go: 1.12.x
go: 1.13.x
script:
- go run build/ci.go install
- go run build/ci.go test -coverage $TEST_PACKAGES

- stage: build
os: osx
go: 1.12.x
go: 1.13.x
script:
- echo "Increase the maximum number of open file descriptors on macOS"
- NOFILE=20480
Expand All @@ -62,7 +62,7 @@ jobs:
os: linux
dist: xenial
sudo: required
go: 1.12.x
go: 1.13.x
env:
- azure-linux
git:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
dist: xenial
services:
- docker
go: 1.12.x
go: 1.13.x
env:
- azure-linux-mips
git:
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
git:
submodules: false # avoid cloning ethereum/tests
before_install:
- curl https://dl.google.com/go/go1.12.linux-amd64.tar.gz | tar -xz
- curl https://dl.google.com/go/go1.13.linux-amd64.tar.gz | tar -xz
- export PATH=`pwd`/go/bin:$PATH
- export GOROOT=`pwd`/go
- export GOPATH=$HOME/go
Expand All @@ -169,7 +169,7 @@ jobs:
- stage: build
if: type = push
os: osx
go: 1.12.x
go: 1.13.x
env:
- azure-osx
- azure-ios
Expand Down Expand Up @@ -203,7 +203,7 @@ jobs:
if: type = cron
os: linux
dist: xenial
go: 1.12.x
go: 1.13.x
env:
- azure-purge
git:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.12-alpine as builder
FROM golang:1.13-alpine as builder

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

Expand All @@ -12,5 +12,5 @@ FROM alpine:latest
RUN apk add --no-cache ca-certificates
COPY --from=builder /go-ethersocial/build/bin/geth /usr/local/bin/

EXPOSE 9545 9546 50505 50505/udp
EXPOSE 9545 9546 9547 50505 50505/udp
ENTRYPOINT ["geth"]
4 changes: 2 additions & 2 deletions Dockerfile.alltools
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.12-alpine as builder
FROM golang:1.13-alpine as builder

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

Expand All @@ -12,4 +12,4 @@ FROM alpine:latest
RUN apk add --no-cache ca-certificates
COPY --from=builder /go-ethersocial/build/bin/* /usr/local/bin/

EXPOSE 9545 9546 50505 50505/udp
EXPOSE 9545 9546 9547 50505 50505/udp
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -8,7 +8,7 @@
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
.PHONY: geth-windows geth-windows-386 geth-windows-amd64

GOBIN = $(shell pwd)/build/bin
GOBIN = ./build/bin
GO ?= latest

geth:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -233,8 +233,8 @@ aware of and agree upon. This consists of a small JSON file (e.g. call it `genes

The above fields should be fine for most purposes, although we'd recommend changing
the `nonce` to some random value so you prevent unknown remote nodes from being able
to connect to you. If you'd like to pre-fund some accounts for easier testing, you can
populate the `alloc` field with account configs:
to connect to you. If you'd like to pre-fund some accounts for easier testing, create
the accounts and populate the `alloc` field with their addresses.

```json
"alloc": {
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Expand Up @@ -23,8 +23,8 @@ environment:
install:
- git submodule update --init
- rmdir C:\go /s /q
- appveyor DownloadFile https://dl.google.com/go/go1.12.9.windows-%GETH_ARCH%.zip
- 7z x go1.12.9.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
- appveyor DownloadFile https://dl.google.com/go/go1.13.windows-%GETH_ARCH%.zip
- 7z x go1.13.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
- go version
- gcc --version

Expand Down
4 changes: 1 addition & 3 deletions build/ci.go
Expand Up @@ -224,7 +224,6 @@ func doInstall(cmdline []string) {
if flag.NArg() > 0 {
packages = flag.Args()
}
packages = build.ExpandPackagesNoVendor(packages)

if *arch == "" || *arch == runtime.GOARCH {
goinstall := goTool("install", buildFlags(env)...)
Expand Down Expand Up @@ -321,13 +320,12 @@ func doTest(cmdline []string) {
if len(flag.CommandLine.Args()) > 0 {
packages = flag.CommandLine.Args()
}
packages = build.ExpandPackagesNoVendor(packages)

// Run the actual tests.
// Test a single package at a time. CI builders are slow
// and some tests run into timeouts under load.
gotest := goTool("test", buildFlags(env)...)
gotest.Args = append(gotest.Args, "-p", "1", "-timeout", "5m")
gotest.Args = append(gotest.Args, "-p", "1", "-timeout", "5m", "--short")
if *coverage {
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/bootnode/main.go
Expand Up @@ -70,7 +70,9 @@ func main() {
if err = crypto.SaveECDSA(*genKey, nodeKey); err != nil {
utils.Fatalf("%v", err)
}
return
if !*writeAddr {
return
}
case *nodeKeyFile == "" && *nodeKeyHex == "":
utils.Fatalf("Use -nodekey or -nodekeyhex to specify a private key")
case *nodeKeyFile != "" && *nodeKeyHex != "":
Expand Down
120 changes: 74 additions & 46 deletions cmd/devp2p/discv4cmd.go
Expand Up @@ -19,10 +19,10 @@ package main
import (
"fmt"
"net"
"sort"
"strings"
"time"

"github.com/ethersocial/go-ethersocial/common"
"github.com/ethersocial/go-ethersocial/crypto"
"github.com/ethersocial/go-ethersocial/p2p/discover"
"github.com/ethersocial/go-ethersocial/p2p/enode"
Expand All @@ -38,23 +38,34 @@ var (
discv4PingCommand,
discv4RequestRecordCommand,
discv4ResolveCommand,
discv4ResolveJSONCommand,
},
}
discv4PingCommand = cli.Command{
Name: "ping",
Usage: "Sends ping to a node",
Action: discv4Ping,
Name: "ping",
Usage: "Sends ping to a node",
Action: discv4Ping,
ArgsUsage: "<node>",
}
discv4RequestRecordCommand = cli.Command{
Name: "requestenr",
Usage: "Requests a node record using EIP-868 enrRequest",
Action: discv4RequestRecord,
Name: "requestenr",
Usage: "Requests a node record using EIP-868 enrRequest",
Action: discv4RequestRecord,
ArgsUsage: "<node>",
}
discv4ResolveCommand = cli.Command{
Name: "resolve",
Usage: "Finds a node in the DHT",
Action: discv4Resolve,
Flags: []cli.Flag{bootnodesFlag},
Name: "resolve",
Usage: "Finds a node in the DHT",
Action: discv4Resolve,
ArgsUsage: "<node>",
Flags: []cli.Flag{bootnodesFlag},
}
discv4ResolveJSONCommand = cli.Command{
Name: "resolve-json",
Usage: "Re-resolves nodes in a nodes.json file",
Action: discv4ResolveJSON,
Flags: []cli.Flag{bootnodesFlag},
ArgsUsage: "<nodes.json file>",
}
)

Expand All @@ -64,10 +75,8 @@ var bootnodesFlag = cli.StringFlag{
}

func discv4Ping(ctx *cli.Context) error {
n, disc, err := getNodeArgAndStartV4(ctx)
if err != nil {
return err
}
n := getNodeArg(ctx)
disc := startV4(ctx)
defer disc.Close()

start := time.Now()
Expand All @@ -79,10 +88,8 @@ func discv4Ping(ctx *cli.Context) error {
}

func discv4RequestRecord(ctx *cli.Context) error {
n, disc, err := getNodeArgAndStartV4(ctx)
if err != nil {
return err
}
n := getNodeArg(ctx)
disc := startV4(ctx)
defer disc.Close()

respN, err := disc.RequestENR(n)
Expand All @@ -94,33 +101,43 @@ func discv4RequestRecord(ctx *cli.Context) error {
}

func discv4Resolve(ctx *cli.Context) error {
n, disc, err := getNodeArgAndStartV4(ctx)
if err != nil {
return err
}
n := getNodeArg(ctx)
disc := startV4(ctx)
defer disc.Close()

fmt.Println(disc.Resolve(n).String())
return nil
}

func getNodeArgAndStartV4(ctx *cli.Context) (*enode.Node, *discover.UDPv4, error) {
if ctx.NArg() != 1 {
return nil, nil, fmt.Errorf("missing node as command-line argument")
func discv4ResolveJSON(ctx *cli.Context) error {
if ctx.NArg() < 1 {
return fmt.Errorf("need nodes file as argument")
}
n, err := parseNode(ctx.Args()[0])
if err != nil {
return nil, nil, err
disc := startV4(ctx)
defer disc.Close()
file := ctx.Args().Get(0)

// Load existing nodes in file.
var nodes []*enode.Node
if common.FileExist(file) {
nodes = loadNodesJSON(file).nodes()
}
var bootnodes []*enode.Node
if commandHasFlag(ctx, bootnodesFlag) {
bootnodes, err = parseBootnodes(ctx)
// Add nodes from command line arguments.
for i := 1; i < ctx.NArg(); i++ {
n, err := parseNode(ctx.Args().Get(i))
if err != nil {
return nil, nil, err
exit(err)
}
nodes = append(nodes, n)
}

result := make(nodeSet, len(nodes))
for _, n := range nodes {
n = disc.Resolve(n)
result[n.ID()] = nodeJSON{Seq: n.Seq(), N: n}
}
disc, err := startV4(bootnodes)
return n, disc, err
writeNodesJSON(file, result)
return nil
}

func parseBootnodes(ctx *cli.Context) ([]*enode.Node, error) {
Expand All @@ -139,28 +156,39 @@ func parseBootnodes(ctx *cli.Context) ([]*enode.Node, error) {
return nodes, nil
}

// commandHasFlag returns true if the current command supports the given flag.
func commandHasFlag(ctx *cli.Context, flag cli.Flag) bool {
flags := ctx.FlagNames()
sort.Strings(flags)
i := sort.SearchStrings(flags, flag.GetName())
return i != len(flags) && flags[i] == flag.GetName()
// startV4 starts an ephemeral discovery V4 node.
func startV4(ctx *cli.Context) *discover.UDPv4 {
socket, ln, cfg, err := listen()
if err != nil {
exit(err)
}
if commandHasFlag(ctx, bootnodesFlag) {
bn, err := parseBootnodes(ctx)
if err != nil {
exit(err)
}
cfg.Bootnodes = bn
}
disc, err := discover.ListenV4(socket, ln, cfg)
if err != nil {
exit(err)
}
return disc
}

// startV4 starts an ephemeral discovery V4 node.
func startV4(bootnodes []*enode.Node) (*discover.UDPv4, error) {
func listen() (*net.UDPConn, *enode.LocalNode, discover.Config, error) {
var cfg discover.Config
cfg.Bootnodes = bootnodes
cfg.PrivateKey, _ = crypto.GenerateKey()
db, _ := enode.OpenDB("")
ln := enode.NewLocalNode(db, cfg.PrivateKey)

socket, err := net.ListenUDP("udp4", &net.UDPAddr{IP: net.IP{0, 0, 0, 0}})
if err != nil {
return nil, err
db.Close()
return nil, nil, cfg, err
}
addr := socket.LocalAddr().(*net.UDPAddr)
ln.SetFallbackIP(net.IP{127, 0, 0, 1})
ln.SetFallbackUDP(addr.Port)
return discover.ListenUDP(socket, ln, cfg)
return socket, ln, cfg, nil
}

0 comments on commit 9515d8d

Please sign in to comment.