Here are a couple of sites explaining how to remove a jailbreak.
https://www.macworld.co.uk/how-to/iphone/unjailbreak-your-iphone-3601679/
https://appletoolbox.com/2016/03/factory-reset-jailbroken-iphone-ipad/
They're both a bit old, and since I've never jailbroken any of my iOS devices, I can't vouch for how well the steps will work. Particularly on a newer iPhone 8.
The general steps are to first use iTunes to backup the phone so you can later restore your contacts and other personal data. Then follow the outlined steps to restore the iPhone to factory condition.
In a jailbroken state, Apple will not for any reason provide warranty work, even if the device is still within the warranty period. Once you reset it, the phone will be the same as if you took it out of the box. The warranty should then still be in effect.