β οΈ gmart7t2 opened an issue: "RPC: getblock(header) returns the same target for every block"
(https://github.com/bitcoin/bitcoin/issues/33440)
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Current behaviour
Run `getblock` or `getblockheader` for block 1 and you get the same "target" reported as for block 900000
### Expected behaviour
I would expect the target to be different for different blocks
### Steps to reproduce
Run `getblock` or `getblockheader` for block 1 and you get the same "target" reported as for block 900000
### Relevant log output
_No response_
### How did you obtain Bit
...
(https://github.com/bitcoin/bitcoin/issues/33440)
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Current behaviour
Run `getblock` or `getblockheader` for block 1 and you get the same "target" reported as for block 900000
### Expected behaviour
I would expect the target to be different for different blocks
### Steps to reproduce
Run `getblock` or `getblockheader` for block 1 and you get the same "target" reported as for block 900000
### Relevant log output
_No response_
### How did you obtain Bit
...
π¬ pinheadmz commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314297074)
Can you paste the exact commands and responses you're getting?
Here's how I do it:
```
$ bitcoin-cli getblockheader `bitcoin-cli getblockhash 1`
{
"hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"confirmations": 915498,
"height": 1,
"version": 1,
"versionHex": "00000001",
"merkleroot": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"time": 1231469665,
"mediantime": 1231469665,
"nonce": 2573394689,
"bits": "1d00ffff",
"targe
...
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314297074)
Can you paste the exact commands and responses you're getting?
Here's how I do it:
```
$ bitcoin-cli getblockheader `bitcoin-cli getblockhash 1`
{
"hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"confirmations": 915498,
"height": 1,
"version": 1,
"versionHex": "00000001",
"merkleroot": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"time": 1231469665,
"mediantime": 1231469665,
"nonce": 2573394689,
"bits": "1d00ffff",
"targe
...
π¬ pinheadmz commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314304664)
Hm yeah...
```
pi@zippi:~ $ bitcoin-cli getblockheader `bitcoin-cli getblockhash 1` | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
pi@zippi:~ $ bitcoin-cli getblockheader `bitcoin-cli getblockhash 100` | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
pi@zippi:~ $ bitcoin-cli getblockheader `bitcoin-cli getblockhash 200000` | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
pi@zippi:~ $ bitcoin-cli getbl
...
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314304664)
Hm yeah...
```
pi@zippi:~ $ bitcoin-cli getblockheader `bitcoin-cli getblockhash 1` | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
pi@zippi:~ $ bitcoin-cli getblockheader `bitcoin-cli getblockhash 100` | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
pi@zippi:~ $ bitcoin-cli getblockheader `bitcoin-cli getblockhash 200000` | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
pi@zippi:~ $ bitcoin-cli getbl
...
π¬ pinheadmz commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314307143)
I believe it's always showing the current difficulty target for the next block
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314307143)
I believe it's always showing the current difficulty target for the next block
π¬ pinheadmz commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314308293)
https://github.com/bitcoin/bitcoin/blob/11d80d4187afaa101de989330fa1982cd019cfa8/src/rpc/blockchain.cpp#L149-L177
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314308293)
https://github.com/bitcoin/bitcoin/blob/11d80d4187afaa101de989330fa1982cd019cfa8/src/rpc/blockchain.cpp#L149-L177
π¬ gmart7t2 commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314350959)
Yes. It's the same as reported by `getblockchaininfo`:
```
$ bitcoin-cli getblockchaininfo | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
```
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314350959)
Yes. It's the same as reported by `getblockchaininfo`:
```
$ bitcoin-cli getblockchaininfo | jq .target
"00000000000000000001fa380000000000000000000000000000000000000000"
```
π¬ pinheadmz commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314372951)
This is expected, see https://github.com/bitcoin/bitcoin/pull/31583 and https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-29.0.md#updated-rpcs
> getblock and getblockheader now return the current target in the target field (#31583)
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314372951)
This is expected, see https://github.com/bitcoin/bitcoin/pull/31583 and https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-29.0.md#updated-rpcs
> getblock and getblockheader now return the current target in the target field (#31583)
π€ w0xlt reviewed a pull request: "kernel: Introduce initial C header API"
(https://github.com/bitcoin/bitcoin/pull/30595#pullrequestreview-3247953537)
Approach ACK
Iβve been using this API in a project for a few days, and itβs been working really well so far.
(https://github.com/bitcoin/bitcoin/pull/30595#pullrequestreview-3247953537)
Approach ACK
Iβve been using this API in a project for a few days, and itβs been working really well so far.
π¬ w0xlt commented on pull request "kernel: Introduce initial C header API":
(https://github.com/bitcoin/bitcoin/pull/30595#discussion_r2365027768)
Wouldnβt it make sense to expose the ` ScriptError` ?
If validation fails, the user might need to know the reason.
(https://github.com/bitcoin/bitcoin/pull/30595#discussion_r2365027768)
Wouldnβt it make sense to expose the ` ScriptError` ?
If validation fails, the user might need to know the reason.
π¬ gmart7t2 commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314536588)
That looks like a release note error to me. Why would we want to know the current target when looking up information about an old block?
The help text for the RPC calls says that it returns the difficulty target and difficulty of blockheader `<hash>`:

It makes no sense to return the target for a different block's difficulty. It means that the block header information returned for old blocks changes over
...
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314536588)
That looks like a release note error to me. Why would we want to know the current target when looking up information about an old block?
The help text for the RPC calls says that it returns the difficulty target and difficulty of blockheader `<hash>`:

It makes no sense to return the target for a different block's difficulty. It means that the block header information returned for old blocks changes over
...
π¬ gmart7t2 commented on issue "RPC: getblock(header) returns the same target for every block":
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314545849)
This tiny change changes both RPCs to return the target for the block of interest rather than the current target:
```
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 8cbca51ccb..edda17d369 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -164,7 +164,7 @@ UniValue blockheaderToJSON(const CBlockIndex& tip, const CBlockIndex& blockindex
result.pushKV("mediantime", blockindex.GetMedianTimePast());
result.pushKV("nonce", blockindex.nNonce);
result
...
(https://github.com/bitcoin/bitcoin/issues/33440#issuecomment-3314545849)
This tiny change changes both RPCs to return the target for the block of interest rather than the current target:
```
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 8cbca51ccb..edda17d369 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -164,7 +164,7 @@ UniValue blockheaderToJSON(const CBlockIndex& tip, const CBlockIndex& blockindex
result.pushKV("mediantime", blockindex.GetMedianTimePast());
result.pushKV("nonce", blockindex.nNonce);
result
...
β οΈ Johnpapandreou21 opened an issue: "Fr to"
(https://github.com/bitcoin/bitcoin/issues/33441)
### Please describe the feature you'd like to see added.
Fr ton
### Is your feature related to a problem, if so please describe it.
_No response_
### Describe the solution you'd like
_No response_
### Describe any alternatives you've considered
_No response_
### Please leave any additional context
_No response_
(https://github.com/bitcoin/bitcoin/issues/33441)
### Please describe the feature you'd like to see added.
Fr ton
### Is your feature related to a problem, if so please describe it.
_No response_
### Describe the solution you'd like
_No response_
### Describe any alternatives you've considered
_No response_
### Please leave any additional context
_No response_
π¬ vasild commented on pull request "system: silence unused variable warning and make GetTotalRAM() work on FreeBSD":
(https://github.com/bitcoin/bitcoin/pull/33435#issuecomment-3314600809)
`2b6497b035...8fcf71ca00`: pick suggestions
> cherry-pick [l0rinc/bitcoin@f011c2c](https://github.com/l0rinc/bitcoin/pull/39/commits/f011c2cdf170dbd53c7ec2e46379238579232d67)
done with some minor changes, see `git range-diff f011c2cd~..f011c2cd 8fcf71ca00~..8fcf71ca00`
(https://github.com/bitcoin/bitcoin/pull/33435#issuecomment-3314600809)
`2b6497b035...8fcf71ca00`: pick suggestions
> cherry-pick [l0rinc/bitcoin@f011c2c](https://github.com/l0rinc/bitcoin/pull/39/commits/f011c2cdf170dbd53c7ec2e46379238579232d67)
done with some minor changes, see `git range-diff f011c2cd~..f011c2cd 8fcf71ca00~..8fcf71ca00`
π¬ vasild commented on pull request "system: silence unused variable warning and make GetTotalRAM() work on FreeBSD":
(https://github.com/bitcoin/bitcoin/pull/33435#discussion_r2365334320)
Done.
(https://github.com/bitcoin/bitcoin/pull/33435#discussion_r2365334320)
Done.
π l0rinc opened a pull request: "validation: make the "rolling forward" loop interruptible"
(https://github.com/bitcoin/bitcoin/pull/33442)
### Summary
Restarting an unsuccessful reindex can result in replay of previously indexed blocks. This process can take many hours and is currently not interruptible.
### Reproducer:
* start a normal ibd, stop after some progress
* do a reindex, stop before it finishes
* restart the node normally without specifying the reindex parameter It should start rolling the blocks forward.
After this change you should be able to interrupt the process:
```
2025-09-20T05:35:42Z Rolling forward
...
(https://github.com/bitcoin/bitcoin/pull/33442)
### Summary
Restarting an unsuccessful reindex can result in replay of previously indexed blocks. This process can take many hours and is currently not interruptible.
### Reproducer:
* start a normal ibd, stop after some progress
* do a reindex, stop before it finishes
* restart the node normally without specifying the reindex parameter It should start rolling the blocks forward.
After this change you should be able to interrupt the process:
```
2025-09-20T05:35:42Z Rolling forward
...
β
achow101 closed an issue: "Fr to"
(https://github.com/bitcoin/bitcoin/issues/33441)
(https://github.com/bitcoin/bitcoin/issues/33441)
π l0rinc opened a pull request: "log: don't rate limit "rolling forward" messages"
(https://github.com/bitcoin/bitcoin/pull/33443)
On an incomplete reindex the blocks will need to be replayed. This results in excessive `Rolling forward` which quickly triggers the recently introduced log rate limiter. Since the corresponding `UpdateTipLog` is also not rate limited, we can either remove the rate limit here as well or change logging to display fewer rolling forward messages. This PR does the first.
Reproducer:
* start a normal ibd, stop after some progress
* do a reindex, stop before it finishes
* restart the node normal
...
(https://github.com/bitcoin/bitcoin/pull/33443)
On an incomplete reindex the blocks will need to be replayed. This results in excessive `Rolling forward` which quickly triggers the recently introduced log rate limiter. Since the corresponding `UpdateTipLog` is also not rate limited, we can either remove the rate limit here as well or change logging to display fewer rolling forward messages. This PR does the first.
Reproducer:
* start a normal ibd, stop after some progress
* do a reindex, stop before it finishes
* restart the node normal
...
π€ mzumsande reviewed a pull request: "validation: make the "rolling forward" loop interruptible"
(https://github.com/bitcoin/bitcoin/pull/33442#pullrequestreview-3248539713)
I did this in #30155 a while back, but in a way such that any partial progress would be saved, and we continue with the next startup.
In any case, now that we flush every hour it's probably a less pressing issue.
(https://github.com/bitcoin/bitcoin/pull/33442#pullrequestreview-3248539713)
I did this in #30155 a while back, but in a way such that any partial progress would be saved, and we continue with the next startup.
In any case, now that we flush every hour it's probably a less pressing issue.
π l0rinc approved a pull request: "system: improve handling around GetTotalRAM()"
(https://github.com/bitcoin/bitcoin/pull/33435#pullrequestreview-3248537350)
ACK 8fcf71ca005449e639f189dec7ec0163a07e6d37
Reproduced the unused clamp on FreeBSD and that the fix returns the correct memory on FreeBSD and NetBSD and OpenBSD as well (`__illumos__` was tested by @hebasto).
I have also tested that on systems that don't support the memory query the test is gracefully skipped and reported as skipped.
Thanks for the quick fix.
(https://github.com/bitcoin/bitcoin/pull/33435#pullrequestreview-3248537350)
ACK 8fcf71ca005449e639f189dec7ec0163a07e6d37
Reproduced the unused clamp on FreeBSD and that the fix returns the correct memory on FreeBSD and NetBSD and OpenBSD as well (`__illumos__` was tested by @hebasto).
I have also tested that on systems that don't support the memory query the test is gracefully skipped and reported as skipped.
Thanks for the quick fix.
π¬ l0rinc commented on pull request "system: improve handling around GetTotalRAM()":
(https://github.com/bitcoin/bitcoin/pull/33435#discussion_r2365342452)
I think this should likely be:
```suggestion
"skipping total_ram_test"
```
(https://github.com/bitcoin/bitcoin/pull/33435#discussion_r2365342452)
I think this should likely be:
```suggestion
"skipping total_ram_test"
```