Skip to content

Commit

Permalink
resolve merge conflicts in eth/tracers/internal/tracetest/calltrace_t…
Browse files Browse the repository at this point in the history
…est.go
  • Loading branch information
ganeshvanahalli committed Apr 9, 2024
2 parents f7f6595 + b1cec85 commit c6b8994
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 108 deletions.
18 changes: 17 additions & 1 deletion cmd/evm/blockrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"os"
"regexp"
"sort"

"github.com/ethereum/go-ethereum/core/rawdb"
Expand All @@ -30,11 +31,18 @@ import (
"github.com/urfave/cli/v2"
)

var RunFlag = &cli.StringFlag{
Name: "run",
Value: ".*",
Usage: "Run only those tests matching the regular expression.",
}

var blockTestCommand = &cli.Command{
Action: blockTestCmd,
Name: "blocktest",
Usage: "executes the given blockchain tests",
ArgsUsage: "<file>",
Flags: []cli.Flag{RunFlag},
}

func blockTestCmd(ctx *cli.Context) error {
Expand All @@ -61,13 +69,21 @@ func blockTestCmd(ctx *cli.Context) error {
if err = json.Unmarshal(src, &tests); err != nil {
return err
}
// run them in order
re, err := regexp.Compile(ctx.String(RunFlag.Name))
if err != nil {
return fmt.Errorf("invalid regex -%s: %v", RunFlag.Name, err)
}

// Run them in order
var keys []string
for key := range tests {
keys = append(keys, key)
}
sort.Strings(keys)
for _, name := range keys {
if !re.MatchString(name) {
continue
}
test := tests[name]
if err := test.Run(false, rawdb.HashScheme, tracer); err != nil {
return fmt.Errorf("test %v: %w", name, err)
Expand Down
11 changes: 4 additions & 7 deletions core/vm/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ const (
SELFDESTRUCT OpCode = 0xff
)

// Since the opcodes aren't all in order we can't use a regular slice.
var opCodeToString = map[OpCode]string{
var opCodeToString = [256]string{
// 0x0 range - arithmetic ops.
STOP: "STOP",
ADD: "ADD",
Expand Down Expand Up @@ -399,12 +398,10 @@ var opCodeToString = map[OpCode]string{
}

func (op OpCode) String() string {
str := opCodeToString[op]
if len(str) == 0 {
return fmt.Sprintf("opcode %#x not defined", int(op))
if s := opCodeToString[op]; s != "" {
return s
}

return str
return fmt.Sprintf("opcode %#x not defined", int(op))
}

var stringToOp = map[string]OpCode{
Expand Down
9 changes: 5 additions & 4 deletions eth/tracers/internal/tracetest/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ type callContext struct {

// callLog is the result of LOG opCode
type callLog struct {
Address common.Address `json:"address"`
Topics []common.Hash `json:"topics"`
Data hexutil.Bytes `json:"data"`
Address common.Address `json:"address"`
Topics []common.Hash `json:"topics"`
Data hexutil.Bytes `json:"data"`
Position hexutil.Uint `json:"position"`
}

type arbitrumTransfer struct {
Expand Down Expand Up @@ -335,7 +336,7 @@ func TestInternals(t *testing.T) {
byte(vm.LOG0),
},
tracer: mkTracer("callTracer", json.RawMessage(`{ "withLog": true }`)),
want: `{"beforeEVMTransfers":[{"purpose":"feePayment","from":"0x000000000000000000000000000000000000FEeD","to":null,"value":"0x0"}],"afterEVMTransfers":[{"purpose":"gasRefund","from":null,"to":"0x000000000000000000000000000000000000FEeD","value":"0x0"},{"purpose":"tip","from":null,"to":"0x0000000000000000000000000000000000000000","value":"0x0"}],"from":"0x000000000000000000000000000000000000feed","gas":"0x13880","gasUsed":"0x5b9e","to":"0x00000000000000000000000000000000deadbeef","input":"0x","logs":[{"address":"0x00000000000000000000000000000000deadbeef","topics":[],"data":"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}],"value":"0x0","type":"CALL"}`,
want: `{"beforeEVMTransfers":[{"purpose":"feePayment","from":"0x000000000000000000000000000000000000FEeD","to":null,"value":"0x0"}],"afterEVMTransfers":[{"purpose":"gasRefund","from":null,"to":"0x000000000000000000000000000000000000FEeD","value":"0x0"},{"purpose":"tip","from":null,"to":"0x0000000000000000000000000000000000000000","value":"0x0"}],"from":"0x000000000000000000000000000000000000feed","gas":"0x13880","gasUsed":"0x5b9e","to":"0x00000000000000000000000000000000deadbeef","input":"0x","logs":[{"address":"0x00000000000000000000000000000000deadbeef","topics":[],"data":"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","position":"0x0"}],"value":"0x0","type":"CALL"}`,
},
{
// Leads to OOM on the prestate tracer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@
"topics": [
"0xe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda"
],
"data": "0x0000000000000000000000004f5777744b500616697cb655dcb02ee6cd51deb5be96016bb57376da7a6d296e0a405ee1501778227dfa604df0a81cb1ae018598"
"data": "0x0000000000000000000000004f5777744b500616697cb655dcb02ee6cd51deb5be96016bb57376da7a6d296e0a405ee1501778227dfa604df0a81cb1ae018598",
"position": "0x0"
},
{
"address": "0x200edd17f30485a8735878661960cd7a9a95733f",
"topics": [
"0xacbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000000"
"data": "0x0000000000000000000000000000000000000000000000000000000000000000",
"position": "0x0"
}
],
"value": "0x8ac7230489e80000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@
"0x0000000000000000000000003de712784baf97260455ae25fb74f574ec9c1add",
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5"
],
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
"position": "0x0"
}
],
"value": "0x0",
Expand All @@ -300,7 +301,8 @@
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd"
],
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
"position": "0x0"
}
],
"value": "0x0",
Expand Down Expand Up @@ -329,7 +331,8 @@
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd"
],
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
"position": "0x0"
}
],
"value": "0x0",
Expand All @@ -350,7 +353,8 @@
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd",
"0x000000000000000000000000950ca4a06c78934a148b7a3ff3ea8fc366f77a06"
],
"data": "0x0000000000000000000000000000000000000000000000000041f50e27d56848"
"data": "0x0000000000000000000000000000000000000000000000000041f50e27d56848",
"position": "0x0"
}
],
"value": "0x0",
Expand Down Expand Up @@ -413,7 +417,8 @@
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
"0x0000000000000000000000003de712784baf97260455ae25fb74f574ec9c1add"
],
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000"
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000",
"position": "0x0"
}
],
"type": "DELEGATECALL",
Expand Down
Loading

0 comments on commit c6b8994

Please sign in to comment.