Continuity mistake: After Costello smashes Costigan's wrist he hands all of the dollars he has in his right hand. A frame later money reappears in the hand.
Continuity mistake: When a shootout between Sullivan's men and Costello's starts after Queenan's death, one shot initially hits the left glass of the van, then in the next shot the glass is intact, only to be hit again.
Visible crew/equipment: When Queenan dies after being thrown out of the building and his body is crushed on the ground in front of Costigan, as he looks at his hand covered in blood, in the shot on the top on the left side of the screen the dolly track of the camera is visible for a second.
Answer: The assumption is that Wahlberg learned of Damon's betrayal from the envelope given to Vera Farmiga, Damon's therapist girlfriend. It could also have been for revenge, but Wahlberg did know that Damon was the rat when he killed him.
Dandude