Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged the second part of 1.10.18 #2190

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ce8e407
Merge pull request #147 from PlatONnetwork/feature/bump-version-to-1.5.0
niuxiaojie81 Nov 1, 2023
1e7c7ad
Merge pull request #148 from PlatONnetwork/feature/bump-version-to-1.5.0
niuxiaojie81 Nov 8, 2023
dabd6db
Merge branch 'feature/bump-version-to-1.5.1' of https://github.com/Pl…
niuxiaojie81 Nov 8, 2023
8f73917
build: ppa build for jammy (ubuntu 22.04) #24813
niuxiaojie81 Nov 8, 2023
e951951
eth/protocols/eth: fix godoc comments #24810
niuxiaojie81 Nov 8, 2023
68fb2ae
eth/filters: remove explicit continue label in filterLogs #24795
niuxiaojie81 Nov 8, 2023
d53512b
p2p/simulations: escape mockerType value from request #24822
niuxiaojie81 Nov 8, 2023
b1de987
p2p/simulations: fix typo in network_test.go #24824
niuxiaojie81 Nov 8, 2023
05f045f
core/rawdb: untie freezer and ancient chain data #24684
niuxiaojie81 Nov 8, 2023
93935b0
core/vm: implement EIP-3855: PUSH0 instruction #24039
niuxiaojie81 Nov 8, 2023
c67782b
eth/fetcher: fix test to avoid hanging. Partial fix for #23331 #23351
niuxiaojie81 Nov 9, 2023
1315a04
abi: fix checks when all fields are indexed #24792
niuxiaojie81 Nov 9, 2023
9af38be
core/state/snapshot: fix race condition #24685
niuxiaojie81 Nov 9, 2023
b66731a
all: replace strings.Replace with string.ReplaceAll #24835
niuxiaojie81 Nov 9, 2023
df668f9
Update benchmark to use bench format instead of wrapping fmt sprintf …
niuxiaojie81 Nov 9, 2023
f5b9da3
eth/protocols/snap: sort trienode heal requests by path #24779
niuxiaojie81 Nov 9, 2023
6aaa0e8
core/vm: clean code #24851
niuxiaojie81 Nov 9, 2023
75da9fc
core/vm: fix comment like in opCodeToString #24850
niuxiaojie81 Nov 9, 2023
9b0e19e
ethclient: add PeerCount method #24849
niuxiaojie81 Nov 9, 2023
bc443d8
core/vm: remove unnecessary memset for Memory.Set32 #24847
niuxiaojie81 Nov 9, 2023
23ef3ff
graphql: fix long literal passed in a variable #24864
niuxiaojie81 Nov 9, 2023
2c7b3b7
internal/ethapi: add debug_getRawReceipts RPC method #24773
niuxiaojie81 Nov 9, 2023
91067dd
core/asm: use strings.Builder and fix godoc issues #24861
niuxiaojie81 Nov 9, 2023
080cd22
eth: fix flaky test #24885
niuxiaojie81 Nov 9, 2023
84987ca
graphql: add raw fields to block and tx #24816
niuxiaojie81 Nov 9, 2023
8dca43e
all: replace uses of ioutil with io and os #24869
niuxiaojie81 Nov 9, 2023
68ef2a5
all: replace non-trivial uses of ioutil with os #24886
niuxiaojie81 Nov 9, 2023
11f7bb2
all: use strings.EqualFold for string comparison #24890
niuxiaojie81 Nov 9, 2023
1f3d483
tests: update reference tests #24899
niuxiaojie81 Nov 10, 2023
14acda0
core: fix the order of address in queue #24908
niuxiaojie81 Nov 10, 2023
8c5ef88
accounts/abi: validate fieldnames, fixes #24930 #24932
niuxiaojie81 Nov 10, 2023
fc1331a
signer/core: always pad clique header extra data with space for seale…
niuxiaojie81 Nov 10, 2023
c88ef64
core/vm: for tracing, do not report post-op memory #24867
niuxiaojie81 Nov 10, 2023
9f57d3b
common/compiler, cmd/abigen: remove solc/vyper compiler integration #…
niuxiaojie81 Nov 10, 2023
43ed52d
ethdb/remotedb, cmd: add support for remote (readonly) databases #24836
niuxiaojie81 Nov 10, 2023
1d658c6
ethdb/remotedb: fix flawed check in Has/HasAncient #24905
niuxiaojie81 Nov 10, 2023
5c3e18c
eth: core: implement final block #24282
niuxiaojie81 Nov 10, 2023
cb1a839
fix
niuxiaojie81 Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (arguments Arguments) isTuple() bool {
// Unpack performs the operation hexdata -> Go format.
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
if len(data) == 0 {
if len(arguments) != 0 {
if len(arguments.NonIndexed()) != 0 {
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
}
return make([]interface{}, 0), nil
Expand All @@ -93,7 +93,7 @@ func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte)
return fmt.Errorf("abi: cannot unpack into a nil map")
}
if len(data) == 0 {
if len(arguments) != 0 {
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
}
return nil // Nothing to unmarshal, return
Expand All @@ -115,8 +115,8 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
}
if len(values) == 0 {
if len(arguments) != 0 {
return fmt.Errorf("abi: attempting to copy no values while %d arguments are expected", len(arguments))
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
}
return nil // Nothing to copy, return
}
Expand Down
5 changes: 2 additions & 3 deletions accounts/abi/bind/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"crypto/ecdsa"
"errors"
"io"
"io/ioutil"
"math/big"

"github.com/PlatONnetwork/PlatON-Go/accounts"
Expand All @@ -44,7 +43,7 @@ var ErrNotAuthorized = errors.New("not authorized to sign this account")
// Deprecated: Use NewTransactorWithChainID instead.
func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
log.Warn("WARNING: NewTransactor has been deprecated in favour of NewTransactorWithChainID")
json, err := ioutil.ReadAll(keyin)
json, err := io.ReadAll(keyin)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -103,7 +102,7 @@ func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
// NewTransactorWithChainID is a utility method to easily create a transaction signer from
// an encrypted json key stream and the associated passphrase.
func NewTransactorWithChainID(keyin io.Reader, passphrase string, chainID *big.Int) (*TransactOpts, error) {
json, err := ioutil.ReadAll(keyin)
json, err := io.ReadAll(keyin)
if err != nil {
return nil, err
}
Expand Down
8 changes: 8 additions & 0 deletions accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,11 @@ func newMockLog(topics []common.Hash, txHash common.Hash) types.Log {
Removed: false,
}
}

// TestCrashers contains some strings which previously caused the abi codec to crash.
func TestCrashers(t *testing.T) {
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"_1"}]}]}]`))
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"&"}]}]}]`))
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"----"}]}]}]`))
abi.JSON(strings.NewReader(`[{"inputs":[{"type":"tuple[]","components":[{"type":"bool","name":"foo.Bar"}]}]}]`))
}
2 changes: 1 addition & 1 deletion accounts/abi/bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]

contracts[types[i]] = &tmplContract{
Type: capitalise(types[i]),
InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1),
InputABI: strings.ReplaceAll(strippedABI, "\"", "\\\""),
InputBin: strings.TrimPrefix(strings.TrimSpace(bytecodes[i]), "0x"),
Constructor: evmABI.Constructor,
Calls: calls,
Expand Down
6 changes: 3 additions & 3 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ var bindTests = []struct {
t.Skip("go sdk not found for testing")
}
// Create a temporary workspace for the test suite
ws, err := ioutil.TempDir("", "binding-test")
ws, err := os.MkdirTemp("", "binding-test")
if err != nil {
t.Fatalf("failed to create temporary workspace: %v", err)
}
Expand All @@ -1848,7 +1848,7 @@ var bindTests = []struct {
if err != nil {
t.Fatalf("test %d: failed to generate binding: %v", i, err)
}
if err = ioutil.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+".go"), []byte(bind), 0600); err != nil {
if err = os.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+".go"), []byte(bind), 0600); err != nil {
t.Fatalf("test %d: failed to write binding: %v", i, err)
}
// Generate the test file with the injected test code
Expand All @@ -1864,7 +1864,7 @@ var bindTests = []struct {
%s
}
`, tt.imports, tt.name, tt.tester)
if err := ioutil.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+"_test.go"), []byte(code), 0600); err != nil {
if err := os.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+"_test.go"), []byte(code), 0600); err != nil {
t.Fatalf("test %d: failed to write tests: %v", i, err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ var (
}
{{range $pattern, $name := .Libraries}}
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1)
{{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:])
{{end}}
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
if err != nil {
Expand Down
34 changes: 33 additions & 1 deletion accounts/abi/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"regexp"
"strconv"
"strings"
"unicode"
"unicode/utf8"

"github.com/PlatONnetwork/PlatON-Go/common"
)
Expand Down Expand Up @@ -173,6 +175,9 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
if err != nil {
return Type{}, err
}
if !isValidFieldName(fieldName) {
return Type{}, fmt.Errorf("field %d has invalid name", idx)
}
overloadedNames[fieldName] = fieldName
fields = append(fields, reflect.StructField{
Name: fieldName, // reflect.StructOf will panic for any exported field.
Expand Down Expand Up @@ -201,7 +206,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
if internalType != "" && strings.HasPrefix(internalType, structPrefix) {
// Foo.Bar type definition is not allowed in golang,
// convert the format to FooBar
typ.TupleRawName = strings.Replace(internalType[len(structPrefix):], ".", "", -1)
typ.TupleRawName = strings.ReplaceAll(internalType[len(structPrefix):], ".", "")
}

case "function":
Expand Down Expand Up @@ -399,3 +404,30 @@ func getTypeSize(t Type) int {
}
return 32
}

// isLetter reports whether a given 'rune' is classified as a Letter.
// This method is copied from reflect/type.go
func isLetter(ch rune) bool {
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= utf8.RuneSelf && unicode.IsLetter(ch)
}

// isValidFieldName checks if a string is a valid (struct) field name or not.
//
// According to the language spec, a field name should be an identifier.
//
// identifier = letter { letter | unicode_digit } .
// letter = unicode_letter | "_" .
// This method is copied from reflect/type.go
func isValidFieldName(fieldName string) bool {
for i, c := range fieldName {
if i == 0 && !isLetter(c) {
return false
}

if !(isLetter(c) || unicode.IsDigit(c)) {
return false
}
}

return len(fieldName) > 0
}
17 changes: 17 additions & 0 deletions accounts/abi/unpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ var unpackTests = []unpackTest{
IntOne *big.Int
}{big.NewInt(1)},
},
{
def: `[{"type":"bool"}]`,
enc: "",
want: false,
err: "abi: attempting to unmarshall an empty string while arguments are expected",
},
{
def: `[{"type":"bytes32","indexed":true},{"type":"uint256","indexed":false}]`,
enc: "",
want: false,
err: "abi: attempting to unmarshall an empty string while arguments are expected",
},
{
def: `[{"type":"bool","indexed":true},{"type":"uint64","indexed":true}]`,
enc: "",
want: false,
},
}

