Any station can pump some crappy gas through their pumps, especially from the bottom of the tank (did you notice the pump running especially slowly?). You just never know...
The knock sensor is often mounted directly to the engine somewhere on the head (may be difficult to get to). It senses the premature detonation etlsport described and retards timing if it detects consistent knocking. I would see if you can find where it mounts and clean up the connection or replace it if you are highly motivated.
The second fault is the one to focus on for now - run the cleaners through your engine and some good fresh gas and see if the fault comes back.
Good luck!