Skip to content

Commit

Permalink
Merge pull request #636 from etclabscore/merge/foundation-release/1.1…
Browse files Browse the repository at this point in the history
…3.15-p2p

Add latest p2p
  • Loading branch information
meowsbits authored Jun 6, 2024
2 parents 4c641ce + 6c483de commit 479b6de
Show file tree
Hide file tree
Showing 76 changed files with 2,132 additions and 2,555 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
os: linux
arch: amd64
dist: bionic
go: 1.21.x
go: 1.22.x
env:
- docker
services:
Expand All @@ -33,7 +33,7 @@ jobs:
os: linux
arch: arm64
dist: bionic
go: 1.21.x
go: 1.22.x
env:
- docker
services:
Expand All @@ -51,7 +51,7 @@ jobs:
os: linux
dist: bionic
sudo: required
go: 1.21.x
go: 1.22.x
env:
- azure-linux
git:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
if: type = push
os: osx
osx_image: xcode14.2
go: 1.21.x
go: 1.22.x
env:
- azure-osx
git:
Expand All @@ -101,7 +101,7 @@ jobs:
os: linux
arch: amd64
dist: bionic
go: 1.21.x
go: 1.22.x
script:
- travis_wait 30 go run build/ci.go test $TEST_PACKAGES

Expand All @@ -110,14 +110,14 @@ jobs:
os: linux
arch: arm64
dist: bionic
go: 1.20.x
go: 1.21.x
script:
- travis_wait 30 go run build/ci.go test $TEST_PACKAGES

- stage: build
os: linux
dist: bionic
go: 1.20.x
go: 1.21.x
script:
- travis_wait 30 go run build/ci.go test $TEST_PACKAGES

Expand All @@ -126,7 +126,7 @@ jobs:
if: type = cron || (type = push && tag ~= /^v[0-9]/)
os: linux
dist: bionic
go: 1.21.x
go: 1.22.x
env:
- ubuntu-ppa
git:
Expand All @@ -149,7 +149,7 @@ jobs:
if: type = cron
os: linux
dist: bionic
go: 1.21.x
go: 1.22.x
env:
- azure-purge
git:
Expand All @@ -162,7 +162,7 @@ jobs:
if: type = cron
os: linux
dist: bionic
go: 1.21.x
go: 1.22.x
script:
- travis_wait 30 go run build/ci.go test -race $TEST_PACKAGES

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.21-alpine as builder
FROM golang:1.22-alpine as builder

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

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.21-alpine as builder
FROM golang:1.22-alpine as builder

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

Expand Down
5 changes: 2 additions & 3 deletions accounts/scwallet/securechannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"crypto/sha512"
Expand Down Expand Up @@ -72,11 +71,11 @@ func NewSecureChannelSession(card *pcsc.Card, keyData []byte) (*SecureChannelSes
if err != nil {
return nil, fmt.Errorf("could not unmarshal public key from card: %v", err)
}
secret, _ := key.Curve.ScalarMult(cardPublic.X, cardPublic.Y, key.D.Bytes())
secret, _ := crypto.S256().ScalarMult(cardPublic.X, cardPublic.Y, key.D.Bytes())
return &SecureChannelSession{
card: card,
secret: secret.Bytes(),
publicKey: elliptic.Marshal(crypto.S256(), key.PublicKey.X, key.PublicKey.Y),
publicKey: crypto.FromECDSAPub(&key.PublicKey),
}, nil
}

Expand Down
30 changes: 15 additions & 15 deletions build/checksums.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
# https://github.com/ethereum/execution-spec-tests/releases/download/v2.1.0/
ca89c76851b0900bfcc3cbb9a26cbece1f3d7c64a3bed38723e914713290df6c fixtures_develop.tar.gz

