Make the cake: Preheat the oven to 350 degrees F. Line a 9-by-13-inch baking dish with foil; butter the foil. Toast the chiles in a dry medium saucepan over medium heat until darkened and pliable, about 5 minutes. Remove from the heat, add 1 cup water and let soak until the chiles soften, about 5 more minutes. Transfer the chiles and soaking liquid to a blender and puree. Strain through a fine-mesh sieve back into the saucepan. Finely chop any chile pieces left in the sieve and add to the saucepan.
Whisk the flour, granulated sugar, brown sugar, salt and baking powder in a large bowl; set aside. Add the butter and cocoa powder to the saucepan with the chile puree; bring to a boil over medium heat, stirring, until the butter is melted. Pour into the flour mixture and stir until combined. Whisk the buttermilk, eggs, vanilla and baking soda in a liquid measuring cup; stir into the batter in two additions until combined.
Pour the batter into the prepared pan, spreading it evenly. Bake until a toothpick inserted into the center comes out clean, about 35 minutes. Transfer to a rack and let cool slightly in the pan.
Meanwhile, make the frosting: Combine the pecans, butter, cayenne and salt in a medium saucepan. Cook over medium heat until the butter is melted and the pecans are lightly toasted, about 5 minutes. Remove 1/2 cup pecans with a slotted spoon and set aside for topping. Stir the cocoa powder into the saucepan and remove from the heat. Whisk in the confectioners? sugar in two batches, alternating with the milk, mixing well after each addition.
Immediately pour the warm frosting over the warm cake and gently spread to cover. Top with the reserved pecans and let cool completely before slicing.
Photograph by Con Poulos