1

In the code of the Nicks pallet, there is some logic to make sure the name passed as parameter is long enough.

ensure!(bounded_name.len() >= T::MinLength::get() as usize, Error::<T>::TooShort);

Now when I call the extrinsic with a name too short, the condition is false, yet the extrinsic is included into a block. Polkadot-js/apps as well as the substrate-UI-template don't show any error (beside one event for the latter). Shouldn't it fail with TooShort?

edit:

  • I confirm that the MinLength is 8 char, and that I set a name smaller than this.
  • Here is the code: https://github.com/Tbaut/substrate-node-template/compare/main...nicks-pallet
  • Now the one reason why the UI may not be able to see that the extrinsic failed, is that it seems to have issues decoding the system events. All the blocks (not only the one with my extrinsic) have the following: enter image description here
4
  • What's the name? And what's the MinLength that you have configured?
    – aurexav
    Commented Oct 20, 2022 at 3:01
  • I edited my post, the MinLength is set to 8 in the config, and I call the extrinsic with a smaller name than this.
    – Tbaut
    Commented Oct 20, 2022 at 11:53
  • 1
    Was able to replicate this on substrate-node-template v0.9.30
    – Bruno
    Commented Oct 20, 2022 at 15:25
  • Following up here github.com/polkadot-js/apps/issues/8259
    – Tbaut
    Commented Oct 21, 2022 at 15:05

2 Answers 2

2

If send the extrinsic setName with a name shorter than the number you set when configured the pallet you can will see that the extrinsic is included in the block, but it fails to perform the operation.

With PolkadotJS you will see in the top-right of the screen when the extrinsic ends: enter image description here

And if you go to the Network explorer and find the Block where your extrinsic was included you can see too, that the extrinsic was included in the block and the reason it failed: enter image description here

If you still can't see, I suggest you check your configuration as someone suggested in the comments.

Go to your node runtime/src/lib.rs and check the MinNickLength value

parameter_types! {
// Choose a fee that incentivizes desireable behavior.
pub const NickReservationFee: u128 = 100;
pub const MinNickLength: u32 = 8;
// Maximum bounds on storage are important to secure your chain.
pub const MaxNickLength: u32 = 32;
}
// Nicks pallet
impl pallet_nicks::Config for Runtime {
    type Currency = Balances;
    // Use the NickReservationFee from the parameter_types block.
    type ReservationFee = NickReservationFee;
    // No action is taken when deposits are forfeited.
    type Slashed = ();
    // Configure the FRAME System Root origin as the Nick pallet admin..
    type ForceOrigin = frame_system::EnsureRoot<AccountId>;
    // Use the MinNickLength from the parameter_types block.
    type MinLength = MinNickLength;
    // Use the MaxNickLength from the parameter_types block.
    type MaxLength = MaxNickLength;
    // The ubiquitous event type.
    type Event = Event;
}
5
  • While what you describe is what I expected, this is not what I see. The MinNickLength is set to ConstU32<8>; and I use setName with a name smaller than 8. Now I realized that all the system events can't be decoded by pjs/apps. All the blocks have a Unable to decode storage system.events:: createType(Vec<FrameSystemEventRecord>):: decodeU8a: failed at 0x0000000000000090e9900e0000000002… (index 0/1): Because of this, the UI can't see that the extrinsic failed. I edited the first post with a screenshot.
    – Tbaut
    Commented Oct 20, 2022 at 11:50
  • Try the latest node-template, Bruno could replicate it. substrate.stackexchange.com/questions/5447/…
    – Tbaut
    Commented Oct 20, 2022 at 21:37
  • Sorry I can experiment your issue now too. I have been testing it with substrate-node-template v0.9.29 and worked, but i can see the error testing it with substrate-node-template v0.9.3o like you. I am going to investigate what can cause the issue
    – Alex Bean
    Commented Oct 21, 2022 at 7:22
  • @Tbaut I have found is a known issue in the PolkadotJS app code: github.com/polkadot-js/apps/issues/8259
    – Alex Bean
    Commented Oct 21, 2022 at 13:31
  • yes I saw it too, at the end of the day, it means either the node-template should be upgraded to weight v2, or the pjs api should handle node-template weight correctly.
    – Tbaut
    Commented Oct 21, 2022 at 15:13
2

While Alex Bean's answer would be perfectly right if things were running normally, in this particular case, the question was asked because something went wrong, while using the latest node-template v9.30

The issue here is that the RuntimeEvent could not be decoded by the api, and hence the UI. Because of this the Error event could also not be decoded and the UI was therefore only showing the green notification that the extrinsic was in a block, but NOT followed by any subsequent red notification, that would mean that something went wrong at run time. This is something that has subsequently been fixed at the pjs api level, another fix would have been if the node-template used weight v2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.