Optimism 백서

Optimism

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 38쪽

rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_sequencerHealthy SequencerHealthy returns true if the sequencer is healthy. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_sequencerHealthy","params":[],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_sequencerHealthy --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_leader <Info> API related to consensus. </Info> Leader returns true if the server is the leader. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_leader","params":[],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_leader --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_leaderWithID <Info> API related to consensus. </Info> LeaderWithID returns the current leader's server info. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_leaderWithID","params":[],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_leaderWithID --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_addServerAsVoter <Info> API related to consensus. </Info> AddServerAsVoter adds a server as a voter to the cluster. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_addServerAsVoter","params":[<raft-server-id>, <raft-consensus-addr>, <raft-config-version>],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_addServerAsVoter <raft-server-id> <raft-consensus-addr> <raft-config-version> --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_addServerAsNonvoter <Info> API related to consensus. </Info> AddServerAsNonvoter adds a server as a non-voter to the cluster. non-voter The non-voter will not participate in the leader election. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_addServerAsNonvoter","params":[<raft-server-id>, <raft-consensus-addr>, <raft-config-version>],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_addServerAsNonvoter <raft-server-id> <raft-consensus-addr> <raft-config-version> --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_removeServer <Info> API related to consensus. </Info> RemoveServer removes a server from the cluster. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_removeServer","params":[<raft-server-id>, <raft-config-version>],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_removeServer <raft-server-id> <raft-config-version> --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_transferLeader <Info> API related to consensus. </Info> TransferLeader transfers leadership to another server (resigns). <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_transferLeader","params":[],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_transferLeader --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_transferLeaderToServer <Info> API related to consensus. </Info> TransferLeaderToServer transfers leadership to a specific server. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_transferLeaderToServer","params":[<raft-server-id>, <raft-consensus-addr>, <raft-config-version>],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_transferLeaderToServer <raft-server-id> <raft-consensus-addr> <raft-config-version> --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_clusterMembership ClusterMembership returns the current cluster membership configuration. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_clusterMembership","params":[],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_clusterMembership --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_active <Info> API called by `op-node`. </Info> Active returns true if the op-conductor is active (not paused or stopped). <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_active","params":[],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} cast rpc conductor_active --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> ### conductor\_commitUnsafePayload <Info> API called by `op-node`. </Info> CommitUnsafePayload commits an unsafe payload (latest head) to the consensus layer. This method is typically called by the op-node to commit execution payload envelopes. <Tabs> <Tab title="curl"> ```sh theme={null} curl -X POST -H "Content-Type: application/json" --data \ '{"jsonrpc":"2.0","method":"conductor_commitUnsafePayload","params":[{ "executionPayload": { "parentHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "feeRecipient": "0x4200000000000000000000000000000000000019", "stateRoot": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "receiptsRoot": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "blockNumber": "0x64", "gasLimit": "0x1c9c380", "gasUsed": "0x5208", "timestamp": "0x12345678", "extraData": "0x", "baseFeePerGas": "0x7", "blockHash": "0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba", "transactions": [] } }],"id":1}' \ http://127.0.0.1:8547 ``` </Tab> <Tab title="cast"> ```sh theme={null} # Example with basic payload structure cast rpc conductor_commitUnsafePayload \ '{"executionPayload":{"parentHash":"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef","feeRecipient":"0x4200000000000000000000000000000000000019","stateRoot":"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890","receiptsRoot":"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef","blockNumber":"0x64","gasLimit":"0x1c9c380","gasUsed":"0x5208","timestamp":"0x12345678","extraData":"0x","baseFeePerGas":"0x7","blockHash":"0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba","transactions":[]}}' \ --rpc-url http://127.0.0.1:8547 ``` </Tab> </Tabs> # Setup Source: https://docs.optimism.io/chain-operators/tools/op-conductor/setup Add op-conductor to an existing multi-sequencer OP Stack network without downtime. For how op-conductor works and the guarantees it provides, see [OP Conductor](/chain-operators/tools/op-conductor). The flags and RPC methods used below are catalogued in the [configuration and RPC reference](/chain-operators/tools/op-conductor/reference). At OP Labs, op-conductor is deployed as a kubernetes statefulset because it requires a persistent volume to store the raft log. This guide describes setting up conductor on an existing network without incurring downtime. You can utilize the [op-conductor-ops](https://github.com/ethereum-optimism/infra/tree/main/op-conductor-ops) tool to confirm the conductor status between the steps. ## Assumptions This setup guide has the following assumptions: * 3 deployed sequencers (sequencer-0, sequencer-1, sequencer-2) that are all in sync and in the same vpc network * sequencer-0 is currently the active sequencer * You can execute a blue/green style sequencer deployment workflow that involves no downtime (described below) * conductor and sequencers are running in k8s or some other container orchestrator (vm-based deployment may be slightly different and not covered here) ## Spin up op-conductor <Steps> <Step title="Deploy conductor"> Deploy a conductor instance per sequencer with sequencer-1 as the raft cluster bootstrap node: * suggested conductor configs: ```yaml theme={null} OP_CONDUCTOR_CONSENSUS_ADDR: '0.0.0.0' OP_CONDUCTOR_CONSENSUS_ADVERTISED: '<raft url or ip>' OP_CONDUCTOR_CONSENSUS_PORT: '50050' OP_CONDUCTOR_EXECUTION_RPC: '<op-geth url or ip>:8545' OP_CONDUCTOR_HEALTHCHECK_INTERVAL: '1' OP_CONDUCTOR_HEALTHCHECK_MIN_PEER_COUNT: '2' # set based on your internal p2p network peer count OP_CONDUCTOR_HEALTHCHECK_UNSAFE_INTERVAL: '5' # recommend a 2-3x multiple of your network block time to account for temporary performance issues OP_CONDUCTOR_LOG_FORMAT: logfmt OP_CONDUCTOR_LOG_LEVEL: info OP_CONDUCTOR_METRICS_ADDR: 0.0.0.0 OP_CONDUCTOR_METRICS_ENABLED: 'true' OP_CONDUCTOR_METRICS_PORT: '7300' OP_CONDUCTOR_NETWORK: '<network>' OP_CONDUCTOR_NODE_RPC: '<op-node url or ip>:8545' OP_CONDUCTOR_RAFT_SERVER_ID: 'unique raft server id' OP_CONDUCTOR_RAFT_STORAGE_DIR: /conductor/raft OP_CONDUCTOR_RPC_ADDR: 0.0.0.0 OP_CONDUCTOR_RPC_ENABLE_ADMIN: 'true' OP_CONDUCTOR_RPC_ENABLE_PROXY: 'true' OP_CONDUCTOR_RPC_PORT: '8547' ``` * sequencer-1 op-conductor extra config: ```yaml theme={null} OP_CONDUCTOR_PAUSED: "true" OP_CONDUCTOR_RAFT_BOOTSTRAP: "true" ``` </Step> <Step title="Pause two conductors"> Pause `sequencer-0` &` sequencer-2` conductors with [conductor\_pause](/chain-operators/tools/op-conductor/reference#conductor_pause) RPC request. </Step> <Step title="Update op-node configuration and switch the active sequencer"> Deploy an `op-node` config update to all sequencers that enables conductor. Use a blue/green style deployment workflow that switches the active sequencer to `sequencer-1`: * all sequencer op-node configs: ```yaml theme={null} OP_NODE_CONDUCTOR_ENABLED: "true" # this is what commits unsafe blocks to the raft logs OP_NODE_RPC_ADMIN_STATE: "" # this flag can't be used with conductor ``` </Step> <Step title="Confirm sequencer switch was successful"> Confirm `sequencer-1` is active and successfully producing unsafe blocks. Because `sequencer-1` was the raft cluster bootstrap node, it is now committing unsafe payloads to the raft log. </Step> <Step title="Add voting nodes"> Add voting nodes to cluster using [conductor\_AddServerAsVoter](/chain-operators/tools/op-conductor/reference#conductor_addserverasvoter) RPC request to the leader conductor (`sequencer-1`) </Step> <Step title="Confirm state"> Confirm cluster membership and sequencer state: * `sequencer-0` and `sequencer-2`: 1. raft cluster follower 2. sequencer is stopped 3. conductor is paused 4. conductor enabled in op-node config * `sequencer-1` 1. raft cluster leader 2. sequencer is active 3. conductor is paused 4. conductor enabled in op-node config </Step> <Step title="Resume conductors"> Resume all conductors with [conductor\_resume](/chain-operators/tools/op-conductor/reference#conductor_resume) RPC request to each conductor instance. </Step> <Step title="Confirm state"> Confirm all conductors successfully resumed with [conductor\_paused](/chain-operators/tools/op-conductor/reference#conductor_paused) </Step> <Step title="Transfer leadership"> Trigger leadership transfer to `sequencer-0` using [conductor\_transferLeaderToServer](/chain-operators/tools/op-conductor/reference#conductor_transferleadertoserver) </Step> <Step title="Confirm state"> Confirm cluster membership and sequencer state: **`sequencer-1` and `sequencer-2`:** 1. raft cluster follower 2. sequencer is stopped 3. conductor is active 4. conductor enabled in op-node config **`sequencer-0`:** 1. raft cluster leader 2. sequencer is active 3. conductor is active 4. conductor enabled in op-node config </Step> <Step title="Update configuration"> Deploy a config change to `sequencer-1` conductor to remove the `OP_CONDUCTOR_PAUSED: true` flag and `OP_CONDUCTOR_RAFT_BOOTSTRAP` flag. </Step> </Steps> ### Blue/green deployment In order to ensure there is no downtime when setting up conductor, you need to have a deployment script that can update sequencers without network downtime. An example of this workflow might look like: 1. Query current state of the network and determine which sequencer is currently active (referred to as "original" sequencer below). From the other available sequencers, choose a candidate sequencer. 2. Deploy the change to the candidate sequencer and then wait for it to sync up to the original sequencer's unsafe head. You may want to check peer counts and other important health metrics. 3. Stop the original sequencer using `admin_stopSequencer` which returns the last inserted unsafe block hash. Wait for candidate sequencer to sync with this returned hash in case there is a delta. 4. Start the candidate sequencer at the original's last inserted unsafe block hash. 1. Here you can also execute additional check for unsafe head progression and decide to roll back the change (stop the candidate sequencer, start the original, rollback deployment of candidate, etc.) 5. Deploy the change to the original sequencer, wait for it to sync to the chain head. Execute health checks. ### Post-conductor launch deployments After conductor is live, a similar canary style workflow is used to ensure minimal downtime in case there is an issue with deployment: 1. Choose a candidate sequencer from the raft-cluster followers 2. Deploy to the candidate sequencer. Run health checks on the candidate. 3. Transfer leadership to the candidate sequencer using `conductor_transferLeaderToServer`. Run health checks on the candidate. 4. Test if candidate is still the leader using `conductor_leader` after some grace period (ex: 30 seconds) 1. If not, then there is likely an issue with the deployment. Roll back. 5. Upgrade the remaining sequencers, run healthchecks. # Install op-deployer Source: https://docs.optimism.io/chain-operators/tools/op-deployer/installation Learn how to install op-deployer from pre-built binaries or from source. OP Deployer can be installed both from pre-built binaries and from source. This guide will walk you through both methods. ## Install From Binaries Installing OP Deployer from pre-built binaries is the easiest and most preferred way to get started. To install from binaries, download the latest release from the [releases page](https://github.com/ethereum-optimism/optimism/releases?q=op-deployer\&expanded=true) and extract the binary to a directory in your `$PATH`. ## Install From Source To install from source, you will need Go, `just`, and `git`. Then, run the following: ```shell theme={null} git clone git@github.com:ethereum-optimism/optimism.git # you can skip this if you already have the repo cd optimism/op-deployer just build cp ./bin/op-deployer /usr/local/bin/op-deployer # or any other directory in your $PATH ``` # Known Limitations Source: https://docs.optimism.io/chain-operators/tools/op-deployer/known-limitations Known limitations and workarounds for OP Deployer. OP Deployer is subject to some known limitations which we're working on addressing in future releases. ## Tagged Releases on New Chains <Info> **Fixed in all versions after v0.0.11.** </Info> It is not currently possible to deploy chains using tagged contract locators (i.e., those starting with `tag://`) anywhere except Sepolia and Ethereum mainnet. If you try to, you'll see an error like this: ``` ####################### WARNING! WARNING WARNING! ####################### You are deploying a tagged release to a chain with no pre-deployed OPCM. Due to a quirk of our contract version system, this can lead to deploying contracts containing unaudited or untested code. As a result, this functionality is currently disabled. We will fix this in an upcoming release. This process will now exit. ####################### WARNING! WARNING WARNING! ####################### ``` Like the error says, this is due to a quirk of how we version our smart contracts. We currently follow a process like this: 1. We tag a release, like op-contracts/v1.8.0. 2. We update the [release notes](https://github.com/ethereum-optimism/optimism/releases/tag/op-contracts%2Fv1.8.0) to reference which contracts are updated in that release. 3. We manually deploy the updated contract implementations. 4. We manually deploy a new OPCM to reference the newly-deployed implementations, as well as existing implementations for any contracts that have not been updated. There's a flaw in this strategy, however. The release only includes the contracts that explicitly changed during that release. **This means that any contract not referenced as "updated" in the release notes is "in-development," and has not been audited or approved by governance.** Deploying all contracts from the release tag will therefore deploy a combination of prod-ready and in-development code. To get the version of the contract that will *actually* run in prod, OP Deployer would have to reference all previous releases to get the correct combination of contracts. For example, to deploy on Holesky you will need to deploy contracts from versions `op-contracts/v1.8.0`, `op-contracts/v1.6.0`, and `op-contracts/v1.3.0`. On Sepolia and mainnet, we've been incrementally deploying implementation contracts so we just use the existing implementations to work around this issue. We plan on addressing this in our next release. In the meantime, as a workaround you can use a non-tagged locator for development chains, or use Sepolia or Ethereum mainnet as your L1. # OP Deployer Source: https://docs.optimism.io/chain-operators/tools/op-deployer/overview A CLI tool for deploying and upgrading smart contracts for OP Stack chains. OP Deployer is a CLI tool that simplifies deploying and upgrading smart contracts for OP Stack chains. It also exposes a suite of libraries that allow developers to easily manage smart contracts from their applications. ## Goals ### Declarative With OP Deployer, developers define their chain's desired configuration in a declarative configuration file. The tool then makes the minimum number of smart contract calls required to make the deployment match the configuration. This ensures that
프로젝트로 돌아가기