Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v1 audit improvements#5460

Merged
softsimon merged 3 commits intomasterfrom
mononaut/v1-audit-improvements
Aug 26, 2024
Merged

v1 audit improvements#5460
softsimon merged 3 commits intomasterfrom
mononaut/v1-audit-improvements

Conversation

@mononaut
Copy link
Contributor

@mononaut mononaut commented Aug 17, 2024

This PR improves on the method introduced in #5354 for detecting prioritized transactions in mined blocks.

Background

That naive algorithm assumed that transactions would only ever have their priority increased out-of-band, and so simply iterated over the set of transactions and marked anything positioned higher than expected as "prioritized".

However, if any transactions in the block had actually been deprioritized, this approach could produce (potentially very many) false positives.

For example, Ocean block 856119 includes several small inscriptions, which Ocean's default template deprioritizes by applying a datacarriercost penalty. The previous algorithm interpreted the large number of subsequent "normal" transactions as prioritized, since they had lower apparent fee rates than the later inscriptions:

Screenshot 2024-08-17 at 1 33 27 AM


Solution

The new algorithm implemented in this PR broadens the assumptions to allow for deprioritization, and efficiently figures out the most likely sets of prioritizations and deprioritizations to explain the composition of the block.

The precise details are a little complicated, but essentially the algorithm involves computing the Longest Increasing Subsequence of transactions in the block, which represents the most likely set of "normal" transactions without any out-of-band fee adjustments. Any other transactions falling outside of that set have probably been prioritized or penalized, depending whether they appear higher or lower than expected based on their simple in-band effective fee rates.

Screenshot 2024-08-17 at 1 48 11 AM
here, the dark blue transactions represent deprioritized inscriptions in the same Ocean block (see the "Other changes" section below)


Effects

In practice, the new algorithm produces exactly the same results as the old one for the 99%+ blocks constructed using default Bitcoin Core settings.

But for the occasional block constructed with, e.g, datacarriercost penalties, it very effectively mitigates the false positive issue.


Other changes

The new algorithm is capable of efficiently detecting both prioritized and deprioritized transactions, and only requires the block summary data which is already available on the block page.

So this PR also runs the calculation in the frontend, and (where appropriate), identifies and highlights any deprioritized transactions in the block audit.

Screenshot 2024-08-17 at 1 49 52 AM

Once the algorithm is a bit more battle-tested, we can start saving those lists of deprioritized transactions to the block audits DB table so that the data is also available on the transaction page etc.

DB migration

Since only four five blocks were affected by false positives from the previous algorithm, this PR adds a database migration to directly fix those specific audits in the DB (if present).

@mononaut mononaut requested review from softsimon and wiz as code owners August 17, 2024 01:57
@cla-bot cla-bot bot added the cla-signed label Aug 17, 2024
@mononaut mononaut force-pushed the mononaut/v1-audit-improvements branch from ac47780 to 8af1a68 Compare August 18, 2024 01:34
@mononaut mononaut force-pushed the mononaut/v1-audit-improvements branch from 8af1a68 to c917122 Compare August 18, 2024 02:21
@wiz wiz added this to the v3.1 milestone Aug 18, 2024
Copy link
Member

@softsimon softsimon left a comment

Choose a reason for hiding this comment

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

tested ACK @ [6208558]

@softsimon softsimon merged commit a0fc486 into master Aug 26, 2024
@softsimon softsimon deleted the mononaut/v1-audit-improvements branch August 26, 2024 19:38
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