joystream icon indicating copy to clipboard operation
joystream copied to clipboard

Storage pallet: Unbound `ipfs_content_id` length

Open Lezek123 opened this issue 2 years ago • 1 comments

At some point when storage pallet benchmarking was being done, it was realized that the ipfs_content_id passed by the user can have an arbitrary length, which is not good, because that would mean we need to add additional, complex benchmarking parameters to account for that.

The solution was to add a new error: InvalidCidLength, which is returned when ipfs_content_id.len() != 46 (46 beeing the number of bytes in the base58-encoded multihash).

However, this check was only added for extrinsics that are invoked directly through storage pallet (ie. update_blacklist), while for cross-pallet calls (ie. create_channel => create_dynamic_bag), it is still missing, resulting in user beeing able to provide arbitrarly long ipfs_content_id as part of, for example, ChannelCreationParameters.

We need to make sure ipfs_content_id.len() is always checked for being == 46

┆Issue is synchronized with this Asana task by Unito ┆Link To Issue: https://app.asana.com/0/1202132419573087/1202597990645609

Lezek123 avatar Jul 13 '22 10:07 Lezek123

Sounds like a good idea, but

  1. should we actually be accepting base58 encoding for this? This is a bloated character format for human purposes, using raw bytes would be more efficient here.
  2. perhaps we should drop reference to ipfs in name? perhaps some different CID scheme will get used later, causing this name to be a source of confusion.

bedeho avatar Jul 14 '22 08:07 bedeho