-
Notifications
You must be signed in to change notification settings - Fork 24
fix: add non-zero balance checks and moved tx ingestion to post-val #1083
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ use irys_actors::services::ServiceSenders; | |
| use irys_actors::{MempoolFacade, TxIngressError}; | ||
| use irys_database::block_header_by_hash; | ||
| use irys_database::db::IrysDatabaseExt as _; | ||
| use irys_database::reth_db::Database as _; | ||
| use irys_domain::chain_sync_state::ChainSyncState; | ||
|
|
||
| #[cfg(test)] | ||
|
|
@@ -820,33 +821,14 @@ where | |
| block_transactions.commitment_txs.len() | ||
| ); | ||
|
|
||
| // Insert transactions into mempool so validation service can find them later. | ||
| for commitment_tx in &block_transactions.commitment_txs { | ||
| if let Err(err) = self | ||
| .mempool | ||
| .handle_commitment_transaction_ingress_gossip(commitment_tx.clone()) | ||
| .await | ||
| { | ||
| if !matches!(err, TxIngressError::Skipped) { | ||
| warn!( | ||
| "Block pool: Failed to insert commitment tx {} into mempool for block {:?}: {:?}", | ||
| commitment_tx.id(), current_block_hash, err | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| for data_tx in block_transactions.all_data_txs() { | ||
| if let Err(err) = self | ||
| .mempool | ||
| .handle_data_transaction_ingress_gossip(data_tx.clone()) | ||
| .await | ||
| { | ||
| if !matches!(err, TxIngressError::Skipped) { | ||
| warn!( | ||
| "Block pool: Failed to insert data tx {} into mempool for block {:?}: {:?}", | ||
| data_tx.id, current_block_hash, err | ||
| ); | ||
| } | ||
| // Cache data roots before validation (needed for publish tx ingress proof validation). | ||
| // Full tx ingestion happens after validation via BlockTransactionsValidated. | ||
| for data_tx in block_transactions.get_ledger_txs(DataLedger::Submit) { | ||
| if let Err(e) = self.db.update(|db_tx| { | ||
| irys_database::cache_data_root(db_tx, data_tx, Some(&block_header))?; | ||
| Ok::<_, eyre::Report>(()) | ||
| }) { | ||
| warn!("Failed to cache data_root for tx {}: {:?}", data_tx.id, e); | ||
| } | ||
| } | ||
|
Comment on lines
+824
to
833
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find the cache_data_root function definition and its signature
ast-grep --pattern 'fn cache_data_root($$$) { $$$ }'Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Search for how publish transaction validation depends on cached data roots
rg "cache_data_root|publish.*ingress.*proof" -A 5 -B 5Repository: Irys-xyz/irys Length of output: 28417 🏁 Script executed: # Check the irys_database module to understand cache_data_root
fd "irys_database" -t f | head -20Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Read the cache_data_root function implementation
sed -n '1,100p' crates/database/src/database.rs | grep -A 50 "fn cache_data_root"Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Get more context around cache_data_root implementation
sed -n '1,500p' crates/database/src/database.rs | tail -100Repository: Irys-xyz/irys Length of output: 2802 🏁 Script executed: # Search for how publish tx validation uses cached data roots
rg "cache_data_root|CachedDataRoots" -A 3 -B 3 crates/actors/src/block_validation.rsRepository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Look for publish transaction ingress proof validation logic
rg "ingress.*proof.*validat|publish.*ledger" -i crates/actors/src/block_validation.rs | head -20Repository: Irys-xyz/irys Length of output: 1471 🏁 Script executed: # Find where store_ingress_proof_checked and store_external_ingress_proof_checked are called
rg "store_ingress_proof_checked|store_external_ingress_proof_checked" -B 3 -A 3Repository: Irys-xyz/irys Length of output: 3910 🏁 Script executed: # Get the full cache_data_root implementation from database.rs
rg -A 30 "pub fn cache_data_root" crates/database/src/database.rsRepository: Irys-xyz/irys Length of output: 1299 🏁 Script executed: # Check what errors cache_data_root can return and under what conditions
rg "cache_data_root" -B 5 -A 10 crates/database/src/database.rs | head -80Repository: Irys-xyz/irys Length of output: 618 🏁 Script executed: # Check the sequence of operations in block_pool.rs around the cache_data_root call
sed -n '800,850p' crates/p2p/src/block_pool.rsRepository: Irys-xyz/irys Length of output: 2112 🏁 Script executed: # Check where store_ingress_proof_checked gets called in block validation/discovery flow
rg "store_ingress_proof|store_external_ingress_proof" -B 5 crates/actors/src/block_discovery.rs crates/actors/src/block_validation.rs 2>/dev/null | head -40Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Check what happens during publish transaction processing in block discovery
sed -n '1,100p' crates/actors/src/block_discovery.rsRepository: Irys-xyz/irys Length of output: 3636 🏁 Script executed: # Search for the full cache_data_root implementation to see all possible error cases
rg -A 50 "pub fn cache_data_root" crates/database/src/database.rs | head -80Repository: Irys-xyz/irys Length of output: 2009 🏁 Script executed: # Find where ingress proofs are stored during block validation/processing
rg "store_ingress_proof|store_external_ingress_proof" -B 10 crates/actors/src/block_validation.rs crates/actors/src/block_discovery.rs | head -100Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Check how publish ledger validation processes ingress proofs
rg -A 20 "validate_publish_ledger|PublishLedger" crates/actors/src/block_validation.rs | head -80Repository: Irys-xyz/irys Length of output: 3578 🏁 Script executed: # Search for where ingress proofs are being written to the database during block processing
rg "IngressProofs|store.*proof" crates/actors/src/block_validation.rs crates/actors/src/block_discovery.rsRepository: Irys-xyz/irys Length of output: 471 🏁 Script executed: # Look at the full block validation flow - where ingress proofs are stored
rg "BlockTransactionsValidated|BlockValidated" -A 10 crates/actors/src/mempool_service/lifecycle.rs | head -60Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Search for where publish transaction proofs are processed in block discovery
rg -A 30 "process.*publish|handle_block" crates/actors/src/block_discovery.rs | head -80Repository: Irys-xyz/irys Length of output: 1622 🏁 Script executed: # Check the block handler flow that uses cached data roots
rg "cached_data_root_by_data_root" -B 5 -A 10Repository: Irys-xyz/irys Length of output: 17469 🏁 Script executed: # Look at what happens after BlockTransactionsValidated - where proofs are stored
rg "BlockTransactionsValidated" -A 20 crates/actors/src/mempool_service/lifecycle.rsRepository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Find the exact panic location in block_validation.rs where cached_data_root is accessed
rg -B 5 -A 15 'panic.*CachedDataRoot should be found' crates/actors/src/block_validation.rsRepository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Check if there are other places in block validation that assume cached data roots exist
rg 'cached_data_root_by_data_root' -A 5 crates/actors/src/block_validation.rs | head -60Repository: Irys-xyz/irys Length of output: 654 🏁 Script executed: # Search for all callers of store_ingress_proof_checked to see how failures are handled
rg 'store_ingress_proof_checked|store_external_ingress_proof_checked' -B 2 -A 5 | grep -A 5 "block.*validat"Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Confirm the full context of the panic and when it's triggered
sed -n '550,620p' crates/actors/src/block_validation.rsRepository: Irys-xyz/irys Length of output: 2628 🏁 Script executed: # Check how often this validation path is executed (is it critical path?)
rg "validate_ingress_proof|validate_publish_ledger" -B 3 -A 10 crates/actors/src/block_validation.rs | head -80Repository: Irys-xyz/irys Length of output: 39 🏁 Script executed: # Find the exact validation function that uses cached_data_root and panics if missing
rg -B 10 -A 30 "CachedDataRoot should be found" crates/actors/src/block_validation.rsRepository: Irys-xyz/irys Length of output: 1817 🏁 Script executed: # Check where this validation is called in the block validation flow
rg "validate_ingress_proof_signer_uniqueness|validate.*publish" -A 20 crates/actors/src/block_validation.rs | head -100Repository: Irys-xyz/irys Length of output: 1843 Cache failures in block processing can cause validation panics downstream. The code silently continues after Rather than silent degradation followed by validation crashes, consider treating cache failures as fatal for the block processing step, or add explicit validation to catch missing cached data roots before they cause panics. |
||
|
|
||
|
|
||
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.
Looks good to me, the only thing is I don't entirely get why would be re-ingest those after the successful validation here - is it to account the transactions that made it to the mempool not from the gossip, but from the block body?
Uh oh!
There was an error while loading. Please reload this page.
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.
This is so that they can be propogated to other nodes