Skip to content

Commit

Permalink
Problem: validator fail to start up (#1445)
Browse files Browse the repository at this point in the history
Solution:
- add unsafe option to unblock the edge case.
  • Loading branch information
yihuang authored May 20, 2024
1 parent f022e62 commit ac56118
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
18 changes: 11 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ const (
// NOTE: In the SDK, the default value is 255.
AddrLen = 20

FlagBlockedAddresses = "blocked-addresses"
FlagBlockedAddresses = "blocked-addresses"
FlagUnsafeIgnoreBlockListFailure = "unsafe-ignore-block-list-failure"
)

var Forks = []Fork{}
Expand Down Expand Up @@ -413,10 +414,12 @@ func New(
bz, err := kr.Get(e2eetypes.DefaultKeyringName)
if err != nil {
logger.Error("e2ee identity for validator not found", "error", err)
identity = noneIdentity{}
} else {
identity, err = age.ParseX25519Identity(string(bz))
if err != nil {
panic(err)
logger.Error("e2ee identity for validator is invalid", "error", err)
identity = noneIdentity{}
}
}
}
Expand Down Expand Up @@ -969,7 +972,12 @@ func New(
}

if err := app.RefreshBlockList(app.NewUncachedContext(false, tmproto.Header{})); err != nil {
panic(err)
if !cast.ToBool(appOpts.Get(FlagUnsafeIgnoreBlockListFailure)) {
panic(err)
}

// otherwise, just emit error log
app.Logger().Error("failed to update blocklist", "error", err)
}
}

Expand Down Expand Up @@ -1076,10 +1084,6 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
}

func (app *App) RefreshBlockList(ctx sdk.Context) error {
if app.blockProposalHandler == nil || app.blockProposalHandler.Identity == nil {
return nil
}

// refresh blocklist
return app.blockProposalHandler.SetBlockList(app.CronosKeeper.GetBlockList(ctx))
}
Expand Down
13 changes: 12 additions & 1 deletion app/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (ts *ExtTxSelector) SelectTxForProposal(maxTxBytes, maxBlockGas uint64, mem
}

type ProposalHandler struct {
TxDecoder sdk.TxDecoder
TxDecoder sdk.TxDecoder
// Identity is nil if it's not a validator node
Identity age.Identity
blocklist map[string]struct{}
lastBlockList []byte
Expand All @@ -68,6 +69,7 @@ func NewProposalHandler(txDecoder sdk.TxDecoder, identity age.Identity) *Proposa
}
}

// SetBlockList don't fail if the identity is not set or the block list is empty.
func (h *ProposalHandler) SetBlockList(blob []byte) error {
if h.Identity == nil {
return nil
Expand Down Expand Up @@ -143,3 +145,12 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}
}
}

// noneIdentity is a dummy identity which postpone the failure to the decryption time
type noneIdentity struct{}

var _ age.Identity = noneIdentity{}

func (noneIdentity) Unwrap([]*age.Stanza) ([]byte, error) {
return nil, age.ErrIncorrectIdentity
}

0 comments on commit ac56118

Please sign in to comment.