-
Notifications
You must be signed in to change notification settings - Fork 784
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
Initial representative weights for bootstrapping. #566
Conversation
In the Python script, I'd recommend using |
@PlasmaPower I'm using that to zero-pad, so the resulting output is always 16/32 bytes. Python longs are variable size. |
@lukealonso can you confirm that this is mostly/totally contingent on #554? i.e. it doesn't make much sense to take this PR without that one? |
@androm3da I would say it's the other way around, it doesn't make much sense to take the other one without this one, but this one might make sense without the other one. |
ci/record_rep_weights.py
Outdated
p = r.json() | ||
block_height = max(0, int(p["count"]) - args.cutoff) | ||
|
||
print("cutoff block height is %d" % block_height) |
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.
If you're going to use py3k style print, then I would recommend a from __future__ import print_function
at the top. And if you do end up adding that, could you put a shebang with /usr/bin/env python
too?
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 just due to pure python ignorance, changed.
ci/record_rep_weights.py
Outdated
|
||
reps.sort(key=lambda x: x["weight"], reverse=True) | ||
|
||
of = open(args.output, "wb") |
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.
Please use with
statements for robust file open/closure.
e.g.
with open(args.output, 'wb') as of:
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.
Done
abb6e28
to
b1033b7
Compare
b1033b7
to
721a948
Compare
Could we get a separate program (probably a Python script or part of the creation script) to read the rep weights file? I think that's important for transparency. |
@PlasmaPower they're dumped to the log every time the node starts, for transparency, but I'm also happy to add a script to print them without starting the node
|
That should be good. In the future, I might make a script to compare it to your node's stake. |
To allow forks to be resolved during early bootstrap, this patch adds a small snapshot of the current rep weights, plus a block height at which to phase it out. This allows a bootstrapping client to use the live network's votes to resolve forks, at the risk of drift from those weight values. However, since the hardcoded weights stop being used after a certain block height, the drift can't be any worse than the (very severe) drift already present when bootstrapping.
Thanks to @PlasmaPower for the bit of cmake magic to embed the file in the executable.