Skip to content

Commit 27c4f0c

Browse files
authored
Add deterministic p2p key (#62)
1 parent 155426d commit 27c4f0c

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

internal/artifacts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ import (
3535
"gopkg.in/yaml.v2"
3636
)
3737

38+
var (
39+
defaultDiscoveryPrivKey = "a11ac89899cd86e36b6fb881ec1255b8a92a688790b7d950f8b7d8dd626671fb"
40+
)
41+
3842
// minimumGenesisDelay is the minimum delay for the genesis time. This is required
3943
// because lighthouse takes some time to start and we need to make sure it is ready
4044
// otherwise, some blocks are missed.
@@ -224,6 +228,7 @@ func (b *ArtifactsBuilder) Build() (*Artifacts, error) {
224228
"testnet/deposit_contract_block.txt": "0",
225229
"testnet/genesis_validators_root.txt": hex.EncodeToString(state.GenesisValidatorsRoot()),
226230
"data_validator/": &lighthouseKeystore{privKeys: priv},
231+
"deterministic_p2p_key.txt": defaultDiscoveryPrivKey,
227232
})
228233
if err != nil {
229234
return nil, err

internal/components.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import (
99

1010
var defaultJWTToken = "04592280e1778419b7aa954d43871cb2cfb2ebda754fb735e8adeb293a88f9bf"
1111

12-
var (
13-
defaultRethDiscoveryPrivKey = "a11ac89899cd86e36b6fb881ec1255b8a92a688790b7d950f8b7d8dd626671fb"
14-
defaultRethDiscoveryPrivKeyLoc = "/tmp/tmp-reth-disc.txt"
15-
)
16-
1712
type RollupBoost struct {
1813
ELNode string
1914
Builder string
@@ -95,6 +90,7 @@ func (o *OpNode) Run(service *service, ctx *ExContext) {
9590
}
9691

9792
type OpGeth struct {
93+
UseDeterministicP2PKey bool
9894
}
9995

10096
func logLevelToGethVerbosity(logLevel LogLevel) string {
@@ -115,6 +111,11 @@ func logLevelToGethVerbosity(logLevel LogLevel) string {
115111
}
116112

117113
func (o *OpGeth) Run(service *service, ctx *ExContext) {
114+
var nodeKeyFlag string
115+
if o.UseDeterministicP2PKey {
116+
nodeKeyFlag = "--nodekey {{.Dir}}/deterministic_p2p_key.txt "
117+
}
118+
118119
service.
119120
WithImage("us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth").
120121
WithTag("v1.101500.0").
@@ -147,6 +148,7 @@ func (o *OpGeth) Run(service *service, ctx *ExContext) {
147148
"--gcmode archive "+
148149
"--state.scheme hash "+
149150
"--port "+`{{Port "rpc" 30303}} `+
151+
nodeKeyFlag+
150152
"--metrics "+
151153
"--metrics.addr 0.0.0.0 "+
152154
"--metrics.port "+`{{Port "metrics" 6061}}`,
@@ -212,8 +214,6 @@ func (r *RethEL) Run(svc *service, ctx *ExContext) {
212214
"--datadir", "{{.Dir}}/data_reth",
213215
"--color", "never",
214216
"--ipcpath", "{{.Dir}}/reth.ipc",
215-
// p2p config. Use a default discovery key and disable public discovery and connections
216-
"--p2p-secret-key", defaultRethDiscoveryPrivKeyLoc,
217217
"--addr", "127.0.0.1",
218218
"--port", `{{Port "rpc" 30303}}`,
219219
// "--disable-discovery",

internal/recipe_opstack.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ func (o *OpRecipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest {
5656
L1Beacon: "beacon",
5757
L2Node: elNode,
5858
})
59-
svcManager.AddService("op-geth", &OpGeth{})
59+
svcManager.AddService("op-geth", &OpGeth{
60+
UseDeterministicP2PKey: o.externalBuilder != "",
61+
})
6062
svcManager.AddService("op-batcher", &OpBatcher{
6163
L1Node: "el",
6264
L2Node: "op-geth",

0 commit comments

Comments
 (0)