-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f559fca
commit ba02231
Showing
4 changed files
with
139 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,98 @@ | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
**Table of Contents** | ||
|
||
- [Optimism Portal](#optimism-portal) | ||
- [Overview (What this contract is actually supposed to do)](#overview-what-this-contract-is-actually-supposed-to-do) | ||
- [Overview](#overview) | ||
- [Perspective](#perspective) | ||
- [Contract Dependencies](#contract-dependencies) | ||
- [AnchorStateRegistry](#anchorstateregistry) | ||
- [SuperchainConfig](#superchainconfig) | ||
- [Contract Dependents](#contract-dependents) | ||
- [Definitions](#definitions) | ||
- [Top-Level Invariants](#top-level-invariants) | ||
- [Function-Level Invariants](#function-level-invariants) | ||
- [Initialize the thing somehow](#initialize-the-thing-somehow) | ||
- [Prove a withdrawal transaction](#prove-a-withdrawal-transaction) | ||
- [Finalize a withdrawal transaction](#finalize-a-withdrawal-transaction) | ||
- [`initialize`](#initialize) | ||
- [`proveWithdrawalTransaction`](#provewithdrawaltransaction) | ||
- [`finalizeWithdrawalTransaction`](#finalizewithdrawaltransaction) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# Optimism Portal | ||
|
||
## Overview (What this contract is actually supposed to do) | ||
## Overview | ||
|
||
### Perspective | ||
|
||
This contract is responsible for moderating [withdrawals](../../protocol/withdrawals.md). | ||
|
||
### Contract Dependencies | ||
|
||
#### AnchorStateRegistry | ||
|
||
Depends on AnchorStateRegistry to correctly report: | ||
|
||
- Whether a game is an **invalid game**. | ||
- Whether a game is a **valid game**. | ||
|
||
#### SuperchainConfig | ||
|
||
Depends on SuperchainConfig to correctly report: | ||
|
||
- System pause status. | ||
- Guardian address. | ||
|
||
### Contract Dependents | ||
|
||
TODO | ||
|
||
## Definitions | ||
|
||
- **Authorized input** | ||
- An input for which there is social consensus, i.e. coming from governance. | ||
- **Proven withdrawal** | ||
- **Finalized withdrawal** | ||
|
||
## Top-Level Invariants | ||
|
||
- A withdrawal transaction must be proven against a game that is not `invalid`. | ||
- A withdrawal transaction must be finalized against a game that is `valid`. | ||
- A withdrawal transaction must be **proven** against a game that is not `invalid`. | ||
- A withdrawal transaction may only be finalized against a game that is `valid`. | ||
- Implicit in this is that a withdrawal transaction may only be finalized after the proof maturity delay has passed. | ||
- A withdrawal transaction may only be finalized if it has already been **proven**. | ||
- A withdrawal transaction must be used only once to finalize a withdrawal. | ||
- A withdrawal can only be finalized if it has been proven. | ||
- A withdrawal transaction that is finalized must attempt execution. | ||
|
||
# Function-Level Invariants | ||
|
||
## Initialize the thing somehow | ||
## `initialize` | ||
|
||
- Proof maturity delay seconds must be an **authorized input**. | ||
- Anchor state registry must be an **authorized input**. | ||
- Dispute game factory must be an **authorized input**. | ||
- Superchain config must be an **authorized input**. | ||
- System config must be an **authorized input**. | ||
|
||
## `proveWithdrawalTransaction` | ||
|
||
Proves a withdrawal transaction. | ||
|
||
- Withdrawal game must not be an **invalid game**. | ||
- Withdrawal transaction's target must not be the OptimismPortal address. | ||
- Withdrawal game's root claim must be equal to the hashed outputRootProof input. | ||
- Must verify that the hash of this withdrawal is stored in the L2toL1MessagePasser contract on L2. | ||
- A withdrawal can only be proven once unless the dispute game it proved against resolves against the favor of the root claim. | ||
- Must add proof submitter to the list of proof submitters for this withdrawal hash. | ||
|
||
- Need an **authorized** input for proof maturity delay seconds. | ||
- Need an **authorized** reference to the anchor state registry. | ||
- Need an **authorized** reference to the dispute game factory. | ||
- Need an **authorized** input to system config. | ||
- Need an **authorized** reference to superchain config. | ||
## `finalizeWithdrawalTransaction` | ||
|
||
## Prove a withdrawal transaction | ||
Finalizes a withdrawal transaction that has already been proven. | ||
|
||
## Finalize a withdrawal transaction | ||
- Withdrawal transaction must have already been proven. | ||
- The proof maturity delay duration must have elapsed between the time the withdrawal was proven and this call for its finalization. | ||
- The time the withdrawal was proven must be greater than the time at which the withdrawal's game was created. | ||
- Withdrawal transaction must not have been finalized before. | ||
- The game upon which the withdrawal proof is based must be a **valid game**. | ||
- Function must register the withdrawal as finalized. | ||
- Function must revert when system is paused. | ||
- TODO: withdrawal tx invariants (can't call token contract, exact balance must be transferred, estimator should revert for gas estimation) | ||
- If these invariants are met, function must attempt execution of the withdrawal transaction. |