I'm having trouble determining values for param num_slashing_spans for api.tx.staking.withdrawUnbonded.
I see that the most popular value is
0, but sometimes people also use
Is there any documents/ instruction on this? Thanks
When an account withdraws unbonded, there is a chance that it will no longer be a stash account at all (i.e., if it has unbonded its entire stake). When a validator gets slashed, it and its nominators get a slashing span in storage that will need to be cleaned up if this stash is removed from staking.
So this param is used by the weight calculator to determine the weight of the transaction (more storage items to remove means more weight). Note that if you provide too low of a number in the transaction, it will fail, but if you provide too high of a number it will still work, you will just pay a higher transaction fee.
To see what value to use, you need to look up the
SlashingSpans, keyed by the stash account. A really easy way to do this is just to use Substrate API Sidecar, which has an account staking info endpoint, which returns slashing spans. For more info on how that is fetched, you can check the implementation of that endpoint.