Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
51e7968b
Unverified
Commit
51e7968b
authored
3 years ago
by
Martin Holst Swende
Committed by
GitHub
3 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/state: fix read-meters + simplify code (#24304)
parent
fb3a6528
master
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
35 deletions
+19
-35
state_object.go
core/state/state_object.go
+10
-25
statedb.go
core/state/statedb.go
+9
-10
No files found.
core/state/state_object.go
View file @
51e7968b
...
...
@@ -198,25 +198,10 @@ func (s *stateObject) GetCommittedState(db Database, key common.Hash) common.Has
}
// If no live objects are available, attempt to use snapshots
var
(
enc
[]
byte
err
error
meter
*
time
.
Duration
enc
[]
byte
err
error
)
readStart
:=
time
.
Now
()
if
metrics
.
EnabledExpensive
{
// If the snap is 'under construction', the first lookup may fail. If that
// happens, we don't want to double-count the time elapsed. Thus this
// dance with the metering.
defer
func
()
{
if
meter
!=
nil
{
*
meter
+=
time
.
Since
(
readStart
)
}
}()
}
if
s
.
db
.
snap
!=
nil
{
if
metrics
.
EnabledExpensive
{
meter
=
&
s
.
db
.
SnapshotStorageReads
}
// If the object was destructed in *this* block (and potentially resurrected),
// the storage has been cleared out, and we should *not* consult the previous
// snapshot about any storage values. The only possible alternatives are:
...
...
@@ -226,20 +211,20 @@ func (s *stateObject) GetCommittedState(db Database, key common.Hash) common.Has
if
_
,
destructed
:=
s
.
db
.
snapDestructs
[
s
.
addrHash
];
destructed
{
return
common
.
Hash
{}
}
start
:=
time
.
Now
()
enc
,
err
=
s
.
db
.
snap
.
Storage
(
s
.
addrHash
,
crypto
.
Keccak256Hash
(
key
.
Bytes
()))
if
metrics
.
EnabledExpensive
{
s
.
db
.
SnapshotStorageReads
+=
time
.
Since
(
start
)
}
}
// If the snapshot is unavailable or reading from it fails, load from the database.
if
s
.
db
.
snap
==
nil
||
err
!=
nil
{
if
meter
!=
nil
{
// If we already spent time checking the snapshot, account for it
// and reset the readStart
*
meter
+=
time
.
Since
(
readStart
)
readStart
=
time
.
Now
()
}
start
:=
time
.
Now
()
enc
,
err
=
s
.
getTrie
(
db
)
.
TryGet
(
key
.
Bytes
())
if
metrics
.
EnabledExpensive
{
meter
=
&
s
.
db
.
StorageReads
s
.
db
.
StorageReads
+=
time
.
Since
(
start
)
}
if
e
nc
,
err
=
s
.
getTrie
(
db
)
.
TryGet
(
key
.
Bytes
());
e
rr
!=
nil
{
if
err
!=
nil
{
s
.
setError
(
err
)
return
common
.
Hash
{}
}
...
...
This diff is collapsed.
Click to expand it.
core/state/statedb.go
View file @
51e7968b
...
...
@@ -506,16 +506,14 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
return
obj
}
// If no live objects are available, attempt to use snapshots
var
(
data
*
types
.
StateAccount
err
error
)
var
data
*
types
.
StateAccount
if
s
.
snap
!=
nil
{
start
:=
time
.
Now
()
acc
,
err
:=
s
.
snap
.
Account
(
crypto
.
HashData
(
s
.
hasher
,
addr
.
Bytes
()))
if
metrics
.
EnabledExpensive
{
defer
func
(
start
time
.
Time
)
{
s
.
SnapshotAccountReads
+=
time
.
Since
(
start
)
}(
time
.
Now
()
)
s
.
SnapshotAccountReads
+=
time
.
Since
(
start
)
}
var
acc
*
snapshot
.
Account
if
acc
,
err
=
s
.
snap
.
Account
(
crypto
.
HashData
(
s
.
hasher
,
addr
.
Bytes
()));
err
==
nil
{
if
err
==
nil
{
if
acc
==
nil
{
return
nil
}
...
...
@@ -534,11 +532,12 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
}
}
// If snapshot unavailable or reading from it failed, load from the database
if
s
.
snap
==
nil
||
err
!=
nil
{
if
data
==
nil
{
start
:=
time
.
Now
()
enc
,
err
:=
s
.
trie
.
TryGet
(
addr
.
Bytes
())
if
metrics
.
EnabledExpensive
{
defer
func
(
start
time
.
Time
)
{
s
.
AccountReads
+=
time
.
Since
(
start
)
}(
time
.
Now
()
)
s
.
AccountReads
+=
time
.
Since
(
start
)
}
enc
,
err
:=
s
.
trie
.
TryGet
(
addr
.
Bytes
())
if
err
!=
nil
{
s
.
setError
(
fmt
.
Errorf
(
"getDeleteStateObject (%x) error: %v"
,
addr
.
Bytes
(),
err
))
return
nil
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment