Initialize Validator Set

Set up the initial validator set when converting a subnet to an L1

When converting an existing subnet to an L1 with sovereign validator management, you need to initialize the Validator Manager with the current validator set. This one-time operation bridges P-Chain subnet creation with L1 validator management using cryptographically verified conversion data.

Validator Manager Deployment Initialize Validator Set

How initializeValidatorSet Works

Function Implementation

You can view the full source code of the initializeValidatorSet function here: ValidatorManager.sol#L211

Here you will find pseudo-code that covers the main logic in the function:

initializeValidatorSet(conversionData, messageIndex):
    // 1. Validation Checks
    CHECK validator set not already initialized
    VERIFY blockchain ID matches current chain
    VERIFY validator manager address is correct
    
    // 2. P-Chain Message Verification
    GET conversion ID from P-Chain Warp message at messageIndex
    COMPUTE hash of provided conversion data
    VERIFY hashes match (ensures data integrity)
    
    // 3. Process Initial Validators
    totalWeight = 0
    FOR each validator in conversionData.initialValidators:
        validationID = sha256(subnetID + validator_index)
        
        VALIDATE node ID format and check for duplicates
        REGISTER validator with "Active" status
        STORE validation period data (weight, start time, etc.)
        ADD to total weight
        EMIT registration event
    
    // 4. Final Validation
    ENSURE total weight meets minimum churn requirements
    
    // 5. Complete Initialization
    MARK validator set as initialized (permanent flag)

P-Chain Integration & Aggregated Signatures

The initialization leverages Avalanche Warp Messaging for security:

  1. P-Chain Validators Sign - The subnet's validators collectively sign the conversion data
  2. Aggregated Signature - Creates a threshold signature proving consensus
  3. Warp Precompile Verifies - The signature is verified before the contract receives it
  4. Contract Validates - Additional checks ensure data integrity

The conversion ID is derived through:

bytes32 conversionID = keccak256(abi.encode(conversionData));

This ID must match the one in the P-Chain signed message, ensuring data hasn't been tampered with.

Understanding Conversion Data

The conversion data structure used by the function:

struct ConversionData {
    bytes32 subnetID;                      // Your L1's subnet identifier
    bytes32 validatorManagerBlockchainID;  // Blockchain ID where VM is deployed  
    address validatorManagerAddress;       // This validator manager contract (0xfacade...)
    InitialValidator[] initialValidators;  // Array of current validators
}
 
struct InitialValidator {
    bytes nodeID;        // Validator's P-Chain node ID (e.g., "NodeID-...")
    bytes blsPublicKey;  // BLS public key for signature verification
    uint64 weight;       // Validator's voting weight
}

Required Information

To initialize, you'll need:

  • Conversion Data: Current validator information from P-Chain
  • Message Index: Position in the Warp message queue
  • Proper Timing: Must be done before other operations

Initialization can only be done once! Make sure you have the correct validator data before proceeding.

Initialize Validator Set

Initialize Validator Set

This will initialize the ValidatorManager contract.

Step 1: Aggregate Signature of Conversion Data

Enter the P-Chain Transaction ID of the ConvertSubnetToL1Tx of the L1 this Validator Manager it is for. It is needed to fetch the conversion data containing the initial validator set. This validator set will be set up in the validator manager contract so the consensus weight of these validators can be changed or they can be removed entirely if desired.

Step 2: Intialize the Validator Manager Contract State

With the aggregated signature, you can now initialize the Validator Manager contract state. This will set up the initial validator set and allow you to manage validators.

Next Steps

Congratulations! You just set up your first Permissioned L1! In the next chapter you will learn how to manage this validator set:

  1. Query the validator set to verify state
  2. Add, Chnage Weight & Remove Validators

Is this guide helpful?

Report Issue