In the voltaic pile, the cathode-half reaction was the reduction of hydrogen ions to form hydrogen gas. Where did these ions come from?

The hydrogen ions likely came from an acidic electrolyte solution that was placed between the two metal electrodes within the voltaic pile. As the anode-half reaction oxidized the metal atoms to release electrons, the electrolyte solution facilitated the movement of these electrons towards the cathode, creating a flow of electric current. At the same time, hydrogen ions from the electrolyte were reduced to form hydrogen gas at the cathode.