-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(revive): handle transaction hash conflicts during re-org #10950
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
Conversation
When a blockchain re-org occurs and the same transaction is included in a different block, the INSERT into transaction_hashes would fail with a UNIQUE constraint violation if the server had restarted (losing the in-memory block_number_to_hashes map used for pruning). This change uses INSERT OR REPLACE to update the block_hash when a transaction is re-included in a different block after a re-org, matching the pattern already used for insert_block_mapping. Fixes: UNIQUE constraint failed: transaction_hashes.transaction_hash
|
/cmd prdoc --audience runtime_dev --bump patch |
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
…time_dev --bump patch'
| // Transaction should now point to block B | ||
| let (found_hash, _) = provider.find_transaction(&tx_hash).await.unwrap(); | ||
| assert_eq!(found_hash, block_b.hash); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert_eq!(count(&provider.pool, "eth_to_substrate_blocks", None).await, 1); |
Or it is ok to have block A still sitting in the table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point we can check in another PR, if we do clean up forked blocks
Summary
Fixes a UNIQUE constraint violation when processing blocks after a re-org:
Problem
When a blockchain re-org occurs:
transaction_hashesblock_number_to_hashesmap)