Preheat oven to 350°F (175°C). Grease and flour a 10x15-inch pan.
In a bowl, combine 2 cups all-purpose flour, 2 cups granulated sugar, 5 tablespoons unsweetened cocoa powder, 1 teaspoon baking soda, and 1/2 teaspoon salt.
Add 1/2 cup sour cream and 2 eggs to the dry ingredients. Mix until combined. Set aside.
In a saucepan over low heat, melt 1 cup butter. Add 1 cup water and 5 tablespoons unsweetened cocoa powder. Bring to a boil, then remove from heat and let cool slightly.
Stir the chocolate mixture into the batter until smooth and fully combined.
Pour batter into prepared pan and bake for about 20 minutes, or until a toothpick inserted in the center comes out clean.
For the frosting, combine 6 tablespoons milk, 5 tablespoons unsweetened cocoa powder, and 1/2 cup butter in a saucepan. Bring to a boil, then remove from heat.
Stir in 4 cups confectioners’ sugar and 1 teaspoon vanilla extract until smooth. Fold in 1 cup chopped walnuts if using.
Spread frosting over the warm cake and allow to set before serving.