Skip to content
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

[RELEASE] 0.13.0 #589

Merged
merged 43 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2f8c065
Merge branch 'master' into develop
aziolek Nov 14, 2024
c64c551
Merge branch 'master' into develop
aziolek Nov 14, 2024
80f7750
[CI/CD] Update uat.env contracts
housekeeper-bot Nov 18, 2024
6105fea
OCT-2177: Fixing multisig on patron mode toggle (#547)
adam-gf Nov 19, 2024
3d01d3d
OCT-2195: Add redis cache for localenv (#558)
kgarbacinski Nov 20, 2024
f663881
[CI/CD] Update uat.env contracts
housekeeper-bot Nov 26, 2024
05c3463
OCT-2055: Add caching for antisybil (#559)
kgarbacinski Nov 27, 2024
fad7242
OCT-2095: Improve test (#562)
kgarbacinski Nov 28, 2024
33675d5
OCT-1746: Add caching for GQL methods (#565)
kgarbacinski Nov 29, 2024
dbdc2be
OCT-2219: Allocations/ endpoints migration to FastAPI (#569)
adam-gf Dec 3, 2024
592e3fc
OCT-2240: Initial setup for FactoryBoy (#574)
kgarbacinski Dec 5, 2024
acd8aca
OCT-2251: Rewrite existing tests using Factory Boy (#576)
kgarbacinski Dec 6, 2024
a76985b
OCT-2246: Migrate logic for /epochs
kgarbacinski Dec 9, 2024
0ab8e34
[SYNC] master => develop (#578)
kgarbacinski Dec 9, 2024
7190bbd
Update Sablier's details for testnet (#580)
kgarbacinski Dec 9, 2024
e5176f8
[CI/CD] Update uat.env contracts
housekeeper-bot Dec 9, 2024
84cf834
cr: alignements
kgarbacinski Dec 10, 2024
99ee7d5
merge: with conflicts
aziolek Dec 10, 2024
7d5437d
merge: client conflicts resolved
aziolek Dec 10, 2024
285f603
wip: prepare base structure
kgarbacinski Dec 10, 2024
102d3d8
Resolve BE conflicts
kgarbacinski Dec 10, 2024
7a9168a
[SYNC] master => develop (#583)
aziolek Dec 11, 2024
534b1ed
OCT-2244: Add Unit Tests for /epochs
kgarbacinski Dec 11, 2024
122bbe9
OCT-2246: Migrate logic for /epochs (#579)
aziolek Dec 11, 2024
621bd47
Merge remote-tracking branch 'origin/develop' into kacper/tests/oct-2…
kgarbacinski Dec 11, 2024
84e7856
cr: self-review
kgarbacinski Dec 11, 2024
c8a8862
test: client E2E from master
aziolek Dec 11, 2024
2bacc77
OCT-2269: Fix bug for moving deposit from Sablier between epochs
kgarbacinski Dec 13, 2024
e1a2f5e
tests: alignement
kgarbacinski Dec 13, 2024
1ac31f1
refactor
kgarbacinski Dec 13, 2024
c987885
OCT-2269: Fix bug for moving deposit from Sablier between epochs (#588)
aziolek Dec 16, 2024
9125967
[CI/CD] Update uat.env contracts
housekeeper-bot Dec 16, 2024
cb701ad
Merge branch 'master' into develop
aziolek Dec 16, 2024
cf81b9e
[CI/CD] Update uat.env contracts
housekeeper-bot Dec 16, 2024
95cb606
Fixing the issue with variable names in schema objects for fast api
adam-gf Dec 16, 2024
01d3e3c
fk up
adam-gf Dec 16, 2024
0a7adad
Merge remote-tracking branch 'origin/quickfix-schema-format' into kac…
kgarbacinski Dec 17, 2024
09b6548
fix: change camel_case to snakeCase
kgarbacinski Dec 17, 2024
2c165ff
OCT-2244: Add unit tests for /epochs (#587)
aziolek Dec 17, 2024
fbe159b
[CI/CD] Update uat.env contracts
housekeeper-bot Dec 17, 2024
95d249f
OCT-2282: Lowering the db connection pool size & adding settings for …
adam-gf Dec 18, 2024
62e3b10
Merge branch 'master' into develop
aziolek Dec 19, 2024
579b2b7
Merge branch 'master' into develop
aziolek Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions backend/app/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,5 @@
"TrustedCitizen": 4.0,
}

SABLIER_SENDER_ADDRESS_SEPOLIA = "0x2417201ca5A11989bF3D0C116888ba866dab1090"
SABLIER_TOKEN_ADDRESS_SEPOLIA = (
"0x2e5221B0f855Be4ea5Cefffb8311EED0563B6e87" # native sETH
)
SABLIER_SENDER_ADDRESS_SEPOLIA = "0xf86fD85672683c220709B9ED80bAD7a51800206a"
SABLIER_TOKEN_ADDRESS_SEPOLIA = "0x71432dd1ae7db41706ee6a22148446087bdd0906"
7 changes: 1 addition & 6 deletions backend/app/modules/user/events_generator/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def unify_deposit_balances(events: List[DepositEvent]) -> List[DepositEvent]:
"""
Unify deposit balance for each event in the list of events. Events are expected to be sorted by timestamp.
The first event is always from Octant, but the first Sablier event may have a non-zero `deposit_before`, indicating a balance from the past.
The first event is taken from deposits, but it already includes deposit from Sablier from the past.

Returns:
List[DepositEvent]: A list of events with adjusted `deposit_before` and `deposit_after`.
Expand All @@ -17,12 +17,7 @@ def unify_deposit_balances(events: List[DepositEvent]) -> List[DepositEvent]:
acc_balance_sablier = 0
acc_balance_octant = events[0].deposit_before # balance from previous epoch

first_sablier_processed = False
for event in modified_events[1:]:
if event.source == DepositSource.SABLIER and not first_sablier_processed:
acc_balance_sablier = event.deposit_before
first_sablier_processed = True

combined_balance = acc_balance_sablier + acc_balance_octant
event.deposit_before = combined_balance

Expand Down
2 changes: 1 addition & 1 deletion backend/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ProdConfig(Config):
os.getenv("SQLALCHEMY_CONNECTION_POOL_SIZE", 10)
)
SQLALCHEMY_CONNECTION_POOL_MAX_OVERFLOW = int(
os.getenv("SQLALCHEMY_CONNECTION_POOL_MAX_OVERFLOW", 100)
os.getenv("SQLALCHEMY_CONNECTION_POOL_MAX_OVERFLOW", 0)
)
SQLALCHEMY_DATABASE_URI = os.getenv("DB_URI")
SQLALCHEMY_ENGINE_OPTIONS = {
Expand Down
955 changes: 507 additions & 448 deletions backend/poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ uvicorn = {extras = ["standard"], version = "^0.31.0"}
asyncpg = "^0.29.0"
uvloop = "^0.20.0"
python-socketio = "^5.11.4"
async-factory-boy = "^1.0.1"
dataclasses-json = "^0.6.7"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=1500,
deposit_before=500, # must be <= than the deposit_before from the first event
source=DepositSource.SABLIER,
),
],
Expand All @@ -79,7 +79,7 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=3000,
deposit_before=1500,
source=DepositSource.SABLIER,
),
],
Expand All @@ -99,7 +99,7 @@
type=EventType.LOCK,
timestamp=1,
amount=1000,
deposit_before=2000,
deposit_before=1000,
source=DepositSource.SABLIER,
),
DepositEvent(
Expand All @@ -108,7 +108,6 @@
timestamp=2,
amount=500,
deposit_before=1000,
# Takes the balance from the previous event from Octant, not Sablier
source=DepositSource.OCTANT,
),
],
Expand All @@ -125,15 +124,15 @@
type=EventType.LOCK,
timestamp=1,
amount=1000,
deposit_before=3000,
deposit_before=1000,
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.LOCK,
timestamp=2,
amount=500,
deposit_before=4000,
deposit_before=2000,
source=DepositSource.OCTANT,
),
],
Expand Down Expand Up @@ -162,16 +161,15 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=1000,
deposit_before=500, # must be <= than the deposit_before from the first event
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.UNLOCK,
timestamp=3,
amount=400,
deposit_before=2000,
# Takes the balance from the previous event from Sablier, not Octant
deposit_before=1500,
source=DepositSource.SABLIER,
),
DepositEvent(
Expand All @@ -180,7 +178,6 @@
timestamp=4,
amount=200,
deposit_before=1500,
# Takes the balance from the previous event from Octant, not Sablier
source=DepositSource.OCTANT,
),
],
Expand All @@ -206,23 +203,23 @@
type=EventType.LOCK,
timestamp=2,
amount=1000,
deposit_before=2000,
deposit_before=1000,
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.UNLOCK,
timestamp=3,
amount=400,
deposit_before=3000,
deposit_before=2000,
source=DepositSource.SABLIER,
),
DepositEvent(
user="0x123",
type=EventType.LOCK,
timestamp=4,
amount=200,
deposit_before=2600,
deposit_before=1600,
source=DepositSource.OCTANT,
),
],
Expand Down
Empty file added backend/tests/v2/__init__.py
Empty file.
38 changes: 17 additions & 21 deletions backend/tests/v2/allocations/test_get_allocations_for_epoch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest
from fastapi import status
from httpx import AsyncClient
from sqlalchemy.ext.asyncio import AsyncSession

from fastapi import status
from tests.v2.utils import FakeUser, FakeAllocation
from tests.v2.factories import FactoriesAggregator

"""Test cases for the GET /allocations/epoch/{epoch_number} endpoint"""

Expand All @@ -22,24 +22,22 @@ async def test_returns_empty_list_when_no_allocations(

@pytest.mark.asyncio
async def test_returns_allocations_when_they_exist(
fast_client: AsyncClient, fast_session: AsyncSession
fast_client: AsyncClient, factories: FactoriesAggregator
):
"""Should return allocations when they exist"""

# Given: donors with allocations
alice = await FakeUser.GetAlice(fast_session)
a_alloc1 = await FakeAllocation.of_(fast_session, alice, 1)
a_alloc2 = await FakeAllocation.of_(fast_session, alice, 2)
a_alloc3 = await FakeAllocation.of_(fast_session, alice, 3)
alice = await factories.users.get_or_create_alice()
a_alloc1 = await factories.allocations.create(user=alice, epoch=1)
a_alloc2 = await factories.allocations.create(user=alice, epoch=2)
a_alloc3 = await factories.allocations.create(user=alice, epoch=3)

bob = await FakeUser.GetBob(fast_session)
b_alloc1 = await FakeAllocation.of_(fast_session, bob, 1)
b_alloc2 = await FakeAllocation.of_(fast_session, bob, 2)
bob = await factories.users.get_or_create_bob()
b_alloc1 = await factories.allocations.create(user=bob, epoch=1)
b_alloc2 = await factories.allocations.create(user=bob, epoch=2)

charlie = await FakeUser.GetCharlie(fast_session)
c_alloc1 = await FakeAllocation.of_(fast_session, charlie, 1)

await fast_session.commit()
charlie = await factories.users.get_or_create_charlie()
c_alloc1 = await factories.allocations.create(user=charlie, epoch=1)

async with fast_client as client:
# Allocations for epoch 1
Expand Down Expand Up @@ -104,20 +102,18 @@ async def test_returns_allocations_when_they_exist(

@pytest.mark.asyncio
async def test_returns_zero_allocations_when_include_zero_allocations_is_true(
fast_client: AsyncClient, fast_session: AsyncSession
fast_client: AsyncClient, factories: FactoriesAggregator
):
"""Should return zero allocations when include_zero_allocations is true"""

# Given: a donor with allocations
alice = await FakeUser.GetAlice(fast_session)
alice = await factories.users.get_or_create_alice()
# For testing purposes, we set the amount to 0 of one of the allocations
a_alloc1 = await FakeAllocation.of_(fast_session, alice, 1, amount=0)
a_alloc2 = await FakeAllocation.of_(
fast_session, alice, 1
a_alloc1 = await factories.allocations.create(alice, epoch=1, amount=0)
a_alloc2 = await factories.allocations.create(
alice, epoch=1
) # This will have random amount

await fast_session.commit()

async with fast_client as client:
resp = await client.get(
"allocations/epoch/1", params={"includeZeroAllocations": True}
Expand Down
55 changes: 25 additions & 30 deletions backend/tests/v2/allocations/test_get_donors_for_epoch.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from datetime import datetime

import pytest
from fastapi import status
from httpx import AsyncClient
from sqlalchemy.ext.asyncio import AsyncSession

from fastapi import status
from tests.v2.utils import FakeUser, FakeAllocation
from tests.v2.factories import FactoriesAggregator

"""Test cases for the GET /allocations/donors/{epoch_number} (get_donors_for_epoch_v1) endpoint"""


@pytest.mark.asyncio
async def test_returns_empty_list_when_no_donors(
fast_client: AsyncClient, fast_session: AsyncSession
fast_client: AsyncClient, fast_session: AsyncClient
):
"""Should return an empty list when there are no donors for the epoch"""

Expand All @@ -26,24 +27,22 @@ async def test_returns_empty_list_when_no_donors(

@pytest.mark.asyncio
async def test_returns_donors_when_they_exist(
fast_client: AsyncClient, fast_session: AsyncSession
fast_client: AsyncClient, factories: FactoriesAggregator
):
"""Should return a list of donors when they exist"""

# Given: a donor
alice = await FakeUser.GetAlice(fast_session)
await FakeAllocation.of_(fast_session, alice, 1)
await FakeAllocation.of_(fast_session, alice, 2)
await FakeAllocation.of_(fast_session, alice, 3)
# Given: donors with allocations
alice = await factories.users.get_or_create_alice()
await factories.allocations.create(user=alice, epoch=1)
await factories.allocations.create(user=alice, epoch=2)
await factories.allocations.create(user=alice, epoch=3)

bob = await FakeUser.GetBob(fast_session)
await FakeAllocation.of_(fast_session, bob, 1)
await FakeAllocation.of_(fast_session, bob, 2)
bob = await factories.users.get_or_create_bob()
await factories.allocations.create(user=bob, epoch=1)
await factories.allocations.create(user=bob, epoch=2)

charlie = await FakeUser.GetCharlie(fast_session)
await FakeAllocation.of_(fast_session, charlie, 1)

await fast_session.commit()
charlie = await factories.users.get_or_create_charlie()
await factories.allocations.create(user=charlie, epoch=1)

async with fast_client as client:
# A, B, C are donors for epoch 1
Expand All @@ -69,17 +68,15 @@ async def test_returns_donors_when_they_exist(

@pytest.mark.asyncio
async def test_returns_unique_donors(
fast_client: AsyncClient, fast_session: AsyncSession
fast_client: AsyncClient, factories: FactoriesAggregator
):
"""Should return unique donors"""

# Given: a donor with allocation for 3 projects in the same epoch
alice = await FakeUser.GetAlice(fast_session)
await FakeAllocation.of_(fast_session, alice, 1)
await FakeAllocation.of_(fast_session, alice, 1)
await FakeAllocation.of_(fast_session, alice, 1)

await fast_session.commit()
alice = await factories.users.get_or_create_alice()
await factories.allocations.create(user=alice, epoch=1)
await factories.allocations.create(user=alice, epoch=1)
await factories.allocations.create(user=alice, epoch=1)

async with fast_client as client:
resp = await client.get("allocations/donors/1")
Expand All @@ -89,17 +86,15 @@ async def test_returns_unique_donors(

@pytest.mark.asyncio
async def test_removed_allocations_are_not_included(
fast_client: AsyncClient, fast_session: AsyncSession
fast_client: AsyncClient, fast_session: AsyncSession, factories: FactoriesAggregator
):
"""Should not include removed allocations"""

# Given: a donor with allocation for 3 projects in the same epoch
alice = await FakeUser.GetAlice(fast_session)
alloc1 = await FakeAllocation.of_(fast_session, alice, 1)
alloc2 = await FakeAllocation.of_(fast_session, alice, 1)
alloc3 = await FakeAllocation.of_(fast_session, alice, 1)

await fast_session.commit()
alice = await factories.users.get_or_create_alice()
alloc1 = await factories.allocations.create(user=alice, epoch=1)
alloc2 = await factories.allocations.create(user=alice, epoch=1)
alloc3 = await factories.allocations.create(user=alice, epoch=1)

async with fast_client as client:
resp = await client.get("allocations/donors/1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
from httpx import AsyncClient
from sqlalchemy.ext.asyncio import AsyncSession

from fastapi import status
from tests.v2.utils import FakeUser, FakeAllocation
from httpx import AsyncClient
from sqlalchemy.ext.asyncio import AsyncSession

from tests.v2.factories import FactoriesAggregator

"""Test cases for the GET /allocations/projects/{project_address}/epoch/{epoch_number} endpoint"""

Expand All @@ -25,20 +25,25 @@ async def test_returns_empty_list_when_no_allocations(

@pytest.mark.asyncio
async def test_returns_allocations_when_they_exist(
fast_client: AsyncClient, fast_session: AsyncSession
fast_client: AsyncClient, factories: FactoriesAggregator
):
"""Should return allocations when they exist"""

# Given: allocations for a project
project_address = "0x433485B5951f250cEFDCbf197Cb0F60fdBE55513"
alice = await FakeUser.GetAlice(fast_session)
a_alloc1 = await FakeAllocation.of_(fast_session, alice, 1, project_address)
a_alloc2 = await FakeAllocation.of_(fast_session, alice, 2, project_address)

bob = await FakeUser.GetBob(fast_session)
b_alloc1 = await FakeAllocation.of_(fast_session, bob, 1, project_address)
alice = await factories.users.get_or_create_alice()
a_alloc1 = await factories.allocations.create(
user=alice, epoch=1, project_address=project_address
)
a_alloc2 = await factories.allocations.create(
user=alice, epoch=2, project_address=project_address
)

await fast_session.commit()
bob = await factories.users.get_or_create_bob()
b_alloc1 = await factories.allocations.create(
user=bob, epoch=1, project_address=project_address
)

async with fast_client as client:
resp = await client.get(f"allocations/project/{project_address}/epoch/1")
Expand Down
Loading
Loading