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: resolved evm addresses for from and to addresses in returned transactions #2185

Merged
merged 7 commits into from
Mar 12, 2024

Conversation

quiet-node
Copy link
Collaborator

@quiet-node quiet-node commented Mar 11, 2024

Description:

  • resolved long zero addresses to EVM addresses for the following RPC endpoints:

    • eth_getTransactionByBlockHashAndIndex
    • eth_getTransactionByBlockNumberAndIndex
    • eth_getBlockByHash
    • eth_getBlockByNumber
  • fixed unit tests where necessary

Related issue(s):

Fixes #2128

Notes for reviewer:

Checklist

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

applied to eth_getBlockByNumber, eth_getBlockByHash

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
…ethod

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
… method

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
@quiet-node quiet-node added this to the 0.44.0 milestone Mar 11, 2024
@quiet-node quiet-node self-assigned this Mar 11, 2024
@quiet-node quiet-node linked an issue Mar 11, 2024 that may be closed by this pull request
@quiet-node quiet-node added enhancement New feature or request P1 labels Mar 11, 2024
Copy link

github-actions bot commented Mar 11, 2024

Tests

    1 files    35 suites   3s ⏱️
194 tests 193 ✔️ 1 💤 0
197 runs  196 ✔️ 1 💤 0

Results for commit d1f0729.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 11, 2024

Acceptance Tests

  12 files  148 suites   14m 12s ⏱️
393 tests 389 ✔️ 4 💤 0
414 runs  410 ✔️ 4 💤 0

Results for commit d1f0729.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

Some questions for consideration

packages/relay/src/lib/eth.ts Outdated Show resolved Hide resolved
packages/server/tests/acceptance/rpc_batch1.spec.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/eth.ts Outdated Show resolved Hide resolved
@Nana-EC Nana-EC requested a review from acuarica March 11, 2024 20:34
…sactionByBlockNumberAndIndex into a shared method

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
…s values if null from Mirror Node

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
@quiet-node quiet-node force-pushed the 2128-incompatible-toaddress-in-json-rpc-response branch from d8b2159 to 9a3e1ab Compare March 11, 2024 22:03
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.15%. Comparing base (3612aed) to head (231ebb6).

❗ Current head 231ebb6 differs from pull request most recent head 9a3e1ab. Consider uploading reports for the commit 9a3e1ab to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2185   +/-   ##
=======================================
  Coverage   75.15%   75.15%           
=======================================
  Files          13       13           
  Lines         644      644           
  Branches      118      118           
=======================================
  Hits          484      484           
  Misses        115      115           
  Partials       45       45           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

A few more suggestions

const fromAccountInfo = await mirrorNode.get(`/accounts/${tx.from}`);
const toAccountInfo = await mirrorNode.get(`/accounts/${tx.to}`);

if (fromAccountInfo) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can simplify

Suggested change
if (fromAccountInfo) {
if (fromAccountInfo?.evmAddress) {
tx.from = fromAccountInfo.evm_address;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed in the fix

@@ -61,6 +61,21 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
const ONE_TINYBAR = Utils.add0xPrefix(Utils.toHex(Constants.TINYBAR_TO_WEIBAR_COEF));
const sendRawTransaction = relay.sendRawTransaction;

const resolveEvmAddress = async (tx: any) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const resolveEvmAddress = async (tx: any) => {
const resolveAccountEvmAddresses = async (tx: any) => {

or

Suggested change
const resolveEvmAddress = async (tx: any) => {
const extractAccountEvmAddresses = async (tx: any) => {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed in the fix

@@ -61,6 +61,21 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
const ONE_TINYBAR = Utils.add0xPrefix(Utils.toHex(Constants.TINYBAR_TO_WEIBAR_COEF));
const sendRawTransaction = relay.sendRawTransaction;

const resolveEvmAddress = async (tx: any) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add comments on the function to explain behaviour and function signature

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed in the fix

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Copy link

sonarcloud bot commented Mar 12, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@quiet-node quiet-node requested a review from Nana-EC March 12, 2024 16:26
@quiet-node quiet-node merged commit 7b12027 into main Mar 12, 2024
27 of 28 checks passed
@quiet-node quiet-node deleted the 2128-incompatible-toaddress-in-json-rpc-response branch March 12, 2024 22:28
AlfredoG87 added a commit that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible toAddress in JSON RPC response
3 participants