fix(eth): process contract logs one block at a time#904
fix(eth): process contract logs one block at a time#904diegomrsantos wants to merge 20 commits intosigp:unstablefrom
Conversation
| .operator_exists_tx(*operator_id, tx) | ||
| .map_err(|e| ExecutionError::Database(e.to_string()))?; | ||
| if !exists { | ||
| return Err(ExecutionError::Database(format!( |
There was a problem hiding this comment.
This returns ExecutionError::Database but the query succeeded — the operator just isn't registered. Same pattern at event_processor.rs:573 (missing validator metadata) and event_processor.rs:591 (missing cluster). All three should be InvalidEvent.
Pre-existing and harmless today since all errors skip-and-continue, but #351 makes
Database→AbortBatch— these would become sync-stalling errors on legitimate "data not yet present" conditions. Worth reclassifying in either this PR or #351 before #351 merges.
There was a problem hiding this comment.
I agree the ambiguity is real, but I don’t think #904 should change that classification. In these paths we cannot actually prove whether the event is invalid or local committed state is unexpectedly missing data, so reclassifying to InvalidEvent here would be a behavior change, not just cleanup. That risk existed before this PR; #904 is only changing the block-scoped processing boundary, so I’d rather keep the existing semantics here and handle the classification question separately.
| })?; | ||
|
|
||
| // Get the fee recipient if one has been stored, otherwise default to the owner address | ||
| let fee_recipient = match self.db.fee_recipient_for_owner(&owner, tx) { |
There was a problem hiding this comment.
nit (pre-existing): The _ arm conflates Ok(None) (no custom fee recipient — legitimate) with Err(...) (DB failure). Splitting into explicit arms with a warn! on the error path would make DB failures observable without blocking validator registration. Low probability but free insurance on a financial-correctness path.
There was a problem hiding this comment.
I agree this would be a cleaner shape, but I’m leaving it out of #904.
This _ arm is pre-existing from unstable, and changing it here would be a small behavior/logging change on the validator-add path rather than part of the block-boundary work in this PR. If we touch it separately, I agree the better version is to split Ok(None) from Err(...) and log the DB-failure path explicitly.
anchor/eth/tests/integration.rs
Outdated
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_database_transaction_rollback_on_error() { |
There was a problem hiding this comment.
The test does NOT test rollback — it tests that a valid event commits while a malformed event is skipped. With per-block transactions, the old "entire batch rolls back on error" behavior no longer exists. The test name is actively misleading.
Recommendation: Rename to test_malformed_events_skipped_without_affecting_valid_events.
i know this was untouched as part of this pr, but easy fix either here or new gh issue, whichever you think
There was a problem hiding this comment.
Fixed in f1d4f592f.
I renamed it to test_malformed_events_skipped_without_affecting_valid_events and added a short doc comment making the preserved semantics explicit. This was a pre-existing test name on unstable; #904 just made the old name more misleading.
Problem, Evidence, and Context (Required)
NetworkStateis published.#885is being replaced by a smaller reviewed stack, and PR#898already prepared the database layer for this boundary change.event_processorpreviously mixed tx writes with in-memory reads, which breaks same-block flows once publication is deferred. This PR adds focused same-block integration coverage forOperatorAdded+ValidatorAddedandValidatorAdded+ValidatorRemoved.#880,#898, replacement for the behavior-fix portion of#885.Change Overview (Required)
event_processor, with one SQLite transaction per block.self.db.state().NetworkStateand trigger index-sync / exit side effects only after the block transaction commits.NetworkStateconsumers outside this boundary.Risks, Trade-offs, and Mitigations (Required)
event_processor, the small set of tx-scoped reads it needs, and targeted integration coverage.Validation (Required)
cargo check -p ethcargo fmt --all --checkcargo clippy -p database -p eth --all-targets -- -D warningscargo test -p eth --testsRollback (Required for behavior or runtime changes; optional otherwise)
#898if needed.Blockers / Dependencies (Optional)
#898.Additional Info / Next Steps (Optional)