It is not due to solidarity.
If Russia wants to they could completely bypass Ukraine once NS2 is complete. Of the countries supplied with TurkStream only Hungary hasn't built their connection to it yet. Turkey has increased their capacity of transit further with the completion of the Trans-Anatolian Pipeline and the Trans Adriatic Pipeline was finished just last year. The little amount of gas that needs to transit Ukraine could be moved via LNG from the Yamal field. The only countries in southern europe which have no alternatives are Romania and Moldova. The Ukraine pipelines will in fact only serve Ukraine, Moldavia, and Romania once Hungary connects via the Balkan Stream pipeline to TurkStream.
But the Russians, unlike other people, do honor contracts. So Ukraine will have at least 5 more years guaranteed transit fees. After that, they will have learn how to live without billions in gas transit fees like everyone else and actually have to work for a living.