// TestLocalUnpackTests runs test specially designed only for unpacking.
Expand Down
9 changes: 4 additions & 5 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package keystore

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
Expand Down Expand Up @@ -382,11 +381,11 @@ func TestUpdatedKeyfileContents(t *testing.T) {
return
}

// needed so that modTime of `file` is different to its current value after ioutil.WriteFile
// needed so that modTime of `file` is different to its current value after os.WriteFile
time.Sleep(1000 * time.Millisecond)

// Now replace file contents with crap
if err := ioutil.WriteFile(file, []byte("foo"), 0644); err != nil {
if err := os.WriteFile(file, []byte("foo"), 0644); err != nil {
t.Fatal(err)
return
}
Expand All @@ -399,9 +398,9 @@ func TestUpdatedKeyfileContents(t *testing.T) {

// forceCopyFile is like cp.CopyFile, but doesn't complain if the destination exists.
func forceCopyFile(dst, src string) error {
data, err := ioutil.ReadFile(src)
data, err := os.ReadFile(src)
if err != nil {
return err
}
return ioutil.WriteFile(dst, data, 0644)
return os.WriteFile(dst, data, 0644)
}
15 changes: 9 additions & 6 deletions accounts/keystore/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
package keystore

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"sync"
"time"

mapset "github.com/deckarep/golang-set"
"github.com/PlatONnetwork/PlatON-Go/log"
mapset "github.com/deckarep/golang-set"
)

// fileCache is a cache of files seen during scan of keystore.
Expand All @@ -41,7 +40,7 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
t0 := time.Now()

// List all the failes from the keystore folder
files, err := ioutil.ReadDir(keyDir)
files, err := os.ReadDir(keyDir)
if err != nil {
return nil, nil, nil, err
}
Expand All @@ -65,7 +64,11 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
// Gather the set of all and fresly modified files
all.Add(path)

modified := fi.ModTime()
info, err := fi.Info()
if err != nil {
return nil, nil, nil, err
}
modified := info.ModTime()
if modified.After(fc.lastMod) {
mods.Add(path)
}
Expand All @@ -89,13 +92,13 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
}

