@@ -424,6 +424,88 @@ func (c *Subnet) InitializeProofOfAuthority(
424424 return nil
425425}
426426
427+ func (c * Subnet ) InitializeValidatorManager (
428+ ctx context.Context ,
429+ network models.Network ,
430+ privateKey string ,
431+ aggregatorExtraPeerEndpoints []info.Peer ,
432+ aggregatorAllowPrivatePeers bool ,
433+ aggregatorLogger logging.Logger ,
434+ validatorManagerAddressStr string ,
435+ ) error {
436+ if c .SubnetID == ids .Empty {
437+ return fmt .Errorf ("unable to initialize Proof of Authority: %w" , errMissingSubnetID )
438+ }
439+
440+ if c .BlockchainID == ids .Empty {
441+ return fmt .Errorf ("unable to initialize Proof of Authority: %w" , errMissingBlockchainID )
442+ }
443+
444+ if c .RPC == "" {
445+ return fmt .Errorf ("unable to initialize Proof of Authority: %w" , errMissingRPC )
446+ }
447+
448+ if c .OwnerAddress == nil {
449+ return fmt .Errorf ("unable to initialize Proof of Authority: %w" , errMissingOwnerAddress )
450+ }
451+
452+ if len (c .BootstrapValidators ) == 0 {
453+ return fmt .Errorf ("unable to initialize Proof of Authority: %w" , errMissingBootstrapValidators )
454+ }
455+
456+ if err := evm .SetupProposerVM (
457+ c .RPC ,
458+ privateKey ,
459+ ); err != nil {
460+ ux .Logger .RedXToUser ("failure setting proposer VM on L1: %s" , err )
461+ }
462+ managerAddress := common .HexToAddress (validatorManagerAddressStr )
463+ tx , _ , err := validatormanager .InitializeValidatorManager (
464+ c .RPC ,
465+ managerAddress ,
466+ privateKey ,
467+ c .SubnetID ,
468+ * c .OwnerAddress ,
469+ )
470+ if err != nil {
471+ if ! errors .Is (err , validatormanager .ErrAlreadyInitialized ) {
472+ return evm .TransactionError (tx , err , "failure initializing poa validator manager" )
473+ }
474+ ux .Logger .PrintToUser ("Warning: the PoA contract is already initialized." )
475+ }
476+
477+ subnetConversionSignedMessage , err := validatormanager .GetPChainSubnetConversionWarpMessage (
478+ ctx ,
479+ network ,
480+ aggregatorLogger ,
481+ 0 ,
482+ aggregatorAllowPrivatePeers ,
483+ aggregatorExtraPeerEndpoints ,
484+ c .SubnetID ,
485+ c .BlockchainID ,
486+ managerAddress ,
487+ c .BootstrapValidators ,
488+ )
489+ if err != nil {
490+ return fmt .Errorf ("failure signing subnet conversion warp message: %w" , err )
491+ }
492+
493+ tx , _ , err = validatormanager .InitializeValidatorsSet (
494+ c .RPC ,
495+ managerAddress ,
496+ privateKey ,
497+ c .SubnetID ,
498+ c .BlockchainID ,
499+ c .BootstrapValidators ,
500+ subnetConversionSignedMessage ,
501+ )
502+ if err != nil {
503+ return evm .TransactionError (tx , err , "failure initializing validators set on poa manager" )
504+ }
505+
506+ return nil
507+ }
508+
427509func (c * Subnet ) InitializeProofOfStake (
428510 ctx context.Context ,
429511 network models.Network ,
0 commit comments