Skip to content

Risczero Fit #30747

@ludete

Description

@ludete

Please describe the feature you'd like to see added.

Support the risczero platfrom by riscv32-unknown-elf-g++. which will bring more prove system for bitcoin.

Is your feature related to a problem, if so please describe it.

when i compile by riscv32-unknown-elf-g++ compiler, get the below error:

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);

This error is caused by the logic in the SignatureHash function within src/script/interpreter.cpp. The function serializes the data to obtain a hash value, but it fails to find a serialization method for the int type.

// Sighash type
ss << nHashType;

This behavior is particularly strict in environments like RISC-V, where the ABI (Application Binary Interface) might enforce more rigid type distinctions, leading to errors during compilation.

The -march=rv32i -mabi=ilp32 for the compiler(riscv32-unknown-elf-g++).

Describe the solution you'd like

This issue was temporarily bypassed by adding serialization/deserialization code for the int type. Supporting R0 will allow the BTC L2 prover to extend to more proof systems.

Add methods temporarily in the PR
: https://github.com/rust-bitcoin/rust-bitcoinconsensus/pull/97/files; Maybe best solution from the commiunity.

Describe any alternatives you've considered

No response

Please leave any additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions