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

Inaccuracy in initialization of highScore #41

Open
ethers opened this issue Sep 9, 2016 · 1 comment
Open

Inaccuracy in initialization of highScore #41

ethers opened this issue Sep 9, 2016 · 1 comment

Comments

@ethers
Copy link
Member

ethers commented Sep 9, 2016

self.highScore = 1 should more accurately be self.highScore = chainWork
https://github.com/ethereum/btcrelay/blob/develop/btcrelay.se#L67

But it doesn't affect things because scorePrevBlock (not highScore) is used to compute the next scoreBlock:

scoreBlock = scorePrevBlock + difficulty

and scorePrevBlock
scorePrevBlock = m_getScore(hashPrevBlock)

Note: there are also tests that verified that scores are expected. (Though there must be a missing/wront test that highScore is correct value after setInitialParent)

@staccDOTsol
Copy link

Thank you for bringing this to my attention. It seems that there might be an inaccuracy in the initialization of highScore in the btcrelay contract. While the current implementation sets self.highScore = 1, you suggest that it should be self.highScore = chainWork for more accuracy.

However, it is important to note that this inaccuracy does not affect the functionality of the contract because scorePrevBlock, not highScore, is used to compute the next scoreBlock. The calculation is done as follows: scoreBlock = scorePrevBlock + difficulty.

Additionally, scorePrevBlock is obtained by calling m_getScore(hashPrevBlock). This means that the value of scorePrevBlock is used to determine the next score, not highScore.

It is worth mentioning that there are tests in place to verify the expected scores. However, it appears that there might be a missing or incorrect test to ensure that highScore has the correct value after setInitialParent.

I appreciate your attention to detail, and I will make a note of this discrepancy.

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

3 participants
@ethers @staccDOTsol and others