Merge pull request #1146 from qinglin89/develop-upstream20
all: sync with upstream
This commit is contained in:
commit
6b83c41123
@ -184,7 +184,7 @@ HTTP based JSON-RPC API options:
|
|||||||
* `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`)
|
* `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`)
|
||||||
* `--ws.origins` Origins from which to accept websockets requests
|
* `--ws.origins` Origins from which to accept websockets requests
|
||||||
* `--ipcdisable` Disable the IPC-RPC server
|
* `--ipcdisable` Disable the IPC-RPC server
|
||||||
* `--ipcapi` API's offered over the IPC-RPC interface (default: `admin,debug,eth,miner,net,personal,shh,txpool,web3`)
|
* `--ipcapi` API's offered over the IPC-RPC interface (default: `admin,debug,eth,miner,net,personal,txpool,web3`)
|
||||||
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
||||||
|
|
||||||
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to
|
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to
|
||||||
|
@ -975,10 +975,11 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
|
|||||||
urls = params.RinkebyBootnodes
|
urls = params.RinkebyBootnodes
|
||||||
case ctx.GlobalBool(GoerliFlag.Name):
|
case ctx.GlobalBool(GoerliFlag.Name):
|
||||||
urls = params.GoerliBootnodes
|
urls = params.GoerliBootnodes
|
||||||
case cfg.BootstrapNodes != nil:
|
|
||||||
return // already set, don't apply defaults.
|
|
||||||
}
|
}
|
||||||
|
// don't apply defaults if BootstrapNodes is already set
|
||||||
|
if cfg.BootstrapNodes != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
cfg.BootstrapNodes = make([]*enode.Node, 0, len(urls))
|
cfg.BootstrapNodes = make([]*enode.Node, 0, len(urls))
|
||||||
for _, url := range urls {
|
for _, url := range urls {
|
||||||
if url != "" {
|
if url != "" {
|
||||||
|
@ -25,6 +25,8 @@ func TestStorageSizeString(t *testing.T) {
|
|||||||
size StorageSize
|
size StorageSize
|
||||||
str string
|
str string
|
||||||
}{
|
}{
|
||||||
|
{2839274474874, "2.58 TiB"},
|
||||||
|
{2458492810, "2.29 GiB"},
|
||||||
{2381273, "2.27 MiB"},
|
{2381273, "2.27 MiB"},
|
||||||
{2192, "2.14 KiB"},
|
{2192, "2.14 KiB"},
|
||||||
{12, "12.00 B"},
|
{12, "12.00 B"},
|
||||||
@ -36,3 +38,22 @@ func TestStorageSizeString(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStorageSizeTerminalString(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
size StorageSize
|
||||||
|
str string
|
||||||
|
}{
|
||||||
|
{2839274474874, "2.58TiB"},
|
||||||
|
{2458492810, "2.29GiB"},
|
||||||
|
{2381273, "2.27MiB"},
|
||||||
|
{2192, "2.14KiB"},
|
||||||
|
{12, "12.00B"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
if test.size.TerminalString() != test.str {
|
||||||
|
t.Errorf("%f: got %q, want %q", float64(test.size), test.size.TerminalString(), test.str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,15 +18,11 @@ package snapshot
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/fastcache"
|
"github.com/VictoriaMetrics/fastcache"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
|
||||||
"github.com/ethereum/go-ethereum/ethdb/leveldb"
|
|
||||||
"github.com/ethereum/go-ethereum/ethdb/memorydb"
|
"github.com/ethereum/go-ethereum/ethdb/memorydb"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
@ -518,18 +514,7 @@ func TestDiskMidAccountPartialMerge(t *testing.T) {
|
|||||||
// TestDiskSeek tests that seek-operations work on the disk layer
|
// TestDiskSeek tests that seek-operations work on the disk layer
|
||||||
func TestDiskSeek(t *testing.T) {
|
func TestDiskSeek(t *testing.T) {
|
||||||
// Create some accounts in the disk layer
|
// Create some accounts in the disk layer
|
||||||
var db ethdb.Database
|
db := rawdb.NewMemoryDatabase()
|
||||||
|
|
||||||
if dir, err := ioutil.TempDir("", "disklayer-test"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
} else {
|
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
diskdb, err := leveldb.New(dir, 256, 0, "", false)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
db = rawdb.NewDatabase(diskdb)
|
|
||||||
}
|
|
||||||
// Fill even keys [0,2,4...]
|
// Fill even keys [0,2,4...]
|
||||||
for i := 0; i < 0xff; i += 2 {
|
for i := 0; i < 0xff; i += 2 {
|
||||||
acc := common.Hash{byte(i)}
|
acc := common.Hash{byte(i)}
|
||||||
|
@ -54,11 +54,7 @@ type fromBufFn = func(vm *goja.Runtime, buf goja.Value, allowString bool) ([]byt
|
|||||||
|
|
||||||
func toBuf(vm *goja.Runtime, bufType goja.Value, val []byte) (goja.Value, error) {
|
func toBuf(vm *goja.Runtime, bufType goja.Value, val []byte) (goja.Value, error) {
|
||||||
// bufType is usually Uint8Array. This is equivalent to `new Uint8Array(val)` in JS.
|
// bufType is usually Uint8Array. This is equivalent to `new Uint8Array(val)` in JS.
|
||||||
res, err := vm.New(bufType, vm.ToValue(val))
|
return vm.New(bufType, vm.ToValue(vm.NewArrayBuffer(val)))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return vm.ToValue(res), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromBuf(vm *goja.Runtime, bufType goja.Value, buf goja.Value, allowString bool) ([]byte, error) {
|
func fromBuf(vm *goja.Runtime, bufType goja.Value, buf goja.Value, allowString bool) ([]byte, error) {
|
||||||
@ -69,6 +65,7 @@ func fromBuf(vm *goja.Runtime, bufType goja.Value, buf goja.Value, allowString b
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
return common.FromHex(obj.String()), nil
|
return common.FromHex(obj.String()), nil
|
||||||
|
|
||||||
case "Array":
|
case "Array":
|
||||||
var b []byte
|
var b []byte
|
||||||
if err := vm.ExportTo(buf, &b); err != nil {
|
if err := vm.ExportTo(buf, &b); err != nil {
|
||||||
@ -80,10 +77,7 @@ func fromBuf(vm *goja.Runtime, bufType goja.Value, buf goja.Value, allowString b
|
|||||||
if !obj.Get("constructor").SameAs(bufType) {
|
if !obj.Get("constructor").SameAs(bufType) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var b []byte
|
b := obj.Get("buffer").Export().(goja.ArrayBuffer).Bytes()
|
||||||
if err := vm.ExportTo(buf, &b); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("invalid buffer type")
|
return nil, fmt.Errorf("invalid buffer type")
|
||||||
@ -775,7 +769,7 @@ func (co *contractObj) GetValue() goja.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (co *contractObj) GetInput() goja.Value {
|
func (co *contractObj) GetInput() goja.Value {
|
||||||
input := co.contract.Input
|
input := common.CopyBytes(co.contract.Input)
|
||||||
res, err := co.toBuf(co.vm, input)
|
res, err := co.toBuf(co.vm, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
co.vm.Interrupt(err)
|
co.vm.Interrupt(err)
|
||||||
|
@ -563,12 +563,6 @@ func (s *PrivateAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Byt
|
|||||||
return crypto.PubkeyToAddress(*rpk), nil
|
return crypto.PubkeyToAddress(*rpk), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignAndSendTransaction was renamed to SendTransaction. This method is deprecated
|
|
||||||
// and will be removed in the future. It primary goal is to give clients time to update.
|
|
||||||
func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args TransactionArgs, passwd string) (common.Hash, error) {
|
|
||||||
return s.SendTransaction(ctx, args, passwd)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key.
|
// InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key.
|
||||||
func (s *PrivateAccountAPI) InitializeWallet(ctx context.Context, url string) (string, error) {
|
func (s *PrivateAccountAPI) InitializeWallet(ctx context.Context, url string) (string, error) {
|
||||||
wallet, err := s.am.Wallet(url)
|
wallet, err := s.am.Wallet(url)
|
||||||
|
@ -40,7 +40,6 @@ import (
|
|||||||
type Backend interface {
|
type Backend interface {
|
||||||
BlockChain() *core.BlockChain
|
BlockChain() *core.BlockChain
|
||||||
TxPool() *core.TxPool
|
TxPool() *core.TxPool
|
||||||
StateAtBlock(block *types.Block, reexec uint64, base *state.StateDB, checkLive bool, preferDisk bool) (statedb *state.StateDB, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is the configuration parameters of mining.
|
// Config is the configuration parameters of mining.
|
||||||
|
@ -786,16 +786,6 @@ func (w *worker) makeEnv(parent *types.Block, header *types.Header, coinbase com
|
|||||||
// Retrieve the parent state to execute on top and start a prefetcher for
|
// Retrieve the parent state to execute on top and start a prefetcher for
|
||||||
// the miner to speed block sealing up a bit
|
// the miner to speed block sealing up a bit
|
||||||
state, err := w.chain.StateAtWithSharedPool(parent.Root())
|
state, err := w.chain.StateAtWithSharedPool(parent.Root())
|
||||||
if err != nil {
|
|
||||||
// Note since the sealing block can be created upon the arbitrary parent
|
|
||||||
// block, but the state of parent block may already be pruned, so the necessary
|
|
||||||
// state recovery is needed here in the future.
|
|
||||||
//
|
|
||||||
// The maximum acceptable reorg depth can be limited by the finalised block
|
|
||||||
// somehow. TODO(rjl493456442) fix the hard-coded number here later.
|
|
||||||
state, err = w.eth.StateAtBlock(parent, 1024, nil, false, false)
|
|
||||||
log.Warn("Recovered mining state", "root", parent.Root(), "err", err)
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func TestNewID(t *testing.T) {
|
|||||||
|
|
||||||
func TestSubscriptions(t *testing.T) {
|
func TestSubscriptions(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
namespaces = []string{"eth", "shh", "bzz"}
|
namespaces = []string{"eth", "bzz"}
|
||||||
service = ¬ificationTestService{}
|
service = ¬ificationTestService{}
|
||||||
subCount = len(namespaces)
|
subCount = len(namespaces)
|
||||||
notificationCount = 3
|
notificationCount = 3
|
||||||
|
@ -40,6 +40,9 @@ func Fuzz(input []byte) int {
|
|||||||
if len(input) == 0 {
|
if len(input) == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
if len(input) > 500*1024 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
var i int
|
var i int
|
||||||
{
|
{
|
||||||
|
@ -841,7 +841,7 @@ func (c *cleaner) Put(key []byte, rlp []byte) error {
|
|||||||
delete(c.db.dirties, hash)
|
delete(c.db.dirties, hash)
|
||||||
c.db.dirtiesSize -= common.StorageSize(common.HashLength + int(node.size))
|
c.db.dirtiesSize -= common.StorageSize(common.HashLength + int(node.size))
|
||||||
if node.children != nil {
|
if node.children != nil {
|
||||||
c.db.dirtiesSize -= common.StorageSize(cachedNodeChildrenSize + len(node.children)*(common.HashLength+2))
|
c.db.childrenSize -= common.StorageSize(cachedNodeChildrenSize + len(node.children)*(common.HashLength+2))
|
||||||
}
|
}
|
||||||
// Move the flushed node into the clean cache to prevent insta-reloads
|
// Move the flushed node into the clean cache to prevent insta-reloads
|
||||||
if c.db.cleans != nil {
|
if c.db.cleans != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user