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
e868adde
Unverified
Commit
e868adde
authored
May 25, 2020
by
Martin Holst Swende
Committed by
GitHub
May 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: improve jumpdest lookup (#21123)
parent
25a661e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
contract.go
core/vm/contract.go
+9
-6
No files found.
core/vm/contract.go
View file @
e868adde
...
@@ -92,25 +92,28 @@ func (c *Contract) validJumpdest(dest *big.Int) bool {
...
@@ -92,25 +92,28 @@ func (c *Contract) validJumpdest(dest *big.Int) bool {
if
OpCode
(
c
.
Code
[
udest
])
!=
JUMPDEST
{
if
OpCode
(
c
.
Code
[
udest
])
!=
JUMPDEST
{
return
false
return
false
}
}
// Do we have a contract hash already?
// Do we have it locally already?
if
c
.
analysis
!=
nil
{
return
c
.
analysis
.
codeSegment
(
udest
)
}
// If we have the code hash (but no analysis), we should look into the
// parent analysis map and see if the analysis has been made previously
if
c
.
CodeHash
!=
(
common
.
Hash
{})
{
if
c
.
CodeHash
!=
(
common
.
Hash
{})
{
// Does parent context have the analysis?
analysis
,
exist
:=
c
.
jumpdests
[
c
.
CodeHash
]
analysis
,
exist
:=
c
.
jumpdests
[
c
.
CodeHash
]
if
!
exist
{
if
!
exist
{
// Do the analysis and save in parent context
// Do the analysis and save in parent context
// We do not need to store it in c.analysis
analysis
=
codeBitmap
(
c
.
Code
)
analysis
=
codeBitmap
(
c
.
Code
)
c
.
jumpdests
[
c
.
CodeHash
]
=
analysis
c
.
jumpdests
[
c
.
CodeHash
]
=
analysis
}
}
// Also stash it in current contract for faster access
c
.
analysis
=
analysis
return
analysis
.
codeSegment
(
udest
)
return
analysis
.
codeSegment
(
udest
)
}
}
// We don't have the code hash, most likely a piece of initcode not already
// We don't have the code hash, most likely a piece of initcode not already
// in state trie. In that case, we do an analysis, and save it locally, so
// in state trie. In that case, we do an analysis, and save it locally, so
// we don't have to recalculate it for every JUMP instruction in the execution
// we don't have to recalculate it for every JUMP instruction in the execution
// However, we don't save it within the parent context
// However, we don't save it within the parent context
if
c
.
analysis
==
nil
{
c
.
analysis
=
codeBitmap
(
c
.
Code
)
c
.
analysis
=
codeBitmap
(
c
.
Code
)
}
return
c
.
analysis
.
codeSegment
(
udest
)
return
c
.
analysis
.
codeSegment
(
udest
)
}
}
...
...
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