rooch-network / rooch

VApp Container with Move Language for Bitcoin ecosystem
https://rooch.network
Apache License 2.0
158 stars 83 forks source link

[bitcoin]: inconsistent states between rooch L1 block execution and bitcoin/ordinals database (relay blocks after import) #2450

Open popcnt1 opened 1 month ago

popcnt1 commented 1 month ago

Rooch version

0.6.8

What did you do?

  1. rooch statedb genesis with utxo & inscription data. block height: [0, 852203)
  2. rooch server start with local bitcoind, sync btc height [852203, 855669] ( have seen log entry: 2024-08-08T17:19:55.719351Z INFO rooch_relayer::actor::relayer: Relayer execute relay block(hash: 9559fcd5b7e769d97bb3705f5548d3583542518215e402000000000000000000, height: 855669) succeed)
  3. rooch statedb genesis-verify --utxo-source ~/moe/btc/utxo/utxo_0_855666 --ord-source ~/moe/btc/ord/dump/ord_0_855666 --outpoint-inscriptions-map-dump-path ~/joe/rooch-dev-chore/855666_outpoint_ins_map -d ~/moe/rooch_data/0_852202_local_seq_clone/ -n main --random-mode --utxo-mismatched-output ~/joe/rooch-dev-chore/verify/855666/new/utxo-mismatched-output --ord-mismatched-output ~/joe/rooch-dev-chore/verify/855666/new/ord-mismatched-output

What did you see happen?

lots inconsistent results found by: rooch statedb genesis-verify

output of cmd: verify.log

mismatched utxo mismatched ord mismatched ord with sequential 50000case

in brief:

cat verify.log | grep FAILED -n -A 2
254:------------FAILED----------------
255-[inscription_store] mismatched size. metadata: exp: 148629784, act: 148629784; cursed: exp: 472043, act: 1138940; blessed: exp: 73842849, act: 73175952; next_sequence_number: exp: 74314892, act: 74314892
256:-----------FAILED-----------------
257:inscription check FAILED. total: 74314892. (mismatched(not_found)/checked): inscription: (1714(0)/74672); inscription_id: (80(0)/74672). cost: 686.399750517s
258-utxo checking: total: 174000000. (mismatched(not_found)/checked): utxo: (312(0)/174151); address: (0(0)/49731). cost: 689.59295572s
259-utxo checking: total: 175000000. (mismatched(not_found)/checked): utxo: (312(0)/175134); address: (0(0)/49969). cost: 693.008468222s
--
269:------------FAILED----------------
270-[utxo_store] mismatched size: exp: 184174498, act: 192548066
271:------------FAILED----------------
272-[address_mapping] mismatched size: exp: 52217048, act: 59708773
273:------------FAILED----------------
274:utxo check FAILED. total: 184174498. (mismatched(not_found)/checked): utxo: (328(0)/184422); address: (0(0)/52275). cost: 725.046587159s
275-null
276-2024-08-16T12:41:53.719291Z  INFO raw_store: Metrics task cancelled for store instance

What did you expect to see?

All things must be matched, main-network has 3 blocks delay, so the state of rooch must be 855666(included)

popcnt1 commented 1 month ago

here is an example: https://github.com/rooch-network/rooch/issues/2441

popcnt1 commented 3 weeks ago

@jolestar owner mismatched:

exp: ba06efa8847c0cba1a7a5dfb62a97e29babf254d788f9ad2389918bc283cf3fd act: 67c639831111df7404f95c2d60ddacd8eb6ad4ac90a54ad0a7cc38d04a7d468e

[inscription] mismatched_meta_val: exp-meta: "ObjectMeta { id: 0xd23c49fb9a742624498390a5b59c90e968c11d52b6437278a0e2eb9b82824103c516d27f40b0ab19ed26e7f0bfe86d789936a7cdd57119ba64092b61cd4e1082, owner: ba06efa8847c0cba1a7a5dfb62a97e29babf254d788f9ad2389918bc283cf3fd, flag: 0, state_root: None, size: 0, created_at: 0, updated_at: 0, object_type: Struct(StructTag { address: 0000000000000000000000000000000000000000000000000000000000000004, module: Identifier(\"ord\"), name: Identifier(\"Inscription\"), type_params: [] }) }", act-meta: "ObjectMeta { id: 0xd23c49fb9a742624498390a5b59c90e968c11d52b6437278a0e2eb9b82824103c516d27f40b0ab19ed26e7f0bfe86d789936a7cdd57119ba64092b61cd4e1082, owner: 67c639831111df7404f95c2d60ddacd8eb6ad4ac90a54ad0a7cc38d04a7d468e, flag: 0, state_root: None, size: 0, created_at: 0, updated_at: 0, object_type: Struct(StructTag { address: 0000000000000000000000000000000000000000000000000000000000000004, module: Identifier(\"ord\"), name: Identifier(\"Inscription\"), type_params: [] }) }", exp-val: "Inscription { txid: caaa156fb2770f35b5343c8cb265c33b7828ca1871fd5b47e28d8450703dd4b6, index: 76, offset: 0, sequence_number: 74294535, inscription_number: 73822492, is_curse: false, body: [115, 104, 117, 110, 115, 104, 117, 110, 46, 98, 116, 99], content_encoding: MoveOption { vec: [] }, content_type: MoveOption { vec: [text/plain] }, metadata: [], metaprotocol: MoveOption { vec: [] }, parents: [], pointer: MoveOption { vec: [25080] }, rune: MoveOption { vec: [] } }", act-val: "Inscription { txid: caaa156fb2770f35b5343c8cb265c33b7828ca1871fd5b47e28d8450703dd4b6, index: 76, offset: 25080, sequence_number: 74294535, inscription_number: 1127922, is_curse: true, body: [115, 104, 117, 110, 115, 104, 117, 110, 46, 98, 116, 99], content_encoding: MoveOption { vec: [] }, content_type: MoveOption { vec: [text/plain] }, metadata: [], metaprotocol: MoveOption { vec: [] }, parents: [], pointer: MoveOption { vec: [25080] }, rune: MoveOption { vec: [] } }", src_data: Some(InscriptionSource { sequence_number: 74294535, inscription_number: 73822492, id: BitcoinInscriptionID { txid: 0xb6d43d7050848de2475bfd7118ca28783bc365b28c3c34b5350f77b26f15aaca, index: 76 }, satpoint_outpoint: "b6d43d7050848de2475bfd7118ca28783bc365b28c3c34b5350f77b26f15aaca:76", satpoint_offset: 0, body: Some([115, 104, 117, 110, 115, 104, 117, 110, 46, 98, 116, 99]), content_encoding: None, content_type: Some("text/plain"), metadata: None, metaprotocol: None, parent: None, pointer: Some(25080), address: "bc1q7pwyaxta920ks5rekvskwzq8gf8g8v58w5jd25", rune: None })

popcnt1 commented 3 weeks ago

@jolestar after re-check and help with new version of verification cmd, I've found there is no index issue( I made mistake, may caused by wrong comparasion with parent's index. The origin version of output is hard to read for human).

For new output, we could easily grep certain fields:

grep diff_ is all you need to do.

ord_mismatched utxo_mismatched ord_mismatched_sequence_number_list utxo_mismatched_outpoint_list

popcnt1 commented 3 weeks ago

For utxo, all cases are seals not match:

number of cases = number of diff_seals