Skip to content

Commit

Permalink
specs: cleanup (#521)
Browse files Browse the repository at this point in the history
Cleanup more interop derivation specs, add missing changes, delete dead
code.
  • Loading branch information
tynes authored Jan 17, 2025
1 parent 640e0f8 commit c4015e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 57 deletions.
18 changes: 12 additions & 6 deletions specs/interop/derivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
**Table of Contents**

- [Overview](#overview)
- [Invariants](#invariants)
- [Invariants](#invariants)
- [L1 Attributes Transaction](#l1-attributes-transaction)
- [Deposit Context](#deposit-context)
- [Opening the deposit context](#opening-the-deposit-context)
- [Closing the deposit context](#closing-the-deposit-context)
Expand All @@ -25,7 +26,7 @@ New derivation rules are added to guaranteee integrity of cross chain messages.
The fork choice rule is updated to fork out unsafe blocks that contain invalid
executing messages.

### Invariants
## Invariants

- An executing message MUST have a corresponding initiating message
- The initiating message referenced in an executing message MUST come from a chain in its dependency set
Expand All @@ -37,12 +38,17 @@ because it includes invalid executing messages MUST be replaced by a deposits on
block height. This guarantees progression of the chain, ensuring that an infinite loop of processing
the same block in the proof system is not possible.

## L1 Attributes Transaction

The L1 attributes transaction is updated to a new entrypoint on the `L1Block` contract.

### Deposit Context

Derivation is extended to create **deposit contexts**, which signifies the execution of a depositing transaction.
A deposit context is scoped to a single block, commencing with the execution of the first deposited transaction
and concluding immediately after the execution of the final deposited transaction within that block.
As such, there is exactly one deposit context per block.
Derivation is extended to create **deposit contexts**, which signify the execution of a depositing transaction.
A deposit context is scoped to a single block, opening with the first deposited transaction and closing after
the execution of the final deposited transaction. As such, there is exactly one deposit context per block.
The deposit context exists to give legibility within the EVM that execution is happening in the context of
a deposit transaction. See [`isDeposit()`](./predeploys.md#isdeposit) for more information.

The order of deposit transactions occurs as follows:

Expand Down
69 changes: 18 additions & 51 deletions specs/interop/predeploys.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
- [OptimismSuperchainERC20Beacon](#optimismsuperchainerc20beacon)
- [Overview](#overview-2)
- [L1Block](#l1block)
- [Static Configuration](#static-configuration)
- [Dependency Set](#dependency-set)
- [L1 Atributes Transaction](#l1-atributes-transaction)
- [Deposit Context](#deposit-context)
- [`isDeposit()`](#isdeposit)
- [`depositsComplete()`](#depositscomplete)
Expand Down Expand Up @@ -466,60 +465,28 @@ The implementation address gets deduced similarly to the `GasPriceOracle` addres
| Address | `0x4200000000000000000000000000000000000015` |
| `DEPOSITOR_ACCOUNT` | `0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001` |

### Static Configuration
### L1 Atributes Transaction

The `L1Block` contract MUST include method `setConfig(ConfigType, bytes)` for setting the system's static values, which
are defined as values that only change based on the chain operator's input. This function serves to reduce the size of
the L1 Attributes transaction, as well as to reduce the need to add specific one off functions. It can only be called by
`DEPOSITOR_ACCOUNT`.

The `ConfigType` enum is defined as follows:
A new entrypoint on the `L1Block` contract is added that is used to open the [deposit context](./derivation.md#deposit-context).

```solidity
enum ConfigType {
SET_GAS_PAYING_TOKEN,
ADD_DEPENDENCY,
REMOVE_DEPENDENCY
}
function setL1AttributesInterop() external;
```

The second argument to `setConfig` is a `bytes` value that is ABI encoded with the necessary values for the `ConfigType`.

| ConfigType | Value |
| ---------------------- | ------------------------------------------- |
| `SET_GAS_PAYING_TOKEN` | `abi.encode(token, decimals, name, symbol)` |
| `ADD_DEPENDENCY` | `abi.encode(chainId)` |
| `REMOVE_DEPENDENCY` | `abi.encode(chainId)` |

where

- `token` is the gas paying token's address (type `address`)

- `decimals` is the gas paying token's decimals (type `uint8`)

- `name` is the gas paying token's name (type `bytes32`)

- `symbol` is the gas paying token's symbol (type `bytes32`)

- `chainId` is the chain id intended to be added or removed from the dependency set (type `uint256`)

Calls to `setConfig` MUST originate from `SystemConfig` and are forwarded to `L1Block` by `OptimismPortal`.

### Dependency Set

`L1Block` is updated to include the set of allowed chains. These chains are added and removed through `setConfig` calls
with `ADD_DEPENDENCY` or `REMOVE_DEPENDENCY`, respectively. The maximum size of the dependency set is `type(uint8).max`,
and adding a chain id when the dependency set size is at its maximum MUST revert. If a chain id already in the
dependency set, such as the chain's chain id, is attempted to be added, the call MUST revert. If a chain id that is not
in the dependency set is attempted to be removed, the call MUST revert. If the chain's chain id is attempted to be
removed, the call also MUST revert.

`L1Block` MUST provide a public getter to check if a particular chain is in the dependency set called
`isInDependencySet(uint256)`. This function MUST return true when a chain id in the dependency set, or the chain's chain
id, is passed in as an argument, and false otherwise. Additionally, `L1Block` MUST provide a public getter to return the
dependency set called `dependencySet()`. This function MUST return the array of chain ids that are in the dependency set.
`L1Block` MUST also provide a public getter to get the dependency set size called `dependencySetSize()`. This function
MUST return the length of the dependency set array.
WARNING: the function name is subject to change depending on the name of the network upgrade.

| Input arg | Type | Calldata bytes | Segment |
| ----------------- | ------- | -------------- | ------- |
| {0xfe8f4eaf} | | 0-3 | n/a |
| baseFeeScalar | uint32 | 4-7 | 1 |
| blobBaseFeeScalar | uint32 | 8-11 | |
| sequenceNumber | uint64 | 12-19 | |
| l1BlockTimestamp | uint64 | 20-27 | |
| l1BlockNumber | uint64 | 28-35 | |
| basefee | uint256 | 36-67 | 2 |
| blobBaseFee | uint256 | 68-99 | 3 |
| l1BlockHash | bytes32 | 100-131 | 4 |
| batcherHash | bytes32 | 132-163 | 5 |

### Deposit Context

Expand Down

0 comments on commit c4015e3

Please sign in to comment.