Bitcoin Forum
April 19, 2024, 10:53:05 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Going backward in time  (Read 227 times)
miner2251 (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 85


View Profile
October 12, 2021, 04:07:10 PM
Merited by vapourminer (2), Timelord2067 (1), ABCbits (1)
 #1

Is it possible to go back in time in a chain? For example, starting from 2009 is it possible to produce blocks with earlier and earlier timestamps and for example reach 2005? Or is there any strict requirement that block timestamps have to go forward? Because if there are three sources of time: local time, time from other nodes and time from block headers, if the first two will be faked, is it possible to also fake block timestamps and set any date, if the whole chain will be long enough?
1713523985
Hero Member
*
Offline Offline

Posts: 1713523985

View Profile Personal Message (Offline)

Ignore
1713523985
Reply with quote  #2

1713523985
Report to moderator
Bitcoin mining is now a specialized and very risky industry, just like gold mining. Amateur miners are unlikely to make much money, and may even lose money. Bitcoin is much more than just mining, though!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713523985
Hero Member
*
Offline Offline

Posts: 1713523985

View Profile Personal Message (Offline)

Ignore
1713523985
Reply with quote  #2

1713523985
Report to moderator
1713523985
Hero Member
*
Offline Offline

Posts: 1713523985

View Profile Personal Message (Offline)

Ignore
1713523985
Reply with quote  #2

1713523985
Report to moderator
BlackHatCoiner
Legendary
*
Online Online

Activity: 1498
Merit: 7235


Farewell, Leo


View Profile
October 12, 2021, 04:18:11 PM
Last edit: October 12, 2021, 08:03:21 PM by BlackHatCoiner
Merited by JayJuanGee (1), hugeblack (1)
 #2

If you started from the very first block, then I don't know, I'll have to look into the code, but: Why does it matter? If a new person wanted to start another chain, they'd mine themselves the first block(s).

If you didn't start from the first block, then no. Because of NLockTime.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
miner2251 (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 85


View Profile
October 12, 2021, 04:28:41 PM
Last edit: October 12, 2021, 04:41:58 PM by miner2251
Merited by NotATether (5), hugeblack (4), o_e_l_e_o (4), vapourminer (2), ABCbits (2)
 #3

Quote
Why does it matter?
Because if doing so is possible, then another kind of attack is possible. For example: an adversary miner could start producing blocks with future timestamps to drop difficulty, then jump back in time (if it is possible and if that does not require dealing with endlessly growing difficulty), and then create a deep reorganization, because a lot of blocks with smaller difficulty could create a sum of chainwork greater than the honest chain. That attack could be of course noticed by anyone, but if it matches consensus rules, then it will be accepted by existing clients. Also, there are some altcoins with different difficulty adjustment algorithms, if the same way of checking time is repeated in other coins, then that altcoins could be potentially easier attacked in this way, because their difficulty can be changed sooner than for example every two weeks.

Edit:
Quote
Because of NLockTime. (Going to continue, gotta go)
Imagine that some transaction have NLockTime set in October 2021. Does it mean that if such transaction is included in the chain, then it is impossible to create any next block with any timestamp below that NLockTime? How it is checked? If you have a new block header, is it compared with some globally stored max(NLockTimeTx1,NLockTimeTx2,...,NLockTimeTxN)?
BlackHatCoiner
Legendary
*
Online Online

Activity: 1498
Merit: 7235


Farewell, Leo


View Profile
October 12, 2021, 08:01:05 PM
Merited by vapourminer (1)
 #4

Imagine that some transaction have NLockTime set in October 2021. Does it mean that if such transaction is included in the chain, then it is impossible to create any next block with any timestamp below that NLockTime? How it is checked?
You sound like myself, couple of months ago when I had a similar query. Read Re: Strange Timestamp Argument.

If you have a new block header, is it compared with some globally stored max(NLockTimeTx1,NLockTimeTx2,...,NLockTimeTxN)?
Are you asking if it's possible to include a transaction whose timestamp is greater than the block's? Whether it does or does not (I honestly don't know, it is required to check the source code), but what does this have to do with your questioning?

The difficulty isn't affected from the transactions' timestamp, but from the blocks'.

For example: an adversary miner could start producing blocks with future timestamps to drop difficulty, then jump back in time (if it is possible and if that does not require dealing with endlessly growing difficulty)
That's true if he's the only miner. As long as there're other miners and an honest majority, willing to play by the rules, it's impossible. What you describe cannot happen due to the median time limitation that is calculated from the comparison of the last 11 blocks. It's written in the nLockTime wiki page.

In other words, one cannot manipulate the timestamp without having the majority of the computational power. The other miners will sooner or later get ahead him.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
DannyHamilton
Legendary
*
Offline Offline

Activity: 3360
Merit: 4570



View Profile
October 12, 2021, 08:59:41 PM
Merited by vjudeu (5), hugeblack (4), vapourminer (3), ABCbits (3), pooya87 (2), RickDeckard (2), n0nce (2), JayJuanGee (1)
 #5

The answer to your question is no, in multiple ways.

First of all, you couldn't create a valid block that precedes the origin block in position in the chain (or even one that closely follows the origin block) without re-performing proof-of-work on EVERY BLOCK that has been created since.  This is because each block contains the hash of its immediately preceding block.  To create a block that precedes any given block, you'd have to create a block that hashes to the EXACT value that is already stored in the block that you are trying to immediately precede.  Since this is effectively impossible, the only alternative is to re-perform the proof-of-work on the block that immediately follows yours using the hash of your block as the "previous block" for your re-hashing attempt.  Unfortunately, this will change the value of that block, so you'll need to re-perform proof-of-work on the block that follows it, and so on.  That's WHY it's called a "blockCHAIN".

Alternately, if you wanted to create a block that just gets placed at the most recent end of the chain as a new "most recently created block", you'll be bound by the rule that any valid block cannot have a timestamp earlier than the median of the timestamps in the 11 blocks that immediately precede it. As such, you can't create a block that is added to the tip of the chain with a date older than a few hours ago.
miner2251 (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 85


View Profile
October 12, 2021, 09:33:36 PM
 #6

I tested some values by starting from zero unix time and saw that it always can only go forward, because it always has to be greater than the median time of the last 11 blocks. But I have another time-related question: will the chain be halted when reaching median time equal to 0xffffffff? Or maybe we have some kind of overflow bug here, as it was in Value Overflow Incident, but time-related, so is it possible to jump back from 0xffffffff to 0x00000000?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3360
Merit: 4570



View Profile
October 13, 2021, 01:22:15 AM
Last edit: October 13, 2021, 02:32:25 PM by DannyHamilton
Merited by nc50lc (1)
 #7

I have another time-related question: will the chain be halted when reaching median time equal to 0xffffffff? Or maybe we have some kind of overflow bug here, as it was in Value Overflow Incident, but time-related, so is it possible to jump back from 0xffffffff to 0x00000000?

Standard unix time uses a signed 4-byte integer. If I remember correctly, Bitcoin blocks use an unsigned 4-byte integer. This allows an additional 68 years before it becomes a problem.

<edit>It seems I did not remember correctly. See the next 2 comments below.</edit>

I'm not sure if the overflow has been addressed in code yet, but if it hasn't, then we've got about 85 more years to take care of it.

<edit>It appears it has not been.  See below.</edit>
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10490



View Profile
October 13, 2021, 03:49:40 AM
Merited by vjudeu (5), JayJuanGee (1)
 #8

Standard unix time uses a signed 4-byte integer. If I remember correctly, Bitcoin blocks use an unsigned 4-byte integer. This allows an additional 68 years before it becomes a problem.

I'm not sure if the overflow has been addressed in code yet, but if it hasn't, then we've got about 85 more years to take care of it.
In block header the value can be either signed or unsigned since it is just a byte stream (bitcoin core uses unsigned Int32) but when it comes to comparison it will be cast to (signed) Int64 then compared to address the overflows.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
miner2251 (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 85


View Profile
October 13, 2021, 04:42:29 AM
Last edit: October 13, 2021, 07:11:03 PM by miner2251
Merited by ABCbits (10), stwenhao (5), LoyceV (4), vapourminer (3), BlackHatCoiner (3), vjudeu (3), pooya87 (2), JayJuanGee (1), n0nce (1)
 #9

It seems that Bitcoin Core is affected by 2038 year problem, I set my clock to 0x7fffffff and the client is halted with this assertion, because when reaching 0x80000000 it is treated as a negative value.
Code:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Assertion failed!

Program: C:\Program Files\Bitcoin\bitcoin-qt.exe
File: util/time.cpp
Line: 97

Expression: now.count() > 0

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

(Press Retry to debug the application - JIT must be enabled)
---------------------------
Abort   Retry   Ignore  
---------------------------

Edit: It seems that I was right and when median time will reach 0xffffffff, it will be impossible to create any new blocks in such chain. Then, modifying the chain is no longer possible without chain reorganization, because the timestamp of the next block has to be greater than 0xffffffff, so there is no 32-bit value that can meet this rule.
Code:
submitblock 0100000006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f3663c0de115e2239e05df4df9c4bfa01b8e843aaf5dae590cac1d9bac0d44c0fffffffffffff7f200100000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0200f2052a010000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000
null
generatetoaddress 1 mpXwg4jMtRhuSpVq4xS3HFHmCmWp9NyGKt
CreateNewBlock: TestBlockValidity failed: time-too-old, block's timestamp is too early (code -1)
hlbog
Jr. Member
*
Offline Offline

Activity: 31
Merit: 10


View Profile
October 13, 2021, 11:12:27 PM
Merited by vapourminer (4), o_e_l_e_o (4), JayJuanGee (1), vjudeu (1)
 #10

2038y problem was reported in March 4th, on this issue:

https://github.com/bitcoin/bitcoin/issues/21356


It seems we'll be fine if we use an updated version of std::chrono.
vjudeu
Hero Member
*****
Offline Offline

Activity: 656
Merit: 1507



View Profile
October 14, 2021, 10:05:53 AM
Merited by vapourminer (2), JayJuanGee (1)
 #11

Quote
so the problem is on Bitcoin Core implementation
This is true if we talk about reaching 0x80000000 and higher values. However, if I understand that correctly, the whole chain will halt after reaching median time 0xffffffff, so producing any new blocks after year 2106 will be impossible, because of currently used consensus rules.

Quote
For reference, what Bitcoin Core version did you use?
I can reproduce the same error messages in 22.0, so I guess all recent versions are affected, maybe some older version handled that differently, but I think many clients will crash in 2038, including custom software used by miners. Also, I cannot produce any valid block after reaching 0xffffffff median time, I tried many different 32-bit values, but each time Bitcoin Core thinks that the time is too old.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
miner2251 (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 85


View Profile
October 15, 2021, 05:10:33 PM
 #12

Quote
I can reproduce the same error messages in 22.0
Yes, it was the newest official release 22.0 for Windows.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!