From 906275b0d1b3189ca8e619c064eeca2bae5c6674 Mon Sep 17 00:00:00 2001 From: huangyi Date: Mon, 20 May 2024 15:59:13 +0800 Subject: [PATCH] Problem: validator fail to start up Solution: - add unsafe option to unblock the edge case. --- app/app.go | 18 +++++++++++------- app/proposal.go | 13 ++++++++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/app.go b/app/app.go index 0ba3610fcb..d8c31380f3 100644 --- a/app/app.go +++ b/app/app.go @@ -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{} @@ -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{} } } } @@ -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) } } @@ -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)) } diff --git a/app/proposal.go b/app/proposal.go index c8f7f54184..dadc1a3a19 100644 --- a/app/proposal.go +++ b/app/proposal.go @@ -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 @@ -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 @@ -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 +}