Skip to content

Conversation

chappjc
Copy link
Member

@chappjc chappjc commented Apr 15, 2022

Resolves #1587

The mainchain and valid returns from (*ExchangeWallet).blockHeader were
switched.  This flips them correctly.

This also changes the way a block is detected as side chain by checking
the Confirmations field of the getblockverbose result instead of
requesting the hash of the block at the same height and comparing
the hashes.  A side chain block will have -1 for Confirmations.

This also changes the way the next block is retrieved for stakeholder
approval checking.  Instead of requesting the hash of the block at the
next height, use the NextHash field returned by getblockverbose.
This saves an RPC, but it is also more robust since there is no need
to use strings.Contains on the error returned from getblockhash
to detect if there is no next block (we are at tip).  If we are at tip,
the NextHash field is empty.  With getblockhash, the wallet says
"-1: Block number out of range: N" while the node says
"-4: wallet.BlockInfo: item does not exist: no block at height N in main
chain".  Although client only ever checks with wallet, these strings are
fairly arbitrary  human readable messages that are likely to change
without warning.

The mainchain and valid returns from (*ExchangeWallet).blockHeader were
switched.  This flips them correctly.

This also changes the way a block is detected as side chain by checking
the Confirmations field of the getblockverbose result instead of
requesting the hash of the block at the same height and comparing
the hashes.  A side chain block will have -1 for Confirmations.

This also changes the way the next block is retrieved for stakeholder
approval checking.  Instead of requesting the hash of the block at the
next height, use the NextHash field returned by getblockverbose.
This saves an RPC, but it is also more robust since there is no need
to use strings.Contains on the error returned from getblockhash
to detect if there is no next block (we are at tip).  If we are at tip,
the NextHash field is empty.  With getblockhash, the wallet says
"-1: Block number out of range: N" while the node says
"-4: wallet.BlockInfo: item does not exist: no block at height N in main
chain".  Although client only ever checks with wallet, these strings are
fairly arbitrary  human readable messages that are likely to change
without warning.
@chappjc
Copy link
Member Author

chappjc commented Apr 18, 2022

Merging so we can test other stuff properly, e.g. #1578

@chappjc chappjc merged commit 1cfe62b into decred:master Apr 18, 2022
@chappjc chappjc deleted the fix-dcr branch April 18, 2022 20:54
@chappjc chappjc added this to the 0.5 milestone May 18, 2022
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.

dcr simnet harness tests fails: mainchain / validation issues
3 participants