Potential-based analyses of first-order methods for constrained and composite optimization