Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: Inconsistent handling of failed EVM transactions #3158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

victor-yanev
Copy link
Contributor

Description:

This PR fixes the issue discussed in the comments of #3115

Related issue(s):

Fixes #3115

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@victor-yanev victor-yanev added bug Something isn't working P1 labels Oct 25, 2024
@victor-yanev victor-yanev added this to the 0.59.0 milestone Oct 25, 2024
@victor-yanev victor-yanev self-assigned this Oct 25, 2024
Copy link

sonarcloud bot commented Oct 25, 2024

Copy link

github-actions bot commented Oct 25, 2024

Test Results

 21 files  +  1  292 suites  +20   36m 59s ⏱️ + 3m 26s
601 tests ±  0  587 ✅  -   4  4 💤 ±0  10 ❌ +4 
845 runs  +104  831 ✅ +102  4 💤  - 2  10 ❌ +4 

For more details on these failures, see this check.

Results for commit 52fb0e1. ± Comparison against base commit 6442c98.

This pull request removes 2 and adds 2 tests. Note that renamed tests count towards both.
"before all" hook for "should associate to a token" ‑ RPC Server Acceptance Tests Acceptance tests @tokencreate HTS Precompile Token Create Acceptance Tests "before all" hook for "should associate to a token"
"before all" hook in "Debug API Test Suite" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests Debug API Test Suite "before all" hook in "Debug API Test Suite"
"before all" hook for "should execute "eth_getCode" for hts token" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode "before all" hook for "should execute "eth_getCode" for hts token"
"before each" hook for "should execute "eth_getStorageAt" request to get current state changes" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before each" hook for "should execute "eth_getStorageAt" request to get current state changes"

♻️ This comment has been updated with latest results.

@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
@hashgraph hashgraph deleted a comment from github-actions bot Oct 25, 2024
Copy link
Collaborator

@ebadiere ebadiere left a comment

Choose a reason for hiding this comment

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

LG.

Copy link
Collaborator

@natanasow natanasow left a comment

Choose a reason for hiding this comment

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

@@ -566,4 +566,66 @@ describe('@ethGetBlockByNumber using MirrorNode', async function () {
args,
);
});

it('eth_getBlockByNumber should skip transactions with wrong nonces when showDetails = false', async function () {
Copy link
Contributor

@acuarica acuarica Oct 25, 2024

Choose a reason for hiding this comment

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

Aren't these two test cases basically the same module showDetails=true|false? If that's the case, maybe it's worth to merge them into a single test case, something like

[false, true].forEach(showDetails => {
  it(`eth_getBlockByNumber should skip transactions with wrong nonces when showDetails = ${showDetails}`, async function () {
  });
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, that would simplify things a bit

@@ -2308,7 +2320,7 @@ export class EthImpl implements Eth {
}

transactionArray = this.populateSyntheticTransactions(showDetails, logs, transactionArray, requestDetails);
transactionArray = showDetails ? _.uniqBy(transactionArray, 'hash') : _.uniq(transactionArray);
transactionArray = showDetails ? transactionArray : _.uniq(transactionArray);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure showDetails should change the length of the array, it concerns only with returning either transaction hashes or the transaction objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, we never want to show duplicated transaction hashes in the response when showDetails is false, so that's why I left this one there just in case.

Filtering the WRONG_NONCE transactions should be sufficient to remove duplicate hashes, but I am not sure if this is the only pre-check where this scenario could happen, that's why I left it just in case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I agree with Luis here. The size should be the same regardless of showDetails.
I'm not sure why this logic exists, shouldn't they always be unique transactions based on hash?
Maybe something to follow up on, why should we ever have duplicates when showDetails is true?

@victor-yanev
Copy link
Contributor Author

LGTM, but we should consider adding an exception for this check as well https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/TransactionProcessor.java#L233 in a follow-up PR.

@natanasow Could you open a new issue for that, we could prioritize it in the next sprint. 😄

@natanasow
Copy link
Collaborator

LGTM, but we should consider adding an exception for this check as well https://github.com/hashgraph/hedera-services/blob/develop/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/TransactionProcessor.java#L233 in a follow-up PR.

@natanasow Could you open a new issue for that, we could prioritize it in the next sprint. 😄

Okay.

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.87%. Comparing base (6442c98) to head (52fb0e1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/relay/src/lib/eth.ts 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3158      +/-   ##
==========================================
- Coverage   83.19%   82.87%   -0.32%     
==========================================
  Files          66       69       +3     
  Lines        4254     4421     +167     
  Branches      829      870      +41     
==========================================
+ Hits         3539     3664     +125     
- Misses        472      508      +36     
- Partials      243      249       +6     
Flag Coverage Δ
config-service 98.14% <ø> (ø)
relay 85.38% <87.50%> (+0.02%) ⬆️
server 83.52% <ø> (ø)
ws-server 36.87% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/relay/src/lib/eth.ts 82.80% <87.50%> (+0.83%) ⬆️

... and 13 files with indirect coverage changes

ConfigService.get('TEST')
? constants.DEFAULT_FEE_HISTORY_MAX_RESULTS
: Number(ConfigService.get('FEE_HISTORY_MAX_RESULTS'));
const maxResults = ConfigService.get('TEST')
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: for a different PR this feels like something the ConfigService should handle internally.
Is that possible?

@@ -2308,7 +2320,7 @@ export class EthImpl implements Eth {
}

transactionArray = this.populateSyntheticTransactions(showDetails, logs, transactionArray, requestDetails);
transactionArray = showDetails ? _.uniqBy(transactionArray, 'hash') : _.uniq(transactionArray);
transactionArray = showDetails ? transactionArray : _.uniq(transactionArray);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I agree with Luis here. The size should be the same regardless of showDetails.
I'm not sure why this logic exists, shouldn't they always be unique transactions based on hash?
Maybe something to follow up on, why should we ever have duplicates when showDetails is true?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Handling of Failed EVM Transactions in JSON-RPC Relay
5 participants