Skip to content

Commit c213fd1

Browse files
committed
all: import "context" instead of "golang.org/x/net/context"
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.
1 parent 525116d commit c213fd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+187
-437
lines changed

accounts/abi/bind/backend.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
package bind
1818

1919
import (
20+
"context"
2021
"errors"
2122
"math/big"
2223

2324
"github.com/ethereum/go-ethereum"
2425
"github.com/ethereum/go-ethereum/common"
2526
"github.com/ethereum/go-ethereum/core/types"
26-
"golang.org/x/net/context"
2727
)
2828

2929
var (

accounts/abi/bind/backends/simulated.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package backends
1818

1919
import (
20+
"context"
2021
"errors"
2122
"fmt"
2223
"math/big"
@@ -34,7 +35,6 @@ import (
3435
"github.com/ethereum/go-ethereum/event"
3536
"github.com/ethereum/go-ethereum/params"
3637
"github.com/ethereum/go-ethereum/pow"
37-
"golang.org/x/net/context"
3838
)
3939

4040
// Default chain configuration which sets homestead phase at block 0 (i.e. no frontier)

accounts/abi/bind/base.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package bind
1818

1919
import (
20+
"context"
2021
"errors"
2122
"fmt"
2223
"math/big"
@@ -26,7 +27,6 @@ import (
2627
"github.com/ethereum/go-ethereum/common"
2728
"github.com/ethereum/go-ethereum/core/types"
2829
"github.com/ethereum/go-ethereum/crypto"
29-
"golang.org/x/net/context"
3030
)
3131

3232
// SignerFn is a signer function callback when a contract requires a method to

accounts/abi/bind/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
package bind
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"time"
2223

2324
"github.com/ethereum/go-ethereum/common"
2425
"github.com/ethereum/go-ethereum/core/types"
2526
"github.com/ethereum/go-ethereum/log"
26-
"golang.org/x/net/context"
2727
)
2828

2929
// WaitMined waits for tx to be mined on the blockchain.

accounts/abi/bind/util_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package bind_test
1818

1919
import (
20+
"context"
2021
"math/big"
2122
"testing"
2223
"time"
@@ -27,7 +28,6 @@ import (
2728
"github.com/ethereum/go-ethereum/core"
2829
"github.com/ethereum/go-ethereum/core/types"
2930
"github.com/ethereum/go-ethereum/crypto"
30-
"golang.org/x/net/context"
3131
)
3232

3333
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")

accounts/usbwallet/ledger_wallet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package usbwallet
2222

2323
import (
24+
"context"
2425
"encoding/binary"
2526
"encoding/hex"
2627
"errors"
@@ -38,7 +39,6 @@ import (
3839
"github.com/ethereum/go-ethereum/log"
3940
"github.com/ethereum/go-ethereum/rlp"
4041
"github.com/karalabe/hid"
41-
"golang.org/x/net/context"
4242
)
4343

4444
// Maximum time between wallet health checks to detect USB unplugs.

build/_vendor/src/golang.org/x/net/LICENSE

-27
This file was deleted.

build/ci-notes.md

-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
# Vendored Dependencies
2-
3-
Dependencies are almost all vendored in at the standard Go `/vendor` path. This allows
4-
people to build go-ethereum using the standard toolchain without any particular package
5-
manager. It also plays nicely with `go get`, not requiring external code to be relied on.
6-
7-
The one single dependent package missing from `vendor` is `golang.org/x/net/context`. As
8-
this is a package exposed via public library APIs, it must not be vendored as dependent
9-
code woulnd't be able to instantiate.
10-
11-
To allow reproducible builds of go-ethereum nonetheless that don't need network access
12-
during build time to fetch `golang.org/x/net/context`, a version was copied into our repo
13-
at the very specific `/build/_vendor` path, which is added automatically by all CI build
14-
scripts and the makefile too.
15-
161
# Debian Packaging
172

183
Tagged releases and develop branch commits are available as installable Debian packages

contracts/chequebook/cheque.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package chequebook
2626

2727
import (
2828
"bytes"
29+
"context"
2930
"crypto/ecdsa"
3031
"encoding/json"
3132
"fmt"
@@ -43,7 +44,6 @@ import (
4344
"github.com/ethereum/go-ethereum/crypto"
4445
"github.com/ethereum/go-ethereum/log"
4546
"github.com/ethereum/go-ethereum/swarm/services/swap/swap"
46-
"golang.org/x/net/context"
4747
)
4848

4949
// TODO(zelig): watch peer solvency and notify of bouncing cheques

contracts/release/release.go

+38-36
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package release
2020
//go:generate abigen --sol ./contract.sol --pkg release --out ./contract.go
2121

2222
import (
23+
"context"
2324
"fmt"
2425
"strings"
2526
"time"
@@ -33,7 +34,6 @@ import (
3334
"github.com/ethereum/go-ethereum/node"
3435
"github.com/ethereum/go-ethereum/p2p"
3536
"github.com/ethereum/go-ethereum/rpc"
36-
"golang.org/x/net/context"
3737
)
3838

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

117117
for {
118118
select {
119-
// If the time arrived, check for a new release
120119
case <-timer.C:
121120
// Rechedule the timer before continuing
122121
timer.Reset(releaseRecheckInterval)
123-
124-
// Retrieve the current version, and handle missing contracts gracefully
125-
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
126-
opts := &bind.CallOpts{Context: ctx}
127-
version, err := r.oracle.CurrentVersion(opts)
128-
if err != nil {
129-
if err == bind.ErrNoCode {
130-
log.Debug("Release oracle not found", "contract", r.config.Oracle)
131-
continue
132-
}
133-
log.Error("Failed to retrieve current release", "err", err)
134-
continue
135-
}
136-
// Version was successfully retrieved, notify if newer than ours
137-
if version.Major > r.config.Major ||
138-
(version.Major == r.config.Major && version.Minor > r.config.Minor) ||
139-
(version.Major == r.config.Major && version.Minor == r.config.Minor && version.Patch > r.config.Patch) {
140-
141-
warning := fmt.Sprintf("Client v%d.%d.%d-%x seems older than the latest upstream release v%d.%d.%d-%x",
142-
r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4])
143-
howtofix := fmt.Sprintf("Please check https://github.com/ethereum/go-ethereum/releases for new releases")
144-
separator := strings.Repeat("-", len(warning))
145-
146-
log.Warn(separator)
147-
log.Warn(warning)
148-
log.Warn(howtofix)
149-
log.Warn(separator)
150-
} else {
151-
log.Debug("Client seems up to date with upstream",
152-
"local", fmt.Sprintf("v%d.%d.%d-%x", r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4]),
153-
"upstream", fmt.Sprintf("v%d.%d.%d-%x", version.Major, version.Minor, version.Patch, version.Commit[:4]))
154-
}
155-
156-
// If termination was requested, return
122+
r.checkVersion()
157123
case errc := <-r.quit:
158124
errc <- nil
159125
return
160126
}
161127
}
162128
}
129+
130+
func (r *ReleaseService) checkVersion() {
131+
// Retrieve the current version, and handle missing contracts gracefully
132+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
133+
opts := &bind.CallOpts{Context: ctx}
134+
defer cancel()
135+
136+
version, err := r.oracle.CurrentVersion(opts)
137+
if err != nil {
138+
if err == bind.ErrNoCode {
139+
log.Debug("Release oracle not found", "contract", r.config.Oracle)
140+
} else {
141+
log.Error("Failed to retrieve current release", "err", err)
142+
}
143+
return
144+
}
145+
// Version was successfully retrieved, notify if newer than ours
146+
if version.Major > r.config.Major ||
147+
(version.Major == r.config.Major && version.Minor > r.config.Minor) ||
148+
(version.Major == r.config.Major && version.Minor == r.config.Minor && version.Patch > r.config.Patch) {
149+
150+
warning := fmt.Sprintf("Client v%d.%d.%d-%x seems older than the latest upstream release v%d.%d.%d-%x",
151+
r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4])
152+
howtofix := fmt.Sprintf("Please check https://github.com/ethereum/go-ethereum/releases for new releases")
153+
separator := strings.Repeat("-", len(warning))
154+
155+
log.Warn(separator)
156+
log.Warn(warning)
157+
log.Warn(howtofix)
158+
log.Warn(separator)
159+
} else {
160+
log.Debug("Client seems up to date with upstream",
161+
"local", fmt.Sprintf("v%d.%d.%d-%x", r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4]),
162+
"upstream", fmt.Sprintf("v%d.%d.%d-%x", version.Major, version.Minor, version.Patch, version.Commit[:4]))
163+
}
164+
}

eth/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package eth
1919
import (
2020
"bytes"
2121
"compress/gzip"
22+
"context"
2223
"errors"
2324
"fmt"
2425
"io"
@@ -39,7 +40,6 @@ import (
3940
"github.com/ethereum/go-ethereum/miner"
4041
"github.com/ethereum/go-ethereum/params"
4142
"github.com/ethereum/go-ethereum/rlp"
42-
"golang.org/x/net/context"
4343
)
4444

4545
const defaultTraceTimeout = 5 * time.Second

eth/api_backend.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package eth
1818

1919
import (
20+
"context"
2021
"math/big"
2122

2223
"github.com/ethereum/go-ethereum/accounts"
@@ -33,7 +34,6 @@ import (
3334
"github.com/ethereum/go-ethereum/internal/ethapi"
3435
"github.com/ethereum/go-ethereum/params"
3536
"github.com/ethereum/go-ethereum/rpc"
36-
"golang.org/x/net/context"
3737
)
3838

3939
// EthApiBackend implements ethapi.Backend for full nodes

eth/bind.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package eth
1818

1919
import (
20+
"context"
2021
"math/big"
2122

2223
"github.com/ethereum/go-ethereum"
@@ -26,7 +27,6 @@ import (
2627
"github.com/ethereum/go-ethereum/internal/ethapi"
2728
"github.com/ethereum/go-ethereum/rlp"
2829
"github.com/ethereum/go-ethereum/rpc"
29-
"golang.org/x/net/context"
3030
)
3131

3232
// ContractBackend implements bind.ContractBackend with direct calls to Ethereum

eth/downloader/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
package downloader
1818

1919
import (
20+
"context"
2021
"sync"
2122

2223
ethereum "github.com/ethereum/go-ethereum"
2324
"github.com/ethereum/go-ethereum/event"
2425
"github.com/ethereum/go-ethereum/rpc"
25-
"golang.org/x/net/context"
2626
)
2727

2828
// PublicDownloaderAPI provides an API which gives information about the current synchronisation status.

eth/filters/api.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
package filters
1818

1919
import (
20+
"context"
2021
"encoding/json"
2122
"errors"
2223
"fmt"
2324
"math/big"
2425
"sync"
2526
"time"
2627

27-
"golang.org/x/net/context"
28-
2928
"github.com/ethereum/go-ethereum/common"
3029
"github.com/ethereum/go-ethereum/common/hexutil"
3130
"github.com/ethereum/go-ethereum/core/types"

eth/filters/filter.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@
1717
package filters
1818

1919
import (
20+
"context"
2021
"math"
21-
"time"
22-
2322
"math/big"
23+
"time"
2424

2525
"github.com/ethereum/go-ethereum/common"
2626
"github.com/ethereum/go-ethereum/core"
2727
"github.com/ethereum/go-ethereum/core/types"
2828
"github.com/ethereum/go-ethereum/ethdb"
2929
"github.com/ethereum/go-ethereum/event"
3030
"github.com/ethereum/go-ethereum/rpc"
31-
"golang.org/x/net/context"
3231
)
3332

3433
type Backend interface {

eth/filters/filter_system.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package filters
2020

2121
import (
22+
"context"
2223
"errors"
2324
"fmt"
2425
"sync"
@@ -29,7 +30,6 @@ import (
2930
"github.com/ethereum/go-ethereum/core/types"
3031
"github.com/ethereum/go-ethereum/event"
3132
"github.com/ethereum/go-ethereum/rpc"
32-
"golang.org/x/net/context"
3333
)
3434

3535
// Type determines the kind of filter and is used to put the filter in to
@@ -372,7 +372,8 @@ func (es *EventSystem) lightFilterNewHead(newHeader *types.Header, callBack func
372372
func (es *EventSystem) lightFilterLogs(header *types.Header, addresses []common.Address, topics [][]common.Hash, remove bool) []*types.Log {
373373
if bloomFilter(header.Bloom, addresses, topics) {
374374
// Get the logs of the block
375-
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
375+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
376+
defer cancel()
376377
receipts, err := es.backend.GetReceipts(ctx, header.Hash())
377378
if err != nil {
378379
return nil

eth/filters/filter_system_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
package filters
1818

1919
import (
20+
"context"
2021
"math/big"
2122
"reflect"
2223
"testing"
2324
"time"
2425

25-
"golang.org/x/net/context"
26-
2726
"github.com/ethereum/go-ethereum/common"
2827
"github.com/ethereum/go-ethereum/core"
2928
"github.com/ethereum/go-ethereum/core/types"

0 commit comments

Comments
 (0)