Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

popcnt1
Copy link
Collaborator

@popcnt1 popcnt1 commented Aug 23, 2024

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) })

Improved mismatch detection by categorizing mismatches into metadata, value, and object level. Added comparison and detailed output formatting for better debugging.
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.
Decode and utilize the expected value object in mismatch handling.
This ensures that both metadata and value mismatches are accurately compared and displayed.
Enhanced genesis verification to support rune comparison and properly format differences. Added helper functions to convert and compare rune values.
Update `rune_from_json_value` to parse runes from JSON objects instead of arrays. Add unit tests to ensure parsing accuracy.
Replace unwraps with `?` operator for better error handling.
Add detailed unit tests including bitcoin inscription handling.
Copy link

vercel bot commented Aug 23, 2024

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) Visit Preview Aug 23, 2024 9:45pm

@popcnt1 popcnt1 merged commit 48195ad into rooch-network:main Aug 23, 2024
7 checks passed
@popcnt1 popcnt1 deleted the refactor/statedb/genesis-verify/cmp-fields branch August 23, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant