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

Reorg rpc (no logic changes) #601

Merged
merged 26 commits into from
Apr 14, 2022
Merged

Reorg rpc (no logic changes) #601

merged 26 commits into from
Apr 14, 2022

Conversation

koushiro
Copy link
Collaborator

@koushiro koushiro commented Feb 27, 2022

Description

This is a big PR without any logical changes about rpc.

I think the big file module is hard to maintain and read, so I made the following changes:

  • Split EthApi into multiple files
    • Block
    • State
    • Execute
    • Fee
    • Mining
    • Block
    • Transaction
    • Submit
  • Move eth_getLogs method to EthFilterApi
  • Move EthBlockDataCache and EthTask into eth/cache module.
  • Move EthSigner and EthDevSigner into signer module.

Waiting #593 to be merged firstly

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@koushiro koushiro requested a review from sorpaas as a code owner February 27, 2022 09:06
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@koushiro
Copy link
Collaborator Author

koushiro commented Mar 3, 2022

@sorpaas PTAL

@koushiro
Copy link
Collaborator Author

koushiro commented Mar 9, 2022

@sorpaas could you give me some feedback?

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@sorpaas
Copy link
Member

sorpaas commented Mar 17, 2022

Sorry about my review order, but can you merge master? (Should be a simple one just due to eth_maxPriorityFeeperGas.)

@koushiro
Copy link
Collaborator Author

@sorpaas PTAL

Copy link
Member

@sorpaas sorpaas left a comment

Choose a reason for hiding this comment

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

I like the improvements of code clarity where we split eth_ implementations into multiple files, but honestly, I don't see much reasons why we need to split the traits as well, which I hope you can explain more. Plus the later will add a lot of API changes to downstream users that they need to adopt.

Alternatively, my recommendation is that we can revert the trait changes, but keep the impl file split structure (you can split a single structs impl into multiple files).

@koushiro
Copy link
Collaborator Author

koushiro commented Mar 22, 2022

I don't see much reasons why we need to split the traits as well, which I hope you can explain more. Plus the later will add a lot of API changes to downstream users that they need to adopt.

I think this may be more flexible, such as only accepting some json-rpc methods, filtering out sendTransaction/sendRawTransaction methods, etc.

Maybe we can add a trait EthApiT and struct EthApi to solve the problem of API changes, like the following:

#[rpc(server)]
pub trait EthApiT:
	EthClientApiT
	+ EthBlockApiT
	+ EthTransactionApiT
	+ EthStateApiT
	+ EthExecuteApiT
	+ EthFeeApiT
	+ EthMiningApiT
	+ EthSubmitApiT
{
}

pub struct EthApi<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> {
	block_api: EthBlockApi<B, C, BE>,
	client_api: EthClientApi<B, C, BE, H>,
	execute_api: EthExecuteApi<B, C, BE, A>,
	fee_api: EthFeeApi<B, C, BE>,
	mining_api: EthMiningApi,
	state_api: EthStateApi<B, C, BE, P, A>,
	submit_api: EthSubmitApi<B, C, P, CT, BE, H, A>,
	transaction_api: EthTransactionApi<B, C, BE, A>,
}

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> EthApiT for EthApi<B, C, P, CT, BE, H, A> {}

impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> EthBlockApiT for EthApi<B, C, P, CT, BE, H, A> {
    ...
}
impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> EthClientApiT for EthApi<B, C, P, CT, BE, H, A> {
    ...
}
impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> EthExecuteApiT for EthApi<B, C, P, CT, BE, H, A> {
    ...
}
...

@koushiro
Copy link
Collaborator Author

@sorpaas what do you think?

@sorpaas
Copy link
Member

sorpaas commented Mar 25, 2022

My main concern is regarding the split trait is honestly how the categorization is done. We'll have more RPC methods in the eth_ namespace in the future, and what I worry is that people cannot (clearly) see where a method should belong then and randomly adding it in a trait. We'll then have a categorization that no one will understand.

If you can explain more about how you did the categorization, it may be helpful. Otherwise, if there are any official EIP categorization, then my recommendation is that we follow that (we of course don't need to strictly follow EIPs if there's something absurd, but given this is not really in our main area of concern, in this case it's useful). If both of the above cannot be satisfied, then my recommendation is still that we tentatively don't split the trait.

@koushiro
Copy link
Collaborator Author

I know what you meaning. Actually, I largely follow the ethereum/execution-apis categorization, but it doesn't include all eth_ prefix json-rpc methods.

@koushiro
Copy link
Collaborator Author

koushiro commented Apr 5, 2022

I know what you meaning. Actually, I largely follow the ethereum/execution-apis categorization, but it doesn't include all eth_ prefix json-rpc methods.

@sorpaas what do you think? If it's still not acceptable, I'd split eth_ implementations into multiple files firstly.

@sorpaas
Copy link
Member

sorpaas commented Apr 5, 2022

I'd split eth_ implementations into multiple files firstly.

Yeah I'd prefer that at this moment. Right now I just don't see much benefits to split the traits (it's unlikely that end users will want to use only a subset of eth_ namespace) and it creates a lot of burdens for them when they need to upgrade.

koushiro added 5 commits April 5, 2022 14:02
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@koushiro
Copy link
Collaborator Author

koushiro commented Apr 6, 2022

@sorpaas could you PTAL again?

@sorpaas
Copy link
Member

sorpaas commented Apr 14, 2022

Please pull master.

@sorpaas sorpaas merged commit 24062a1 into polkadot-evm:master Apr 14, 2022
@koushiro koushiro deleted the reorg-rpc branch April 15, 2022 02:04
@notlesh notlesh mentioned this pull request May 9, 2022
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
* Split net api and web3 api into their own modules

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* some nits

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* remove some useless trait bound

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Reorg eth rpc

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* remove useless

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix fmt

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* rename src/eth.rs => src/eth/mod.rs

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix fmt

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Some nits

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* remove some useless trait bound

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* fix some doc

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix license header of each file

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* enable use_field_init_shorthand format config

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix warning, replace AllPallets with AllPalletsWithSystem

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Split eth_ impls into multiple files

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Some nits

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants