Avoid Simplicity header dependency propogation
What changed, and why it matters
This commit is a straightforward build hygiene change. It moves a Simplicity library header include out of a widely-used header file and into the single source file that actually needs it, replacing the direct include with forward declarations. This reduces compile-time dependencies for other parts of the project and makes future build system changes easier. There is no functional change to how transactions or scripts are validated.
No security action required. Treat as normal build/maintenance refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes #include <simplicity/elements/env.h> from src/script/interpreter.h and adds it to src/script/interpreter.cpp. It introduces forward declarations for elementsTransaction and rawElementsTapEnv in interpreter.h and moves the definition of SimplicityTransactionDeleter::operator() into the .cpp file. This is a pure refactoring to prevent Simplicity header dependency propagation; no logic, interfaces, or security behavior are altered.
Changed components
src/script/interpreter.hsrc/script/interpreter.cppInspect captured patch +10 / −7
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index d01d4a1..4983434 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -13,6 +13,7 @@
#include <script/script.h>
#include <uint256.h>
extern "C" {
+#include <simplicity/elements/env.h>
#include <simplicity/elements/exec.h>
#include <simplicity/errorCodes.h>
}
@@ -2675,6 +2676,10 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
}
}
+void SimplicityTransactionDeleter::operator()(elementsTransaction* ptr) const {
+ simplicity_elements_freeTransaction(ptr);
+}
+
template <class T>
PrecomputedTransactionData::PrecomputedTransactionData(const T& txTo)
: PrecomputedTransactionData(uint256{})
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index 6ec8339..9bfab86 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -10,9 +10,6 @@
#include <script/script_error.h>
#include <span.h>
#include <primitives/transaction.h>
-extern "C" {
-#include <simplicity/elements/env.h>
-}
#include <optional>
#include <vector>
@@ -169,12 +166,13 @@ enum : uint32_t {
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
+// Forward declarations of Simplicity structures.
+struct elementsTransaction;
+struct rawElementsTapEnv;
+
struct SimplicityTransactionDeleter
{
- void operator()(elementsTransaction* ptr)
- {
- simplicity_elements_freeTransaction(ptr);
- }
+ void operator()(elementsTransaction* ptr) const;
};
using SimplicityTransactionUniquePtr = std::unique_ptr<elementsTransaction, SimplicityTransactionDeleter>;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.