Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

ENG 119 restructure json rpc api #1218

Merged
merged 27 commits into from
Aug 9, 2022
Merged

Conversation

danburck
Copy link
Contributor

@danburck danburck commented Jul 29, 2022

Description

This PR reorganizes the JSON-RPC apis and backend.

Right now the changes include an example for the following proposal:

  • use namespace/ethereum/<namespace>/api.go files for an overview of exposed apis

    • order by groups
  • use backend for api logic. Separate into several backend logic files:

    • Blocks
      • Read Transactions
      • Write Transactions
      • Account Information
      • EVM/Smart Contract Execution
      • Event Logs
      • Chain Information
      • Getting Uncles
      • Proof of Work
      • Other

@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #1218 (66239ba) into main (d1543ce) will decrease coverage by 5.27%.
The diff coverage is 10.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1218      +/-   ##
==========================================
- Coverage   57.20%   51.92%   -5.28%     
==========================================
  Files          94      102       +8     
  Lines        8424     9282     +858     
==========================================
+ Hits         4819     4820       +1     
- Misses       3358     4214     +856     
- Partials      247      248       +1     
Impacted Files Coverage Δ
rpc/backend/account_info.go 0.00% <0.00%> (ø)
rpc/backend/call_tx.go 0.00% <0.00%> (ø)
rpc/backend/filters.go 0.00% <0.00%> (ø)
rpc/backend/node_info.go 0.00% <0.00%> (ø)
rpc/backend/sign_tx.go 0.00% <0.00%> (ø)
rpc/backend/tracing.go 0.00% <0.00%> (ø)
rpc/backend/tx_info.go 0.00% <0.00%> (ø)
rpc/backend/utils.go 3.79% <ø> (+1.48%) ⬆️
rpc/backend/chain_info.go 10.05% <10.05%> (ø)
rpc/backend/backend.go 50.00% <14.28%> (-36.67%) ⬇️
... and 1 more

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM

@facs95
Copy link
Contributor

facs95 commented Aug 3, 2022

Updated the PR doing the following changes:

  • Merge the latest from main (with the new integration tests)
  • Refractor main apis moving every clientquery to the backend

Still missing

  • Reorganize evm_backend into different files

I think that will be enough for a first PR.
I will not refractor filters until we have an integration tests for them to make sure no regressions happen as the refractor is a bit more complex.

@facs95 facs95 marked this pull request as ready for review August 8, 2022 23:44
@fedekunze fedekunze merged commit e70d8fc into main Aug 9, 2022
@fedekunze fedekunze deleted the ENG-119-restructure-json-rpc-api branch August 9, 2022 05:52
Copy link
Contributor Author

@danburck danburck left a comment

Choose a reason for hiding this comment

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

@facs95 Looks good, since it's already merged I think we should address the following things in future PRs:

  • move remaining logic from eth/api.go (GetTransactionByBlockNumberAndIndex(), GasPrice(), MaxPriorityFeePerGas(), GetTransactionLogs(), GetPendingTransactions())
  • clean up interfaces. We probably don't need both interfaces EVMBackend and EthereumAPI interface. What do you think?

// ProtocolVersion returns the supported Ethereum protocol version.
func (e *PublicAPI) ProtocolVersion() hexutil.Uint {
e.logger.Debug("eth_protocolVersion")
return hexutil.Uint(ethermint.ProtocolVersion)
}

// GasPrice returns the current gas price based on Ethermint's gas price oracle.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@facs95 Any reason, why you didn't move this endpoint logic?

Copy link
Contributor

Choose a reason for hiding this comment

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

any method of PublicAPI gets exposed as an endpoint (eth_protocolVersion) its not the same when its a backend method. Those are not exposed. So I just moved the logic that use clientQuery or clientCtx to the backend. Anything that required state query.

facs95 added a commit that referenced this pull request Aug 12, 2022
* move non api methods from eth/api.go to evm_backend: ClientCtx, QueryClient, Ctx, getBlockNumber, getTransactionByBlockAndIndex, doCall

* organize eth/api.go into sections and move backend logic to dedicated files

* remove unnecesary comment

* move resend to the backend

* refractor eth api

* refractor debug namespace

* refactor miner namespace

* refactor personal namespace

* update transactionReceipt from upstream

* update getBlockByNumber from upstream

* update getBalance from upstream

* update getProof from upstream

* update getBalance from upstream

* fix linter

* remove duplicated import

* remove duplicated import

* fix backend tests

* fix lint

* fix duplicated imports

* fix linter

* reorganize blocks

* backend folder refractor

* remove unnecessary file

* remove duplicate import

Co-authored-by: Freddy Caceres <facs95@gmail.com>
hoanguyenkh pushed a commit to AstraProtocol/ethermint that referenced this pull request Aug 17, 2022
* move non api methods from eth/api.go to evm_backend: ClientCtx, QueryClient, Ctx, getBlockNumber, getTransactionByBlockAndIndex, doCall

* organize eth/api.go into sections and move backend logic to dedicated files

* remove unnecesary comment

* move resend to the backend

* refractor eth api

* refractor debug namespace

* refactor miner namespace

* refactor personal namespace

* update transactionReceipt from upstream

* update getBlockByNumber from upstream

* update getBalance from upstream

* update getProof from upstream

* update getBalance from upstream

* fix linter

* remove duplicated import

* remove duplicated import

* fix backend tests

* fix lint

* fix duplicated imports

* fix linter

* reorganize blocks

* backend folder refractor

* remove unnecessary file

* remove duplicate import

Co-authored-by: Freddy Caceres <facs95@gmail.com>
devon-chain pushed a commit to FunctionX/ethermint that referenced this pull request Nov 17, 2022
* move non api methods from eth/api.go to evm_backend: ClientCtx, QueryClient, Ctx, getBlockNumber, getTransactionByBlockAndIndex, doCall

* organize eth/api.go into sections and move backend logic to dedicated files

* remove unnecesary comment

* move resend to the backend

* refractor eth api

* refractor debug namespace

* refactor miner namespace

* refactor personal namespace

* update transactionReceipt from upstream

* update getBlockByNumber from upstream

* update getBalance from upstream

* update getProof from upstream

* update getBalance from upstream

* fix linter

* remove duplicated import

* remove duplicated import

* fix backend tests

* fix lint

* fix duplicated imports

* fix linter

* reorganize blocks

* backend folder refractor

* remove unnecessary file

* remove duplicate import

Co-authored-by: Freddy Caceres <facs95@gmail.com>
(cherry picked from commit d43386d)
@danburck danburck mentioned this pull request Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants