From b86896afa2729c225ee4cfaf18739d04dff3fefb Mon Sep 17 00:00:00 2001 From: "terry.hung" Date: Tue, 6 Jun 2023 20:14:24 +0800 Subject: [PATCH] fix: keep running the whole tipset task without cancel (#1219) * Keep running the whole tipset task without cancel * Add error to errordetected --------- Co-authored-by: Terry --- chain/indexer/integrated/tipset/tipset.go | 1 - tasks/fevm/blockheader/tasks.go | 11 +++++++---- tasks/fevm/contract/task.go | 9 ++++----- tasks/fevm/receipt/tasks.go | 9 ++++----- tasks/fevm/transaction/tasks.go | 9 ++++----- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/chain/indexer/integrated/tipset/tipset.go b/chain/indexer/integrated/tipset/tipset.go index 26782ad6d..875c447c4 100644 --- a/chain/indexer/integrated/tipset/tipset.go +++ b/chain/indexer/integrated/tipset/tipset.go @@ -145,7 +145,6 @@ func (ti *TipSetIndexer) TipSet(ctx context.Context, ts *types.TipSet) (chan *Re if res.Error != nil { llt.Errorw("task returned with error", "error", res.Error.Error()) errCh <- res.Error - return } // processor is complete if we receive a result executingTasks[res.Task] = true diff --git a/tasks/fevm/blockheader/tasks.go b/tasks/fevm/blockheader/tasks.go index b7096de38..715ab2134 100644 --- a/tasks/fevm/blockheader/tasks.go +++ b/tasks/fevm/blockheader/tasks.go @@ -48,24 +48,27 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut cid, err := executed.Key().Cid() if err != nil { log.Errorf("Error at getting cid: [%v] err: %v", cid, err) - return nil, report, err + report.ErrorsDetected = err + return nil, report, nil } hash, err := ethtypes.EthHashFromCid(cid) if err != nil { log.Errorf("Error at finding hash: [%v] err: %v", hash, err) - return nil, report, err + report.ErrorsDetected = err + return nil, report, nil } ethBlock, err := p.node.EthGetBlockByHash(ctx, hash, false) if err != nil { log.Errorf("EthGetBlockByHash: [hash: %v] err: %v", hash.String(), err) - return nil, report, err + report.ErrorsDetected = err + return nil, report, nil } if ethBlock.Number == 0 { log.Warn("block number == 0") - return nil, report, err + return nil, report, nil } return &fevm.FEVMBlockHeader{ Height: int64(executed.Height()), diff --git a/tasks/fevm/contract/task.go b/tasks/fevm/contract/task.go index 25c41ae6a..3a70e7d0c 100644 --- a/tasks/fevm/contract/task.go +++ b/tasks/fevm/contract/task.go @@ -53,7 +53,8 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut actorChanges, err := p.node.ActorStateChanges(ctx, current, executed) if err != nil { - return nil, report, err + report.ErrorsDetected = err + return nil, report, nil } out := make(fevm.FEVMContractList, 0) @@ -109,10 +110,8 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut } if len(errs) > 0 { - err = fmt.Errorf("%v", errs) - } else { - err = nil + report.ErrorsDetected = fmt.Errorf("%v", errs) } - return model.PersistableList{out}, report, err + return model.PersistableList{out}, report, nil } diff --git a/tasks/fevm/receipt/tasks.go b/tasks/fevm/receipt/tasks.go index 9e16c874f..57da3e1a7 100644 --- a/tasks/fevm/receipt/tasks.go +++ b/tasks/fevm/receipt/tasks.go @@ -55,7 +55,8 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut messages, err := p.node.ChainGetMessagesInTipset(ctx, executed.Key()) if err != nil { log.Errorf("Error at getting messages. ts: %v, height: %v, err: %v", executed.String(), executed.Height(), err) - return nil, report, err + report.ErrorsDetected = err + return nil, report, nil } errs := []error{} out := make(fevm.FEVMReceiptList, 0) @@ -115,10 +116,8 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut } if len(errs) > 0 { - err = fmt.Errorf("%v", errs) - } else { - err = nil + report.ErrorsDetected = fmt.Errorf("%v", errs) } - return model.PersistableList{out}, report, err + return model.PersistableList{out}, report, nil } diff --git a/tasks/fevm/transaction/tasks.go b/tasks/fevm/transaction/tasks.go index 32690a4d6..666b9e734 100644 --- a/tasks/fevm/transaction/tasks.go +++ b/tasks/fevm/transaction/tasks.go @@ -53,7 +53,8 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut messages, err := p.node.ChainGetMessagesInTipset(ctx, executed.Key()) if err != nil { log.Errorf("Error at getting messages. ts: %v, height: %v, err: %v", executed.String(), executed.Height(), err) - return nil, report, err + report.ErrorsDetected = err + return nil, report, nil } errs := []error{} out := make(fevm.FEVMTransactionList, 0) @@ -127,10 +128,8 @@ func (p *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut } if len(errs) > 0 { - err = fmt.Errorf("%v", errs) - } else { - err = nil + report.ErrorsDetected = fmt.Errorf("%v", errs) } - return model.PersistableList{out}, report, err + return model.PersistableList{out}, report, nil }