Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Feb 3, 2025
2 parents a960b18 + 00d2ea1 commit c0b704b
Show file tree
Hide file tree
Showing 22 changed files with 1,135 additions and 98 deletions.
19 changes: 19 additions & 0 deletions backend/app/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,25 @@
"0xadd7b1e78f0e59d96135c5240e1175d5a7dc210d",
"0x094b75eedf58a83af4d37694b7532691fb26570e",
}

GUEST_LIST_NOT_MAINNET = {
"0xfe8076f61ffe6a01035919a20e8c8afe3dae6d6c",
"0x80f9e65b8a4b896993c2f306f56743c7d5cfc214",
"0x9b479432155c96c664a9f40fcb3a4ae0abc20920",
"0x825c523c9e4269f4d671aeb4f7ff7fc3f8545aae",
"0x4e36e39779d539388a5db1b0044d9e7e2a650318",
"0x4abbec7c97cf0bd86b820fa969ce3d9b3c114e63",
"0x3d32cedc106b727a9de5adf83dbb26a77962b667",
"0xc879b314fdae292ce863135393bb34519ad3dbf5",
"0x33d05a2a1777edc22ba1fe7d9f031b5515893499",
"0xf02c943f9c22604bedbb9b6f4312b25d7c03fca4",
"0xc4501ef6a12c9c218f1816358300bb41b5bf3032",
"0x9f872dcdf45fddf000239bd1d1287de691769b68",
"0x38bdc76739ab5c2deeaa190c9bbd3a57555108df",
"0x5ee66522e9f7d527e666402a5c82cd1e8eac4a53",
"0x8a650e57f7b82bc4479a40a19c011b740fa17e15",
}

TIMEOUT_LIST_NOT_MAINNET = {
"0xdf486eec7b89c390569194834a2f7a71da05ee13",
"0x689f1a51c177cce66e3afdca4b1ded7721f531f9",
Expand Down
13 changes: 11 additions & 2 deletions backend/app/modules/modules_factory/current.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@
TIMEOUT_LIST,
SABLIER_UNLOCK_GRACE_PERIOD_24_HRS,
TEST_SABLIER_UNLOCK_GRACE_PERIOD_15_MIN,
GUEST_LIST_NOT_MAINNET,
)
from app.modules.projects.details.service.projects_details import (
StaticProjectsDetailsService,
)
from app.modules.user.winnings.service.raffle import RaffleWinningsService
from migrations.versions.e27e85614385_bump_uq_score_for_addresses_with_ import (
GUEST_LIST,
)


class CurrentUserDeposits(UserEffectiveDeposits, TotalEffectiveDeposits, Protocol):
Expand Down Expand Up @@ -120,7 +124,10 @@ def create(chain_id: int) -> "CurrentServices":
user_withdrawals = FinalizedWithdrawals()

timeout_list = TIMEOUT_LIST if is_mainnet else TIMEOUT_LIST_NOT_MAINNET
user_antisybil_service = GitcoinPassportAntisybil(timeout_list=timeout_list)
guest_list = GUEST_LIST if is_mainnet else GUEST_LIST_NOT_MAINNET
user_antisybil_service = GitcoinPassportAntisybil(
timeout_list=timeout_list, guest_list=guest_list
)

