Skip to content

use variable length slice for Solution to permit regtest#541

Merged
LarryRuane merged 1 commit intozcash:masterfrom
LarryRuane:2025-12-solution-slice-regtest
Jan 30, 2026
Merged

use variable length slice for Solution to permit regtest#541
LarryRuane merged 1 commit intozcash:masterfrom
LarryRuane:2025-12-solution-slice-regtest

Conversation

@LarryRuane
Copy link
Collaborator

This fixes the breaking of regtest caused by #505 (Change hash representation from slice to 32-byte array). There is no functional mainnet difference.

The Solution field within the block header has different sizes for regtest (36 bytes) and mainnet and testnet (1344 bytes), and #505 added the assumption that Solution is always 1344 bytes long. This is the one field whose length is compact-length encoded in the serialization, so it makes sense to treat it as variable length -- it could change in the future. (The other fields in the header are fixed-sized.) There is some unit test code that assumes 1344 bytes, but that's okay.

This PR replaces #533, which has been in draft status for a long time and seems to have been abandoned.

@LarryRuane LarryRuane changed the title use variable length slice for Solution to permit use of both regtest and mainnet use variable length slice for Solution to permit regtest Jan 7, 2026
@LarryRuane
Copy link
Collaborator Author

LarryRuane commented Jan 7, 2026

To test this using regtest:

$ rm -rf /tmp/zrtest
$ mkdir /tmp/zrtest
cat <<EOF >/tmp/zrtest/zcash.conf
regtest=1
lightwalletd=1
experimentalfeatures=1
debug=1
i-am-aware-zcashd-will-be-replaced-by-zebrad-and-zallet-in-2025=1
rpcpassword=light
EOF
$ zcashd -datadir=/tmp/zrtest

In another window, at the top level of the lightwalletd source directory:

$ go run main.go --zcash-conf-path /tmp/zrtest/zcash.conf --no-tls-very-insecure --log-file /dev/stdout

Without this PR, you'll see this in the log messages:

getblock 0 failed, will retry: error parsing block: parsing block header: solution length is not 1344 as expected

Copy link
Collaborator

@pacu pacu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. Looks good to me.

…and mainnet

This fixes the breaking of regtest by PR 505 (Change hash representation
from slice to 32-byte array). See also PR 533.

Co-authored-by: Larry Ruane <larry@electriccoin.co>
@LarryRuane LarryRuane force-pushed the 2025-12-solution-slice-regtest branch from e40459e to 2f2637f Compare January 30, 2026 18:06
@LarryRuane LarryRuane merged commit ac36aac into zcash:master Jan 30, 2026
3 checks passed
@LarryRuane LarryRuane deleted the 2025-12-solution-slice-regtest branch January 30, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants