-
Notifications
You must be signed in to change notification settings - Fork 710
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
[pallet-revive] Add Ethereum JSON-RPC server #5953
Conversation
d80a5ce
to
d931a80
Compare
Depends on #5866
ebb0b36
to
de0b0ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that it works with vanilla ether.js now. This is how it should have been.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have a better name than just "demo". Maybe "rpc_demo".
#[subxt::subxt( | ||
runtime_metadata_path = "kitchensink.scale", | ||
substitute_type( | ||
path = "pallet_revive::primitives::EthContractResult<A>", | ||
with = "::subxt::utils::Static<::pallet_revive::EthContractResult<A>>" | ||
), | ||
substitute_type( | ||
path = "pallet_revive::primitives::EthTransactKind", | ||
with = "::subxt::utils::Static<::pallet_revive::EthTransactKind>" | ||
), | ||
substitute_type( | ||
path = "sp_weights::weight_v2::Weight", | ||
with = "::subxt::utils::Static<::sp_weights::Weight>" | ||
) | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to use the dynamic API of subxt here. Otherwise the pallet ids and so on will be hardcoded to whatever kitchensink is using, right?
Or how do we make sure that this will be compatible across different runtimes (westend ah, kusama ah, polkadot ah)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes correct, the only thing that can break I believe is the encoding of the dispatchable, since the index will differ for each runtime, I was planning to go with feature flag to start with, until I find a more suitable solution, will look into their dynamic API as well.
pub extern "C" fn call() { | ||
input!(128, data: [u8],); | ||
api::deposit_event(&[], data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert the selector here? ether.js should derive a selector from the provided ABI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right yes it does, might be easier to add the assert in the js code directly, since that's where we define the "fake ABI"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want the assert here, too. So we can make sure that the selector actually reaches the contract.
log::info!(target: LOG_TARGET, "method: {method} params: {params}"); | ||
let resp = service.call(req).await; | ||
if resp.is_success() { | ||
log::info!(target: LOG_TARGET, "✅ rpc: {method}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that for eth_call
response is very useful. Could we print it out in dev mode?
arg bad merge, not sure what I have done here, will recreate the PR |
This PR introduces the necessary changes to pallet-revive for integrating with our Ethereum JSON-RPC. The RPC proxy itself will be added in a follow up. ## Changes - A new pallet::call `Call::eth_transact`. This is used as a wrapper to accept unsigned Ethereum transaction, valid call will be routed to `Call::call` or `Call::instantiate_with_code` - A custom UncheckedExtrinsic struct, that wraps the generic one usually and add the ability to check eth_transact calls sent from an Ethereum JSON-RPC proxy. - Generated types and traits to support implementing a JSON-RPC Ethereum proxy. ## Flow Overview: - A user submits a transaction via MetaMask or another Ethereum-compatible wallet. - The proxy dry run the transaction and add metadata to the call (gas limit in Weight, storage deposit limit, and length of bytecode and constructor input for contract instantiation) - The raw transaction, along with the additional metadata, is submitted to the node as an unsigned extrinsic. - On the runtime, our custom UncheckedExtrinsic define a custom Checkable implementation that converts the unsigned extrinsics into checked one - It recovers the signer - validates the payload, and injects signed extensions, allowing the system to increment the nonce and charge the appropriate fees. - re-route the call to pallet-revive::Call::call or pallet-revive::Call::instantiateWithCode ## Dependencies - paritytech/polkavm#188 ## Follow up PRs - #5926 - #6147 (previously #5953) - #5502 --------- Co-authored-by: Alexander Theißen <[email protected]> Co-authored-by: Cyrill Leutwiler <[email protected]>
Redo of #5953 --------- Co-authored-by: Alexander Theißen <[email protected]> Co-authored-by: GitHub Action <[email protected]>
Redo of paritytech#5953 --------- Co-authored-by: Alexander Theißen <[email protected]> Co-authored-by: GitHub Action <[email protected]>
Redo of paritytech#5953 --------- Co-authored-by: Alexander Theißen <[email protected]> Co-authored-by: GitHub Action <[email protected]>
No description provided.