Skip to content

Commit 4612168

Browse files
committed
compute cost instead & emit the relayer address
1 parent 6ef55dd commit 4612168

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ecosystem/l2tol2cdm-gasreceipt.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,28 @@ All superchain interop cross domain messages are relayed via the `L2ToL2CrossDom
102102

103103
We include the `block.basefee` and not the `tx.gasprice`, so that the priority fee (included in gasPrice) set by the relaying entity is not included and only the minimum execution costs are computed.
104104

105-
- **Question**: _Should we simply emit the computed cost here rather than the individual parts? Would emitting the gasPrice be useful for someone else building on top?_
105+
- **Question**: _Should we simply emit individual parts instead of the computed cost? Would emitting the baseFee & gasPrice be useful for someone else building on top?_
106106

107107
New Event:
108108

109109
```solidity
110-
event RelayedMessageGasReceipt(bytes32 indexed msgHash, bytes32 indexed rootMsgHash, uint256 indexed depth, address indexed txOrigin, uint256 baseFee, uint256 gasUsed)
110+
event RelayedMessageGasReceipt(bytes32 indexed msgHash, bytes32 indexed rootMsgHash, uint256 indexed depth, address indexed txOrigin, address relayer, uint256 cost)
111111
```
112112

113113
```solidity
114114
function relayMessage(...) {
115115
uint256 _gasLeft = gasLeft()
116116
_ = target.call{ value: msg.value }(message);
117-
uint256 gasUsed = _gasLeft - gasLeft();
117+
uint256 gasUsed = (_gasLeft - gasLeft()) + RELAY_MESSAGE_OVERHEAD;
118+
119+
address relayer = msg.sender;
120+
uint256 cost = block.basefee * gasUsed;
118121
119122
// there will always be populated context when relaying.
120123
(,,bytes ctx memory) = crossDomainMessageContext();
121124
(bytes32 rootMsgHash, address txorigin, uint256 depth) = _decodeContext(ctx);
122-
emit RelayedMessageGasReceipt(msgHash, rootMsgHash, depth, txorigin, block.basefee, gasUsed + RELAY_MESSAGE_OVERHEAD);
125+
126+
emit RelayedMessageGasReceipt(msgHash, rootMsgHash, depth, txorigin, relayer, cost);
123127
}
124128
```
125129

0 commit comments

Comments
 (0)