def _update_statechanges(storage: SQLiteStorage):
    """
    Update each ContractReceiveChannelNew's channel_state member
    by setting the `mediation_fee` that was added to the NettingChannelState
    """
    batch_size = 50
    batch_query = storage.batch_query_state_changes(
        batch_size=batch_size,
        filters=[
            ('_type', 'raiden.transfer.state_change.ContractReceiveChannelNew'),
        ],
    )

    for state_changes_batch in batch_query:
        updated_state_changes = list()
        for state_change in state_changes_batch:
            data = json.loads(state_change.data)
            msg = 'v20 ContractReceiveChannelNew channel state should not contain medation_fee'
            assert 'mediation_fee' not in data['channel_state'], msg
            data['channel_state']['mediation_fee'] = '0'

            updated_state_changes.append((
                json.dumps(data),
                state_change.state_change_identifier,
            ))

        storage.update_state_changes(updated_state_changes)

    batch_query = storage.batch_query_state_changes(
        batch_size=batch_size,
        filters=[
            ('_type', 'raiden.transfer.mediated_transfer.state_change.ActionInitInitiator'),
        ],
    )

    for state_changes_batch in batch_query:
        updated_state_changes = list()
        for state_change in state_changes_batch:
            data = json.loads(state_change.data)
            msg = 'v20 ActionInitInitiator transfer should not contain allocated_fee'
            assert 'allocated_fee' not in data['transfer'], msg
            data['transfer']['allocated_fee'] = '0'

            updated_state_changes.append((
                json.dumps(data),
                state_change.state_change_identifier,
            ))

        storage.update_state_changes(updated_state_changes)
Update each ContractReceiveChannelNew's channel_state member
    by setting the `mediation_fee` that was added to the NettingChannelState