Skip to content

Commit

Permalink
evm: Revert existing events and overload them to return sourceChainId
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsriram committed Dec 5, 2024
1 parent 01c2ef1 commit 534d9b0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
3 changes: 2 additions & 1 deletion evm/src/NttManager/ManagerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@ abstract contract ManagerBase is
_setTransceiverAttestedToMessage(digest, _getTransceiverInfosStorage()[transceiver].index);

emit MessageAttestedTo(
sourceChainId, digest, transceiver, _getTransceiverInfosStorage()[transceiver].index
digest, transceiver, _getTransceiverInfosStorage()[transceiver].index
);
emit MessageAttestedTo(sourceChainId);
}

/// @dev Returns the bitmap of attestations from enabled transceivers for a given message.
Expand Down
3 changes: 2 additions & 1 deletion evm/src/NttManager/NttManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
if (cancelled) {
emit OutboundTransferCancelled(uint256(digest), recipient, untrimmedAmount);
} else {
emit TransferRedeemed(sourceChain, digest);
emit TransferRedeemed(digest);
emit TransferRedeemed(sourceChain);
}

if (mode == Mode.LOCKING) {
Expand Down
13 changes: 8 additions & 5 deletions evm/src/interfaces/IManagerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ interface IManagerBase {

/// @notice Emitted when a message has been attested to.
/// @dev Topic0
/// 0xf1ec44311dd9bf51a389c38e415716ad070edf9e303ea55ed7ae11472a5f031d.
/// @param sourceChain The source chain.
/// 0x35a2101eaac94b493e0dfca061f9a7f087913fde8678e7cde0aca9897edba0e5.
/// @param digest The digest of the message.
/// @param transceiver The address of the transceiver.
/// @param index The index of the transceiver in the bitmap.
event MessageAttestedTo(
uint16 indexed sourceChain, bytes32 digest, address transceiver, uint8 index
);
event MessageAttestedTo(bytes32 digest, address transceiver, uint8 index);

/// @notice Emitted when a message has been attested to.
/// @dev Topic0
/// 0x9fbae37d6867991331ee754b07fe4cc479ea8f0cd952e61f450740d6c350e580.
/// @param sourceChain The source chain.
event MessageAttestedTo(uint16 indexed sourceChain);

/// @notice Emmitted when the threshold required transceivers is changed.
/// @dev Topic0
Expand Down
12 changes: 9 additions & 3 deletions evm/src/interfaces/INttManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ interface INttManager is IManagerBase {
/// @notice Emitted when a transfer has been redeemed
/// (either minted or unlocked on the recipient chain).
/// @dev Topic0
/// 0x822760cb8aef838664db98515460929d89d5799b7546e9269dffdc09e2cbb995.
/// @param sourceChain The source chain.
/// 0x504e6efe18ab9eed10dc6501a417f5b12a2f7f2b1593aed9b89f9bce3cf29a91.
/// @param digest The digest of the message.
event TransferRedeemed(uint16 indexed sourceChain, bytes32 indexed digest);
event TransferRedeemed(bytes32 indexed digest);

/// @notice Emitted when a transfer has been redeemed
/// (either minted or unlocked on the recipient chain).
/// @dev Topic0
/// 0x56b025e18da6f1f65995c2b538c47cabdb4103d11c9bb3ebbacb098d14fa12c6.
/// @param sourceChain The source chain.
event TransferRedeemed(uint16 indexed sourceChain);

/// @notice Emitted when an outbound transfer has been cancelled
/// @dev Topic0
Expand Down
16 changes: 5 additions & 11 deletions evm/test/IntegrationStandalone.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ contract TestEndToEndBase is Test, IRateLimiterEvents {

vm.stopPrank();

// Get the TransferSent(bytes32) event digest to ensure it matches up with the TransferRedeemed(uint16,bytes32) event digest later
// Get the TransferSent(bytes32) event to ensure it matches up with the TransferRedeemed(bytes32) event later
Vm.Log[] memory recordedLogs = vm.getRecordedLogs();
bytes32 sentEventDigest;
for (uint256 i = 0; i < recordedLogs.length; i++) {
Expand Down Expand Up @@ -220,24 +220,18 @@ contract TestEndToEndBase is Test, IRateLimiterEvents {
);
}

// Get the TransferRedeemed(uint16,bytes32) event digest to ensure it matches up with the TransferSent(bytes32) event digest earlier
// Get the TransferRedeemed(bytes32) event to ensure it matches up with the TransferSent(bytes32) event earlier
recordedLogs = vm.getRecordedLogs();
bytes32 recvEventDigest;
bytes32 recvSourceChain;
for (uint256 i = 0; i < recordedLogs.length; i++) {
if (recordedLogs[i].topics[0] == keccak256("TransferRedeemed(uint16,bytes32)")) {
recvSourceChain = recordedLogs[i].topics[1];
recvEventDigest = recordedLogs[i].topics[2];
if (recordedLogs[i].topics[0] == keccak256("TransferRedeemed(bytes32)")) {
recvEventDigest = recordedLogs[i].topics[1];
break;
}
}
require(
recvSourceChain == bytes32(uint256(chainId1)),
"Incorrect TransferRedeemed(uint16,bytes32) event sourceChain"
);
require(
sentEventDigest == recvEventDigest,
"TransferRedeemed(uint16,bytes32) event digest should match TransferSent(bytes32) event digest"
"TransferRedeemed(bytes32) event should match TransferSent(bytes32)"
);

// Can't resubmit the same message twice
Expand Down

0 comments on commit 534d9b0

Please sign in to comment.