-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: debug_traceTransaction default param #9788
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
Open
macfarla
wants to merge
8
commits into
hyperledger:main
Choose a base branch
from
macfarla:debug-trace-tx-empty-options
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8c21d15
added test to demonstrate the problem
macfarla e8f74ab
only override defaults when user explicitly provides a value
macfarla b31bf13
memory off by default
macfarla a522775
adjust tests; Changed TraceOptions.DEFAULT to override traceMemory=tr…
macfarla 9ef10b7
fix failing test
macfarla 81a0e4a
memory off by default
macfarla c0645c6
Merge branch 'main' of github.com:hyperledger/besu into debug-trace-t…
macfarla df49ac9
add nuance for tracecall tracer params
macfarla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TransactionTraceParamsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * Copyright contributors to Hyperledger Besu. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import org.hyperledger.besu.ethereum.debug.TraceOptions; | ||
| import org.hyperledger.besu.evm.tracing.OpCodeTracerConfigBuilder.OpCodeTracerConfig; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class TransactionTraceParamsTest { | ||
|
|
||
| private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
|
||
| @Test | ||
| public void emptyOptionsObjectShouldMatchDefaultTraceOptions() throws Exception { | ||
| // Passing {} should be equivalent to passing no options at all. | ||
| // All disable* fields default to false, so all tracing is enabled by default. | ||
| final OpCodeTracerConfig defaultConfig = TraceOptions.DEFAULT.opCodeTracerConfig(); | ||
|
|
||
| // Parse an empty JSON options object — simulates debug_traceTransaction(hash, {}) | ||
| final TransactionTraceParams emptyParams = MAPPER.readValue("{}", TransactionTraceParams.class); | ||
| final OpCodeTracerConfig emptyParamsConfig = emptyParams.traceOptions().opCodeTracerConfig(); | ||
|
|
||
| assertThat(emptyParamsConfig.traceMemory()) | ||
| .describedAs("traceMemory should match DEFAULT") | ||
| .isEqualTo(defaultConfig.traceMemory()); | ||
|
|
||
| assertThat(emptyParamsConfig.traceStorage()) | ||
| .describedAs("traceStorage should match DEFAULT") | ||
| .isEqualTo(defaultConfig.traceStorage()); | ||
|
|
||
| assertThat(emptyParamsConfig.traceStack()) | ||
| .describedAs("traceStack should match DEFAULT") | ||
| .isEqualTo(defaultConfig.traceStack()); | ||
| } | ||
|
|
||
| @Test | ||
| public void defaultsShouldMatchOpCodeTracerConfigDefaults() { | ||
| // TraceOptions.DEFAULT should use OpCodeTracerConfig.DEFAULT directly. | ||
| // Memory tracing is off by default for performance reasons. | ||
| final OpCodeTracerConfig defaultConfig = TraceOptions.DEFAULT.opCodeTracerConfig(); | ||
|
|
||
| assertThat(defaultConfig.traceStorage()).isTrue(); | ||
| assertThat(defaultConfig.traceMemory()).isFalse(); | ||
| assertThat(defaultConfig.traceStack()).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void nonOpcodeTracerShouldEnableMemoryByDefault() throws Exception { | ||
| // Non-opcode tracers (e.g. callTracer) need memory for internal operations | ||
| // such as extracting CREATE init code, so memory should be enabled by default | ||
| final TransactionTraceParams callTracerParams = | ||
| MAPPER.readValue("{\"tracer\": \"callTracer\"}", TransactionTraceParams.class); | ||
| final OpCodeTracerConfig config = callTracerParams.traceOptions().opCodeTracerConfig(); | ||
|
|
||
| assertThat(config.traceMemory()) | ||
| .describedAs("callTracer should have memory enabled by default") | ||
| .isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void nonOpcodeTracerShouldRespectExplicitDisableMemory() throws Exception { | ||
| // When user explicitly sets disableMemory, it should be respected even for callTracer | ||
| final TransactionTraceParams params = | ||
| MAPPER.readValue( | ||
| "{\"tracer\": \"callTracer\", \"disableMemory\": true}", TransactionTraceParams.class); | ||
| final OpCodeTracerConfig config = params.traceOptions().opCodeTracerConfig(); | ||
|
|
||
| assertThat(config.traceMemory()) | ||
| .describedAs("explicit disableMemory=true should be respected") | ||
| .isFalse(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I know this was like this before but this name
defaultTracerConfigcould be misleading. At this stage these option are not default anymore, they are a mix of user set params and defaults, so probably would just call ittracerConfig