0

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.

Jdawg287
  • 117
  • 5
  • seems that the 2 extrinsics are excatly the same and you want to distinguish them by the nonce. Have you thought about if the design is reasonable? what's the meaning of many validators send the same tx. – Clark Lee Oct 06 '21 at 15:08
  • Many validators send the same transaction means for example they call the same unsigned transaction with their own piece of relevant data that is to be stored in the offchain indexing storage. – Jdawg287 Oct 06 '21 at 23:50
  • So if we have 2 validators that are chosen to be the next validators after the era elections each of them would call `Call::submit_participant(validator_A_data)` and `Call::submit_participant(validator_B_data)` from the offchain worker. Of course when storing the data the key for the storage is derived individually for each validator from their signing keys. This produces the same nonce for me which can be seen from the error "10100". – Jdawg287 Oct 06 '21 at 23:50

1 Answers1

6

Unsigned transactions are not associated to any account and thus, they also don't have any nonce.

bkchr
  • 621
  • 2
  • 5