I have an offchain worker instance running in my pallet, which is calling an unsigned extrinsic after the era elections are over. The purpose of this unsigned extrinsic is to store some data in the offchain indexing storage for all the validators for the next era. If there are more than 1 validators to call this unsigned extrinsic in a same block I get the following error:
2021-10-06 14:06:19.406 WARN ThreadId(26) txpool: (offchain call) Error submitting a transaction to the pool: Pool(TooLowPriority { old: 10100, new: 10100 })
2021-10-06 14:06:19.406 ERROR ThreadId(26) pallet_participant: Failed in submit_participant
2021-10-06 14:06:19.406 ERROR ThreadId(26) pallet_participant: offchain_worker error: OffchainUnsignedTxSignedPayloadError
After some digging (here) I've found out that the error is coming from having the same nonce for both the unsigned extrinsics in the same block. In my case since my pallet is under development the weight for my extrinsic is set as follows:
#[weight = 10000]
pub fn submit_participant(_signature: T::Signature) -> DispatchResult {
and my validate unsigned function the transaction priority is set as follows:
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
let valid_tx = |provide| {
ValidTransaction::with_tag_prefix("pallet-participant")
.priority(100)
.and_provides([&provide])
.longevity(3)
.propagate(true)
.build()
};
So the question is how to manage the nonce so that it does not give me error about transaction priority? If there is an example for this kind of implementation, it would be really helpful.