Skip to content

Commit

Permalink
fix encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Nov 24, 2022
1 parent e458ecf commit 1213f88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion local/helpers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package local

import (
"encoding/base64"
"fmt"
"os"
"path/filepath"
Expand All @@ -20,6 +21,10 @@ func writeFiles(genesis []byte, nodeRootDir string, nodeConfig *node.Config) ([]
path string
contents []byte
}
decodedStakingSigningKey, err := base64.StdEncoding.DecodeString(nodeConfig.StakingSigningKey)
if err != nil {
return nil, err
}
files := []file{
{
flagValue: filepath.Join(nodeRootDir, stakingKeyFileName),
Expand All @@ -37,7 +42,7 @@ func writeFiles(genesis []byte, nodeRootDir string, nodeConfig *node.Config) ([]
flagValue: filepath.Join(nodeRootDir, stakingSigningKeyFileName),
path: filepath.Join(nodeRootDir, stakingSigningKeyFileName),
pathKey: config.StakingSignerKeyPathKey,
contents: []byte(nodeConfig.StakingSigningKey),
contents: decodedStakingSigningKey,
},
{
flagValue: filepath.Join(nodeRootDir, genesisFileName),
Expand Down
7 changes: 5 additions & 2 deletions local/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package local
import (
"context"
"embed"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -217,7 +218,8 @@ func init() {
if err != nil {
panic(err)
}
defaultNetworkConfig.NodeConfigs[i].StakingSigningKey = string(stakingSigningKey)
encodedStakingSigningKey := base64.StdEncoding.EncodeToString(stakingSigningKey)
defaultNetworkConfig.NodeConfigs[i].StakingSigningKey = encodedStakingSigningKey
defaultNetworkConfig.NodeConfigs[i].IsBeacon = true
}

Expand Down Expand Up @@ -530,7 +532,8 @@ func (ln *localNetwork) addNode(nodeConfig node.Config) (node.Node, error) {
return nil, fmt.Errorf("couldn't generate new signing key: %w", err)
}
keyBytes := bls.SecretKeyToBytes(key)
nodeConfig.StakingSigningKey = string(keyBytes)
encodedKey := base64.StdEncoding.EncodeToString(keyBytes)
nodeConfig.StakingSigningKey = encodedKey
}

if err := ln.setNodeName(&nodeConfig); err != nil {
Expand Down

0 comments on commit 1213f88

Please sign in to comment.