Skip to content

Commit d683e31

Browse files
Inphiskeletor-spaceman0xDiscotech
authored
interop: Specify deposit handling (#258)
* interop: Specify deposit handling * lint * refine spec; include L1Block upgrade * chore: rename reset to complete * fix: fixes lint reference issues * fix: missing rename of resetIsDeposit * fix: mdbook references * fix: Interop to Isthmus rename * fix: typos Co-authored-by: Disco <[email protected]> * fix: reference L1BlockInterop instead of L1Block Co-authored-by: Disco <[email protected]> * fix: l1_attributes to - * fix: l1-attributes reference to corresponding folder * fix: l1-attributes reference to corresponding folder * fix: l1-attributes reference to corresponding folder * fix: l1-attributes reference to corresponding folder * fix: l1-attributes reference to corresponding folder * fix: remove trailing spaces * fix: remove liq-migration * fix: rename interop to isthmus, remove L1BlockInterop reference --------- Co-authored-by: Skeletor Spaceman <[email protected]> Co-authored-by: Skeletor Spaceman <[email protected]> Co-authored-by: Disco <[email protected]>
1 parent 9342867 commit d683e31

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed

specs/SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
- [Delta](./protocol/delta/overview.md)
4040
- [Span Batches](./protocol/delta/span-batches.md)
4141
- [Ecotone](./protocol/ecotone/overview.md)
42+
- [Derivation](./protocol/ecotone/derivation.md)
43+
- [L1 attributes](./protocol/ecotone/l1-attributes.md)
4244
- [Fjord](./protocol/fjord/overview.md)
4345
- [Execution Engine](./protocol/fjord/exec-engine.md)
4446
- [Derivation](./protocol/fjord/derivation.md)
@@ -53,6 +55,7 @@
5355
- [Messaging](./interop/messaging.md)
5456
- [Predeploys](./interop/predeploys.md)
5557
- [Sequencer](./interop/sequencer.md)
58+
- [Derivation](./interop/derivation.md)
5659
- [Verifier](./interop/verifier.md)
5760
- [Rollup Node P2P](./interop/rollup-node-p2p.md)
5861
- [Fault Proof](./interop/fault-proof.md)

specs/interop/derivation.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Derivation
2+
3+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
4+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5+
**Table of Contents**
6+
7+
- [Overview](#overview)
8+
- [Deposit Context](#deposit-context)
9+
- [Gas Considerations](#gas-considerations)
10+
- [Security Considerations](#security-considerations)
11+
12+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
13+
14+
## Overview
15+
16+
This is an experimental section and may be changed in the future. It is not required
17+
for the initial release.
18+
19+
### Deposit Context
20+
21+
Derivation is extended to create **deposit contexts**, which signifies the execution of a depositing transaction.
22+
A deposit context is scoped to a single block, commencing with the execution of the first deposited transaction
23+
and concluding immediately after the execution of the final deposited transaction within that block.
24+
As such, there is exactly one deposit context per block.
25+
26+
A deposit context is created by two operations:
27+
28+
- An L1 attributes transaction that sets `isDeposit = true` on the `L1Block` contract.
29+
This instantiates a deposit context for the current block.
30+
- An L1 attributes transaction that sets `isDeposit = false`. This destroys the existing deposit context.
31+
32+
These two operations wrap user deposits, such that `isDeposit = true` occurs during the first L1 attributes
33+
transaction and `isDeposit = false` occurs immediately after the last user deposit,
34+
if any exists, or after the first L1 attributes transaction if there are no user deposits.
35+
36+
The order of deposit transactions occurs as follows:
37+
38+
1. L1 attributes transaction calling [`setL1BlockValuesInterop()`](../protocol/ecotone/l1-attributes.md).
39+
1. User deposits
40+
1. L1 attributes transaction calling [`depositsComplete()`](../protocol/ecotone/l1-attributes.md)
41+
42+
### Gas Considerations
43+
44+
There must be sufficient gas available in the block to destroy deposit context.
45+
There's no guarantee on the minimum gas available for the second L1 attributes transaction as the block
46+
may be filled by the other deposit transactions. As a consequence, a deposit context may spill into multiple blocks.
47+
48+
This will be fixed in the future.
49+
50+
## Security Considerations
51+
52+
TODO

specs/interop/predeploys.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Interop Start Timestamp](#interop-start-timestamp)
1313
- [`ExecutingMessage` Event](#executingmessage-event)
1414
- [Reference implementation](#reference-implementation)
15+
- [Deposit Handling](#deposit-handling)
1516
- [`Identifier` Getters](#identifier-getters)
1617
- [L2ToL2CrossDomainMessenger](#l2tol2crossdomainmessenger)
1718
- [`relayMessage` Invariants](#relaymessage-invariants)
@@ -40,6 +41,9 @@
4041
- [L1Block](#l1block)
4142
- [Static Configuration](#static-configuration)
4243
- [Dependency Set](#dependency-set)
44+
- [Deposit Context](#deposit-context)
45+
- [`isDeposit()`](#isdeposit)
46+
- [`depositsComplete()`](#depositscomplete)
4347
- [OptimismMintableERC20Factory](#optimismmintableerc20factory)
4448
- [OptimismMintableERC20](#optimismmintableerc20)
4549
- [Updates](#updates)
@@ -182,6 +186,15 @@ function executeMessage(Identifier calldata _id, address _target, bytes calldata
182186

183187
Note that the `executeMessage` function is `payable` to enable relayers to earn in the gas paying asset.
184188

189+
### Deposit Handling
190+
191+
Any call to the `CrossL2Inbox` that would emit an `ExecutingMessage` event will reverts
192+
if the call is made in a [deposit context](./derivation.md#deposit-context).
193+
The deposit context status can be determined by callling `isDeposit` on the `L1Block` contract.
194+
195+
In the future, deposit handling will be modified to be more permissive.
196+
It will revert only in specific cases where interop dependency resolution is not feasible.
197+
185198
### `Identifier` Getters
186199

187200
The `Identifier` MUST be exposed via `public` getters so that contracts can call back to authenticate
@@ -581,6 +594,28 @@ dependency set called `dependencySet()`. This function MUST return the array of
581594
`L1Block` MUST also provide a public getter to get the dependency set size called `dependencySetSize()`. This function
582595
MUST return the length of the dependency set array.
583596

597+
### Deposit Context
598+
599+
New methods will be added on the `L1Block` contract to interact with [deposit contexts](./derivation.md#deposit-context).
600+
601+
```solidity
602+
function isDeposit() public view returns (bool);
603+
function depositsComplete() public;
604+
```
605+
606+
### `isDeposit()`
607+
608+
Returns true if the current execution occurs in a [deposit context](./derivation.md#deposit-context).
609+
610+
Only the `CrossL2Inbox` is authorized to call `isDeposit`.
611+
This is done to prevent apps from easily detecting and censoring deposits.
612+
613+
#### `depositsComplete()`
614+
615+
Called after processing the first L1 Attributes transaction and user deposits to destroy the deposit context.
616+
617+
Only the `DEPOSITOR_ACCOUNT` is authorized to call `depositsComplete()`.
618+
584619
## OptimismMintableERC20Factory
585620

586621
| Constant | Value |

specs/interop/upgrade.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
55
**Table of Contents**
66

7+
- [L1 Attributes](#l1-attributes)
8+
- [L1 Attributes Predeployed Contract](#l1-attributes-predeployed-contract)
9+
- [Interop L1Block upgrade](#interop-l1block-upgrade)
710
- [Security Considerations](#security-considerations)
811

912
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -30,6 +33,43 @@ The execution payload MUST set `noTxPool` to `true` for this block.
3033

3134
The exact definitions for these upgrade transactions are still to be defined.
3235

36+
## L1 Attributes
37+
38+
On the Interop activation block, and if Interop is not activated at Genesis,
39+
the L1 Attributes Transaction includes a call to `setL1BlockValuesEcotone`.
40+
41+
Every subsequent L1 Attributes transaction should include a call to the new `setL1BlockValuesIsthmus` function.
42+
The input args and encoding of `setL1BlockValuesIsthmus` are identical to `setL1BlockValuesEcotone`.
43+
44+
### L1 Attributes Predeployed Contract
45+
46+
The L1 Attributes predeploy adds a new storage state in addition to the existing ones contained in the
47+
pre-Interop L1 Attributes predeploy:
48+
49+
- `isDeposit` (`bool`) - Set to `true` iff the current execution occurs in a [deposit context](./derivation.md#deposit-context).
50+
51+
`setL1BlockValuesIsthmus` extends the behavior of `setL1BlockValuesEcotone` by additionally setting the
52+
`isDeposit` state storage to `true`.
53+
54+
### Interop L1Block upgrade
55+
56+
The L1 Attributes Predeployed contract, `L1Block.sol`, is upgraded as part of the Interop upgrade.
57+
The version is incremented to `1.3.0` to contain the new `isDeposit` storage slot.
58+
59+
The function called by the L1 attributes transaction depends on the network upgrade:
60+
61+
- Before the Interop activation:
62+
- `setL1BlockValuesEcotone` is called, following the pre-Interop L1 attributes rules.
63+
- At the Interop activation block:
64+
- `setL1BlockValuesEcotone` function MUST be called, except if activated at genesis.
65+
The contract is upgraded later in this block, to support `setL1BlockValuesIsthmus`.
66+
- After the Interop activation:
67+
- `setL1BlockValuesEcotone` function is deprecated and MUST never be called.
68+
- `setL1BlockValuesIsthmus` MUST be called.
69+
70+
The `setL1BlockValuesIsthmus` input parameters are identical to `setL1BlockValuesEcotone` as described in
71+
[L1 Attributes Deposited Transaction Calldata](../protocol/ecotone/l1-attributes.md#l1-attributes-deposited-transaction-calldata).
72+
3373
## Security Considerations
3474

3575
TODO

0 commit comments

Comments
 (0)