z_anonsettxdelta + z_anonsetblockdelta #138

Closed
opened 2 years ago by duke · 5 comments
duke commented 2 years ago
Owner

This will be 2 new RPCs which calculate the delta (difference) of the anonset at a certain txid or block height. A delta > 0 means the anonset increased, a delta < 0 means the anonset decreased and a delta=0 means the anonset stayed the same.

The anonset delta of a block is the sum of all anonset deltas for each transaction in that block.

This will make it much easier to study how the anonset changes over ranges of block heights or how a certain tx changed the anonset. It will also allow gathering/studying anonset stats without having a full zindex. If you know from an external source (such as an explorer) that the anonset is X at height Y, then you can do Z = z_anonsetblockdelta(X+1) and then you will know that the anonset at height X+1 is X+Z

This will be 2 new RPCs which calculate the delta (difference) of the anonset at a certain txid or block height. A delta > 0 means the anonset increased, a delta < 0 means the anonset decreased and a delta=0 means the anonset stayed the same. The anonset delta of a block is the sum of all anonset deltas for each transaction in that block. This will make it much easier to study how the anonset changes over ranges of block heights or how a certain tx changed the anonset. It will also allow gathering/studying anonset stats without having a full `zindex`. If you know from an external source (such as an explorer) that the anonset is X at height Y, then you can do ` Z = z_anonsetblockdelta(X+1)` and then you will know that the anonset at height `X+1` is `X+Z`
Poster
Owner

@onryo it seems to work, it's on the danger branch, give it some testing. It does not require zindex to be enabled.

@onryo it seems to work, it's on the `danger` branch, give it some testing. It does not require `zindex` to be enabled.
onryo was assigned by duke 2 years ago
Poster
Owner

@onryo I could relatively easily add the funcationality to z_anonsetblockdelta to do a range of block heights, such as z_anonsetblockdelta 100 200, is that something you would want or use? In theory, you could do z_anonsetblockdelta 1 X where X is the latest block height and calculate the full anonset value without having zindex enabled.

@onryo I could relatively easily add the funcationality to `z_anonsetblockdelta` to do a range of block heights, such as `z_anonsetblockdelta 100 200`, is that something you would want or use? In theory, you could do `z_anonsetblockdelta 1 X` where X is the latest block height and calculate the full anonset value without having `zindex` enabled.
Poster
Owner

@onryo other ideas I have that can use this code:

With these 2 RPCs, now our explorers can render how each block and tx changed the anonset. Something like "this tx added/subtracted X from the anonset" and "this block added/subtracted Y from the anonset"

@onryo other ideas I have that can use this code: With these 2 RPCs, now our explorers can render how each block and tx changed the anonset. Something like "this tx added/subtracted X from the anonset" and "this block added/subtracted Y from the anonset"
Poster
Owner

I just pushed code to calculate anonset of block ranges, it seems to work:

$ time ./src/hush-cli z_anonsetblockdelta 1 970245
1039411

real	3m13.080s

3 minutes to calculate the anonset of all time, not too bad, but not something you want to call for every block. What it's most useful for is looking at slices of anonset history.

$ time ./src/hush-cli z_anonsetblockdelta 1 100000
602

real	0m12.669s

12.6 seconds to see that we only had an anonset of 602 in our first 100k blocks.

 $ time ./src/hush-cli z_anonsetblockdelta 800000 900000
47879

real	0m14.388s

14.3 seconds to see that we added ~48K to our anonset in block heights 800K to 900K. The reason this block range is slower is because it must look at every tx in every block, so the more tx's that are in a range, the slower it will be.

$ time ./src/hush-cli z_anonsetblockdelta 900000 970000
122776

real	0m16.379s
user	0m0.002s
sys	0m0.002s

16.3 seconds to see we added ~122K(!) to our anonset in the last ~70K blocks. Makes sense that it is slower because our chain usage has gone up and we have more tx's in the last 70K blocks than previous block ranges.

I just pushed code to calculate anonset of block ranges, it seems to work: ``` $ time ./src/hush-cli z_anonsetblockdelta 1 970245 1039411 real 3m13.080s ``` 3 minutes to calculate the anonset of all time, not too bad, but not something you want to call for every block. What it's most useful for is looking at slices of anonset history. ``` $ time ./src/hush-cli z_anonsetblockdelta 1 100000 602 real 0m12.669s ``` 12.6 seconds to see that we only had an anonset of 602 in our first 100k blocks. ``` $ time ./src/hush-cli z_anonsetblockdelta 800000 900000 47879 real 0m14.388s ``` 14.3 seconds to see that we added ~48K to our anonset in block heights 800K to 900K. The reason this block range is slower is because it must look at every tx in every block, so the more tx's that are in a range, the slower it will be. ``` $ time ./src/hush-cli z_anonsetblockdelta 900000 970000 122776 real 0m16.379s user 0m0.002s sys 0m0.002s ``` 16.3 seconds to see we added ~122K(!) to our anonset in the last ~70K blocks. Makes sense that it is slower because our chain usage has gone up and we have more tx's in the last 70K blocks than previous block ranges.
Poster
Owner

these are done and seem to be working fine

these are done and seem to be working fine
duke closed this issue 2 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.