diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java index b7456561aa..013813b602 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/RpcMethod.java @@ -114,6 +114,7 @@ public enum RpcMethod { PERM_REMOVE_NODES_FROM_WHITELIST("perm_removeNodesFromWhitelist"), RPC_MODULES("rpc_modules"), TRACE_REPLAY_BLOCK_TRANSACTIONS("trace_replayBlockTransactions"), + TRACE_BLOCK("trace_block"), TRACE_TRANSACTION("trace_transaction"), TX_POOL_BESU_STATISTICS("txpool_besuStatistics"), TX_POOL_BESU_TRANSACTIONS("txpool_besuTransactions"), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceBlock.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceBlock.java new file mode 100644 index 0000000000..068e5083b1 --- /dev/null +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceBlock.java @@ -0,0 +1,116 @@ +/* + * Copyright ConsenSys AG. + * + * 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.methods; + +import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTraceGenerator; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.RewardTraceGenerator; +import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; +import org.hyperledger.besu.ethereum.core.Block; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.debug.TraceOptions; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; + +import java.util.List; +import java.util.function.Supplier; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; + +public class TraceBlock extends AbstractBlockParameterMethod { + + private static final ObjectMapper MAPPER = new ObjectMapper(); + private final Supplier blockTracerSupplier; + private final ProtocolSchedule protocolSchedule; + + public TraceBlock( + final Supplier blockTracerSupplier, + final ProtocolSchedule protocolSchedule, + final BlockchainQueries queries) { + super(queries); + this.blockTracerSupplier = blockTracerSupplier; + this.protocolSchedule = protocolSchedule; + } + + @Override + public String getName() { + return RpcMethod.TRACE_BLOCK.getMethodName(); + } + + @Override + protected BlockParameter blockParameter(final JsonRpcRequestContext request) { + return request.getRequiredParameter(0, BlockParameter.class); + } + + @Override + protected Object resultByBlockNumber( + final JsonRpcRequestContext request, final long blockNumber) { + if (blockNumber == BlockHeader.GENESIS_BLOCK_NUMBER) { + // Nothing to trace for the genesis block + return emptyResult(); + } + + return getBlockchainQueries() + .getBlockchain() + .getBlockByNumber(blockNumber) + .map(this::traceBlock) + .orElse(null); + } + + private Object traceBlock(final Block block) { + + if (block == null) { + return emptyResult(); + } + final ArrayNode resultArrayNode = MAPPER.createArrayNode(); + + blockTracerSupplier + .get() + .trace(block, new DebugOperationTracer(TraceOptions.DEFAULT)) + .ifPresent( + blockTrace -> + generateTracesFromTransactionTraceAndBlock( + blockTrace.getTransactionTraces(), block, resultArrayNode)); + + generateRewardsFromBlock(block, resultArrayNode); + + return resultArrayNode; + } + + private void generateTracesFromTransactionTraceAndBlock( + final List transactionTraces, + final Block block, + final ArrayNode resultArrayNode) { + + transactionTraces.forEach( + transactionTrace -> + FlatTraceGenerator.generateFromTransactionTraceAndBlock(transactionTrace, block) + .forEachOrdered(resultArrayNode::addPOJO)); + } + + private void generateRewardsFromBlock(final Block block, final ArrayNode resultArrayNode) { + RewardTraceGenerator.generateFromBlock(protocolSchedule, block) + .forEachOrdered(resultArrayNode::addPOJO); + } + + private Object emptyResult() { + return MAPPER.createArrayNode(); + } +} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java index 0cd76f7ddb..07611f7019 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java @@ -20,8 +20,24 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionT import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(NON_NULL) +@JsonPropertyOrder({ + "creationMethod", + "callType", + "from", + "gas", + "input", + "to", + "init", + "author", + "rewardType", + "value", + "address", + "balance", + "refundAddress", +}) public class Action { private final String creationMethod; @@ -35,6 +51,8 @@ public class Action { private final String address; private final String balance; private final String refundAddress; + private final String author; + private final String rewardType; private Action( final String creationMethod, @@ -47,7 +65,9 @@ public class Action { final String value, final String address, final String balance, - final String refundAddress) { + final String refundAddress, + final String author, + final String rewardType) { this.creationMethod = creationMethod; this.callType = callType; this.from = from; @@ -59,6 +79,8 @@ public class Action { this.address = address; this.balance = balance; this.refundAddress = refundAddress; + this.author = author; + this.rewardType = rewardType; } public static Builder builder() { @@ -109,6 +131,14 @@ public class Action { return refundAddress; } + public String getAuthor() { + return author; + } + + public String getRewardType() { + return rewardType; + } + public static final class Builder { private String creationMethod; private String callType; @@ -121,6 +151,8 @@ public class Action { private String address; private String balance; private String refundAddress; + private String author; + private String rewardType; private Builder() {} @@ -137,6 +169,8 @@ public class Action { builder.address = action.address; builder.refundAddress = action.refundAddress; builder.balance = action.balance; + builder.author = action.author; + builder.rewardType = action.rewardType; return builder; } @@ -185,6 +219,16 @@ public class Action { return this; } + public Builder author(final String author) { + this.author = author; + return this; + } + + public Builder rewardType(final String rewardType) { + this.rewardType = rewardType; + return this; + } + public String getTo() { return to; } @@ -230,7 +274,9 @@ public class Action { value, address, balance, - refundAddress); + refundAddress, + author, + rewardType); } } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTrace.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTrace.java index cab45d1a1c..d040ed8015 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTrace.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTrace.java @@ -51,7 +51,7 @@ public class FlatTrace implements Trace { private final List traceAddress; private final String type; - private FlatTrace( + protected FlatTrace( final Action.Builder actionBuilder, final Result.Builder resultBuilder, final int subtraces, @@ -75,7 +75,7 @@ public class FlatTrace implements Trace { error); } - private FlatTrace( + protected FlatTrace( final Action action, final Result result, final int subtraces, @@ -205,7 +205,7 @@ public class FlatTrace implements Trace { } } - public static final class Builder { + public static class Builder { private Action.Builder actionBuilder; private Result.Builder resultBuilder; @@ -218,7 +218,7 @@ public class FlatTrace implements Trace { private Integer transactionPosition; private Optional error = Optional.empty(); - private Builder() {} + protected Builder() {} Builder resultBuilder(final Result.Builder resultBuilder) { this.resultBuilder = resultBuilder; @@ -230,10 +230,6 @@ public class FlatTrace implements Trace { return this; } - public int getSubtraces() { - return subtraces; - } - public Builder traceAddress(final List traceAddress) { this.traceAddress = traceAddress; return this; @@ -244,10 +240,6 @@ public class FlatTrace implements Trace { return this; } - public String getType() { - return type; - } - public Builder blockNumber(final Long blockNumber) { this.blockNumber = blockNumber; return this; @@ -273,6 +265,38 @@ public class FlatTrace implements Trace { return this; } + public String getType() { + return type; + } + + public int getSubtraces() { + return subtraces; + } + + public List getTraceAddress() { + return traceAddress; + } + + public Long getBlockNumber() { + return blockNumber; + } + + public String getBlockHash() { + return blockHash; + } + + public String getTransactionHash() { + return transactionHash; + } + + public Integer getTransactionPosition() { + return transactionPosition; + } + + public Optional getError() { + return error; + } + void incSubTraces() { this.subtraces++; } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTrace.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTrace.java new file mode 100644 index 0000000000..149020a442 --- /dev/null +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTrace.java @@ -0,0 +1,99 @@ +/* + * Copyright ConsenSys AG. + * + * 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.results.tracing.flat; + +import static com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS; + +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.annotation.JsonInclude; + +public class RewardTrace extends FlatTrace { + + protected RewardTrace( + final Action.Builder actionBuilder, + final Result.Builder resultBuilder, + final int subtraces, + final List traceAddress, + final String type, + final Long blockNumber, + final String blockHash, + final Integer transactionPosition, + final String transactionHash, + final Optional error) { + super( + actionBuilder, + resultBuilder, + subtraces, + traceAddress, + type, + blockNumber, + blockHash, + transactionPosition, + transactionHash, + error); + } + + /** + * We have to override the {@link FlatTrace} method because in the case of a reward the + * transactionHash value must be returned even if it is null + * + * @return transactionHash + */ + @Override + @JsonInclude(ALWAYS) + public String getTransactionHash() { + return super.getTransactionHash(); + } + + /** + * We have to override the {@link FlatTrace} method because in the case of a reward the + * transactionPosition value must be returned even if it is null + * + * @return transactionPosition + */ + @Override + @JsonInclude(ALWAYS) + public Integer getTransactionPosition() { + return super.getTransactionPosition(); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder extends FlatTrace.Builder { + + public Builder() { + super(); + } + + @Override + public RewardTrace build() { + return new RewardTrace( + getActionBuilder(), + getResultBuilder(), + getSubtraces(), + getTraceAddress(), + getType(), + getBlockNumber(), + getBlockHash(), + getTransactionPosition(), + getTransactionHash(), + getError()); + } + } +} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGenerator.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGenerator.java new file mode 100644 index 0000000000..154037202f --- /dev/null +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGenerator.java @@ -0,0 +1,101 @@ +/* + * Copyright ConsenSys AG. + * + * 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.results.tracing.flat; + +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.Trace; +import org.hyperledger.besu.ethereum.core.Block; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.Wei; +import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +public class RewardTraceGenerator { + + private static final String REWARD_LABEL = "reward"; + private static final String BLOCK_LABEL = "block"; + private static final String UNCLE_LABEL = "uncle"; + + /** + * Generates a stream of reward {@link Trace} from the passed {@link Block} data. + * + * @param protocolSchedule the {@link ProtocolSchedule} to use + * @param block the current {@link Block} to use + * @return a stream of generated reward traces {@link Trace} + */ + public static Stream generateFromBlock( + final ProtocolSchedule protocolSchedule, final Block block) { + + final List flatTraces = new ArrayList<>(); + + final BlockHeader blockHeader = block.getHeader(); + final List ommers = block.getBody().getOmmers(); + final ProtocolSpec protocolSpec = protocolSchedule.getByBlockNumber(blockHeader.getNumber()); + final Wei blockReward = protocolSpec.getBlockReward(); + final MiningBeneficiaryCalculator miningBeneficiaryCalculator = + protocolSpec.getMiningBeneficiaryCalculator(); + + final Wei coinbaseReward = + protocolSpec + .getBlockProcessor() + .getCoinbaseReward(blockReward, blockHeader.getNumber(), ommers.size()); + + // add uncle reward traces + ommers.forEach( + ommerBlockHeader -> { + final Wei ommerReward = + protocolSpec + .getBlockProcessor() + .getOmmerReward( + blockReward, blockHeader.getNumber(), ommerBlockHeader.getNumber()); + final Action.Builder uncleActionBuilder = + Action.builder() + .author( + miningBeneficiaryCalculator + .calculateBeneficiary(ommerBlockHeader) + .toHexString()) + .rewardType(UNCLE_LABEL) + .value(ommerReward.toShortHexString()); + flatTraces.add( + RewardTrace.builder() + .actionBuilder(uncleActionBuilder) + .blockHash(block.getHash().toHexString()) + .blockNumber(blockHeader.getNumber()) + .type(REWARD_LABEL) + .build()); + }); + + // add block reward trace + final Action.Builder blockActionBuilder = + Action.builder() + .author(miningBeneficiaryCalculator.calculateBeneficiary(blockHeader).toHexString()) + .rewardType(BLOCK_LABEL) + .value(coinbaseReward.toShortHexString()); + flatTraces.add( + 0, + RewardTrace.builder() + .actionBuilder(blockActionBuilder) + .blockHash(block.getHash().toHexString()) + .blockNumber(blockHeader.getNumber()) + .type(REWARD_LABEL) + .build()); + + return flatTraces.stream(); + } +} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java index c1880ade64..53711c6a88 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.methods; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApi; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.TraceBlock; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.TraceReplayBlockTransactions; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.TraceTransaction; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockReplay; @@ -52,6 +53,7 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods { blockchainQueries.getWorldStateArchive()); return mapOf( new TraceReplayBlockTransactions(() -> new BlockTracer(blockReplay), blockchainQueries), - new TraceTransaction(() -> new BlockTracer(blockReplay), blockchainQueries)); + new TraceTransaction(() -> new BlockTracer(blockReplay), blockchainQueries), + new TraceBlock(() -> new BlockTracer(blockReplay), protocolSchedule, blockchainQueries)); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java index 22e53263cf..f05ad71582 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java @@ -44,6 +44,7 @@ public class TraceJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { @Parameters(name = "{index}: {0}") public static Object[][] specs() { return AbstractJsonRpcHttpBySpecTest.findSpecFiles( + "trace/specs/trace-block", "trace/specs/trace-transaction", "trace/specs/replay-trace-transaction/flat", "trace/specs/replay-trace-transaction/vm-trace", diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java new file mode 100644 index 0000000000..ed43e578bb --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java @@ -0,0 +1,196 @@ +/* + * Copyright ConsenSys AG. + * + * 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.results.tracing.flat; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.Trace; +import org.hyperledger.besu.ethereum.core.Address; +import org.hyperledger.besu.ethereum.core.Block; +import org.hyperledger.besu.ethereum.core.BlockBody; +import org.hyperledger.besu.ethereum.core.BlockDataGenerator; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.Wei; +import org.hyperledger.besu.ethereum.mainnet.ClassicBlockProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor; +import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; +import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.apache.tuweni.bytes.Bytes; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class RewardTraceGeneratorTest { + + private final BlockDataGenerator gen = new BlockDataGenerator(); + + @Mock private ProtocolSchedule protocolSchedule; + @Mock private ProtocolSpec protocolSpec; + @Mock private MiningBeneficiaryCalculator miningBeneficiaryCalculator; + @Mock private TransactionProcessor transactionProcessor; + + private final Address ommerBeneficiary = + Address.wrap(Bytes.fromHexString("0x095e7baea6a6c7c4c2dfeb977efac326af552d87")); + private final Address blockBeneficiary = + Address.wrap(Bytes.fromHexString("0x095e7baea6a6c7c4c2dfeb977efac326af552d88")); + private final Wei blockReward = Wei.of(10000); + private final BlockHeader ommerHeader = gen.header(0x09); + + private Block block; + + @Before + public void setUp() { + final BlockBody blockBody = new BlockBody(Collections.emptyList(), List.of(ommerHeader)); + final BlockHeader blockHeader = + gen.header(0x0A, blockBody, new BlockDataGenerator.BlockOptions()); + block = new Block(blockHeader, blockBody); + when(protocolSchedule.getByBlockNumber(block.getHeader().getNumber())).thenReturn(protocolSpec); + when(protocolSpec.getBlockReward()).thenReturn(blockReward); + when(protocolSpec.getMiningBeneficiaryCalculator()).thenReturn(miningBeneficiaryCalculator); + when(miningBeneficiaryCalculator.calculateBeneficiary(block.getHeader())) + .thenReturn(blockBeneficiary); + when(miningBeneficiaryCalculator.calculateBeneficiary(ommerHeader)) + .thenReturn(ommerBeneficiary); + } + + @Test + public void assertThatTraceGeneratorReturnValidRewardsForMainnetBlockProcessor() { + final MainnetBlockProcessor.TransactionReceiptFactory transactionReceiptFactory = + mock(MainnetBlockProcessor.TransactionReceiptFactory.class); + final MainnetBlockProcessor blockProcessor = + new MainnetBlockProcessor( + transactionProcessor, + transactionReceiptFactory, + blockReward, + BlockHeader::getCoinbase, + true); + when(protocolSpec.getBlockProcessor()).thenReturn(blockProcessor); + + final Stream traceStream = + RewardTraceGenerator.generateFromBlock(protocolSchedule, block); + + final Action.Builder actionBlockReward = + Action.builder() + .rewardType("block") + .author(blockBeneficiary.toHexString()) + .value( + blockProcessor + .getCoinbaseReward(blockReward, block.getHeader().getNumber(), 1) + .toShortHexString()); + final Trace blocReward = + new RewardTrace.Builder() + .blockHash(block.getHash().toHexString()) + .blockNumber(block.getHeader().getNumber()) + .actionBuilder(actionBlockReward) + .type("reward") + .build(); + + // calculate reward with MainnetBlockProcessor + final Action.Builder actionOmmerReward = + Action.builder() + .rewardType("uncle") + .author(ommerBeneficiary.toHexString()) + .value( + blockProcessor + .getOmmerReward( + blockReward, block.getHeader().getNumber(), ommerHeader.getNumber()) + .toShortHexString()); + final Trace ommerReward = + new RewardTrace.Builder() + .blockHash(block.getHash().toHexString()) + .blockNumber(block.getHeader().getNumber()) + .actionBuilder(actionOmmerReward) + .type("reward") + .build(); + + final List traces = traceStream.collect(Collectors.toList()); + + // check block reward + assertThat(traces.get(0)).usingRecursiveComparison().isEqualTo(blocReward); + // check ommer reward + assertThat(traces.get(1)).usingRecursiveComparison().isEqualTo(ommerReward); + } + + @Test + public void assertThatTraceGeneratorReturnValidRewardsForClassicBlockProcessor() { + final ClassicBlockProcessor.TransactionReceiptFactory transactionReceiptFactory = + mock(ClassicBlockProcessor.TransactionReceiptFactory.class); + final ClassicBlockProcessor blockProcessor = + new ClassicBlockProcessor( + transactionProcessor, + transactionReceiptFactory, + blockReward, + BlockHeader::getCoinbase, + true); + when(protocolSpec.getBlockProcessor()).thenReturn(blockProcessor); + + final Stream traceStream = + RewardTraceGenerator.generateFromBlock(protocolSchedule, block); + + final Action.Builder actionBlockReward = + Action.builder() + .rewardType("block") + .author(blockBeneficiary.toHexString()) + .value( + blockProcessor + .getCoinbaseReward(blockReward, block.getHeader().getNumber(), 1) + .toShortHexString()); + final Trace blocReward = + new RewardTrace.Builder() + .blockHash(block.getHash().toHexString()) + .blockNumber(block.getHeader().getNumber()) + .actionBuilder(actionBlockReward) + .type("reward") + .build(); + + // calculate reward with ClassicBlockProcessor + final Action.Builder actionOmmerReward = + Action.builder() + .rewardType("uncle") + .author(ommerBeneficiary.toHexString()) + .value( + blockProcessor + .getOmmerReward( + blockReward, block.getHeader().getNumber(), ommerHeader.getNumber()) + .toShortHexString()); + final Trace ommerReward = + new RewardTrace.Builder() + .blockHash(block.getHash().toHexString()) + .blockNumber(block.getHeader().getNumber()) + .actionBuilder(actionOmmerReward) + .type("reward") + .build(); + + final List traces = traceStream.collect(Collectors.toList()); + + // check block reward + assertThat(traces.get(0)).usingRecursiveComparison().isEqualTo(blocReward); + // check ommer reward + assertThat(traces.get(1)).usingRecursiveComparison().isEqualTo(ommerReward); + } +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x0.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x0.json new file mode 100644 index 0000000000..265196b17e --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x0.json @@ -0,0 +1,16 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x0" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x1.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x1.json new file mode 100644 index 0000000000..38c7ecced1 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x1.json @@ -0,0 +1,32 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x1" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x0761d17e67d10a05a35febb73fd5b9a079df9f225611424e562d8bb29c838faf", + "blockNumber": 1, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x10.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x10.json new file mode 100644 index 0000000000..974a75e5f8 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x10.json @@ -0,0 +1,86 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x10" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x00c0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x1e28ec91e3f78da15344a480a1845db6bfeedaf1917aefbd94a60dc20f17f999", + "blockNumber": 16, + "error": "Bad instruction", + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x6aed559a5dcf73efa132d8182585c40fdc6ef3b99a7629d80ffd4a62cb3db622", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x00d0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x1e28ec91e3f78da15344a480a1845db6bfeedaf1917aefbd94a60dc20f17f999", + "blockNumber": 16, + "error": "Stack underflow", + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xb39fa8a1cb1db4663dc3733bc014d524e90a862bf2607e028eeb3932d92574fe", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x00e0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x1e28ec91e3f78da15344a480a1845db6bfeedaf1917aefbd94a60dc20f17f999", + "blockNumber": 16, + "error": "Bad jump destination", + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x11a725053a6ece79d8de11cb75dd1f09c40dcd109a1c63573e847ad4f456a296", + "transactionPosition": 2, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x1e28ec91e3f78da15344a480a1845db6bfeedaf1917aefbd94a60dc20f17f999", + "blockNumber": 16, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x11.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x11.json new file mode 100644 index 0000000000..bc1f03044b --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x11.json @@ -0,0 +1,53 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x11" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x00f0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x1a5856646dba994ce7e9482c72c054817b5db1da2db06113d2a810fe0fb4c0ff", + "blockNumber": 17, + "result": { + "gasUsed": "0xf", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x93d974a14c784be231a7b580a6476a330e5d6f9ddfef70a6b5cacd9f91a1e495", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x1a5856646dba994ce7e9482c72c054817b5db1da2db06113d2a810fe0fb4c0ff", + "blockNumber": 17, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x12.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x12.json new file mode 100644 index 0000000000..4a6522e4de --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x12.json @@ -0,0 +1,71 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x12" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0100000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x02b747255e0ea46a5768e23739be52822cd3744e87a229bb8cd1ae5f88b0c4e2", + "blockNumber": 18, + "result": { + "gasUsed": "0x1e", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x2a5079cc535c429f668f13a7fb9a28bdba6831b5462bd04f781777b332a8fcbd", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0110000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x02b747255e0ea46a5768e23739be52822cd3744e87a229bb8cd1ae5f88b0c4e2", + "blockNumber": 18, + "error": "Reverted", + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xc388baa0e55e6b73e850b22dc7e9853700f6b995fd55d95dd6ccd5a13d63c566", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x02b747255e0ea46a5768e23739be52822cd3744e87a229bb8cd1ae5f88b0c4e2", + "blockNumber": 18, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x13.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x13.json new file mode 100644 index 0000000000..c343a5078f --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x13.json @@ -0,0 +1,350 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x13" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "creationMethod": "create", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xff300e", + "init": "0x6004600c60003960046000f3600035ff", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "address": "0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f", + "code": "0x600035ff", + "gasUsed": "0x338" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x1309b6d2187aa8b0dfe78fcf0a96d4a3e861bfbc381959d253ede57624a37f9b", + "transactionPosition": 0, + "type": "create" + }, + { + "action": { + "creationMethod": "create", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xff2e26", + "init": "0x60006000600060006000738f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f5af1600060006000600060007300a00000000000000000000000000000000000005af1", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "address": "0x9fbda871d559710256a2502a2517b794b482db40", + "code": "0x", + "gasUsed": "0x1c39" + }, + "subtraces": 2, + "traceAddress": [], + "transactionHash": "0x6b9b967cfbeedeb7f0f4956b8103075ddfcea26c01d6d5dc3f9e2ed2ec9c42c0", + "transactionPosition": 1, + "type": "create" + }, + { + "action": { + "callType": "call", + "from": "0x9fbda871d559710256a2502a2517b794b482db40", + "gas": "0xfb2ea9", + "input": "0x", + "to": "0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "gasUsed": "0x138e", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [ + 0 + ], + "transactionHash": "0x6b9b967cfbeedeb7f0f4956b8103075ddfcea26c01d6d5dc3f9e2ed2ec9c42c0", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "address": "0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f", + "balance": "0x0", + "refundAddress": "0x0000000000000000000000000000000000000000" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": null, + "subtraces": 0, + "traceAddress": [ + 0, + 0 + ], + "transactionHash": "0x6b9b967cfbeedeb7f0f4956b8103075ddfcea26c01d6d5dc3f9e2ed2ec9c42c0", + "transactionPosition": 1, + "type": "suicide" + }, + { + "action": { + "callType": "call", + "from": "0x9fbda871d559710256a2502a2517b794b482db40", + "gas": "0xfb18a5", + "input": "0x", + "to": "0x00a0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "gasUsed": "0x30b", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 1 + ], + "transactionHash": "0x6b9b967cfbeedeb7f0f4956b8103075ddfcea26c01d6d5dc3f9e2ed2ec9c42c0", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "creationMethod": "create", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xff300e", + "init": "0x6004600c60003960046000f3600035ff", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "address": "0x2c2b9c9a4a25e24b174f26114e8926a9f2128fe4", + "code": "0x600035ff", + "gasUsed": "0x338" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xf12fd37f0836bd51f21bc15aa6bf5bea4b62fbbd39e1ee06725f91ac13ebc904", + "transactionPosition": 2, + "type": "create" + }, + { + "action": { + "creationMethod": "create", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xff2e26", + "init": "0x60006000600060006000732c2b9c9a4a25e24b174f26114e8926a9f2128fe45af2600060006000600060007300a00000000000000000000000000000000000005af2", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "address": "0x30753e4a8aad7f8597332e813735def5dd395028", + "code": "0x", + "gasUsed": "0x1c39" + }, + "subtraces": 2, + "traceAddress": [], + "transactionHash": "0x4c253746668dca6ac3f7b9bc18248b558a95b5fc881d140872c2dff984d344a7", + "transactionPosition": 3, + "type": "create" + }, + { + "action": { + "callType": "callcode", + "from": "0x30753e4a8aad7f8597332e813735def5dd395028", + "gas": "0xfb2ea9", + "input": "0x", + "to": "0x2c2b9c9a4a25e24b174f26114e8926a9f2128fe4", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "gasUsed": "0x138e", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [ + 0 + ], + "transactionHash": "0x4c253746668dca6ac3f7b9bc18248b558a95b5fc881d140872c2dff984d344a7", + "transactionPosition": 3, + "type": "call" + }, + { + "action": { + "address": "0x30753e4a8aad7f8597332e813735def5dd395028", + "balance": "0x0", + "refundAddress": "0x0000000000000000000000000000000000000000" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": null, + "subtraces": 0, + "traceAddress": [ + 0, + 0 + ], + "transactionHash": "0x4c253746668dca6ac3f7b9bc18248b558a95b5fc881d140872c2dff984d344a7", + "transactionPosition": 3, + "type": "suicide" + }, + { + "action": { + "callType": "callcode", + "from": "0x30753e4a8aad7f8597332e813735def5dd395028", + "gas": "0xfb18a5", + "input": "0x", + "to": "0x00a0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "gasUsed": "0x30b", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 1 + ], + "transactionHash": "0x4c253746668dca6ac3f7b9bc18248b558a95b5fc881d140872c2dff984d344a7", + "transactionPosition": 3, + "type": "call" + }, + { + "action": { + "creationMethod": "create", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xff300e", + "init": "0x6004600c60003960046000f3600035ff", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "address": "0xfb88de099e13c3ed21f80a7a1e49f8caecf10df6", + "code": "0x600035ff", + "gasUsed": "0x338" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x821ca63d171c5a3c60d32a738803092a52562056db3727a175f659cf49aae283", + "transactionPosition": 4, + "type": "create" + }, + { + "action": { + "creationMethod": "create", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xff2e4e", + "init": "0x600060006000600073fb88de099e13c3ed21f80a7a1e49f8caecf10df65af460006000600060007300a00000000000000000000000000000000000005af4", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "address": "0xaa588d3737b611bafd7bd713445b314bd453a5c8", + "code": "0x", + "gasUsed": "0x1c33" + }, + "subtraces": 2, + "traceAddress": [], + "transactionHash": "0xb795475e8f1820b683b60eb1a366bdc23e29f9cdf9639f7768c6644d20e3bbd1", + "transactionPosition": 5, + "type": "create" + }, + { + "action": { + "callType": "delegatecall", + "from": "0xaa588d3737b611bafd7bd713445b314bd453a5c8", + "gas": "0xfb2ed3", + "input": "0x", + "to": "0xfb88de099e13c3ed21f80a7a1e49f8caecf10df6", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "gasUsed": "0x138e", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [ + 0 + ], + "transactionHash": "0xb795475e8f1820b683b60eb1a366bdc23e29f9cdf9639f7768c6644d20e3bbd1", + "transactionPosition": 5, + "type": "call" + }, + { + "action": { + "address": "0xaa588d3737b611bafd7bd713445b314bd453a5c8", + "balance": "0x0", + "refundAddress": "0x0000000000000000000000000000000000000000" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": null, + "subtraces": 0, + "traceAddress": [ + 0, + 0 + ], + "transactionHash": "0xb795475e8f1820b683b60eb1a366bdc23e29f9cdf9639f7768c6644d20e3bbd1", + "transactionPosition": 5, + "type": "suicide" + }, + { + "action": { + "callType": "delegatecall", + "from": "0xaa588d3737b611bafd7bd713445b314bd453a5c8", + "gas": "0xfb18d2", + "input": "0x", + "to": "0x00a0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": { + "gasUsed": "0x30b", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 1 + ], + "transactionHash": "0xb795475e8f1820b683b60eb1a366bdc23e29f9cdf9639f7768c6644d20e3bbd1", + "transactionPosition": 5, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0xaa784964a04756483805fa30bef153bf5119044d886ec59039ac0349ee9a0f93", + "blockNumber": 19, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x14.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x14.json new file mode 100644 index 0000000000..8412c00dfb --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x14.json @@ -0,0 +1,120 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x14" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0130000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x0cb7eac77beedefce26f33030dfce377121133ba6869f83b1713dc3d8103e13a", + "blockNumber": 20, + "result": { + "gasUsed": "0x16c46", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0xd32c538fd1b3ef854c04ae39925dc9e849b568b92ea388f778b794851ab37f7c", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "creationMethod": "create", + "from": "0x0130000000000000000000000000000000000000", + "gas": "0xfb3412", + "init": "0x600160015560015460025561ffff6000526002601ef3", + "value": "0x0" + }, + "blockHash": "0x0cb7eac77beedefce26f33030dfce377121133ba6869f83b1713dc3d8103e13a", + "blockNumber": 20, + "result": { + "address": "0xaac0627078c038eb3d06e04b57d020fe212be97d", + "code": "0xffff", + "gasUsed": "0xa10e" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0xd32c538fd1b3ef854c04ae39925dc9e849b568b92ea388f778b794851ab37f7c", + "transactionPosition": 0, + "type": "create" + }, + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0140000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x0cb7eac77beedefce26f33030dfce377121133ba6869f83b1713dc3d8103e13a", + "blockNumber": 20, + "result": { + "gasUsed": "0x16b87", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0xaf151fc10eb21e76efb0bc74da179a674083e420280fb2985f76b0326682864a", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "creationMethod": "create2", + "from": "0x0140000000000000000000000000000000000000", + "gas": "0xfb3409", + "init": "0x600160015560015460025560ff60005360016000f3", + "value": "0x0" + }, + "blockHash": "0x0cb7eac77beedefce26f33030dfce377121133ba6869f83b1713dc3d8103e13a", + "blockNumber": 20, + "result": { + "address": "0x0deea5bd06fb86553643c1e94a2f5aac632b9ec9", + "code": "0xff", + "gasUsed": "0xa046" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0xaf151fc10eb21e76efb0bc74da179a674083e420280fb2985f76b0326682864a", + "transactionPosition": 1, + "type": "create" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x0cb7eac77beedefce26f33030dfce377121133ba6869f83b1713dc3d8103e13a", + "blockNumber": 20, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x15.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x15.json new file mode 100644 index 0000000000..1092fe0820 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x15.json @@ -0,0 +1,208 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x15" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab2e", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x9f59", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x7ab106c58a1c4d5c5f545f94ad266a945e3ed82835528fd3adbf7973d2c0c953", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xfba993", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x9c58", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x7ab106c58a1c4d5c5f545f94ad266a945e3ed82835528fd3adbf7973d2c0c953", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab2e", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x2a29", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x2b701e0b45e80f1c179a3696786aff2a411a51b03153528d1579f20915def5e4", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xfba993", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x2728", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x2b701e0b45e80f1c179a3696786aff2a411a51b03153528d1579f20915def5e4", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab3a", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x19c1", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0xcc81ab56669a97c5debfff3e23ab5ffb366f04c8c7eaf83f259c975c1816cb41", + "transactionPosition": 2, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xfba99f", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x16c0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0xcc81ab56669a97c5debfff3e23ab5ffb366f04c8c7eaf83f259c975c1816cb41", + "transactionPosition": 2, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab46", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x19c1", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x422edfe209e8b97f77a8e879db5182158f23e823ba7f59725d463d99d7ae66bd", + "transactionPosition": 3, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xfba9aa", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": { + "gasUsed": "0x16c0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x422edfe209e8b97f77a8e879db5182158f23e823ba7f59725d463d99d7ae66bd", + "transactionPosition": 3, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x58e4a5938ff28a9732602ffbf7bed5261a97f65cdcecb1b5e8bdff03bdc2dc42", + "blockNumber": 21, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x16.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x16.json new file mode 100644 index 0000000000..d34a2c1bd5 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x16.json @@ -0,0 +1,208 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x16" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab2e", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002", + "to": "0x0060000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x9f57", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x1f74ac428df5427f3a5576869e870cfff6712e4cffb1506bb4ef8f36c5e48162", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "delegatecall", + "from": "0x0060000000000000000000000000000000000000", + "gas": "0xfba995", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x9c58", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x1f74ac428df5427f3a5576869e870cfff6712e4cffb1506bb4ef8f36c5e48162", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab2e", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004", + "to": "0x0060000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x2a27", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x43d6ba1caeced03b6fa8cc3549c0557eea52917f1de50f4da23c9642beca95ee", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "callType": "delegatecall", + "from": "0x0060000000000000000000000000000000000000", + "gas": "0xfba995", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x2728", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x43d6ba1caeced03b6fa8cc3549c0557eea52917f1de50f4da23c9642beca95ee", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab3a", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0060000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x19bf", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x9eb50f31fc1d953e27331cd923f6b2f7fa11827d399c70aec00a04cf98cfd2ac", + "transactionPosition": 2, + "type": "call" + }, + { + "action": { + "callType": "delegatecall", + "from": "0x0060000000000000000000000000000000000000", + "gas": "0xfba9a0", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x16c0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x9eb50f31fc1d953e27331cd923f6b2f7fa11827d399c70aec00a04cf98cfd2ac", + "transactionPosition": 2, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffab46", + "input": "0x00000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0060000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x19bf", + "output": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0xe2ef09a0b71f50947bd0bd1cacac77903d2a5fce80f34862bd4559727e0f608c", + "transactionPosition": 3, + "type": "call" + }, + { + "action": { + "callType": "delegatecall", + "from": "0x0060000000000000000000000000000000000000", + "gas": "0xfba9ac", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": { + "gasUsed": "0x16c0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0xe2ef09a0b71f50947bd0bd1cacac77903d2a5fce80f34862bd4559727e0f608c", + "transactionPosition": 3, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x7acf18339aa8181c12a2e589d42e5fe65be08acc6a695ea9a0ddebd0d22a146d", + "blockNumber": 22, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x2.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x2.json new file mode 100644 index 0000000000..4d1b35795d --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x2.json @@ -0,0 +1,53 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x2" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffadea", + "input": "0x", + "to": "0x0000000000000000000000000000000000000999", + "value": "0x1" + }, + "blockHash": "0x4388532b2494aa5af1ebbc4208dc7d4c3c0a13d55929c0d994793f4ba82f4e9f", + "blockNumber": 2, + "result": { + "gasUsed": "0x0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x28fa8042c7b5835f4f91fc20937f3e70dcf3585c1afe31202bb6075185f9abfe", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x4388532b2494aa5af1ebbc4208dc7d4c3c0a13d55929c0d994793f4ba82f4e9f", + "blockNumber": 2, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x3.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x3.json new file mode 100644 index 0000000000..3cebc8059d --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x3.json @@ -0,0 +1,53 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x3" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "creationMethod": "create", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xff300e", + "init": "0x6004600c60003960046000f3600035ff", + "value": "0x0" + }, + "blockHash": "0x40783d74f3f4680c23003b1dc9a14d7e178b28fdcc2082085047b20c4c40cae9", + "blockNumber": 3, + "result": { + "address": "0xf12b5dd4ead5f743c6baa640b0216200e89b60da", + "code": "0x600035ff", + "gasUsed": "0x338" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x8d5477f0aae852c3e9487b0f8e7b9ecf9ccdf23d7934d4b4b7eff40c271031e5", + "transactionPosition": 0, + "type": "create" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x40783d74f3f4680c23003b1dc9a14d7e178b28fdcc2082085047b20c4c40cae9", + "blockNumber": 3, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x4.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x4.json new file mode 100644 index 0000000000..3a5fd637bd --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x4.json @@ -0,0 +1,95 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x4" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffabba", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x269b3f43a3ad6c6955a249c13f7879b6aaf95e18bd58e3d9c70eb473f938334b", + "blockNumber": 4, + "result": { + "gasUsed": "0x9c58", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x4de634fe767d1f6d0512ca0c9c0a054d3a2596f7cdd7c1eea5f93046a740b3c7", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffabba", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x269b3f43a3ad6c6955a249c13f7879b6aaf95e18bd58e3d9c70eb473f938334b", + "blockNumber": 4, + "result": { + "gasUsed": "0x2728", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xf882ec206292910527fd7095e59a1ca027b873296f1eba3886aa1addc4ff0ab9", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x627306090abab3a6e1400e9345bc60c78a8bef57", + "gas": "0xffabc6", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x269b3f43a3ad6c6955a249c13f7879b6aaf95e18bd58e3d9c70eb473f938334b", + "blockNumber": 4, + "result": { + "gasUsed": "0x16c0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x7ca6bf869e8882216f7443accb8d642df41af5bfa3a0e63bf03be2cfe629a030", + "transactionPosition": 2, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x269b3f43a3ad6c6955a249c13f7879b6aaf95e18bd58e3d9c70eb473f938334b", + "blockNumber": 4, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x5.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x5.json new file mode 100644 index 0000000000..1ce1499be3 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x5.json @@ -0,0 +1,53 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x5" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffabd2", + "input": "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000", + "to": "0x0010000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x3802c63f4f89ae8db95c4c19a196a6dabaf95143779045c248c5fd8bb8a009cf", + "blockNumber": 5, + "result": { + "gasUsed": "0x16c0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xdb2cd5e93dedae66371fc4a95452c746e11f7d2097464707597b8807c889ef5b", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x3802c63f4f89ae8db95c4c19a196a6dabaf95143779045c248c5fd8bb8a009cf", + "blockNumber": 5, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x6.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x6.json new file mode 100644 index 0000000000..b6aa915654 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x6.json @@ -0,0 +1,70 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x6" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffad82", + "input": "0x0000000000000000000000000000000000000999", + "to": "0x0020000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x71b149e2f81386fa7dbc0a636e94d9fb6f101c91cf5a8078f3a4ae74b686696f", + "blockNumber": 6, + "result": { + "gasUsed": "0x7536", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x91eeabc671e2dd2b1c8ddebb46ba59e8cb3e7d189f80bcc868a9787728c6e59e", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "address": "0x0020000000000000000000000000000000000000", + "balance": "0x300", + "refundAddress": "0x0000000000000999000000000000000000000000" + }, + "blockHash": "0x71b149e2f81386fa7dbc0a636e94d9fb6f101c91cf5a8078f3a4ae74b686696f", + "blockNumber": 6, + "result": null, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x91eeabc671e2dd2b1c8ddebb46ba59e8cb3e7d189f80bcc868a9787728c6e59e", + "transactionPosition": 0, + "type": "suicide" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x71b149e2f81386fa7dbc0a636e94d9fb6f101c91cf5a8078f3a4ae74b686696f", + "blockNumber": 6, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x7.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x7.json new file mode 100644 index 0000000000..2eb5fc4f14 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x7.json @@ -0,0 +1,53 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x7" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffad52", + "input": "0xf000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0030000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x23d0e40a97f475813f17a1998af71805faf7ecd1ca640d5cd0852e346f809c7a", + "blockNumber": 7, + "result": { + "gasUsed": "0x1b", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x47f4d445ea1812cb1ddd3464ab23d2bfc6ed408a8a9db1c497f94e8e06e85286", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x23d0e40a97f475813f17a1998af71805faf7ecd1ca640d5cd0852e346f809c7a", + "blockNumber": 7, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x8.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x8.json new file mode 100644 index 0000000000..64fd910912 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x8.json @@ -0,0 +1,76 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x8" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffacc6", + "input": "0x0000000000000000000000000030000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x1988c04a64a98a4e0d8a84dfe9f375200b051b1a02985a209eaed4258adde310", + "blockNumber": 8, + "result": { + "gasUsed": "0x30a", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0xa29f9d6a4f183f4c22c4857544a9a6b69c48d7bb8a97652be06e50bb69470666", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xfbab36", + "input": "0xf000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0030000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x1988c04a64a98a4e0d8a84dfe9f375200b051b1a02985a209eaed4258adde310", + "blockNumber": 8, + "result": { + "gasUsed": "0x1b", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0xa29f9d6a4f183f4c22c4857544a9a6b69c48d7bb8a97652be06e50bb69470666", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x1988c04a64a98a4e0d8a84dfe9f375200b051b1a02985a209eaed4258adde310", + "blockNumber": 8, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x9.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x9.json new file mode 100644 index 0000000000..eda6f73aec --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0x9.json @@ -0,0 +1,125 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0x9" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffabae", + "input": "0x000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x90d7d16f175e0fc78c561dd02238f235c0d3c345580670386114f1ecfeef70a9", + "blockNumber": 9, + "result": { + "gasUsed": "0x8fa", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x4af0ef28fbfcbdee7cc5925797c1b9030b3848c2f63f92737c3fe76b45582af5", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xfbaa17", + "input": "0x00000000000000000000000000400000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x90d7d16f175e0fc78c561dd02238f235c0d3c345580670386114f1ecfeef70a9", + "blockNumber": 9, + "result": { + "gasUsed": "0x5ff", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 1, + "traceAddress": [ + 0 + ], + "transactionHash": "0x4af0ef28fbfcbdee7cc5925797c1b9030b3848c2f63f92737c3fe76b45582af5", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xf7b88c", + "input": "0x0000000000000000000000000030000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0040000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x90d7d16f175e0fc78c561dd02238f235c0d3c345580670386114f1ecfeef70a9", + "blockNumber": 9, + "result": { + "gasUsed": "0x30a", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 1, + "traceAddress": [ + 0, + 0 + ], + "transactionHash": "0x4af0ef28fbfcbdee7cc5925797c1b9030b3848c2f63f92737c3fe76b45582af5", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0x0040000000000000000000000000000000000000", + "gas": "0xf3d6cd", + "input": "0xf000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0030000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x90d7d16f175e0fc78c561dd02238f235c0d3c345580670386114f1ecfeef70a9", + "blockNumber": 9, + "result": { + "gasUsed": "0x1b", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 0, + "traceAddress": [ + 0, + 0, + 0 + ], + "transactionHash": "0x4af0ef28fbfcbdee7cc5925797c1b9030b3848c2f63f92737c3fe76b45582af5", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x90d7d16f175e0fc78c561dd02238f235c0d3c345580670386114f1ecfeef70a9", + "blockNumber": 9, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xA.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xA.json new file mode 100644 index 0000000000..87ec9307fd --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xA.json @@ -0,0 +1,76 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0xA" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffacc6", + "input": "0x0000000000000000000000000030000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0050000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7ac846d481de9605cb99a95ab4c45d1964065303f901276955b450562845274f", + "blockNumber": 10, + "result": { + "gasUsed": "0x30a", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x4ec95b7de430b61fc9a57ed35274fd766b7f5fac5213ab946963eb528deae6b5", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "callcode", + "from": "0x0050000000000000000000000000000000000000", + "gas": "0xfbab36", + "input": "0xf000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0030000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x7ac846d481de9605cb99a95ab4c45d1964065303f901276955b450562845274f", + "blockNumber": 10, + "result": { + "gasUsed": "0x1b", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x4ec95b7de430b61fc9a57ed35274fd766b7f5fac5213ab946963eb528deae6b5", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x7ac846d481de9605cb99a95ab4c45d1964065303f901276955b450562845274f", + "blockNumber": 10, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xB.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xB.json new file mode 100644 index 0000000000..501dd30704 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xB.json @@ -0,0 +1,76 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0xB" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffacc6", + "input": "0x0000000000000000000000000030000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0060000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x57daa2146d6b41a07cdb087d88f597ace8b54a636625634b61c790eb5b67bc3b", + "blockNumber": 11, + "result": { + "gasUsed": "0x308", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 1, + "traceAddress": [], + "transactionHash": "0x6f77512ee9d43474a884c0703c86712fb98dca772fa6e12252786e3e23f196c1", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "delegatecall", + "from": "0x0060000000000000000000000000000000000000", + "gas": "0xfbab38", + "input": "0xf000000000000000000000000000000000000000000000000000000000000001", + "to": "0x0030000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x57daa2146d6b41a07cdb087d88f597ace8b54a636625634b61c790eb5b67bc3b", + "blockNumber": 11, + "result": { + "gasUsed": "0x1b", + "output": "0xf000000000000000000000000000000000000000000000000000000000000002" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "transactionHash": "0x6f77512ee9d43474a884c0703c86712fb98dca772fa6e12252786e3e23f196c1", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x57daa2146d6b41a07cdb087d88f597ace8b54a636625634b61c790eb5b67bc3b", + "blockNumber": 11, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xC.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xC.json new file mode 100644 index 0000000000..d6c6815169 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xC.json @@ -0,0 +1,53 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0xC" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0070000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x2986eeeb3f222cddd217ad7b6fc02b92d8dee63f33ad7bd7a4b664c822ddd9a6", + "blockNumber": 12, + "result": { + "gasUsed": "0x1e", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x12e4a98e63825852a69d7702202a3b593e4059ec913c479443665d590da18724", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x2986eeeb3f222cddd217ad7b6fc02b92d8dee63f33ad7bd7a4b664c822ddd9a6", + "blockNumber": 12, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xD.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xD.json new file mode 100644 index 0000000000..91bbc1c5fb --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xD.json @@ -0,0 +1,50 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0xD" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0080000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x6da2dc77f2f37923c7e418be8fcb76bafc3e71cf00341137eeee895bff17f399", + "blockNumber": 13, + "error": "Out of gas", + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x547c7e2fcdf9f88b03b4f4184d667d6768c669f279785774d0cf42435cab06f1", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x6da2dc77f2f37923c7e418be8fcb76bafc3e71cf00341137eeee895bff17f399", + "blockNumber": 13, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xE.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xE.json new file mode 100644 index 0000000000..be26b476e9 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xE.json @@ -0,0 +1,95 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0xE" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0090000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x29d84439ffa2c31026f05aa2e813a08784b4ecfcd0d22e9ec9448db3d759c381", + "blockNumber": 14, + "result": { + "gasUsed": "0x515e", + "output": "0x01" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xe3ebc73c55176c3f2e72b289f8a9cefbcd5b25dcd205db5661f81b0bb974fa73", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0090000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x29d84439ffa2c31026f05aa2e813a08784b4ecfcd0d22e9ec9448db3d759c381", + "blockNumber": 14, + "result": { + "gasUsed": "0x16c6", + "output": "0x02" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xb4dc55ca4a7c1f72402860c594efaa7da32035003f8e203b7f6a3cf1826685a5", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x0090000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x29d84439ffa2c31026f05aa2e813a08784b4ecfcd0d22e9ec9448db3d759c381", + "blockNumber": 14, + "result": { + "gasUsed": "0x16c6", + "output": "0x03" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x1a9f6256886437cfa21ee7685dd7a996024bea4d4bf6554b14787a6c9e5b90e6", + "transactionPosition": 2, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x29d84439ffa2c31026f05aa2e813a08784b4ecfcd0d22e9ec9448db3d759c381", + "blockNumber": 14, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xF.json b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xF.json new file mode 100644 index 0000000000..02d5cd9b86 --- /dev/null +++ b/ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/trace/specs/trace-block/trace_block_0xF.json @@ -0,0 +1,74 @@ +{ + "request": { + "jsonrpc": "2.0", + "method": "trace_block", + "params": [ + "0xF" + ], + "id": 415 + }, + "response": { + "jsonrpc": "2.0", + "result": [ + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x00a0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x16da147a8a4763f06bcd16fa2ec19ab2706bf2933758efb2ecaac444f2ddfa5a", + "blockNumber": 15, + "result": { + "gasUsed": "0x30b", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0x293cefc718137a74d36a5da204e3617604a9e8dfc79b6a6efb11056b3efd3b4a", + "transactionPosition": 0, + "type": "call" + }, + { + "action": { + "callType": "call", + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "gas": "0xffadea", + "input": "0x", + "to": "0x00b0000000000000000000000000000000000000", + "value": "0x0" + }, + "blockHash": "0x16da147a8a4763f06bcd16fa2ec19ab2706bf2933758efb2ecaac444f2ddfa5a", + "blockNumber": 15, + "result": { + "gasUsed": "0x485", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [], + "transactionHash": "0xb19370be2ace59794ee9bb5a69db98464cd6cb0b02b9afb3b978c9aad2bf5417", + "transactionPosition": 1, + "type": "call" + }, + { + "action": { + "author": "0x0000000000000000000000000000000000000000", + "rewardType": "block", + "value": "0x1bc16d674ec80000" + }, + "blockHash": "0x16da147a8a4763f06bcd16fa2ec19ab2706bf2933758efb2ecaac444f2ddfa5a", + "blockNumber": 15, + "result": null, + "subtraces": 0, + "traceAddress": [], + "transactionHash": null, + "transactionPosition": null, + "type": "reward" + } + ], + "id": 415 + }, + "statusCode": 200 +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockProcessor.java index 90b58ecae6..81bdcc0101 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockProcessor.java @@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; +import org.hyperledger.besu.ethereum.core.Wei; import java.util.List; @@ -80,4 +81,31 @@ public interface BlockProcessor { BlockHeader blockHeader, List transactions, List ommers); + + /** + * Get ommer reward in ${@link Wei} + * + * @param blockReward reward of the block + * @param blockNumber number of the block + * @param ommerBlockNumber number of the block ommer + * @return ommer reward + */ + default Wei getOmmerReward( + final Wei blockReward, final long blockNumber, final long ommerBlockNumber) { + final long distance = blockNumber - ommerBlockNumber; + return blockReward.subtract(blockReward.multiply(distance).divide(8)); + } + + /** + * Get coinbase reward in ${@link Wei} + * + * @param blockReward reward of the block + * @param blockNumber number of the block + * @param numberOfOmmers number of ommers for this block + * @return coinbase reward + */ + default Wei getCoinbaseReward( + final Wei blockReward, final long blockNumber, final int numberOfOmmers) { + return blockReward.add(blockReward.multiply(numberOfOmmers).divide(32)); + } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java index 42ff45e212..2aa6b8b968 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java @@ -56,9 +56,7 @@ public class ClassicBlockProcessor extends AbstractBlockProcessor { if (skipZeroBlockRewards && blockReward.isZero()) { return true; } - final int blockEra = getBlockEra(header.getNumber(), ERA_LENGTH); - final Wei winnerReward = getBlockWinnerRewardByEra(blockEra); - final Wei coinbaseReward = winnerReward.plus(winnerReward.multiply(ommers.size()).divide(32)); + final Wei coinbaseReward = getCoinbaseReward(blockReward, header.getNumber(), ommers.size()); final WorldUpdater updater = worldState.updater(); final MutableAccount coinbase = updater.getOrCreate(header.getCoinbase()).getMutable(); @@ -75,8 +73,8 @@ public class ClassicBlockProcessor extends AbstractBlockProcessor { final MutableAccount ommerCoinbase = updater.getOrCreate(ommerHeader.getCoinbase()).getMutable(); - final long distance = header.getNumber() - ommerHeader.getNumber(); - final Wei ommerReward = calculateOmmerReward(blockEra, distance); + final Wei ommerReward = + getOmmerReward(blockReward, header.getNumber(), ommerHeader.getNumber()); ommerCoinbase.incrementBalance(ommerReward); } @@ -132,4 +130,20 @@ public class ClassicBlockProcessor extends AbstractBlockProcessor { r = r.divide(d); return Wei.of(r); } + + @Override + public Wei getOmmerReward( + final Wei blockReward, final long blockNumber, final long ommerBlockNumber) { + final int blockEra = getBlockEra(blockNumber, ERA_LENGTH); + final long distance = blockNumber - ommerBlockNumber; + return calculateOmmerReward(blockEra, distance); + } + + @Override + public Wei getCoinbaseReward( + final Wei blockReward, final long blockNumber, final int ommersSize) { + final int blockEra = getBlockEra(blockNumber, ERA_LENGTH); + final Wei winnerReward = getBlockWinnerRewardByEra(blockEra); + return winnerReward.plus(winnerReward.multiply(ommersSize).divide(32)); + } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java index 44fb0d7acf..76d3c0df3e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java @@ -54,7 +54,7 @@ public class MainnetBlockProcessor extends AbstractBlockProcessor { return true; } - final Wei coinbaseReward = blockReward.add(blockReward.multiply(ommers.size()).divide(32)); + final Wei coinbaseReward = getCoinbaseReward(blockReward, header.getNumber(), ommers.size()); final WorldUpdater updater = worldState.updater(); final MutableAccount coinbase = updater.getOrCreate(header.getCoinbase()).getMutable(); @@ -71,8 +71,8 @@ public class MainnetBlockProcessor extends AbstractBlockProcessor { final MutableAccount ommerCoinbase = updater.getOrCreate(ommerHeader.getCoinbase()).getMutable(); - final long distance = header.getNumber() - ommerHeader.getNumber(); - final Wei ommerReward = blockReward.subtract(blockReward.multiply(distance).divide(8)); + final Wei ommerReward = + getOmmerReward(blockReward, header.getNumber(), ommerHeader.getNumber()); ommerCoinbase.incrementBalance(ommerReward); }