Neptune-Crypto / neptune-core

anonymous peer-to-peer cash
Apache License 2.0
23 stars 7 forks source link

Launch Date in Future causes mining error due to invalid block time. #158

Closed dan-da closed 1 week ago

dan-da commented 1 month ago

I normally test mining wtih regtest, but just now I tried with alpha and I get this error:

2024-05-30T17:01:43.378836263Z  WARN ThreadId(03) neptune_core::models::blockchain::block: Block's timestamp (1717088503376) should be greater than or equal to that of previous block (1719792000000)
previous <= current ?? false
thread 'tokio-runtime-worker' panicked at /home/danda/dev/neptune/neptune-core/src/mine_loop.rs:471:17:
Own mined block must be valid. Failed validity check after successful PoW check.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is while mining block 1. Notice that the previous block (genesis) is larger.

Investigating a bit further:

$ cargo run --bin neptune-cli -- block-info height/0 | grep time
timestamp: 2024-06-30T17:00:00-07:00

Hmm, today is 2024-05-30, so that date is in the future.

Checking in network.rs, Network::launch_date():

            Network::RegTest => Timestamp(BFieldElement::new(now_rounded)),
            // 1 July 2024 (might be revised though)
            Network::Alpha | Network::Testnet | Network::Beta | Network::Main => {
                Timestamp(BFieldElement::new(1719792000000u64))
            }

so yeah, for all networks except regtest genesis block is hard-coded with a timestamp in the future that breaks mining in the present.

What to do:

dan-da commented 1 week ago

today is 2024-07-02. closing.