aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-09-20 13:42:50 -0400
committerAva Chow <github@achow101.com>2024-09-20 13:42:50 -0400
commit48c20dbd86c29e7102a9ece016159f126c586de6 (patch)
tree2eafdf631a12a5e3e11354b2de2b44c520cf5bb3 /src
parent4148e60909e135dd4a728527ca94e9f5505c9ef8 (diff)
parentbc52cda1f3c007bdf1ed00aa3011e207c7531017 (diff)
downloadbitcoin-48c20dbd86c29e7102a9ece016159f126c586de6.tar.xz
Merge bitcoin/bitcoin#30794: interpreter: use int32_t instead of int type for risczero compile
bc52cda1f3c007bdf1ed00aa3011e207c7531017 fix use int32_t instead of int type for risczero compile with (-march=rv32i, -mabi=ilp32) (Simon) Pull request description: When compile bitcoin by the toolchain(`riscv32-unknown-elf-g++`) from risc0 , the compiler argument is `-march=rv32i, -mabi=ilp32`, which will get the error which due to not serialize the value of type int . ``` blockbody-guest: cargo:warning=In file included from depend/bitcoin/src/hash.h:14, blockbody-guest: cargo:warning= from depend/bitcoin/src/script/interpreter.h:9, blockbody-guest: cargo:warning= from depend/bitcoin/src/script/interpreter.cpp:6: blockbody-guest: cargo:warning=depend/bitcoin/src/serialize.h: In instantiation of 'void Serialize(Stream&, const T&) [with Stream = HashWriter; T = int]': blockbody-guest: cargo:warning=depend/bitcoin/src/hash.h:144:20: required from 'HashWriter& HashWriter::operator<<(const T&) [with T = int]' blockbody-guest: cargo:warning=depend/bitcoin/src/script/interpreter.cpp:1613:12: required from 'uint256 SignatureHash(const CScript&, const T&, unsigned int, int, const CAmount&, SigVersion, const PrecomputedTransactionData*) [with T = CTransaction; CAmount = long long int]' blockbody-guest: cargo:warning=depend/bitcoin/src/script/interpreter.cpp:1664:36: required from 'bool GenericTransactionSignatureChecker<T>::CheckECDSASignature(const std::vector<unsigned char>&, const std::vector<unsigned char>&, const CScript&, SigVersion) const [with T = CTransaction]' blockbody-guest: cargo:warning=depend/bitcoin/src/script/interpreter.cpp:1785:16: required from here blockbody-guest: cargo:warning=depend/bitcoin/src/serialize.h:776:7: error: request for member 'Serialize' in 'a', which is of non-class type 'const int' blockbody-guest: cargo:warning= 776 | a.Serialize(os); ``` -------------- ### Reason "The toolchain from RISC Zero defines int and int32_t as different types, although they have the same width. This means that `src/compat/assumptions.h` compiles fine; however, the templated serialization code cannot accept values of type int. Fix the compilation on RISC Zero by serializing int32_t instead of int values. This patch will explicitly use the `int32_t` type instead of `int` to avoid errors when compiling with the risc0 toolchain. Additionally, this patch will not change any behavior on platforms where compilation was previously successful. Fixes #30747 ACKs for top commit: maflcko: review-only ACK bc52cda1f3c007bdf1ed00aa3011e207c7531017 achow101: ACK bc52cda1f3c007bdf1ed00aa3011e207c7531017 TheCharlatan: ACK bc52cda1f3c007bdf1ed00aa3011e207c7531017 Tree-SHA512: ef880e7dfa1335bf2704ab17c0f506f17390b8259755674dfcd57131736492b2f4cfc36babda6902202b7c55a7513991e21f6634b0cd9b2b03baf4f1c0f8d78b
Diffstat (limited to 'src')
-rw-r--r--src/script/interpreter.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 9d0e9b5e3c..dcdddb88e9 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1303,7 +1303,7 @@ public:
// Serialize the nSequence
if (nInput != nIn && (fHashSingle || fHashNone))
// let the others update at will
- ::Serialize(s, int{0});
+ ::Serialize(s, int32_t{0});
else
::Serialize(s, txTo.vin[nInput].nSequence);
}
@@ -1565,7 +1565,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
}
template <class T>
-uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache)
+uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn, int32_t nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache)
{
assert(nIn < txTo.vin.size());