tos_verifier = InitialUserTosVerifier()
user_tos = InitialUserTos(verifier=tos_verifier)
Expand Down Expand Up @@ -154,7 +161,9 @@ def create(chain_id: int) -> "CurrentServices":
)
uq_threshold = UQ_THRESHOLD_MAINNET if is_mainnet else UQ_THRESHOLD_NOT_MAINNET
uniqueness_quotients = PreliminaryUQ(
antisybil=GitcoinPassportAntisybil(timeout_list=timeout_list),
antisybil=GitcoinPassportAntisybil(
timeout_list=timeout_list, guest_list=guest_list
),
budgets=user_budgets,
uq_threshold=uq_threshold,
)
Expand Down
7 changes: 6 additions & 1 deletion backend/app/modules/modules_factory/pending.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
UQ_THRESHOLD_NOT_MAINNET,
TIMEOUT_LIST,
TIMEOUT_LIST_NOT_MAINNET,
GUEST_LIST_NOT_MAINNET,
GUEST_LIST,
)
from app.modules.dto import SignatureOpType
from app.modules.modules_factory.protocols import (
Expand Down Expand Up @@ -109,8 +111,11 @@ def create(chain_id: int) -> "PendingServices":
is_mainnet = compare_blockchain_types(chain_id, ChainTypes.MAINNET)
uq_threshold = UQ_THRESHOLD_MAINNET if is_mainnet else UQ_THRESHOLD_NOT_MAINNET
timeout_list = TIMEOUT_LIST if is_mainnet else TIMEOUT_LIST_NOT_MAINNET
guest_list = GUEST_LIST if is_mainnet else GUEST_LIST_NOT_MAINNET
uniqueness_quotients = PreliminaryUQ(
antisybil=GitcoinPassportAntisybil(timeout_list=timeout_list),
antisybil=GitcoinPassportAntisybil(
timeout_list=timeout_list, guest_list=guest_list
),
budgets=saved_user_budgets,
uq_threshold=uq_threshold,
)
Expand Down
9 changes: 4 additions & 5 deletions backend/app/modules/user/antisybil/core.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from datetime import datetime, timezone
import json
from datetime import datetime, timezone
from typing import Optional

from app.modules.user.antisybil.dto import AntisybilStatusDTO
from app.constants import (
GUEST_LIST,
GUEST_LIST_STAMP_PROVIDERS,
GTC_STAKING_STAMP_PROVIDERS_AND_SCORES,
)
from app.infrastructure.database.models import GPStamps
from app.modules.user.antisybil.dto import AntisybilStatusDTO


def determine_antisybil_score(
score: GPStamps, user_address: str, timeout_list: set
score: GPStamps, user_address: str, timeout_list: set, guest_list: set
) -> Optional[AntisybilStatusDTO]:
"""
Determine the antisybil score for a user.
Expand All @@ -30,7 +29,7 @@ def determine_antisybil_score(
return AntisybilStatusDTO(
score=0.0, expires_at=score.expires_at, is_on_timeout_list=True
)
elif user_address.lower() in GUEST_LIST and not _has_guest_stamp_applied_by_gp(
elif user_address.lower() in guest_list and not _has_guest_stamp_applied_by_gp(
score, now
):
return AntisybilStatusDTO(
Expand Down
5 changes: 4 additions & 1 deletion backend/app/modules/user/antisybil/service/initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

class GitcoinPassportAntisybil(Model):
timeout_list: set
guest_list: set

def get_antisybil_status(
self, _: Context, user_address: str
Expand All @@ -37,7 +38,9 @@ def get_antisybil_status(
)
raise ex

return determine_antisybil_score(score, user_address, self.timeout_list)
return determine_antisybil_score(
score, user_address, self.timeout_list, self.guest_list
)

def fetch_antisybil_status(
self, _: Context, user_address: str
Expand Down
9 changes: 0 additions & 9 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,15 +1147,6 @@ def patch_gitcoin_passport_fetch_stamps(monkeypatch):
)


@pytest.fixture(scope="function")
def patch_guest_list_for_scoring(monkeypatch, alice):
MOCK_GUEST_LIST = [alice.address.lower()]
monkeypatch.setattr(
"app.modules.user.antisybil.core.GUEST_LIST",
MOCK_GUEST_LIST,
)


@pytest.fixture(scope="function")
def patch_etherscan_transactions_api(monkeypatch):
monkeypatch.setattr(
Expand Down
6 changes: 4 additions & 2 deletions backend/tests/modules/modules_factory/test_modules_factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app.constants import UQ_THRESHOLD_MAINNET, TIMEOUT_LIST
from app.constants import UQ_THRESHOLD_MAINNET, TIMEOUT_LIST, GUEST_LIST
from app.modules.dto import SignatureOpType
from app.modules.history.service.full import FullHistory
from app.modules.modules_factory.current import CurrentServices
Expand Down Expand Up @@ -154,7 +154,9 @@ def test_pending_services_factory():
saved_user_budgets = SavedUserBudgets()
user_nonce = SavedUserAllocationsNonce()
uniqueness_quotients = PreliminaryUQ(
antisybil=GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST),
antisybil=GitcoinPassportAntisybil(
timeout_list=TIMEOUT_LIST, guest_list=GUEST_LIST
),
budgets=saved_user_budgets,
uq_threshold=UQ_THRESHOLD_MAINNET,
)
Expand Down
18 changes: 11 additions & 7 deletions backend/tests/modules/user/antisybil/test_antisybil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from app import exceptions, db
from app.constants import GUEST_LIST
from app.exceptions import UserNotFound
from app.infrastructure import database
from app.modules.common.delegation import get_hashed_addresses
Expand All @@ -24,7 +25,7 @@ def test_antisybil_service(
):
context = get_context(4)

service = GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST)
service = GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST, guest_list=GUEST_LIST)

unknown_address = "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720"
try:
Expand Down Expand Up @@ -54,7 +55,7 @@ def test_gtc_staking_stamp_nullification(
mock_users_db,
):
context = get_context(4)
service = GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST)
service = GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST, guest_list=GUEST_LIST)
_, _, carol = mock_users_db
score, expires_at, stamps = service.fetch_antisybil_status(context, carol.address)
service.update_antisybil_status(context, carol.address, score, expires_at, stamps)
Expand All @@ -68,13 +69,14 @@ def test_guest_stamp_score_bump_for_both_gp_and_octant_side_application(
patch_gitcoin_passport_issue_address_for_scoring,
patch_gitcoin_passport_fetch_score,
patch_gitcoin_passport_fetch_stamps,
patch_guest_list_for_scoring,
mock_users_db,
):
context = get_context(4)

service = GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST)
alice, bob, _ = mock_users_db
service = GitcoinPassportAntisybil(
timeout_list=TIMEOUT_LIST, guest_list={alice.address.lower()}
)

score, expires_at, stamps = service.fetch_antisybil_status(context, bob.address)

Expand Down Expand Up @@ -111,7 +113,7 @@ def test_antisybil_cant_be_update_when_address_is_delegated(alice, bob):
database.score_delegation.save_delegation(primary, secondary, both)
db.session.commit()

service = GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST)
service = GitcoinPassportAntisybil(timeout_list=TIMEOUT_LIST, guest_list=GUEST_LIST)

with pytest.raises(exceptions.AddressAlreadyDelegated):
service.update_antisybil_status(
Expand All @@ -131,7 +133,8 @@ def test_antisybil_score_is_nullified_when_address_on_timeout_list(
context = get_context(4)

service = GitcoinPassportAntisybil(
timeout_list={"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"}
timeout_list={"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"},
guest_list=GUEST_LIST,
)
alice, _, _ = mock_users_db
timeout_address = alice.address
Expand All @@ -153,7 +156,8 @@ def test_fetch_antisybil_return_0_when_address_on_timeout_list(
context = get_context(4)

service = GitcoinPassportAntisybil(
timeout_list={"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"}
timeout_list={"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"},
guest_list=GUEST_LIST,
)
alice, _, _ = mock_users_db
timeout_address = alice.address
Expand Down
7 changes: 6 additions & 1 deletion backend/v2/uniqueness_quotients/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
TIMEOUT_LIST_NOT_MAINNET,
UQ_THRESHOLD_MAINNET,
UQ_THRESHOLD_NOT_MAINNET,
GUEST_LIST_NOT_MAINNET,
)
from app.shared.blockchain_types import ChainTypes
from fastapi import Depends
Expand Down Expand Up @@ -52,7 +53,11 @@ def get_uq_score_getter(

address_set_validator = TypeAdapter(set[Address])
timeout_set = address_set_validator.validate_python(timeout_list)
guest_set = address_set_validator.validate_python(GUEST_LIST)

if is_mainnet:
guest_set = address_set_validator.validate_python(GUEST_LIST)
else:
guest_set = address_set_validator.validate_python(GUEST_LIST_NOT_MAINNET)

return UQScoreGetter(
session=session,
Expand Down
14 changes: 7 additions & 7 deletions ci/argocd/contracts/master.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BLOCK_NUMBER=7510799
BLOCK_NUMBER=7603103
GLM_CONTRACT_ADDRESS=0x71432DD1ae7DB41706ee6a22148446087BdD0906
AUTH_CONTRACT_ADDRESS=0x2260229B791Fc1749F0adc4061F3Af0868348Cf2
DEPOSITS_CONTRACT_ADDRESS=0xE2Cc32155f249a0B421F2220872E110d5382843E
EPOCHS_CONTRACT_ADDRESS=0xca32654C9d636879B3A1AB3641f7Dddf67F5480B
PROPOSALS_CONTRACT_ADDRESS=0x181Bc90CC3229bDd565D9ea0E615cCb6cF11448C
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0xAf1d9bbEce78ea62BF69Ac78baB7e9708694950C
VAULT_CONTRACT_ADDRESS=0x83b965EBcE901001f11e717808b302c1718b45B0
AUTH_CONTRACT_ADDRESS=0xa09575881fBA466AE99F899068654CbAF82C4A4B
DEPOSITS_CONTRACT_ADDRESS=0x94F20FDF26d8920B69F86B405FCC1e8e4c0389e2
EPOCHS_CONTRACT_ADDRESS=0x9bE59362fa654750c2B573401d88cC1dFA21d628
PROPOSALS_CONTRACT_ADDRESS=0xCF135a3452D474ea71E5b6414079170cf0EE2d5f
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0x43Ab9A57c3742Ad4b3a63007950157720e3AA0b9
VAULT_CONTRACT_ADDRESS=0x8633C4C7f07A3C99401C66df49BAb714BB4dC1e1
21 changes: 21 additions & 0 deletions client/cypress/e2e/group2/_09settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Object.values(viewports).forEach(
});

beforeEach(() => {
cy.disconnectMetamaskWalletFromAllDapps();
mockCoinPricesServer();
localStorage.setItem(IS_ONBOARDING_ALWAYS_VISIBLE, 'false');
localStorage.setItem(IS_ONBOARDING_DONE, 'true');
Expand Down Expand Up @@ -262,7 +263,9 @@ Object.values(viewports).forEach(
cy.get(`[data-test=LayoutNavbar__Button--settings]`).click();
checkLocationWithLoader(ROOT_ROUTES.settings.absolute);
}
cy.wait(500);
cy.get('[data-test=SettingsCurrencyBox__InputSelect--currency]').click();
cy.wait(500);
cy.get(
`[data-test=SettingsCurrencyBox__InputSelect--currency__Option--${nextDisplayCurrency}]`,
).click();
Expand Down Expand Up @@ -303,6 +306,24 @@ Object.values(viewports).forEach(
cy.get('[data-test=HomeGridVideoBar]').should('be.visible');
}
});

it('"Enable patron mode" option is visible only when wallet is connected', () => {
cy.wait(500);
cy.get('[data-test=SettingsPatronModeBox]').should('not.exist');

if (isLargeDesktop || isDesktop) {
cy.get('[data-test=SettingsDrawer__closeButton]').click();
cy.wait(500);
}

connectWallet({ isPatronModeEnabled: false });
cy.wait(2000);

if (isLargeDesktop || isDesktop) {
cy.get('[data-test=LayoutTopBar__settingsButton]').click();
}
cy.get('[data-test=SettingsPatronModeBox]').should('be.visible');
});
});
},
);
Loading

0 comments on commit c0b704b

Please sign in to comment.