Skip to content

Conversation

@Imod7
Copy link
Contributor

@Imod7 Imod7 commented Jan 5, 2026

Description

While querying pallets/staking/progress in Kusama Asset Hub (example: public instance of KAH Sidecar), the below error is returned:

{
  "code": 500,
  "message": "unappliedSlashesAtActiveEra[0][1].map is not a function",
  "stack": "TypeError: unappliedSlashesAtActiveEra[0][1].map is not a function\n    at PalletsStakingProgressService.derivePalletStakingProgress (/usr/src/app/build/src/services/pallets/PalletsStakingProgressService.js:96:53)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async PalletsStakingProgressController.getPalletStakingProgress (/usr/src/app/build/src/controllers/pallets/PalletsStakingProgressController.js:119:32)\n    at async /usr/src/app/build/src/controllers/AbstractController.js:313:9",
  "level": "error"
}

Root Cause

When we call .entries() on UnappliedSlashes/StorageDoubleMap, it returns an array of [StorageKey, PendingSlashes] items where PendingSlashes is an object. However, we assume that PendingSlashes is an array and try to use map on it.

Suggested Solution

We should use map over unappliedSlashesAtActiveEra (== array) directly instead of unappliedSlashesAtActiveEra[0][1] (==PendingSlashes == object/struct).

The above is confirmed looking at the code in polkadot-sdk:

  • UnappliedSlashes code --> shows that the UnappliedSlashes is a StorageDoubleMap.
  • PendingSlashes code --> shows that the PendingSlashes is a struct thus an object (not an array).

The format of the unappliedSlashes.entries() (unappliedSlashesAtActiveEra) is also confirmed when I run in debug:

  • unappliedSlashesAtActiveEra[0][0] --> StorageKey(92) [...]
  • unappliedSlashesAtActiveEra[0][1] --> data of PendingSlashes object
{"validator":"D5aAp1y8XfkrmtPqsGFZtCjJrPZqKrsG2ceSha846jy6RMU","own":3289142260,"others":[["G1rrUNQSk7CjjEmLSGcpNu72tVtyzbWdUvgmSer9eBitXWf",5213796174],["G4RasQNUjgkXkdCuW2zgMJPcjZijaTmkJixb3oMxg9eiHng",58511039826],["F7oUkCrka4KGEmHpMweomYTh9ebrJ5e1SNoXCKqUVRXbxZ1",5746245842],["ESNmSiVRtezE2LmvXKAcZb4cm5hsSAVZkhMPLsRNiqPMjBp",847234987],["EFSNCLVUoTHTp2DcmQVw17YaouTxLAEQoVNoT9T1ToEb3SZ",279452729],["DDqMKWm7qerD9w4kXG1iYrMp4ac1sZ5Mak64A8B6XbDc3kn",127007745],["DXpDoDfFBh6iZX9JJZKgXs5d8NXM4f7eLch9RTQwiePZDX9",56688815]],"reporter":"Ed1xXhwva7tsK6sY5WnRQNVQ5bXC2kNbkpbU1EhjPZy4Cb6","payout":7407060837}

Testing

This solution works when testing

  • with a local instance of Sidecar with .env file:
SAS_SUBSTRATE_URL=wss://kusama-asset-hub-rpc.polkadot.io
SAS_SUBSTRATE_MULTI_CHAIN_URL='[{"url":"wss://kusama-rpc.polkadot.io","type":"relay"}]'
  • querying endpoint http://127.0.0.1:8080/pallets/staking/progress
  • returns
 "unappliedSlashes": [
    {
      "validator": "D5aAp1y8XfkrmtPqsGFZtCjJrPZqKrsG2ceSha846jy6RMU",
      "own": "3289142260",
      "others": [
        [
          "G1rrUNQSk7CjjEmLSGcpNu72tVtyzbWdUvgmSer9eBitXWf",
          "5213796174"
        ],
        .....

Todos

  • The mock tests need to be updated

@Imod7 Imod7 requested a review from a team as a code owner January 5, 2026 12:55
@Imod7 Imod7 merged commit ee1d98f into master Jan 5, 2026
11 checks passed
@Imod7 Imod7 deleted the domi-fix-unappliedSlashes branch January 5, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants