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
9c82c646
Unverified
Commit
9c82c646
authored
Apr 12, 2022
by
Sina Mahmoodi
Committed by
GitHub
Apr 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/tracers: make txhash blockhash accessible to native tracers (#24679)
parent
d4d288e3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
9 deletions
+12
-9
4byte.go
eth/tracers/native/4byte.go
+1
-1
call.go
eth/tracers/native/call.go
+1
-1
noop.go
eth/tracers/native/noop.go
+1
-1
prestate.go
eth/tracers/native/prestate.go
+1
-1
tracer.go
eth/tracers/native/tracer.go
+8
-5
No files found.
eth/tracers/native/4byte.go
View file @
9c82c646
...
@@ -55,7 +55,7 @@ type fourByteTracer struct {
...
@@ -55,7 +55,7 @@ type fourByteTracer struct {
// newFourByteTracer returns a native go tracer which collects
// newFourByteTracer returns a native go tracer which collects
// 4 byte-identifiers of a tx, and implements vm.EVMLogger.
// 4 byte-identifiers of a tx, and implements vm.EVMLogger.
func
newFourByteTracer
()
tracers
.
Tracer
{
func
newFourByteTracer
(
ctx
*
tracers
.
Context
)
tracers
.
Tracer
{
t
:=
&
fourByteTracer
{
t
:=
&
fourByteTracer
{
ids
:
make
(
map
[
string
]
int
),
ids
:
make
(
map
[
string
]
int
),
}
}
...
...
eth/tracers/native/call.go
View file @
9c82c646
...
@@ -56,7 +56,7 @@ type callTracer struct {
...
@@ -56,7 +56,7 @@ type callTracer struct {
// newCallTracer returns a native go tracer which tracks
// newCallTracer returns a native go tracer which tracks
// call frames of a tx, and implements vm.EVMLogger.
// call frames of a tx, and implements vm.EVMLogger.
func
newCallTracer
()
tracers
.
Tracer
{
func
newCallTracer
(
ctx
*
tracers
.
Context
)
tracers
.
Tracer
{
// First callframe contains tx context info
// First callframe contains tx context info
// and is populated on start and end.
// and is populated on start and end.
return
&
callTracer
{
callstack
:
make
([]
callFrame
,
1
)}
return
&
callTracer
{
callstack
:
make
([]
callFrame
,
1
)}
...
...
eth/tracers/native/noop.go
View file @
9c82c646
...
@@ -35,7 +35,7 @@ func init() {
...
@@ -35,7 +35,7 @@ func init() {
type
noopTracer
struct
{}
type
noopTracer
struct
{}
// newNoopTracer returns a new noop tracer.
// newNoopTracer returns a new noop tracer.
func
newNoopTracer
()
tracers
.
Tracer
{
func
newNoopTracer
(
ctx
*
tracers
.
Context
)
tracers
.
Tracer
{
return
&
noopTracer
{}
return
&
noopTracer
{}
}
}
...
...
eth/tracers/native/prestate.go
View file @
9c82c646
...
@@ -51,7 +51,7 @@ type prestateTracer struct {
...
@@ -51,7 +51,7 @@ type prestateTracer struct {
reason
error
// Textual reason for the interruption
reason
error
// Textual reason for the interruption
}
}
func
newPrestateTracer
()
tracers
.
Tracer
{
func
newPrestateTracer
(
ctx
*
tracers
.
Context
)
tracers
.
Tracer
{
// First callframe contains tx context info
// First callframe contains tx context info
// and is populated on start and end.
// and is populated on start and end.
return
&
prestateTracer
{
prestate
:
prestate
{}}
return
&
prestateTracer
{
prestate
:
prestate
{}}
...
...
eth/tracers/native/tracer.go
View file @
9c82c646
...
@@ -45,6 +45,9 @@ func init() {
...
@@ -45,6 +45,9 @@ func init() {
tracers
.
RegisterLookup
(
false
,
lookup
)
tracers
.
RegisterLookup
(
false
,
lookup
)
}
}
// ctorFn is the constructor signature of a native tracer.
type
ctorFn
=
func
(
*
tracers
.
Context
)
tracers
.
Tracer
/*
/*
ctors is a map of package-local tracer constructors.
ctors is a map of package-local tracer constructors.
...
@@ -57,12 +60,12 @@ The go spec (https://golang.org/ref/spec#Package_initialization) says
...
@@ -57,12 +60,12 @@ The go spec (https://golang.org/ref/spec#Package_initialization) says
Hence, we cannot make the map in init, but must make it upon first use.
Hence, we cannot make the map in init, but must make it upon first use.
*/
*/
var
ctors
map
[
string
]
func
()
tracers
.
Tracer
var
ctors
map
[
string
]
ctorFn
// register is used by native tracers to register their presence.
// register is used by native tracers to register their presence.
func
register
(
name
string
,
ctor
func
()
tracers
.
Tracer
)
{
func
register
(
name
string
,
ctor
ctorFn
)
{
if
ctors
==
nil
{
if
ctors
==
nil
{
ctors
=
make
(
map
[
string
]
func
()
tracers
.
Tracer
)
ctors
=
make
(
map
[
string
]
ctorFn
)
}
}
ctors
[
name
]
=
ctor
ctors
[
name
]
=
ctor
}
}
...
@@ -70,10 +73,10 @@ func register(name string, ctor func() tracers.Tracer) {
...
@@ -70,10 +73,10 @@ func register(name string, ctor func() tracers.Tracer) {
// lookup returns a tracer, if one can be matched to the given name.
// lookup returns a tracer, if one can be matched to the given name.
func
lookup
(
name
string
,
ctx
*
tracers
.
Context
)
(
tracers
.
Tracer
,
error
)
{
func
lookup
(
name
string
,
ctx
*
tracers
.
Context
)
(
tracers
.
Tracer
,
error
)
{
if
ctors
==
nil
{
if
ctors
==
nil
{
ctors
=
make
(
map
[
string
]
func
()
tracers
.
Tracer
)
ctors
=
make
(
map
[
string
]
ctorFn
)
}
}
if
ctor
,
ok
:=
ctors
[
name
];
ok
{
if
ctor
,
ok
:=
ctors
[
name
];
ok
{
return
ctor
(),
nil
return
ctor
(
ctx
),
nil
}
}
return
nil
,
errors
.
New
(
"no tracer found"
)
return
nil
,
errors
.
New
(
"no tracer found"
)
}
}
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