@@ -51,6 +51,7 @@ use frame_system::{
51
51
} ;
52
52
use scale_info:: prelude:: cmp;
53
53
use sha2:: { Digest , Sha256 } ;
54
+ use sp_core:: blake2_256;
54
55
use sp_runtime:: {
55
56
offchain:: { http, Duration } ,
56
57
traits:: { Hash , One } ,
@@ -279,6 +280,7 @@ pub mod pallet {
279
280
payload,
280
281
signature,
281
282
& payload. block_number ,
283
+ & payload. public ,
282
284
)
283
285
}
284
286
Call :: write_pulse {
@@ -290,6 +292,7 @@ pub mod pallet {
290
292
payload,
291
293
signature,
292
294
& payload. block_number ,
295
+ & payload. public ,
293
296
)
294
297
}
295
298
_ => InvalidTransaction :: Call . into ( ) ,
@@ -506,16 +509,20 @@ impl<T: Config> Pallet<T> {
506
509
payload : & impl SignedPayload < T > ,
507
510
signature : & T :: Signature ,
508
511
block_number : & BlockNumberFor < T > ,
512
+ public : & T :: Public ,
509
513
) -> TransactionValidity {
510
514
let signature_valid =
511
515
SignedPayload :: < T > :: verify :: < T :: AuthorityId > ( payload, signature. clone ( ) ) ;
512
516
if !signature_valid {
513
517
return InvalidTransaction :: BadProof . into ( ) ;
514
518
}
515
- Self :: validate_transaction_parameters ( block_number)
519
+ Self :: validate_transaction_parameters ( block_number, public )
516
520
}
517
521
518
- fn validate_transaction_parameters ( block_number : & BlockNumberFor < T > ) -> TransactionValidity {
522
+ fn validate_transaction_parameters (
523
+ block_number : & BlockNumberFor < T > ,
524
+ public : & T :: Public ,
525
+ ) -> TransactionValidity {
519
526
// Now let's check if the transaction has any chance to succeed.
520
527
let next_unsigned_at = NextUnsignedAt :: < T > :: get ( ) ;
521
528
if & next_unsigned_at > block_number {
@@ -527,6 +534,8 @@ impl<T: Config> Pallet<T> {
527
534
return InvalidTransaction :: Future . into ( ) ;
528
535
}
529
536
537
+ let provides_tag = ( next_unsigned_at, public. encode ( ) ) . using_encoded ( blake2_256) ;
538
+
530
539
ValidTransaction :: with_tag_prefix ( "DrandOffchainWorker" )
531
540
// We set the priority to the value stored at `UnsignedPriority`.
532
541
. priority ( T :: UnsignedPriority :: get ( ) )
@@ -538,7 +547,7 @@ impl<T: Config> Pallet<T> {
538
547
// get to the transaction pool and will end up in the block.
539
548
// We can still have multiple transactions compete for the same "spot",
540
549
// and the one with higher priority will replace other one in the pool.
541
- . and_provides ( next_unsigned_at )
550
+ . and_provides ( provides_tag )
542
551
// The transaction is only valid for next block. After that it's
543
552
// going to be revalidated by the pool.
544
553
. longevity ( 1 )
0 commit comments