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

txpool: Fix incorrect datatype checking in recomputeBlockEvaluator #2155

Merged
merged 1 commit into from
May 14, 2021

Conversation

tsachiherman
Copy link
Contributor

Summary

When the recomputeBlockEvaluator runs, it tests all the pending transactions against the ledger to detect duplicate transactions ( which happen all the time; these aren't an issue ).
The block evaluator reports the error by returning *ledgercore.TransactionInLedgerError and not ledgercore.TransactionInLedgerError as the code was testing against.

Note

Yet another one character bug fix.

Test Plan

The bug would only affect the reported block assembly stats, and therefore the issue was validated against the telemetry.

Copy link
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Looks correct.
However, I prefer that the error be returned by value, and the pointer be inside the error struct.

@@ -695,7 +695,7 @@ func (pool *TransactionPool) recomputeBlockEvaluator(committedTxIds map[transact
}

switch err.(type) {
case ledgercore.TransactionInLedgerError:
case *ledgercore.TransactionInLedgerError:
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks confusing, and can be mistaken somewhere else.
Why not return the error by value, and make the Txid inside it a pointer, if copying it is a concern?
type TransactionInLedgerError struct {
Txid *transactions.Txid
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. We clearly need to figure this out. However, as you've noted, it could be a sensitive issue where fixing it incorrectly could lead to other issues. That's why I opted in for the simple fix.

@tsachiherman tsachiherman merged commit 3021d15 into algorand:master May 14, 2021
@tsachiherman tsachiherman deleted the tsachi/txpooldup branch May 14, 2021 12:51
tsachiherman added a commit to tsachiherman/go-algorand that referenced this pull request Jul 7, 2021
)

When the recomputeBlockEvaluator runs, it tests all the pending transactions against the ledger to detect duplicate transactions ( which happen all the time; these aren't an issue ).
The block evaluator reports the error by returning `*ledgercore.TransactionInLedgerError` and not `ledgercore.TransactionInLedgerError` as the code was testing against.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants