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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cr: alignements
kgarbacinski committed Dec 10, 2024
commit 84cf8346a675e127413238a05aa1bc85f8e10925
8 changes: 8 additions & 0 deletions backend/v2/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -7,3 +7,11 @@ class AllocationWindowClosed(OctantException):

def __init__(self):
super().__init__(self.description, self.code)


class EpochsNotFound(OctantException):
code = 404
description = "Epochs not found in Subgraph"

def __init__(self):
super().__init__(self.description, self.code)
10 changes: 6 additions & 4 deletions backend/v2/epochs/dependencies.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

from fastapi import Depends

from app.exceptions import InvalidEpoch
from app.modules.staking.proceeds.core import ESTIMATED_STAKING_REWARDS_RATE
from v2.core.dependencies import OctantSettings, Web3
from v2.core.exceptions import AllocationWindowClosed
@@ -61,14 +62,15 @@ async def get_current_epoch(epochs_contracts: GetEpochsContracts) -> int:


async def get_indexed_epoch(epochs_subgraph: GetEpochsSubgraph) -> int:
sg_epochs = await epochs_subgraph.get_epochs()
sg_epochs_sorted = sorted(sg_epochs, key=lambda d: d.epoch_num)

return sg_epochs_sorted[-1].epoch_num
latest_epoch = await epochs_subgraph.get_latest_epoch()
return latest_epoch.epoch_num


async def get_rewards_rate(epoch_number: int) -> float:
logging.debug(f"Getting rewards rate for epoch {epoch_number}")
if epoch_number <= 0:
raise InvalidEpoch()

return ESTIMATED_STAKING_REWARDS_RATE


48 changes: 25 additions & 23 deletions backend/v2/epochs/router.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
from fastapi import APIRouter

from v2.epochs.dependencies import (
GetEpochsContracts,
GetCurrentEpoch,
GetIndexedEpoch,
GetRewardsRate,
)
from v2.epochs.schemas import (
CurrentEpochResponse,
IndexedEpochResponse,
EpochRewardsRateResponse,
CurrentEpochResponseV1,
IndexedEpochResponseV1,
EpochRewardsRateResponseV1,
)

api = APIRouter(prefix="/epochs", tags=["Epochs"])


@api.get("/current")
async def get_current_epoch_v1(
epochs_contract: GetEpochsContracts,
) -> CurrentEpochResponse:
current_epoch: GetCurrentEpoch,
) -> CurrentEpochResponseV1:
"""
Returns the current epoch number from the blockchain.

This endpoint queries the smart contract to get the current active epoch number.
The epoch number is used throughout the system to track allocation periods
and rewards distribution cycles.

Returns:
CurrentEpochResponse: Object containing the current epoch number
Args:
current_epoch (int): Injected dependency representing the current epoch number
retrieved from the blockchain.
"""
current_epoch = epochs_contract.get_current_epoch()
return CurrentEpochResponse(current_epoch=current_epoch)
return CurrentEpochResponseV1(current_epoch=current_epoch)


