Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: msapprovals missing pending transaction #395

Merged
merged 11 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions tasks/actorstate/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 15 additions & 8 deletions tasks/msapprovals/msapprovals.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ 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())
// 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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some underlying behaviour change that now we need to use the parents?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but pts is the tipset containing the message, so we need to look at the actor state before the message was applied

if err != nil {
return false, nil, xerrors.Errorf("failed to load previous actor: %w", err)
}
Expand All @@ -257,21 +259,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 {
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
Expand Down