Skip to content

Commit

Permalink
chore: remove clef references (#4812)
Browse files Browse the repository at this point in the history
Co-authored-by: Ljubisa <ljubisa.rs@gmail.com>
  • Loading branch information
martinconic and gacevicljubisa authored Sep 16, 2024
1 parent 06a0aca commit a416700
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 506 deletions.
6 changes: 0 additions & 6 deletions cmd/bee/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ const (
optionNamePaymentEarly = "payment-early-percent"
optionNameResolverEndpoints = "resolver-options"
optionNameBootnodeMode = "bootnode-mode"
optionNameClefSignerEnable = "clef-signer-enable"
optionNameClefSignerEndpoint = "clef-signer-endpoint"
optionNameClefSignerEthereumAddress = "clef-signer-ethereum-address"
optionNameSwapEndpoint = "swap-endpoint" // deprecated: use rpc endpoint instead
optionNameBlockchainRpcEndpoint = "blockchain-rpc-endpoint"
optionNameSwapFactoryAddress = "swap-factory-address"
Expand Down Expand Up @@ -263,9 +260,6 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
cmd.Flags().Int64(optionNamePaymentEarly, 50, "percentage below the peers payment threshold when we initiate settlement")
cmd.Flags().StringSlice(optionNameResolverEndpoints, []string{}, "ENS compatible API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url")
cmd.Flags().Bool(optionNameBootnodeMode, false, "cause the node to always accept incoming connections")
cmd.Flags().Bool(optionNameClefSignerEnable, false, "enable clef signer")
cmd.Flags().String(optionNameClefSignerEndpoint, "", "clef signer endpoint")
cmd.Flags().String(optionNameClefSignerEthereumAddress, "", "blockchain address to use from clef signer")
cmd.Flags().String(optionNameSwapEndpoint, "", "swap blockchain endpoint") // deprecated: use rpc endpoint instead
cmd.Flags().String(optionNameBlockchainRpcEndpoint, "", "rpc blockchain endpoint")
cmd.Flags().String(optionNameSwapFactoryAddress, "", "swap factory addresses")
Expand Down
71 changes: 6 additions & 65 deletions cmd/bee/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,16 @@ import (
"syscall"
"time"

"github.com/ethereum/go-ethereum/accounts/external"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethersphere/bee/v2"
"github.com/ethersphere/bee/v2/pkg/accesscontrol"
chaincfg "github.com/ethersphere/bee/v2/pkg/config"
"github.com/ethersphere/bee/v2/pkg/crypto"
"github.com/ethersphere/bee/v2/pkg/crypto/clef"
"github.com/ethersphere/bee/v2/pkg/keystore"
filekeystore "github.com/ethersphere/bee/v2/pkg/keystore/file"
memkeystore "github.com/ethersphere/bee/v2/pkg/keystore/mem"
"github.com/ethersphere/bee/v2/pkg/log"
"github.com/ethersphere/bee/v2/pkg/node"
"github.com/ethersphere/bee/v2/pkg/resolver/multiresolver"
"github.com/ethersphere/bee/v2/pkg/spinlock"
"github.com/ethersphere/bee/v2/pkg/swarm"
"github.com/kardianos/service"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -369,22 +364,6 @@ type signerConfig struct {
session accesscontrol.Session
}

func waitForClef(logger log.Logger, maxRetries uint64, endpoint string) (externalSigner *external.ExternalSigner, err error) {
var (
interval = time.Second * 5
timeout = interval * time.Duration(maxRetries)
)

spinErr := spinlock.WaitWithInterval(timeout, interval, func() bool {
externalSigner, err = external.NewExternalSigner(endpoint)
return err == nil
})
if spinErr != nil {
logger.Warning("connect to clef signer failed", "error", err)
}
return
}

func (c *command) configureSigner(cmd *cobra.Command, logger log.Logger) (config *signerConfig, err error) {
var keystore keystore.Service
if c.config.GetString(optionNameDataDir) == "" {
Expand Down Expand Up @@ -427,51 +406,13 @@ func (c *command) configureSigner(cmd *cobra.Command, logger log.Logger) (config
}
}

if c.config.GetBool(optionNameClefSignerEnable) {
endpoint := c.config.GetString(optionNameClefSignerEndpoint)
if endpoint == "" {
endpoint, err = clef.DefaultIpcPath()
if err != nil {
return nil, err
}
}

externalSigner, err := waitForClef(logger, 5, endpoint)
if err != nil {
return nil, err
}

clefRPC, err := rpc.Dial(endpoint)
if err != nil {
return nil, err
}

wantedAddress := c.config.GetString(optionNameClefSignerEthereumAddress)
var overlayEthAddress *common.Address = nil
// if wantedAddress was specified use that, otherwise clef account 0 will be selected.
if wantedAddress != "" {
ethAddress := common.HexToAddress(wantedAddress)
overlayEthAddress = &ethAddress
}

signer, err = clef.NewSigner(externalSigner, clefRPC, crypto.Recover, overlayEthAddress)
if err != nil {
return nil, err
}

publicKey, err = signer.PublicKey()
if err != nil {
return nil, err
}
} else {
swarmPrivateKey, _, err := keystore.Key("swarm", password, crypto.EDGSecp256_K1)
if err != nil {
return nil, fmt.Errorf("swarm key: %w", err)
}
signer = crypto.NewDefaultSigner(swarmPrivateKey)
publicKey = &swarmPrivateKey.PublicKey
session = accesscontrol.NewDefaultSession(swarmPrivateKey)
swarmPrivateKey, _, err := keystore.Key("swarm", password, crypto.EDGSecp256_K1)
if err != nil {
return nil, fmt.Errorf("swarm key: %w", err)
}
signer = crypto.NewDefaultSigner(swarmPrivateKey)
publicKey = &swarmPrivateKey.PublicKey
session = accesscontrol.NewDefaultSession(swarmPrivateKey)

logger.Info("swarm public key", "public_key", hex.EncodeToString(crypto.EncodeSecp256k1PublicKey(publicKey)))

Expand Down
159 changes: 0 additions & 159 deletions pkg/crypto/clef/clef.go

This file was deleted.

Loading

0 comments on commit a416700

Please sign in to comment.