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

Duplicate creation of cell_input data in transactions #543

Closed
rabbitz opened this issue Feb 18, 2024 · 1 comment
Closed

Duplicate creation of cell_input data in transactions #543

rabbitz opened this issue Feb 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rabbitz
Copy link

rabbitz commented Feb 18, 2024

Summary

https://explorer.nervos.org/block/11990208

Some transactions have synchronization anomalies, synchronizing redundant inputs, and displaying some addresses as "Unable to decode address".

image

Reason

We found an example transaction https://explorer.nervos.org/transaction/0xbe996233232e586cfd2cd4b2012aad7a2e8b8bde1c049bef514002837c4ee780, which seems to have issues in processing pending transactions.

At 2024-01-18 10:30:49 +0800, 2 pending transactions were synchronized. However, an exception occurred when searching for the previous output with previous_index 604. The corresponding previous output was not found. At this point, the cell's index is 1, but the field was not created when recording the cell input.

At 2024-01-18 15:23:04 +0800, the transaction was synchronized again. Due to the primary key of the cell input database being based on ckb_transaction_id and index, duplicate data was inserted, and the issue of incorrectly updating duplicate cells from the previous pending transactions occurred.

#<CellInput:0x00007f0b43422598
  ckb_transaction_id: 29981415,
  created_at: Thu, 18 Jan 2024 15:23:04.575152000 CST +08:00,
  updated_at: Thu, 18 Jan 2024 15:23:04.575157000 CST +08:00,
  previous_cell_output_id: 57242535,
  from_cell_base: false,
  block_id: 12008642,
  since: 0,
  cell_type: "normal",
  index: 1,
  previous_tx_hash: "0x84e7f0c14013918dce426a3f307ad0bad966eec264d7e50009036e52d0401938",
  previous_index: 604>,
 #<CellInput:0x00007f0b43421c10
  ckb_transaction_id: 29981415,
  created_at: Thu, 18 Jan 2024 10:30:49.796601000 CST +08:00,
  updated_at: Thu, 18 Jan 2024 10:30:49.796601000 CST +08:00,
  previous_cell_output_id: nil,
  from_cell_base: false,
  block_id: nil,
  since: 0,
  cell_type: "normal",
  index: nil,
  previous_tx_hash: "0x84e7f0c14013918dce426a3f307ad0bad966eec264d7e50009036e52d0401938",
  previous_index: 604>]

Therefore, the error "Unable to decode address" occurred.

https://github.com/nervosnetwork/ckb-explorer/blob/2f318c1ea9e440ee5e77e1b6704452224bba3670/app/models/ckb_sync/new_node_data_processor.rb#L908-L909

https://github.com/nervosnetwork/ckb-explorer/blob/6e31433319ac413e22482201be42ac6b8bc21fcf/app/jobs/import_transaction_job.rb#L74-L78

@rabbitz rabbitz added the bug Something isn't working label Feb 18, 2024
@rabbitz rabbitz self-assigned this Feb 18, 2024
@rabbitz
Copy link
Author

rabbitz commented Feb 18, 2024

@poor-defined poor-defined moved this to 🆕 New in CKB Explorer Feb 18, 2024
@poor-defined poor-defined moved this from 🆕 New to 🔎 Code Review in CKB Explorer Feb 19, 2024
@poor-defined poor-defined moved this from 🔎 Code Review to ✅ Done in CKB Explorer Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants