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

Investigate bnChainTrust usage and whether or not it needs porting. #20

Open
r3rcloak opened this issue Jan 14, 2019 · 1 comment
Open
Assignees
Labels
investigation Investigate a problem or new feature Sync/Consensus Issues related to block syncing / network consensus rules

Comments

@r3rcloak
Copy link
Collaborator

Cloak and PeerCoin etc use a variable called bnChainTrust (member of block index) to ascertain the current chain trust at the particular block height associated with the block index. Seeing as the code used to calculate bnChainTrust has separate paths for PoW and PoS, it is likely that this will need to be ported in some manner, even if that just involves tweaking the nChainTrust property for a block index in the new codebase.

More information to follow after some investigation...

@r3rcloak r3rcloak added the investigation Investigate a problem or new feature label Jan 14, 2019
@r3rcloak r3rcloak self-assigned this Jan 14, 2019
@anorakthagreat anorakthagreat self-assigned this Feb 3, 2019
@anorakthagreat
Copy link
Collaborator

Client calls GetBlockTrust() in AddToBlockIndex() to calculate bnChainTrust.
bnChainTrust is calculated as 2**256 / (bnTarget+1)
bnTarget is a function of nBits:
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);

https://github.com/CloakProject/CloakCoin/blob/b813d5f21387143b572e7f605f302ec56377de66/src/main.cpp#L2240

GetBlockTrust uses a trick in calculation to still use uint256 instead of uint512. I did some CPU profiling with Valgrind/KCachegrind on this before to see if I can reduce the CPU/mem load - there was an extremely large amount of calls to GetBlockTrust. Think we should stick with the uint256 implementation for that reason.

@r3rcloak r3rcloak added the Sync/Consensus Issues related to block syncing / network consensus rules label May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation Investigate a problem or new feature Sync/Consensus Issues related to block syncing / network consensus rules
Projects
None yet
Development

No branches or pull requests

2 participants