Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.github @lidofinance/lido-dao-ops-team
* @lidofinance/lido-dao-ops-team
24 changes: 18 additions & 6 deletions tests/regression/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import os

from tqdm import tqdm
from web3 import Web3
from brownie import interface, convert, web3
from brownie.network.event import _decode_logs
Expand Down Expand Up @@ -489,19 +490,30 @@ def active_aragon_roles(protocol_permissions):
w3 = Web3(Web3.HTTPProvider(f'https://mainnet.infura.io/v3/{os.getenv("WEB3_INFURA_PROJECT_ID")}'))

event_signature_hash = w3.keccak(text="SetPermission(address,address,bytes32,bool)").hex()
events_before_voting = w3.eth.filter(
{"address": contracts.acl.address, "fromBlock": ACL_DEPLOY_BLOCK_NUMBER, "topics": [event_signature_hash]}
).get_all_entries()

def fetch_events_in_batches(start_block, end_block, step=100000):
"""Fetch events in batches of `step` blocks with a progress bar."""
events = []
total_batches = (end_block - start_block) // step + 1
with tqdm(total=total_batches, desc="Fetching Events") as pbar:
for batch_start in range(start_block, end_block, step):
batch_end = min(batch_start + step - 1, end_block)
batch_events = w3.eth.filter(
{"address": contracts.acl.address, "fromBlock": batch_start, "toBlock": batch_end, "topics": [event_signature_hash]}
).get_all_entries()
events.extend(batch_events)
pbar.update(1)
return events

events_before_voting = fetch_events_in_batches(ACL_DEPLOY_BLOCK_NUMBER, w3.eth.block_number)

permission_events = _decode_logs(events_before_voting)["SetPermission"]._ordered

history = TxHistory()
if len(history) > 0:
vote_block = history[0].block_number

events_after_voting = web3.eth.filter(
{"address": contracts.acl.address, "fromBlock": vote_block, "topics": [event_signature_hash]}
).get_all_entries()
events_after_voting = fetch_events_in_batches(vote_block, w3.eth.block_number)

try:
permission_events_after_voting = _decode_logs(events_after_voting)["SetPermission"]._ordered
Expand Down
Loading