<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _add_onchain_locksroot_to_snapshot( raiden: RaidenService, storage: SQLiteStorage, snapshot_record: StateChangeRecord, ) -> str: """ Add `onchain_locksroot` to each NettingChannelEndState """

    snapshot = json.loads(snapshot_record.data)

    for payment_network in snapshot.get('identifiers_to_paymentnetworks', dict()).values():
        for token_network in payment_network.get('tokennetworks', list()):
            channelidentifiers_to_channels = token_network.get(
                'channelidentifiers_to_channels',
                dict(),
            )
            for channel in channelidentifiers_to_channels.values():
                our_locksroot, partner_locksroot = _get_onchain_locksroots(
                    raiden=raiden,
                    storage=storage,
                    token_network=token_network,
                    channel=channel,
                )
                channel['our_state']['onchain_locksroot'] = serialize_bytes(our_locksroot)
                channel['partner_state']['onchain_locksroot'] = serialize_bytes(partner_locksroot)

    return json.dumps(snapshot, indent=4), snapshot_record.identifier