Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: cmd: invert disableMemory #23558

Merged
merged 4 commits into from Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/evm/internal/t8ntool/flags.go
Expand Up @@ -30,17 +30,17 @@ var (
Name: "trace",
Usage: "Output full trace logs to files <txhash>.jsonl",
}
TraceDisableMemoryFlag = cli.BoolFlag{
Name: "trace.nomemory",
Usage: "Disable full memory dump in traces",
TraceEnableMemoryFlag = cli.BoolFlag{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can preserve this flag TraceDisableMemoryFlag but change the type as cli.TBoolFlag. So that the default value is True. I think we should keep the compatibility if possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this for all flags.

(but please keep the existing change to LogConfig)

Name: "trace.memory",
Usage: "Enable full memory dump in traces",
}
TraceDisableStackFlag = cli.BoolFlag{
Name: "trace.nostack",
Usage: "Disable stack output in traces",
}
TraceDisableReturnDataFlag = cli.BoolFlag{
Name: "trace.noreturndata",
Usage: "Disable return data output in traces",
TraceEnableReturnDataFlag = cli.BoolFlag{
Name: "trace.returndata",
Usage: "Enable return data output in traces",
}
OutputBasedir = cli.StringFlag{
Name: "output.basedir",
Expand Down
8 changes: 4 additions & 4 deletions cmd/evm/internal/t8ntool/transition.go
Expand Up @@ -107,10 +107,10 @@ func Main(ctx *cli.Context) error {
if ctx.Bool(TraceFlag.Name) {
// Configure the EVM logger
logConfig := &vm.LogConfig{
DisableStack: ctx.Bool(TraceDisableStackFlag.Name),
DisableMemory: ctx.Bool(TraceDisableMemoryFlag.Name),
DisableReturnData: ctx.Bool(TraceDisableReturnDataFlag.Name),
Debug: true,
DisableStack: ctx.Bool(TraceDisableStackFlag.Name),
EnableMemory: ctx.Bool(TraceEnableMemoryFlag.Name),
EnableReturnData: ctx.Bool(TraceEnableReturnDataFlag.Name),
Debug: true,
}
var prevFile *os.File
// This one closes the last file
Expand Down
20 changes: 10 additions & 10 deletions cmd/evm/main.go
Expand Up @@ -113,9 +113,9 @@ var (
Name: "receiver",
Usage: "The transaction receiver (execution context)",
}
DisableMemoryFlag = cli.BoolFlag{
Name: "nomemory",
Usage: "disable memory output",
EnableMemoryFlag = cli.BoolFlag{
Name: "memory",
Usage: "enable memory output",
}
DisableStackFlag = cli.BoolFlag{
Name: "nostack",
Expand All @@ -125,9 +125,9 @@ var (
Name: "nostorage",
Usage: "disable storage output",
}
DisableReturnDataFlag = cli.BoolFlag{
Name: "noreturndata",
Usage: "disable return data output",
EnableReturnDataFlag = cli.BoolFlag{
Name: "returndata",
Usage: "enable return data output",
}
)

Expand All @@ -138,9 +138,9 @@ var stateTransitionCommand = cli.Command{
Action: t8ntool.Main,
Flags: []cli.Flag{
t8ntool.TraceFlag,
t8ntool.TraceDisableMemoryFlag,
t8ntool.TraceEnableMemoryFlag,
t8ntool.TraceDisableStackFlag,
t8ntool.TraceDisableReturnDataFlag,
t8ntool.TraceEnableReturnDataFlag,
t8ntool.OutputBasedir,
t8ntool.OutputAllocFlag,
t8ntool.OutputResultFlag,
Expand Down Expand Up @@ -176,10 +176,10 @@ func init() {
MachineFlag,
SenderFlag,
ReceiverFlag,
DisableMemoryFlag,
EnableMemoryFlag,
DisableStackFlag,
DisableStorageFlag,
DisableReturnDataFlag,
EnableReturnDataFlag,
}
app.Commands = []cli.Command{
compileCommand,
Expand Down
10 changes: 5 additions & 5 deletions cmd/evm/runner.go
Expand Up @@ -108,11 +108,11 @@ func runCmd(ctx *cli.Context) error {
glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
log.Root().SetHandler(glogger)
logconfig := &vm.LogConfig{
DisableMemory: ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.GlobalBool(DisableStorageFlag.Name),
DisableReturnData: ctx.GlobalBool(DisableReturnDataFlag.Name),
Debug: ctx.GlobalBool(DebugFlag.Name),
EnableMemory: ctx.GlobalBool(EnableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.GlobalBool(DisableStorageFlag.Name),
EnableReturnData: ctx.GlobalBool(EnableReturnDataFlag.Name),
Debug: ctx.GlobalBool(DebugFlag.Name),
}

var (
Expand Down
8 changes: 4 additions & 4 deletions cmd/evm/staterunner.go
Expand Up @@ -59,10 +59,10 @@ func stateTestCmd(ctx *cli.Context) error {

// Configure the EVM logger
config := &vm.LogConfig{
DisableMemory: ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.GlobalBool(DisableStorageFlag.Name),
DisableReturnData: ctx.GlobalBool(DisableReturnDataFlag.Name),
EnableMemory: ctx.GlobalBool(EnableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.GlobalBool(DisableStorageFlag.Name),
EnableReturnData: ctx.GlobalBool(EnableReturnDataFlag.Name),
}
var (
tracer vm.Tracer
Expand Down
16 changes: 8 additions & 8 deletions core/vm/logger.go
Expand Up @@ -46,12 +46,12 @@ func (s Storage) Copy() Storage {

// LogConfig are the configuration options for structured logger the EVM
type LogConfig struct {
DisableMemory bool // disable memory capture
DisableStack bool // disable stack capture
DisableStorage bool // disable storage capture
DisableReturnData bool // disable return data capture
Debug bool // print output during capture end
Limit int // maximum length of output, but zero means unlimited
EnableMemory bool // disable memory capture
MariusVanDerWijden marked this conversation as resolved.
Show resolved Hide resolved
DisableStack bool // disable stack capture
DisableStorage bool // disable storage capture
EnableReturnData bool // disable return data capture
MariusVanDerWijden marked this conversation as resolved.
Show resolved Hide resolved
Debug bool // print output during capture end
Limit int // maximum length of output, but zero means unlimited
// Chain overrides, can be used to execute a trace using future fork rules
Overrides *params.ChainConfig `json:"overrides,omitempty"`
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost ui
}
// Copy a snapshot of the current memory state to a new buffer
var mem []byte
if !l.cfg.DisableMemory {
if l.cfg.EnableMemory {
mem = make([]byte, len(memory.Data()))
copy(mem, memory.Data())
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost ui
}
}
var rdata []byte
if !l.cfg.DisableReturnData {
if l.cfg.EnableReturnData {
rdata = make([]byte, len(rData))
copy(rdata, rData)
}
Expand Down
4 changes: 2 additions & 2 deletions core/vm/logger_json.go
Expand Up @@ -61,13 +61,13 @@ func (l *JSONLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint
RefundCounter: env.StateDB.GetRefund(),
Err: err,
}
if !l.cfg.DisableMemory {
if l.cfg.EnableMemory {
log.Memory = memory.Data()
}
if !l.cfg.DisableStack {
log.Stack = stack.data
}
if !l.cfg.DisableReturnData {
if l.cfg.EnableReturnData {
log.ReturnData = rData
}
l.encoder.Encode(log)
Expand Down
4 changes: 2 additions & 2 deletions eth/tracers/tracers_test.go
Expand Up @@ -353,8 +353,8 @@ func BenchmarkTransactionTrace(b *testing.B) {
tracer := vm.NewStructLogger(&vm.LogConfig{
Debug: false,
//DisableStorage: true,
//DisableMemory: true,
//DisableReturnData: true,
//EnableMemory: false,
//EnableReturnData: false,
})
evm := vm.NewEVM(context, txContext, statedb, params.AllEthashProtocolChanges, vm.Config{Debug: true, Tracer: tracer})
msg, err := tx.AsMessage(signer, nil)
Expand Down
2 changes: 1 addition & 1 deletion tests/state_test.go
Expand Up @@ -115,7 +115,7 @@ func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
}
buf := new(bytes.Buffer)
w := bufio.NewWriter(buf)
tracer := vm.NewJSONLogger(&vm.LogConfig{DisableMemory: true}, w)
tracer := vm.NewJSONLogger(&vm.LogConfig{EnableMemory: false}, w)
MariusVanDerWijden marked this conversation as resolved.
Show resolved Hide resolved
config.Debug, config.Tracer = true, tracer
err2 := test(config)
if !reflect.DeepEqual(err, err2) {
Expand Down