-
Notifications
You must be signed in to change notification settings - Fork 535
Conversation
After tuning the unit tests, I discovered that TD is calculated in other places as well ( I've left Regarding the TD field in the units test (blockchain_test.go), this is the value we would like to see hardcoded to 1, in which case, all that is needed is to hardcode |
After revising the aforementioned calculation of TD, I decided to go with the less invasive approach of hardcoding each block's difficulty to 1, keeping the existing logic (summing of difficulties) intact, such that the following are true:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me 💯
Left a minor question that needs clarification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making the requested changes 🙏
Looks great now 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. I like renaming variable to proper one. I've left small comments. I'd appreciated if you could check and fix if need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing. LGTM👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for a second time because Github reset my approval for some reason 🙂
@dbrajovic feel free to close this PR and delete the branch if you plan on opening a new one 👍 |
Closing this PR in favour of #208 cc @dbrajovic |
* Add etherscan gas price * Update Changelog
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.18.0 to 0.19.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](golang/tools@v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description
Defining total difficulty in our IBFT implementation.
Addresses #179
Update:
Hardcoding
GenesisDifficulty
to 1 breaks backwards compatibility for existing chains due to new nodes having to generate the genesis block with difficulty 1.Changes include
Checklist
Additional comments
This PR is about coming to terms on what Total Difficulty means in IBFT.
In other consensuses, TD is what helps identify the correct chain (fork) based on the sum of all blocks'
difficulty
field (which varies from block to block).In IBFT, TD has nothing to do with the
difficulty
field, but serves the same purpose, in a sense that it decides what is the latest block (number) - hence this value should represent the block'snumber
field.In short (our IBFT impl):
Related issues:
https://github.com/0xPolygon/polygon-sdk/issues/179
This fix should provide the
Syncer
with the correct value (fetched withCurrentTD()
) in order to resolve its best peer.