liftedinit / liftedinit/many-rs

Event IDs with "block" 0 happens on the first 2 blocks

Open
#267 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
6
Forks
11
PR merge metrics
No merged PRs in 30d

Description

The way we setup `latest_tid` in ledger and kvstore makes it so that we repeat the `latest_tid` of the first block;

1. on the first block, `latest_tid` starts at 0.
2. during commit, `latest_tid` is set to `height << SOME_INDEX`. `height` is the current height, which is 0.
3. during the next block, `latest_tid` starts at 0 because of the above, and so any events would have the same IDs as the previous block.
4. during commit, `height` is now `1` and `latest_tid` will be set properly.

We set `latest_tid` to the block height so that we can resume with a known value when resetting the process. This actually highlighted that we cannot resume a non-blockchain ledger.

There are multiple solutions here, but the simplest one would likely be never to set `latest_tid` and only increment it (and save it in the database).

Also, it would be useful to have `height` be not the latest height committed, but the height of the block being built. This would solve some inconsistencies around the storage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing latest_tid initialization and commit handling in the ledger and kvstore, then inspect how block height is recorded during block construction. Done means event IDs remain unique across the first two blocks and the stored height semantics are consistent with the block being built.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.