In a 5-quart (4.7 L) Dutch oven or heavy-bottomed pot, combine the beans, 2 tablespoons of the onion, 1 clove of garlic, and 8 cups (2 L) of water. Bring to a boil and then lower the heat to a simmer, cover, and let cook for an hour. After an hour, add 1 teaspoon of sea salt. Test the beans for doneness. If tender, turn off the heat and set aside to cool. If the beans are still hard, cook for 15 minutes more.
When cooled, drain the beans in a colander and discard the bean water. Put the beans back in the Dutch oven and add 6½ cups (1.5 L) water.
In a 2-quart (2 L) saucepan, combine the nopales, 2 tablespoons of the onion, 1 garlic clove, and 4½ cups (1 L) of water. Bring to a boil and cook for 30 minutes or until the nopales change color. Pour the nopales into a colander and discard the cooking liquid. Rinse with cold water. Set aside.
Heat a comal or skillet to medium heat and toast the rest of the onion and garlic. When charred, set aside. Next, individually toast the cloves, black peppercorns, cumin seeds, oregano, and avocado leaves. When aromatic, set aside. Lastly, toast the chiles and then let them soak in hot water for 30 minutes.
Combine the masa with 1 cup (240 ml) of water in a blender and blend until smooth. Pass through a double-fine-mesh strainer and add the strained masa to the beans. Bring the mixture to a boil, then lower the heat to a low simmer. Make sure to mix well and constantly scrape the sides with a spatula so that the masa doesn’t stick to the bottom of the pan.
Meanwhile, in a molcajete or spice grinder, grind the cumin, oregano, peppercorns, and cloves until finely ground. In the same blender, combine the rehydrated chiles, charred onion and garlic, and freshly ground spices with ¼ cup (60 ml) of the chile soaking liquid. Pass through a double-fine-mesh strainer and pour the puree into the simmering beans.
In a 2-quart (2 L) saucepan, bring 2 cups (480 ml) of water to a boil. Quickly dip the shrimp into the boiling water and remove right away to remove any excess smell of dried shrimp.
Add the nopales to the beans, along with the blanched dried shrimp and toasted avocado leaves. Continue simmering for 8 minutes and taste for seasoning. The soup is done when the shrimps have softened, which should be about 15 minutes after you’ve added them.