mirror of https://github.com/hyperledger/besu
Extend OperationTracer with new methods (#5662)
* Extend OperationTracer with new methods, create
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Rename ExtendedOperationTracer to BlockAwareOperationTracer
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* fixed plugin api hash
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* added missing javadoc comments
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Update evm/src/main/java/org/hyperledger/besu/evm/tracing/OperationTracer.java
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Only update peer with the first and last block (#5659)
* only update peer with the first and last block
Signed-off-by: Stefan <stefan.pingel@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Put download links into CHANGELOG and do some clean up (#5660)
* put the download links for 23.4.4 into the CHANGELOG.md
* clean up CHANGELOG
Signed-off-by: Stefan <stefan.pingel@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Add --amend to docker manifest create to fix docker latest tag (#5661)
We need to replace previous release's latest tag. Might be broken due to a recent change in the docker command implementation
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Add Xlayered-tx-pool to the config log printout (#5665)
Unrelated: clarify epoch length in javadoc
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Add hooks to AbstractCreateOperation for library users (#5656)
Add hooks for a successful contract create, a failed contract create,
and an invalid contact create. Users of the library will be able to
customize create responses without having to replace core logic.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Test updates for cancun execution-spec-tests (#5670)
- support legacy V values (larger V value) and type 1+ (v is recId only)
- new fields
- shared transaction extraction
- rejection detection
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Upgrade BouncyCastle libraries (#5675)
Upgrade bouncy castle to v1.75. This involved a change in maven
coordinates for other modules.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Introduce transaction validator interface (phase 1) (#5673)
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Only validate `--miner-enabled` option for ethash networks (#5669)
* Modify the min-gas-price option validation
* Check for whether ethash is in use, either from genesis or network config, and use that for miner checks
* Add genesis configuration isPoa() convenience function
---------
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matt Whitehead <matthew1001@hotmail.com>
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Update tuweni2.4.2 (#5684)
* Revert "Revert "Update Tuweni to 2.4.1 (#5513)" (#5585)"
This reverts commit 6111e1bbc3
.
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* update Tuweni to 2.4.2
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
---------
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* Do not leak references to PendingTransactions (#5693)
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* remove v0 version of the database (#5698)
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* updated plugin api hash
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* spotless
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* updating plugin api hash
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* moved transcation interface to datatypes to use it in the OperationTracer.traceStartTransaction method
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
* fix import
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
---------
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Signed-off-by: Stefan <stefan.pingel@consensys.net>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matt Whitehead <matthew1001@hotmail.com>
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Stefan Pingel <16143240+pinges@users.noreply.github.com>
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Co-authored-by: Danno Ferrin <danno.ferrin@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Matt Whitehead <matthew1001@gmail.com>
Co-authored-by: Antoine Toulme <antoine@lunar-ocean.com>
Co-authored-by: matkt <karim.t2am@gmail.com>
pull/5710/head
parent
03ff688043
commit
1a087709ac
@ -0,0 +1,107 @@ |
|||||||
|
/* |
||||||
|
* Copyright Hyperledger Besu Contributors. |
||||||
|
* |
||||||
|
* 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.evm.tracing; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
import static org.mockito.ArgumentMatchers.any; |
||||||
|
import static org.mockito.ArgumentMatchers.anyInt; |
||||||
|
import static org.mockito.Mockito.when; |
||||||
|
|
||||||
|
import org.hyperledger.besu.evm.EVM; |
||||||
|
import org.hyperledger.besu.evm.account.EvmAccount; |
||||||
|
import org.hyperledger.besu.evm.account.MutableAccount; |
||||||
|
import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; |
||||||
|
import org.hyperledger.besu.evm.frame.MessageFrame; |
||||||
|
import org.hyperledger.besu.evm.gascalculator.GasCalculator; |
||||||
|
import org.hyperledger.besu.evm.processor.ContractCreationProcessor; |
||||||
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
import java.util.Optional; |
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes; |
||||||
|
import org.junit.jupiter.api.BeforeEach; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
import org.junit.jupiter.api.extension.ExtendWith; |
||||||
|
import org.mockito.Mock; |
||||||
|
import org.mockito.junit.jupiter.MockitoExtension; |
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class) |
||||||
|
class ExtendedOperationTracerTest { |
||||||
|
|
||||||
|
@Mock GasCalculator gasCalculator; |
||||||
|
@Mock EVM evm; |
||||||
|
@Mock MessageFrame frame; |
||||||
|
@Mock WorldUpdater worldUpdater; |
||||||
|
@Mock EvmAccount evmAccount; |
||||||
|
@Mock MutableAccount mutableAccount; |
||||||
|
|
||||||
|
@BeforeEach |
||||||
|
void setUp() { |
||||||
|
when(frame.getOutputData()).thenReturn(Bytes.EMPTY); |
||||||
|
when(gasCalculator.codeDepositGasCost(anyInt())).thenReturn(0L); |
||||||
|
when(frame.getRemainingGas()).thenReturn(1L); |
||||||
|
|
||||||
|
when(frame.getWorldUpdater()).thenReturn(worldUpdater); |
||||||
|
when(worldUpdater.getOrCreate(any())).thenReturn(evmAccount); |
||||||
|
when(evmAccount.getMutable()).thenReturn(mutableAccount); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
void shouldCallTraceAccountCreationResultIfIsExtendedTracing() { |
||||||
|
final ContractCreationProcessor contractCreationProcessor = |
||||||
|
new ContractCreationProcessor(gasCalculator, evm, false, Collections.emptyList(), 0); |
||||||
|
|
||||||
|
final ExtendedOperationTracer tracer = new ExtendedOperationTracer(); |
||||||
|
contractCreationProcessor.codeSuccess(frame, tracer); |
||||||
|
|
||||||
|
// traceAccountCreationResult has been called and values have been set
|
||||||
|
assertThat(tracer.frame).isNotNull(); |
||||||
|
assertThat(tracer.haltReason).isNotNull(); |
||||||
|
assertThat(tracer.haltReason).isEmpty(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
void shouldNotCallTraceAccountCreationResultIfIsNotExtendedTracing() { |
||||||
|
final ContractCreationProcessor contractCreationProcessor = |
||||||
|
new ContractCreationProcessor(gasCalculator, evm, false, Collections.emptyList(), 0); |
||||||
|
|
||||||
|
final DefaultOperationTracer tracer = new DefaultOperationTracer(); |
||||||
|
contractCreationProcessor.codeSuccess(frame, tracer); |
||||||
|
|
||||||
|
// traceAccountCreationResult has not been called and values are still null
|
||||||
|
assertThat(tracer.frame).isNull(); |
||||||
|
assertThat(tracer.haltReason).isNull(); |
||||||
|
} |
||||||
|
|
||||||
|
static class DefaultOperationTracer implements OperationTracer { |
||||||
|
public MessageFrame frame = null; |
||||||
|
public Optional<ExceptionalHaltReason> haltReason = null; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void traceAccountCreationResult( |
||||||
|
final MessageFrame frame, final Optional<ExceptionalHaltReason> haltReason) { |
||||||
|
this.frame = frame; |
||||||
|
this.haltReason = haltReason; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static class ExtendedOperationTracer extends DefaultOperationTracer { |
||||||
|
@Override |
||||||
|
public boolean isExtendedTracing() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
/* |
||||||
|
* Copyright Hyperledger Besu Contributors. |
||||||
|
* |
||||||
|
* 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.plugin.services.tracer; |
||||||
|
|
||||||
|
import org.hyperledger.besu.evm.tracing.OperationTracer; |
||||||
|
import org.hyperledger.besu.plugin.data.BlockBody; |
||||||
|
import org.hyperledger.besu.plugin.data.BlockHeader; |
||||||
|
|
||||||
|
/** |
||||||
|
* An extended operation tracer that can trace the start and end of a block. |
||||||
|
* |
||||||
|
* <p>In both methods, the block header and body are provided. |
||||||
|
*/ |
||||||
|
public interface BlockAwareOperationTracer extends OperationTracer { |
||||||
|
/** |
||||||
|
* Trace the start of a block. |
||||||
|
* |
||||||
|
* @param blockHeader the header of the block which is traced |
||||||
|
* @param blockBody the body of the block which is traced |
||||||
|
*/ |
||||||
|
default void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {} |
||||||
|
|
||||||
|
/** |
||||||
|
* Trace the end of a block. |
||||||
|
* |
||||||
|
* @param blockHeader the header of the block which is traced |
||||||
|
* @param blockBody the body of the block which is traced |
||||||
|
*/ |
||||||
|
default void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBody) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
default boolean isExtendedTracing() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue