Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Remove assert for solver overlap (#119)
Browse files Browse the repository at this point in the history
This PR removes an assert which checked that solvers do only appear in
one of prod and barn. Instead, a warning is logged.

Even though in most cases a solver appearing in prod and barn is a sign
of invalid solver behavior, the rest of the code of this repo does not
depend on this assumption. Data is just concatenated and uploaded as is.

The [main rewards
query](https://github.com/cowprotocol/dune-queries/blob/main/cowprotocol/accounting/rewards/mainnet/mainnet_dashboard_query_2510345.sql)
on dune also does not depend on associating settlements to environments.
The environment is only added after aggregating payments
[here](https://github.com/cowprotocol/dune-queries/blob/6be6c1cfaa78b3dfc2ed65494c2cc0ef5c303889/cowprotocol/accounting/rewards/mainnet/mainnet_dashboard_query_2510345.sql#L118)
for easier digestion of the final table.
  • Loading branch information
fhenneke authored Oct 25, 2024
1 parent a35f5fb commit e3224ff
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/fetch/orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
from sqlalchemy import create_engine
from sqlalchemy.engine import Engine

from src.logger import set_log
from src.models.block_range import BlockRange
from src.utils import open_query

log = set_log(__name__)

MAX_PROCESSING_DELAY = 10


Expand Down Expand Up @@ -95,8 +98,13 @@ def get_order_rewards(cls, block_range: BlockRange) -> DataFrame:
cow_reward_query_prod, cow_reward_query_barn, data_types
)

# Solvers do not appear in both environments!
assert set(prod.solver).isdisjoint(set(barn.solver)), "solver overlap!"
# Warn if solver appear in both environments.
if not set(prod.solver).isdisjoint(set(barn.solver)):
log.warning(
f"solver overlap in {block_range}: solvers "
f"{set(prod.solver).intersection(set(barn.solver))} part of both prod and barn"
)

if not prod.empty and not barn.empty:
return pd.concat([prod, barn])
if not prod.empty:
Expand Down Expand Up @@ -142,8 +150,13 @@ def get_batch_rewards(cls, block_range: BlockRange) -> DataFrame:
cow_reward_query_prod, cow_reward_query_barn, data_types
)

# Solvers do not appear in both environments!
assert set(prod.solver).isdisjoint(set(barn.solver)), "solver overlap!"
# Warn if solver appear in both environments.
if not set(prod.solver).isdisjoint(set(barn.solver)):
log.warning(
f"solver overlap in {block_range}: solvers "
f"{set(prod.solver).intersection(set(barn.solver))} part of both prod and barn"
)

if not prod.empty and not barn.empty:
return pd.concat([prod, barn])
if not prod.empty:
Expand Down

0 comments on commit e3224ff

Please sign in to comment.