linera-io/linera-protocol · error

Start timestamp before 1970

Error message

Start timestamp before 1970

What it means

create-genesis-config converts the --start-timestamp DateTime into microseconds since epoch via u64::try_from(st.timestamp_micros()). If the start timestamp is before 1970-01-01, timestamp_micros() is negative, the conversion returns Err, and .expect("Start timestamp before 1970") panics while computing the genesis timestamp.

Source

Thrown at linera-service/src/cli/main.rs:2419

                    })
                    .transpose()
                    .expect("Invalid application ID")
                    .unwrap_or(existing_policy.free_application_ids),
                flags: flags
                    .as_ref()
                    .map(|values| {
                        values
                            .iter()
                            .map(|s| s.parse())
                            .collect::<Result<BTreeSet<_>, _>>()
                    })
                    .transpose()
                    .expect("Invalid protocol flag")
                    .unwrap_or(existing_policy.flags),
            };
            let timestamp = start_timestamp.map_or_else(Timestamp::now, |st| {
                let micros =
                    u64::try_from(st.timestamp_micros()).expect("Start timestamp before 1970");
                Timestamp::from(micros)
            });

            let mut keystore = options.create_keystore(*testing_prng_seed)?;
            let admin_public_key = keystore.generate_key().await?;

            let network_name = network_name.clone().unwrap_or_else(|| {
                // Default: e.g. "linera-2023-11-14T23:13:20"
                format!("linera-{}", Utc::now().naive_utc().format("%FT%T"))
            });
            let mut genesis_config = persistent::File::new(
                genesis_config_path,
                committee_config.into_genesis(
                    timestamp,
                    policy,
                    network_name,
                    admin_public_key,
                    *initial_funding,

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. Supply a start timestamp at or after 1970, normally the intended near-future time: --start-timestamp '2026-09-01T00:00:00Z'
  2. Omit --start-timestamp to default to Timestamp::now if an explicit start is unnecessary
  3. Add a date sanity check to the genesis script (year >= 1970, value in the future) before running the CLI

Example fix

# before
linera create-genesis-config ... --start-timestamp 1969-01-01T00:00:00Z

# after
linera create-genesis-config ... --start-timestamp 2026-09-01T00:00:00Z
Defensive patterns

Strategy: validation

Validate before calling

# Sanity-check the start timestamp before create-genesis-config.
START_TS='2026-09-01T00:00:00Z'
epoch=$(date -u -d "$START_TS" +%s)
[ "$epoch" -gt 0 ] || { echo 'start timestamp must be after 1970' >&2; exit 1; }
linera create-genesis-config ... --start-timestamp "$START_TS"

Prevention

When it happens

Trigger: Passing --start-timestamp with a pre-epoch date (year < 1970): a typo like 1026 instead of 2026, a negative epoch offset, or a misparsed local-time string that lands before the epoch.

Common situations: Scripted date arithmetic producing negative epoch values; typo'd ISO-8601 years; timestamps generated from uninitialized clocks or default zero-values interpreted as pre-epoch.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/b29f9ed741377691. Report an issue: GitHub.