So the US knew the location of the Iranian ship off Sri Lanka bc both the US and Iran were part of a military exercise hosted by India which the US pulled out of at the last minute, presumably so as to bomb the unarmed Iranian ship.
The former Indian FM:

@AlisonCreekside In wartime it is lawful to attack enemy ships even if they are defenseless, but you must first declare war to give them fair notice that their ships may be attacked without warning. But we haven’t done that. Only congress has the constitutional authority to declare war.

Every unprovoked attack on Iran is a war crime, including the school we bombed and the attack that killed the Iranian leadership.