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

Early Adjustment Windows #167

Merged
merged 13 commits into from May 2, 2019

Conversation

Projects
None yet
3 participants
@fosskers
Copy link
Contributor

commented Apr 23, 2019

The value prereduction found in Chainweb.Difficulty is used to artificially slow mining during initial conditions of the network. Its specific value is mostly a guess based on behaviour observed during testing.

The downsides to introducing prereduction are multifold:

  • The Genesis blocks need to be mined, since only certain Nonce values will allow validation to succeed.
  • The Genesis blocks need to be hard-coded, since re-mining them on-the-fly isn't realistic.
  • Hard-coding the blocks is boilerplate, and will only get worse with time as more ChainwebVersions are invented.
  • A side tool needed to be written to perform said hard-coding.
  • Unit tests slow down, since the genesis blocks need to be re-mined in order to be validated.

This PR adds early adjustment windows for BlockHeights lower than the first "official" adjustment.

@fosskers fosskers force-pushed the colin/early-da branch from f4962bc to bfa4a09 Apr 29, 2019

@fosskers

This comment has been minimized.

Copy link
Contributor Author

commented Apr 29, 2019

Rebased onto master.

@fosskers fosskers marked this pull request as ready for review Apr 29, 2019

@fosskers fosskers force-pushed the colin/early-da branch from d31eb8b to 1fe217e Apr 29, 2019

@fosskers

This comment has been minimized.

Copy link
Contributor Author

commented Apr 29, 2019

Rebased again.

@fosskers fosskers force-pushed the colin/early-da branch from 1fe217e to 669c89c Apr 30, 2019

@fosskers

This comment has been minimized.

Copy link
Contributor Author

commented Apr 30, 2019

Rebased again.

@fosskers fosskers force-pushed the colin/early-da branch from 89dfddd to d6b6776 May 1, 2019

@fosskers

This comment has been minimized.

Copy link
Contributor Author

commented May 1, 2019

Yet another rebase.

fosskers added some commits Apr 23, 2019

[difficulty] Shorter windows for early network conditions
The shortened windows are based on the given `WindowWidth`, which is
a function of `ChainwebVersion`.

@fosskers fosskers force-pushed the colin/early-da branch from d6b6776 to 0708e10 May 1, 2019

@emilypi

emilypi approved these changes May 2, 2019

Copy link
Contributor

left a comment

Two comments! One for documenting the adjustment strategy, one potential code thing which is only a minor wibble.

Show resolved Hide resolved src/Chainweb/TreeDB/Difficulty.hs
Show resolved Hide resolved src/Chainweb/TreeDB/Difficulty.hs
[ea] Automatically generate all possible Payloads
The idea being that if you had made code changes and were looking
to regenerate the payload for a *particular* ChainwebVersion,
you'd also want to do so for *all* such ChainwebVersions that have
an associated Payload.

This should help avoid future foot-gun.
adjust :: ChainwebVersion -> TimeSpan Int64 -> HashTarget -> HashTarget
adjust ver (TimeSpan delta) oldTarget
adjust :: ChainwebVersion -> WindowWidth -> TimeSpan Int64 -> HashTarget -> HashTarget
adjust ver (WindowWidth ww) (TimeSpan delta) oldTarget

This comment has been minimized.

Copy link
@fosskers

fosskers May 2, 2019

Author Contributor

Notice that ww was removed from the where clause below, and is now passed-in explicitly. This lets the caller (the hashTarget function in Chainweb.TreeDB.Difficulty) to reduce the window size freely. This is the entire point of the "early adjustment windows".

Show resolved Hide resolved src/Chainweb/TreeDB/Difficulty.hs
Show resolved Hide resolved src/Chainweb/TreeDB/Difficulty.hs

@fosskers fosskers merged commit b95cd28 into master May 2, 2019

1 check passed

ci/gitlab/gitlab.com Pipeline skipped on GitLab
Details

@fosskers fosskers deleted the colin/early-da branch May 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.