FuelLabs/fuel-core · error · anyhow::Error

Message should not exist

Error message

Message should not exist

What it means

Duplicate guard for Messages during on-chain genesis import: replace(message.id(), &message) returned Some. A message with the same id (deterministic from sender, recipient, nonce, body and other fields) was already inserted in this batch or already exists in storage.

Solutions

  1. Dedupe messages by message id in the genesis state and re-import.
  2. Wipe the db directory and re-run the import.
  3. Regenerate the message list from the source of truth with deduplication.

Example fix

// before: same message (same nonce + sender + body) twice
"messages": [
  { "sender": "0x...", "recipient": "0x...", "nonce": "0x1", "amount": "100", "data": "0x" },
  { "sender": "0x...", "recipient": "0x...", "nonce": "0x1", "amount": "100", "data": "0x" }
]

// after: single entry
"messages": [ { "sender": "0x...", "recipient": "0x...", "nonce": "0x1", "amount": "100", "data": "0x" } ]
Defensive patterns

Strategy: validation

Validate before calling

fn validate_message_uniqueness(
    messages: &[fuel_core::chain_config::MessageConfig],
) -> Result<(), String> {
    let mut seen = std::collections::HashSet::new();
    for m in messages {
        let id = fuel_core_types::fuel_types::MessageId::new(
            &m.sender,
            &m.recipient,
            &m.nonce,
            m.amount,
            &m.data,
        );
        if !seen.insert(id) {
            return Err(format!("duplicate message id {id} in genesis state"));
        }
    }
    Ok(())
}

Try / catch

match importer.run().await {
    Err(e) if e.to_string().contains("Message should not exist") => {
        // dedupe messages by id and re-import into clean storage
    }
    rest => rest,
}

Prevention

When it happens

Trigger: The same message listed twice in the genesis messages (same sender, recipient, nonce, and body), or import into a database that already contains those messages.

Common situations: Bridge message dumps containing replayed duplicates; snapshot concatenation without dedup; dirty db from a previous import.

Related errors


AI-assisted analysis of FuelLabs/fuel-core@b9d4d170da (2026-08-16). Data as JSON: /api/errors/216887f390c3531a. Report an issue: GitHub.

Appendix: source

Thrown at crates/fuel-core/src/service/genesis/importer/on_chain.rs:329

fn init_da_message(
    transaction: &mut StorageTransaction<&mut GenesisDatabase>,
    msg: TableEntry<Messages>,
    da_height: DaBlockHeight,
) -> anyhow::Result<()> {
    let message: Message = msg.value;

    if message.da_height() > da_height {
        return Err(anyhow!(
            "message da_height cannot be greater than genesis da block height"
        ));
    }

    if transaction
        .storage::<Messages>()
        .replace(message.id(), &message)?
        .is_some()
    {
        return Err(anyhow!("Message should not exist"));
    }

    Ok(())
}

View on GitHub (pinned to b9d4d170da)