Skip to content

signet/miner: reduce default interblock interval limit to 30min#26208

Merged
fanquake merged 1 commit intobitcoin:masterfrom
ajtowns:202209-signetminercap
Oct 3, 2022
Merged

signet/miner: reduce default interblock interval limit to 30min#26208
fanquake merged 1 commit intobitcoin:masterfrom
ajtowns:202209-signetminercap

Conversation

@ajtowns
Copy link
Copy Markdown
Contributor

@ajtowns ajtowns commented Sep 29, 2022

Reduces the cap on the time between blocks from 60 minutes to 30 minutes, and makes it configurable.

Also allow the operator to change it, if desired, without having
to edit the code.
@ajtowns
Copy link
Copy Markdown
Contributor Author

ajtowns commented Sep 29, 2022

signet/miner --poisson attempts to simulate the distribution of times you'd see on mainnet. My original reasoning for the 60 minute cap is that you only expect 0.25% of blocks to take that long, so what does it matter. With a lower cap it seems worthwhile checking what that effects. I think you can work out the expected average with a cap as follows:

def expected_times(tgt, N=100000):
    return [tgt*-math.log(1-i*1.0/N) for i in range(N)]

def capped_average(seq, cap):
    sum, cnt = 0,0
    for v in seq:
        sum += min(v, cap)
        cnt += 1
    return sum/cnt

def bisect(f, want, l=0, h=100000, prec=0.0005):
    while l + prec < h:
        m = (l + h)/2
        if f(m) < want:
            l = m
        else:
            h = m
    return h

for cap in [11, 15, 16, 20, 25, 30, 45, 60]:
    tgt = bisect(lambda t: capped_average(expected_times(t), cap*60), 600)
    print("cap=%dmin, tgt=%.2fmin, average=%ds" % (cap, tgt/60, capped_average(expected_times(tgt), cap*60)))

# results:
# cap=11min, tgt=56.78min, average=600.0s
# cap=15min, tgt=17.16min, average=600.0s
# cap=16min, tgt=15.58min, average=600.0s
# cap=20min, tgt=12.55min, average=600.0s
# cap=25min, tgt=11.20min, average=600.0s
# cap=30min, tgt=10.63min, average=600.0s
# cap=45min, tgt=10.12min, average=600.0s
# cap=60min, tgt=10.03min, average=600.0s

That is, if you have a cap of 30 minutes, you need to be trying to have blocks every 10.63 minutes instead of every ten minutes because after applying the cap, you actual average will be reduced by that much. Effectively, this means the actual difficulty will generally be somewhat above the --nbits target, causing the signet miner to attempt to reduce the difficulty by mining more slowly, but that reduction will be offset in practice by the cap.

It seems to me like 30 minutes is a nice round figure that doesn't cause anything to get too weird; and I've used 16minutes as a lower limit, since below that, you're targetting an average block interval that's higher than your maximum acceptable block interval, so it's probably better to just not use --poisson at all at that point, I think.

@fanquake fanquake requested a review from kallewoof September 29, 2022 21:28
Comment thread contrib/signet/miner
Copy link
Copy Markdown
Contributor

@kallewoof kallewoof left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@fanquake fanquake merged commit 6c5ef5d into bitcoin:master Oct 3, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 4, 2022
… limit to 30min

51a08f4 signet/miner: reduce default interblock interval limit to 30min (Anthony Towns)

Pull request description:

  Reduces the cap on the time between blocks from 60 minutes to 30 minutes, and makes it configurable.

Top commit has no ACKs.

Tree-SHA512: 7b880c50e47d055a2737c057fab190017748849d264c6c39dde465959a544d502221d12c6307d4de693f51badb4779b9c147e48775ede6ec6613e808067ab279
@bitcoin bitcoin locked and limited conversation to collaborators Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants