Skip to content

Commit

Permalink
test: revert to the last working version
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Apr 6, 2024
1 parent 4614ee1 commit 992097f
Show file tree
Hide file tree
Showing 41 changed files with 411 additions and 692 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ jobs:
secrets: inherit
with:
image-tag: ${{ github.sha }}
git-ref: ${{ github.ref }}

# +-------------------------
# | Tests: NodeJS
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
secrets: inherit
with:
image-tag: ${{ github.sha }}
git-ref: ${{ github.ref }}
run:
name: Run
uses: ./.github/workflows/tpl-start-env.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
secrets: inherit
with:
image-tag: ${{ needs.run.outputs.sha }}
git-ref: ${{ needs.run.outputs.ref }}

deploy:
name: Deploy
needs:
Expand Down
42 changes: 22 additions & 20 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,31 @@ on:
tags:
- v[0-9]+.[0-9]+.[0-9]+

env:
IMAGE_TAG: "${{ github.sha }}"
GIT_TAG: "${{ github.ref }}"

jobs:
run-deployment:
name: Run Deployment
build:
name: Build
uses: ./.github/workflows/tpl-images.yml
secrets: inherit
with:
image-tag: ${{ github.sha }}
output:
name: Output Variables
needs:
- build
runs-on:
- metal
steps:
- name: Sanitise variables
id: sanitise-vars
env:
IMAGE_TAG: "${{ github.ref }}"
GIT_REF: "${{ github.sha }}"
run: |
set -ex
echo "IMAGE_TAG=${IMAGE_TAG##*/}" >> $GITHUB_OUTPUT
echo "GIT_REF=${GIT_REF}" >> $GITHUB_OUTPUT
- name: Show variables for the CI pipeline
run : |
echo '================================'
echo ' Use the following variables'
echo ''
echo "CI_PIPELINE_SOURCE: pipeline"
echo "DEV_IMAGE_TAG: ${{ github.sha }}"
echo "PROD_IMAGE_TAG: ${GIT_TAG##*/}"
shell: bash

- name: Invoke octant-pipelines workflow
uses: benc-uk/workflow-dispatch@v1
with:
workflow: deploy-prod.yml
repo: golemfoundation/octant-pipelines
ref: master
inputs: '{"image_tag":"${{ steps.sanitise-vars.outputs.IMAGE_TAG }}","git_ref":"${{ steps.sanitise-vars.outputs.GIT_REF }}"}'
token: "${{ secrets.GH_BOT_TOKEN }}"
1 change: 0 additions & 1 deletion .github/workflows/deploy-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
secrets: inherit
with:
image-tag: ${{ github.sha }}
git-ref: ${{ github.ref }}
deploy:
name: Deploy
needs:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy-uat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
secrets: inherit
with:
image-tag: ${{ github.sha }}
git-ref: ${{ github.ref }}
run:
name: Run
uses: ./.github/workflows/tpl-start-env.yml
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/tpl-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
image-tag:
required: true
type: string
git-ref:
required: true
type: string
concurrency:
group: "${{ github.ref }}-images"
cancel-in-progress: true
Expand All @@ -34,8 +31,6 @@ jobs:
# account
# see: https://github.com/actions/checkout/issues/211
path: __local
ref: ${{ inputs.git-ref }}

- name: Login to Docker registry
uses: docker/login-action@v3
with:
Expand Down
16 changes: 4 additions & 12 deletions backend/app/infrastructure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs):
Resource.__init__(self, *args, *kwargs)

@classmethod
def canonize_address(cls, field_name: str, force=True):
def canonize_address(cls, field_name: str = "user_address", force=True):
def _add_address_canonization(handler):
def _decorated(*args, **kwargs):
field_value = kwargs.get(field_name)
Expand All @@ -36,22 +36,14 @@ def _decorated(*args, **kwargs):

return _add_address_canonization

@classmethod
def _default_address_canonizer(cls, attr):
user_address_canonizer = OctantResource.canonize_address(
field_name="user_address", force=False
)
proposal_address_canonizer = OctantResource.canonize_address(
field_name="proposal_address", force=False
)
return user_address_canonizer(proposal_address_canonizer(attr))

def __getattribute__(self, name):
user_address_canonizer = OctantResource.canonize_address(force=False)

attr = object.__getattribute__(self, name)

