-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement opcode logger functionality #8241
base: 8174-add-new-opcodes-endpoint
Are you sure you want to change the base?
feat: Implement opcode logger functionality #8241
Conversation
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
…nto 8173-implement-opcode-logger-tracing-logic Need changes from other branch to debug
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Quality Gate failedFailed conditions |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8241 +/- ##
============================================
+ Coverage 92.28% 92.45% +0.17%
+ Complexity 7280 1270 -6010
============================================
Files 898 372 -526
Lines 29338 11455 -17883
Branches 3575 1549 -2026
============================================
- Hits 27075 10591 -16484
+ Misses 1446 699 -747
+ Partials 817 165 -652 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
…nto 8173-implement-opcode-logger-tracing-logic # Conflicts: # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/evm/contracts/execution/traceability/OpcodeTracer.java # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/ContractCallService.java # hedera-mirror-web3/src/main/java/com/hedera/node/app/service/evm/contracts/execution/HederaEvmTxProcessor.java # hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/evm/config/EvmConfiguration.java
Outdated
Show resolved
Hide resolved
hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/ContractCallService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
…nto 8173-implement-opcode-logger-tracing-logic # Conflicts: # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/ContractCallContext.java # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/controller/OpcodesController.java # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/ContractCallService.java # hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java
…lement-opcode-logger-tracing-logic # Conflicts: # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/ContractCallContext.java # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/controller/OpcodesController.java # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/ContractCallService.java # hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job 🔥! This has been a tough task!
I've left a few suggestions below:
.../src/main/java/com/hedera/mirror/web3/evm/contracts/execution/traceability/OpcodeTracer.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/hedera/mirror/web3/evm/contracts/execution/traceability/OpcodeTracer.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/hedera/mirror/web3/evm/contracts/execution/traceability/OpcodeTracer.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/hedera/mirror/web3/evm/contracts/execution/traceability/OpcodeTracer.java
Show resolved
Hide resolved
hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/ContractActionService.java
Outdated
Show resolved
Hide resolved
hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/ContractActionServiceImpl.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/hedera/node/app/service/evm/contracts/execution/HederaEvmTxProcessor.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/hedera/node/app/service/evm/contracts/execution/HederaEvmTxProcessor.java
Outdated
Show resolved
Hide resolved
hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/ContractCallContext.java
Outdated
Show resolved
Hide resolved
...ra-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/ContractActionRepository.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
…cing-logic' into 8173-implement-opcode-logger-tracing-logic
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
…lement-opcode-logger-tracing-logic # Conflicts: # hedera-mirror-common/src/main/java/com/hedera/mirror/common/domain/transaction/Opcode.java # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/controller/OpcodesController.java # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/ContractCallService.java # hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
…lement-opcode-logger-tracing-logic # Conflicts: # hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/controller/OpcodesController.java # hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
…Exception when transaction cannot be found Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
|
||
@Override | ||
public List<ContractAction> findFromTransaction(@NonNull @Valid TransactionIdOrHashParameter transactionIdOrHash) { | ||
Assert.isTrue(transactionIdOrHash.isValid(), "Invalid transactionIdOrHash"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the @Valid annotation doing this check automatically?
@@ -88,20 +97,9 @@ public String processCall(final CallServiceParameters params) { | |||
if (params.isEstimate()) { | |||
// eth_estimateGas initialization - historical timestamp is Optional.empty() | |||
ctx.initializeStackFrames(store.getStackedStateFrames()); | |||
result = estimateGas(params); | |||
result = estimateGas(params, ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner if we have a dedicated ContractCallDebugService, which would be dedicated only for all existing and future debug related RPC calls. The workflow there is different - we replay an already executed transaction, while in ContractCallService we simulate a hypothetical transaction. So both services would have different responsibilities and needs.
If some components seem to be common for both services, they can be extracted in a parent Service class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
Will do.
} else { | ||
BlockType block = params.getBlock(); | ||
// if we have historical call then set corresponding file record | ||
if (block != BlockType.LATEST) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of debug_traceTransaction
we won't have a defined block explicitly. We should find the record_file
corresponding to the timestamp for the transactionHash
that is sent as an input, so that the ContractCallContext
contains proper data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already done when constructing the call service parameters, and the block number is passed to the ContractCallService.
// if the call is historical | ||
ctx.initializeStackFrames(store.getStackedStateFrames()); | ||
final var ethCallTxnResult = doProcessCall(params, params.getGas(), true); | ||
final var ethCallTxnResult = callContract(params, TracerType.OPERATION, ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a symptom of why we should split the logic in 2 different services. We shouldn't use any tracing in the case of eth_call
, eth_estimateGas
, so that we don't make this operations more CPU and memory intensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but the other operation tracer was used previously as well, we haven’t introduced any changes to the other methods.
Previously, the MirrorOperationTracer
was injected directly into the processor and now we inject a Map<TracerType, HederaEvmTracer>
instead, and thats why we need to pass the tracer type here, in order to get the right tracer that we want to use.
If we don’t want to do any tracing in eth_call
and eth_estimateGas
, we can create a new TracerType.NONE
that’s used by default and doesn’t invoke any tracers when processing the call.
What’s your opinion here?
|
||
public enum TracerType { | ||
OPCODE, | ||
OPERATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For OPERATION
we use directly the json-rpc-relay
implementation, which utilises the /actions endpoint. The REST API in the web3 module should be used only for OPCODE
tracing. I think we should delete the OPERATION
type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Service | ||
@RequiredArgsConstructor | ||
public class EntityServiceImpl implements EntityService { | ||
private final EntityRepository entityRepository; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can directly use the EntityDatabaseAccessor
for the moment and delete this Service definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used in the StackedStateFrames
component, but could be used as a service layer abstraction over the EntityRepository
.
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
Description:
The main goal of this PR is to add new tracer (OpcodeTracer) in the web3 module, in order to support opcodeLogger for debugging purposes.
Main files added:
OpcodeTracer
- tracer class, which has methods for tracing contract calls and uses the message frame to get the executed opcodes and save themContractionActionService
- service that queries the DB for relevant contract actions, used in the OpcodeTracerEntityService
- service that finds an entity in the DB, used to find the evmAddress of an accountRelated issue(s):
Fixes #8173
Notes for reviewer: