rooch-network / rooch

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

feat(statedb/genesis-verify): enhance mismatch detetion(fields level output) #2497

Closed popcnt1 closed 1 month ago

popcnt1 commented 1 month ago

Summary

  1. Improved mismatch detection by categorizing mismatches into field, metadata, value, and object level. Added comparison and detailed output formatting for better debugging.
  2. Enhanced the inscription state comparison by adding InscriptionForComparison struct and its related methods. Also optimized file I/O operations with buffered reads and writes for performance gains.
  3. Enhanced genesis verification to support rune comparison and properly format differences. Added helper functions to convert and compare rune values. (rune is u128, lack of supports in json)

e.g.

we could search certain mismatched type by: grep diff_*

[inscription] mismatched_meta. <diff_meta: "diff_owner: String(\"721b1d265d7031b22ca16d9857904c1a2014f4f242f68f484d729198ce01cf4e\") -> String(\"0000000000000000000000000000000000000000000000000000000000000004\")">; <diff_val: "diff_inscription_number: Number(73839872) -> Number(73173785);diff_rune: Some(449272580684223630017036914) -> None">. exp_meta: ObjectMeta { id: 0xd23c49fb9a742624498390a5b59c90e968c11d52b6437278a0e2eb9b828241032ba7f3a274c3b3f33d04b7621264ca56357ac57d4a0b416eec523591bb5a01ba, owner: 721b1d265d7031b22ca16d9857904c1a2014f4f242f68f484d729198ce01cf4e, 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: InscriptionForComparison { txid: 27d4544d856234c7934eebffb0dbc05f4c6438481ba7b57288978ae7034832ab, index: 0, offset: 0, sequence_number: 74311915, inscription_number: 73839872, is_curse: false, body: [79, 102, 102, 105, 99, 105, 97, 108, 32, 67, 101, 110, 116, 114, 105, 99, 97, 32, 112, 108, 99], content_encoding: MoveOption { vec: [] }, content_type: MoveOption { vec: [text/plain;charset=utf-8] }, metadata: [], metaprotocol: MoveOption { vec: [] }, parents: [], pointer: MoveOption { vec: [] }, rune: MoveOption { vec: [[114, 2, 168, 87, 207, 215, 154, 102, 43, 161, 115, 1]] } }; src_data: Some(InscriptionSource { sequence_number: 74311915, inscription_number: 73839872, id: BitcoinInscriptionID { txid: 0xab324803e78a978872b5a71b4838644c5fc0dbb0ffeb4e93c73462854d54d427, index: 0 }, satpoint_outpoint: "ab324803e78a978872b5a71b4838644c5fc0dbb0ffeb4e93c73462854d54d427:1", satpoint_offset: 0, body: Some([79, 102, 102, 105, 99, 105, 97, 108, 32, 67, 101, 110, 116, 114, 105, 99, 97, 32, 112, 108, 99]), content_encoding: None, content_type: Some("text/plain;charset=utf-8"), metadata: None, metaprotocol: None, parent: None, pointer: None, address: "bc1pl6xn9vvpqna0grwd0tuwyj9z8s55gw8wvrd8885yra9hc9hlkh5s0rcxm2", rune: Some(449272580684223630017036914) })
vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 9:45pm
1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **rooch** | ⬜️ Ignored ([Inspect](https://vercel.com/rooch/rooch/GMztHiY7ASxKH8hTiFQYY12G1PE5)) | [Visit Preview](https://rooch-git-fork-popcnt1-refactor-statedbgenesis-ver-446dc9-rooch.vercel.app) | | Aug 23, 2024 9:45pm |