// nonKeyFile ignores editor backups, hidden files and folders/symlinks.
func nonKeyFile(fi os.FileInfo) bool {
func nonKeyFile(fi os.DirEntry) bool {
// Skip editor backups and UNIX-style hidden files.
if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
return true
}
// Skip misc special files, directories (yes, symlinks too).
if fi.IsDir() || fi.Mode()&os.ModeType != 0 {
if fi.IsDir() || !fi.Type().IsRegular() {
return true
}
return false
Expand Down
3 changes: 1 addition & 2 deletions accounts/keystore/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -195,7 +194,7 @@ func writeTemporaryKeyFile(file string, content []byte) (string, error) {
}
// Atomic write: create a temporary hidden file first
// then move it into place. TempFile assigns mode 0600.
f, err := ioutil.TempFile(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
f, err := os.CreateTemp(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
if err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions accounts/keystore/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package keystore

import (
"github.com/PlatONnetwork/PlatON-Go/crypto"
"io/ioutil"
"math/rand"
"os"
"runtime"
Expand Down Expand Up @@ -462,7 +461,7 @@ func checkEvents(t *testing.T, want []walletEvent, have []walletEvent) {
}

func tmpKeyStore(t *testing.T, encrypted bool) (string, *KeyStore) {
d, err := ioutil.TempDir("", "eth-keystore-test")
d, err := os.MkdirTemp("", "eth-keystore-test")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions accounts/keystore/passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -82,7 +81,7 @@ type keyStorePassphrase struct {

func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) (*Key, error) {
// Load the key from the keystore and decrypt its contents
keyjson, err := ioutil.ReadFile(filename)
keyjson, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions accounts/keystore/passphrase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package keystore

import (
"io/ioutil"
"os"
"testing"

"github.com/PlatONnetwork/PlatON-Go/common"
Expand All @@ -30,7 +30,7 @@ const (

// Tests that a json key file can be decrypted and encrypted in multiple rounds.
func TestKeyEncryptDecrypt(t *testing.T) {
keyjson, err := ioutil.ReadFile("testdata/very-light-scrypt.json")
keyjson, err := os.ReadFile("testdata/very-light-scrypt.json")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions accounts/keystore/plain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand All @@ -32,7 +31,7 @@ import (
)

func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) {
d, err := ioutil.TempDir("", "platon-keystore-test")
d, err := os.MkdirTemp("", "platon-keystore-test")
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions accounts/scwallet/hud.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ package scwallet

import (
"encoding/json"
"io/ioutil"
"io"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -97,7 +97,7 @@ func (hub *Hub) readPairings() error {
return err
}

pairingData, err := ioutil.ReadAll(pairingFile)
pairingData, err := io.ReadAll(pairingFile)
if err != nil {
return err
}
Expand Down
Loading
Loading