Skip to content

Commit 571b42d

Browse files
committed
Merge remote-tracking branch 'origin/master' into snap_sync
2 parents e2d1583 + 0a65849 commit 571b42d

File tree

462 files changed

+22460
-20058
lines changed

Some content is hidden

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

462 files changed

+22460
-20058
lines changed

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ use separate accounts for play and real money. Unless you manually move
123123
accounts, `geth` will by default correctly separate the two networks and will not make any
124124
accounts available between them.*
125125

126-
### Full node on the Rinkeby test network
127-
128-
Go Ethereum also supports connecting to the older proof-of-authority based test network
129-
called [*Rinkeby*](https://www.rinkeby.io) which is operated by members of the community.
130-
131-
```shell
132-
$ geth --rinkeby console
133-
```
134-
135126
### Configuration
136127

137128
As an alternative to passing the numerous flags to the `geth` binary, you can also pass a

accounts/abi/bind/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
var (
3030
// ErrNoCode is returned by call and transact operations for which the requested
3131
// recipient contract to operate on does not exist in the state db or does not
32-
// have any code associated with it (i.e. suicided).
32+
// have any code associated with it (i.e. self-destructed).
3333
ErrNoCode = errors.New("no contract code at given address")
3434

3535
// ErrNoPendingState is raised when attempting to perform a pending state action

accounts/abi/bind/backends/simulated.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
681681
// Get the last block
682682
block, err := b.blockByHash(ctx, b.pendingBlock.ParentHash())
683683
if err != nil {
684-
return fmt.Errorf("could not fetch parent")
684+
return errors.New("could not fetch parent")
685685
}
686686
// Check transaction validity
687687
signer := types.MakeSigner(b.blockchain.Config(), block.Number(), block.Time())
@@ -815,7 +815,7 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
815815
// Get the last block
816816
block := b.blockchain.GetBlockByHash(b.pendingBlock.ParentHash())
817817
if block == nil {
818-
return fmt.Errorf("could not find parent")
818+
return errors.New("could not find parent")
819819
}
820820

821821
blocks, _ := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {

accounts/abi/bind/backends/simulated_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func TestAdjustTime(t *testing.T) {
161161
func TestNewAdjustTimeFail(t *testing.T) {
162162
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
163163
sim := simTestBackend(testAddr)
164+
defer sim.blockchain.Stop()
164165

165166
// Create tx and send
166167
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough

accounts/abi/bind/template.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ var (
325325
if err != nil {
326326
return *outstruct, err
327327
}
328-
{{range $i, $t := .Normalized.Outputs}}
328+
{{range $i, $t := .Normalized.Outputs}}
329329
outstruct.{{.Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}
330330
331331
return *outstruct, err
@@ -335,7 +335,7 @@ var (
335335
}
336336
{{range $i, $t := .Normalized.Outputs}}
337337
out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}
338-
338+
339339
return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} err
340340
{{end}}
341341
}
@@ -378,7 +378,7 @@ var (
378378
}
379379
{{end}}
380380
381-
{{if .Fallback}}
381+
{{if .Fallback}}
382382
// Fallback is a paid mutator transaction binding the contract fallback function.
383383
//
384384
// Solidity: {{.Fallback.Original.String}}
@@ -392,16 +392,16 @@ var (
392392
func (_{{$contract.Type}} *{{$contract.Type}}Session) Fallback(calldata []byte) (*types.Transaction, error) {
393393
return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata)
394394
}
395-
395+
396396
// Fallback is a paid mutator transaction binding the contract fallback function.
397-
//
397+
//
398398
// Solidity: {{.Fallback.Original.String}}
399399
func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Fallback(calldata []byte) (*types.Transaction, error) {
400400
return _{{$contract.Type}}.Contract.Fallback(&_{{$contract.Type}}.TransactOpts, calldata)
401401
}
402402
{{end}}
403403
404-
{{if .Receive}}
404+
{{if .Receive}}
405405
// Receive is a paid mutator transaction binding the contract receive function.
406406
//
407407
// Solidity: {{.Receive.Original.String}}
@@ -415,9 +415,9 @@ var (
415415
func (_{{$contract.Type}} *{{$contract.Type}}Session) Receive() (*types.Transaction, error) {
416416
return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts)
417417
}
418-
418+
419419
// Receive is a paid mutator transaction binding the contract receive function.
420-
//
420+
//
421421
// Solidity: {{.Receive.Original.String}}
422422
func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) Receive() (*types.Transaction, error) {
423423
return _{{$contract.Type}}.Contract.Receive(&_{{$contract.Type}}.TransactOpts)

accounts/abi/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Error struct {
3232
str string
3333

3434
// Sig contains the string signature according to the ABI spec.
35-
// e.g. error foo(uint32 a, int b) = "foo(uint32,int256)"
35+
// e.g. error foo(uint32 a, int b) = "foo(uint32,int256)"
3636
// Please note that "int" is substitute for its canonical representation "int256"
3737
Sig string
3838

accounts/abi/reflect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[stri
228228
structFieldName := ToCamelCase(argName)
229229

230230
if structFieldName == "" {
231-
return nil, fmt.Errorf("abi: purely underscored output cannot unpack to struct")
231+
return nil, errors.New("abi: purely underscored output cannot unpack to struct")
232232
}
233233

234234
// this abi has already been paired, skip it... unless there exists another, yet unassigned

accounts/abi/selector_parser.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package abi
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
)
2223

@@ -40,7 +41,7 @@ func isIdentifierSymbol(c byte) bool {
4041

4142
func parseToken(unescapedSelector string, isIdent bool) (string, string, error) {
4243
if len(unescapedSelector) == 0 {
43-
return "", "", fmt.Errorf("empty token")
44+
return "", "", errors.New("empty token")
4445
}
4546
firstChar := unescapedSelector[0]
4647
position := 1
@@ -110,7 +111,7 @@ func parseCompositeType(unescapedSelector string) ([]interface{}, string, error)
110111

111112
func parseType(unescapedSelector string) (interface{}, string, error) {
112113
if len(unescapedSelector) == 0 {
113-
return nil, "", fmt.Errorf("empty type")
114+
return nil, "", errors.New("empty type")
114115
}
115116
if unescapedSelector[0] == '(' {
116117
return parseCompositeType(unescapedSelector)

accounts/abi/type.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var (
7070
func NewType(t string, internalType string, components []ArgumentMarshaling) (typ Type, err error) {
7171
// check that array brackets are equal if they exist
7272
if strings.Count(t, "[") != strings.Count(t, "]") {
73-
return Type{}, fmt.Errorf("invalid arg type in abi")
73+
return Type{}, errors.New("invalid arg type in abi")
7474
}
7575
typ.stringKind = t
7676

@@ -109,7 +109,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
109109
}
110110
typ.stringKind = embeddedType.stringKind + sliced
111111
} else {
112-
return Type{}, fmt.Errorf("invalid formatting of array type")
112+
return Type{}, errors.New("invalid formatting of array type")
113113
}
114114
return typ, err
115115
}
@@ -348,7 +348,7 @@ func (t Type) pack(v reflect.Value) ([]byte, error) {
348348
}
349349
}
350350

351-
// requireLengthPrefix returns whether the type requires any sort of length
351+
// requiresLengthPrefix returns whether the type requires any sort of length
352352
// prefixing.
353353
func (t Type) requiresLengthPrefix() bool {
354354
return t.T == StringTy || t.T == BytesTy || t.T == SliceTy

accounts/abi/unpack.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package abi
1818

1919
import (
2020
"encoding/binary"
21+
"errors"
2122
"fmt"
2223
"math"
2324
"math/big"
@@ -125,7 +126,7 @@ func readBool(word []byte) (bool, error) {
125126
// readFunctionType enforces that standard by always presenting it as a 24-array (address + sig = 24 bytes)
126127
func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
127128
if t.T != FunctionTy {
128-
return [24]byte{}, fmt.Errorf("abi: invalid type in call to make function type byte array")
129+
return [24]byte{}, errors.New("abi: invalid type in call to make function type byte array")
129130
}
130131
if garbage := binary.BigEndian.Uint64(word[24:32]); garbage != 0 {
131132
err = fmt.Errorf("abi: got improperly encoded function type, got %v", word)
@@ -138,7 +139,7 @@ func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
138139
// ReadFixedBytes uses reflection to create a fixed array to be read from.
139140
func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
140141
if t.T != FixedBytesTy {
141-
return nil, fmt.Errorf("abi: invalid type in call to make fixed byte array")
142+
return nil, errors.New("abi: invalid type in call to make fixed byte array")
142143
}
143144
// convert
144145
array := reflect.New(t.GetType()).Elem()
@@ -166,7 +167,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
166167
// declare our array
167168
refSlice = reflect.New(t.GetType()).Elem()
168169
} else {
169-
return nil, fmt.Errorf("abi: invalid type in array/slice unpacking stage")
170+
return nil, errors.New("abi: invalid type in array/slice unpacking stage")
170171
}
171172

172173
// Arrays have packed elements, resulting in longer unpack steps.

accounts/external/backend.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package external
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"math/big"
2223
"sync"
@@ -98,11 +99,11 @@ func (api *ExternalSigner) Status() (string, error) {
9899
}
99100

100101
func (api *ExternalSigner) Open(passphrase string) error {
101-
return fmt.Errorf("operation not supported on external signers")
102+
return errors.New("operation not supported on external signers")
102103
}
103104

104105
func (api *ExternalSigner) Close() error {
105-
return fmt.Errorf("operation not supported on external signers")
106+
return errors.New("operation not supported on external signers")
106107
}
107108

108109
func (api *ExternalSigner) Accounts() []accounts.Account {
@@ -145,7 +146,7 @@ func (api *ExternalSigner) Contains(account accounts.Account) bool {
145146
}
146147

147148
func (api *ExternalSigner) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error) {
148-
return accounts.Account{}, fmt.Errorf("operation not supported on external signers")
149+
return accounts.Account{}, errors.New("operation not supported on external signers")
149150
}
150151

151152
func (api *ExternalSigner) SelfDerive(bases []accounts.DerivationPath, chain ethereum.ChainStateReader) {
@@ -242,14 +243,14 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
242243
}
243244

244245
func (api *ExternalSigner) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
245-
return []byte{}, fmt.Errorf("password-operations not supported on external signers")
246+
return []byte{}, errors.New("password-operations not supported on external signers")
246247
}
247248

248249
func (api *ExternalSigner) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
249-
return nil, fmt.Errorf("password-operations not supported on external signers")
250+
return nil, errors.New("password-operations not supported on external signers")
250251
}
251252
func (api *ExternalSigner) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
252-
return nil, fmt.Errorf("password-operations not supported on external signers")
253+
return nil, errors.New("password-operations not supported on external signers")
253254
}
254255

255256
func (api *ExternalSigner) listAccounts() ([]common.Address, error) {

accounts/keystore/account_cache.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ import (
3131
"github.com/ethereum/go-ethereum/accounts"
3232
"github.com/ethereum/go-ethereum/common"
3333
"github.com/ethereum/go-ethereum/log"
34+
"golang.org/x/exp/slices"
3435
)
3536

3637
// Minimum amount of time between cache reloads. This limit applies if the platform does
3738
// not support change notifications. It also applies if the keystore directory does not
3839
// exist yet, the code will attempt to create a watcher at most this often.
3940
const minReloadInterval = 2 * time.Second
4041

41-
type accountsByURL []accounts.Account
42-
43-
func (s accountsByURL) Len() int { return len(s) }
44-
func (s accountsByURL) Less(i, j int) bool { return s[i].URL.Cmp(s[j].URL) < 0 }
45-
func (s accountsByURL) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
42+
// byURL defines the sorting order for accounts.
43+
func byURL(a, b accounts.Account) int {
44+
return a.URL.Cmp(b.URL)
45+
}
4646

4747
// AmbiguousAddrError is returned when attempting to unlock
4848
// an address for which more than one file exists.
@@ -67,7 +67,7 @@ type accountCache struct {
6767
keydir string
6868
watcher *watcher
6969
mu sync.Mutex
70-
all accountsByURL
70+
all []accounts.Account
7171
byAddr map[common.Address][]accounts.Account
7272
throttle *time.Timer
7373
notify chan struct{}
@@ -194,7 +194,7 @@ func (ac *accountCache) find(a accounts.Account) (accounts.Account, error) {
194194
default:
195195
err := &AmbiguousAddrError{Addr: a.Address, Matches: make([]accounts.Account, len(matches))}
196196
copy(err.Matches, matches)
197-
sort.Sort(accountsByURL(err.Matches))
197+
slices.SortFunc(err.Matches, byURL)
198198
return accounts.Account{}, err
199199
}
200200
}

accounts/keystore/account_cache_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@
1717
package keystore
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"math/rand"
2223
"os"
2324
"path/filepath"
2425
"reflect"
25-
"sort"
2626
"testing"
2727
"time"
2828

2929
"github.com/cespare/cp"
3030
"github.com/davecgh/go-spew/spew"
3131
"github.com/ethereum/go-ethereum/accounts"
3232
"github.com/ethereum/go-ethereum/common"
33+
"golang.org/x/exp/slices"
3334
)
3435

3536
var (
@@ -74,7 +75,7 @@ func waitForAccounts(wantAccounts []accounts.Account, ks *KeyStore) error {
7475
select {
7576
case <-ks.changes:
7677
default:
77-
return fmt.Errorf("wasn't notified of new accounts")
78+
return errors.New("wasn't notified of new accounts")
7879
}
7980
return nil
8081
}
@@ -202,7 +203,7 @@ func TestCacheAddDeleteOrder(t *testing.T) {
202203
// Check that the account list is sorted by filename.
203204
wantAccounts := make([]accounts.Account, len(accs))
204205
copy(wantAccounts, accs)
205-
sort.Sort(accountsByURL(wantAccounts))
206+
slices.SortFunc(wantAccounts, byURL)
206207
list := cache.accounts()
207208
if !reflect.DeepEqual(list, wantAccounts) {
208209
t.Fatalf("got accounts: %s\nwant %s", spew.Sdump(accs), spew.Sdump(wantAccounts))

accounts/keystore/keystore_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"math/rand"
2121
"os"
2222
"runtime"
23-
"sort"
2423
"strings"
2524
"sync"
2625
"sync/atomic"
@@ -31,6 +30,7 @@ import (
3130
"github.com/ethereum/go-ethereum/common"
3231
"github.com/ethereum/go-ethereum/crypto"
3332
"github.com/ethereum/go-ethereum/event"
33+
"golang.org/x/exp/slices"
3434
)
3535

3636
var testSigData = make([]byte, 32)
@@ -397,19 +397,19 @@ func TestImportRace(t *testing.T) {
397397
t.Fatalf("failed to export account: %v", acc)
398398
}
399399
_, ks2 := tmpKeyStore(t, true)
400-
var atom uint32
400+
var atom atomic.Uint32
401401
var wg sync.WaitGroup
402402
wg.Add(2)
403403
for i := 0; i < 2; i++ {
404404
go func() {
405405
defer wg.Done()
406406
if _, err := ks2.Import(json, "new", "new"); err != nil {
407-
atomic.AddUint32(&atom, 1)
407+
atom.Add(1)
408408
}
409409
}()
410410
}
411411
wg.Wait()
412-
if atom != 1 {
412+
if atom.Load() != 1 {
413413
t.Errorf("Import is racy")
414414
}
415415
}
@@ -424,7 +424,7 @@ func checkAccounts(t *testing.T, live map[common.Address]accounts.Account, walle
424424
for _, account := range live {
425425
liveList = append(liveList, account)
426426
}
427-
sort.Sort(accountsByURL(liveList))
427+
slices.SortFunc(liveList, byURL)
428428
for j, wallet := range wallets {
429429
if accs := wallet.Accounts(); len(accs) != 1 {
430430
t.Errorf("wallet %d: contains invalid number of accounts: have %d, want 1", j, len(accs))

0 commit comments

Comments
 (0)