1

When a transaction is being checked for validity, is there a particular order that the inputs are evaluated for script correctness?

This might be relevant when determining what consensus changes might be practical to design. For example, if we wanted to add incremental metadata for a given transaction during validation -- for example, "sum the nValues for inputs that are related ways x, y, z - but do it on the fly so we don't impair validation speed."

Whether or not inputs are validated in a certain order would help gauge the feasibility of a consensus change that relayed on those kinds of "lazy" data computation.


Right now in the source code, the CheckInputScripts() function creates CScriptCheck objects in order of vin. Does this mean that input scripts are validated in order of vin-index?

// validation.cpp

    for (unsigned int i = 0; i < tx.vin.size(); i++) {
        [...]

        // Verify signature
        CScriptCheck check(txdata.m_spent_outputs[i], tx, i, flags, cacheSigStore, &txdata);
        if (pvChecks) {
            pvChecks->push_back(CScriptCheck());

If we got cross-input signature aggregation, would that change such an ordering?

1 Answer 1

2

Inputs are not necessarily evaluated for script validity in any particular order. Indeed, today certain calls to CheckInputScripts() will push the created CScriptCheck objects onto a vector (pvChecks). Those script check objects will be pulled off the vector by asynchronous workers and may be evaluated in any order.

Since there is no particular ordering today, the implementation of cross-input signature aggregation will not affect any guarantees that exist today.

This lack of ordered script checking may make dynamically computing certain data about "like" inputs difficult, which may be relevant when trying to design covenants whose spends can be batched together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.