stakelink / substrate-payctl

Simple command line application to control the payouts of Substrate validators (Polkadot and Kusama among others).
MIT License
33 stars 8 forks source link

Claiming rewards on Centrifuge #15

Open mario-sangar opened 3 years ago

mario-sangar commented 3 years ago

I'm trying to claim rewards on the Centrifuge network with this tool and it doesn't work with the default type_preset. I tried to add the Centrifuge types defined on @polkadot/api (adapted for the substrate-interface). The tool connected successfully, but it failed in a similar way as with the default types when signing the extrinsic.

scalecodec.exceptions.RemainingScaleBytesNotEmptyException: Decoding "None" - No more bytes available (needed: 72 / total: 69)

A link to the Centrifuge types:

https://github.com/polkadot-js/apps/blob/master/packages/apps-config/src/api/spec/centrifuge-chain.ts

It's there something I'm missing here? Using the @polkadot/api it's able to submit the extrinsic with those types, so I don't know if it's related to the types themselves. You can replicate the issue even without submitting the extrinsic, the error pops up when signing.

arjanz commented 3 years ago

I guess somewhere along the extrinsic compose, sign and submit process there is still a type mismatch.. What I can think of is to verify if the converted type registry from PolkadotJs is in the same format as: https://github.com/polkascan/py-scale-codec/blob/master/scalecodec/type_registry/polkadot.json ? And if it's the signing where the exception is raised, it could be the ExtrinsicPayloadValue type is a different format for Centrifuge

I know first hand it can be a delicate and somewhat cumbersome process to debug the specific exceptions from the default Substrate types and I'm afraid it will take some step-by-step debugging to pin point the exact culprit. It is unfortunately still a lot a manual upkeep to reflect the types in the runtime (and keep the versioning for backwards compatibility) but hopefully this process will be automated soon (I know Parity is working on scale-info )

I would definitely welcome a PR though if you manage to figure this one out, or give you some more pointers along the way.

arjanz commented 3 years ago

Maybe this can be of some help, before we dropped support for non-Parity runtimes, we got Centrifuge working with this type registry preset (but is from March 2020, so must be outdated):

{
  "runtime_id": 198,
  "types": {
    "Address": "AccountIdAddress",
    "BlockNumber": "u32",
    "Keys": {
      "type": "struct",
      "type_mapping": [
         ["grandpa", "AccountId"],
         ["babe", "AccountId"],
         ["im_online", "AccountId"],
         ["authority_discovery", "AccountId"]
      ]
    },
    "Fee<Hash, Balance>": {
      "type": "struct",
      "type_mapping": [
         ["key", "Hash"],
         ["price", "Balance"]
      ]
    },
    "PreCommitData<Hash, AccountId, BlockNumber>": {
      "type": "struct",
      "type_mapping": [
         ["signing_root", "Hash"],
         ["identity", "AccountId"],
         ["expiration_block", "BlockNumber"]
      ]
    },
    "Proof": {
      "type": "struct",
      "type_mapping": [
         ["leaf_hash", "H256"],
         ["sorted_hashes", "Vec<H256>"]
      ]
    }
  }
}