hashgraph / hedera-mirror-node

Hedera Mirror Node archives data from consensus nodes and serves it via an API
Apache License 2.0
147 stars 112 forks source link

Fix error on calls with value with not existing sender alias #9302

Closed kselveliev closed 2 months ago

kselveliev commented 2 months ago

Description: This PR aims to fix null error when a contract call is made with value and evm address as a sender. Where the evm address is not existing.

Couple of scenarios:

Currently when an empty from is passed. We are creating an Account.getDummySenderAccount(). that does not have alias

If the from is a not existing long zero address We are creating an Account.getDummySenderAccount(long zero address) from it without alias.

In the cases where evm address alias was passed as a from parameter. We were still creating a dummy account without alias. And subsequent account retrievals by alias were returning null causing the error since we did not create the account with that alias.

This pr adds a check. Check if the from is an evm canonical address. Create the dummy account with that alias. Otherwise create the dummy account as before without alias.

This PR modifies: MirrorEvmTxProcessorImpl - add a check to see is the from address is not existing and also a canonical evm address and it it is creates the dummy account with that alias.

Account.java - created new methods that creates dummy account with and alias

MirrorEvmTxProcessorTest - adds a test case for the error scenario.

ContractCallServiceTest - adds a test case for the error scenario.

Related issue(s):

Fixes #9301

Notes for reviewer:

Checklist

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.

Project coverage is 92.51%. Comparing base (d2f7848) to head (05a3106). Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
...java/com/hedera/services/store/models/Account.java 87.50% 1 Missing and 1 partial :warning:
.../contracts/execution/MirrorEvmTxProcessorImpl.java 80.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #9302 +/- ## ============================================ - Coverage 92.62% 92.51% -0.11% - Complexity 6908 7017 +109 ============================================ Files 885 903 +18 Lines 29382 29647 +265 Branches 3716 3739 +23 ============================================ + Hits 27216 27429 +213 - Misses 1402 1449 +47 - Partials 764 769 +5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud