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

Initial representative weights for bootstrapping. #566

Merged
merged 1 commit into from
Feb 8, 2018

Conversation

lukealonso
Copy link
Contributor

@lukealonso lukealonso commented Jan 30, 2018

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.

@PlasmaPower
Copy link
Contributor

In the Python script, I'd recommend using pack and unpack instead of hexlify and unhexlify. I was very confused by the data sizes being in nibbles instead of bytes.

@lukealonso
Copy link
Contributor Author

lukealonso commented Jan 30, 2018

@PlasmaPower I'm using that to zero-pad, so the resulting output is always 16/32 bytes. Python longs are variable size.

@androm3da
Copy link
Contributor

@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?

@lukealonso
Copy link
Contributor Author

@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.

p = r.json()
block_height = max(0, int(p["count"]) - args.cutoff)

print("cutoff block height is %d" % block_height)
Copy link
Contributor

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?

Copy link
Contributor Author

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.


reps.sort(key=lambda x: x["weight"], reverse=True)

of = open(args.output, "wb")
Copy link
Contributor

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:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@PlasmaPower
Copy link
Contributor

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.

@lukealonso
Copy link
Contributor Author

lukealonso commented Feb 4, 2018

@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

[2018-02-03 19:55:02.250259]: Using bootstrap rep weight: xrb_3pczxuorp48td8645bs3m6c3xotxd3idskrenmi65rbrga5zmkemzhwkaznh -> 21,835,226 XRB
[2018-02-03 19:55:02.250290]: Using bootstrap rep weight: xrb_1awsn43we17c1oshdru4azeqjz9wii41dy8npubm4rg11so7dx3jtqgoeahy -> 21,041,038 XRB
[2018-02-03 19:55:02.250307]: Using bootstrap rep weight: xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4 -> 12,156,823 XRB
[2018-02-03 19:55:02.250323]: Using bootstrap rep weight: xrb_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou -> 10,250,117 XRB
[2018-02-03 19:55:02.250338]: Using bootstrap rep weight: xrb_3hd4ezdgsp15iemx7h81in7xz5tpxi43b6b41zn3qmwiuypankocw3awes5k -> 10,149,562 XRB
[2018-02-03 19:55:02.250352]: Using bootstrap rep weight: xrb_1niabkx3gbxit5j5yyqcpas71dkffggbr6zpd3heui8rpoocm5xqbdwq44oh -> 7,839,305 XRB
[2018-02-03 19:55:02.250366]: Using bootstrap rep weight: xrb_39ymww61tksoddjh1e43mprw5r8uu1318it9z3agm7e6f96kg4ndqg9tuds4 -> 6,904,598 XRB
[2018-02-03 19:55:02.250380]: Using bootstrap rep weight: xrb_1111111111111111111111111111111111111111111111111117353trpda -> 6,469,409 XRB
[2018-02-03 19:55:02.250393]: Using bootstrap rep weight: xrb_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p -> 5,997,312 XRB
[2018-02-03 19:55:02.250407]: Using bootstrap rep weight: xrb_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs -> 5,604,444 XRB
[2018-02-03 19:55:02.250421]: Using bootstrap rep weight: xrb_3dmtrrws3pocycmbqwawk6xs7446qxa36fcncush4s1pejk16ksbmakis78m -> 4,757,930 XRB
[2018-02-03 19:55:02.250435]: Using bootstrap rep weight: xrb_1hza3f7wiiqa7ig3jczyxj5yo86yegcmqk3criaz838j91sxcckpfhbhhra1 -> 4,146,411 XRB
[2018-02-03 19:55:02.250449]: Using bootstrap rep weight: xrb_16k5pimotz9zehjk795wa4qcx54mtusk8hc5mdsjgy57gnhbj3hj6zaib4ic -> 1,067,243 XRB
[2018-02-03 19:55:02.250463]: Using bootstrap rep weight: xrb_39776qz9wnt3dwyuiy4erq8f1gqujykzggeu9n46gmhangxrh15a3mzfjskk -> 1,012,709 XRB
[2018-02-03 19:55:02.250477]: Using bootstrap rep weight: xrb_16u1uufyoig8777y6r8iqjtrw8sg8maqrm36zzcm95jmbd9i9aj5i8abr8u5 -> 969,771 XRB
[2018-02-03 19:55:02.250490]: Using bootstrap rep weight: xrb_38zpmsje8de6tgkan8yf3t86e31444qkznxyah6zqtqckex1nec97wo94xc9 -> 967,304 XRB
[2018-02-03 19:55:02.250504]: Using bootstrap rep weight: xrb_35nu7hynfzecjtauskk6yb8pgfeifscqz4hmgtani15s8eiocgsz15axursj -> 895,360 XRB
[2018-02-03 19:55:02.250517]: Using bootstrap rep weight: xrb_3e4kqytg85qrhz197tp93tz8w8g5xmencs8nq6eyqj3yqsdfxmg6eobw96wn -> 860,000 XRB
[2018-02-03 19:55:02.250531]: Using bootstrap rep weight: xrb_1gaysex8yymd5ef88hjqxt8xbjt63qz43cujrrzy4df9xb6zhf315csi35ww -> 760,305 XRB
[2018-02-03 19:55:02.250544]: Using bootstrap rep weight: xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3 -> 670,008 XRB
[2018-02-03 19:55:02.250558]: Using bootstrap rep weight: xrb_3uignwbigfz49rqfwuzi8x91u6u4pm6j8pii6sb8rorxexxzd455wobg7xd1 -> 434,323 XRB
[2018-02-03 19:55:02.250571]: Using bootstrap rep weight: xrb_34hj673xxckh1mmthfmrpweds9wbx6177uie3zi61qinixtnrns6wnn48ayp -> 407,909 XRB
[2018-02-03 19:55:02.250585]: Using bootstrap rep weight: xrb_1tig1rio7iskejqgy6ap75rima35f9mexjazdqqquthmyu48118jiewny7zo -> 374,203 XRB
[2018-02-03 19:55:02.250598]: Using bootstrap rep weight: xrb_1bk1w8nqjk1qwj9srfcoxw11d6bsiimmkecy6e3m7wco38gstn5pqimdur7o -> 309,925 XRB
[2018-02-03 19:55:02.250612]: Using bootstrap rep weight: xrb_1zo54ia1363ikd4nb9ikamux3fnsnr7jurzs45xhda78o9piowa44o5zzaws -> 208,276 XRB
[2018-02-03 19:55:02.250626]: Using bootstrap rep weight: xrb_1dykbp1gr395ybjaef94yqwosge3brc6ou6exkhx71hsoqju93s64e3tzzwf -> 183,471 XRB
[2018-02-03 19:55:02.250640]: Using bootstrap rep weight: xrb_1cwswatjifmjnmtu5toepkwca64m7qtuukizyjxsghujtpdr9466wjmn89d8 -> 181,747 XRB
[2018-02-03 19:55:02.250653]: Using bootstrap rep weight: xrb_38qjwp3cxd9fq5pcrg4xogk1c5h49rab7uwmksmcbor5ymk76gi33reg5kw8 -> 162,192 XRB
[2018-02-03 19:55:02.250666]: Using bootstrap rep weight: xrb_3ju9wdb8zpzdn3bnhz6ypm5sipccok9urqif9kdyweimj9c9zyi54ceos1qu -> 113,542 XRB
[2018-02-03 19:55:02.250693]: Using bootstrap rep weight: xrb_13kaonowbrkzrpkh6capzf6e1wc9m6df1ocjdrzwt9bedgkxrfr9cuoqangg -> 105,981 XRB
[2018-02-03 19:55:02.250708]: Using bootstrap rep weight: xrb_1on6578kfe6t9kxtuecyy7rpi1e19nctgy3ahfbwimuh9q4y43m67qtayd16 -> 102,853 XRB
[2018-02-03 19:55:02.250721]: Using bootstrap rep weight: xrb_1djabcejb3pxge363rya3s8gsmiu64nieee8mq1zzgr411qaqrugr9kthkcr -> 101,186 XRB
[2018-02-03 19:55:02.250735]: Using bootstrap rep weight: xrb_1wrzqghox3sn7gnipj9rjqapbqykk1r94zfpidtrayb4rws9y59axnhhbo9o -> 100,529 XRB
[2018-02-03 19:55:02.250748]: Using bootstrap rep weight: xrb_3nqagouyt51eko3eo51t3ex1rptxsymh9cz4wr8u86er7ruf6peg8hzccy5b -> 90,675 XRB
[2018-02-03 19:55:02.250762]: Using bootstrap rep weight: xrb_1agtsfkragmzo7afcuya8sig9fcw83gfmbssc3ihw4idcdjc6p6gdtr1y59t -> 90,201 XRB
[2018-02-03 19:55:02.250784]: Using bootstrap rep weight: xrb_1bxtaqobuyfjs55tzmq38f58nh39qctfyowahpe5tqyhzza3f3eeatp7hsi9 -> 88,550 XRB
[2018-02-03 19:55:02.250797]: Using bootstrap rep weight: xrb_1rx5r9njgu3jf5isydgpfkzgox5ppisshgq5dtg7res569ujjjqoi5ebqx7x -> 85,431 XRB
[2018-02-03 19:55:02.250810]: Using bootstrap rep weight: xrb_153hw4s799ks6d5t5qjw4espn5naxmzs4qouhtopr856h1js6zmzpzaoqf73 -> 82,813 XRB
[2018-02-03 19:55:02.250823]: Using bootstrap rep weight: xrb_1kd4h9nqaxengni43xy9775gcag8ptw8ddjifnm77qes1efuoqikoqy5sjq3 -> 80,560 XRB
[2018-02-03 19:55:02.250837]: Using bootstrap rep weight: xrb_1twmssnq9otxag476ahy5m8mrt5m89e69c9amu4yzxba7n3zh4jz8c7sxkzj -> 72,595 XRB
[2018-02-03 19:55:02.250850]: Using bootstrap rep weight: xrb_3r5ooenxm6r46tcbfpi4rdw69euu9u1tqizjpkoo3a4bckh8asyr99kjugki -> 68,849 XRB
[2018-02-03 19:55:02.250863]: Using bootstrap rep weight: xrb_3bsss5udi1pa6miwqsk4hm7yngbkjwg7im4raged5u8nfmf45a38zhjyrt6f -> 66,579 XRB

@PlasmaPower
Copy link
Contributor

That should be good. In the future, I might make a script to compare it to your node's stake.

@androm3da androm3da merged commit 89339ef into nanocurrency:master Feb 8, 2018
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

Successfully merging this pull request may close these issues.

None yet

3 participants