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.12.0 #557

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
5 changes: 5 additions & 0 deletions backend/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ MAINNET_PROPOSAL_CIDS=

SABLIER_MAINNET_SUBGRAPH_URL=
SABLIER_SEPOLIA_SUBGRAPH_URL=

CACHE_REDIS_HOST=
CACHE_REDIS_PORT=
CACHE_REDIS_PASSWORD=
CACHE_REDIS_DB=
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from http import HTTPStatus
import requests

import app as app_module
Expand All @@ -13,7 +14,8 @@ def get_message_details(message_hash: str, is_mainnet: bool) -> dict:
response.raise_for_status()
json_response = response.json()
except requests.exceptions.RequestException as e:
app_module.ExceptionHandler.print_stacktrace(e)
if response.status_code != HTTPStatus.NOT_FOUND:
app_module.ExceptionHandler.print_stacktrace(e)
raise ExternalApiException(e)

return json_response
Expand Down
10 changes: 8 additions & 2 deletions backend/app/legacy/crypto/eth_sign/patron_mode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from app.legacy.crypto.eth_sign.signature import verify_signed_message
from app.modules.common.crypto.signature import (
encode_for_signing,
EncodingStandardFor,
verify_signed_message,
)


def build_patron_mode_msg(user_address: str, toggle: bool) -> str:
Expand All @@ -9,4 +13,6 @@ def build_patron_mode_msg(user_address: str, toggle: bool) -> str:
def verify(user_address: str, toggle: bool, signature: str) -> bool:
msg_text = build_patron_mode_msg(user_address, toggle)

return verify_signed_message(user_address, msg_text, signature)
encoded_msg = encode_for_signing(EncodingStandardFor.TEXT, msg_text)

return verify_signed_message(user_address, encoded_msg, signature)
36 changes: 0 additions & 36 deletions backend/app/legacy/crypto/eth_sign/signature.py

This file was deleted.

13 changes: 2 additions & 11 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,18 +656,12 @@ def get_rewards_budget(self, address: str, epoch: int):

def get_user_rewards_in_upcoming_epoch(self, address: str):
rv = self._flask_client.get(f"/rewards/budget/{address}/upcoming")
current_app.logger.debug(
"get_user_rewards_in_upcoming_epoch :",
self._flask_client.get(f"/rewards/budget/{address}/upcoming").request,
)
current_app.logger.debug("get_user_rewards_in_upcoming_epoch :", rv.text)
return json.loads(rv.text)

def get_user_rewards_in_epoch(self, address: str, epoch: int):
rv = self._flask_client.get(f"/rewards/budget/{address}/epoch/{epoch}")
current_app.logger.debug(
"get_rewards_budget :",
self._flask_client.get(f"/rewards/budget/{address}/epoch/{epoch}").request,
)
current_app.logger.debug("get_rewards_budget :", rv.text)
return json.loads(rv.text)

def get_total_users_rewards_in_epoch(self, epoch):
Expand Down Expand Up @@ -1036,9 +1030,6 @@ def patch_vault(monkeypatch):

@pytest.fixture(scope="function")
def patch_is_contract(monkeypatch):
monkeypatch.setattr(
"app.legacy.crypto.eth_sign.signature.is_contract", MOCK_IS_CONTRACT
)
monkeypatch.setattr(
"app.modules.common.crypto.signature.is_contract", MOCK_IS_CONTRACT
)
Expand Down
14 changes: 7 additions & 7 deletions ci/argocd/contracts/uat.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BLOCK_NUMBER=6982586
BLOCK_NUMBER=7156082
GLM_CONTRACT_ADDRESS=0x71432DD1ae7DB41706ee6a22148446087BdD0906
AUTH_CONTRACT_ADDRESS=0xDBf4afCC7c4394C3679b0A9E53d736294D63C886
DEPOSITS_CONTRACT_ADDRESS=0x2524b5FA6Ae221a540A52744661277796aF36791
EPOCHS_CONTRACT_ADDRESS=0xC3E155B1b382F6766bA22f949D996EA10E342Cd3
PROPOSALS_CONTRACT_ADDRESS=0xF4ffF4D6061A44097222B1C2176627F84F7696C9
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0xcE997E5e2114dD32B89dA78802f29748EABfC9f5
VAULT_CONTRACT_ADDRESS=0x83aCd40D6f3fA6f8927A7ABc34a56DD58C2B518A
AUTH_CONTRACT_ADDRESS=0xC09CddcF90F5aF074D9670682c980345D04a5b07
DEPOSITS_CONTRACT_ADDRESS=0x53BF7aB7d5130c2f085990f32b3975fFC724123d
EPOCHS_CONTRACT_ADDRESS=0x983d3c467d46b85858b65C4Fa72394Cc96F04762
PROPOSALS_CONTRACT_ADDRESS=0xA9361e7258Ee22B006dCB90Bf2A06D0edACdF31F
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0x6013d2240B7Ff82D7781786273ec6B73CfB90d79
VAULT_CONTRACT_ADDRESS=0x0f9D1aba589792B3a12F8e8823581c257C237B52
11 changes: 11 additions & 0 deletions localenv/localenv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ services:
- octant


