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

feat: modify rpc methods to include synthetic txs #2282

Merged
merged 29 commits into from
May 31, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented May 28, 2024

Description

This PR introduces changes in rpc methods to support synthetic ethermint txs (txs of type 88, where ethermint state is changed by directly calling ApplyMessage method from zetacore).

Some details:

EthMsgsFromTendermintBlock method is modified to include all txs, both regular ethermint and synthetic.

This enabled simple implementation of following methods:

  • debug_traceTransaction
  1. get all eth msgs from block
  2. iterate msgs - all before requested tx are predecessors
  3. once tx is found, use it for tracing
  • debug_traceBlock
  1. get all eth msgs from block and trace block
  • eth_getTransactionByBlockHashAndIndex
  • eth_getTransactionByBlockNumberAndIndex
  1. get all eth msgs from block
  2. use their order and requested index to find requested tx
  3. because index of synthetic txs is always 8888, this is the only way to get both tx types by index

Regarding other tx info methods:

  • eth_getTransactionByHash

  • eth_getTransactionReceipt

If its regular ethermint tx, it can be decoded from tx. If it's not, recreate it from additional tx fields.

Regarding block methods it seems they can remain the same.

Closes: 1959

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Smoke tests done for athens3 and local txs, more testing in next PR (#2282) : move unit tests from ethermint fork here and extend them for these modifications.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

@skosito skosito changed the title Modify rpc methods to include synthetic txs feat: modify rpc methods to include synthetic txs May 28, 2024
Copy link

gitguardian bot commented May 28, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
11033145 Triggered Generic High Entropy Secret 7dd8aa6 cmd/zetae2e/local/accounts.go View secret
11033146 Triggered Generic High Entropy Secret 7dd8aa6 cmd/zetae2e/local/accounts.go View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link

github-actions bot commented May 28, 2024

!!!WARNING!!!
nosec detected in the following files: rpc/backend/tracing.go, rpc/backend/tx_info.go, rpc/types/events.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label May 28, 2024
go.mod Outdated Show resolved Hide resolved
@skosito skosito closed this May 28, 2024
@skosito skosito reopened this May 28, 2024
Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.26%. Comparing base (54de761) to head (f947a6e).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2282   +/-   ##
========================================
  Coverage    69.25%   69.26%           
========================================
  Files          274      274           
  Lines        16535    16537    +2     
========================================
+ Hits         11452    11454    +2     
  Misses        4599     4599           
  Partials       484      484           
Files Coverage Δ
x/fungible/keeper/evm.go 87.81% <100.00%> (+0.05%) ⬆️

@skosito skosito requested review from lumtis and ws4charlie as code owners May 28, 2024 23:30
go.mod Outdated Show resolved Hide resolved
changelog.md Outdated Show resolved Hide resolved
rpc/backend/blocks.go Outdated Show resolved Hide resolved
rpc/backend/blocks.go Outdated Show resolved Hide resolved
rpc/backend/blocks.go Outdated Show resolved Hide resolved
rpc/types/events.go Outdated Show resolved Hide resolved
rpc/types/events.go Outdated Show resolved Hide resolved
rpc/types/events.go Show resolved Hide resolved
rpc/types/utils.go Outdated Show resolved Hide resolved
rpc/types/utils.go Show resolved Hide resolved
@skosito skosito requested a review from lumtis May 29, 2024 19:52
rpc/backend/blocks.go Outdated Show resolved Hide resolved
rpc/backend/blocks.go Outdated Show resolved Hide resolved
rpc/types/events.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kingpinXD kingpinXD left a comment

Choose a reason for hiding this comment

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

Looks good , wondering if there is a separate task any plans to add add unit tests for some of the functions added or modified ?

@lumtis
Copy link
Member

lumtis commented May 30, 2024

Looks good , wondering if there is a separate task any plans to add add unit tests for some of the functions added or modified ?

#2283

@skosito skosito requested a review from kingpinXD May 30, 2024 17:56
@skosito skosito merged commit 0a3b8dc into develop May 31, 2024
18 of 19 checks passed
@skosito skosito deleted the debug-trace-tx-changes branch May 31, 2024 18:37
@skosito skosito mentioned this pull request Jun 17, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix JSON RPC issues linked to Ethermint
3 participants