Ethereum Name Service, Cross Chain Reverse Resolution (ENSIP-19)
ENS primary names allow for the owner of an address to specify which of their ENS names is the main identifer for that particular address. Under the hood this was historically done as outlined in ENSIP-3: Reverse Resolution (opens in a new tab).
ENSIP-19: Multichain Primary Names (opens in a new tab) outlines the process by which the primary name for an address can be resolved on a chain by chain basis using data from the chain in question.
The team at Base Names (opens in a new tab) have documented their implementation here: L2 Primary Names are coming to Basenames: ENSIP-19 (opens in a new tab).
Under the hood, the reading and verification of data coming from the supported L2s is handled by the Unruggable Gateways codebase. Gateways for these chains are operated by dRPC (opens in a new tab) and verifiers for each chain have been deployed on Ethereum mainnet.