-
Notifications
You must be signed in to change notification settings - Fork 521
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
Add runtime API ConvertTransactionRuntime API
#559
Add runtime API ConvertTransactionRuntime API
#559
Conversation
|
||
#[api_version(2)] | ||
pub trait ConvertTransactionRuntimeApi { | ||
fn convert_transaction(transaction: ethereum::TransactionV2) -> <Block as BlockT>::Extrinsic; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have this type, then why do you still have an Option<_>
in Eth::new
?
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.
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.
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 talked with @tgmichel and let's keep it the current way, as the code is already semi-used in production.
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
NoTransactionCorverter
type was introduced.