Skip to content

Commit

Permalink
Load local deposit data (#17)
Browse files Browse the repository at this point in the history
* Load deposit data locally

* Update oracles address

* Update logging messages

* Fix index var name
  • Loading branch information
tsudmi authored Jan 30, 2023
1 parent bc0a0f7 commit 619fbcd
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 346 deletions.
81 changes: 44 additions & 37 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sentry-sdk = "==1.12.1"
web3 = "==6.0.0b9"
py-ecc = "==6.0.0"
multiproof = { git = "https://github.com/stakewise/multiproof.git", rev = "v0.1.2" }
sw-utils = { git = "https://github.com/stakewise/sw-utils.git", rev = "v0.2.12" }
sw-utils = { git = "https://github.com/stakewise/sw-utils.git", rev = "v0.2.13" }
staking-deposit = { git = "https://github.com/ethereum/staking-deposit-cli.git", rev = "v2.3.0" }
pycryptodomex = "==3.16.0"
milagro-bls-binding = "==1.9.0"
Expand Down
11 changes: 0 additions & 11 deletions src/common/abi/IEthVault.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,6 @@
"internalType": "bytes32",
"name": "validatorsRoot",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "string",
"name": "validatorsIpfsHash",
"type": "string"
}
],
"name": "ValidatorsRootUpdated",
Expand Down Expand Up @@ -978,11 +972,6 @@
"internalType": "bytes32",
"name": "_validatorsRoot",
"type": "bytes32"
},
{
"internalType": "string",
"name": "validatorsIpfsHash",
"type": "string"
}
],
"name": "setValidatorsRoot",
Expand Down
8 changes: 2 additions & 6 deletions src/config/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class NetworkConfig:
ORACLES_CONTRACT_ADDRESS: ChecksumAddress
ORACLES_GENESIS_BLOCK: BlockNumber
GENESIS_VALIDATORS_ROOT: Bytes32
VAULT_GENESIS_BLOCK: BlockNumber
SECONDS_PER_BLOCK: Decimal
CONFIRMATION_BLOCKS: int
GENESIS_FORK_VERSION: bytes
Expand All @@ -42,7 +41,6 @@ class NetworkConfig:
hexstr=HexStr('0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95')
)
),
VAULT_GENESIS_BLOCK=BlockNumber(0),
SECONDS_PER_BLOCK=Decimal(12),
CONFIRMATION_BLOCKS=64,
GENESIS_FORK_VERSION=bytes.fromhex('00000000'),
Expand All @@ -54,15 +52,14 @@ class NetworkConfig:
),
VALIDATORS_REGISTRY_GENESIS_BLOCK=BlockNumber(4367321),
ORACLES_CONTRACT_ADDRESS=Web3.to_checksum_address(
'0xb1A899f03a7F68C81f0d80fD2162214B8562E3e2'
'0x7f6F787feC4735B914EE4836A78487F2bFA9e70B'
),
ORACLES_GENESIS_BLOCK=BlockNumber(8368601),
ORACLES_GENESIS_BLOCK=BlockNumber(8398334),
GENESIS_VALIDATORS_ROOT=Bytes32(
Web3.to_bytes(
hexstr=HexStr('0x043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb')
)
),
VAULT_GENESIS_BLOCK=BlockNumber(8368606),
SECONDS_PER_BLOCK=Decimal(12),
CONFIRMATION_BLOCKS=64,
GENESIS_FORK_VERSION=bytes.fromhex('00001020'),
Expand All @@ -81,7 +78,6 @@ class NetworkConfig:
hexstr=HexStr('0xf5dcb5564e829aab27264b9becd5dfaa017085611224cb3036f573368dbb9d47')
)
),
VAULT_GENESIS_BLOCK=BlockNumber(0),
SECONDS_PER_BLOCK=Decimal('6.8'),
CONFIRMATION_BLOCKS=24,
GENESIS_FORK_VERSION=bytes.fromhex('00000064'),
Expand Down
3 changes: 3 additions & 0 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
KEYSTORES_PASSWORD_PATH = config('KEYSTORES_PASSWORD_PATH')
KEYSTORES_PATH = config('KEYSTORES_PATH')

# deposit data
DEPOSIT_DATA_PATH = config('DEPOSIT_DATA_PATH')

# operator
OPERATOR_PRIVATE_KEY = config('OPERATOR_PRIVATE_KEY')

Expand Down
28 changes: 9 additions & 19 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
from src.common.clients import execution_client
from src.config.settings import LOG_LEVEL, NETWORK, NETWORK_CONFIG, SENTRY_DSN
from src.validators.database import setup as validators_db_setup
from src.validators.execution import (
NetworkValidatorsProcessor,
VaultValidatorsProcessor,
)
from src.validators.execution import NetworkValidatorsProcessor
from src.validators.tasks import load_genesis_validators, register_validators
from src.validators.utils import load_private_keys
from src.validators.utils import load_deposit_data, load_keystores

logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
Expand All @@ -39,31 +36,24 @@ async def main() -> None:
# load genesis validators for some networks
await load_genesis_validators()

# extract private keys from the keystores
private_keys = load_private_keys()
# load keystores
keystores = load_keystores()

# load deposit data
deposit_data = await load_deposit_data()

# start operator tasks
interrupt_handler = InterruptHandler()

# periodically scan validators root updates
vault_validators_processor = VaultValidatorsProcessor()
vault_validators_scanner = EventScanner(
vault_validators_processor
)

# periodically scan network validator updates
network_validators_processor = NetworkValidatorsProcessor()
network_validators_scanner = EventScanner(
network_validators_processor
)
network_validators_scanner = EventScanner(network_validators_processor)

while not interrupt_handler.exit:
to_block = await get_safe_block_number()
await asyncio.gather(
# check and register new validators
register_validators(private_keys),
# process validators root updates
vault_validators_scanner.process_new_events(to_block),
register_validators(keystores, deposit_data),
# process new network validators
network_validators_scanner.process_new_events(to_block),
)
Expand Down
Loading

0 comments on commit 619fbcd

Please sign in to comment.