Skip to content

Commit

Permalink
feat: add eslint and remark linting
Browse files Browse the repository at this point in the history
Adds eslint and remark so we can start linting Markdown files.
First of a few commits that will progressively get everything in
place for having linting happen automatically and blocking PRs
when linting runs fail.
  • Loading branch information
smartcontracts committed Nov 14, 2023
1 parent 18d6876 commit 0ad2d87
Show file tree
Hide file tree
Showing 85 changed files with 6,992 additions and 4,636 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
extends: [
'plugin:mdx/recommended',
],
rules: {
},
overrides: [
{
files: ['pages/**/*.mdx'],
extends: [
'plugin:mdx/recommended'
],
settings: {
'mdx/code-blocks': true,
}
}
]
}
7 changes: 6 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ const withNextra = require('nextra')({
defaultShowCopyCode: true,
})

module.exports = withNextra()
module.exports = {
...withNextra(),
eslint: {
ignoreDuringBuilds: true,
},
}
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
"version": "0.0.1",
"description": "OP Docs",
"scripts": {
"lint": "eslint . --ext mdx",
"dev": "next dev",
"build": "next build",
"start": "next start",
"postbuild": "next-sitemap"
},
"remarkConfig": {
"plugins": [
"remark-lint-no-dead-urls",
"remark-frontmatter",
"remark-preset-lint-consistent",
"remark-preset-lint-recommended",
[
"remark-lint-heading-style",
"atx"
]
]
},
"dependencies": {
"@feelback/react": "^0.3.4",
"next": "^13.5.6",
Expand All @@ -19,6 +32,15 @@
},
"devDependencies": {
"@types/node": "18.11.10",
"eslint": "^8.53.0",
"eslint-plugin-mdx": "^2.2.0",
"remark": "^15.0.1",
"remark-frontmatter": "^5.0.0",
"remark-lint-heading-style": "^3.1.2",
"remark-lint-list-item-indent": "^3.1.2",
"remark-lint-no-dead-urls": "^1.1.0",
"remark-preset-lint-consistent": "^5.1.2",
"remark-preset-lint-recommended": "^6.1.3",
"typescript": "^4.9.5"
}
}
18 changes: 8 additions & 10 deletions pages/cex-wallet-developers/cex-support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You connect to OP Mainnet the same way you do to Ethereum, by connecting to a JS

### Endpoints

You can choose between our public endpoints, which are rate limited, and endpoints from [infrastructure providers](/op-networks). Given rate throughput limits, we recommend using a private rpc provider for both mainnet and testnet use cases.
You can choose between our public endpoints, which are rate limited, and endpoints from [infrastructure providers](/op-networks). Given rate throughput limits, we recommend using a private rpc provider for both mainnet and testnet use cases.

### ETH balance

Expand All @@ -27,37 +27,35 @@ For example, looking at the **SNX** token, we get these addresses:

To get the total SNX balance of a user that uses OP Mainnet you need to:

1. Connect to a standard Ethereum endpoint and send a `balanceOf` query to address `0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f`.
1. Connect to an OP Mainnet endpoint and send a `balanceOf` query to address `0x8700daec35af8ff88c16bdf0418774cb3d7599b4`.

1. Connect to a standard Ethereum endpoint and send a `balanceOf` query to address `0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f`.
2. Connect to an OP Mainnet endpoint and send a `balanceOf` query to address `0x8700daec35af8ff88c16bdf0418774cb3d7599b4`.

## Deposits and withdrawals within OP Mainnet

The ERC-20 contracts on OP Mainnet function the same way they do on Ethereum, so you can use your existing code for withdrawals and deposits. Just connect to an OP Mainnet endpoint.


### Transaction fees

Most of the cost of an OP Mainnet transaction is not the gas consumed by the transaction itself (which is rarely above 0.001 gwei per gas), but the cost of writing the transaction in Ethereum. That cost is deducted automatically from the user's balance on OP Mainnet. If you charge your users the cost of withdrawals, you have to account for it.

You can read more about [transaction fees](/transaction-fees/overview).
The relevant code is [here](/tools/javascript/sdk-estimate-gas).


## Deposits and withdrawals across chains

