Kiddushin 72 - Generations
When R' Akiva died, Rebbi was born. When Rabbi died, Rav Yehudah was born. When Rav Yehudah died, Rava was born. When Rava died, Rav Ashi was born. This comes to teach you that a righteous person does not depart from the world until another righteous person like him is born, as it is said, " And the sun rises and the sun sets... "
Mamzerim will be genealogically pure in the Messianic Era, because of " I will cast pure water on you and you will be purified from all your impurities and from all your defilements I will purify you ."