@@ -8,6 +8,7 @@ extern crate alloc;
88#[ cfg( feature = "std" ) ]
99include ! ( concat!( env!( "OUT_DIR" ) , "/wasm_binary.rs" ) ) ;
1010
11+ use bp_runtime:: OwnedBridgeModule ;
1112use bridge_runtime_common:: generate_bridge_reject_obsolete_headers_and_messages;
1213use frame_support:: { derive_impl, traits:: ValidatorRegistration } ;
1314use frame_system:: EnsureRoot ;
@@ -339,13 +340,6 @@ impl pallet_timestamp::Config for Runtime {
339340 type WeightInfo = ( ) ;
340341}
341342
342- // TODO: remove sudo before go live
343- impl pallet_sudo:: Config for Runtime {
344- type RuntimeEvent = RuntimeEvent ;
345- type RuntimeCall = RuntimeCall ;
346- type WeightInfo = pallet_sudo:: weights:: SubstrateWeight < Runtime > ;
347- }
348-
349343impl pallet_transaction_storage:: Config for Runtime {
350344 type RuntimeEvent = RuntimeEvent ;
351345 type WeightInfo = pallet_transaction_storage:: weights:: SubstrateWeight < Runtime > ;
@@ -406,9 +400,6 @@ construct_runtime!(
406400 BridgePolkadotGrandpa : pallet_bridge_grandpa = 51 ,
407401 BridgePolkadotParachains : pallet_bridge_parachains = 52 ,
408402 BridgePolkadotMessages : pallet_bridge_messages = 53 ,
409-
410- // sudo
411- Sudo : pallet_sudo = 255 ,
412403 }
413404) ;
414405
@@ -419,18 +410,6 @@ pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
419410/// Block type as expected by this runtime.
420411pub type Block = generic:: Block < Header , UncheckedExtrinsic > ;
421412
422- fn validate_sudo ( _who : & AccountId ) -> TransactionValidity {
423- // TODO: make Sudo::key() accessible and uncomment this.
424- // // Only allow sudo transactions signed by the sudo account. The sudo pallet obviously checks
425- // // this, but not until transaction execution.
426- // if Sudo::key().map_or(false, |k| who == &k) {
427- // Ok(ValidTransaction { priority: SudoPriority::get(), ..Default::default() })
428- // } else {
429- // Err(InvalidTransaction::BadSigner.into())
430- // }
431- Ok ( ValidTransaction { priority : SudoPriority :: get ( ) , ..Default :: default ( ) } )
432- }
433-
434413fn validate_purge_keys ( who : & AccountId ) -> TransactionValidity {
435414 // Only allow if account has keys to purge
436415 if Session :: is_registered ( who) {
@@ -493,9 +472,6 @@ impl TransactionExtension<RuntimeCall> for ValidateSigned {
493472 RuntimeCall :: TransactionStorage ( inner_call) =>
494473 TransactionStorage :: validate_signed ( who, inner_call) ,
495474
496- // Sudo call
497- RuntimeCall :: Sudo ( _) => validate_sudo ( who) ,
498-
499475 // Session key management
500476 RuntimeCall :: Session ( SessionCall :: set_keys { .. } ) =>
501477 ValidatorSet :: validate_set_keys ( who) . map ( |( ) | ValidTransaction {
@@ -530,6 +506,16 @@ impl TransactionExtension<RuntimeCall> for ValidateSigned {
530506 ..Default :: default ( )
531507 } ) ,
532508
509+ // Bridge-privileged calls
510+ RuntimeCall :: BridgePolkadotGrandpa ( BridgeGrandpaCall :: initialize { .. } ) =>
511+ BridgePolkadotGrandpa :: ensure_owner_or_root ( origin. clone ( ) )
512+ . map_err ( |_| InvalidTransaction :: BadSigner . into ( ) )
513+ . map ( |( ) | ValidTransaction {
514+ priority : BridgeTxPriority :: get ( ) ,
515+ longevity : BridgeTxLongevity :: get ( ) ,
516+ ..Default :: default ( )
517+ } ) ,
518+
533519 // All other calls are invalid
534520 _ => Err ( InvalidTransaction :: Call . into ( ) ) ,
535521 } ?;
@@ -551,9 +537,6 @@ impl TransactionExtension<RuntimeCall> for ValidateSigned {
551537 RuntimeCall :: TransactionStorage ( inner_call) =>
552538 TransactionStorage :: pre_dispatch_signed ( who, inner_call) . map ( |( ) | None ) ,
553539
554- // Sudo validation
555- RuntimeCall :: Sudo ( _) => validate_sudo ( who) . map ( |_| None ) ,
556-
557540 // Session key management
558541 RuntimeCall :: Session ( SessionCall :: set_keys { .. } ) =>
559542 ValidatorSet :: pre_dispatch_set_keys ( who) . map ( |( ) | None ) ,
@@ -580,6 +563,12 @@ impl TransactionExtension<RuntimeCall> for ValidateSigned {
580563 BridgeMessagesCall :: receive_messages_delivery_proof { .. } ,
581564 ) => RelayerSet :: validate_bridge_tx ( who) . map ( |( ) | Some ( who. clone ( ) ) ) ,
582565
566+ // Bridge-privileged calls
567+ RuntimeCall :: BridgePolkadotGrandpa ( BridgeGrandpaCall :: initialize { .. } ) =>
568+ BridgePolkadotGrandpa :: ensure_owner_or_root ( origin. clone ( ) )
569+ . map_err ( |_| InvalidTransaction :: BadSigner . into ( ) )
570+ . map ( |( ) | Some ( who. clone ( ) ) ) ,
571+
583572 // All other calls are invalid
584573 _ => Err ( InvalidTransaction :: Call . into ( ) ) ,
585574 }
@@ -646,7 +635,6 @@ mod benches {
646635 [ frame_benchmarking, BaselineBench :: <Runtime >]
647636 [ frame_system, SystemBench :: <Runtime >]
648637 [ pallet_timestamp, Timestamp ]
649- [ pallet_sudo, Sudo ]
650638 [ pallet_transaction_storage, TransactionStorage ]
651639 [ pallet_validator_set, ValidatorSet ]
652640 [ pallet_relayer_set, RelayerSet ]
0 commit comments