Skip to content

Commit

Permalink
Add holesky network (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi authored Oct 25, 2023
1 parent efe9e67 commit 0a79005
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 63 deletions.
5 changes: 2 additions & 3 deletions src/commands/validators_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def validators_exit(
async def main(count: int | None) -> None:
keystores = load_keystores()
remote_signer_config = None
fork = await consensus_client.get_consensus_fork()

if len(keystores) > 0:
all_validator_pubkeys = list(keystores.keys()) # pylint: disable=no-member
Expand Down Expand Up @@ -186,14 +185,14 @@ async def main(count: int | None) -> None:
exit_signature = await _get_exit_signature(
exit_keystore=exit_keystore,
remote_signer_config=remote_signer_config,
fork=fork,
fork=settings.network_config.SHAPELLA_FORK,
network=settings.network,
)
try:
await consensus_client.submit_voluntary_exit(
validator_index=exit_keystore.index,
signature=Web3.to_hex(exit_signature),
epoch=fork.epoch,
epoch=settings.network_config.SHAPELLA_FORK.epoch,
)
except ClientResponseError as e:
# Validator status is updated in CL after some delay.
Expand Down
80 changes: 45 additions & 35 deletions src/common/abi/IEthVault.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@
{
"indexed": false,
"internalType": "uint256",
"name": "coveredShares",
"name": "osTokenShares",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "shares",
"type": "uint256"
},
{
Expand Down Expand Up @@ -319,6 +325,12 @@
"name": "receiver",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
Expand Down Expand Up @@ -411,25 +423,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -461,6 +454,11 @@
"name": "positionTicket",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "exitQueueIndex",
Expand Down Expand Up @@ -508,6 +506,11 @@
"name": "positionTicket",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "exitQueueIndex",
Expand Down Expand Up @@ -666,6 +669,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "getShares",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "implementation",
Expand Down Expand Up @@ -737,13 +759,7 @@
}
],
"name": "liquidateOsToken",
"outputs": [
{
"internalType": "uint256",
"name": "receivedAssets",
"type": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
Expand Down Expand Up @@ -903,13 +919,7 @@
}
],
"name": "redeemOsToken",
"outputs": [
{
"internalType": "uint256",
"name": "receivedAssets",
"type": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
Expand Down Expand Up @@ -1080,7 +1090,7 @@
},
{
"inputs": [],
"name": "totalSupply",
"name": "totalShares",
"outputs": [
{
"internalType": "uint256",
Expand Down
24 changes: 18 additions & 6 deletions src/common/abi/IKeeper.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@
"name": "vault",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes",
"name": "validators",
"type": "bytes"
},
{
"indexed": false,
"internalType": "string",
Expand Down Expand Up @@ -388,8 +382,26 @@
"internalType": "uint256",
"name": "unlockedMevDelta",
"type": "uint256"
},
{
"internalType": "bool",
"name": "harvested",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
Expand Down
57 changes: 52 additions & 5 deletions src/config/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

from ens.constants import EMPTY_ADDR_HEX
from eth_typing import BlockNumber, ChecksumAddress, HexStr
from sw_utils.typings import Bytes32
from sw_utils.typings import Bytes32, ConsensusFork
from web3 import Web3
from web3.types import Wei

MAINNET = 'mainnet'
GOERLI = 'goerli'
GNOSIS = 'gnosis'
HOLESKY = 'holesky'

ETH_NETWORKS = [MAINNET, GOERLI]
ETH_NETWORKS = [MAINNET, GOERLI, HOLESKY]
GNO_NETWORKS = [GNOSIS]


Expand All @@ -33,6 +34,15 @@ class NetworkConfig:
GENESIS_FORK_VERSION: bytes
IS_POA: bool
HOT_WALLET_MIN_BALANCE: Wei
SHAPELLA_FORK_VERSION: bytes
SHAPELLA_EPOCH: int

@property
def SHAPELLA_FORK(self) -> ConsensusFork:
return ConsensusFork(
version=self.SHAPELLA_FORK_VERSION,
epoch=self.SHAPELLA_EPOCH,
)


NETWORKS = {
Expand All @@ -58,9 +68,42 @@ class NetworkConfig:
GENESIS_VALIDATORS_IPFS_HASH='',
SLOTS_PER_EPOCH=32,
SECONDS_PER_BLOCK=Decimal(12),
GENESIS_FORK_VERSION=bytes.fromhex('00000000'),
GENESIS_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x00000000')),
IS_POA=False,
HOT_WALLET_MIN_BALANCE=Web3.to_wei('0.01', 'ether'),
SHAPELLA_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x03000000')),
SHAPELLA_EPOCH=194048,
),
HOLESKY: NetworkConfig(
SYMBOL='HolETH',
VALIDATORS_REGISTRY_CONTRACT_ADDRESS=Web3.to_checksum_address(
'0x4242424242424242424242424242424242424242'
),
VALIDATORS_REGISTRY_GENESIS_BLOCK=BlockNumber(0),
KEEPER_CONTRACT_ADDRESS=Web3.to_checksum_address(
'0xc3e8c8BA310b62540FBb5eB81c9028444D35e568'
),
KEEPER_GENESIS_BLOCK=BlockNumber(167109),
V2_POOL_CONTRACT_ADDRESS=Web3.to_checksum_address(
'0x0000000000000000000000000000000000000000'
),
V2_POOL_GENESIS_BLOCK=BlockNumber(167109),
GENESIS_VAULT_CONTRACT_ADDRESS=Web3.to_checksum_address(
'0xcca5bB5089B83060793B9b6DF35Bfe62B922b8E4'
),
GENESIS_VALIDATORS_ROOT=Bytes32(
Web3.to_bytes(
hexstr=HexStr('0x9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1')
)
),
GENESIS_VALIDATORS_IPFS_HASH='QmRQC77DywyAofaYdiNPm8wvskMMd88S65aCfoxEnDfKEr',
SLOTS_PER_EPOCH=32,
SECONDS_PER_BLOCK=Decimal(12),
GENESIS_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x01017000')),
IS_POA=False,
HOT_WALLET_MIN_BALANCE=Web3.to_wei('0.01', 'ether'),
SHAPELLA_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x01017000')),
SHAPELLA_EPOCH=256,
),
GOERLI: NetworkConfig(
SYMBOL='GoerliETH',
Expand All @@ -87,9 +130,11 @@ class NetworkConfig:
GENESIS_VALIDATORS_IPFS_HASH='QmQo3oLYxqWm75fbgJJkCaUttZoYVqZhZj9r99r1UsZVpu',
SLOTS_PER_EPOCH=32,
SECONDS_PER_BLOCK=Decimal(12),
GENESIS_FORK_VERSION=bytes.fromhex('00001020'),
GENESIS_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x00001020')),
IS_POA=True,
HOT_WALLET_MIN_BALANCE=Web3.to_wei('0.01', 'ether'),
SHAPELLA_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x03001020')),
SHAPELLA_EPOCH=162304,
),
GNOSIS: NetworkConfig(
SYMBOL='xDAI',
Expand All @@ -113,8 +158,10 @@ class NetworkConfig:
GENESIS_VALIDATORS_IPFS_HASH='',
SLOTS_PER_EPOCH=32,
SECONDS_PER_BLOCK=Decimal('6.8'),
GENESIS_FORK_VERSION=bytes.fromhex('00000064'),
GENESIS_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x00000064')),
IS_POA=False,
HOT_WALLET_MIN_BALANCE=Web3.to_wei('0.01', 'ether'),
SHAPELLA_FORK_VERSION=Web3.to_bytes(hexstr=HexStr('0x0')),
SHAPELLA_EPOCH=0, # todo
),
}
4 changes: 2 additions & 2 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from web3 import Web3
from web3.types import ChecksumAddress

from src.config.networks import GOERLI, NETWORKS, NetworkConfig
from src.config.networks import GOERLI, HOLESKY, NETWORKS, NetworkConfig

DATA_DIR = Path.home() / '.stakewise'

Expand Down Expand Up @@ -177,7 +177,7 @@ def network_config(self) -> NetworkConfig:

settings = Settings()

AVAILABLE_NETWORKS = [GOERLI]
AVAILABLE_NETWORKS = [GOERLI, HOLESKY]

# oracles
UPDATE_SIGNATURES_URL_PATH = '/signatures'
Expand Down
7 changes: 2 additions & 5 deletions src/exits/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from web3 import Web3
from web3.types import HexStr

from src.common.clients import consensus_client
from src.common.contracts import keeper_contract
from src.common.execution import get_oracles
from src.common.metrics import metrics
Expand Down Expand Up @@ -130,8 +129,6 @@ async def _get_oracles_request(
validators: dict[int, HexStr],
) -> SignatureRotationRequest:
"""Fetches approval from oracles."""
fork = await consensus_client.get_consensus_fork()

# get exit signature shards
request = SignatureRotationRequest(
vault_address=settings.vault,
Expand All @@ -148,7 +145,7 @@ async def _get_oracles_request(
validator_index=validator_index,
private_key=keystores[public_key],
oracles=oracles,
fork=fork,
fork=settings.network_config.SHAPELLA_FORK,
)
elif remote_signer_config and public_key in remote_signer_config.pubkeys_to_shares:
# pylint: disable=duplicate-code
Expand All @@ -157,7 +154,7 @@ async def _get_oracles_request(
validator_index=validator_index,
validator_pubkey_shares=[BLSPubkey(Web3.to_bytes(hexstr=s)) for s in pubkey_shares],
oracles=oracles,
fork=fork,
fork=settings.network_config.SHAPELLA_FORK,
)
else:
failed_indexes.append(validator_index)
Expand Down
Loading

0 comments on commit 0a79005

Please sign in to comment.