-
Notifications
You must be signed in to change notification settings - Fork 219
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
Request PoW target difficulty for miner from the base node #1085
Request PoW target difficulty for miner from the base node #1085
Conversation
42ece20
to
fd34167
Compare
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 good.
I checked the target window, it should be 90.
There is also some dbg! code left to be taken out
fd34167
to
323bd1e
Compare
…e chain state to calculate the target difficulty of the different PoW algorithms. - Added the GetTargetDifficulty comms request and TargetDifficulty comms response to the BaseNodeService allowing miners to request the target difficulty from a Base node. - Added proto conversions for the GetTargetDifficulty request and TargetDifficulty response. - Added the difficulty adjustment manager to the tari base node and existing tests. - Fixed 0 difficulty issue in Lwma_diff and change it to make use of the correct target time. Changed it to make the target time configurable. - Added a test for testing the the get target difficulty request and response system and tests for the DiffAdjManager system.
323bd1e
to
d1c5041
Compare
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.
I had some comments, but it's ok to merge as is.
DifficultyAdjustmentError(DifficultyAdjustmentError), | ||
ChainStorageError(ChainStorageError), | ||
EmptyBlockchain, | ||
PoisonedAccess, |
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.
I think I've mentioned this before, but I'd rather not lift RWLock errors to the caller -- there's no real action they can take, right; it's usually a sign of a bug? I'd just bundle this in with the general error case with a suitable message.
|
||
/// DiffAdjManager makes use of DiffAdjStorage to provide thread save access to its LinearWeightedMovingAverages for | ||
/// each PoW algorithm. | ||
pub struct DiffAdjStorage<T> |
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.
This is a lot of code for a "keep a running list of the last N block data"-- it works, so we'll leave it as is, but did you consider any other strategies?:
- Use VecDequeues and just update from the DB every time? i.e. assume we're always in
SyncToTip
but you pop off the front and push to the back until you have enough data - Or make it someone else's job to keep the Queues up to date (like a subscriber to a newBlock message)
Merge pull request #1085 - Introduced the difficulty adjustment manager that keeps track of the chain state to calculate the target difficulty of the different PoW algorithms. - Added the GetTargetDifficulty comms request and TargetDifficulty comms response to the BaseNodeService allowing miners to request the target difficulty from a Base node. - Added proto conversions for the GetTargetDifficulty request and TargetDifficulty response. - Added the difficulty adjustment manager to the tari base node and existing tests. - Fixed 0 difficulty issue in Lwma_diff and change it to make use of the correct target time. Changed it to make the target time configurable. - Added a test for testing the the get target difficulty request and response system and tests for the DiffAdjManager system. (#1085)
Description
Motivation and Context
Enables miners to query a Base node to determine the target difficulty for a specified PoW algorithm.
How Has This Been Tested?
Added a test for testing the the get target difficulty request and response system and tests for the DiffAdjManager system.
Types of changes
Checklist:
development
branchcargo-fmt --all
before pushing