What will happen if I loop through 1000 or 10000 values in a vector. Will the transaction fail or block time will increase?
1 Answer
Depends on what exactly you are doing. If you just loop through them and don't do anything, it should work. In this case the decoding is probably the most expensive operation.
Generally, a transaction will not fail when it takes too long to execute. It will basically just increase the time to build the block. For Substrate the runtime is trusted and this means that the runtime needs to be benchmarked properly. You also need to ensure that loading these 10000 elements does not lead to the allocator running out of memory.
TLDR: If possible, I would not do this ;)
-
I just need to add the u32 values. Taking out standard deviation and mean. Commented Sep 3 at 16:35