IB20: add from/to/amount/nonce to Memo event#38
Closed
eric-ships wants to merge 1 commit into
Closed
Conversation
The previous Memo(bytes32 memo) required indexers to join to the
preceding Transfer log via logIndex - 1, which breaks if any log is
interleaved. The new signature is fully self-contained:
Memo(address indexed from, address indexed to, uint256 amount,
bytes32 indexed memo, uint256 nonce)
nonce is a per-token monotonic counter (stored in MockB20Storage at
MEMO_NONCE_OFFSET = 15) that increments on every *WithMemo call,
guaranteeing uniqueness even when (from, to, amount, memo) repeats.
No ERC is broken: Transfer (ERC-20) is unchanged; Memo is a custom
extension not defined by any standard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The previous
Memo(bytes32 indexed memo)event required indexers to correlate it to the precedingTransferlog vialogIndex - 1. This coupling is fragile: any log interleaved betweenTransferandMemobreaks the join silently. Even withfrom/toadded, the identity is not unique — the same sender can pay the same recipient the same amount with the same memo multiple times (retries, repeated invoices).The new signature is fully self-contained and unconditionally unique:
nonceis a per-token monotonic counter that increments on every*WithMemocall, guaranteeing uniqueness even when(from, to, amount, memo)repeats. No join toTransferis needed; indexers can consumeMemoalone.What changed
IB20.sol:Memoevent gainsfrom,to,amount,nonce; natspec updatedMockB20Storage:memoNonce uint256appended atMEMO_NONCE_OFFSET = 15MockB20: all four*WithMemofunctions read-increment-emit the noncevm.expectEmitupdated to assert the full new signatureWhat was tried / considered
Adding only
from/towas considered but rejected:(from, to, memo)is still not unique if the same invoice is retried. Addingamountwas also considered but(from, to, amount, memo)is similarly non-unique. A contract-level nonce is the only mechanism that gives unconditional uniqueness without relying on log position.No ERC is broken:
Transfer(ERC-20) is unchanged.Memois a custom extension not defined by any standard.