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
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');
-
In the definition of snapshot_block I think it should be (snapshot - 1) instead of (snapshot + 1) Jun 20, 2019 at 15:01
-
-
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!– GroxanJun 24, 2019 at 21:57