Skip to content

Commit

Permalink
Print Electrum URL in the logs (#3596)
Browse files Browse the repository at this point in the history
Unless specified in the config, mainnet client binary selects the
Electrum server from one of the preconfigured nodes. It is nice to know
which server was selected, even for debugging purposes. Additionally, we
should log both Bitcoin and Ethereum networks used by the client.
Electrum server URL is printed to the logs only if it has been
auto-selected. This approach is consistent with not logging Ethereum
server URL at all given we expect it is passed in the configuration.

I snaked one more change in this PR: fixed the number of accounts
requirement in `scripts/install.sh`. Given the recent changes in tbtc-v2
project, at least 11 accounts are required in the local Ethereum client
keystore to deploy and initialize contracts.

The `v1Redeemer` [set in tbtc-v2
`hardhat.config.ts`](https://github.com/keep-network/tbtc-v2/blob/7f48d6362f8bfc9a2931c4087e5eba28efee5370/solidity/hardhat.config.ts#L227)
uses index 10 and indexes start from 0.

Example:
```
2023-06-05T08:54:24.185+0200    INFO    keep-config     config/config.go:95     using [mainnet] Ethereum network and [mainnet] Bitcoin network
2023-06-05T08:54:24.187+0200    INFO    keep-config     config/electrum.go:68   Auto-selecting Electrum server: [ssl://electrum.blockstream.info:50002]
```
  • Loading branch information
nkuba authored Jun 5, 2023
2 parents eb8c461 + b06c66d commit cdddee4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 0 additions & 5 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ Environment variables:
func start(cmd *cobra.Command) error {
ctx := context.Background()

logger.Infof(
"Starting the client against [%s] ethereum network...",
clientConfig.Ethereum.Network,
)

beaconChain, tbtcChain, blockCounter, signing, operatorPrivateKey, err :=
ethereum.Connect(ctx, clientConfig.Ethereum)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ func (c *Config) resolveNetworks(flagSet *pflag.FlagSet) (network.Type, error) {
c.Ethereum.Network = clientNetwork.Ethereum()
c.Bitcoin.Network = clientNetwork.Bitcoin()

logger.Infof(
"using [%v] Ethereum network and [%v] Bitcoin network",
c.Ethereum.Network,
c.Bitcoin.Network,
)

return clientNetwork, err
}

Expand Down
2 changes: 2 additions & 0 deletions config/electrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func (c *Config) resolveElectrum(rng *rand.Rand) error {
// Picking up an Electrum server does not require secure randomness.
selectedURL := urls[rng.Intn(len(urls))]

logger.Infof("auto-selecting Electrum server: [%v]", selectedURL)

// Set only the URL in the original config. Other fields may be already set,
// and we don't want to override them.
c.Bitcoin.Electrum.URL = selectedURL
Expand Down
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ OPENZEPPELIN_MANIFEST=".openzeppelin/unknown-*.json"
# This number should be no less than the highest index assigned to a named account
# specified in `hardhat.config.ts` configs across all the used projects. Note that
# account indices start from 0.
REQUIRED_ACCOUNTS_NUMBER=8
REQUIRED_ACCOUNTS_NUMBER=11

# Defaults, can be overwritten by env variables/input parameters
NETWORK_DEFAULT="development"
Expand Down

0 comments on commit cdddee4

Please sign in to comment.