-
Notifications
You must be signed in to change notification settings - Fork 25
/
examples.py
161 lines (108 loc) · 5.22 KB
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
"""
Functions in this file alter a Config object (that must be default-initiatilized!) so that it
matches some well-known configuration example.
"""
import os
import state
from config import Config
####################################################################################################
def use_devnet_config(config: Config):
"""
Overrides the configuration values with those from the Optimism monorepo devnet.
The default config is already based on the devnet, so this only overrides some paths.
We also don't enable metric servers, pprof servers, and admin APIs, neither here or in the
default config.
The source of truth for these values can be found here:
https://github.com/ethereum-optimism/optimism/blob/op-node/v1.3.1/ops-bedrock/docker-compose.yml
Or in Go defaults, e.g.
https://github.com/ethereum-optimism/optimism/blob/op-node/v1.3.1/op-service/txmgr/cli.go
"""
ops_bedrock = os.path.join(config.op_monorepo_dir, "ops-bedrock")
# === Network ===
config.jwt_secret_path = os.path.join(ops_bedrock, "test-jwt-secret.txt")
# === Node ===
config.p2p_peer_key_path = os.path.join(ops_bedrock, "p2p-node-key.txt")
####################################################################################################
# noinspection PyAttributeOutsideInit
def use_op_doc_config(config: Config):
"""
Overrides the configuration values with the values specified in the OP stack "Getting
Started" guide (https://stack.optimism.io/docs/build/getting-started), wherever they
differ from the default values.
One difference is that we don't enable admin APIs.
Note that the guide also uses deploy config values equivalent to the "prod" preset in
roll-op (see `PRODUCTION_CONFIG` in `deploy_config_templates.py`).
The guide also uses a batch inbox address of 0xff00000000000000000000000000000000042069,
but roll-op automatically overrides this to 0xff69000000000000000000000000000000042069
(based on the chain ID) unless configured explicitly in the `config.toml` file.
"""
# === Network ===
config.l1_chain_id = 11155111
config.l2_chain_id = 42069
# We need to do this because the documentation assigns 8545 to the L2 engine RPC.
config.l1_rpc_url = "http://127.0.0.1:9545"
config.l1_rpc_for_node_url = "ws://127.0.0.1:9546"
config.l2_engine_rpc_http_url = "http://127.0.0.1:8545"
config.l2_engine_rpc_ws_url = "ws://127.0.0.1:8546"
config.l2_engine_rpc_url = config.l2_engine_rpc_http_url
config.l2_engine_authrpc_url = "http://127.0.0.1:8551"
config.l2_node_rpc_url = "http://127.0.0.1:8547"
config.jwt_secret_path = "jwt.txt"
# === Devnet L1 ===
config.l1_rpc_listen_port = 9545
config.l1_rpc_ws_listen_port = 9546
config.l1_authrpc_listen_port = 9551
# === Engine ===
config.l2_engine_rpc_listen_port = 8545
config.l2_engine_rpc_ws_listen_port = 8546
config.l2_engine_authrpc_listen_port = 8551
config.l2_engine_p2p_port = 9003
# === Node ===
config.l2_node_sequencer_l1_confs = 3
config.l2_node_verifier_l1_confs = 3
config.l2_node_rpc_listen_port = 8547
# === Proposer ===
config.l2_proposer_poll_interval = 12
config.l2_proposer_num_confirmations = 10
# Must be true if using the devnet L1 or any L1 that doesn't mark blocks as finalized!
config.l2_proposer_allow_non_finalized = False
config.l2_proposer_rpc_listen_port = 8560
# === Batcher ===
config.batcher_num_confirmations = 10
config.sub_safety_margin = 6
config.batcher_rpc_listen_port = 8548
####################################################################################################
def use_production_config(config: Config):
"""
Use a configuration suitable for production, inspired from the OP stack "Getting
Started" guide (https://stack.optimism.io/docs/build/getting-started), but not identical
(e.g. we don't follow their port scheme). If you want an identical configuration, use
:py:meth:`use_op_doc_config`.
"""
# === Node ===
config.l2_node_sequencer_l1_confs = 5
config.l2_node_verifier_l1_confs = 4
# === Proposer ===
config.l2_proposer_poll_interval = 12
config.l2_proposer_num_confirmations = 10
# Must be true if using the devnet L1 or any L1 that doesn't mark blocks as finalized!
config.l2_proposer_allow_non_finalized = state.args.command == "devnet"
# === Batcher ===
config.batcher_num_confirmations = 10
config.sub_safety_margin = 6
####################################################################################################
def use_upnode_config(config: Config):
"""
Config from https://github.com/upnodedev/op-stack-basic-deployment
"""
# === Node ===
config.l2_node_sequencer_l1_confs = 4
# === Proposer ===
config.l2_proposer_poll_interval = 6
config.l2_proposer_num_confirmations = 10
# Must be true if using the devnet L1 or any L1 that doesn't mark blocks as finalized!
config.l2_proposer_allow_non_finalized = False
# === Batcher ===
config.batcher_num_confirmations = 10
config.sub_safety_margin = 10
####################################################################################################