Skip to content

Commit 48c20db

Browse files
committed
Merge bitcoin/bitcoin#30794: interpreter: use int32_t instead of int type for risczero compile
bc52cda 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 bc52cda achow101: ACK bc52cda TheCharlatan: ACK bc52cda Tree-SHA512: ef880e7dfa1335bf2704ab17c0f506f17390b8259755674dfcd57131736492b2f4cfc36babda6902202b7c55a7513991e21f6634b0cd9b2b03baf4f1c0f8d78b
2 parents 4148e60 + bc52cda commit 48c20db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/script/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ class CTransactionSignatureSerializer
13031303
// Serialize the nSequence
13041304
if (nInput != nIn && (fHashSingle || fHashNone))
13051305
// let the others update at will
1306-
::Serialize(s, int{0});
1306+
::Serialize(s, int32_t{0});
13071307
else
13081308
::Serialize(s, txTo.vin[nInput].nSequence);
13091309
}
@@ -1565,7 +1565,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
15651565
}
15661566

15671567
template <class T>
1568-
uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache)
1568+
uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn, int32_t nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache)
15691569
{
15701570
assert(nIn < txTo.vin.size());
15711571

0 commit comments

Comments
 (0)