Skip to content

feat: added cctp helper#54

Merged
supervaulter merged 2 commits into
mainfrom
feat/cctp-helper
May 8, 2026
Merged

feat: added cctp helper#54
supervaulter merged 2 commits into
mainfrom
feat/cctp-helper

Conversation

@supervaulter
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Collaborator

@0xTimepunk 0xTimepunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@supervaulter
Copy link
Copy Markdown
Collaborator Author

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!

Copy link
Copy Markdown
Collaborator

@0xTimepunk 0xTimepunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@supervaulter supervaulter merged commit 8ba2a52 into main May 8, 2026
2 checks passed
@0xTimepunk 0xTimepunk deleted the feat/cctp-helper branch May 8, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants