6

I would like to know, for every baker at cycle x, how many rolls they owned that contributed to their baking rights in that cycle. To do that, I believe I have to know how many rolls they owned during the particular snapshot that was selected in cycle x - 7. Is there any way to get this number from a full archival node?

1 Answer 1

4

You can get information about snapshot for a given cycle from the raw context:

var cycle = 100;
var level = cycle * 4096 + 1;

var snapshot = get('/chains/main/blocks/{level}/context/raw/json/cycle/{cycle}/roll_snapshot');

var snapshot_block = ((cycle - 7) * 4096 + 1) + (snapshot + 1) * 256 - 1;

var balance = get('/chains/main/blocks/{snapshot_block}/context/contracts/KT1.../balance');
7
  • In the definition of snapshot_block I think it should be (snapshot - 1) instead of (snapshot + 1) Jun 20, 2019 at 15:01
  • I'm afraid you're wrong ;) Did you try to check it?
    – Groxan
    Jun 20, 2019 at 19:22
  • yes I was wrong the snapshot index ranges from 0 to 15 but there is a -1 after * 256. Jun 21, 2019 at 15:19
  • (this is funny there is a 5 min limit to post a comment), anyway for example for the first snapshot cycle with blocks range {1 - 4096}, the first snapshot is taken at block 256, then the second at 512 and so on. That means that the snapshot_block equation is ((7 - 7) *4096 +1) + (snap + 1) *256 -1. With snap={0,1} we have snapshot_block={256,512} (I checked on tzscan.io) Jun 21, 2019 at 15:27
  • Hmm, I have looked at the sources gitlab.com/tezos/tezos/blob/master/src/proto_alpha/lib_protocol/… and found that the whole time was wrong... Thanks a lot!
    – Groxan
    Jun 24, 2019 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.