From a81e6dd35e6ac4daa3f8b12fb08a942a634e87c6 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 09:46:38 +0000 Subject: [PATCH 01/11] fix: msapprovals missing pending transaction --- tasks/msapprovals/msapprovals.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index fac353a0e..855e78859 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -13,6 +13,7 @@ import ( sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" multisig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" "github.com/ipfs/go-cid" + logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" "github.com/filecoin-project/sentinel-visor/lens" @@ -21,6 +22,8 @@ import ( visormodel "github.com/filecoin-project/sentinel-visor/model/visor" ) +var log = logging.Logger("msapprovals") + const ( ProposeMethodNum = 2 ApproveMethodNum = 3 @@ -260,6 +263,7 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, var tx transaction if err := prevActorState.ForEachPendingTxn(func(id int64, txn multisig.Transaction) error { + log.Debugw("found pending transaction", "id", id, "to", txn.To.String()) if id == int64(params.ID) { tx.id = int64(params.ID) tx.to = txn.To.String() From 0c76fc07ffd9c26a1614dbee28df3f5da769414b Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 10:04:02 +0000 Subject: [PATCH 02/11] logging --- tasks/msapprovals/msapprovals.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index 855e78859..7f3f7fd40 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -85,6 +85,7 @@ func (p *Task) ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types applied, tx, err := p.getTransactionIfApplied(ctx, m.Message, m.Receipt, pts) if err != nil { + log.Debugw("failed to get transaction", "error", err.Error(), "addr", m.Message.To.String()) errorsDetected = append(errorsDetected, &MultisigError{ Addr: m.Message.To.String(), Error: xerrors.Errorf("failed to find transaction: %w", err).Error(), From 5077db6eb036e6d2afd9ea2c34c9ee560f5d3aa8 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 10:42:29 +0000 Subject: [PATCH 03/11] logging --- tasks/actorstate/multisig.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/actorstate/multisig.go b/tasks/actorstate/multisig.go index 33b37e3db..b22e29fb9 100644 --- a/tasks/actorstate/multisig.go +++ b/tasks/actorstate/multisig.go @@ -113,6 +113,9 @@ func ExtractMultisigTransactions(a ActorInfo, ec *MsigExtractionContext) (multis }) } + for _, removed := range changes.Removed { + log.Debugw("multisig tx removed", "id", removed.TxID, "to", removed.Tx.To.String()) + } return out, nil } From 71eb1a5de75a6d3d2a0153869e85e65cf8eee128 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 10:58:14 +0000 Subject: [PATCH 04/11] logging --- tasks/msapprovals/msapprovals.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index 7f3f7fd40..8dbdb08f6 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -83,7 +83,7 @@ func (p *Task) ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types continue } - applied, tx, err := p.getTransactionIfApplied(ctx, m.Message, m.Receipt, pts) + applied, tx, err := p.getTransactionIfApplied(ctx, m.Message, m.Receipt, ts, pts) if err != nil { log.Debugw("failed to get transaction", "error", err.Error(), "addr", m.Message.To.String()) errorsDetected = append(errorsDetected, &MultisigError{ @@ -198,7 +198,7 @@ type transaction struct { // getTransactionIfApplied returns the transaction associated with the message if the transaction was applied (i.e. had enough // approvals). Returns true and the transaction if the transaction was applied, false otherwise. -func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, rcpt *types.MessageReceipt, pts *types.TipSet) (bool, *transaction, error) { +func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, rcpt *types.MessageReceipt, ts, pts *types.TipSet) (bool, *transaction, error) { switch msg.Method { case ProposeMethodNum: // If the message is a proposal then the parameters will contain details of the transaction @@ -251,7 +251,7 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, } // Get state of actor before the message was applied - act, err := p.node.StateGetActor(ctx, msg.To, pts.Key()) + act, err := p.node.StateGetActor(ctx, msg.To, ts.Key()) if err != nil { return false, nil, xerrors.Errorf("failed to load previous actor: %w", err) } From 6e9ca7073b6e054b8ad832ac61c4ce63a83598cc Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 11:09:54 +0000 Subject: [PATCH 05/11] fix loop --- tasks/msapprovals/msapprovals.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index 8dbdb08f6..8d07039af 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -261,22 +261,26 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, return false, nil, xerrors.Errorf("failed to load previous actor state: %w", err) } - var tx transaction + var tx *transaction if err := prevActorState.ForEachPendingTxn(func(id int64, txn multisig.Transaction) error { - log.Debugw("found pending transaction", "id", id, "to", txn.To.String()) if id == int64(params.ID) { - tx.id = int64(params.ID) - tx.to = txn.To.String() - tx.value = txn.Value.String() - return nil + tx = &transaction{ + id: int64(params.ID), + to: txn.To.String(), + value: txn.Value.String(), + } } - return xerrors.Errorf("pending transaction %d not found", params.ID) + return nil }); err != nil { return false, nil, xerrors.Errorf("failed to read transaction details: %w", err) } - return true, &tx, nil + if tx == nil { + return false, nil, xerrors.Errorf("pending transaction %d not found", params.ID) + } + + return true, tx, nil default: // Not interested in any other methods From 4cfce46711e0ab783d98b69525f239682054fcb9 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 11:11:42 +0000 Subject: [PATCH 06/11] logging --- tasks/msapprovals/msapprovals.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index 8d07039af..afa333366 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -264,6 +264,7 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, var tx *transaction if err := prevActorState.ForEachPendingTxn(func(id int64, txn multisig.Transaction) error { + log.Debugf("reading pending txn", "id", id, "to", txn.To.String()) if id == int64(params.ID) { tx = &transaction{ id: int64(params.ID), From 0180d78fdc6f008e25ae2db03539bc95a3fdfb69 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 11:13:14 +0000 Subject: [PATCH 07/11] logging --- tasks/msapprovals/msapprovals.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index afa333366..fdb6ec668 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -83,7 +83,7 @@ func (p *Task) ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types continue } - applied, tx, err := p.getTransactionIfApplied(ctx, m.Message, m.Receipt, ts, pts) + applied, tx, err := p.getTransactionIfApplied(ctx, m.Message, m.Receipt, pts) if err != nil { log.Debugw("failed to get transaction", "error", err.Error(), "addr", m.Message.To.String()) errorsDetected = append(errorsDetected, &MultisigError{ @@ -198,7 +198,7 @@ type transaction struct { // getTransactionIfApplied returns the transaction associated with the message if the transaction was applied (i.e. had enough // approvals). Returns true and the transaction if the transaction was applied, false otherwise. -func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, rcpt *types.MessageReceipt, ts, pts *types.TipSet) (bool, *transaction, error) { +func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, rcpt *types.MessageReceipt, pts *types.TipSet) (bool, *transaction, error) { switch msg.Method { case ProposeMethodNum: // If the message is a proposal then the parameters will contain details of the transaction @@ -251,7 +251,7 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, } // Get state of actor before the message was applied - act, err := p.node.StateGetActor(ctx, msg.To, ts.Key()) + act, err := p.node.StateGetActor(ctx, msg.To, pts.Key()) if err != nil { return false, nil, xerrors.Errorf("failed to load previous actor: %w", err) } @@ -264,7 +264,7 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, var tx *transaction if err := prevActorState.ForEachPendingTxn(func(id int64, txn multisig.Transaction) error { - log.Debugf("reading pending txn", "id", id, "to", txn.To.String()) + log.Debugw("reading pending txn", "id", id, "to", txn.To.String()) if id == int64(params.ID) { tx = &transaction{ id: int64(params.ID), From d1bc9c58983e0550686b9fccc0c535034a4f17aa Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 11:16:22 +0000 Subject: [PATCH 08/11] logging --- tasks/msapprovals/msapprovals.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index fdb6ec668..afc7a33a3 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -42,6 +42,8 @@ func NewTask(opener lens.APIOpener) *Task { } func (p *Task) ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types.TipSet, emsgs []*lens.ExecutedMessage) (model.Persistable, *visormodel.ProcessingReport, error) { + log.Debugw("ProcessMessages", "ts_height", ts.Height(), "pts_height", pts.Height()) + // TODO: refactor this boilerplate into a helper if p.node == nil { node, closer, err := p.opener.Open(ctx) From ed4b371925b7704aac4fd63e3a1e2ebc818a521c Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 11:26:38 +0000 Subject: [PATCH 09/11] logging --- tasks/actorstate/multisig.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasks/actorstate/multisig.go b/tasks/actorstate/multisig.go index b22e29fb9..1000080e5 100644 --- a/tasks/actorstate/multisig.go +++ b/tasks/actorstate/multisig.go @@ -144,6 +144,13 @@ func NewMultiSigExtractionContext(ctx context.Context, a ActorInfo, node ActorSt prevState := curState if a.Epoch != 0 { + + prevTipset, err := node.ChainGetTipSet(ctx, a.ParentTipSet) + if err != nil { + return nil, xerrors.Errorf("loading current tipset %s: %w", a.TipSet.String(), err) + } + log.Debugw("MultiSigActorExtractor", "ts_height", curTipset.Height(), "pts_height", prevTipset.Height()) + prevActor, err := node.StateGetActor(ctx, a.Address, a.ParentTipSet) if err != nil { return nil, xerrors.Errorf("loading previous multisig %s at tipset %s epoch %d: %w", a.Address, a.ParentTipSet, a.Epoch, err) From 08b5e17df0d387efda6f73a9670f934b4577f599 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 11:30:51 +0000 Subject: [PATCH 10/11] logging --- tasks/msapprovals/msapprovals.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index afc7a33a3..9cda98bf8 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -253,7 +253,7 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, } // Get state of actor before the message was applied - act, err := p.node.StateGetActor(ctx, msg.To, pts.Key()) + act, err := p.node.StateGetActor(ctx, msg.To, pts.Parents()) if err != nil { return false, nil, xerrors.Errorf("failed to load previous actor: %w", err) } From 268a832c844ff40c3e21a58cdf5e08147ba0a82b Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 19 Feb 2021 11:34:39 +0000 Subject: [PATCH 11/11] clean up logging --- tasks/actorstate/multisig.go | 12 ------------ tasks/msapprovals/msapprovals.go | 9 ++------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/tasks/actorstate/multisig.go b/tasks/actorstate/multisig.go index 1000080e5..dd7e81863 100644 --- a/tasks/actorstate/multisig.go +++ b/tasks/actorstate/multisig.go @@ -75,8 +75,6 @@ func ExtractMultisigTransactions(a ActorInfo, ec *MsigExtractionContext) (multis return nil, xerrors.Errorf("diffing pending transactions: %w", err) } - log.Debugw("multisig diff", "added", len(changes.Added), "modified", len(changes.Modified), "removed", len(changes.Removed)) - for _, added := range changes.Added { approved := make([]string, len(added.Tx.Approved)) for i, addr := range added.Tx.Approved { @@ -113,9 +111,6 @@ func ExtractMultisigTransactions(a ActorInfo, ec *MsigExtractionContext) (multis }) } - for _, removed := range changes.Removed { - log.Debugw("multisig tx removed", "id", removed.TxID, "to", removed.Tx.To.String()) - } return out, nil } @@ -144,13 +139,6 @@ func NewMultiSigExtractionContext(ctx context.Context, a ActorInfo, node ActorSt prevState := curState if a.Epoch != 0 { - - prevTipset, err := node.ChainGetTipSet(ctx, a.ParentTipSet) - if err != nil { - return nil, xerrors.Errorf("loading current tipset %s: %w", a.TipSet.String(), err) - } - log.Debugw("MultiSigActorExtractor", "ts_height", curTipset.Height(), "pts_height", prevTipset.Height()) - prevActor, err := node.StateGetActor(ctx, a.Address, a.ParentTipSet) if err != nil { return nil, xerrors.Errorf("loading previous multisig %s at tipset %s epoch %d: %w", a.Address, a.ParentTipSet, a.Epoch, err) diff --git a/tasks/msapprovals/msapprovals.go b/tasks/msapprovals/msapprovals.go index 9cda98bf8..eda684fce 100644 --- a/tasks/msapprovals/msapprovals.go +++ b/tasks/msapprovals/msapprovals.go @@ -13,7 +13,6 @@ import ( sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" multisig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" "github.com/ipfs/go-cid" - logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" "github.com/filecoin-project/sentinel-visor/lens" @@ -22,8 +21,6 @@ import ( visormodel "github.com/filecoin-project/sentinel-visor/model/visor" ) -var log = logging.Logger("msapprovals") - const ( ProposeMethodNum = 2 ApproveMethodNum = 3 @@ -42,8 +39,6 @@ func NewTask(opener lens.APIOpener) *Task { } func (p *Task) ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types.TipSet, emsgs []*lens.ExecutedMessage) (model.Persistable, *visormodel.ProcessingReport, error) { - log.Debugw("ProcessMessages", "ts_height", ts.Height(), "pts_height", pts.Height()) - // TODO: refactor this boilerplate into a helper if p.node == nil { node, closer, err := p.opener.Open(ctx) @@ -87,7 +82,6 @@ func (p *Task) ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types applied, tx, err := p.getTransactionIfApplied(ctx, m.Message, m.Receipt, pts) if err != nil { - log.Debugw("failed to get transaction", "error", err.Error(), "addr", m.Message.To.String()) errorsDetected = append(errorsDetected, &MultisigError{ Addr: m.Message.To.String(), Error: xerrors.Errorf("failed to find transaction: %w", err).Error(), @@ -253,6 +247,8 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, } // Get state of actor before the message was applied + // pts is the tipset containing the messages, so we need the state as seen at the start of message processing + // for that tipset act, err := p.node.StateGetActor(ctx, msg.To, pts.Parents()) if err != nil { return false, nil, xerrors.Errorf("failed to load previous actor: %w", err) @@ -266,7 +262,6 @@ func (p *Task) getTransactionIfApplied(ctx context.Context, msg *types.Message, var tx *transaction if err := prevActorState.ForEachPendingTxn(func(id int64, txn multisig.Transaction) error { - log.Debugw("reading pending txn", "id", id, "to", txn.To.String()) if id == int64(params.ID) { tx = &transaction{ id: int64(params.ID),