Refactor updater to use ethabi-derive#6896
Conversation
lght
left a comment
There was a problem hiding this comment.
Couple of minor grumbles about dependency checksums and abstracting do_call's type. Other than that, the changes look great!
| fetcher: Mutex<Option<fetch::Client>>, | ||
| operations: Mutex<Option<Operations>>, | ||
| operations_contract: operations_contract::Operations, | ||
| do_call: Mutex<Option<Box<Fn(Vec<u8>) -> Result<Vec<u8>, String> + Send + Sync + 'static>>>, |
There was a problem hiding this comment.
Could you abstract do_call's type with a type alias? Maybe above UpdateFilter you could add:
pub type DoCallFn = Fn(Vec<u8>) -> Result<Vec<u8>, String> + Send + Sync + 'static>
| "checksum ethabi 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c819a3adef0413a2519cbd9a19a35dd1c20c7a0110705beaba8aa4aa87eda95f" | ||
| "checksum ethabi 4.1.0 (git+https://github.com/paritytech/ethabi/?branch=call-function)" = "<none>" | ||
| "checksum ethabi-contract 4.1.0 (git+https://github.com/paritytech/ethabi/?branch=call-function)" = "<none>" | ||
| "checksum ethabi-derive 4.1.0 (git+https://github.com/paritytech/ethabi/?branch=call-function)" = "<none>" |
There was a problem hiding this comment.
Will checksums automatically get added to the ethabi dependencies? I'm not very familiar with how checksums are calculated/stored for github dependencies.
There was a problem hiding this comment.
I don't know, I'm not familiar with them either, but we will switch to a regular dependency (on crates.io) once the ethabi branch is merged; this will probably add the checksums again?
There was a problem hiding this comment.
Yeah, pretty sure that crates.io includes the checksum with the crate. If this will be pulling from crates.io on merge, I have no issues with the missing checksum here. Think cargo pins the a release hash to the github url anyway, so secure enough for dev purposes. Just didn't want it to get rolled into master that way
There was a problem hiding this comment.
I'm waiting for https://github.com/paritytech/ethabi/pull/62 to be merged and then I'll update the dependency in this PR.
There was a problem hiding this comment.
Ok sounds good. Everything else looks great. So far from the tests I've written, your changes are easy to incorporate.
There was a problem hiding this comment.
I've added paritytech/core-devs to the owners list of ethabi_derive. I've also released 4.2, so feel free to use it instead of github repo ;)
|
A0 and A3 labels are clearly conflicting :) |
|
I don't plan to make modifications to the code, so reviewing can happen now, but I need to wait for the tests #6913 to be written until this can be merged ^^ I guess I'll ask for a review once this PR is ready to get merged :) |
|
On ice, waiting for #6913 |
|
I'll take it from here |
Use ethabi-derive (with
callfunction @ this branch: https://github.com/paritytech/ethabi/pull/62) to generate the updater contract, rather than using the auto-generated operations.rs contract file. The ABI passed touse_contract!is the same as before.Todo:
Before merging:
Issues/questions:
callreturns anethabi::Result(i.e.Result<_, ethabi::Error>). However, updater.rs expectsResult<_, String>, so I need tomap_errtheethabi::Errorinto a string each time (when using?for example); not sure if this is optimal. Let me know if this should be done another way; I imagine this will change with the error-chain refactoring by Marek.collect_release_infoa static method? I kept it this way but I'm wondering why it cannot be made a regular method so we don't have to pass the contract and the call method to it.(u32, u8, u32, bool)). ethabi-derive currently uses pretty generic input/output types (e.g.(ethabi::Uint , ethabi::Uint , ethabi::Uint , bool)). This creates the need for quite a bit of boilerplate to convert the types to and fro (I imagine this will also be linked with Marek's refactoring for unifying the types). Same for strings; they need to be converted to a hash before being passed as an input. Wouldn't it better if the functions generated by ethabi-derive took care of this and matched the function signatures in the ABI more closely?This change is