turboflakes / crunch

Crunch is a command-line interface (CLI) and Matrix Bot to claim staking rewards every Era for Substrate-based chains
https://turboflakes.io
Apache License 2.0
64 stars 22 forks source link

First attempt on Joystream payouts #27

Closed pmensik closed 9 months ago

pmensik commented 1 year ago

This is the first attempt for adding Joystream to the list of Substate-based projects for automated payouts. It's not ready for merge yet because there are still some compilation errors thanks to the missing fields in the node-runtime - and hopefully this can get resolved by the Joystream team.

Workarounds so far applied are

Current compilation errors are listed on pastebin.

paulormart commented 1 year ago

Hi @pmensik, some of those errors is just because Joystream uses different types from the ones in Kusama/Polkadot.

As a suggestion you can try to get all runtime types just by running:

subxt metadata --url wss://rpc.joystream.org:443 -f bytes > joystream_metadata.scale
subxt codegen -f joystream_metadata.scale | rustfmt --edition=2018 --emit=stdout > joystream_runtime.rs

And than adjust the file src/runtimes/joystream.rs accordingly.

As an example the type for events::Rewarded in Joystream is a tuple while in Kusama is a struct, you can adjust the code from ev.stash == validator.stash to ev.0 == validator.stash to override the following error:

error[E0609]: no field `stash` on type `joystream::node_runtime::staking::events::Rewarded`
   --> src/runtimes/joystream.rs:333:39
    |
333 | ...                   if ev.stash == validator.stash {
    |                             ^^^^^ unknown field
    |
    = note: available fields are: `0`, `1`

Nice to know that you are trying crunch in other substrate networks.

pmensik commented 1 year ago

@paulormart Thanks for suggestios! The thing is that I am a very poor Rust/Substrate developer but this seems doable so I'll try myself first!

pmensik commented 1 year ago

Ok, so after some playing around I was able to get rid of all the compilation errors. However, now I am experiencing some runtime errors and this is where I got stuck. Here is the log. Thanks for any help with debugging the issue!

paulormart commented 1 year ago

Yeah the Subxt error: Rpc error: RPC error error is not very explicit.. a few things to check for:

Does Joystream network have a test environment like Westend?

paulormart commented 9 months ago

Hi @pmensik I'm closing this issue as - no longer needed - , feel free to open a new one if you need help with this.