@api.get("/indexed")
async def get_indexed_epoch_v1(
current_epoch: GetCurrentEpoch, indexed_epoch: GetIndexedEpoch
) -> IndexedEpochResponse:
) -> IndexedEpochResponseV1:
"""
Returns the last indexed epoch number and current epoch number from the blockchain.

This endpoint provides information about the indexing status of epochs by returning both
the current epoch number and the last epoch that has been fully indexed in the system.
the current epoch number and the last epoch that has been fully indexed in the subgraph.
The indexed epoch will always be less than or equal to the current epoch.
If they differ, it means the subgraph is still being updated.

Returns:
IndexedEpochResponse: Object containing both the current epoch number and last indexed epoch number
Args:
current_epoch (int): Injected dependency representing the current epoch number
retrieved from the blockchain.
indexed_epoch (int): Injected dependency representing the last indexed epoch number
retrieved from the subgraph.
"""
return IndexedEpochResponse(
return IndexedEpochResponseV1(
current_epoch=current_epoch, indexed_epoch=indexed_epoch
)

@@ -68,18 +71,17 @@ async def get_indexed_epoch_v1(
@api.get("/rewards-rate/{epoch_number}")
async def get_epoch_rewards_rate_v1(
rewards_rate: GetRewardsRate,
) -> EpochRewardsRateResponse:
) -> EpochRewardsRateResponseV1:
"""
Returns the rewards rate for a specific epoch from the blockchain.

This endpoint queries the smart contract to get the rewards rate for the specified epoch number.
The rewards rate represents the percentage of rewards that will be distributed for that epoch,
and is used in calculating final reward amounts.
The rewards rate represents the percentage of rewards distributed for that epoch and is used
in calculating final reward amounts.

Args:
rewards_rate (float): The rewards rate retrieved from the blockchain via dependency injection

Returns:
EpochRewardsRateResponse: Object containing the rewards rate for the specified epoch
epoch_number (int): The epoch number in the blockchain to fetch rewards rate for.
rewards_rate (float): Injected dependency representing the rewards rate retrieved
from the blockchain.
"""
return EpochRewardsRateResponse(rewards_rate=rewards_rate)
return EpochRewardsRateResponseV1(rewards_rate=rewards_rate)
8 changes: 4 additions & 4 deletions backend/v2/epochs/schemas.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from pydantic import BaseModel


class CurrentEpochResponse(BaseModel):
class CurrentEpochResponseV1(BaseModel):
current_epoch: int


class IndexedEpochResponse(BaseModel):
class IndexedEpochResponseV1(BaseModel):
current_epoch: int
indexed_epoch: int


class EpochStatsResponse(BaseModel):
class EpochStatsResponseV1(BaseModel):
staking_proceeds: str
total_effective_deposit: str
total_rewards: str
@@ -25,5 +25,5 @@ class EpochStatsResponse(BaseModel):
donated_to_projects: str | None


class EpochRewardsRateResponse(BaseModel):
class EpochRewardsRateResponseV1(BaseModel):
rewards_rate: float
39 changes: 20 additions & 19 deletions backend/v2/epochs/subgraphs.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

import backoff
from app import exceptions
from v2.core.exceptions import EpochsNotFound
from app.context.epoch.details import EpochDetails
from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport
@@ -112,14 +113,14 @@ async def get_epoch_by_number(self, epoch_number: int) -> EpochDetails:
remaining_sec=0,
)

async def get_epochs(self) -> list[EpochDetails]:
"""Get all epochs from the subgraph."""
logging.debug("[Subgraph] Getting list of all epochs")
async def get_latest_epoch(self) -> EpochDetails:
"""Get latest epoch from the subgraph."""
logging.debug("[Subgraph] Getting latest epoch from subgraph.")

query = gql(
"""
query {
epoches(first: 1000) {
epoches(first: 1, orderBy: epoch, orderDirection: desc) {
epoch
fromTs
toTs
@@ -132,23 +133,23 @@ async def get_epochs(self) -> list[EpochDetails]:
}
}
}
"""
"""
)

data = await self.gql_client.execute_async(query)
response = await self.gql_client.execute_async(query)
data = response["epoches"]

logging.debug(f"[Subgraph] Received epochs: {data}")
if not data:
logging.warning("[Subgraph] No epochs included in the subgraph.")
raise EpochsNotFound()

epoches = data["epoches"]
epoches_details = []
for epoch in epoches:
epoch_detail = EpochDetails(
epoch_num=epoch["epoch"],
start=epoch["fromTs"],
duration=epoch["duration"],
decision_window=epoch["decisionWindow"],
remaining_sec=0,
)
epoches_details.append(epoch_detail)
logging.debug(f"[Subgraph] Received the latest epoch: {data}")

return epoches_details
epoch_details = data[0]
return EpochDetails(
epoch_num=epoch_details["epoch"],
start=epoch_details["fromTs"],
duration=epoch_details["duration"],
decision_window=epoch_details["decisionWindow"],
remaining_sec=0,
)