diff --git a/rust/chains/hyperlane-ethereum/abis/Mailbox.abi.json b/rust/chains/hyperlane-ethereum/abis/Mailbox.abi.json index d9436364c..cbd5b914e 100644 --- a/rust/chains/hyperlane-ethereum/abis/Mailbox.abi.json +++ b/rust/chains/hyperlane-ethereum/abis/Mailbox.abi.json @@ -26,10 +26,22 @@ { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint32", + "name": "destination", + "type": "uint32" + }, { "indexed": true, "internalType": "bytes32", - "name": "messageId", + "name": "recipient", "type": "bytes32" }, { @@ -42,6 +54,19 @@ "name": "Dispatch", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "messageId", + "type": "bytes32" + } + ], + "name": "DispatchId", + "type": "event" + }, { "anonymous": false, "inputs": [ @@ -77,16 +102,41 @@ { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "origin", + "type": "uint32" + }, { "indexed": true, "internalType": "bytes32", - "name": "messageId", + "name": "sender", "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" } ], "name": "Process", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "messageId", + "type": "bytes32" + } + ], + "name": "ProcessId", + "type": "event" + }, { "inputs": [], "name": "MAX_MESSAGE_BODY_BYTES", diff --git a/rust/chains/hyperlane-ethereum/src/mailbox.rs b/rust/chains/hyperlane-ethereum/src/mailbox.rs index b58c52dc4..495acdb05 100644 --- a/rust/chains/hyperlane-ethereum/src/mailbox.rs +++ b/rust/chains/hyperlane-ethereum/src/mailbox.rs @@ -126,7 +126,7 @@ where async fn fetch_delivered_messages(&self, from: u32, to: u32) -> Result> { Ok(self .contract - .process_filter() + .process_id_filter() .from_block(from) .to_block(to) .query_with_meta() diff --git a/solidity/contracts/Mailbox.sol b/solidity/contracts/Mailbox.sol index e994fd6cd..b3ed34026 100644 --- a/solidity/contracts/Mailbox.sol +++ b/solidity/contracts/Mailbox.sol @@ -59,16 +59,41 @@ contract Mailbox is /** * @notice Emitted when a new message is dispatched via Hyperlane - * @param messageId The unique message identifier + * @param sender The address that dispatched the message + * @param destination The destination domain of the message + * @param recipient The message recipient address on `destination` * @param message Raw bytes of message */ - event Dispatch(bytes32 indexed messageId, bytes message); + event Dispatch( + address indexed sender, + uint32 indexed destination, + bytes32 indexed recipient, + bytes message + ); /** - * @notice Emitted when a Hyperlane message is delivered + * @notice Emitted when a new message is dispatched via Hyperlane + * @param messageId The unique message identifier + */ + event DispatchId(bytes32 indexed messageId); + + /** + * @notice Emitted when a Hyperlane message is processed * @param messageId The unique message identifier */ - event Process(bytes32 indexed messageId); + event ProcessId(bytes32 indexed messageId); + + /** + * @notice Emitted when a Hyperlane message is delivered + * @param origin The origin domain of the message + * @param sender The message sender address on `origin` + * @param recipient The address that handled the message + */ + event Process( + uint32 indexed origin, + bytes32 indexed sender, + address indexed recipient + ); // ============ Constructor ============ @@ -122,7 +147,13 @@ contract Mailbox is // Insert the message ID into the merkle tree. bytes32 _id = _message.id(); tree.insert(_id); - emit Dispatch(_id, _message); + emit Dispatch( + msg.sender, + _destinationDomain, + _recipientAddress, + _message + ); + emit DispatchId(_id); return _id; } @@ -153,13 +184,12 @@ contract Mailbox is require(_ism.verify(_metadata, _message), "!module"); // Deliver the message to the recipient. - uint32 _origin = _message.origin(); - IMessageRecipient(_message.recipientAddress()).handle( - _origin, - _message.sender(), - _message.body() - ); - emit Process(_id); + uint32 origin = _message.origin(); + bytes32 sender = _message.sender(); + address recipient = _message.recipientAddress(); + IMessageRecipient(recipient).handle(origin, sender, _message.body()); + emit Process(origin, sender, recipient); + emit ProcessId(_id); } // ============ Public Functions ============ diff --git a/solidity/test/lib/mailboxes.ts b/solidity/test/lib/mailboxes.ts index 1ff3db419..6d7e44f9a 100644 --- a/solidity/test/lib/mailboxes.ts +++ b/solidity/test/lib/mailboxes.ts @@ -40,12 +40,13 @@ export const dispatchMessageAndReturnProof = async ( messageStr: string, ): Promise => { const nonce = await mailbox.count(); - const { message, messageId } = await dispatchMessage( + const { message } = await dispatchMessage( mailbox, destination, utils.addressToBytes32(recipient), messageStr, ); + const messageId = utils.messageId(message); const proof = await mailbox.proof(); return { proof: { diff --git a/solidity/test/mailbox.test.ts b/solidity/test/mailbox.test.ts index 361506fe9..799645520 100644 --- a/solidity/test/mailbox.test.ts +++ b/solidity/test/mailbox.test.ts @@ -70,17 +70,14 @@ describe('Mailbox', async () => { it('Dispatches a message', async () => { // Send message with signer address as msg.sender + const recipientBytes = utils.addressToBytes32(recipient.address); await expect( - mailbox - .connect(signer) - .dispatch( - destDomain, - utils.addressToBytes32(recipient.address), - body, - ), + mailbox.connect(signer).dispatch(destDomain, recipientBytes, body), ) .to.emit(mailbox, 'Dispatch') - .withArgs(id, message); + .withArgs(signer.address, destDomain, recipientBytes, message) + .to.emit(mailbox, 'DispatchId') + .withArgs(utils.messageId(message)); }); it('Returns the id of the dispatched message', async () => { @@ -120,7 +117,15 @@ describe('Mailbox', async () => { }); it('processes a message', async () => { - await expect(mailbox.process('0x', message)).to.emit(mailbox, 'Process'); + await expect(mailbox.process('0x', message)) + .to.emit(mailbox, 'Process') + .withArgs( + originDomain, + utils.addressToBytes32(signer.address), + recipient, + ) + .to.emit(mailbox, 'ProcessId') + .withArgs(id); expect(await mailbox.delivered(id)).to.be.true; }); diff --git a/solidity/update_abis.sh b/solidity/update_abis.sh index c78885073..7d87255b0 100755 --- a/solidity/update_abis.sh +++ b/solidity/update_abis.sh @@ -9,4 +9,4 @@ copy() { jq .abi < artifacts/contracts/"$1".sol/"$CONTRACT_NAME".json > ../rust/chains/hyperlane-ethereum/abis/"$CONTRACT_NAME".abi.json } -copy Mailbox && copy isms/MultisigIsm && copy InterchainGasPaymaster +copy Mailbox && copy InterchainGasPaymaster && copy isms/MultisigIsm diff --git a/typescript/sdk/src/core/HyperlaneCore.ts b/typescript/sdk/src/core/HyperlaneCore.ts index c1dac3bc4..639b2e1f3 100644 --- a/typescript/sdk/src/core/HyperlaneCore.ts +++ b/typescript/sdk/src/core/HyperlaneCore.ts @@ -120,7 +120,7 @@ export class HyperlaneCore< ): Promise { const id = utils.messageId(message.message); const { mailbox, chainConnection } = this.getDestination(message); - const filter = mailbox.filters.Process(id); + const filter = mailbox.filters.ProcessId(id); return new Promise((resolve, reject) => { mailbox.once(filter, (emittedId, event) => { diff --git a/typescript/sdk/src/core/TestCoreApp.ts b/typescript/sdk/src/core/TestCoreApp.ts index c515d77db..25c76f63b 100644 --- a/typescript/sdk/src/core/TestCoreApp.ts +++ b/typescript/sdk/src/core/TestCoreApp.ts @@ -53,16 +53,14 @@ export class TestCoreApp< const dispatchFilter = outbox.filters.Dispatch(); const dispatches = await outbox.queryFilter(dispatchFilter); for (const dispatch of dispatches) { - const message = utils.parseMessage(dispatch.args.message); - const destination = message.destination; + const destination = dispatch.args.destination; if (destination === chainMetadata[origin].id) { throw new Error('Dispatched message to local domain'); } - const destinationChain = DomainIdToChainName[destination]; - const inbox: TestMailbox = - // @ts-ignore - this.getContracts(destinationChain).mailbox.contract; - const delivered = await inbox.delivered(dispatch.args.messageId); + const destinationChain = DomainIdToChainName[destination] as TestChain; + const inbox = this.getContracts(destinationChain).mailbox.contract; + const id = utils.messageId(dispatch.args.message); + const delivered = await inbox.delivered(id); if (!delivered) { const response = await inbox.process('0x', dispatch.args.message); const destinationResponses = responses.get(destinationChain) || []; diff --git a/typescript/sdk/src/core/message.ts b/typescript/sdk/src/core/message.ts index 5376057af..49fda3e32 100644 --- a/typescript/sdk/src/core/message.ts +++ b/typescript/sdk/src/core/message.ts @@ -368,9 +368,9 @@ export class HyperlaneMessage { } /** - * The messageId committed to the tree in the Outbox contract. + * The messageId committed to the tree in the Mailbox contract. */ get id(): string { - return this.dispatch.event.args.messageId; + return utils.messageId(this.dispatch.event.args.message); } }