Page MenuHomePhabricator

[Chronik] Add `MempoolTokens` to index mempool token txs
ClosedPublic

Authored by tobias_ruck on Jan 5 2024, 17:27.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC9fe11d18aec3: [Chronik] Add `MempoolTokens` to index mempool token txs
Summary

Parses, colors, validates and indexes mempool txs as SLP/ALP txs.

In fetch_tx_spent_tokens, bulk-query ops are used wherever possible. It is exposed so we can use it in the indexer later, too.

Test Plan

cargo test -p chronik-db test_mempool_tokens

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tobias_ruck updated this revision to Diff 43946.

remove dbg! macros

Fabien requested changes to this revision.Jan 8 2024, 09:45
Fabien added inline comments.
chronik/chronik-db/src/mem/tokens.rs
38 ↗(On Diff #43946)

Please add the word token somewhere in this message, otherwise it can be understood as if the mempool was corrupted

89 ↗(On Diff #43946)

Since this is expected to not fail as the genesis should be in a block already, should you have some error in the else case to give feedback to the user?

164 ↗(On Diff #43946)

What happens if the tx is in the mempool but the vout doesn't exist ?

195 ↗(On Diff #43946)

Please comment: "Not a token spendable output"

777 ↗(On Diff #43946)
804 ↗(On Diff #43946)

Can you remove txid(10) and check the input is not found on txid(11) instead ? You get more coverage

This revision now requires changes to proceed.Jan 8 2024, 09:45
chronik/chronik-db/src/mem/tokens.rs
89 ↗(On Diff #43946)

The error will be "Missing MINT Vault"; I think this should be enough in practice

164 ↗(On Diff #43946)

token_tx.outputs.get(out_idx) => None already covers that. And for non-token txs, bitcoind will ensure the output exists

mention "token" in error messages; add explanatory comments; fix typo; test tx 10 too

chronik/chronik-db/src/mem/tokens.rs
804 ↗(On Diff #43946)

Not sure why exactly; the mempool expects txs to be removed in reverse-topological order and 11 depends on 10, so it'll just sperg

The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
Fabien requested changes to this revision.Jan 12 2024, 13:55

Please rebase on master for the tests to run

This revision now requires changes to proceed.Jan 12 2024, 13:55

fix bug when adding uncolored txs that burn tokens to the mempool

This revision is now accepted and ready to land.Jan 15 2024, 11:04