AmbireTech / adex-market

AdEx Market: a scraper that aggregates ad campaign information from the validator network
7 stars 6 forks source link

GET /units-for-slot/{slotId}: the "supermarket" #101

Closed Ivshti closed 3 years ago

Ivshti commented 4 years ago

Problem

There's a few things about the current market that can be easily optimized/improved:

Solution

A new route that allows to get all units matching a certain ad slot. We will build it as a separate component called the "supermarket" and we'll run it separately, and route on a NGINX level

This gives us 2 advantages:

Functionality:

Tech design

The supermarket will function in-memory, without a database. It will pull all data it needs from the validators.

Recommendations for internal data structures:

That way only active (non-finalized) campaigns are kept in memory and updated, and once a campaign becomes inactive (which is irreversible), it will be flagged in finalized. Note that unsound (Unhealthy, Invalid, etc.) campaigns are not finalized - only Exhausted/Closed/Withdraw/Expired are finalized.

On start-up and every few minutes, we will get all known campaigns from a configurable list of validators. Every few seconds (10-20), we will update our active campaigns from the validators (update their latest balance tree/messages/status).

Ad slots can be retrieved from the market on demand without a cache: this means every request to /unit-for-slot will first request the slot from the market. The market endpoint will be configurable. Later on, we can cache that too if needed.

Applying earning limits

There are a few concepts of earning limits within AdEx: the limits recommended by the Market per slot. Those are based on the Alexa rank of the website in question and may include quick account limits too in the future.

We cannot apply earning limits because we can't compute all lifetime earnings because we drop finalized campaigns from memory (also, we only crawl active ones from validators). But the Market can apply limits at an ad slot level, by sneaking in { onlyShowIf: false } within adSlot.rules.

Prerequisites

https://github.com/AdExNetwork/aips/issues/31 and it's matching engine - although that's mostly implemented

Ivshti commented 3 years ago

This was done a while back, the issue was kept open because of the third point but that's now in #170