decorator = default_decorators.get(name)
if decorator is not None:
attr = OctantResource._default_address_canonizer(decorator(attr))
attr = user_address_canonizer(decorator(attr))

return attr

Expand Down
16 changes: 2 additions & 14 deletions backend/app/infrastructure/routes/allocations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import dataclasses

from flask import current_app as app
from flask import request
from flask_restx import Namespace, fields

from app.extensions import api
from app.infrastructure import OctantResource
from app.modules.common import parse_bool
from app.modules.user.allocations import controller

ns = Namespace("allocations", description="Octant allocations")
Expand Down Expand Up @@ -247,22 +245,12 @@ def post(self, user_address: str):
},
)
class EpochAllocations(OctantResource):
@ns.param(
"includeZeroAllocations",
description="Include zero allocations to projects. Defaults to false.",
_in="query",
)
@ns.marshal_with(epoch_allocations_model)
@ns.response(200, "Epoch allocations successfully retrieved")
def get(self, epoch: int):
include_zero_allocations = request.args.get(
"includeZeroAllocations", default=False, type=parse_bool
)
app.logger.debug(f"Getting latest allocations in epoch {epoch}")
allocs = controller.get_all_allocations(epoch, include_zero_allocations)
app.logger.debug(
f"Allocations for epoch {epoch} (with zero allocations: {include_zero_allocations}): {allocs}"
)
allocs = controller.get_all_allocations(epoch)
app.logger.debug(f"Allocations for epoch {epoch}: {allocs}")

return {"allocations": allocs}

Expand Down
29 changes: 13 additions & 16 deletions backend/app/infrastructure/routes/deposits.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from eth_utils import to_checksum_address
from flask import current_app as app
from flask_restx import Namespace, fields

Expand Down Expand Up @@ -91,48 +92,44 @@ def get(self, epoch):
return {"lockedRatio": locked_ratio}


@ns.route("/users/<string:user_address>/<int:epoch>")
@ns.route("/users/<string:address>/<int:epoch>")
@ns.doc(
description="Returns user's effective deposit for a finialized or pending epoch.",
params={
"epoch": "Epoch number",
"user_address": "User ethereum address in hexadecimal form (case-insensitive, prefixed with 0x)",
"address": "User ethereum address in hexadecimal form (case-insensitive, prefixed with 0x)",
},
)
class UserEffectiveDeposit(OctantResource):
@ns.marshal_with(user_effective_deposit_model)
@ns.response(200, "User effective deposit successfully retrieved")
def get(self, user_address: str, epoch: int):
app.logger.debug(
f"Getting user {user_address} effective deposit in epoch {epoch}"
)
result = get_user_effective_deposit(user_address, epoch)
app.logger.debug(
f"User {user_address} effective deposit in epoch {epoch}: {result}"
)
def get(self, address: str, epoch: int):
app.logger.debug(f"Getting user {address} effective deposit in epoch {epoch}")
result = get_user_effective_deposit(to_checksum_address(address), epoch)
app.logger.debug(f"User {address} effective deposit in epoch {epoch}: {result}")

return {
"effectiveDeposit": result,
}


@ns.route("/users/<string:user_address>/estimated_effective_deposit")
@ns.route("/users/<string:address>/estimated_effective_deposit")
@ns.doc(
description="Returns user's estimated effective deposit for the current epoch.",
params={
"user_address": "User ethereum address in hexadecimal form (case-insensitive, prefixed with 0x)",
"address": "User ethereum address in hexadecimal form (case-insensitive, prefixed with 0x)",
},
)
class UserEstimatedEffectiveDeposit(OctantResource):
@ns.marshal_with(user_effective_deposit_model)
@ns.response(200, "User estimated effective deposit successfully retrieved")
def get(self, user_address: str):
def get(self, address: str):
app.logger.debug(
f"Getting user {user_address} estimated effective deposit in the current epoch"
f"Getting user {address} estimated effective deposit in the current epoch"
)
result = estimate_user_effective_deposit(user_address)
result = estimate_user_effective_deposit(to_checksum_address(address))
app.logger.debug(
f"User {user_address} estimated effective deposit in the current epoch: {result}"
f"User {address} estimated effective deposit in the current epoch: {result}"
)

