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

tx_pool: full tx revalidation on fork boundaries #7169

Merged
merged 1 commit into from
Nov 10, 2021

Conversation

moneromooo-monero
Copy link
Collaborator

avoids mining txes after a fork that are invalid by this fork's
rules, but were valid by the previous fork rules at the time
they were verified and added to the txpool.

@moneromooo-monero moneromooo-monero force-pushed the txpv branch 3 times, most recently from 032444a to bbbcc51 Compare October 15, 2021 21:49
Copy link
Collaborator

@j-berman j-berman left a comment

Choose a reason for hiding this comment

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

LGTM

One question: it looks like all tx's from the pool are loaded into memory -- would this be a concern? Thinking of a scenario where someone malicious tries to cause issues at hard fork time by spamming. The default cap on the pool is ~618 MB and it can be adjusted lower via a param for lower end hardware, so probably not I would think (which is why I approved)

// get all txids
std::vector<tx_entry_t> txes;
m_blockchain.for_all_txpool_txes([this, &txes](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata_ref*) {
if (!meta.pruned) // skip pruned txes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, my reading of this is that at the fork, pruned nodes won't have any validation logic a number of their tx's meet the fork's new rules (even on tx weight). So at fork time, pruned nodes would be relying on non-pruned nodes to avoid any issues, which seems alright? Am I reading that right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In normal "cruise" usage, transactions get pruned after 5500 blocks.
The only way a pruned tx can get into the txpool is when it is an old tx that was requested by a syncing node. In that case, this only gets requested if the node has a known block hash to compare it with, and this test will not matter.

@moneromooo-monero
Copy link
Collaborator Author

That is a good point, they don't seem to need to be loaded at once. I'll fix that.

@moneromooo-monero
Copy link
Collaborator Author

Well, loaded fully parsed in memory at least.

avoids mining txes after a fork that are invalid by this fork's
rules, but were valid by the previous fork rules at the time
they were verified and added to the txpool.
@moneromooo-monero
Copy link
Collaborator Author

Done, though tbh I don't remember the original test case. Simple enough though.

Copy link
Collaborator

@j-berman j-berman left a comment

Choose a reason for hiding this comment

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

Update looks good

I also used the view tag stuff I've been working on to test behavior. I repro'd the scenario without this code, then added this code to make sure invalid tx's that were valid prior to fork height would get ejected from the pool at fork height. It worked as expected

@luigi1111 luigi1111 merged commit c3b1b94 into monero-project:master Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants