Proposed BIP for OP_CAT

Posted by Rusty Russell

Oct 24, 2023/03:45 UTC

In an email from Andrew Poelstra, he mentions that the diff being discussed is even smaller than the OP_CAT diff. He also expresses the need for refactoring the interpreter code, stating that using a class for the stack would be beneficial. The email includes a code snippet for the interpreter.cpp file, which shows modifications made to the EvalChecksig and EvalScript functions.

The first modification is the addition of a function called effective_size, which calculates the effective size of the stack. It takes into account that the first 520 bytes are free, but any additional bytes consume an extra slot in the stack. This function is used later in the EvalScript function.

The EvalScript function is responsible for evaluating a script. It takes a vector stack, a CScript script, flags, a BaseSignatureChecker checker, a SigVersion sigversion, a ScriptExecutionData execdata, and a ScriptError serror.

Within the EvalScript function, there is a check for size limits. Previously, the check was based on the total size of the stack and altstack combined being greater than the MAX_STACK_SIZE. Now, with the use of the effective_size function, the check takes into account the effective size of both the stack and altstack. If the effective size exceeds the MAX_STACK_SIZE, an error is returned.

Overall, this email discusses the small size of the diff compared to the OP_CAT diff and suggests refactoring the interpreter code by using a class for the stack. It also provides a code snippet showing modifications made to the EvalChecksig and EvalScript functions, including the addition of the effective_size function to calculate the effective size of the stack.

Link to Raw Post
Bitcoin Logo

TLDR

Join Our Newsletter

We’ll email you summaries of the latest discussions from authoritative bitcoin sources, like bitcoin-dev, lightning-dev, and Delving Bitcoin.

Explore all Products

ChatBTC imageBitcoin searchBitcoin TranscriptsSaving SatoshiBitcoin Transcripts Review
Built with 🧡 by the Bitcoin Dev Project
View our public visitor count

We'd love to hear your feedback on this project?

Give Feedback