Skip to content

chore: rebuild native libs with the electrum block.headers fix - #143

Merged
jvsena42 merged 1 commit into
mainfrom
chore/bump-electrum-headers-fix
Jul 21, 2026
Merged

chore: rebuild native libs with the electrum block.headers fix#143
jvsena42 merged 1 commit into
mainfrom
chore/bump-electrum-headers-fix

Conversation

@jvsena42

@jvsena42 jvsena42 commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Closes #136.

Rebuilds libflorestad_ffi.so for both ABIs against floresta-mandacaru-ffi f9e21ce, which pins Floresta-mandacaru 111f9e33.

What the fix does

The Electrum blockchain.block.headers handler advertised a count taken from the requested range length, but built hex with a filter_map that silently dropped any height it failed to look up. Electrum clients assert len(hex) / 160 == count, so one dropped height made the client raise RequestCorrupted('inconsistent chunk hex and count'), disconnect and reconnect — the wallet flipped between "Connected" and "Not connected" and never reached tip, with New client connection / Client closed connection scrolling in the node log.

The handler now derives count from the headers it actually serialized and stops at the first height it can't serve, keeping the chunk contiguous from start_height.

References

Changes

Two .so files only. The Kotlin bindings (florestad.kt) are byte-identical — the fix touches no FFI surface. arm64-v8a keeps its 16 KB page alignment (LOAD Align 0x4000); x86_64 stays at 4 KB, and both still link Bionic libc/libm/libdl dynamically.

Testing

These exact binaries were installed on an x86_64 emulator (clean install, node synced from genesis) and driven against the live on-device Electrum server on port 50001:

  • Four shapes of request all satisfy len(hex) / 160 == count: a full 2016-header chunk from genesis, a chunk crossing the tip, a chunk starting at the tip, and a range starting past the tip.
  • A 90-second stress run issued 3342 blockchain.block.headers requests while the chain advanced from height 118k to 196k — the moving-tip condition the bug reproduces under — with zero count / hex mismatches.

The same checks were also run before the merge against a path-dep build of the identical Floresta commit (2874 requests, tip ~416k → ~488k, zero mismatches).

Unit coverage came with the fork PR: test_headers_chunk_is_consistent_with_count in floresta-electrum.

Rebuilds both ABIs against floresta-mandacaru-ffi f9e21ce, which pins
Floresta-mandacaru 111f9e33. That commit makes the Electrum
`blockchain.block.headers` response report a `count` equal to the number
of headers actually serialized into `hex`, so wallets no longer reject
the chunk as corrupted and reconnect in a loop.

Kotlin bindings are unchanged — the fix touches no FFI surface.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jvsena42
jvsena42 merged commit 9aeb799 into main Jul 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Electrum reconnect loop: floresta-electrum returns inconsistent chunk hex/count for block.headers

1 participant