Currently, the multisig descriptor constructions are limited to 16 keys only possibly because of template parsing reasons. Under p2sh context, such scripts would be invalid anyway because of 520-byte rule, but we can support up to 20 keys for CHECKMULTISIG in witness script context. 


{
    std::vector<valtype> stack{stack_span.begin(), stack_span.end()};
    if (sigversion == SigVersion::TAPSCRIPT) {
        
        CScript::const_iterator pc = scriptPubKey.begin();
        while (pc < scriptPubKey.end()) {
            opcodetype opcode;
            if (!scriptPubKey.GetOp(pc, opcode)) {
                
                return set_error(serror, SCRIPT_ERR_BAD_OPCODE);
            }
            
            if (IsOpSuccess(opcode)) {
                if (flags & SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS) {
                    return set_error(serror, SCRIPT_ERR_DISCOURAGE_OP_SUCCESS);
                }
                return set_success(serror);
            }
        }
        
        if (stack.size() > MAX_STACK_SIZE) return set_error(serror, SCRIPT_ERR_STACK_SIZE);
    }
    
    for (const valtype& elem : stack) {
        if (elem.size() > MAX_SCRIPT_ELEMENT_SIZE) return set_error(serror, SCRIPT_ERR_PUSH_SIZE);
    }
    
    if (!EvalScript(stack, scriptPubKey, flags, checker, sigversion, execdata, serror)) return false;
    
    if (stack.size() != 1) return set_error(serror, SCRIPT_ERR_CLEANSTACK);