Skip to content

Commit

Permalink
deploy: 7722954
Browse files Browse the repository at this point in the history
  • Loading branch information
tynes committed Aug 1, 2024
1 parent f245837 commit 978eeb5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
15 changes: 8 additions & 7 deletions interop/predeploys.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,16 @@ <h4 id="_target"><a class="header" href="#_target"><code>_target</code></a></h4>
<h3 id="executingmessage-event"><a class="header" href="#executingmessage-event"><code>ExecutingMessage</code> Event</a></h3>
<p>The <code>ExecutingMessage</code> event represents an executing message. It MUST be emitted on every call
to <code>executeMessage</code>.</p>
<pre><code class="language-solidity">event ExecutingMessage(bytes,bytes);
<pre><code class="language-solidity">event ExecutingMessage(bytes32 indexed msgHash, Identifier identifier);
</code></pre>
<p>The data encoded in the event contains the <code>Identifier</code> and the <code>msg</code>.
<p>The data encoded in the event contains the keccak hash of the <code>msg</code> and the <code>Identifier</code>.
The following pseudocode shows the deserialization:</p>
<pre><code class="language-solidity">(bytes memory identifier, bytes memory log) = abi.decode(log.data, (bytes, bytes));
Identifier id = abi.decode(identifier, (Identifier));
<pre><code class="language-solidity">bytes32 msgHash = log.topics[1];
Identifier identifier = abi.decode(log.data, (Identifier));
</code></pre>
<p>It is not possible to use solidity structs directly in events, which is why it is ABI encoded
into <code>bytes</code> first.</p>
<p>Emitting the hash of the message is more efficient than emitting the
message in its entirety. Equality with the initiating message can be handled off-chain through
hash comparison.</p>
<h3 id="reference-implementation"><a class="header" href="#reference-implementation">Reference implementation</a></h3>
<p>A simple implementation of the <code>executeMessage</code> function is included below.</p>
<pre><code class="language-solidity">function executeMessage(Identifier calldata _id, address _target, bytes calldata _msg) public payable {
Expand All @@ -297,7 +298,7 @@ <h3 id="reference-implementation"><a class="header" href="#reference-implementat

require(success);

emit ExecutingMessage(abi.encode(_id), _msg);
emit ExecutingMessage(keccak256(_msg), _id);
}
</code></pre>
<p>Note that the <code>executeMessage</code> function is <code>payable</code> to enable relayers to earn in the gas paying asset.</p>
Expand Down
5 changes: 3 additions & 2 deletions interop/sequencer.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ <h4 id="direct-dependency-confirmation"><a class="header" href="#direct-dependen

for log in receipt.logs:
if is_executing_message(log):
id, message = abi.decode(log.data)
id = abi.decode(log.data)
messageHash = log.topics[1]

# assumes there is a client for each chain in the dependency set
eth = clients[id.chainid]
Expand All @@ -282,7 +283,7 @@ <h4 id="direct-dependency-confirmation"><a class="header" href="#direct-dependen
if len(log) == 0:
return False

if message != encode(log[0]):
if messageHash != hash(encode(log[0])):
return False

block = eth.getBlockByNumber(id.blocknumber)
Expand Down
20 changes: 11 additions & 9 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -8619,15 +8619,16 @@ <h4 id="_target"><a class="header" href="#_target"><code>_target</code></a></h4>
<h3 id="executingmessage-event"><a class="header" href="#executingmessage-event"><code>ExecutingMessage</code> Event</a></h3>
<p>The <code>ExecutingMessage</code> event represents an executing message. It MUST be emitted on every call
to <code>executeMessage</code>.</p>
<pre><code class="language-solidity">event ExecutingMessage(bytes,bytes);
<pre><code class="language-solidity">event ExecutingMessage(bytes32 indexed msgHash, Identifier identifier);
</code></pre>
<p>The data encoded in the event contains the <code>Identifier</code> and the <code>msg</code>.
<p>The data encoded in the event contains the keccak hash of the <code>msg</code> and the <code>Identifier</code>.
The following pseudocode shows the deserialization:</p>
<pre><code class="language-solidity">(bytes memory identifier, bytes memory log) = abi.decode(log.data, (bytes, bytes));
Identifier id = abi.decode(identifier, (Identifier));
<pre><code class="language-solidity">bytes32 msgHash = log.topics[1];
Identifier identifier = abi.decode(log.data, (Identifier));
</code></pre>
<p>It is not possible to use solidity structs directly in events, which is why it is ABI encoded
into <code>bytes</code> first.</p>
<p>Emitting the hash of the message is more efficient than emitting the
message in its entirety. Equality with the initiating message can be handled off-chain through
hash comparison.</p>
<h3 id="reference-implementation"><a class="header" href="#reference-implementation">Reference implementation</a></h3>
<p>A simple implementation of the <code>executeMessage</code> function is included below.</p>
<pre><code class="language-solidity">function executeMessage(Identifier calldata _id, address _target, bytes calldata _msg) public payable {
Expand All @@ -8650,7 +8651,7 @@ <h3 id="reference-implementation"><a class="header" href="#reference-implementat

require(success);

emit ExecutingMessage(abi.encode(_id), _msg);
emit ExecutingMessage(keccak256(_msg), _id);
}
</code></pre>
<p>Note that the <code>executeMessage</code> function is <code>payable</code> to enable relayers to earn in the gas paying asset.</p>
Expand Down Expand Up @@ -9016,7 +9017,8 @@ <h4 id="direct-dependency-confirmation"><a class="header" href="#direct-dependen

for log in receipt.logs:
if is_executing_message(log):
id, message = abi.decode(log.data)
id = abi.decode(log.data)
messageHash = log.topics[1]

# assumes there is a client for each chain in the dependency set
eth = clients[id.chainid]
Expand All @@ -9029,7 +9031,7 @@ <h4 id="direct-dependency-confirmation"><a class="header" href="#direct-dependen
if len(log) == 0:
return False

if message != encode(log[0]):
if messageHash != hash(encode(log[0])):
return False

block = eth.getBlockByNumber(id.blocknumber)
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

0 comments on commit 978eeb5

Please sign in to comment.