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
1fff77e7
Commit
1fff77e7
authored
Jul 07, 2025
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
323d4af7
Changes
23
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
184 additions
and
2463 deletions
+184
-2463
README.md
README.md
+1
-0
analysis_legacy_test.go
evm/vm/analysis_legacy_test.go
+1
-2
contracts_fuzz_test.go
evm/vm/contracts_fuzz_test.go
+2
-3
contracts_test.go
evm/vm/contracts_test.go
+36
-37
eof_test.go
evm/vm/eof_test.go
+8
-9
eof_validation_test.go
evm/vm/eof_validation_test.go
+3
-4
gas_table_test.go
evm/vm/gas_table_test.go
+0
-181
instructions.go
evm/vm/instructions.go
+7
-2
instructions_test.go
evm/vm/instructions_test.go
+0
-974
interface.go
evm/vm/interface.go
+2
-3
interpreter_test.go
evm/vm/interpreter_test.go
+0
-76
memory_test.go
evm/vm/memory_test.go
+3
-4
runtime.go
evm/vm/runtime/runtime.go
+14
-15
runtime_example_test.go
evm/vm/runtime/runtime_example_test.go
+0
-34
runtime_fuzz_test.go
evm/vm/runtime/runtime_fuzz_test.go
+0
-29
runtime_test.go
evm/vm/runtime/runtime_test.go
+0
-939
go.mod
go.mod
+7
-13
go.sum
go.sum
+10
-46
encoding.go
stateless/encoding.go
+2
-2
witness.go
stateless/witness.go
+11
-12
hooks.go
tracing/hooks.go
+9
-9
journal.go
tracing/journal.go
+2
-2
types.go
types/types.go
+66
-67
No files found.
README.md
View file @
1fff77e7
# ethtracer
# ethtracer
# todo: modify types/transaction types/receipt types/block types/header to evm/evmtypes.
\ No newline at end of file
evm/vm/analysis_legacy_test.go
View file @
1fff77e7
...
@@ -17,10 +17,9 @@
...
@@ -17,10 +17,9 @@
package
vm
package
vm
import
(
import
(
"code.wuban.net.cn/cmpchain/ethcrypto/crypto"
"math/bits"
"math/bits"
"testing"
"testing"
"github.com/ethereum/go-ethereum/crypto"
)
)
func
TestJumpDestAnalysis
(
t
*
testing
.
T
)
{
func
TestJumpDestAnalysis
(
t
*
testing
.
T
)
{
...
...
evm/vm/contracts_fuzz_test.go
View file @
1fff77e7
...
@@ -17,14 +17,13 @@
...
@@ -17,14 +17,13 @@
package
vm
package
vm
import
(
import
(
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
)
)
func
FuzzPrecompiledContracts
(
f
*
testing
.
F
)
{
func
FuzzPrecompiledContracts
(
f
*
testing
.
F
)
{
// Create list of addresses
// Create list of addresses
var
addrs
[]
common
.
Address
var
addrs
[]
metatypes
.
Address
for
k
:=
range
allPrecompiles
{
for
k
:=
range
allPrecompiles
{
addrs
=
append
(
addrs
,
k
)
addrs
=
append
(
addrs
,
k
)
}
}
...
...
evm/vm/contracts_test.go
View file @
1fff77e7
...
@@ -20,11 +20,10 @@ import (
...
@@ -20,11 +20,10 @@ import (
"bytes"
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"os"
"os"
"testing"
"testing"
"time"
"time"
"github.com/ethereum/go-ethereum/common"
)
)
// precompiledTest defines the input/output pairs for precompiled contract tests.
// precompiledTest defines the input/output pairs for precompiled contract tests.
...
@@ -45,26 +44,26 @@ type precompiledFailureTest struct {
...
@@ -45,26 +44,26 @@ type precompiledFailureTest struct {
// allPrecompiles does not map to the actual set of precompiles, as it also contains
// allPrecompiles does not map to the actual set of precompiles, as it also contains
// repriced versions of precompiles at certain slots
// repriced versions of precompiles at certain slots
var
allPrecompiles
=
map
[
common
.
Address
]
PrecompiledContract
{
var
allPrecompiles
=
map
[
metatypes
.
Address
]
PrecompiledContract
{
common
.
BytesToAddress
([]
byte
{
1
})
:
&
ecrecover
{},
metatypes
.
BytesToAddress
([]
byte
{
1
})
:
&
ecrecover
{},
common
.
BytesToAddress
([]
byte
{
2
})
:
&
sha256hash
{},
metatypes
.
BytesToAddress
([]
byte
{
2
})
:
&
sha256hash
{},
common
.
BytesToAddress
([]
byte
{
3
})
:
&
ripemd160hash
{},
metatypes
.
BytesToAddress
([]
byte
{
3
})
:
&
ripemd160hash
{},
common
.
BytesToAddress
([]
byte
{
4
})
:
&
dataCopy
{},
metatypes
.
BytesToAddress
([]
byte
{
4
})
:
&
dataCopy
{},
common
.
BytesToAddress
([]
byte
{
5
})
:
&
bigModExp
{
eip2565
:
false
},
metatypes
.
BytesToAddress
([]
byte
{
5
})
:
&
bigModExp
{
eip2565
:
false
},
common
.
BytesToAddress
([]
byte
{
0xf5
})
:
&
bigModExp
{
eip2565
:
true
},
metatypes
.
BytesToAddress
([]
byte
{
0xf5
})
:
&
bigModExp
{
eip2565
:
true
},
common
.
BytesToAddress
([]
byte
{
6
})
:
&
bn256AddIstanbul
{},
metatypes
.
BytesToAddress
([]
byte
{
6
})
:
&
bn256AddIstanbul
{},
common
.
BytesToAddress
([]
byte
{
7
})
:
&
bn256ScalarMulIstanbul
{},
metatypes
.
BytesToAddress
([]
byte
{
7
})
:
&
bn256ScalarMulIstanbul
{},
common
.
BytesToAddress
([]
byte
{
8
})
:
&
bn256PairingIstanbul
{},
metatypes
.
BytesToAddress
([]
byte
{
8
})
:
&
bn256PairingIstanbul
{},
common
.
BytesToAddress
([]
byte
{
9
})
:
&
blake2F
{},
metatypes
.
BytesToAddress
([]
byte
{
9
})
:
&
blake2F
{},
common
.
BytesToAddress
([]
byte
{
0x0a
})
:
&
kzgPointEvaluation
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0a
})
:
&
kzgPointEvaluation
{},
common
.
BytesToAddress
([]
byte
{
0x0f
,
0x0a
})
:
&
bls12381G1Add
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0f
,
0x0a
})
:
&
bls12381G1Add
{},
common
.
BytesToAddress
([]
byte
{
0x0f
,
0x0b
})
:
&
bls12381G1MultiExp
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0f
,
0x0b
})
:
&
bls12381G1MultiExp
{},
common
.
BytesToAddress
([]
byte
{
0x0f
,
0x0c
})
:
&
bls12381G2Add
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0f
,
0x0c
})
:
&
bls12381G2Add
{},
common
.
BytesToAddress
([]
byte
{
0x0f
,
0x0d
})
:
&
bls12381G2MultiExp
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0f
,
0x0d
})
:
&
bls12381G2MultiExp
{},
common
.
BytesToAddress
([]
byte
{
0x0f
,
0x0e
})
:
&
bls12381Pairing
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0f
,
0x0e
})
:
&
bls12381Pairing
{},
common
.
BytesToAddress
([]
byte
{
0x0f
,
0x0f
})
:
&
bls12381MapG1
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0f
,
0x0f
})
:
&
bls12381MapG1
{},
common
.
BytesToAddress
([]
byte
{
0x0f
,
0x10
})
:
&
bls12381MapG2
{},
metatypes
.
BytesToAddress
([]
byte
{
0x0f
,
0x10
})
:
&
bls12381MapG2
{},
}
}
// EIP-152 test vectors
// EIP-152 test vectors
...
@@ -92,20 +91,20 @@ var blake2FMalformedInputTests = []precompiledFailureTest{
...
@@ -92,20 +91,20 @@ var blake2FMalformedInputTests = []precompiledFailureTest{
}
}
func
testPrecompiled
(
addr
string
,
test
precompiledTest
,
t
*
testing
.
T
)
{
func
testPrecompiled
(
addr
string
,
test
precompiledTest
,
t
*
testing
.
T
)
{
p
:=
allPrecompiles
[
common
.
HexToAddress
(
addr
)]
p
:=
allPrecompiles
[
metatypes
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
Input
)
in
:=
metatypes
.
Hex2Bytes
(
test
.
Input
)
gas
:=
p
.
RequiredGas
(
in
)
gas
:=
p
.
RequiredGas
(
in
)
t
.
Run
(
fmt
.
Sprintf
(
"%s-Gas=%d"
,
test
.
Name
,
gas
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"%s-Gas=%d"
,
test
.
Name
,
gas
),
func
(
t
*
testing
.
T
)
{
if
res
,
_
,
err
:=
RunPrecompiledContract
(
p
,
in
,
gas
,
nil
);
err
!=
nil
{
if
res
,
_
,
err
:=
RunPrecompiledContract
(
p
,
in
,
gas
,
nil
);
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
}
else
if
common
.
Bytes2Hex
(
res
)
!=
test
.
Expected
{
}
else
if
metatypes
.
Bytes2Hex
(
res
)
!=
test
.
Expected
{
t
.
Errorf
(
"Expected %v, got %v"
,
test
.
Expected
,
common
.
Bytes2Hex
(
res
))
t
.
Errorf
(
"Expected %v, got %v"
,
test
.
Expected
,
metatypes
.
Bytes2Hex
(
res
))
}
}
if
expGas
:=
test
.
Gas
;
expGas
!=
gas
{
if
expGas
:=
test
.
Gas
;
expGas
!=
gas
{
t
.
Errorf
(
"%v: gas wrong, expected %d, got %d"
,
test
.
Name
,
expGas
,
gas
)
t
.
Errorf
(
"%v: gas wrong, expected %d, got %d"
,
test
.
Name
,
expGas
,
gas
)
}
}
// Verify that the precompile did not touch the input buffer
// Verify that the precompile did not touch the input buffer
exp
:=
common
.
Hex2Bytes
(
test
.
Input
)
exp
:=
metatypes
.
Hex2Bytes
(
test
.
Input
)
if
!
bytes
.
Equal
(
in
,
exp
)
{
if
!
bytes
.
Equal
(
in
,
exp
)
{
t
.
Errorf
(
"Precompiled %v modified input data"
,
addr
)
t
.
Errorf
(
"Precompiled %v modified input data"
,
addr
)
}
}
...
@@ -113,8 +112,8 @@ func testPrecompiled(addr string, test precompiledTest, t *testing.T) {
...
@@ -113,8 +112,8 @@ func testPrecompiled(addr string, test precompiledTest, t *testing.T) {
}
}
func
testPrecompiledOOG
(
addr
string
,
test
precompiledTest
,
t
*
testing
.
T
)
{
func
testPrecompiledOOG
(
addr
string
,
test
precompiledTest
,
t
*
testing
.
T
)
{
p
:=
allPrecompiles
[
common
.
HexToAddress
(
addr
)]
p
:=
allPrecompiles
[
metatypes
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
Input
)
in
:=
metatypes
.
Hex2Bytes
(
test
.
Input
)
gas
:=
p
.
RequiredGas
(
in
)
-
1
gas
:=
p
.
RequiredGas
(
in
)
-
1
t
.
Run
(
fmt
.
Sprintf
(
"%s-Gas=%d"
,
test
.
Name
,
gas
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"%s-Gas=%d"
,
test
.
Name
,
gas
),
func
(
t
*
testing
.
T
)
{
...
@@ -123,7 +122,7 @@ func testPrecompiledOOG(addr string, test precompiledTest, t *testing.T) {
...
@@ -123,7 +122,7 @@ func testPrecompiledOOG(addr string, test precompiledTest, t *testing.T) {
t
.
Errorf
(
"Expected error [out of gas], got [%v]"
,
err
)
t
.
Errorf
(
"Expected error [out of gas], got [%v]"
,
err
)
}
}
// Verify that the precompile did not touch the input buffer
// Verify that the precompile did not touch the input buffer
exp
:=
common
.
Hex2Bytes
(
test
.
Input
)
exp
:=
metatypes
.
Hex2Bytes
(
test
.
Input
)
if
!
bytes
.
Equal
(
in
,
exp
)
{
if
!
bytes
.
Equal
(
in
,
exp
)
{
t
.
Errorf
(
"Precompiled %v modified input data"
,
addr
)
t
.
Errorf
(
"Precompiled %v modified input data"
,
addr
)
}
}
...
@@ -131,8 +130,8 @@ func testPrecompiledOOG(addr string, test precompiledTest, t *testing.T) {
...
@@ -131,8 +130,8 @@ func testPrecompiledOOG(addr string, test precompiledTest, t *testing.T) {
}
}
func
testPrecompiledFailure
(
addr
string
,
test
precompiledFailureTest
,
t
*
testing
.
T
)
{
func
testPrecompiledFailure
(
addr
string
,
test
precompiledFailureTest
,
t
*
testing
.
T
)
{
p
:=
allPrecompiles
[
common
.
HexToAddress
(
addr
)]
p
:=
allPrecompiles
[
metatypes
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
Input
)
in
:=
metatypes
.
Hex2Bytes
(
test
.
Input
)
gas
:=
p
.
RequiredGas
(
in
)
gas
:=
p
.
RequiredGas
(
in
)
t
.
Run
(
test
.
Name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
test
.
Name
,
func
(
t
*
testing
.
T
)
{
_
,
_
,
err
:=
RunPrecompiledContract
(
p
,
in
,
gas
,
nil
)
_
,
_
,
err
:=
RunPrecompiledContract
(
p
,
in
,
gas
,
nil
)
...
@@ -140,7 +139,7 @@ func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing
...
@@ -140,7 +139,7 @@ func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing
t
.
Errorf
(
"Expected error [%v], got [%v]"
,
test
.
ExpectedError
,
err
)
t
.
Errorf
(
"Expected error [%v], got [%v]"
,
test
.
ExpectedError
,
err
)
}
}
// Verify that the precompile did not touch the input buffer
// Verify that the precompile did not touch the input buffer
exp
:=
common
.
Hex2Bytes
(
test
.
Input
)
exp
:=
metatypes
.
Hex2Bytes
(
test
.
Input
)
if
!
bytes
.
Equal
(
in
,
exp
)
{
if
!
bytes
.
Equal
(
in
,
exp
)
{
t
.
Errorf
(
"Precompiled %v modified input data"
,
addr
)
t
.
Errorf
(
"Precompiled %v modified input data"
,
addr
)
}
}
...
@@ -151,8 +150,8 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
...
@@ -151,8 +150,8 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
if
test
.
NoBenchmark
{
if
test
.
NoBenchmark
{
return
return
}
}
p
:=
allPrecompiles
[
common
.
HexToAddress
(
addr
)]
p
:=
allPrecompiles
[
metatypes
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
Input
)
in
:=
metatypes
.
Hex2Bytes
(
test
.
Input
)
reqGas
:=
p
.
RequiredGas
(
in
)
reqGas
:=
p
.
RequiredGas
(
in
)
var
(
var
(
...
@@ -184,8 +183,8 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
...
@@ -184,8 +183,8 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
bench
.
Error
(
err
)
bench
.
Error
(
err
)
return
return
}
}
if
common
.
Bytes2Hex
(
res
)
!=
test
.
Expected
{
if
metatypes
.
Bytes2Hex
(
res
)
!=
test
.
Expected
{
bench
.
Errorf
(
"Expected %v, got %v"
,
test
.
Expected
,
common
.
Bytes2Hex
(
res
))
bench
.
Errorf
(
"Expected %v, got %v"
,
test
.
Expected
,
metatypes
.
Bytes2Hex
(
res
))
return
return
}
}
})
})
...
...
evm/vm/eof_test.go
View file @
1fff77e7
...
@@ -18,10 +18,9 @@ package vm
...
@@ -18,10 +18,9 @@ package vm
import
(
import
(
"encoding/hex"
"encoding/hex"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"reflect"
"reflect"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
)
)
func
TestEOFMarshaling
(
t
*
testing
.
T
)
{
func
TestEOFMarshaling
(
t
*
testing
.
T
)
{
...
@@ -32,7 +31,7 @@ func TestEOFMarshaling(t *testing.T) {
...
@@ -32,7 +31,7 @@ func TestEOFMarshaling(t *testing.T) {
{
{
want
:
Container
{
want
:
Container
{
types
:
[]
*
functionMetadata
{{
inputs
:
0
,
outputs
:
0x80
,
maxStackHeight
:
1
}},
types
:
[]
*
functionMetadata
{{
inputs
:
0
,
outputs
:
0x80
,
maxStackHeight
:
1
}},
codeSections
:
[][]
byte
{
common
.
Hex2Bytes
(
"604200"
)},
codeSections
:
[][]
byte
{
metatypes
.
Hex2Bytes
(
"604200"
)},
data
:
[]
byte
{
0x01
,
0x02
,
0x03
},
data
:
[]
byte
{
0x01
,
0x02
,
0x03
},
dataSize
:
3
,
dataSize
:
3
,
},
},
...
@@ -40,7 +39,7 @@ func TestEOFMarshaling(t *testing.T) {
...
@@ -40,7 +39,7 @@ func TestEOFMarshaling(t *testing.T) {
{
{
want
:
Container
{
want
:
Container
{
types
:
[]
*
functionMetadata
{{
inputs
:
0
,
outputs
:
0x80
,
maxStackHeight
:
1
}},
types
:
[]
*
functionMetadata
{{
inputs
:
0
,
outputs
:
0x80
,
maxStackHeight
:
1
}},
codeSections
:
[][]
byte
{
common
.
Hex2Bytes
(
"604200"
)},
codeSections
:
[][]
byte
{
metatypes
.
Hex2Bytes
(
"604200"
)},
data
:
[]
byte
{
0x01
,
0x02
,
0x03
},
data
:
[]
byte
{
0x01
,
0x02
,
0x03
},
dataSize
:
3
,
dataSize
:
3
,
},
},
...
@@ -53,9 +52,9 @@ func TestEOFMarshaling(t *testing.T) {
...
@@ -53,9 +52,9 @@ func TestEOFMarshaling(t *testing.T) {
{
inputs
:
1
,
outputs
:
1
,
maxStackHeight
:
1
},
{
inputs
:
1
,
outputs
:
1
,
maxStackHeight
:
1
},
},
},
codeSections
:
[][]
byte
{
codeSections
:
[][]
byte
{
common
.
Hex2Bytes
(
"604200"
),
metatypes
.
Hex2Bytes
(
"604200"
),
common
.
Hex2Bytes
(
"6042604200"
),
metatypes
.
Hex2Bytes
(
"6042604200"
),
common
.
Hex2Bytes
(
"00"
),
metatypes
.
Hex2Bytes
(
"00"
),
},
},
data
:
[]
byte
{},
data
:
[]
byte
{},
},
},
...
@@ -77,12 +76,12 @@ func TestEOFMarshaling(t *testing.T) {
...
@@ -77,12 +76,12 @@ func TestEOFMarshaling(t *testing.T) {
func
TestEOFSubcontainer
(
t
*
testing
.
T
)
{
func
TestEOFSubcontainer
(
t
*
testing
.
T
)
{
var
subcontainer
=
new
(
Container
)
var
subcontainer
=
new
(
Container
)
if
err
:=
subcontainer
.
UnmarshalBinary
(
common
.
Hex2Bytes
(
"ef000101000402000100010400000000800000fe"
),
true
);
err
!=
nil
{
if
err
:=
subcontainer
.
UnmarshalBinary
(
metatypes
.
Hex2Bytes
(
"ef000101000402000100010400000000800000fe"
),
true
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
container
:=
Container
{
container
:=
Container
{
types
:
[]
*
functionMetadata
{{
inputs
:
0
,
outputs
:
0x80
,
maxStackHeight
:
1
}},
types
:
[]
*
functionMetadata
{{
inputs
:
0
,
outputs
:
0x80
,
maxStackHeight
:
1
}},
codeSections
:
[][]
byte
{
common
.
Hex2Bytes
(
"604200"
)},
codeSections
:
[][]
byte
{
metatypes
.
Hex2Bytes
(
"604200"
)},
subContainers
:
[]
*
Container
{
subcontainer
},
subContainers
:
[]
*
Container
{
subcontainer
},
data
:
[]
byte
{
0x01
,
0x02
,
0x03
},
data
:
[]
byte
{
0x01
,
0x02
,
0x03
},
dataSize
:
3
,
dataSize
:
3
,
...
...
evm/vm/eof_validation_test.go
View file @
1fff77e7
...
@@ -17,12 +17,11 @@
...
@@ -17,12 +17,11 @@
package
vm
package
vm
import
(
import
(
"code.wuban.net.cn/cmpchain/ethtracer/params"
"encoding/binary"
"encoding/binary"
"errors"
"errors"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
)
)
func
TestValidateCode
(
t
*
testing
.
T
)
{
func
TestValidateCode
(
t
*
testing
.
T
)
{
...
@@ -253,7 +252,7 @@ func TestValidateCode(t *testing.T) {
...
@@ -253,7 +252,7 @@ func TestValidateCode(t *testing.T) {
}
}
_
,
err
:=
validateCode
(
test
.
code
,
test
.
section
,
container
,
&
eofInstructionSet
,
false
)
_
,
err
:=
validateCode
(
test
.
code
,
test
.
section
,
container
,
&
eofInstructionSet
,
false
)
if
!
errors
.
Is
(
err
,
test
.
err
)
{
if
!
errors
.
Is
(
err
,
test
.
err
)
{
t
.
Errorf
(
"test %d (%s): unexpected error (want: %v, got: %v)"
,
i
,
common
.
Bytes2Hex
(
test
.
code
),
test
.
err
,
err
)
t
.
Errorf
(
"test %d (%s): unexpected error (want: %v, got: %v)"
,
i
,
metatypes
.
Bytes2Hex
(
test
.
code
),
test
.
err
,
err
)
}
}
}
}
}
}
...
...
evm/vm/gas_table_test.go
deleted
100644 → 0
View file @
323d4af7
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package
vm
import
(
"bytes"
"errors"
"math"
"math/big"
"sort"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"
)
func
TestMemoryGasCost
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
size
uint64
cost
uint64
overflow
bool
}{
{
0x1fffffffe0
,
36028809887088637
,
false
},
{
0x1fffffffe1
,
0
,
true
},
}
for
i
,
tt
:=
range
tests
{
v
,
err
:=
memoryGasCost
(
&
Memory
{},
tt
.
size
)
if
(
err
==
ErrGasUintOverflow
)
!=
tt
.
overflow
{
t
.
Errorf
(
"test %d: overflow mismatch: have %v, want %v"
,
i
,
err
==
ErrGasUintOverflow
,
tt
.
overflow
)
}
if
v
!=
tt
.
cost
{
t
.
Errorf
(
"test %d: gas cost mismatch: have %v, want %v"
,
i
,
v
,
tt
.
cost
)
}
}
}
var
eip2200Tests
=
[]
struct
{
original
byte
gaspool
uint64
input
string
used
uint64
refund
uint64
failure
error
}{
{
0
,
math
.
MaxUint64
,
"0x60006000556000600055"
,
1612
,
0
,
nil
},
// 0 -> 0 -> 0
{
0
,
math
.
MaxUint64
,
"0x60006000556001600055"
,
20812
,
0
,
nil
},
// 0 -> 0 -> 1
{
0
,
math
.
MaxUint64
,
"0x60016000556000600055"
,
20812
,
19200
,
nil
},
// 0 -> 1 -> 0
{
0
,
math
.
MaxUint64
,
"0x60016000556002600055"
,
20812
,
0
,
nil
},
// 0 -> 1 -> 2
{
0
,
math
.
MaxUint64
,
"0x60016000556001600055"
,
20812
,
0
,
nil
},
// 0 -> 1 -> 1
{
1
,
math
.
MaxUint64
,
"0x60006000556000600055"
,
5812
,
15000
,
nil
},
// 1 -> 0 -> 0
{
1
,
math
.
MaxUint64
,
"0x60006000556001600055"
,
5812
,
4200
,
nil
},
// 1 -> 0 -> 1
{
1
,
math
.
MaxUint64
,
"0x60006000556002600055"
,
5812
,
0
,
nil
},
// 1 -> 0 -> 2
{
1
,
math
.
MaxUint64
,
"0x60026000556000600055"
,
5812
,
15000
,
nil
},
// 1 -> 2 -> 0
{
1
,
math
.
MaxUint64
,
"0x60026000556003600055"
,
5812
,
0
,
nil
},
// 1 -> 2 -> 3
{
1
,
math
.
MaxUint64
,
"0x60026000556001600055"
,
5812
,
4200
,
nil
},
// 1 -> 2 -> 1
{
1
,
math
.
MaxUint64
,
"0x60026000556002600055"
,
5812
,
0
,
nil
},
// 1 -> 2 -> 2
{
1
,
math
.
MaxUint64
,
"0x60016000556000600055"
,
5812
,
15000
,
nil
},
// 1 -> 1 -> 0
{
1
,
math
.
MaxUint64
,
"0x60016000556002600055"
,
5812
,
0
,
nil
},
// 1 -> 1 -> 2
{
1
,
math
.
MaxUint64
,
"0x60016000556001600055"
,
1612
,
0
,
nil
},
// 1 -> 1 -> 1
{
0
,
math
.
MaxUint64
,
"0x600160005560006000556001600055"
,
40818
,
19200
,
nil
},
// 0 -> 1 -> 0 -> 1
{
1
,
math
.
MaxUint64
,
"0x600060005560016000556000600055"
,
10818
,
19200
,
nil
},
// 1 -> 0 -> 1 -> 0
{
1
,
2306
,
"0x6001600055"
,
2306
,
0
,
ErrOutOfGas
},
// 1 -> 1 (2300 sentry + 2xPUSH)
{
1
,
2307
,
"0x6001600055"
,
806
,
0
,
nil
},
// 1 -> 1 (2301 sentry + 2xPUSH)
}
func
TestEIP2200
(
t
*
testing
.
T
)
{
for
i
,
tt
:=
range
eip2200Tests
{
address
:=
common
.
BytesToAddress
([]
byte
(
"contract"
))
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabaseForTesting
())
statedb
.
CreateAccount
(
address
)
statedb
.
SetCode
(
address
,
hexutil
.
MustDecode
(
tt
.
input
))
statedb
.
SetState
(
address
,
common
.
Hash
{},
common
.
BytesToHash
([]
byte
{
tt
.
original
}))
statedb
.
Finalise
(
true
)
// Push the state into the "original" slot
vmctx
:=
BlockContext
{
CanTransfer
:
func
(
StateDB
,
common
.
Address
,
*
uint256
.
Int
)
bool
{
return
true
},
Transfer
:
func
(
StateDB
,
common
.
Address
,
common
.
Address
,
*
uint256
.
Int
)
{},
}
evm
:=
NewEVM
(
vmctx
,
statedb
,
params
.
AllEthashProtocolChanges
,
Config
{
ExtraEips
:
[]
int
{
2200
}})
_
,
gas
,
err
:=
evm
.
Call
(
common
.
Address
{},
address
,
nil
,
tt
.
gaspool
,
new
(
uint256
.
Int
))
if
!
errors
.
Is
(
err
,
tt
.
failure
)
{
t
.
Errorf
(
"test %d: failure mismatch: have %v, want %v"
,
i
,
err
,
tt
.
failure
)
}
if
used
:=
tt
.
gaspool
-
gas
;
used
!=
tt
.
used
{
t
.
Errorf
(
"test %d: gas used mismatch: have %v, want %v"
,
i
,
used
,
tt
.
used
)
}
if
refund
:=
evm
.
StateDB
.
GetRefund
();
refund
!=
tt
.
refund
{
t
.
Errorf
(
"test %d: gas refund mismatch: have %v, want %v"
,
i
,
refund
,
tt
.
refund
)
}
}
}
var
createGasTests
=
[]
struct
{
code
string
eip3860
bool
gasUsed
uint64
minimumGas
uint64
}{
// legacy create(0, 0, 0xc000) without 3860 used
{
"0x61C00060006000f0"
+
"600052"
+
"60206000F3"
,
false
,
41237
,
41237
},
// legacy create(0, 0, 0xc000) _with_ 3860
{
"0x61C00060006000f0"
+
"600052"
+
"60206000F3"
,
true
,
44309
,
44309
},
// create2(0, 0, 0xc001, 0) without 3860
{
"0x600061C00160006000f5"
+
"600052"
+
"60206000F3"
,
false
,
50471
,
50471
},
// create2(0, 0, 0xc001, 0) (too large), with 3860
{
"0x600061C00160006000f5"
+
"600052"
+
"60206000F3"
,
true
,
32012
,
100
_000
},
// create2(0, 0, 0xc000, 0)
// This case is trying to deploy code at (within) the limit
{
"0x600061C00060006000f5"
+
"600052"
+
"60206000F3"
,
true
,
53528
,
53528
},
// create2(0, 0, 0xc001, 0)
// This case is trying to deploy code exceeding the limit
{
"0x600061C00160006000f5"
+
"600052"
+
"60206000F3"
,
true
,
32024
,
100000
},
}
func
TestCreateGas
(
t
*
testing
.
T
)
{
for
i
,
tt
:=
range
createGasTests
{
var
gasUsed
=
uint64
(
0
)
doCheck
:=
func
(
testGas
int
)
bool
{
address
:=
common
.
BytesToAddress
([]
byte
(
"contract"
))
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabaseForTesting
())
statedb
.
CreateAccount
(
address
)
statedb
.
SetCode
(
address
,
hexutil
.
MustDecode
(
tt
.
code
))
statedb
.
Finalise
(
true
)
vmctx
:=
BlockContext
{
CanTransfer
:
func
(
StateDB
,
common
.
Address
,
*
uint256
.
Int
)
bool
{
return
true
},
Transfer
:
func
(
StateDB
,
common
.
Address
,
common
.
Address
,
*
uint256
.
Int
)
{},
BlockNumber
:
big
.
NewInt
(
0
),
}
config
:=
Config
{}
if
tt
.
eip3860
{
config
.
ExtraEips
=
[]
int
{
3860
}
}
evm
:=
NewEVM
(
vmctx
,
statedb
,
params
.
AllEthashProtocolChanges
,
config
)
var
startGas
=
uint64
(
testGas
)
ret
,
gas
,
err
:=
evm
.
Call
(
common
.
Address
{},
address
,
nil
,
startGas
,
new
(
uint256
.
Int
))
if
err
!=
nil
{
return
false
}
gasUsed
=
startGas
-
gas
if
len
(
ret
)
!=
32
{
t
.
Fatalf
(
"test %d: expected 32 bytes returned, have %d"
,
i
,
len
(
ret
))
}
if
bytes
.
Equal
(
ret
,
make
([]
byte
,
32
))
{
// Failure
return
false
}
return
true
}
minGas
:=
sort
.
Search
(
100
_000
,
doCheck
)
if
uint64
(
minGas
)
!=
tt
.
minimumGas
{
t
.
Fatalf
(
"test %d: min gas error, want %d, have %d"
,
i
,
tt
.
minimumGas
,
minGas
)
}
// If the deployment succeeded, we also check the gas used
if
minGas
<
100
_000
{
if
gasUsed
!=
tt
.
gasUsed
{
t
.
Errorf
(
"test %d: gas used mismatch: have %v, want %v"
,
i
,
gasUsed
,
tt
.
gasUsed
)
}
}
}
}
evm/vm/instructions.go
View file @
1fff77e7
...
@@ -18,9 +18,9 @@ package vm
...
@@ -18,9 +18,9 @@ package vm
import
(
import
(
"code.wuban.net.cn/cmpchain/ethcrypto/crypto"
"code.wuban.net.cn/cmpchain/ethcrypto/crypto"
"code.wuban.net.cn/cmpchain/ethtracer/evm/evmtypes"
"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"
"math"
"math"
...
@@ -943,7 +943,12 @@ func makeLog(size int) executionFunc {
...
@@ -943,7 +943,12 @@ func makeLog(size int) executionFunc {
}
}
d
:=
scope
.
Memory
.
GetCopy
(
mStart
.
Uint64
(),
mSize
.
Uint64
())
d
:=
scope
.
Memory
.
GetCopy
(
mStart
.
Uint64
(),
mSize
.
Uint64
())
interpreter
.
evm
.
StateDB
.
AddLog
(
types
.
NewLog
(
scope
.
Contract
.
Address
(),
topics
,
d
,
interpreter
.
evm
.
Context
.
BlockNumber
.
Uint64
()))
interpreter
.
evm
.
StateDB
.
AddLog
(
&
evmtypes
.
Log
{
Address
:
scope
.
Contract
.
Address
(),
Topics
:
topics
,
Data
:
d
,
BlockNumber
:
interpreter
.
evm
.
Context
.
BlockNumber
.
Uint64
(),
})
return
nil
,
nil
return
nil
,
nil
}
}
...
...
evm/vm/instructions_test.go
deleted
100644 → 0
View file @
323d4af7
This diff is collapsed.
Click to expand it.
evm/vm/interface.go
View file @
1fff77e7
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
"code.wuban.net.cn/cmpchain/ethtracer/state"
"code.wuban.net.cn/cmpchain/ethtracer/state"
"code.wuban.net.cn/cmpchain/ethtracer/stateless"
"code.wuban.net.cn/cmpchain/ethtracer/stateless"
"code.wuban.net.cn/cmpchain/ethtracer/tracing"
"code.wuban.net.cn/cmpchain/ethtracer/tracing"
"code.wuban.net.cn/cmpchain/ethtracer/types"
"code.wuban.net.cn/cmpchain/ethtracer/utils"
"code.wuban.net.cn/cmpchain/ethtracer/utils"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
...
@@ -96,7 +95,7 @@ type StateDB interface {
...
@@ -96,7 +95,7 @@ type StateDB interface {
RevertToSnapshot
(
int
)
RevertToSnapshot
(
int
)
Snapshot
()
int
Snapshot
()
int
AddLog
(
*
types
.
Log
)
AddLog
(
*
evm
types
.
Log
)
AddPreimage
(
metatypes
.
Hash
,
[]
byte
)
AddPreimage
(
metatypes
.
Hash
,
[]
byte
)
Witness
()
*
stateless
.
Witness
Witness
()
*
stateless
.
Witness
...
...
evm/vm/interpreter_test.go
deleted
100644 → 0
View file @
323d4af7
// Copyright 2021 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package
vm
import
(
"code.wuban.net.cn/cmpchain/ethtracer/params"
"code.wuban.net.cn/cmpchain/ethtracer/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"github.com/ethereum/go-ethereum/core/state"
"math"
"testing"
"time"
"github.com/holiman/uint256"
)
var
loopInterruptTests
=
[]
string
{
// infinite loop using JUMP: push(2) jumpdest dup1 jump
"60025b8056"
,
// infinite loop using JUMPI: push(1) push(4) jumpdest dup2 dup2 jumpi
"600160045b818157"
,
}
func
TestLoopInterrupt
(
t
*
testing
.
T
)
{
address
:=
metatypes
.
BytesToAddress
([]
byte
(
"contract"
))
vmctx
:=
BlockContext
{
Transfer
:
func
(
StateDB
,
metatypes
.
Address
,
metatypes
.
Address
,
*
uint256
.
Int
)
{},
}
for
i
,
tt
:=
range
loopInterruptTests
{
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabaseForTesting
())
statedb
.
CreateAccount
(
address
)
statedb
.
SetCode
(
address
,
metatypes
.
Hex2Bytes
(
tt
))
statedb
.
Finalise
(
true
)
evm
:=
NewEVM
(
vmctx
,
statedb
,
params
.
AllEthashProtocolChanges
,
Config
{})
errChannel
:=
make
(
chan
error
)
timeout
:=
make
(
chan
bool
)
go
func
(
evm
*
EVM
)
{
_
,
_
,
err
:=
evm
.
Call
(
metatypes
.
Address
{},
address
,
nil
,
math
.
MaxUint64
,
new
(
uint256
.
Int
))
errChannel
<-
err
}(
evm
)
go
func
()
{
<-
time
.
After
(
time
.
Second
)
timeout
<-
true
}()
evm
.
Cancel
()
select
{
case
<-
timeout
:
t
.
Errorf
(
"test %d timed out"
,
i
)
case
err
:=
<-
errChannel
:
if
err
!=
nil
{
t
.
Errorf
(
"test %d failure: %v"
,
i
,
err
)
}
}
}
}
evm/vm/memory_test.go
View file @
1fff77e7
...
@@ -18,10 +18,9 @@ package vm
...
@@ -18,10 +18,9 @@ package vm
import
(
import
(
"bytes"
"bytes"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"strings"
"strings"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
)
)
func
TestMemoryCopy
(
t
*
testing
.
T
)
{
func
TestMemoryCopy
(
t
*
testing
.
T
)
{
...
@@ -71,13 +70,13 @@ func TestMemoryCopy(t *testing.T) {
...
@@ -71,13 +70,13 @@ func TestMemoryCopy(t *testing.T) {
}
{
}
{
m
:=
NewMemory
()
m
:=
NewMemory
()
// Clean spaces
// Clean spaces
data
:=
common
.
FromHex
(
strings
.
ReplaceAll
(
tc
.
pre
,
" "
,
""
))
data
:=
metatypes
.
FromHex
(
strings
.
ReplaceAll
(
tc
.
pre
,
" "
,
""
))
// Set pre
// Set pre
m
.
Resize
(
uint64
(
len
(
data
)))
m
.
Resize
(
uint64
(
len
(
data
)))
m
.
Set
(
0
,
uint64
(
len
(
data
)),
data
)
m
.
Set
(
0
,
uint64
(
len
(
data
)),
data
)
// Do the copy
// Do the copy
m
.
Copy
(
tc
.
dst
,
tc
.
src
,
tc
.
len
)
m
.
Copy
(
tc
.
dst
,
tc
.
src
,
tc
.
len
)
want
:=
common
.
FromHex
(
strings
.
ReplaceAll
(
tc
.
want
,
" "
,
""
))
want
:=
metatypes
.
FromHex
(
strings
.
ReplaceAll
(
tc
.
want
,
" "
,
""
))
if
have
:=
m
.
store
;
!
bytes
.
Equal
(
want
,
have
)
{
if
have
:=
m
.
store
;
!
bytes
.
Equal
(
want
,
have
)
{
t
.
Errorf
(
"case %d: want: %#x
\n
have: %#x
\n
"
,
i
,
want
,
have
)
t
.
Errorf
(
"case %d: want: %#x
\n
have: %#x
\n
"
,
i
,
want
,
have
)
}
}
...
...
evm/vm/runtime/runtime.go
View file @
1fff77e7
...
@@ -21,11 +21,8 @@ import (
...
@@ -21,11 +21,8 @@ import (
"code.wuban.net.cn/cmpchain/ethtracer/evm/evmtypes"
"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/types"
"errors"
"errors"
basetype
"github.com/CaduceusMetaverseProtocol/MetaProtocol/gen/proto/go/base/v1"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"github.com/ethereum/go-ethereum/core/state"
"math"
"math"
"math/big"
"math/big"
...
@@ -153,7 +150,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, vm.StateDB, error) {
...
@@ -153,7 +150,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, vm.StateDB, error) {
uint256
.
MustFromBig
(
cfg
.
Value
),
uint256
.
MustFromBig
(
cfg
.
Value
),
)
)
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
!=
nil
{
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
!=
nil
{
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
(
&
types
.
Receipt
{
GasUsed
:
cfg
.
GasLimit
-
leftOverGas
},
err
)
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
(
&
evm
types
.
Receipt
{
GasUsed
:
cfg
.
GasLimit
-
leftOverGas
},
err
)
}
}
return
ret
,
cfg
.
State
,
err
return
ret
,
cfg
.
State
,
err
}
}
...
@@ -166,14 +163,15 @@ func Create(input []byte, cfg *Config) ([]byte, metatypes.Address, uint64, error
...
@@ -166,14 +163,15 @@ func Create(input []byte, cfg *Config) ([]byte, metatypes.Address, uint64, error
setDefaults
(
cfg
)
setDefaults
(
cfg
)
if
cfg
.
State
==
nil
{
if
cfg
.
State
==
nil
{
cfg
.
State
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabaseForTesting
())
return
nil
,
metatypes
.
Address
{},
0
,
errors
.
New
(
"state must be set in config for Create"
)
//cfg.State, _ = state.New(types.EmptyRootHash, state.NewDatabaseForTesting())
}
}
var
(
var
(
vmenv
=
NewEnv
(
cfg
)
vmenv
=
NewEnv
(
cfg
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
,
vmenv
.
Context
.
Time
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
,
vmenv
.
Context
.
Time
)
)
)
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
!=
nil
{
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
!=
nil
{
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
(
vmenv
.
GetVMContext
(),
types
.
NewTx
(
&
types
.
LegacyTx
{
Data
:
input
,
Value
:
cfg
.
Value
,
Gas
:
cfg
.
GasLimit
}),
cfg
.
Origin
)
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
(
vmenv
.
GetVMContext
(),
evmtypes
.
NewTx
(
&
evm
types
.
LegacyTx
{
Data
:
input
,
Value
:
cfg
.
Value
,
Gas
:
cfg
.
GasLimit
}),
cfg
.
Origin
)
}
}
// Execute the preparatory steps for state transition which includes:
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
// - prepare accessList(post-berlin)
...
@@ -187,10 +185,8 @@ func Create(input []byte, cfg *Config) ([]byte, metatypes.Address, uint64, error
...
@@ -187,10 +185,8 @@ func Create(input []byte, cfg *Config) ([]byte, metatypes.Address, uint64, error
uint256
.
MustFromBig
(
cfg
.
Value
),
uint256
.
MustFromBig
(
cfg
.
Value
),
)
)
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
!=
nil
{
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
!=
nil
{
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
(
&
types
.
Receipt
{
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
(
&
evmtypes
.
Receipt
{
MetaReceipt
:
&
basetype
.
MetaReceipt
{
GasUsed
:
cfg
.
GasLimit
-
leftOverGas
,
GasUsed
:
cfg
.
GasLimit
-
leftOverGas
,
},
},
err
)
},
err
)
}
}
return
code
,
address
,
leftOverGas
,
err
return
code
,
address
,
leftOverGas
,
err
...
@@ -210,7 +206,7 @@ func Call(address metatypes.Address, input []byte, cfg *Config) ([]byte, uint64,
...
@@ -210,7 +206,7 @@ func Call(address metatypes.Address, input []byte, cfg *Config) ([]byte, uint64,
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
,
vmenv
.
Context
.
Time
)
rules
=
cfg
.
ChainConfig
.
Rules
(
vmenv
.
Context
.
BlockNumber
,
vmenv
.
Context
.
Random
!=
nil
,
vmenv
.
Context
.
Time
)
)
)
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
!=
nil
{
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
!=
nil
{
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
(
vmenv
.
GetVMContext
(),
types
.
NewTx
(
&
types
.
LegacyTx
{
To
:
&
address
,
Data
:
input
,
Value
:
cfg
.
Value
,
Gas
:
cfg
.
GasLimit
}),
cfg
.
Origin
)
cfg
.
EVMConfig
.
Tracer
.
OnTxStart
(
vmenv
.
GetVMContext
(),
evmtypes
.
NewTx
(
&
evm
types
.
LegacyTx
{
To
:
&
address
,
Data
:
input
,
Value
:
cfg
.
Value
,
Gas
:
cfg
.
GasLimit
}),
cfg
.
Origin
)
}
}
// Execute the preparatory steps for state transition which includes:
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
// - prepare accessList(post-berlin)
...
@@ -226,11 +222,14 @@ func Call(address metatypes.Address, input []byte, cfg *Config) ([]byte, uint64,
...
@@ -226,11 +222,14 @@ func Call(address metatypes.Address, input []byte, cfg *Config) ([]byte, uint64,
uint256
.
MustFromBig
(
cfg
.
Value
),
uint256
.
MustFromBig
(
cfg
.
Value
),
)
)
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
!=
nil
{
if
cfg
.
EVMConfig
.
Tracer
!=
nil
&&
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
!=
nil
{
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
(
&
types
.
Receipt
{
cfg
.
EVMConfig
.
Tracer
.
OnTxEnd
(
&
evmtypes
.
Receipt
{
MetaReceipt
:
&
basetype
.
MetaReceipt
{
GasUsed
:
cfg
.
GasLimit
-
leftOverGas
,
GasUsed
:
cfg
.
GasLimit
-
leftOverGas
,
},
},
err
)
},
err
)
//cfg.EVMConfig.Tracer.OnTxEnd(&types.Receipt{
// MetaReceipt: &basetype.MetaReceipt{
// GasUsed: cfg.GasLimit - leftOverGas,
// },
//}, err)
}
}
return
ret
,
leftOverGas
,
err
return
ret
,
leftOverGas
,
err
}
}
evm/vm/runtime/runtime_example_test.go
deleted
100644 → 0
View file @
323d4af7
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package
runtime_test
import
(
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm/runtime"
)
func
ExampleExecute
()
{
ret
,
_
,
err
:=
runtime
.
Execute
(
common
.
Hex2Bytes
(
"6060604052600a8060106000396000f360606040526008565b00"
),
nil
,
nil
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
fmt
.
Println
(
ret
)
// Output:
// [96 96 96 64 82 96 8 86 91 0]
}
evm/vm/runtime/runtime_fuzz_test.go
deleted
100644 → 0
View file @
323d4af7
// Copyright 2023 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package
runtime
import
(
"testing"
)
func
FuzzVmRuntime
(
f
*
testing
.
F
)
{
f
.
Fuzz
(
func
(
t
*
testing
.
T
,
code
,
input
[]
byte
)
{
Execute
(
code
,
input
,
&
Config
{
GasLimit
:
12000000
,
})
})
}
evm/vm/runtime/runtime_test.go
deleted
100644 → 0
View file @
323d4af7
This diff is collapsed.
Click to expand it.
go.mod
View file @
1fff77e7
...
@@ -3,33 +3,27 @@ module code.wuban.net.cn/cmpchain/ethtracer
...
@@ -3,33 +3,27 @@ module code.wuban.net.cn/cmpchain/ethtracer
go 1.24.0
go 1.24.0
require (
require (
github.com/CaduceusMetaverseProtocol/MetaProtocol v0.0.0-00010101000000-000000000000
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707071006-5c3f8f42b6ad
github.com/CaduceusMetaverseProtocol/MetaTypes v1.0.0
github.com/CaduceusMetaverseProtocol/MetaTypes v1.0.0
github.com/consensys/gnark-crypto v0.18.0
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a
github.com/ethereum/go-verkle v0.2.2
github.com/holiman/uint256 v1.3.2
github.com/holiman/uint256 v1.3.2
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.36.0
)
)
require (
require (
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707071006-5c3f8f42b6ad // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
github.com/consensys/gnark-crypto v0.18.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 // indirect
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/supranational/blst v0.3.14 // indirect
github.com/supranational/blst v0.3.14 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/sys v0.33.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
)
...
...
go.sum
View file @
1fff77e7
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707002024-1f73f3d61c24 h1:yfcvA4ma+sn2LaUSDKEqlLCqc8O38kRNzZX022FRFEA=
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707002024-1f73f3d61c24/go.mod h1:yA5sSeNbmo4+xVQ5P0/5xAA/jh8eP3CYB9M+sGn3llM=
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707071006-5c3f8f42b6ad h1:3oJWA4OyqocLv8uwSV47wba6+ZX+Pq7EBI4kolp+RbI=
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707071006-5c3f8f42b6ad h1:3oJWA4OyqocLv8uwSV47wba6+ZX+Pq7EBI4kolp+RbI=
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707071006-5c3f8f42b6ad/go.mod h1:yA5sSeNbmo4+xVQ5P0/5xAA/jh8eP3CYB9M+sGn3llM=
code.wuban.net.cn/cmpchain/ethcrypto v0.0.0-20250707071006-5c3f8f42b6ad/go.mod h1:yA5sSeNbmo4+xVQ5P0/5xAA/jh8eP3CYB9M+sGn3llM=
github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3MdfoPyRVU=
github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3MdfoPyRVU=
github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/consensys/gnark-crypto v0.18.0 h1:vIye/FqI50VeAr0B3dx+YjeIvmc3LWz4yEfbWBpTUf0=
github.com/consensys/gnark-crypto v0.18.0 h1:vIye/FqI50VeAr0B3dx+YjeIvmc3LWz4yEfbWBpTUf0=
github.com/consensys/gnark-crypto v0.18.0/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c=
github.com/consensys/gnark-crypto v0.18.0/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c=
github.com/crate-crypto/go-ipa v0.0.0-20240
223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I
=
github.com/crate-crypto/go-ipa v0.0.0-20240
724233137-53bbb0ceb27a h1:W8mUrRp6NOVl3J+MYp5kPMoUZPp7aOYHtaua31lwRHg
=
github.com/crate-crypto/go-ipa v0.0.0-20240
223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs
=
github.com/crate-crypto/go-ipa v0.0.0-20240
724233137-53bbb0ceb27a/go.mod h1:sTwzHBvIzm2RfVCGNEBZgRyjwK40bVoun3ZnGOCafNM
=
github.com/crate-crypto/go-kzg-4844 v1.1.0 h1:EN/u9k2TF6OWSHrCCDBBU6GLNMq88OspHHlMnHfoyU4=
github.com/crate-crypto/go-kzg-4844 v1.1.0 h1:EN/u9k2TF6OWSHrCCDBBU6GLNMq88OspHHlMnHfoyU4=
github.com/crate-crypto/go-kzg-4844 v1.1.0/go.mod h1:JolLjpSff1tCCJKaJx4psrlEdlXuJEC996PL3tTAFks=
github.com/crate-crypto/go-kzg-4844 v1.1.0/go.mod h1:JolLjpSff1tCCJKaJx4psrlEdlXuJEC996PL3tTAFks=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8=
github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 h1:B2mpK+MNqgPqk2/KNi1LbqwtZDy5F7iy0mynQiBr8VA=
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 h1:B2mpK+MNqgPqk2/KNi1LbqwtZDy5F7iy0mynQiBr8VA=
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4/go.mod h1:y4GA2JbAUama1S4QwYjC2hefgGLU8Ul0GMtL/ADMF1c=
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4/go.mod h1:y4GA2JbAUama1S4QwYjC2hefgGLU8Ul0GMtL/ADMF1c=
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA=
github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA=
github.com/holiman/uint256 v1.3.2/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/holiman/uint256 v1.3.2/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
...
@@ -47,46 +39,18 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
...
@@ -47,46 +39,18 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/supranational/blst v0.3.14 h1:xNMoHRJOTwMn63ip6qoWJ2Ymgvj7E2b9jY2FAwY+qRo=
github.com/supranational/blst v0.3.14 h1:xNMoHRJOTwMn63ip6qoWJ2Ymgvj7E2b9jY2FAwY+qRo=
github.com/supranational/blst v0.3.14/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/supranational/blst v0.3.14/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
stateless/encoding.go
View file @
1fff77e7
...
@@ -17,10 +17,10 @@
...
@@ -17,10 +17,10 @@
package
stateless
package
stateless
import
(
import
(
"code.wuban.net.cn/cmpchain/ethtracer/evm/evmtypes"
"io"
"io"
"code.wuban.net.cn/cmpchain/ethcrypto/rlp"
"code.wuban.net.cn/cmpchain/ethcrypto/rlp"
"code.wuban.net.cn/cmpchain/ethtracer/types"
)
)
// toExtWitness converts our internal witness representation to the consensus one.
// toExtWitness converts our internal witness representation to the consensus one.
...
@@ -70,7 +70,7 @@ func (w *Witness) DecodeRLP(s *rlp.Stream) error {
...
@@ -70,7 +70,7 @@ func (w *Witness) DecodeRLP(s *rlp.Stream) error {
// extWitness is a witness RLP encoding for transferring across clients.
// extWitness is a witness RLP encoding for transferring across clients.
type
extWitness
struct
{
type
extWitness
struct
{
Headers
[]
*
types
.
Header
Headers
[]
*
evm
types
.
Header
Codes
[][]
byte
Codes
[][]
byte
State
[][]
byte
State
[][]
byte
}
}
stateless/witness.go
View file @
1fff77e7
...
@@ -17,28 +17,27 @@
...
@@ -17,28 +17,27 @@
package
stateless
package
stateless
import
(
import
(
"code.wuban.net.cn/cmpchain/ethtracer/evm/evmtypes"
"errors"
"errors"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"maps"
"maps"
"slices"
"slices"
"sync"
"sync"
"code.wuban.net.cn/cmpchain/ethtracer/types"
)
)
// HeaderReader is an interface to pull in headers in place of block hashes for
// HeaderReader is an interface to pull in headers in place of block hashes for
// the witness.
// the witness.
type
HeaderReader
interface
{
type
HeaderReader
interface
{
// GetHeader retrieves a block header from the database by hash and number,
// GetHeader retrieves a block header from the database by hash and number,
GetHeader
(
hash
metatypes
.
Hash
,
number
uint64
)
*
types
.
Header
GetHeader
(
hash
metatypes
.
Hash
,
number
uint64
)
*
evm
types
.
Header
}
}
// Witness encompasses the state required to apply a set of transactions and
// Witness encompasses the state required to apply a set of transactions and
// derive a post state/receipt root.
// derive a post state/receipt root.
type
Witness
struct
{
type
Witness
struct
{
context
*
types
.
Header
// Header to which this witness belongs to, with rootHash and receiptHash zeroed out
context
*
evm
types
.
Header
// Header to which this witness belongs to, with rootHash and receiptHash zeroed out
Headers
[]
*
types
.
Header
// Past headers in reverse order (0=parent, 1=parent's-parent, etc). First *must* be set.
Headers
[]
*
evmtypes
.
Header
// Past headers in reverse order (0=parent, 1=parent's-parent, etc). First *must* be set.
Codes
map
[
string
]
struct
{}
// Set of bytecodes ran or accessed
Codes
map
[
string
]
struct
{}
// Set of bytecodes ran or accessed
State
map
[
string
]
struct
{}
// Set of MPT state trie nodes (account and storage together)
State
map
[
string
]
struct
{}
// Set of MPT state trie nodes (account and storage together)
...
@@ -47,12 +46,12 @@ type Witness struct {
...
@@ -47,12 +46,12 @@ type Witness struct {
}
}
// NewWitness creates an empty witness ready for population.
// NewWitness creates an empty witness ready for population.
func
NewWitness
(
context
*
types
.
Header
,
chain
HeaderReader
)
(
*
Witness
,
error
)
{
func
NewWitness
(
context
*
evm
types
.
Header
,
chain
HeaderReader
)
(
*
Witness
,
error
)
{
// When building witnesses, retrieve the parent header, which will *always*
// When building witnesses, retrieve the parent header, which will *always*
// be included to act as a trustless pre-root hash container
// be included to act as a trustless pre-root hash container
var
headers
[]
*
types
.
Header
var
headers
[]
*
evm
types
.
Header
if
chain
!=
nil
{
if
chain
!=
nil
{
parent
:=
chain
.
GetHeader
(
context
.
Parent
(),
context
.
Number
()
.
Uint64
()
-
1
)
parent
:=
chain
.
GetHeader
(
context
.
Parent
Hash
,
context
.
Number
.
Uint64
()
-
1
)
if
parent
==
nil
{
if
parent
==
nil
{
return
nil
,
errors
.
New
(
"failed to retrieve parent header"
)
return
nil
,
errors
.
New
(
"failed to retrieve parent header"
)
}
}
...
@@ -73,9 +72,9 @@ func NewWitness(context *types.Header, chain HeaderReader) (*Witness, error) {
...
@@ -73,9 +72,9 @@ func NewWitness(context *types.Header, chain HeaderReader) (*Witness, error) {
// the chain to cover the block being added.
// the chain to cover the block being added.
func
(
w
*
Witness
)
AddBlockHash
(
number
uint64
)
{
func
(
w
*
Witness
)
AddBlockHash
(
number
uint64
)
{
// Keep pulling in headers until this hash is populated
// Keep pulling in headers until this hash is populated
for
int
(
w
.
context
.
Number
()
.
Uint64
()
-
number
)
>
len
(
w
.
Headers
)
{
for
int
(
w
.
context
.
Number
.
Uint64
()
-
number
)
>
len
(
w
.
Headers
)
{
tail
:=
w
.
Headers
[
len
(
w
.
Headers
)
-
1
]
tail
:=
w
.
Headers
[
len
(
w
.
Headers
)
-
1
]
w
.
Headers
=
append
(
w
.
Headers
,
w
.
chain
.
GetHeader
(
tail
.
Parent
(),
tail
.
Number
()
.
Uint64
()
-
1
))
w
.
Headers
=
append
(
w
.
Headers
,
w
.
chain
.
GetHeader
(
tail
.
Parent
Hash
,
tail
.
Number
.
Uint64
()
-
1
))
}
}
}
}
...
@@ -108,7 +107,7 @@ func (w *Witness) Copy() *Witness {
...
@@ -108,7 +107,7 @@ func (w *Witness) Copy() *Witness {
chain
:
w
.
chain
,
chain
:
w
.
chain
,
}
}
if
w
.
context
!=
nil
{
if
w
.
context
!=
nil
{
cpy
.
context
=
types
.
CopyHeader
(
w
.
context
)
cpy
.
context
=
evm
types
.
CopyHeader
(
w
.
context
)
}
}
return
cpy
return
cpy
}
}
...
@@ -118,5 +117,5 @@ func (w *Witness) Copy() *Witness {
...
@@ -118,5 +117,5 @@ func (w *Witness) Copy() *Witness {
// Note, this method will panic in case of a bad witness (but RLP decoding will
// Note, this method will panic in case of a bad witness (but RLP decoding will
// sanitize it and fail before that).
// sanitize it and fail before that).
func
(
w
*
Witness
)
Root
()
metatypes
.
Hash
{
func
(
w
*
Witness
)
Root
()
metatypes
.
Hash
{
return
w
.
Headers
[
0
]
.
Root
()
return
w
.
Headers
[
0
]
.
Root
}
}
tracing/hooks.go
View file @
1fff77e7
...
@@ -25,12 +25,12 @@
...
@@ -25,12 +25,12 @@
package
tracing
package
tracing
import
(
import
(
"code.wuban.net.cn/cmpchain/ethtracer/evm/evmtypes"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"github.com/CaduceusMetaverseProtocol/MetaTypes/types/coretype"
metacore
"github.com/CaduceusMetaverseProtocol/MetaTypes/types/coretype"
"math/big"
"math/big"
"code.wuban.net.cn/cmpchain/ethtracer/params"
"code.wuban.net.cn/cmpchain/ethtracer/params"
"code.wuban.net.cn/cmpchain/ethtracer/types"
"github.com/holiman/uint256"
"github.com/holiman/uint256"
)
)
...
@@ -71,9 +71,9 @@ type VMContext struct {
...
@@ -71,9 +71,9 @@ type VMContext struct {
// BlockEvent is emitted upon tracing an incoming block.
// BlockEvent is emitted upon tracing an incoming block.
// It contains the block as well as consensus related information.
// It contains the block as well as consensus related information.
type
BlockEvent
struct
{
type
BlockEvent
struct
{
Block
*
types
.
Block
Block
*
evm
types
.
Block
Finalized
*
types
.
Header
Finalized
*
evm
types
.
Header
Safe
*
types
.
Header
Safe
*
evm
types
.
Header
}
}
type
(
type
(
...
@@ -84,10 +84,10 @@ type (
...
@@ -84,10 +84,10 @@ type (
// TxStartHook is called before the execution of a transaction starts.
// TxStartHook is called before the execution of a transaction starts.
// Call simulations don't come with a valid signature. `from` field
// Call simulations don't come with a valid signature. `from` field
// to be used for address of the caller.
// to be used for address of the caller.
TxStartHook
=
func
(
vm
*
VMContext
,
tx
*
types
.
Transaction
,
from
metatypes
.
Address
)
TxStartHook
=
func
(
vm
*
VMContext
,
tx
*
evm
types
.
Transaction
,
from
metatypes
.
Address
)
// TxEndHook is called after the execution of a transaction ends.
// TxEndHook is called after the execution of a transaction ends.
TxEndHook
=
func
(
receipt
*
types
.
Receipt
,
err
error
)
TxEndHook
=
func
(
receipt
*
evm
types
.
Receipt
,
err
error
)
// EnterHook is invoked when the processing of a message starts.
// EnterHook is invoked when the processing of a message starts.
//
//
...
@@ -140,7 +140,7 @@ type (
...
@@ -140,7 +140,7 @@ type (
SkippedBlockHook
=
func
(
event
BlockEvent
)
SkippedBlockHook
=
func
(
event
BlockEvent
)
// GenesisBlockHook is called when the genesis block is being processed.
// GenesisBlockHook is called when the genesis block is being processed.
GenesisBlockHook
=
func
(
genesis
*
types
.
Block
,
alloc
coretyp
e
.
GenesisAccount
)
GenesisBlockHook
=
func
(
genesis
*
evmtypes
.
Block
,
alloc
metacor
e
.
GenesisAccount
)
// OnSystemCallStartHook is called when a system call is about to be executed. Today,
// OnSystemCallStartHook is called when a system call is about to be executed. Today,
// this hook is invoked when the EIP-4788 system call is about to be executed to set the
// this hook is invoked when the EIP-4788 system call is about to be executed to set the
...
@@ -182,7 +182,7 @@ type (
...
@@ -182,7 +182,7 @@ type (
StorageChangeHook
=
func
(
addr
metatypes
.
Address
,
slot
metatypes
.
Hash
,
prev
,
new
metatypes
.
Hash
)
StorageChangeHook
=
func
(
addr
metatypes
.
Address
,
slot
metatypes
.
Hash
,
prev
,
new
metatypes
.
Hash
)
// LogHook is called when a log is emitted.
// LogHook is called when a log is emitted.
LogHook
=
func
(
log
*
types
.
Log
)
LogHook
=
func
(
log
*
evm
types
.
Log
)
// BlockHashReadHook is called when EVM reads the blockhash of a block.
// BlockHashReadHook is called when EVM reads the blockhash of a block.
BlockHashReadHook
=
func
(
blockNumber
uint64
,
hash
metatypes
.
Hash
)
BlockHashReadHook
=
func
(
blockNumber
uint64
,
hash
metatypes
.
Hash
)
...
...
tracing/journal.go
View file @
1fff77e7
...
@@ -17,10 +17,10 @@
...
@@ -17,10 +17,10 @@
package
tracing
package
tracing
import
(
import
(
"code.wuban.net.cn/cmpchain/ethtracer/evm/evmtypes"
"fmt"
"fmt"
"math/big"
"math/big"
"code.wuban.net.cn/cmpchain/ethtracer/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
)
)
...
@@ -112,7 +112,7 @@ func (j *journal) popRevision() {
...
@@ -112,7 +112,7 @@ func (j *journal) popRevision() {
}
}
// OnTxEnd resets the journal since each transaction has its own EVM call stack.
// OnTxEnd resets the journal since each transaction has its own EVM call stack.
func
(
j
*
journal
)
OnTxEnd
(
receipt
*
types
.
Receipt
,
err
error
)
{
func
(
j
*
journal
)
OnTxEnd
(
receipt
*
evm
types
.
Receipt
,
err
error
)
{
j
.
reset
()
j
.
reset
()
if
j
.
hooks
.
OnTxEnd
!=
nil
{
if
j
.
hooks
.
OnTxEnd
!=
nil
{
j
.
hooks
.
OnTxEnd
(
receipt
,
err
)
j
.
hooks
.
OnTxEnd
(
receipt
,
err
)
...
...
types/types.go
View file @
1fff77e7
package
types
package
types
import
(
import
(
basetype
"github.com/CaduceusMetaverseProtocol/MetaProtocol/gen/proto/go/base/v1"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
metatypes
"github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"math/big"
)
)
var
(
var
(
...
@@ -12,69 +10,70 @@ var (
...
@@ -12,69 +10,70 @@ var (
EmptyCodeHash
=
metatypes
.
HexToHash
(
"c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
)
EmptyCodeHash
=
metatypes
.
HexToHash
(
"c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
)
)
)
type
Block
struct
{
//
*
basetype
.
MetaBlock
//type Block struct {
}
// *basetype.MetaBlock
//}
type
Header
struct
{
//
*
basetype
.
MetaBlockHeader
//type Header struct {
}
// *basetype.MetaBlockHeader
//}
func
(
h
*
Header
)
Number
()
*
big
.
Int
{
//
return
h
.
BlockNumber
.
GetInt
()
//func (h *Header) Number() *big.Int {
}
// return h.BlockNumber.GetInt()
//}
func
(
h
*
Header
)
Parent
()
metatypes
.
Hash
{
//
return
*
h
.
ParentHash
//func (h *Header) Parent() metatypes.Hash {
}
// return *h.ParentHash
func
(
h
*
Header
)
Root
()
metatypes
.
Hash
{
//}
return
*
h
.
StateRoot
//func (h *Header) Root() metatypes.Hash {
}
// return *h.StateRoot
//}
type
Transaction
struct
{
//
*
basetype
.
MetaProofTx
//type Transaction struct {
}
// *basetype.MetaProofTx
//}
type
Receipt
struct
{
//
*
basetype
.
MetaReceipt
//type Receipt struct {
}
// *basetype.MetaReceipt
//}
type
Log
struct
{
//
*
basetype
.
MetaTxLog
//type Log struct {
}
// *basetype.MetaTxLog
//}
func
NewLog
(
addr
metatypes
.
Address
,
topics
[]
metatypes
.
Hash
,
data
[]
byte
,
number
uint64
)
*
Log
{
//
l
:=
&
Log
{
//func NewLog(addr metatypes.Address, topics []metatypes.Hash, data []byte, number uint64) *Log {
MetaTxLog
:
&
basetype
.
MetaTxLog
{
// l := &Log{
Address
:
new
(
metatypes
.
Address
),
// MetaTxLog: &basetype.MetaTxLog{
Topics
:
make
([]
*
basetype
.
MetaTopic
,
len
(
topics
)),
// Address: new(metatypes.Address),
Data
:
data
,
// Topics: make([]*basetype.MetaTopic, len(topics)),
BlockNumber
:
number
,
// Data: data,
},
// BlockNumber: number,
}
// },
l
.
Address
.
SetBytes
(
addr
.
Bytes
())
// }
for
i
,
topic
:=
range
topics
{
// l.Address.SetBytes(addr.Bytes())
l
.
Topics
[
i
]
=
&
basetype
.
MetaTopic
{
// for i, topic := range topics {
Topic
:
new
(
metatypes
.
Hash
),
// l.Topics[i] = &basetype.MetaTopic{
}
// Topic: new(metatypes.Hash),
l
.
Topics
[
i
]
.
Topic
.
SetBytes
(
topic
.
Bytes
())
// }
}
// l.Topics[i].Topic.SetBytes(topic.Bytes())
return
l
// }
}
// return l
//}
//type GenesisAlloc struct {
//
// *basetype.MetaGenesisAlloc
////type GenesisAlloc struct {
//// *basetype.MetaGenesisAlloc
////}
//
//func CopyHeader(h *Header) *Header {
// return &Header{
// MetaBlockHeader: &basetype.MetaBlockHeader{
// BlockNumber: h.BlockNumber,
// ParentHash: h.ParentHash,
// Timestamp: h.Timestamp,
// Miner: h.Miner,
// GasLimit: h.GasLimit,
// GasUsed: h.GasUsed,
// },
// }
//}
//}
func
CopyHeader
(
h
*
Header
)
*
Header
{
return
&
Header
{
MetaBlockHeader
:
&
basetype
.
MetaBlockHeader
{
BlockNumber
:
h
.
BlockNumber
,
ParentHash
:
h
.
ParentHash
,
Timestamp
:
h
.
Timestamp
,
Miner
:
h
.
Miner
,
GasLimit
:
h
.
GasLimit
,
GasUsed
:
h
.
GasUsed
,
},
}
}
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