Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ethtracer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Nebula
ethtracer
Commits
5d6866aa
Commit
5d6866aa
authored
Jul 07, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
b141dadd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
evm.go
evm/evm.go
+14
-14
No files found.
evm/evm.go
View file @
5d6866aa
...
@@ -17,10 +17,10 @@
...
@@ -17,10 +17,10 @@
package
evm
package
evm
import
(
import
(
"code.wuban.net.cn/cmpchain/ethtracer/evm/evmtypes"
"code.wuban.net.cn/cmpchain/ethtracer/evm/vm"
"code.wuban.net.cn/cmpchain/ethtracer/evm/vm"
"code.wuban.net.cn/cmpchain/ethtracer/params"
"code.wuban.net.cn/cmpchain/ethtracer/params"
"code.wuban.net.cn/cmpchain/ethtracer/tracing"
"code.wuban.net.cn/cmpchain/ethtracer/tracing"
"code.wuban.net.cn/cmpchain/ethtracer/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"github.com/holiman/uint256"
"github.com/holiman/uint256"
"math/big"
"math/big"
...
@@ -32,17 +32,17 @@ type ChainContext interface {
...
@@ -32,17 +32,17 @@ type ChainContext interface {
// Engine retrieves the chain's consensus engine.
// Engine retrieves the chain's consensus engine.
//Engine() consensus.Engine
//Engine() consensus.Engine
Author
(
header
*
types
.
Header
)
(
metatypes
.
Address
,
error
)
Author
(
header
*
evm
types
.
Header
)
(
metatypes
.
Address
,
error
)
// GetHeader returns the header corresponding to the hash/number argument pair.
// GetHeader returns the header corresponding to the hash/number argument pair.
GetHeader
(
metatypes
.
Hash
,
uint64
)
*
types
.
Header
GetHeader
(
metatypes
.
Hash
,
uint64
)
*
evm
types
.
Header
// Config returns the chain's configuration.
// Config returns the chain's configuration.
Config
()
*
params
.
ChainConfig
Config
()
*
params
.
ChainConfig
}
}
// NewEVMBlockContext creates a new context for use in the EVM.
// NewEVMBlockContext creates a new context for use in the EVM.
func
NewEVMBlockContext
(
header
*
types
.
Header
,
chain
ChainContext
,
author
*
metatypes
.
Address
)
vm
.
BlockContext
{
func
NewEVMBlockContext
(
header
*
evm
types
.
Header
,
chain
ChainContext
,
author
*
metatypes
.
Address
)
vm
.
BlockContext
{
var
(
var
(
beneficiary
metatypes
.
Address
beneficiary
metatypes
.
Address
baseFee
*
big
.
Int
baseFee
*
big
.
Int
...
@@ -70,8 +70,8 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *metaty
...
@@ -70,8 +70,8 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *metaty
Transfer
:
Transfer
,
Transfer
:
Transfer
,
GetHash
:
GetHashFn
(
header
,
chain
),
GetHash
:
GetHashFn
(
header
,
chain
),
Coinbase
:
beneficiary
,
Coinbase
:
beneficiary
,
BlockNumber
:
new
(
big
.
Int
)
.
Set
(
header
.
BlockNumber
.
GetInt
()
),
BlockNumber
:
new
(
big
.
Int
)
.
Set
(
header
.
Number
),
Time
:
header
.
Time
stamp
,
Time
:
header
.
Time
,
Difficulty
:
big
.
NewInt
(
0
),
Difficulty
:
big
.
NewInt
(
0
),
BaseFee
:
baseFee
,
BaseFee
:
baseFee
,
BlobBaseFee
:
blobBaseFee
,
BlobBaseFee
:
blobBaseFee
,
...
@@ -94,36 +94,36 @@ func NewEVMTxContext(msg *Message) vm.TxContext {
...
@@ -94,36 +94,36 @@ func NewEVMTxContext(msg *Message) vm.TxContext {
}
}
// GetHashFn returns a GetHashFunc which retrieves header hashes by number
// GetHashFn returns a GetHashFunc which retrieves header hashes by number
func
GetHashFn
(
ref
*
types
.
Header
,
chain
ChainContext
)
func
(
n
uint64
)
metatypes
.
Hash
{
func
GetHashFn
(
ref
*
evm
types
.
Header
,
chain
ChainContext
)
func
(
n
uint64
)
metatypes
.
Hash
{
// Cache will initially contain [refHash.parent],
// Cache will initially contain [refHash.parent],
// Then fill up with [refHash.p, refHash.pp, refHash.ppp, ...]
// Then fill up with [refHash.p, refHash.pp, refHash.ppp, ...]
var
cache
[]
metatypes
.
Hash
var
cache
[]
metatypes
.
Hash
return
func
(
n
uint64
)
metatypes
.
Hash
{
return
func
(
n
uint64
)
metatypes
.
Hash
{
if
ref
.
Number
()
.
Uint64
()
<=
n
{
if
ref
.
Number
.
Uint64
()
<=
n
{
// This situation can happen if we're doing tracing and using
// This situation can happen if we're doing tracing and using
// block overrides.
// block overrides.
return
metatypes
.
Hash
{}
return
metatypes
.
Hash
{}
}
}
// If there's no hash cache yet, make one
// If there's no hash cache yet, make one
if
len
(
cache
)
==
0
{
if
len
(
cache
)
==
0
{
cache
=
append
(
cache
,
ref
.
Parent
()
)
cache
=
append
(
cache
,
ref
.
Parent
Hash
)
}
}
if
idx
:=
ref
.
Number
()
.
Uint64
()
-
n
-
1
;
idx
<
uint64
(
len
(
cache
))
{
if
idx
:=
ref
.
Number
.
Uint64
()
-
n
-
1
;
idx
<
uint64
(
len
(
cache
))
{
return
cache
[
idx
]
return
cache
[
idx
]
}
}
// No luck in the cache, but we can start iterating from the last element we already know
// No luck in the cache, but we can start iterating from the last element we already know
lastKnownHash
:=
cache
[
len
(
cache
)
-
1
]
lastKnownHash
:=
cache
[
len
(
cache
)
-
1
]
lastKnownNumber
:=
ref
.
Number
()
.
Uint64
()
-
uint64
(
len
(
cache
))
lastKnownNumber
:=
ref
.
Number
.
Uint64
()
-
uint64
(
len
(
cache
))
for
{
for
{
header
:=
chain
.
GetHeader
(
lastKnownHash
,
lastKnownNumber
)
header
:=
chain
.
GetHeader
(
lastKnownHash
,
lastKnownNumber
)
if
header
==
nil
{
if
header
==
nil
{
break
break
}
}
cache
=
append
(
cache
,
header
.
Parent
()
)
cache
=
append
(
cache
,
header
.
Parent
Hash
)
lastKnownHash
=
header
.
Parent
()
lastKnownHash
=
header
.
Parent
Hash
lastKnownNumber
=
header
.
Number
()
.
Uint64
()
-
1
lastKnownNumber
=
header
.
Number
.
Uint64
()
-
1
if
n
==
lastKnownNumber
{
if
n
==
lastKnownNumber
{
return
lastKnownHash
return
lastKnownHash
}
}
...
...
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