Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Assertion `pindex->nCachedBranchId' failed" when trying to simulate a reorg #6685

Closed
cadaniluk opened this issue May 27, 2023 · 1 comment
Closed

Comments

@cadaniluk
Copy link

For testing purposes I wanted to simulate a reorg on zcashd. What I am doing is essentially starting two nodes (0 denotes the first node, 1 the second), making them generate an unequal number of blocks, and then connecting them to see the shorter one reorg.
The full error I am getting on node 0 is

zcashd: main.cpp:2982: DisconnectResult DisconnectBlock(const CBlock &, CValidationState &, const CBlockIndex *,
CCoinsViewCache &, const CChainParams &, const bool): Assertion `pindex->nCachedBranchId' failed.

I started them like this:

Node 0: zcashd -debug -regtest -datadir=node0 -conf=zcash.conf -port=40000 -rpcport=50000 &
Node 1: zcashd -debug -regtest -datadir=node1 -conf=zcash.conf -port=40001 -rpcport=50001 &

In terms of RPC commands, this is what I did:

(Node 0 runs on 127.0.0.1:40000, node 1 on 127.0.0.1:40001.)

0: addnode 127.0.0.1:40001 add
0: generate 200                                      # shared base
0: disconnectnode 127.0.0.1:40001 
0: setban 127.0.0.1 add                        # prevent reconnection
0: generate 1                                          # short branch only on node 0
1: generate 2                                          # long branch only on node 1
0: clearbanned                                       # allow reconnection, triggering reorg on node 1

I also tried without 0: generate 200 to start from the Genesis block, the result is the same.

I would have expected to see some messages concerning the reorg and its result showing in 0: getchaintips. Node 0 crashes, however, because of the failed assertion.

I guess this is a bug since a user should not be able to trigger an assertion failure with RPC commands, but if I am doing something non-standard, tell me. Furthermore, could you suggest some workaround if this bug is not straightforward to fix, please?

Node 0's and node 1's debug.log files are attached.

Zcash version: v5.5.1

Machine specs:

  • OS name + version: Fedora 37
  • CPU: Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
  • Linux kernel version (uname -a): Linux *** 6.2.15-200.fc37.x86_64 Dust off codebase: build, run, poke at JSON api, try to exercise mint, pour, and receive manually. #1 SMP PREEMPT_DYNAMIC Thu May 11 15:56:33 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • Compiler version (gcc --version): gcc (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1)
  • Linker version (ld -v): GNU ld version 2.38-27.fc37
  • Assembler version (as --version): GNU assembler version 2.38-27.fc37
@miodragpop
Copy link
Contributor

Network upgrades are not automatically activated in regtest mode. I think you should manually activate some (at least). For example, by adding -nuparams=76b809bb:1 to zcashd command line arguments for Sapling activation at height 1.

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

No branches or pull requests

2 participants