# version:golang 1.21.6
# version:golang 1.22.1
# https://go.dev/dl/
124926a62e45f78daabbaedb9c011d97633186a33c238ffc1e25320c02046248 go1.21.6.src.tar.gz
31d6ecca09010ab351e51343a5af81d678902061fee871f912bdd5ef4d778850 go1.21.6.darwin-amd64.tar.gz
0ff541fb37c38e5e5c5bcecc8f4f43c5ffd5e3a6c33a5d3e4003ded66fcfb331 go1.21.6.darwin-arm64.tar.gz
a1d1a149b34bf0f53965a237682c6da1140acabb131bf0e597240e4a140b0e5e go1.21.6.freebsd-386.tar.gz
de59e1217e4398b1522eed8dddabab2fa1b97aecbdca3af08e34832b4f0e3f81 go1.21.6.freebsd-amd64.tar.gz
05d09041b5a1193c14e4b2db3f7fcc649b236c567f5eb93305c537851b72dd95 go1.21.6.linux-386.tar.gz
3f934f40ac360b9c01f616a9aa1796d227d8b0328bf64cb045c7b8c4ee9caea4 go1.21.6.linux-amd64.tar.gz
e2e8aa88e1b5170a0d495d7d9c766af2b2b6c6925a8f8956d834ad6b4cacbd9a go1.21.6.linux-arm64.tar.gz
6a8eda6cc6a799ff25e74ce0c13fdc1a76c0983a0bb07c789a2a3454bf6ec9b2 go1.21.6.linux-armv6l.tar.gz
e872b1e9a3f2f08fd4554615a32ca9123a4ba877ab6d19d36abc3424f86bc07f go1.21.6.linux-ppc64le.tar.gz
92894d0f732d3379bc414ffdd617eaadad47e1d72610e10d69a1156db03fc052 go1.21.6.linux-s390x.tar.gz
65b38857135cf45c80e1d267e0ce4f80fe149326c68835217da4f2da9b7943fe go1.21.6.windows-386.zip
27ac9dd6e66fb3fd0acfa6792ff053c86e7d2c055b022f4b5d53bfddec9e3301 go1.21.6.windows-amd64.zip
b93aff8f3c882c764c66a39b7a1483b0460e051e9992bf3435479129e5051bcd go1.21.6.windows-arm64.zip
79c9b91d7f109515a25fc3ecdaad125d67e6bdb54f6d4d98580f46799caea321 go1.22.1.src.tar.gz
3bc971772f4712fec0364f4bc3de06af22a00a12daab10b6f717fdcd13156cc0 go1.22.1.darwin-amd64.tar.gz
f6a9cec6b8a002fcc9c0ee24ec04d67f430a52abc3cfd613836986bcc00d8383 go1.22.1.darwin-arm64.tar.gz
99f81c10d5a3f8a886faf8fa86aaa2aaf929fbed54a972ae5eec3c5e0bdb961a go1.22.1.freebsd-386.tar.gz
51c614ddd92ee4a9913a14c39bf80508d9cfba08561f24d2f075fd00f3cfb067 go1.22.1.freebsd-amd64.tar.gz
8484df36d3d40139eaf0fe5e647b006435d826cc12f9ae72973bf7ec265e0ae4 go1.22.1.linux-386.tar.gz
aab8e15785c997ae20f9c88422ee35d962c4562212bb0f879d052a35c8307c7f go1.22.1.linux-amd64.tar.gz
e56685a245b6a0c592fc4a55f0b7803af5b3f827aaa29feab1f40e491acf35b8 go1.22.1.linux-arm64.tar.gz
8cb7a90e48c20daed39a6ac8b8a40760030ba5e93c12274c42191d868687c281 go1.22.1.linux-armv6l.tar.gz
ac775e19d93cc1668999b77cfe8c8964abfbc658718feccfe6e0eb87663cd668 go1.22.1.linux-ppc64le.tar.gz
7bb7dd8e10f95c9a4cc4f6bef44c816a6e7c9e03f56ac6af6efbb082b19b379f go1.22.1.linux-s390x.tar.gz
0c5ebb7eb39b7884ec99f92b425d4c03a96a72443562aafbf6e7d15c42a3108a go1.22.1.windows-386.zip
cf9c66a208a106402a527f5b956269ca506cfe535fc388e828d249ea88ed28ba go1.22.1.windows-amd64.zip
85b8511b298c9f4199ecae26afafcc3d46155bac934d43f2357b9224bcaa310f go1.22.1.windows-arm64.zip

# version:golangci 1.55.2
# https://github.com/golangci/golangci-lint/releases/
Expand Down
57 changes: 57 additions & 0 deletions cmd/devp2p/discv4cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"net"
"net/http"
"strconv"
"strings"
"time"
Expand All @@ -28,9 +29,11 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/urfave/cli/v2"
)

Expand All @@ -45,6 +48,7 @@ var (
discv4ResolveJSONCommand,
discv4CrawlCommand,
discv4TestCommand,
discv4ListenCommand,
},
}
discv4PingCommand = &cli.Command{
Expand Down Expand Up @@ -75,6 +79,14 @@ var (
Flags: discoveryNodeFlags,
ArgsUsage: "<nodes.json file>",
}
discv4ListenCommand = &cli.Command{
Name: "listen",
Usage: "Runs a discovery node",
Action: discv4Listen,
Flags: flags.Merge(discoveryNodeFlags, []cli.Flag{
httpAddrFlag,
}),
}
discv4CrawlCommand = &cli.Command{
Name: "crawl",
Usage: "Updates a nodes.json file with random nodes found in the DHT",
Expand Down Expand Up @@ -131,6 +143,10 @@ var (
Usage: "Enode of the remote node under test",
EnvVars: []string{"REMOTE_ENODE"},
}
httpAddrFlag = &cli.StringFlag{
Name: "rpc",
Usage: "HTTP server listening address",
}
)

var discoveryNodeFlags = []cli.Flag{
Expand All @@ -154,6 +170,27 @@ func discv4Ping(ctx *cli.Context) error {
return nil
}

func discv4Listen(ctx *cli.Context) error {
disc, _ := startV4(ctx)
defer disc.Close()

fmt.Println(disc.Self())

httpAddr := ctx.String(httpAddrFlag.Name)
if httpAddr == "" {
// Non-HTTP mode.
select {}
}

api := &discv4API{disc}
log.Info("Starting RPC API server", "addr", httpAddr)
srv := rpc.NewServer()
srv.RegisterName("discv4", api)
http.DefaultServeMux.Handle("/", srv)
httpsrv := http.Server{Addr: httpAddr, Handler: http.DefaultServeMux}
return httpsrv.ListenAndServe()
}

func discv4RequestRecord(ctx *cli.Context) error {
n := getNodeArg(ctx)
disc, _ := startV4(ctx)
Expand Down Expand Up @@ -362,3 +399,23 @@ func parseBootnodes(ctx *cli.Context) ([]*enode.Node, error) {
}
return nodes, nil
}

type discv4API struct {
host *discover.UDPv4
}

func (api *discv4API) LookupRandom(n int) (ns []*enode.Node) {
it := api.host.RandomNodes()
for len(ns) < n && it.Next() {
ns = append(ns, it.Node())
}
return ns
}

func (api *discv4API) Buckets() [][]discover.BucketNode {
return api.host.TableBuckets()
}

func (api *discv4API) Self() *enode.Node {
return api.host.Self()
}
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/v4test/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (te *testenv) localEndpoint(c net.PacketConn) v4wire.Endpoint {
}

func (te *testenv) remoteEndpoint() v4wire.Endpoint {
return v4wire.NewEndpoint(te.remoteAddr, 0)
return v4wire.NewEndpoint(te.remoteAddr.AddrPort(), 0)
}

func contains(ns []v4wire.Node, key v4wire.Pubkey) bool {
Expand Down
7 changes: 4 additions & 3 deletions cmd/era/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"encoding/json"
"errors"
"fmt"
"math/big"
"os"
Expand Down Expand Up @@ -182,7 +183,7 @@ func open(ctx *cli.Context, epoch uint64) (*era.Era, error) {
// that the accumulator matches the expected value.
func verify(ctx *cli.Context) error {
if ctx.Args().Len() != 1 {
return fmt.Errorf("missing accumulators file")
return errors.New("missing accumulators file")
}

roots, err := readHashes(ctx.Args().First())
Expand All @@ -203,7 +204,7 @@ func verify(ctx *cli.Context) error {
}

if len(entries) != len(roots) {
return fmt.Errorf("number of era1 files should match the number of accumulator hashes")
return errors.New("number of era1 files should match the number of accumulator hashes")
}

// Verify each epoch matches the expected root.
Expand Down Expand Up @@ -308,7 +309,7 @@ func checkAccumulator(e *era.Era) error {
func readHashes(f string) ([]common.Hash, error) {
b, err := os.ReadFile(f)
if err != nil {
return nil, fmt.Errorf("unable to open accumulators file")
return nil, errors.New("unable to open accumulators file")
}
s := strings.Split(string(b), "\n")
// Remove empty last element, if present.
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func importHistory(ctx *cli.Context) error {
return fmt.Errorf("no era1 files found in %s", dir)
}
if len(networks) > 1 {
return fmt.Errorf("multiple networks found, use a network flag to specify desired network")
return errors.New("multiple networks found, use a network flag to specify desired network")
}
network = networks[0]
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func readList(filename string) ([]string, error) {
// starting from genesis.
func ImportHistory(chain *core.BlockChain, db ethdb.Database, dir string, network string) error {
if chain.CurrentSnapBlock().Number.BitLen() != 0 {
return fmt.Errorf("history import only supported when starting from genesis")
return errors.New("history import only supported when starting from genesis")
}
entries, err := era.ReadDir(dir, network)
if err != nil {
Expand Down
15 changes: 2 additions & 13 deletions consensus/ethash/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/binary"
"hash"
"math/big"
"reflect"
"runtime"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -176,12 +175,7 @@ func generateCache(dest []uint32, epoch uint64, epochLength uint64, seed []byte)
logFn("Generated ethash verification cache", "epochLength", epochLength, "elapsed", common.PrettyDuration(elapsed))
}()
// Convert our destination slice to a byte buffer
var cache []byte
cacheHdr := (*reflect.SliceHeader)(unsafe.Pointer(&cache))
dstHdr := (*reflect.SliceHeader)(unsafe.Pointer(&dest))
cacheHdr.Data = dstHdr.Data
cacheHdr.Len = dstHdr.Len * 4
cacheHdr.Cap = dstHdr.Cap * 4
cache := unsafe.Slice((*byte)(unsafe.Pointer(&dest[0])), len(dest)*4)

// Calculate the number of theoretical rows (we'll store in one buffer nonetheless)
size := uint64(len(cache))
Expand Down Expand Up @@ -310,12 +304,7 @@ func generateDataset(dest []uint32, epoch uint64, epochLength uint64, cache []ui
swapped := !isLittleEndian()

// Convert our destination slice to a byte buffer
var dataset []byte
datasetHdr := (*reflect.SliceHeader)(unsafe.Pointer(&dataset))
destHdr := (*reflect.SliceHeader)(unsafe.Pointer(&dest))
datasetHdr.Data = destHdr.Data
datasetHdr.Len = destHdr.Len * 4
datasetHdr.Cap = destHdr.Cap * 4
dataset := unsafe.Slice((*byte)(unsafe.Pointer(&dest[0])), len(dest)*4)

// Generate the dataset on many goroutines since it takes a while
threads := runtime.NumCPU()
Expand Down
7 changes: 1 addition & 6 deletions consensus/ethash/ethash.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"math/rand"
"os"
"path/filepath"
"reflect"
"runtime"
"strconv"
"sync"
Expand Down Expand Up @@ -144,11 +143,7 @@ func memoryMapFile(file *os.File, write bool) (mmap.MMap, []uint32, error) {
return nil, nil, err
}
// The file is now memory-mapped. Create a []uint32 view of the file.
var view []uint32
header := (*reflect.SliceHeader)(unsafe.Pointer(&view))
header.Data = (*reflect.SliceHeader)(unsafe.Pointer(&mem)).Data
header.Cap = len(mem) / 4
header.Len = header.Cap
view := unsafe.Slice((*uint32)(unsafe.Pointer(&mem[0])), len(mem)/4)
return mem, view, nil
}

Expand Down
Loading

0 comments on commit 479b6de

Please sign in to comment.