Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/golemfoundation/octant i…
Browse files Browse the repository at this point in the history
…nto leon/OCT-1522/fix-multisig-signatures
  • Loading branch information
leoni-q committed Apr 8, 2024
2 parents 8e0731c + 2089aa1 commit 7a1dd68
Show file tree
Hide file tree
Showing 19 changed files with 598 additions and 66 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ jobs:
network-name: local
chain-name: localhost
snapshotter-enabled: false
multisigger-enabled: false
scheduler-enabled: true
glm-claim-enabled: true
vault-confirm-withdrawals-enabled: true
Expand All @@ -212,6 +213,8 @@ jobs:
chain-id: 1337
network-name: local
chain-name: localhost
snapshotter-enabled: false
multisigger-enabled: false
web-client-replicas: 0
coin-prices-server-replicas: 0
backend-server-replicas: 0
Expand Down
43 changes: 20 additions & 23 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,29 @@ on:
tags:
- v[0-9]+.[0-9]+.[0-9]+

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

jobs:
build:
name: Build
uses: ./.github/workflows/tpl-images.yml
secrets: inherit
with:
image-tag: ${{ github.sha }}
git-ref: ${{ github.ref }}
output:
name: Output Variables
needs:
- build
run-deployment:
name: Run Deployment
runs-on:
- metal
steps:
- 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##*/}"
- 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
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 }}"
5 changes: 5 additions & 0 deletions .github/workflows/tpl-deploy-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ on:
required: false
default: false
type: boolean
multisigger-enabled:
required: false
default: true
type: boolean
scheduler-enabled:
required: false
default: false
Expand Down Expand Up @@ -114,6 +118,7 @@ env:
CHAIN_NAME: ${{ inputs.chain-name }}
OCTANT_BACKEND_SECRET_KEY: some-random-key
SNAPSHOTTER_ENABLED: ${{ inputs.snapshotter-enabled }}
MULTISIGGER_ENABLED: ${{ inputs.multisigger-enabled }}
SCHEDULER_ENABLED: ${{ inputs.scheduler-enabled }}
GLM_CLAIM_ENABLED: ${{ inputs.glm-claim-enabled }}
VAULT_CONFIRM_WITHDRAWALS_ENABLED: ${{ inputs.vault-confirm-withdrawals-enabled }}
Expand Down
16 changes: 12 additions & 4 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 = "user_address", force=True):
def canonize_address(cls, field_name: str, force=True):
def _add_address_canonization(handler):
def _decorated(*args, **kwargs):
field_value = kwargs.get(field_name)
Expand All @@ -36,14 +36,22 @@ def _decorated(*args, **kwargs):

return _add_address_canonization

def __getattribute__(self, name):
user_address_canonizer = OctantResource.canonize_address(force=False)
@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):
attr = object.__getattribute__(self, name)

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

return attr

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

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


@ns.route("/users/<string:address>/<int:epoch>")
@ns.route("/users/<string:user_address>/<int:epoch>")
@ns.doc(
description="Returns user's effective deposit for a finialized or pending epoch.",
params={
"epoch": "Epoch number",
"address": "User ethereum address in hexadecimal form (case-insensitive, prefixed with 0x)",
"user_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, 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}")
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}"
)

return {
"effectiveDeposit": result,
}


@ns.route("/users/<string:address>/estimated_effective_deposit")
@ns.route("/users/<string:user_address>/estimated_effective_deposit")
@ns.doc(
description="Returns user's estimated effective deposit for the current epoch.",
params={
"address": "User ethereum address in hexadecimal form (case-insensitive, prefixed with 0x)",
"user_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, address: str):
def get(self, user_address: str):
app.logger.debug(
f"Getting user {address} estimated effective deposit in the current epoch"
f"Getting user {user_address} estimated effective deposit in the current epoch"
)
result = estimate_user_effective_deposit(to_checksum_address(address))
result = estimate_user_effective_deposit(user_address)
app.logger.debug(
f"User {address} estimated effective deposit in the current epoch: {result}"
f"User {user_address} estimated effective deposit in the current epoch: {result}"
)

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

Expand Down Expand Up @@ -191,10 +190,9 @@ class UserBudget(OctantResource):
@ns.marshal_with(user_budget_model)
@ns.response(200, "Budget successfully retrieved")
def get(self, user_address, epoch):
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}")
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}")

return {"budget": budget}

Expand Down
4 changes: 0 additions & 4 deletions backend/app/infrastructure/routes/user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
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 @@ -126,8 +125,6 @@ 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 @@ -144,7 +141,6 @@ 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
4 changes: 3 additions & 1 deletion ci/argocd/templates/octant-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
namespace: $DEPLOYMENT_ID
sources:
- repoURL: 'https://gitlab.com/api/v4/projects/48137258/packages/helm/devel'
targetRevision: 0.2.41
targetRevision: 0.2.44
chart: octant
helm:
parameters:
Expand Down Expand Up @@ -60,6 +60,8 @@ spec:
value: '$GLM_CLAIM_ENABLED'
- name: 'backendServer.snapshotter.enabled'
value: '$SNAPSHOTTER_ENABLED'
- name: 'backendServer.multisigger.enabled'
value: '$MULTISIGGER_ENABLED'
- name: 'backendServer.rpcUrl'
value: '$BACKEND_RPC_URL'
# Hardcoded in this file
Expand Down
Loading

0 comments on commit 7a1dd68

Please sign in to comment.