Skip to content

Commit

Permalink
fix(consensus): stopped abci client is not recoverable
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Dec 11, 2024
1 parent 7681ea4 commit 0896537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type socketClient struct {

var _ Client = (*socketClient)(nil)

var (
ErrClientStopped = errors.New("client has stopped")
)

// NewSocketClient creates a new socket client, which connects to a given
// address. If mustConnect is true, the client will return an error upon start
// if it fails to connect.
Expand Down Expand Up @@ -234,7 +238,7 @@ func (cli *socketClient) didRecvResponse(res *types.Response) error {

func (cli *socketClient) doRequest(ctx context.Context, req *types.Request) (*types.Response, error) {
if !cli.IsRunning() {
return nil, errors.New("client has stopped")
return nil, ErrClientStopped
}

reqres := makeReqRes(ctx, req)
Expand Down
6 changes: 6 additions & 0 deletions internal/consensus/state_try_add_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package consensus

import (
"context"
"errors"
"fmt"

abciclient "github.com/dashpay/tenderdash/abci/client"
"github.com/dashpay/tenderdash/dash"
cstypes "github.com/dashpay/tenderdash/internal/consensus/types"
"github.com/dashpay/tenderdash/libs/log"
Expand Down Expand Up @@ -108,6 +110,10 @@ func (cs *TryAddCommitAction) verifyCommit(ctx context.Context, stateData *State
// We have a correct block, let's process it before applying the commit
err = cs.blockExec.ensureProcess(ctx, &stateData.RoundState, commit.Round)
if err != nil {
if errors.Is(err, abciclient.ErrClientStopped) {
// this is a non-recoverable error in current architecture
panic(fmt.Errorf("ABCI client stopped, Tenderdash needs to be restarted: %w", err))
}
return false, fmt.Errorf("unable to process proposal: %w", err)
}
err = cs.blockExec.validate(ctx, stateData)
Expand Down

0 comments on commit 0896537

Please sign in to comment.