return {
Expand Down
8 changes: 5 additions & 3 deletions backend/app/infrastructure/routes/rewards.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from eth_utils import to_checksum_address
from flask import current_app as app
from flask_restx import Namespace, fields

Expand Down Expand Up @@ -190,9 +191,10 @@ class UserBudget(OctantResource):
@ns.marshal_with(user_budget_model)
@ns.response(200, "Budget successfully retrieved")
def get(self, user_address, epoch):
app.logger.debug(f"Getting user {user_address} budget in epoch {epoch}")
budget = get_budget(user_address, epoch)
app.logger.debug(f"User {user_address} budget in epoch {epoch}: {budget}")
checksum_address = to_checksum_address(user_address)
app.logger.debug(f"Getting user {checksum_address} budget in epoch {epoch}")
budget = get_budget(checksum_address, epoch)
app.logger.debug(f"User {checksum_address} budget in epoch {epoch}: {budget}")

return {"budget": budget}

Expand Down
4 changes: 4 additions & 0 deletions backend/app/infrastructure/routes/user.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from eth_utils import to_checksum_address
from flask import current_app as app, request
from flask_restx import Namespace, fields
from flask_restx import reqparse
Expand Down Expand Up @@ -125,6 +126,8 @@ class PatronMode(OctantResource):
@ns.marshal_with(user_patron_mode_status_model)
@ns.response(200, "User's patron mode status retrieved")
def get(self, user_address: str):
user_address = to_checksum_address(user_address)

app.logger.debug(f"Getting user {user_address} patron mode status")
patron_mode_status = user_controller.get_patron_mode_status(user_address)
app.logger.debug(
Expand All @@ -141,6 +144,7 @@ def get(self, user_address: str):
@ns.response(204, "User's patron mode status updated.")
@ns.response(400, "Could not update patron mode status.")
def patch(self, user_address: str):
user_address = to_checksum_address(user_address)
signature = ns.payload.get("signature")

app.logger.info(f"Updating user {user_address} patron mode status")
Expand Down
2 changes: 0 additions & 2 deletions backend/app/modules/common/__init__.py

This file was deleted.

13 changes: 2 additions & 11 deletions backend/app/modules/multisig_signatures/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from app.modules.dto import SignatureOpType
from app.modules.multisig_signatures.dto import Signature, ApprovedSignatureTypes
from app.modules.registry import get_services
from app.exceptions import InvalidEpoch


def get_last_pending_signature(
Expand Down Expand Up @@ -44,22 +43,14 @@ def apply_pending_allocation_signature(signature_id: int):


def _apply(op_type: SignatureOpType, signature_id):
try:
context = _get_context(op_type)
except InvalidEpoch:
return None

context = _get_context(op_type)
service = get_services(context.epoch_state).multisig_signatures_service

service.apply_staged_signatures(context, signature_id)


def _approve(op_type: SignatureOpType) -> list[Signature]:
try:
context = _get_context(op_type)
except InvalidEpoch:
return []

context = _get_context(op_type)
service = get_services(context.epoch_state).multisig_signatures_service

return service.approve_pending_signatures(context)
Expand Down
6 changes: 2 additions & 4 deletions backend/app/modules/user/allocations/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ def get_user_next_nonce(user_address: str) -> int:
return service.get_user_next_nonce(user_address)


def get_all_allocations(
epoch_num: int, include_zero_allocations=True
) -> List[ProposalDonationDTO]:
def get_all_allocations(epoch_num: int) -> List[ProposalDonationDTO]:
context = epoch_context(epoch_num)
if context.epoch_state > EpochState.PENDING:
raise NotImplementedForGivenEpochState()
service = get_services(context.epoch_state).user_allocations_service
return service.get_all_allocations(context, include_zero_allocations)
return service.get_all_allocations(context)


def get_all_donations_by_project(
Expand Down
5 changes: 1 addition & 4 deletions backend/app/modules/user/allocations/service/saved.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def get_user_allocations_by_timestamp(
)
]

def get_all_allocations(
self, context: Context, include_zero_allocations=True
) -> List[ProposalDonationDTO]:
def get_all_allocations(self, context: Context) -> List[ProposalDonationDTO]:
allocations = database.allocations.get_all(context.epoch_details.epoch_num)
return [
ProposalDonationDTO(
Expand All @@ -67,7 +65,6 @@ def get_all_allocations(
proposal=alloc.proposal_address,
)
for alloc in allocations
if include_zero_allocations or alloc.amount > 0
]

def get_allocations_by_project(
Expand Down
Loading

0 comments on commit 992097f

Please sign in to comment.