You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/interop/estimate-costs.mdx
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,8 +36,6 @@ There are several factors that determine the cost of an [interop transaction](/i
36
36
You can either use [`CrossL2Inbox`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/CrossL2Inbox.sol) directly, or use the cross domain messenger, [`L2ToL2CrossDomainMessenger`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol), which uses `CrossL2Inbox` internally.
37
37
* The transaction type.
38
38
Every interop message has two transactions, an [initiating message](/interop/message-passing#initiating-message) in a transaction to the source chain, and an [executing message](/interop/message-passing#executing-message) in the destination chain.
39
-
* Whether autorelay is turned on.
40
-
When enabled for a specific chain, the `L2ToL2CrossDomainMessenger` still executes a message, but the chain operator covers the execution costs.
41
39
42
40
## CrossL2Inbox
43
41
@@ -73,7 +71,7 @@ Where:
73
71
*`n` = number of data bytes in the log entry
74
72
75
73
Every transaction posted costs at least *21,000* gas.
76
-
In comparison, the hashing operation costs approximately [*30+0.2×\<number of bytes>*](https://www.evm.codes/?fork=cancun#20), which is negligible by comparison.
74
+
The hashing operation costs approximately [*30+0.2×\<number of bytes>*](https://www.evm.codes/?fork=cancun#20), which is negligible by comparison.
77
75
We can usually ignore the [memory expansion cost](https://www.evm.codes/about#memoryexpansion), unless the validating contract uses a really large amount of memory.
78
76
79
77
The cost of using the message is beyond the scope here, because it depends on your application.
@@ -94,8 +92,8 @@ This would typically be written to previously empty storage, so the cost is *22,
94
92
Then it [increments the nonce value](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol#L158).
95
93
Overwriting previously used storage (which means storage where the present value is *not* zero) only costs *5,000* gas.
96
94
97
-
So, the initiating message costs a little over *27,100* gas, plus the negligible cost of emitting the log message, a few if statements, etc.
98
-
Of course, it is created as part of a transaction, so we might want to include the *21,000* transaction cost too.
95
+
Hence, the gas cost for creating an initiating message is approximately *27,100* gas, plus minor overhead for log emission and contract operations.
96
+
Note that this estimate excludes the 21,000 gas base transaction cost, which applies to all transactions.
0 commit comments