difficulty
difficulty here is called work: the amount of tax, in bnb, that finds one block on average. it retargets every 16 blocks so that a block takes about 32 deliveries.
work now
where the current work sits between a thousandth of a bnb and a thousand bnb.
retargets
every change of work found in the last 160 blocks.
a retarget happens when a block whose height divides by 16 is found. the vault counts the deliveries the last 16 blocks took. 512 deliveries is the goal, 32 for each block. the new work is the old work times 512 divided by that count, held between a quarter and four times the old work.
| after block | work before | work after | factor | deliveries in window | clamp |
|---|
the rule worked through
seven cases, computed from the formula.
work is not a guess about the market. it is feedback. the vault only asks one question every 16 blocks: how many deliveries did that take. the answer moves work up or down and nothing else does.
when trades get larger, each delivery carries more bnb and blocks arrive in fewer deliveries, so work rises until a block costs about 32 deliveries again. when trades get smaller, work falls. the chain keeps the same rhythm in deliveries whatever the size of the market.
one delivery can never be worth more than one block. if a single delivery is larger than the whole work, its chance is simply one.
new work = old work * 512 / deliveries in window
new work is held between old work / 4 and old work * 4
| deliveries in 16 blocks | raw factor | factor applied | what happened |
|---|---|---|---|
| 64 | 8.00 | 4.00 | blocks came eight times too fast, clamped |
| 128 | 4.00 | 4.00 | blocks came four times too fast |
| 256 | 2.00 | 2.00 | blocks came twice too fast |
| 512 | 1.00 | 1.00 | on target |
| 1,024 | 0.50 | 0.50 | blocks came twice too slow |
| 2,048 | 0.25 | 0.25 | blocks came four times too slow |
| 4,096 | 0.13 | 0.25 | blocks came eight times too slow, clamped |