backend-redis:
image: redis:7
ports:
- '6379:6379'
networks:
- octant


backend:
image: octant/backend:latest
platform: linux/amd64
Expand All @@ -50,6 +58,9 @@ services:

SABLIER_SEPOLIA_SUBGRAPH_URL: "${SABLIER_SEPOLIA_SUBGRAPH_URL}"

CACHE_REDIS_HOST: backend-redis
CACHE_REDIS_PORT: 6379

depends_on:
- backend-postgres
- anvil
Expand Down
96 changes: 96 additions & 0 deletions raffle-weights/calc_weights.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import csv
import requests
from eth_utils import to_checksum_address

# Dictionary to store address -> totalPoints mapping
address_points = {}
# Dictionary to store address -> total allocation amount (in WEI)
address_allocations = {}
# Dictionary to store address -> total allocation amount (in ETH)
address_allocations_eth = {}
# Dictionary to store final total points
final_points = {}

WEI_TO_ETH = 1_000_000_000_000_000_000 # 1 ETH = 1,000,000,000,000,000,000 WEI
MAX_ETH = 0.1 # Maximum ETH cap

# Get list of donors for epoch 5
donors_response = requests.get('https://backend.mainnet.octant.app/flask/user/patrons/5')
donors = []
if donors_response.status_code == 200:
donors = [to_checksum_address(addr) for addr in donors_response.json().get('patrons', [])]

# Read the CSV file and convert addresses to checksum format
with open('raffle-weights/leaderboard-62254-33064.csv', mode='r') as csvfile:
reader = csv.DictReader(csvfile)
for row in list(reader):
original_address = row['address']
checksum_address = to_checksum_address(original_address)
total_points = int(row['totalPoints']) # Convert points to integer

# Print if totalPoints is 0
if total_points == 0:
print(f"Warning: Address {checksum_address} has 0 total points")

# Store in dictionary
address_points[checksum_address] = total_points

# Fetch allocations for the 5th epoch
epoch_num = 5
url = f"https://backend.mainnet.octant.app/flask/allocations/user/{checksum_address}/epoch/{epoch_num}"
response = requests.get(url)

# Initialize total allocation amount for this address
total_allocation = 0

if response.status_code == 200:
allocations = response.json().get('allocations', [])
if not allocations and checksum_address in donors:
# This is a donor with no allocations, get their budget
budget_url = f"https://backend.mainnet.octant.app/flask/rewards/budget/{checksum_address}/epoch/{epoch_num}"
budget_response = requests.get(budget_url)
if budget_response.status_code == 200:
total_allocation = int(budget_response.json().get('budget', 0))
# print(f"Donor found: {checksum_address} with budget: {total_allocation / WEI_TO_ETH:.4f} ETH")
else:
# Sum up all allocation amounts for this address
for allocation in allocations:
amount = int(allocation.get('amount', 0)) # amount in WEI
total_allocation += amount

# Store total allocation for this address (in WEI)
address_allocations[checksum_address] = total_allocation
# Store total allocation in ETH (capped at 0.1 ETH)
eth_amount = total_allocation / WEI_TO_ETH
capped_eth_amount = min(eth_amount, MAX_ETH)

# Print if amount was capped
if eth_amount > MAX_ETH:
print(f"Notice: Address {checksum_address} allocation capped from {eth_amount:.4f} ETH to {MAX_ETH} ETH")

address_allocations_eth[checksum_address] = capped_eth_amount

# Calculate final points
# total = total_points + (eth_value * 2000) if total_points > 0 and eth_value > 0
# total = 0 otherwise
if total_points > 0 and capped_eth_amount > 0:
final_total = total_points + (capped_eth_amount * 2000)
else:
final_total = 0

final_points[checksum_address] = final_total

print(f"Address: {checksum_address}, Weight: {final_total:.4f}, Points: {total_points}, Eth: {eth_amount:.4f}, Donor: {checksum_address in donors}")

# Write results to new CSV file (only non-zero weights)
output_file = 'raffle-weights/raffle_weights_output.csv'
with open(output_file, 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
# Write header
writer.writerow(['wallet address', 'weight'])
# Write data (only non-zero weights)
for address, weight in final_points.items():
if weight > 0: # Only write if weight is non-zero
writer.writerow([address, weight])

print(f"\nResults have been written to {output_file}")