feat: added cctp helper#54
Conversation
There was a problem hiding this comment.
A few things that I think will actually bite users in tests, plus a small ask about the PR description.
1. topics[0] will OOB-revert on logs with zero topics
src/cctp/CctpV2Helper.sol:63:
for (uint256 i; i < logs.length; i++) {
if (logs[i].topics[0] != MESSAGE_SENT_TOPIC) continue;Any anonymous event / log0 in the captured logs makes topics[0] revert before the selector check runs. Whether you hit this depends on what else the contracts under test emit, but it's the kind of thing where someone's test works fine until they wire in a new contract and suddenly the helper blows up. CcipHelper guards this with if (l.topics.length == 0) continue;
2. No dedup → silent double-mint if the same logs are replayed
_clearUsedNonce re-zeros the usedNonces slot on every pass, so if help is called twice with the same Vm.Log[] (e.g., a test that records once and runs the helper across multiple destinations or steps), receiveMessage runs again and USDC gets minted twice on the destination. The first call already replayed the message — the second one shouldn't.
CcipHelper keeps an internal _processedMessageIds set for exactly this. Tracking (sourceDomain, nonce) here would close it.
3. The MessageSent(bytes) selector is generic — worth filtering by emitter
MessageSent(bytes) is a pretty common event signature; anything else in the test emitting it will get decoded as a CCTP message and likely revert deeper in _getDestinationDomain or receiveMessage. CcipHelper takes an optional srcOnRamp for this. Defaulting to MESSAGE_TRANSMITTER_V2 (with an override) would make the helper robust against incidental collisions.
Nit: PR body
Could you add a short summary to the PR description?
Addressed your feedback. Thanks! |
No description provided.