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

Merge ETH #2266

Open
wants to merge 104 commits into
base: feature/bump-version-to-1.5.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
4c4550f
Merge pull request #171 from PlatONnetwork/feature/bump-version-to-1.5.1
niuxiaojie81 May 9, 2024
b5bed43
rpc: support inject http headers using outgoing context #26023
niuxiaojie81 May 9, 2024
c1ebe20
Dockerfile: upgrade to Go 1.19 #26195
niuxiaojie81 May 9, 2024
a00120e
rlp: improve tests for Split functions #26200
niuxiaojie81 May 9, 2024
c112eac
rpc, internal/guide: speed up tests a bit #26193
niuxiaojie81 May 9, 2024
d6c0c52
ethstats: set readlimit on ethstats server connection #26207
niuxiaojie81 May 9, 2024
8d6a53a
cmd/utils: log path used when checking disk space #26212
niuxiaojie81 May 9, 2024
f8f0df9
core/rawdb: improve freezerTable.Sync #26245
niuxiaojie81 May 9, 2024
d8db02d
cmd/utils: print warning when --metrics.port set without --metrics.ad…
niuxiaojie81 May 9, 2024
3b98de3
signer/core/apitypes: deep convert types in slice #26203
niuxiaojie81 May 9, 2024
919744f
core/rawdb: fix freezer validation #26251
niuxiaojie81 May 9, 2024
839b237
rpc: decrease websocket ping interval #26253
niuxiaojie81 May 9, 2024
3ac60a9
signer: enable typed data signing from signer rpc #26241
niuxiaojie81 May 9, 2024
2368b3d
p2p/nat: use IP.IsPrivate #26252
niuxiaojie81 May 9, 2024
9ee25b7
internal/web3ext: fix eth_call stateOverrides in console #26265
niuxiaojie81 May 9, 2024
9f29ae9
p2p/discover: add config option for discv5 protocol ID #26041
niuxiaojie81 May 9, 2024
c4db555
all: refactor txpool into it's own package in prep for 4844 #26038
niuxiaojie81 May 10, 2024
2b7f71b
all: assign zero after resize in implementations of heap.Interface #2…
niuxiaojie81 May 10, 2024
b3c4e40
console: use default APIs when server doesn't have rpc_modules #26267
niuxiaojie81 May 10, 2024
580384a
eth/tracers/logger: do not include elapsed time in evm output #26291
niuxiaojie81 May 10, 2024
5d57d1c
cmd/geth: fix typo in comment #26308
niuxiaojie81 May 10, 2024
5e753a4
graphql: add query timeout to prevent dos attack #26116
niuxiaojie81 May 10, 2024
c95cf9a
graphql, node, rpc: improve HTTP write timeout handling #25457
niuxiaojie81 May 10, 2024
f3e0628
p2p/nat: handle responses with alternative port in NAT-PMP #26321
niuxiaojie81 May 10, 2024
1ae95e9
p2p/discover: improve nodesByDistance.push #26019
niuxiaojie81 May 10, 2024
5ecf5c1
event: add FeedOf[T] #26310
niuxiaojie81 May 10, 2024
7abc361
eth/tracers: return proper error from debug_TraceTransaction when tx …
niuxiaojie81 May 10, 2024
9c54afe
core: fix comment about recipient for contract creation #26349
niuxiaojie81 May 10, 2024
e63a844
core, cmd: fill blockNumber in logs #26345
niuxiaojie81 May 10, 2024
aa96729
signer/core: handle gnosis safe problem with missing chain id #26309
niuxiaojie81 May 10, 2024
2d9c655
core: fix typo in blockchain_snapshot_test.go #26357
niuxiaojie81 May 10, 2024
7703e5a
eth/filters, eth/tracers: add request cancellation checks #26320
niuxiaojie81 May 11, 2024
59762dc
core/rawdb: implement resettable freezer #26324
niuxiaojie81 May 11, 2024
928d862
build: add support for Ubuntu 22.10 (Kinetic Kudu) #26379
niuxiaojie81 May 11, 2024
9012f95
miner: allow for extradata in post-merge blocks #26387
niuxiaojie81 May 11, 2024
c58ba57
eth/downloader: fix some typos #26396
niuxiaojie81 May 11, 2024
6fba2c2
Update copyright year to 2023 #26382
niuxiaojie81 May 11, 2024
622369b
common/mclock: add Alarm #26333
niuxiaojie81 May 11, 2024
62df588
p2p/discover: improve discv5 NODES response packing #26033
niuxiaojie81 May 11, 2024
f52516b
p2p/discover: add more packet information in logs #26307
niuxiaojie81 May 11, 2024
4e07161
p2p/discover: fix handling of distance 256 in lookupDistances #26087
niuxiaojie81 May 11, 2024
f5160f3
crypto/bls12381: use worst case scalar for input to G1/G2 mul benchma…
niuxiaojie81 May 11, 2024
8523cdb
core/vm: minor trivial clean up #25880
niuxiaojie81 May 15, 2024
bbaf18d
eth/tracers: fix the issue of stateobject modified #25884
niuxiaojie81 May 15, 2024
bb3fabb
internal/ethapi: handle odd length hex in decodeHash #25883
niuxiaojie81 May 15, 2024
ae02ecb
accounts/abi: return toGoType error immediately #25565
niuxiaojie81 May 15, 2024
e5c68af
core: rework tx indexer #25723
niuxiaojie81 May 15, 2024
a7ea32b
eth/tracers: remove revertReasonTracer, add revert reason to callTrac…
niuxiaojie81 May 15, 2024
f48aa57
accounts/abi/bind: parse ABI once on bind #25574
niuxiaojie81 May 15, 2024
4a6ae03
cmd/geth, cmd/utils: geth attach with custom headers #25829
niuxiaojie81 May 15, 2024
df9d35c
core/types: add a testcase to TestLegacyReceiptDecoding #25909
niuxiaojie81 May 15, 2024
05b6941
tests/fuzzers: add snap protocol handling fuzzer #23957
niuxiaojie81 May 15, 2024
6b29dde
all: fix docstrings #25924
niuxiaojie81 May 15, 2024
fb30651
eth/tracers: add diffMode to prestateTracer #25422
niuxiaojie81 May 16, 2024
c618438
eth/traces: add state limit #25812
niuxiaojie81 May 16, 2024
2556619
core/bloombits: speed up windows-test #25844
niuxiaojie81 May 16, 2024
01f111c
core, ethclient/gethclient: improve flaky tests #25918
niuxiaojie81 May 16, 2024
15cd565
node: prevent exposing engine API on unauthenticated endpoint #25939
niuxiaojie81 May 16, 2024
1a85387
eth/filters: fix for eth_getLogs failing with finalized- and safe tag…
niuxiaojie81 May 16, 2024
ab5257d
cmd/geth: fix help output issues #25941
niuxiaojie81 May 16, 2024
e926237
all: fix spelling mistakes #25961
niuxiaojie81 May 16, 2024
01da327
cmd/geth, core: fix typo in comment #25954
niuxiaojie81 May 16, 2024
38b8f12
core/rawdb: provide more info on 'gap in the chain' error #25938
niuxiaojie81 May 16, 2024
9b82837
core/types: make ErrInvalidChainID more useful #25367
niuxiaojie81 May 16, 2024
ac8d929
common/math: optimized modexp (+ fuzzer) #25525
niuxiaojie81 May 16, 2024
52c5a1d
accounts/keystore: faster tests #25827
niuxiaojie81 May 16, 2024
fd66f66
eth/filters, ethclient/gethclient: add fullTx option to pending tx fi…
niuxiaojie81 May 16, 2024
878d81a
go.mod: upgrade github.com/dop251/goja #25955
niuxiaojie81 May 16, 2024
2ba85df
eth/tracers: fix the issue of panic in prestate with diffmode #25957
niuxiaojie81 May 16, 2024
64a73e3
Revert "go.mod: upgrade github.com/dop251/goja" #25975
niuxiaojie81 May 16, 2024
9f57a88
common/math, tests/fuzzers: use big.Int clone #26006
niuxiaojie81 May 16, 2024
f45a4eb
core/rawdb: refactor db key prefix #26000
niuxiaojie81 May 17, 2024
361c877
core/rawdb: open meta file in read only mode #26009
niuxiaojie81 May 17, 2024
c489969
internal/ethapi, accounts/abi/backends: use error defined in core #26012
niuxiaojie81 May 17, 2024
c554e0f
eth/tracers: fix the issue prestate missing existing contract state #…
niuxiaojie81 May 17, 2024
10e4294
eth/tracers: simplify test framework #25973
niuxiaojie81 May 17, 2024
6be9b31
core/types: rename tx files to group them better together #26044
niuxiaojie81 May 17, 2024
52530ea
core, eth: for types with accurate size calcs, return uint64, not flo…
niuxiaojie81 May 17, 2024
d8d63fc
accounts/scwallet: fix keycard data signing error #25331
niuxiaojie81 May 17, 2024
26e7b9b
build: make ios work again #26052
niuxiaojie81 May 17, 2024
b368854
core/vm: use optimized bigint #26021
niuxiaojie81 May 17, 2024
00d44c9
eth/tracers: fix gasUsed for native and JS tracers #26048
niuxiaojie81 May 20, 2024
d56c13b
rpc: update docstring #26072
niuxiaojie81 May 20, 2024
5fda433
Fix trace call for inner reverts #25971
niuxiaojie81 May 20, 2024
f573432
eth: implement eth/68 to support only announcing certain tx types #25980
niuxiaojie81 May 21, 2024
b1869f1
回滚部分被冲掉的代码
niuxiaojie81 May 21, 2024
dbc6c30
eth/tracers: add withLog to callTracer #25991
niuxiaojie81 May 21, 2024
4fdfd34
eth/tracers: prestateTracer - exclude unchanged storage slots in diff…
niuxiaojie81 May 21, 2024
fb7b167
accounts/abi: fixed bytes with size larger than 32 bytes is not allow…
niuxiaojie81 May 21, 2024
3513a87
miner: fail early if core.NewBlockChain fails #26079
niuxiaojie81 May 21, 2024
bc0a741
rlp: add more tests for nil pointer / optional field encoding #26077
niuxiaojie81 May 21, 2024
a2cd3ab
crypto/bls12381: fix broken links to references for point addition/do…
niuxiaojie81 May 21, 2024
cd11c7a
params: make eip1559 params non-global #25994
niuxiaojie81 May 21, 2024
c57c851
signer/core/apitypes: support more input types for eip-712 encoding #…
niuxiaojie81 May 21, 2024
6edbdbe
accounts/abi: properly quote untrusted data in error message #26110
niuxiaojie81 May 21, 2024
0fea40b
cmd/clef: list accounts at startup #26082
niuxiaojie81 May 21, 2024
67342a7
eth/tracers: add multiplexing tracer #26086
niuxiaojie81 May 21, 2024
c55bf5d
p2p/enode: implement per-source timeout in FairMix #25962
niuxiaojie81 May 21, 2024
6435c8b
core/vm: deep copy jumptable when enabling extra eips #26137
niuxiaojie81 May 21, 2024
48386e3
core/state: replace fastcache code cache with gc-friendly structure #…
niuxiaojie81 May 21, 2024
c3acc46
common/lru: fix race in lru #26164
niuxiaojie81 May 21, 2024
3c3ca14
common/lru: add generic LRU implementation #26162
niuxiaojie81 May 21, 2024
5550f42
Merge pull request #173 from PlatONnetwork/feature/bump-version-to-1.5.1
niuxiaojie81 Nov 12, 2024
b37708a
trie, les, tests, core: implement trie tracer #24403
niuxiaojie81 Nov 20, 2024
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build PlatON in a stock Go builder container
FROM golang:1.16-alpine3.13 as builder
FROM golang:1.19-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers g++ llvm bash cmake git gmp-dev openssl-dev

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.15-alpine as builder
FROM golang:1.19-alpine as builder

RUN apk add --no-cache make gcc musl-dev linux-headers g++ llvm bash cmake git gmp-dev openssl-dev

Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
var args Arguments
if method, ok := abi.Methods[name]; ok {
if len(data)%32 != 0 {
return nil, fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(data), data)
return nil, fmt.Errorf("abi: improperly formatted output: %q - Bytes: %+v", data, data)
}
args = method.Outputs
}
Expand Down
6 changes: 3 additions & 3 deletions accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) {
virtualArgs := 0
for index, arg := range nonIndexedArgs {
marshalledValue, err := toGoType((index+virtualArgs)*32, arg.Type, data)
if err != nil {
return nil, err
}
if arg.Type.T == ArrayTy && !isDynamicType(arg.Type) {
// If we have a static array, like [3]uint256, these are coded as
// just like uint256,uint256,uint256.
Expand All @@ -204,9 +207,6 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) {
// coded as just like uint256,bool,uint256
virtualArgs += getTypeSize(arg.Type)/32 - 1
}
if err != nil {
return nil, err
}
retval = append(retval, marshalledValue)
}
return retval, nil
Expand Down
15 changes: 11 additions & 4 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
available := new(big.Int).Set(balance)
if call.Value != nil {
if call.Value.Cmp(available) >= 0 {
return 0, errors.New("insufficient funds for transfer")
return 0, core.ErrInsufficientFundsForTransfer
}
available.Sub(available, call.Value)
}
Expand Down Expand Up @@ -822,11 +822,18 @@ type filterBackend struct {
func (fb *filterBackend) ChainDb() ethdb.Database { return fb.db }
func (fb *filterBackend) EventMux() *event.TypeMux { panic("not supported") }

func (fb *filterBackend) HeaderByNumber(ctx context.Context, block rpc.BlockNumber) (*types.Header, error) {
if block == rpc.LatestBlockNumber {
func (fb *filterBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
switch number {
case rpc.PendingBlockNumber:
if block := fb.backend.pendingBlock; block != nil {
return block.Header(), nil
}
return nil, nil
case rpc.LatestBlockNumber, rpc.FinalizedBlockNumber, rpc.SafeBlockNumber:
return fb.bc.CurrentHeader(), nil
default:
return fb.bc.GetHeaderByNumber(uint64(number.Int64())), nil
}
return fb.bc.GetHeaderByNumber(uint64(block.Int64())), nil
}

func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
Expand Down
5 changes: 3 additions & 2 deletions accounts/abi/bind/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ var (
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
_ = abi.ConvertType
)

{{$structs := .Structs}}
Expand Down Expand Up @@ -268,11 +269,11 @@ var (

// bind{{.Type}} binds a generic wrapper to an already deployed contract.
func bind{{.Type}}(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
parsed, err := {{.Type}}MetaData.GetAbi()
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
}

// Call invokes the (constant) contract method with params as input values and
Expand Down
3 changes: 3 additions & 0 deletions accounts/abi/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
if varSize == 0 {
typ.T = BytesTy
} else {
if varSize > 32 {
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
}
typ.T = FixedBytesTy
typ.Size = varSize
}
Expand Down
7 changes: 7 additions & 0 deletions accounts/abi/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,10 @@ func TestGetTypeSize(t *testing.T) {
}
}
}

func TestNewFixedBytesOver32(t *testing.T) {
_, err := NewType("bytes4096", "", nil)
if err == nil {
t.Errorf("fixed bytes with size over 32 is not spec'd")
}
}
6 changes: 3 additions & 3 deletions accounts/abi/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ func forTupleUnpack(t Type, output []byte) (interface{}, error) {
virtualArgs := 0
for index, elem := range t.TupleElems {
marshalledValue, err := toGoType((index+virtualArgs)*32, *elem, output)
if err != nil {
return nil, err
}
if elem.T == ArrayTy && !isDynamicType(*elem) {
// If we have a static array, like [3]uint256, these are coded as
// just like uint256,uint256,uint256.
Expand All @@ -179,9 +182,6 @@ func forTupleUnpack(t Type, output []byte) (interface{}, error) {
// coded as just like uint256,bool,uint256
virtualArgs += getTypeSize(*elem)/32 - 1
}
if err != nil {
return nil, err
}
retval.Field(index).Set(reflect.ValueOf(marshalledValue))
}
return retval.Interface(), nil
Expand Down
8 changes: 8 additions & 0 deletions accounts/keystore/account_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ func (ac *accountCache) deleteByFile(path string) {
}
}

// watcherStarted returns true if the watcher loop started running (even if it
// has since also ended).
func (ac *accountCache) watcherStarted() bool {
ac.mu.Lock()
defer ac.mu.Unlock()
return ac.watcher.running || ac.watcher.runEnded
}

func removeAccount(slice []accounts.Account, elem accounts.Account) []accounts.Account {
for i := range slice {
if slice[i] == elem {
Expand Down
97 changes: 50 additions & 47 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,48 @@ var (
}
)

// waitWatcherStarts waits up to 1s for the keystore watcher to start.
func waitWatcherStart(ks *KeyStore) bool {
// On systems where file watch is not supported, just return "ok".
if !ks.cache.watcher.enabled() {
return true
}
// The watcher should start, and then exit.
for t0 := time.Now(); time.Since(t0) < 1*time.Second; time.Sleep(100 * time.Millisecond) {
if ks.cache.watcherStarted() {
return true
}
}
return false
}

func waitForAccounts(wantAccounts []accounts.Account, ks *KeyStore) error {
var list []accounts.Account
for t0 := time.Now(); time.Since(t0) < 5*time.Second; time.Sleep(200 * time.Millisecond) {
list = ks.Accounts()
if reflect.DeepEqual(list, wantAccounts) {
// ks should have also received change notifications
select {
case <-ks.changes:
default:
return fmt.Errorf("wasn't notified of new accounts")
}
return nil
}
}
return fmt.Errorf("\ngot %v\nwant %v", list, wantAccounts)
}

func TestWatchNewFile(t *testing.T) {
t.Parallel()

dir, ks := tmpKeyStore(t, false)

// Ensure the watcher is started before adding any files.
ks.Accounts()
time.Sleep(1000 * time.Millisecond)

if !waitWatcherStart(ks) {
t.Fatal("keystore watcher didn't start in time")
}
// Move in the files.
wantAccounts := make([]accounts.Account, len(cachetestAccounts))
for i := range cachetestAccounts {
Expand All @@ -73,37 +106,25 @@ func TestWatchNewFile(t *testing.T) {
}

// ks should see the accounts.
var list []accounts.Account
for d := 200 * time.Millisecond; d < 5*time.Second; d *= 2 {
list = ks.Accounts()
if reflect.DeepEqual(list, wantAccounts) {
// ks should have also received change notifications
select {
case <-ks.changes:
default:
t.Fatalf("wasn't notified of new accounts")
}
return
}
time.Sleep(d)
if err := waitForAccounts(wantAccounts, ks); err != nil {
t.Error(err)
}
t.Errorf("got %s, want %s", spew.Sdump(list), spew.Sdump(wantAccounts))
}

func TestWatchNoDir(t *testing.T) {
t.Parallel()

// Create ks but not the directory that it watches.
rand.New(rand.NewSource(time.Now().UnixNano()))
rand.Seed(time.Now().UnixNano())
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watchnodir-test-%d-%d", os.Getpid(), rand.Int()))
ks := NewKeyStore(dir, LightScryptN, LightScryptP)

list := ks.Accounts()
if len(list) > 0 {
t.Error("initial account list not empty:", list)
}
time.Sleep(100 * time.Millisecond)

// The watcher should start, and then exit.
if !waitWatcherStart(ks) {
t.Fatal("keystore watcher didn't start in time")
}
// Create the directory and copy a key file into it.
os.MkdirAll(dir, 0700)
defer os.RemoveAll(dir)
Expand Down Expand Up @@ -296,40 +317,23 @@ func TestCacheFind(t *testing.T) {
}
}

func waitForAccounts(wantAccounts []accounts.Account, ks *KeyStore) error {
var list []accounts.Account
for d := 200 * time.Millisecond; d < 8*time.Second; d *= 2 {
list = ks.Accounts()
if reflect.DeepEqual(list, wantAccounts) {
// ks should have also received change notifications
select {
case <-ks.changes:
default:
return fmt.Errorf("wasn't notified of new accounts")
}
return nil
}
time.Sleep(d)
}
return fmt.Errorf("\ngot %v\nwant %v", list, wantAccounts)
}

// TestUpdatedKeyfileContents tests that updating the contents of a keystore file
// is noticed by the watcher, and the account cache is updated accordingly
func TestUpdatedKeyfileContents(t *testing.T) {
t.Parallel()

// Create a temporary kesytore to test with
rand.New(rand.NewSource(time.Now().UnixNano()))
// Create a temporary keystore to test with
rand.Seed(time.Now().UnixNano())
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-updatedkeyfilecontents-test-%d-%d", os.Getpid(), rand.Int()))
ks := NewKeyStore(dir, LightScryptN, LightScryptP)

list := ks.Accounts()
if len(list) > 0 {
t.Error("initial account list not empty:", list)
}
time.Sleep(100 * time.Millisecond)

if !waitWatcherStart(ks) {
t.Fatal("keystore watcher didn't start in time")
}
// Create the directory and copy a key file into it.
os.MkdirAll(dir, 0700)
defer os.RemoveAll(dir)
Expand All @@ -347,9 +351,8 @@ func TestUpdatedKeyfileContents(t *testing.T) {
t.Error(err)
return
}

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

// Now replace file contents
if err := forceCopyFile(file, cachetestAccounts[1].URL.Path); err != nil {
Expand All @@ -365,7 +368,7 @@ func TestUpdatedKeyfileContents(t *testing.T) {
}

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

// Now replace file contents again
if err := forceCopyFile(file, cachetestAccounts[2].URL.Path); err != nil {
Expand All @@ -381,7 +384,7 @@ func TestUpdatedKeyfileContents(t *testing.T) {
}

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

// Now replace file contents with crap
if err := os.WriteFile(file, []byte("foo"), 0600); err != nil {
Expand Down
9 changes: 8 additions & 1 deletion accounts/keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
//
// Keys are stored as encrypted JSON files according to the Web3 Secret Storage specification.
// See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.

package keystore

import (
Expand Down Expand Up @@ -498,6 +497,14 @@ func (ks *KeyStore) ImportPreSaleKey(keyJSON []byte, passphrase string) (account
return a, nil
}

// isUpdating returns whether the event notification loop is running.
// This method is mainly meant for tests.
func (ks *KeyStore) isUpdating() bool {
ks.mu.RLock()
defer ks.mu.RUnlock()
return ks.updating
}

// zeroKey zeroes a private key in memory.
func zeroKey(k *ecdsa.PrivateKey) {
b := k.D.Bits()
Expand Down
Loading
Loading