Skip to main content
£0.00 0

Basket

No products in the basket.

ASIC mining articles and advice

BIP 117 Tail-Call Execution Semantics: Draft Script Guide

BIP 117 guide covering its Draft single tail-call execution rule, SegWit restriction, stack transfer, MAST use with BIP 116 and consensus testing.

BIP 117 Tail Call Execution Semantics guide cover

This guide explains BIP 117 Tail Call Execution Semantics in plain English. It covers the problem behind the BIP, why it matters and whether the proposal is part of Bitcoin today.

TL;DR

  • What it is: BIP 117 is a Draft soft-fork proposal for limited tail-call execution in Bitcoin Script. Under tightly defined end-of-script conditions, a serialised script left on the stack would be popped and executed while remaining stack values became its arguments.
  • Why it matters: BIP 117 offers a constrained route to executing a selected hidden policy, but it is not general recursion and is not active consensus. Safe research requires exact stack semantics, one-level resource bounds and differential activation tests.
  • Current position: These semantics are not active Bitcoin consensus.

BIP 117 Tail Call Execution Semantics in simple English

BIP 117 Tail Call Execution Semantics: A tail call transfers execution to a final subscript rather than returning to the caller. The original script finishes by placing the selected serialised policy on the stack.

Simple example

A node operator is checking BIP 117 Tail Call Execution Semantics. Test the largest allowed caller, callee, stack and witness combination and ensure failure is deterministic before resource exhaustion.

Key terms in plain English

BIP:
Bitcoin Improvement Proposal: a document describing a proposed rule, standard or process. Its status must be checked separately.
Consensus:
The shared rules full nodes use to decide whether blocks and transactions are valid.
Node:
A computer running Bitcoin software that checks data and communicates with other peers.

What tail-call mean

A tail call transfers execution to a final subscript rather than returning to the caller. The original script finishes by placing the selected serialised policy on the stack; the interpreter resets specified state and begins that policy with the remaining stack and alt-stack as inputs. There is no general EVAL instruction and no arbitrary return path.

Trigger conditions

The proposed interpreter change only applies when the script stop with the required stack shape and truthy script element. The exact cases differ for one script element and encoded argument counts. Any ambiguity in boolean conversion, minimal number encoding, stack counts or alt-stack handling can create consensus divergence, so vectors must cover every neighbouring condition.

Why only SegWit

Direct scriptPubKey and P2SH tail calls were excluded because legacy script and signature-hashing properties can create resource and quadratic-cost problems. The BIP allows one layer inside a SegWit execution context, where relevant malleability and hashing issues are constrained. This is a proposal-specific boundary, not a claim that every SegWit script can execute dynamic code.

BIP 117 Tail Call Execution Semantics technical diagram
Why only SegWit: the fields, validation boundary and operational evidence that implementations need to agree.

One-level resource limit

Unrestricted recursive evaluation would require a new way to meter script work, witness size, signature checks, memory and distribution cost. Limiting execution to one tail call avoids recursion but does not remove the need for normal script limits. Test the largest allowed caller, callee, stack and witness combination and ensure failure is deterministic before resource exhaustion.

Generalised MAST combination

With BIP 116, the caller can verify that a disclosed policy script belongs to a committed Merkle tree and then tail-call it. Only the exercised policy needs to be revealed. The construction inherits MBV proof rules plus callee execution rules, and neither BIP is deployed. Testing one component successfully does not establish the combined consensus behaviour.

Clean-stack and arguments

SegWit version-zero clean-stack rules complicate forwarding multiple arguments. The examples use the alt-stack and explicit counts so the policy receives its parameters without leaving extra main-stack elements. Contract tooling must prove argument order and count, reject unused values that permit witness malleability, and display the actual selected policy to reviewers.

How specialists test it

Developers test the proposal with made-up data on an isolated test network. They check normal cases and deliberately invalid cases. Different implementations should reach the same result before anyone relies on the proposal.

Frequently asked questions

What is the main point of BIP 117 Tail Call Execution Semantics?

BIP 117 Tail Call Execution Semantics: A tail call transfers execution to a final subscript rather than returning to the caller.

For BIP 117 Tail Call Execution Semantics, what should a beginner know about what tail-call means?

A tail call transfers execution to a final subscript rather than returning to the caller.

For BIP 117 Tail Call Execution Semantics, what should a beginner know about trigger conditions?

The proposed interpreter change only applies when the script stop with the required stack shape and truthy script element.

For BIP 117 Tail Call Execution Semantics, why only SegWit?

Direct scriptPubKey and P2SH tail calls were excluded because legacy script and signature-hashing properties can create resource and quadratic-cost problems.

Conclusion

BIP 117 offers a constrained route to executing a selected hidden policy, but it is not general recursion and is not active consensus. Safe research requires exact stack semantics, one-level resource bounds and differential activation tests.

Primary sources

Check the current specification status and the documentation for the exact implementation you operate before moving production funds or changing a mining node.

ASIC MINER PICKS

Recommended ASIC Mining Hardware

Compare three of our highest ranked ASIC miners currently available, with live product details and pricing.
Browse all ASIC miners
MORE MINING ADVICE

More ASIC Mining Articles

Read practical advice about choosing hardware, calculating electricity costs, setting up miners, hosting and maintenance.
MINER COMMUNITY

Join the ASIC Mining Discussion

Ask a question or share what has worked for you. Your experience may help another miner make a better decision.

Members can read and join the discussion

Log in to read comments from other miners. Create a free account if you would like to ask a question or share your experience.

Log in to read comments Register to join the discussion

Membership helps us protect the discussion from spam and keep answers useful.

ASIC MINING SUPPORT

Need Help Choosing an ASIC Miner?

Tell us what you want to mine, your electricity cost and where the machine will run. We can help you compare hardware, power requirements, hosting and repairs.
Contact our mining team
Browse ASIC miners