Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hweawer committed Feb 10, 2025
1 parent b01e42f commit 3f5ae8f
Show file tree
Hide file tree
Showing 73 changed files with 128 additions and 119 deletions.
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.types import Gwei, SlotNumber
from src.custom_types import Gwei, SlotNumber

# https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#misc
GENESIS_SLOT = SlotNumber(0)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from src.modules.checks.checks_module import ChecksModule
from src.modules.csm.csm import CSOracle
from src.providers.ipfs import GW3, IPFSProvider, MultiIPFSProvider, Pinata, PublicIPFS
from src.types import OracleModule
from src.custom_types import OracleModule
from src.utils.build import get_build_info
from src.utils.exception import IncompatibleException
from src.web3py.extensions import (
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def format(self, record: logging.LogRecord) -> str:
handler.setFormatter(JsonFormatter())

logging.basicConfig(
level=logging.CRITICAL,
level=logging.INFO,
handlers=[handler],
)
2 changes: 1 addition & 1 deletion src/modules/accounting/accounting.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from src.modules.submodules.oracle_module import BaseModule, ModuleExecuteDelay
from src.services.withdrawal import Withdrawal
from src.services.bunker import BunkerService
from src.types import BlockStamp, Gwei, ReferenceBlockStamp, StakingModuleId, NodeOperatorGlobalIndex, FinalizationBatches
from src.custom_types import BlockStamp, Gwei, ReferenceBlockStamp, StakingModuleId, NodeOperatorGlobalIndex, FinalizationBatches
from src.utils.cache import global_lru_cache as lru_cache
from src.utils.units import gwei_to_wei
from src.variables import ALLOW_REPORTING_IN_BUNKER_MODE
Expand Down
2 changes: 1 addition & 1 deletion src/modules/accounting/third_phase/extra_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from src.modules.accounting.third_phase.types import ExtraData, ItemType, ExtraDataLengths, FormatList
from src.modules.submodules.types import ZERO_HASH
from src.types import NodeOperatorGlobalIndex
from src.custom_types import NodeOperatorGlobalIndex
from src.web3py.types import Web3


Expand Down
2 changes: 1 addition & 1 deletion src/modules/accounting/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from hexbytes import HexBytes
from web3.types import Wei

from src.types import (
from src.custom_types import (
SlotNumber,
Gwei,
StakingModuleId,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/checks/suites/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from xdist.dsession import TerminalDistReporter # type: ignore[import]

from src import variables
from src.types import EpochNumber, SlotNumber, BlockRoot
from src.custom_types import EpochNumber, SlotNumber, BlockRoot
from src.utils.blockstamp import build_blockstamp
from src.utils.slot import get_reference_blockstamp
from src.web3py.contract_tweak import tweak_w3_contracts
Expand Down
2 changes: 1 addition & 1 deletion src/modules/csm/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from src.modules.csm.state import State
from src.providers.consensus.client import ConsensusClient
from src.providers.consensus.types import BlockAttestation, BlockAttestationEIP7549
from src.types import BlockRoot, BlockStamp, CommitteeIndex, EpochNumber, SlotNumber, ValidatorIndex
from src.custom_types import BlockRoot, BlockStamp, CommitteeIndex, EpochNumber, SlotNumber, ValidatorIndex
from src.utils.range import sequence
from src.utils.timeit import timeit
from src.utils.types import hex_str_to_bytes
Expand Down
2 changes: 1 addition & 1 deletion src/modules/csm/csm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from src.providers.execution.contracts.cs_fee_oracle import CSFeeOracleContract
from src.providers.execution.exceptions import InconsistentData
from src.providers.ipfs import CID
from src.types import (
from src.custom_types import (
BlockStamp,
EpochNumber,
ReferenceBlockStamp,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/csm/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from src.modules.csm.state import AttestationsAccumulator
from src.modules.csm.types import Shares
from src.types import EpochNumber, NodeOperatorId, ReferenceBlockStamp, ValidatorIndex
from src.custom_types import EpochNumber, NodeOperatorId, ReferenceBlockStamp, ValidatorIndex


class LogJSONEncoder(json.JSONEncoder): ...
Expand Down
2 changes: 1 addition & 1 deletion src/modules/csm/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Self

from src import variables
from src.types import EpochNumber, ValidatorIndex
from src.custom_types import EpochNumber, ValidatorIndex
from src.utils.range import sequence

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/csm/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from hexbytes import HexBytes

from src.providers.ipfs import CID
from src.types import NodeOperatorId, SlotNumber
from src.custom_types import NodeOperatorId, SlotNumber

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/modules/ejector/data_encode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from eth_typing import HexStr

from src.types import ValidatorIndex
from src.custom_types import ValidatorIndex
from src.utils.types import hex_str_to_bytes
from src.web3py.extensions.lido_validators import LidoValidator, NodeOperatorGlobalIndex

Expand Down
2 changes: 1 addition & 1 deletion src/modules/ejector/ejector.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from src.services.exit_order_iterator import ValidatorExitIterator
from src.services.prediction import RewardsPredictionService
from src.services.validator_state import LidoValidatorStateService
from src.types import BlockStamp, EpochNumber, Gwei, NodeOperatorGlobalIndex, ReferenceBlockStamp
from src.custom_types import BlockStamp, EpochNumber, Gwei, NodeOperatorGlobalIndex, ReferenceBlockStamp
from src.utils.cache import global_lru_cache as lru_cache
from src.utils.units import gwei_to_wei
from src.utils.validator_state import (
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ejector/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from src.modules.submodules.types import ChainConfig
from src.providers.consensus.types import BeaconStateView
from src.types import Gwei
from src.custom_types import Gwei
from src.utils.validator_state import (
is_fully_withdrawable_validator,
is_partially_withdrawable_validator,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ejector/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass

from src.types import SlotNumber
from src.custom_types import SlotNumber


@dataclass
Expand Down
8 changes: 6 additions & 2 deletions src/modules/submodules/consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from src.metrics.prometheus.basic import ORACLE_SLOT_NUMBER, ORACLE_BLOCK_NUMBER, GENESIS_TIME, ACCOUNT_BALANCE
from src.providers.execution.contracts.base_oracle import BaseOracleContract
from src.providers.execution.contracts.hash_consensus import HashConsensusContract
from src.types import BlockStamp, ReferenceBlockStamp, SlotNumber, FrameNumber
from src.custom_types import BlockStamp, ReferenceBlockStamp, SlotNumber, FrameNumber
from src.metrics.prometheus.business import (
ORACLE_MEMBER_LAST_REPORT_REF_SLOT,
FRAME_CURRENT_REF_SLOT,
Expand Down Expand Up @@ -426,7 +426,11 @@ def _submit_report(self, report: tuple, contract_version: int):
self.w3.transaction.check_and_send_transaction(tx, variables.ACCOUNT)

def _get_latest_blockstamp(self) -> BlockStamp:
root = self.w3.cc.get_block_root('head').root
refslot = os.getenv("ORACLE_REFSLOT")
if refslot is not None:
root = self.w3.cc.get_block_root(SlotNumber(int(refslot) + 3 * 32)).root
else:
root = self.w3.cc.get_block_root('head').root
block_details = self.w3.cc.get_block_details(root)
bs = build_blockstamp(block_details)
logger.debug({'msg': 'Fetch latest blockstamp.', 'value': bs})
Expand Down
11 changes: 8 additions & 3 deletions src/modules/submodules/oracle_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import time
import traceback
from abc import abstractmethod, ABC
Expand All @@ -23,7 +24,7 @@
from web3_multi_provider import NoActiveProviderError

from src import variables
from src.types import SlotNumber, BlockStamp, BlockRoot
from src.custom_types import SlotNumber, BlockStamp, BlockRoot

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -119,7 +120,11 @@ def _sleep_cycle():
time.sleep(variables.CYCLE_SLEEP_IN_SECONDS)

def _receive_last_finalized_slot(self) -> BlockStamp:
block_root = BlockRoot(self.w3.cc.get_block_root('finalized').root)
refslot = os.getenv("ORACLE_REFSLOT")
if refslot is not None:
block_root = BlockRoot(self.w3.cc.get_block_root(SlotNumber(int(refslot) + 3 * 32)).root)
else:
block_root = BlockRoot(self.w3.cc.get_block_root('finalized').root)
block_details = self.w3.cc.get_block_details(block_root)
bs = build_blockstamp(block_details)
logger.info({'msg': 'Fetch last finalized BlockStamp.', 'value': asdict(bs)})
Expand All @@ -130,7 +135,7 @@ def _receive_last_finalized_slot(self) -> BlockStamp:
def run_cycle(self, blockstamp: BlockStamp):
logger.info({'msg': 'Execute module.', 'value': blockstamp})
result = self.execute_module(blockstamp)
pulse()
# pulse()
if result is ModuleExecuteDelay.NEXT_FINALIZED_EPOCH:
self._slot_threshold = blockstamp.slot_number

Expand Down
2 changes: 1 addition & 1 deletion src/modules/submodules/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass

from src.types import SlotNumber
from src.custom_types import SlotNumber


ZERO_HASH = bytes([0]*32)
Expand Down
2 changes: 1 addition & 1 deletion src/providers/consensus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
SlotAttestationCommittee,
)
from src.providers.http_provider import HTTPProvider, NotOkResponse
from src.types import BlockRoot, BlockStamp, SlotNumber, EpochNumber, StateRoot
from src.custom_types import BlockRoot, BlockStamp, SlotNumber, EpochNumber, StateRoot
from src.utils.dataclass import list_of_dataclasses
from src.utils.cache import global_lru_cache as lru_cache

Expand Down
2 changes: 1 addition & 1 deletion src/providers/consensus/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from web3.types import Timestamp

from src.constants import FAR_FUTURE_EPOCH
from src.types import BlockHash, BlockRoot, CommitteeIndex, EpochNumber, Gwei, SlotNumber, StateRoot, ValidatorIndex
from src.custom_types import BlockHash, BlockRoot, CommitteeIndex, EpochNumber, Gwei, SlotNumber, StateRoot, ValidatorIndex
from src.utils.dataclass import FromResponse, Nested


Expand Down
2 changes: 1 addition & 1 deletion src/providers/execution/contracts/base_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from web3.types import BlockIdentifier

from src.providers.execution.base_interface import ContractInterface
from src.types import SlotNumber
from src.custom_types import SlotNumber


logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/providers/execution/contracts/hash_consensus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from src.types import SlotNumber
from src.custom_types import SlotNumber
from src.utils.cache import global_lru_cache as lru_cache

from eth_typing import ChecksumAddress
Expand Down
2 changes: 1 addition & 1 deletion src/providers/execution/contracts/lido.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from src.modules.accounting.types import LidoReportRebase, BeaconStat
from src.providers.execution.base_interface import ContractInterface
from src.types import SlotNumber
from src.custom_types import SlotNumber
from src.utils.abi import named_tuple_to_dataclass
from src.utils.cache import global_lru_cache as lru_cache

Expand Down
2 changes: 1 addition & 1 deletion src/providers/keys/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from src.metrics.prometheus.basic import KEYS_API_REQUESTS_DURATION, KEYS_API_LATEST_BLOCKNUMBER
from src.providers.http_provider import HTTPProvider, NotOkResponse
from src.providers.keys.types import LidoKey, KeysApiStatus
from src.types import BlockStamp, StakingModuleAddress
from src.custom_types import BlockStamp, StakingModuleAddress
from src.utils.cache import global_lru_cache as lru_cache


Expand Down
2 changes: 1 addition & 1 deletion src/providers/keys/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from eth_typing import ChecksumAddress, HexStr

from src.types import NodeOperatorId
from src.custom_types import NodeOperatorId
from src.utils.dataclass import FromResponse


Expand Down
90 changes: 45 additions & 45 deletions src/scrap_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,42 @@ def extract_ref_slot(tx_data, type):


if __name__ == "__main__":
print(f"---AccountingOracle---")
accounting_address = "0x852deD011285fe67063a08005c71a85690503Cee"

transactions = get_transactions(accounting_address)

if not transactions:
print("No submitReportData transactions found!")
sys.exit(0)

print(f"✅ Found {len(transactions)} submitReportData calls")

for tx in transactions:
tx_hash = tx["hash"]
refslot = extract_ref_slot(tx["input"], 'accounting')
print(f"🔹 Tx: {tx_hash} → X: {refslot}")
os.environ["ORACLE_REFSLOT"] = str(refslot)
os.environ["DEAMON"] = str(False)
run_oracle('accounting')

print(f"---ValidatorExitBusOracle---")
ejector_address = "0x0De4Ea0184c2ad0BacA7183356Aea5B8d5Bf5c6e"
transactions = get_transactions(ejector_address, "0x294492c8")
if not transactions:
print("No submitReportData transactions found!")
sys.exit(0)

print(f"✅ Found {len(transactions)} submitReportData calls")
for tx in transactions:
tx_hash = tx["hash"]
decoded_static_values = extract_ref_slot(tx["input"], 'ejector')
refslot = decoded_static_values[0][1]
print(f"🔹 Tx: {tx_hash} → X: {refslot}")
os.environ["ORACLE_REFSLOT"] = str(refslot)
os.environ["DEAMON"] = str(False)
print(decoded_static_values)
run_oracle('ejector')
#print(f"---AccountingOracle---")
#accounting_address = "0x852deD011285fe67063a08005c71a85690503Cee"

#transactions = get_transactions(accounting_address)

#if not transactions:
# print("No submitReportData transactions found!")
# sys.exit(0)

#print(f"✅ Found {len(transactions)} submitReportData calls")

#for tx in transactions:
# tx_hash = tx["hash"]
# refslot = extract_ref_slot(tx["input"], 'accounting')
# print(f"🔹 Tx: {tx_hash} → X: {refslot}")
# os.environ["ORACLE_REFSLOT"] = str(refslot)
# os.environ["DEAMON"] = str(False)
# run_oracle('accounting')

#print(f"---ValidatorExitBusOracle---")
#ejector_address = "0x0De4Ea0184c2ad0BacA7183356Aea5B8d5Bf5c6e"
#transactions = get_transactions(ejector_address, "0x294492c8")
#if not transactions:
# print("No submitReportData transactions found!")
# sys.exit(0)

#print(f"✅ Found {len(transactions)} submitReportData calls")
#for tx in transactions:
# tx_hash = tx["hash"]
# decoded_static_values = extract_ref_slot(tx["input"], 'ejector')
# refslot = decoded_static_values[0][1]
# print(f"🔹 Tx: {tx_hash} → X: {refslot}")
# os.environ["ORACLE_REFSLOT"] = str(refslot)
# os.environ["DEAMON"] = str(False)
# print(decoded_static_values)
# run_oracle('ejector')

print(f"---CSFeeOracle---")
csm_oracle_address = "0x4D4074628678Bd302921c20573EEa1ed38DdF7FB"
Expand All @@ -95,12 +95,12 @@ def extract_ref_slot(tx_data, type):
sys.exit(0)

print(f"✅ Found {len(transactions)} submitReportData calls")
for tx in transactions:
tx_hash = tx["hash"]
decoded_static_values = extract_ref_slot(tx["input"], 'csm')
refslot = decoded_static_values[0][1]
print(f"🔹 Tx: {tx_hash} → X: {refslot}")
os.environ["ORACLE_REFSLOT"] = str(refslot)
os.environ["DEAMON"] = str(False)
print(decoded_static_values)
run_oracle('csm')
tx = transactions[0]
tx_hash = tx["hash"]
decoded_static_values = extract_ref_slot(tx["input"], 'csm')
refslot = decoded_static_values[0][1]
print(f"🔹 Tx: {tx_hash} → X: {refslot}")
os.environ["ORACLE_REFSLOT"] = str(refslot)
os.environ["DEAMON"] = str(False)
print(decoded_static_values)
run_oracle('csm')
2 changes: 1 addition & 1 deletion src/services/bunker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from src.modules.submodules.consensus import FrameConfig, ChainConfig
from src.services.bunker_cases.types import BunkerConfig
from src.services.safe_border import filter_slashed_validators
from src.types import BlockStamp, ReferenceBlockStamp, Gwei
from src.custom_types import BlockStamp, ReferenceBlockStamp, Gwei
from src.utils.units import wei_to_gwei
from src.utils.web3converter import Web3Converter
from src.web3py.types import Web3
Expand Down
2 changes: 1 addition & 1 deletion src/services/bunker_cases/abnormal_cl_rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from src.providers.consensus.types import Validator
from src.providers.keys.types import LidoKey
from src.services.bunker_cases.types import BunkerConfig
from src.types import ReferenceBlockStamp, Gwei, BlockNumber, SlotNumber, BlockStamp, EpochNumber
from src.custom_types import ReferenceBlockStamp, Gwei, BlockNumber, SlotNumber, BlockStamp, EpochNumber
from src.utils.events import get_events_in_range
from src.utils.slot import get_blockstamp, get_reference_blockstamp
from src.utils.units import wei_to_gwei
Expand Down
2 changes: 1 addition & 1 deletion src/services/bunker_cases/midterm_slashing_penalty.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX,
)
from src.providers.consensus.types import Validator
from src.types import EpochNumber, FrameNumber, Gwei, ReferenceBlockStamp, SlotNumber
from src.custom_types import EpochNumber, FrameNumber, Gwei, ReferenceBlockStamp, SlotNumber
from src.utils.validator_state import calculate_total_active_effective_balance
from src.utils.web3converter import Web3Converter
from src.web3py.extensions.lido_validators import LidoValidator
Expand Down
Loading

0 comments on commit 3f5ae8f

Please sign in to comment.