Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebrad instead of zcashd in error messages #489

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func startServer(opts *common.Options) error {
if err != nil {
common.Log.WithFields(logrus.Fields{
"error": err,
}).Fatal("setting up RPC connection to zcashd")
}).Fatal("setting up RPC connection to zebrad or zcashd")
}
// Indirect function for test mocking (so unit tests can talk to stub functions).
common.RawRequest = rpcClient.RawRequest
Expand All @@ -210,14 +210,18 @@ func startServer(opts *common.Options) error {
if err != nil {
common.Log.WithFields(logrus.Fields{
"error": err,
}).Fatal("getting initial information from zcashd")
}).Fatal("getting initial information from zebrad or zcashd")
}
common.Log.Info("Got sapling height ", getLightdInfo.SaplingActivationHeight,
" block height ", getLightdInfo.BlockHeight,
" chain ", getLightdInfo.ChainName,
" branchID ", getLightdInfo.ConsensusBranchId)
saplingHeight = int(getLightdInfo.SaplingActivationHeight)
chainName = getLightdInfo.ChainName
if strings.Contains(getLightdInfo.ZcashdSubversion, "MagicBean") {
// The default is zebrad
common.NodeName = "zcashd"
}
}

dbPath := filepath.Join(opts.DataDir, "db")
Expand Down Expand Up @@ -339,12 +343,12 @@ func init() {
rootCmd.Flags().String("rpcport", "", "RPC host port")
rootCmd.Flags().Bool("no-tls-very-insecure", false, "run without the required TLS certificate, only for debugging, DO NOT use in production")
rootCmd.Flags().Bool("gen-cert-very-insecure", false, "run with self-signed TLS certificate, only for debugging, DO NOT use in production")
rootCmd.Flags().Bool("redownload", false, "re-fetch all blocks from zcashd; reinitialize local cache files")
rootCmd.Flags().Bool("redownload", false, "re-fetch all blocks from zebrad or zcashd; reinitialize local cache files")
rootCmd.Flags().Bool("nocache", false, "don't maintain a compact blocks disk cache (to reduce storage)")
rootCmd.Flags().Int("sync-from-height", -1, "re-fetch blocks from zcashd start at this height")
rootCmd.Flags().Int("sync-from-height", -1, "re-fetch blocks from zebrad or zcashd, starting at this height")
rootCmd.Flags().String("data-dir", "/var/lib/lightwalletd", "data directory (such as db)")
rootCmd.Flags().Bool("ping-very-insecure", false, "allow Ping GRPC for testing")
rootCmd.Flags().Bool("darkside-very-insecure", false, "run with GRPC-controllable mock zcashd for integration testing (shuts down after 30 minutes)")
rootCmd.Flags().Bool("darkside-very-insecure", false, "run with GRPC-controllable mock zebrad for integration testing (shuts down after 30 minutes)")
rootCmd.Flags().Int("darkside-timeout", 30, "override 30 minute default darkside timeout")

viper.BindPFlag("grpc-bind-addr", rootCmd.Flags().Lookup("grpc-bind-addr"))
Expand Down
7 changes: 4 additions & 3 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
Branch = ""
BuildDate = ""
BuildUser = ""
NodeName = "zebrad"
)

type Options struct {
Expand Down Expand Up @@ -225,7 +226,7 @@ func FirstRPC() {
if retryCount > 10 {
Log.WithFields(logrus.Fields{
"timeouts": retryCount,
}).Fatal("unable to issue getblockchaininfo RPC call to zcashd node")
}).Fatal("unable to issue getblockchaininfo RPC call to zebrad or zcashd node")
}
Log.WithFields(logrus.Fields{
"error": err.Error(),
Expand Down Expand Up @@ -418,7 +419,7 @@ func BlockIngestor(c *BlockCache, rep int) {
if err != nil {
Log.WithFields(logrus.Fields{
"error": err,
}).Fatal("error zcashd getbestblockhash rpc")
}).Fatal("error " + NodeName + " getbestblockhash rpc")
}
var hashHex string
err = json.Unmarshal(result, &hashHex)
Expand Down Expand Up @@ -462,7 +463,7 @@ func BlockIngestor(c *BlockCache, rep int) {
}
if height == c.GetFirstHeight() {
c.Sync()
Log.Info("Waiting for zcashd height to reach Sapling activation height ",
Log.Info("Waiting for "+NodeName+" height to reach Sapling activation height ",
"(", c.GetFirstHeight(), ")...")
Time.Sleep(20 * time.Second)
return
Expand Down
2 changes: 1 addition & 1 deletion common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ func TestMempoolStream(t *testing.T) {
t.Fatal("unexpected end time")
}
if step != 8 {
t.Fatal("unexpected number of zcashd RPCs")
t.Fatal("unexpected number of zebrad RPCs")
}

step = 0
Expand Down
4 changes: 3 additions & 1 deletion frontend/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func (s *lwdStreamer) GetBlock(ctx context.Context, id *walletrpc.BlockID) (*wal
// Precedence: a hash is more specific than a height. If we have it, use it first.
if id.Hash != nil {
// TODO: Get block by hash
// see https://github.com/zcash/lightwalletd/pull/309
return nil, errors.New("gRPC GetBlock by Hash is not yet implemented")
}
cBlock, err := common.GetBlock(s.cache, int(id.Height))
Expand All @@ -162,6 +163,7 @@ func (s *lwdStreamer) GetBlockNullifiers(ctx context.Context, id *walletrpc.Bloc
// Precedence: a hash is more specific than a height. If we have it, use it first.
if id.Hash != nil {
// TODO: Get block by hash
// see https://github.com/zcash/lightwalletd/pull/309
return nil, errors.New("gRPC GetBlock by Hash is not yet implemented")
}
cBlock, err := common.GetBlock(s.cache, int(id.Height))
Expand Down Expand Up @@ -286,7 +288,7 @@ func (s *lwdStreamer) GetTreeState(ctx context.Context, id *walletrpc.BlockID) (
params[0] = hashJSON
}
if gettreestateReply.Sapling.Commitments.FinalState == "" {
return nil, errors.New("zcashd did not return treestate")
return nil, errors.New(common.NodeName + " did not return treestate")
}
return &walletrpc.TreeState{
Network: s.chainName,
Expand Down
Loading