Add runtime API ConvertTransactionRuntime API#559
Add runtime API ConvertTransactionRuntime API#559sorpaas merged 3 commits intopolkadot-evm:masterfrom
ConvertTransactionRuntime API#559Conversation
|
|
||
| #[api_version(2)] | ||
| pub trait ConvertTransactionRuntimeApi { | ||
| fn convert_transaction(transaction: ethereum::TransactionV2) -> <Block as BlockT>::Extrinsic; |
There was a problem hiding this comment.
Consider changing this to with RLP Vec<u8> as input, and return Option<Extrinsic> where None indicates that the conversion failed.
Ethereum transaction's RLP encoding is backward and future compatible, but not really the SCALE encoding, as that's internal. Doing the above ensures that when runtime updates to support a new transaction type, you can immediately use it without waiting for old nodes to update. With this you can also remove the versioning.
Also, is there a particular reason that this isn't put into EthereumRuntimeRPCApi?
There was a problem hiding this comment.
Hmm I realized that our EthereumRuntimeRPCApi is not forward compatible anyway, so the above (using RLP Vec<u8> as input) may not provide much benefits.
The other points still stands -- maybe consider moving this to EthereumRuntimeRPCApi.
There was a problem hiding this comment.
We decided to have it in a separate trait so that the client can ask if the API is present or not.
Indeed, substrate does not allow to ask if a particular method of a runtime api is present or not.
|
|
||
| // `NoTransactionConverter` is a non-instantiable type (an enum with no variants), | ||
| // so we are guaranteed at compile time that `NoTransactionConverter` can never be instantiated. | ||
| pub enum NoTransactionConverter {} |
There was a problem hiding this comment.
Is this actually used? Do we actually have a situation where transaction conversion is just not possible or something?
There was a problem hiding this comment.
If you have this type, then why do you still have an Option<_> in Eth::new?
There was a problem hiding this comment.
Oh, I get it. I use this only as a type parameter. and use None as the value. That's why it's not instantiable.
|
I'd like to highlight some differences compared to #558:
It is very sad to see that #558 didn't got the attention it deserved. |
Sorry @MOZGIII , I hadn't seen your PR, and we had to implement it in a hurry to solve a problem in production :/ Your PR seems to be better designed, you can open a new one to improve the implementation, and tag me to review it :) |
* Add runtime API `ConvertTransactionRuntime API` * ref: make transaction_converter optional * rustfmt
Closes #508
Introduces a new runtime API (
ConvertTransactionRuntimeApi) to convert an ethereum transaction to an Extrinsic.This is necessary for production networks that want to move to eth transactions V2 without a breaking update (like Moonbeam).
The TransactionConverter is still used if the runtime API is not present.
For projects that integrate the runtime API into their runtime, a TransactionConverter must still be provided to satisfy the rust traits bound, which is why a
NoTransactionCorvertertype was introduced.