As a centralized exchange, there will be times that withdrawals of ETH or an ERC-20 token on either OP Mainnet or Ethereum exceed deposits and you need to transfer assets.
To do that you use a bridge or a gateway.
We have a [standard gateway](https://app.optimism.io/bridge) that receives assets on L1 (Ethereum mainnet), and mints the equivalent asset on OP Mainnet.
As a centralized exchange, there will be times that withdrawals of ETH or an ERC-20 token on either OP Mainnet or Ethereum exceed deposits and you need to transfer assets.
To do that you use a bridge or a gateway.
We have a [standard gateway](https://app.optimism.io/bridge) that receives assets on L1 (Ethereum mainnet), and mints the equivalent asset on OP Mainnet.
When a user wants to withdraw the assets back to L1, the bridge burns the asset on L2 and releases it to the user on L1. If you want to use this gateway automatically, [follow this tutorial for ETH](/dapp-developers/bridging/cross-dom-bridge-eth) or [this one for ERC-20 tokens](/dapp-developers/bridging/cross-dom-bridge-erc20).

Note that while L1 to L2 transactions typically take minutes, L2 to L1 transaction on the gateway require [a seven day challenge period](https://help.optimism.io/hc/en-us/articles/4411895558171-Why-do-I-need-to-wait-a-week-when-moving-assets-out-of-Optimism-).

Alternatively, you can use a [third party bridge](https://www.optimism.io/apps/bridges). These bridges usually rely on liquidity pools to allow for faster withdrawals and support multiple L2 chains. However, their token selection might be more limited and they may not be as decentralized as our gateway.

When an ERC-20 token does not have an OP Mainnet equivalent you can create one.
When an ERC-20 token does not have an OP Mainnet equivalent you can create one.
If there is no need for custom business logic, you can [follow the steps in this tutorial](/dapp-developers/bridging/standard-bridge-standard-token).
If you need to implement some kind of custom logic, [see this tutorial](/dapp-developers/bridging/standard-bridge-custom-token).

## Audit reports

For a full list of audit reports visit [GitHub](https://github.com/ethereum-optimism/optimism/tree/develop/docs/security-reviews).
34 changes: 12 additions & 22 deletions pages/cex-wallet-developers/wallet-support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,64 +30,54 @@ For example, looking at the **SNX** token, the [Superchain token list](https://s
| 5 | Goerli (test network) | 0x51f44ca59b867E005e48FA573Cb8df83FC7f7597
| 420 | OP Goerli (test network) | 0x2E5ED97596a8368EB9E44B1f3F25B2E813845303



## Transaction status

A transaction in OP Mainnet can be in one of two states:

1. **Sequencer Confirmed**: The transaction has been accepted by the sequencer on OP Mainnet (L2)
2. **Confirmed Onchain**: The transaction has been written to Ethereum (L1)
1. **Sequencer Confirmed**: The transaction has been accepted by the sequencer on OP Mainnet (L2)
2. **Confirmed Onchain**: The transaction has been written to Ethereum (L1)

We're still working on the tooling to easily detect when a given transaction has been published to Ethereum.
For the moment, we recommend wallets consider transactions final after they are "Sequencer Confirmed".
Transactions are considered "Sequencer Confirmed" as soon as their transaction receipt shows at least one confirmation.



## Transaction fees

In OP Mainnet transaction fees include both an [L1 data fee](/transaction-fees/overview#estimating-the-l1-data-fee) and an [L2 execution fee](/transaction-fees/overview#the-l2-execution-fee).
In OP Mainnet transaction fees include both an [L1 data fee](/transaction-fees/overview#estimating-the-l1-data-fee) and an [L2 execution fee](/transaction-fees/overview#the-l2-execution-fee).
To display the entire estimated cost of a transaction to your users we recommend you [use the SDK](/tools/javascript/sdk-estimate-gas).
We **highly recommend** displaying fees on OP Mainnet (and any other OP Stack chain that uses the same mechanism) as one unified fee to minimize user confusion.


In Bedrock we support [EIP 1559](https://eips.ethereum.org/EIPS/eip-1559).
Therefore, the L2 execution fee is composed of two components: a fixed (per-block) base fee and a user selected priority fee.


### Base fee

[The EIP 1559 parameters](/differences-op-stack#pre--EIP--155-support) have different values in OP Mainnet (and many other OP Stack chains) than those on L1 Ethereum.
As a result, in every block the base fee can be between 98% and 110% of the previous value.
As a result, in every block the base fee can be between 98% and 110% of the previous value.
As blocks are produced every two seconds, the base fee can be between 54% and 1,745% of the value a minute earlier.
If it takes the user fourteen seconds to approve the transaction in the wallet, the base fee can almost double in that time.

The base fee specified in the transaction is not necessarily the base fee that the user will pay, *it is merely an upper limit to that amount*.
In most cases, it makes sense to specify a much higher base fee than the current value, to ensure acceptance.
In most cases, it makes sense to specify a much higher base fee than the current value, to ensure acceptance.

For example, as I'm writing this, ETH is about $2000, and a cent is about 5000 gwei.
Assuming 20% of a cent is an acceptable base fee for a transaction, and that the transaction is a big 5,000,000 gas one (at the target block size), this gives us a base fee of 200,000 wei.
That would be the value to put in the transaction, even though the L2 base fee (as I'm writing this) is 2,420 wei.
For example, as I'm writing this, ETH is about $2000, and a cent is about 5000 gwei.
Assuming 20% of a cent is an acceptable base fee for a transaction, and that the transaction is a big 5,000,000 gas one (at the target block size), this gives us a base fee of 200,000 wei.
That would be the value to put in the transaction, even though the L2 base fee (as I'm writing this) is 2,420 wei.

<Callout>
Up to date information

You can get the current L2 base fee [in the gas tracker dashboard](https://optimism.io/gas-tracker).
Up to date information

You can get the current L2 base fee [in the gas tracker dashboard](https://optimism.io/gas-tracker).
</Callout>


### Priority fee

In contrast to the base fee, the priority fee in the transaction is the amount that the user pays, and therefore it makes sense to keep it as low as possible.
If you already have estimating code you use for L1 Ethereum, you can just use that.

Note that on OP Mainnet the priority fee tends to be very low.
Note that on OP Mainnet the priority fee tends to be very low.
As I am writing this, a priority fee of 500 wei is sufficient ([see here](https://optimism.io/gas-tracker) to get the current values).



### Sending "max" ETH

Many wallets allow users to send the maximum amount of ETH available in the user's balance.
Expand All @@ -96,4 +86,4 @@ You **MUST** deduct both the L2 execution fee and the L1 data fee or the charged

### Displaying the gas prices

If you want to display the current gas prices, you can use [`eth_gasPrice`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gasprice).
If you want to display the current gas prices, you can use [`eth_gasPrice`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gasprice).
23 changes: 7 additions & 16 deletions pages/chain-operators/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import { Callout } from 'nextra/components'

The OP Stack is a flexible platform with various configuration values that you can tweak to fit your specific needs. If you’re looking to fine-tune your deployment, look no further.

<Callout type="warning">
Work in Progress

OP Stack configuration is an active work in progress and will likely evolve significantly as time goes on. If something isn’t working about your configuration, check back with this page to see if anything has changed.
<Callout type="warning">
Work in Progress

OP Stack configuration is an active work in progress and will likely evolve significantly as time goes on. If something isn’t working about your configuration, check back with this page to see if anything has changed.
</Callout>

## New Blockchain Configuration

New OP Stack blockchains are currently configured with a JSON file inside the Optimism repository. The file is `<optimism repository>/packages/contracts-bedrock/deploy-config/<chain name>.json`. For example, [this is the configuration file for the tutorial blockchain](https://github.com/ethereum-optimism/optimism/blob/129032f15b76b0d2a940443a39433de931a97a44/packages/contracts-bedrock/deploy-config/getting-started.json).

New OP Stack blockchains are currently configured with a JSON file inside the Optimism repository. The file is `<optimism repository>/packages/contracts-bedrock/deploy-config/<chain name>.json`. For example, [this is the configuration file for the tutorial blockchain](https://github.com/ethereum-optimism/optimism/blob/129032f15b76b0d2a940443a39433de931a97a44/packages/contracts-bedrock/deploy-config/getting-started.json).

### Admin accounts

Expand All @@ -24,7 +22,6 @@ New OP Stack blockchains are currently configured with a JSON file inside the Op
| `controller` | L1 Address | Address that will own the `SystemDictator` contract and can therefore control the flow of the deployment or upgrade. | It is recommended to have a single admin account to retain a common security model. |
| `proxyAdminOwner` | L2 Address | Address that will own the `ProxyAdmin` contract on L2. The L2 `ProxyAdmin` contract owns all of the `Proxy` contracts for every predeployed contract in the range `0x42...0000` to `0x42..2048`. This makes predeployed contracts easily upgradeable. | It is recommended to have a single admin account to retain a common security model. |


### Fee recipients

| Key | Type | Description | Default value |
Expand Down Expand Up @@ -55,25 +52,23 @@ New OP Stack blockchains are currently configured with a JSON file inside the Op
| --- | --- | --- | --- |
| `numDeployConfirmations` | Number of blocks | Number of confirmations to wait when deploying smart contracts to L1. | 1 |
| `l1StartingBlockTag` | Block hash | Block tag for the L1 block where the L2 chain will begin syncing from. Generally recommended to use a finalized block to avoid issues with reorgs. | |
| `l1ChainID` | Number | Chain ID of the L1 chain. | 1 for L1 Ethereum mainnet, <br></br> 5 for the Goerli test network. <br></br> [See here for other blockchains](https://chainlist.org/?testnets=true). |
| `l1ChainID` | Number | Chain ID of the L1 chain. | 1 for L1 Ethereum mainnet, <br /> 5 for the Goerli test network. <br /> [See here for other blockchains](https://chainlist.org/?testnets=true). |
| `l2ChainID` | Number | Chain ID of the L2 chain. | 42069 |


### Blocks

These fields apply to L2 blocks: Their timing, when do they need to be written to L1, and how they get written.

| Key | Type | Description | Default value |
| --- | --- | --- | --- |
| `l2BlockTime` | Number of seconds | Number of seconds between each L2 block. Must be < = L1 block time (12 on mainnet and Goerli) | 2 |
| `l2BlockTime` | Number of seconds | Number of seconds between each L2 block. Must be \< = L1 block time (12 on mainnet and Goerli) | 2 |
| `maxSequencerDrift` | Number of seconds | How far the L2 timestamp can differ from the actual L1 timestamp | 600 (10 minutes) |
| `sequencerWindowSize` | Number of blocks | Maximum number of L1 blocks that a Sequencer can wait to incorporate the information in a specific L1 block. For example, if the window is `10` then the information in L1 block `n` must be incorporated by L1 block `n+10`. | 3600 (12 hours) |
| `channelTimeout` | Number of blocks | Maximum number of L1 blocks that a transaction channel frame can be considered valid. A transaction channel frame is a chunk of a compressed batch of transactions. After the timeout, the frame is dropped. | 300 (1 hour) |
| `p2pSequencerAddress` | L1 Address | Address of the key that the Sequencer uses to sign blocks on the p2p network. | Sequencer, an address for which you own the private key |
| `batchInboxAddress` | L1 Address | Address that Sequencer transaction batches are sent to on L1. | 0xff00…0042069 |
| `batchSenderAddress` | L1 Address | Address of the account that nodes will filter for when searching for Sequencer transaction batches being sent to the `batchInboxAddress`. Can be updated later via the `SystemConfig` contract on L1. | Batcher, an address for which you own the private key |


### Proposal fields

These fields apply to output root proposals.
Expand All @@ -87,8 +82,6 @@ These fields apply to output root proposals.
| `l2OutputOracleProposer` | L1 Address | Address that is allowed to submit output proposals to the `L2OutputOracle` contract. Will be removed when we have permissionless proposals. | |
| `l2OutputOracleChallenger` | L1 Address | Address that is allowed to challenge output proposals submitted to the `L2OutputOracle`. Will be removed when we have permissionless challenges. | It is recommended to have a single admin account to retain a common security model. |



### L1 data fee

These fields apply to the cost of the [L1 data fee](/transaction-fees/overview#the-l1-data-fee) for L2 transactions.
Expand All @@ -98,7 +91,6 @@ These fields apply to the cost of the [L1 data fee](/transaction-fees/overview#t
| `gasPriceOracleOverhead` | Number | Fixed L1 gas overhead per transaction. Default value will likely be adjusted with more information from the Optimism Goerli deployment. | 2100 |
| `gasPriceOracleScalar` | Number | Dynamic L1 gas overhead per transaction, given in 6 decimals. Default value of 1000000 implies a dynamic gas overhead of exactly 1x (no overhead). | 1000000 |


### EIP 1559 gas algorithm

These fields apply to [the EIP 1559 algorithm](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) used for the [L2 execution costs](/transaction-fees/overview/#the-l2-execution-fee) of transactions on the blockchain.
Expand All @@ -110,7 +102,6 @@ These fields apply to [the EIP 1559 algorithm](https://github.com/ethereum/EIPs/
| `l2GenesisBlockGasLimit` | String | Initial block gas limit, represented as a hex string. Default is 25m, implying a 2.5m target when combined with a 10x elasticity. | 0x17D7840 | |
| `l2GenesisBlockBaseFeePerGas` | String | Initial base fee, used to avoid an unstable EIP1559 calculation out of the gate. Initial value is 1 gwei. | 0x3b9aca00 | |


### Governance token

The governance token is a side-effect of use of the OP Stack in the Optimism Mainnet network. It may not be included by default in future releases.
Expand All @@ -119,4 +110,4 @@ The governance token is a side-effect of use of the OP Stack in the Optimism Mai
| --- | --- | --- | --- |
| `governanceTokenOwner` | L2 Address | Address that will own the token contract deployed by default to every OP Stack based chain. | |
| `governanceTokenSymbol` | String | Symbol for the token deployed by default to each OP Stack chain. | OP |
| `governanceTokenName` | String | Name for the token deployed by default to each OP Stack chain. | Optimism |
| `governanceTokenName` | String | Name for the token deployed by default to each OP Stack chain. | Optimism |
Loading

0 comments on commit 0ad2d87

Please sign in to comment.