Skip to content

monerod revalidates the whole tx-pool on HFs #10142

@Boog900

Description

@Boog900

When adding a block and the HF changes the tx-pool is re-validated:

const uint8_t new_hf_version = get_current_hard_fork_version();
if (new_hf_version != hf_version)
{
// the genesis block is added before everything's setup, and the txpool is empty
// when we start from scratch, so we skip this
const bool is_genesis_block = new_height == 1;
if (!is_genesis_block)
{
MGINFO("Validating txpool for v" << (unsigned)new_hf_version);
m_tx_pool.validate(new_hf_version);
}
}

Which would freeze up the node for a while with a big tx-pool. Cuprate caches when a tx was validated with the tx in the pool: https://github.com/Cuprate/cuprate/blob/065054996d4db3e86a02205ed01aa6a6286003a6/types/types/src/transaction_verification_data.rs#L35 so we don't need to do tx-pool re-validation at start up/when a HF changes, we only re-validate a single tx if the current blockchain state requires it compared to the cached verification.

monerod could probably do something similar, just caching the HF each tx was validated at and doing ver_non_input_consensus added in #9135 if the HF has changed when adding the tx to the blockchain, skipping the need for re-validation of the whole txpool at the same time.

Originally posted by @Boog900 in #9404 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions