Add the onion, carrot, leek, cinnamon stick, bay leaves, and peppercorns to the ham in the pot and pour in the stout. Top with enough cold water to make sure the ham is completely covered. Bring to a simmer and cook, partially covered, for 2½ hours over low heat. Skim off any foam during cooking and top off with boiling water as necessary.