The PropagateRoot service is a helper component in the Linea WorldID system. Its primary function is to relay Merkle tree roots from the Ethereum L1 (mainnet) WorldID Identity Manager to the Linea L2 WorldID contract.
The service aims to:
- Monitor changes in the WorldID Merkle tree on Ethereum L1.
- Call
propagateRoot()
on the LineaStateBridge contract on Ethereum when changes are detected. - Claim the resulting messages on the LineaWorldID contract on Linea L2.
- L1MessageListener: Monitors events on L1.
- L2MessageHandler: Claims messages on L2.
- LineaRootPropagator: Manages the root propagation process.
- Scheduler: Orchestrates tasks.
- Config: Manages configuration settings.
- Initialization: The service validates its configuration and connects to L1 and L2 networks.
- L1 Event Monitoring: Listens for TreeChanged events on the WorldID Identity Manager contract on L1.
- Root Propagation: Upon detecting a TreeChanged event, calls
propagateRoot()
on the LineaStateBridge contract on L1. - L2 Message Claiming: Periodically checks for and claims messages on the LineaWorldID contract on L2.
- Continuous Operation: Continues monitoring events and claiming messages to maintain synchronization.
PRIVATE_KEY
: For transaction signing.ETH_RPC_URL
: Ethereum L1 RPC URL.LINEA_RPC_URL
: Linea L2 RPC URL.LINEA_STATE_BRIDGE_ADDRESS
: LineaStateBridge contract address on L1.MESSAGE_SERVICE_ADDRESS_L1
: L1 Message Service contract address.MESSAGE_SERVICE_ADDRESS_L2
: L2 Message Service contract address.WORLD_ID_IDENTITY_MANAGER_ADDRESS
: WorldID Identity Manager contract address on L1.LINEA_WORLD_ID_ADDRESS
: LineaWorldID contract address on L2.
Optional variables (with defaults) include:
PROPAGATION_PERIOD
: Time between root propagations (default: 1 hour).LISTENER_INIT_DELAY
: Delay before starting the L1 listener (default: 0 seconds).L1_BLOCKS_TO_QUERY
: Number of L1 blocks to query for events (default: 1000).L2_BLOCKS_TO_QUERY
: Number of L2 blocks to query for events (default: 1000).L2_POLLING_INTERVAL
: Interval for polling L2 for new blocks (default: 15 seconds).LINEA_NETWORK
: Linea network name (default: "linea-mainnet").
It also supports a special ENVIRONMENT
variable to load environment-specific variables from the corresponding .env
file.
Ensure all environment variables are set securely, especially the private key.
Monitor logs for successful root propagations, message claims, and any errors.