Bitcoin full node and query server

May 9, 2025

View in context in the libbitcoin Slack #general mirror.

evoskuil05:34
On the call today I mentioned that we are now precomputing (1) success opcode, (2) invalid opcode, and (3) op_roll existence in all scripts during parse. This includes reading off the wire and from the store, though it's very efficient since the iteration is already necessary. Previously we were only testing for invalid during parse, and op_roll was computed on the fly prior to script execution. This saved one bit (bool) per script, which wasn't really worth it, since the two flags would just be packed into one byte by the compiler. And since we otherwise need another iteration for the success codes prior to tapscript execution, it was an easy choice to just put these all into the script parser, which basically looks like this (emplace invokes chain::op(reader) to perform an in-place construction on the operation stack).
    while (!source.is_exhausted())
    {
        ops_.emplace_back(source);
        const auto& op = ops_.back();
        easier_ |= op.is_success();
        failer_ |= op.is_invalid();
        roller_ |= op.is_roller();
    }