Skip to content

Commit

Permalink
all: import "context" instead of "golang.org/x/net/context"
Browse files Browse the repository at this point in the history
There is no need to depend on the old context package now that the
minimum Go version is 1.7. The move to "context" eliminates our weird
vendoring setup. Some vendored code still uses golang.org/x/net/context
and it is now vendored in the normal way.

This change triggered new vet checks around context.WithTimeout which
didn't fire with golang.org/x/net/context.
  • Loading branch information
fjl committed Mar 22, 2017
1 parent 525116d commit c213fd1
Show file tree
Hide file tree
Showing 69 changed files with 187 additions and 437 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/bind/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package bind

import (
"context"
"errors"
"math/big"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"golang.org/x/net/context"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package backends

import (
"context"
"errors"
"fmt"
"math/big"
Expand All @@ -34,7 +35,6 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
"golang.org/x/net/context"
)

// Default chain configuration which sets homestead phase at block 0 (i.e. no frontier)
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package bind

import (
"context"
"errors"
"fmt"
"math/big"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"golang.org/x/net/context"
)

// SignerFn is a signer function callback when a contract requires a method to
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package bind

import (
"context"
"fmt"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"golang.org/x/net/context"
)

// WaitMined waits for tx to be mined on the blockchain.
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package bind_test

import (
"context"
"math/big"
"testing"
"time"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"golang.org/x/net/context"
)

var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
Expand Down
2 changes: 1 addition & 1 deletion accounts/usbwallet/ledger_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package usbwallet

import (
"context"
"encoding/binary"
"encoding/hex"
"errors"
Expand All @@ -38,7 +39,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/karalabe/hid"
"golang.org/x/net/context"
)

// Maximum time between wallet health checks to detect USB unplugs.
Expand Down
27 changes: 0 additions & 27 deletions build/_vendor/src/golang.org/x/net/LICENSE

This file was deleted.

15 changes: 0 additions & 15 deletions build/ci-notes.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
# Vendored Dependencies

Dependencies are almost all vendored in at the standard Go `/vendor` path. This allows
people to build go-ethereum using the standard toolchain without any particular package
manager. It also plays nicely with `go get`, not requiring external code to be relied on.

The one single dependent package missing from `vendor` is `golang.org/x/net/context`. As
this is a package exposed via public library APIs, it must not be vendored as dependent
code woulnd't be able to instantiate.

To allow reproducible builds of go-ethereum nonetheless that don't need network access
during build time to fetch `golang.org/x/net/context`, a version was copied into our repo
at the very specific `/build/_vendor` path, which is added automatically by all CI build
scripts and the makefile too.

# Debian Packaging

Tagged releases and develop branch commits are available as installable Debian packages
Expand Down
2 changes: 1 addition & 1 deletion contracts/chequebook/cheque.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package chequebook

import (
"bytes"
"context"
"crypto/ecdsa"
"encoding/json"
"fmt"
Expand All @@ -43,7 +44,6 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/services/swap/swap"
"golang.org/x/net/context"
)

// TODO(zelig): watch peer solvency and notify of bouncing cheques
Expand Down
74 changes: 38 additions & 36 deletions contracts/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package release
//go:generate abigen --sol ./contract.sol --pkg release --out ./contract.go

import (
"context"
"fmt"
"strings"
"time"
Expand All @@ -33,7 +34,6 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
"golang.org/x/net/context"
)

// Interval to check for new releases
Expand Down Expand Up @@ -116,47 +116,49 @@ func (r *ReleaseService) checker() {

for {
select {
// If the time arrived, check for a new release
case <-timer.C:
// Rechedule the timer before continuing
timer.Reset(releaseRecheckInterval)

// Retrieve the current version, and handle missing contracts gracefully
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
opts := &bind.CallOpts{Context: ctx}
version, err := r.oracle.CurrentVersion(opts)
if err != nil {
if err == bind.ErrNoCode {
log.Debug("Release oracle not found", "contract", r.config.Oracle)
continue
}
log.Error("Failed to retrieve current release", "err", err)
continue
}
// Version was successfully retrieved, notify if newer than ours
if version.Major > r.config.Major ||
(version.Major == r.config.Major && version.Minor > r.config.Minor) ||
(version.Major == r.config.Major && version.Minor == r.config.Minor && version.Patch > r.config.Patch) {

warning := fmt.Sprintf("Client v%d.%d.%d-%x seems older than the latest upstream release v%d.%d.%d-%x",
r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4])
howtofix := fmt.Sprintf("Please check https://github.com/ethereum/go-ethereum/releases for new releases")
separator := strings.Repeat("-", len(warning))

log.Warn(separator)
log.Warn(warning)
log.Warn(howtofix)
log.Warn(separator)
} else {
log.Debug("Client seems up to date with upstream",
"local", fmt.Sprintf("v%d.%d.%d-%x", r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4]),
"upstream", fmt.Sprintf("v%d.%d.%d-%x", version.Major, version.Minor, version.Patch, version.Commit[:4]))
}

// If termination was requested, return
r.checkVersion()
case errc := <-r.quit:
errc <- nil
return
}
}
}

func (r *ReleaseService) checkVersion() {
// Retrieve the current version, and handle missing contracts gracefully
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
opts := &bind.CallOpts{Context: ctx}
defer cancel()

version, err := r.oracle.CurrentVersion(opts)
if err != nil {
if err == bind.ErrNoCode {
log.Debug("Release oracle not found", "contract", r.config.Oracle)
} else {
log.Error("Failed to retrieve current release", "err", err)
}
return
}
// Version was successfully retrieved, notify if newer than ours
if version.Major > r.config.Major ||
(version.Major == r.config.Major && version.Minor > r.config.Minor) ||
(version.Major == r.config.Major && version.Minor == r.config.Minor && version.Patch > r.config.Patch) {

warning := fmt.Sprintf("Client v%d.%d.%d-%x seems older than the latest upstream release v%d.%d.%d-%x",
r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4])
howtofix := fmt.Sprintf("Please check https://github.com/ethereum/go-ethereum/releases for new releases")
separator := strings.Repeat("-", len(warning))

log.Warn(separator)
log.Warn(warning)
log.Warn(howtofix)
log.Warn(separator)
} else {
log.Debug("Client seems up to date with upstream",
"local", fmt.Sprintf("v%d.%d.%d-%x", r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4]),
"upstream", fmt.Sprintf("v%d.%d.%d-%x", version.Major, version.Minor, version.Patch, version.Commit[:4]))
}
}
2 changes: 1 addition & 1 deletion eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eth
import (
"bytes"
"compress/gzip"
"context"
"errors"
"fmt"
"io"
Expand All @@ -39,7 +40,6 @@ import (
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"golang.org/x/net/context"
)

const defaultTraceTimeout = 5 * time.Second
Expand Down
2 changes: 1 addition & 1 deletion eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package eth

import (
"context"
"math/big"

"github.com/ethereum/go-ethereum/accounts"
Expand All @@ -33,7 +34,6 @@ import (
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"golang.org/x/net/context"
)

// EthApiBackend implements ethapi.Backend for full nodes
Expand Down
2 changes: 1 addition & 1 deletion eth/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package eth

import (
"context"
"math/big"

"github.com/ethereum/go-ethereum"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"golang.org/x/net/context"
)

// ContractBackend implements bind.ContractBackend with direct calls to Ethereum
Expand Down
2 changes: 1 addition & 1 deletion eth/downloader/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package downloader

import (
"context"
"sync"

ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"
"golang.org/x/net/context"
)

// PublicDownloaderAPI provides an API which gives information about the current synchronisation status.
Expand Down
3 changes: 1 addition & 2 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
package filters

import (
"context"
"encoding/json"
"errors"
"fmt"
"math/big"
"sync"
"time"

"golang.org/x/net/context"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
Expand Down
5 changes: 2 additions & 3 deletions eth/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
package filters

import (
"context"
"math"
"time"

"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"
"golang.org/x/net/context"
)

type Backend interface {
Expand Down
5 changes: 3 additions & 2 deletions eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package filters

import (
"context"
"errors"
"fmt"
"sync"
Expand All @@ -29,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"
"golang.org/x/net/context"
)

// Type determines the kind of filter and is used to put the filter in to
Expand Down Expand Up @@ -372,7 +372,8 @@ func (es *EventSystem) lightFilterNewHead(newHeader *types.Header, callBack func
func (es *EventSystem) lightFilterLogs(header *types.Header, addresses []common.Address, topics [][]common.Hash, remove bool) []*types.Log {
if bloomFilter(header.Bloom, addresses, topics) {
// Get the logs of the block
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
receipts, err := es.backend.GetReceipts(ctx, header.Hash())
if err != nil {
return nil
Expand Down
3 changes: 1 addition & 2 deletions eth/filters/filter_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
package filters

import (
"context"
"math/big"
"reflect"
"testing"
"time"

"golang.org/x/net/context"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
Expand Down
Loading

0 comments on commit c213fd1

Please sign in to comment.