Skip to content

Commit 2bea587

Browse files
authored
chore: update passphrase to file rather than string in cli (#146)
* chore: write password file * chore: also fix evm-single
1 parent be63c71 commit 2bea587

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

framework/docker/evstack/evmsingle/node.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"net"
88
"net/http"
9+
"path/filepath"
910
"sync"
1011
"time"
1112

@@ -60,6 +61,11 @@ func (n *Node) Name() string {
6061
// HostName returns a condensed hostname
6162
func (n *Node) HostName() string { return internal.CondenseHostName(n.Name()) }
6263

64+
// passphraseFilePath returns the path to the passphrase file
65+
func (n *Node) passphraseFilePath() string {
66+
return filepath.Join(n.HomeDir(), "config", "passphrase.txt")
67+
}
68+
6369
// GetNetworkInfo returns internal/external addressing
6470
func (n *Node) GetNetworkInfo(ctx context.Context) (types.NetworkInfo, error) {
6571
internalIP, err := internal.GetContainerInternalIP(ctx, n.DockerClient, n.ContainerLifecycle.ContainerID())
@@ -115,9 +121,13 @@ func (n *Node) initContainer(ctx context.Context) error {
115121
// Always run init to ensure config exists and is up to date
116122
initCmd := []string{n.cfg.Bin, "init", "--home", n.HomeDir()}
117123
if n.nodeCfg.EVMSignerPassphrase != "" {
124+
if err := n.WriteFile(ctx, filepath.Join("config", "passphrase.txt"), []byte(n.nodeCfg.EVMSignerPassphrase)); err != nil {
125+
return fmt.Errorf("failed to write passphrase file: %w", err)
126+
}
127+
118128
initCmd = append(initCmd,
119129
"--rollkit.node.aggregator=true",
120-
"--rollkit.signer.passphrase", n.nodeCfg.EVMSignerPassphrase,
130+
"--rollkit.signer.passphrase_file", n.passphraseFilePath(),
121131
)
122132
}
123133

@@ -156,7 +166,7 @@ func (n *Node) createNodeContainer(ctx context.Context) error {
156166
cmd = append(cmd, "--evnode.node.block_time", n.nodeCfg.EVMBlockTime)
157167
}
158168
if n.nodeCfg.EVMSignerPassphrase != "" {
159-
cmd = append(cmd, "--evnode.node.aggregator=true", "--evnode.signer.passphrase", n.nodeCfg.EVMSignerPassphrase)
169+
cmd = append(cmd, "--evnode.node.aggregator=true", "--evnode.signer.passphrase_file", n.passphraseFilePath())
160170
}
161171

162172
if n.nodeCfg.DAAddress != "" {

framework/docker/evstack/node.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,26 @@ func (n *Node) isAggregator() bool {
9393
return n.isAggregatorFlag
9494
}
9595

96+
// passphraseFilePath returns the path to the passphrase file
97+
func (n *Node) passphraseFilePath() string {
98+
return filepath.Join(n.HomeDir(), "config", "passphrase.txt")
99+
}
100+
96101
// Init initializes the Node.
97102
func (n *Node) Init(ctx context.Context, initArguments ...string) error {
98103
n.mu.Lock()
99104
defer n.mu.Unlock()
100105

101106
cmd := []string{n.cfg.Bin, "--home", n.HomeDir(), "--chain_id", n.cfg.ChainID, "init"}
102107
if n.isAggregator() {
108+
if err := n.WriteFile(ctx, filepath.Join("config", "passphrase.txt"), []byte(n.cfg.AggregatorPassphrase)); err != nil {
109+
return fmt.Errorf("failed to write passphrase file: %w", err)
110+
}
111+
103112
signerPath := filepath.Join(n.HomeDir(), "config")
104113
cmd = append(cmd,
105114
"--evnode.node.aggregator",
106-
"--evnode.signer.passphrase="+n.cfg.AggregatorPassphrase, //nolint:gosec // used for testing only
115+
"--evnode.signer.passphrase_file="+n.passphraseFilePath(), //nolint:gosec // used for testing only
107116
"--evnode.signer.signer_path="+signerPath)
108117
}
109118

@@ -147,7 +156,7 @@ func (n *Node) createEvstackContainer(ctx context.Context, additionalStartArgs .
147156
signerPath := filepath.Join(n.HomeDir(), "config")
148157
startCmd = append(startCmd,
149158
"--evnode.node.aggregator",
150-
"--evnode.signer.passphrase="+n.cfg.AggregatorPassphrase, //nolint:gosec // used for testing only
159+
"--evnode.signer.passphrase_file="+n.passphraseFilePath(), //nolint:gosec // used for testing only
151160
"--evnode.signer.signer_path="+signerPath)
152161
}
153162

0 commit comments

Comments
 (0)