-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(coprocessor): use block hash to identify transaction #1438
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
base: release/0.10.x
Are you sure you want to change the base?
Conversation
29b7096 to
668274f
Compare
|
add a test with duplicate transaction id that forms a transaction cycle without the block hash |
668274f to
05ddd0a
Compare
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.
Pull request overview
This PR enhances transaction identification in the coprocessor system by adding block_hash and block_number fields alongside the existing transaction_id. This change enables proper identification of transactions that may be replayed or reorged across different blocks on the blockchain, which is critical for handling blockchain reorganizations correctly.
Key changes:
- Added
block_hashandblock_numberfields to theAsyncComputationprotobuf message - Created a new
Transactiontype combiningtransaction_idandblock_hashfor unique identification - Updated database schema with new columns and composite indexes
- Modified all SQL queries to use the composite key
(transaction_id, block_hash)for transaction identification
Reviewed changes
Copilot reviewed 25 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| coprocessor/proto/coprocessor.proto | Added block_hash and block_number fields to AsyncComputation message |
| coprocessor/fhevm-engine/scheduler/src/dfg/types.rs | Introduced Transaction struct and updated DFGTxResult to use it |
| coprocessor/fhevm-engine/scheduler/src/dfg.rs | Updated component node building to use Transaction type |
| coprocessor/fhevm-engine/scheduler/src/dfg/scheduler.rs | Updated scheduler logic to work with Transaction objects |
| coprocessor/fhevm-engine/tfhe-worker/src/tfhe_worker.rs | Modified queries and handlers to include block_hash in all operations |
| coprocessor/fhevm-engine/tfhe-worker/src/server.rs | Updated computation insertion to include block metadata |
| coprocessor/fhevm-engine/host-listener/src/database/tfhe_event_propagate.rs | Added block_hash to database insertion logic |
| coprocessor/fhevm-engine/host-listener/src/cmd/mod.rs | Updated block insertion to include block_hash |
| coprocessor/fhevm-engine/db-migration/migrations/*.sql | Added new database columns and indexes |
| coprocessor/fhevm-engine/tfhe-worker/src/tests/*.rs | Updated all test fixtures to include block_hash and block_number |
| coprocessor/fhevm-engine/tfhe-worker/benches/*.rs | Updated all benchmark fixtures to include block_hash and block_number |
| coprocessor/fhevm-engine/tfhe-worker/src/bin/cli.rs | Updated CLI smoke test to include new fields |
| coprocessor/fhevm-engine/tfhe-worker/src/utils.rs | Updated test utilities to include new fields |
| coprocessor/fhevm-engine/stress-test-generator/src/utils.rs | Updated stress test generator to include block_hash |
| coprocessor/fhevm-engine/.sqlx/*.json | Updated SQL query metadata files |
| coprocessor/fhevm-engine/Cargo.lock | Updated svm-rs and svm-rs-builds dependencies (unrelated change) |
Files not reviewed (2)
- coprocessor/fhevm-engine/.sqlx/query-63f097acd50a5ec09f959668fce297d0c2c1c9851741c2a5bbb3238af2fe5b75.json: Language not supported
- coprocessor/fhevm-engine/.sqlx/query-b759c3143d1832a0f950a57fd3a795a87b98cd4267f5a858ab4f6320c8200209.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| block_hash: block_hash.clone(), | ||
| block_number, | ||
| is_allowed: true, |
Copilot
AI
Dec 4, 2025
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.
[nitpick] The field order in this AsyncComputation struct initialization is inconsistent with the protobuf definition order. While Rust allows any field order, it's a best practice to match the definition order for maintainability. The correct order should be: inputs, is_allowed, block_hash, block_number. Consider reordering these fields to match the protobuf definition and the pattern used in other files.
fixes a bug where 2 transactions are swapped during a reorg while keeping the same tx id the 4 tx (2 are reorged out) are merged and create a cycle
05ddd0a to
eb0ca4b
Compare
No description provided.