Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix solver competition reading (#3171)
# Description Fixes a bug where transaction hashes from different environment (prod/staging) are shown on solver competition endpoint. Example: https://api.cow.fi/mainnet/api/v1/solver_competition/9861815 Here, transaction `0xb608f1e2a644befda65a6a87ce6b93fc8a3441d9729b8ce4b2a2db02c1247e60` is from production enviroment and valid one, while `0xc85cd0ad8e3aac389836a71da9795bdd1bedce7b21da1950b48f93165c9f6be8` is from staging environment and mistakenly added to result. The reason why this happens is: 1. The solver competition with the same `auction_id` can be saved in both environments, regardless if the competition ended up with mined settlement (which is fine). 2. `settlement::Observer` saves the relationship <auction, settlement> even for settlements from another environment (this is a decision made long time ago, before refactoring, [reference code here](https://github.com/cowprotocol/services/blob/main/crates/autopilot/src/infra/persistence/mod.rs#L654-L660) ) But, what this PR introduces is leveraging the fact that, for settlement from another environment, there is no matching entry in `settlement_observations` table, [reference code here](https://github.com/cowprotocol/services/blob/main/crates/autopilot/src/infra/persistence/mod.rs#L682-L693). Note how the saving is executed only if the `settlement` exists, which if [false](https://github.com/cowprotocol/services/blob/main/crates/autopilot/src/domain/settlement/observer.rs#L90-L92) for settlements from another environment. # Changes <!-- List of detailed changes (how the change is accomplished) --> - [ ] Update reading functions for solver competition, to exclude transaction hashes for settlements from another environment. ## How to test Updated unit test. Existing e2e tests. Manually tested all updated functions on production database, works as expected.
- Loading branch information