Alss, you usually have to use the command in the RetroArch config otherwise MAME won't know to enable cheats
mame2010-cheats = "enabled"
for mame2003 :
mame2003-cheats = "enabled"
Cheats are optional, so are not enabled by default
I've just checked my mame2010, the samples folder for mame2010 and the "history,dat" and "cheat.dat" are in
/home/pi/RetroPie/BIOS/mame2003/
I had to build the current mame201o from the optional menu in RetroPie. Be warned it can take HOURS even on an overclocked PI3 and running from USB hard drive. I use the SD card purely to boot into OSMC KODI then control is passed over to the USB hard drive. Its much faster and saves wear on the SD card. I used RetroSMC script to install RetroPie onto the OSMC build, so everything runs off USB hard drive and it all works perfectly, including snapshots and gameplay videos