diff --git a/Dockerfile b/Dockerfile index 265ebf5..ac3a1cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,12 @@ WORKDIR /app COPY requirements.txt setup.py ./ -COPY staking_deposit ./staking_deposit - RUN apk add --update gcc libc-dev linux-headers RUN pip3 install -r requirements.txt +COPY staking_deposit ./staking_deposit + RUN python3 setup.py install ARG cli_command diff --git a/Makefile b/Makefile index aa118b1..2df369f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VENV_NAME?=venv VENV_ACTIVATE=. $(VENV_NAME)/bin/activate PYTHON=${VENV_NAME}/bin/python3.8 -DOCKER_IMAGE="ethereum/staking-deposit-cli:latest" +DOCKER_IMAGE="registry.gitlab.com/pulsechaincom/staking-deposit-cli:latest" help: @echo "clean - remove build and Python file artifacts" diff --git a/staking_deposit/cli/generate_keys.py b/staking_deposit/cli/generate_keys.py index 9163d55..70d7a66 100644 --- a/staking_deposit/cli/generate_keys.py +++ b/staking_deposit/cli/generate_keys.py @@ -16,10 +16,7 @@ from staking_deposit.utils.validation import ( validate_password_strength, validate_eth1_withdrawal_address, ) -from staking_deposit.utils.constants import ( - MAX_DEPOSIT_AMOUNT, - DEFAULT_VALIDATOR_KEYS_FOLDER_NAME, -) +from staking_deposit.utils.constants import DEFAULT_VALIDATOR_KEYS_FOLDER_NAME from staking_deposit.utils.ascii_art import RHINO_0 from staking_deposit.utils.click import ( captive_prompt_callback, @@ -117,9 +114,9 @@ def generate_keys(ctx: click.Context, validator_start_index: int, execution_address: HexAddress, **kwargs: Any) -> None: mnemonic = ctx.obj['mnemonic'] mnemonic_password = ctx.obj['mnemonic_password'] - amounts = [MAX_DEPOSIT_AMOUNT] * num_validators - folder = os.path.join(folder, DEFAULT_VALIDATOR_KEYS_FOLDER_NAME) chain_setting = get_chain_setting(chain) + amounts = [chain_setting.MAX_DEPOSIT_AMOUNT] * num_validators + folder = os.path.join(folder, DEFAULT_VALIDATOR_KEYS_FOLDER_NAME) if not os.path.exists(folder): os.mkdir(folder) click.clear() diff --git a/staking_deposit/credentials.py b/staking_deposit/credentials.py index 9d70ead..3d4de63 100644 --- a/staking_deposit/credentials.py +++ b/staking_deposit/credentials.py @@ -20,7 +20,6 @@ from staking_deposit.utils.constants import ( BLS_WITHDRAWAL_PREFIX, ETH1_ADDRESS_WITHDRAWAL_PREFIX, ETH2GWEI, - MAX_DEPOSIT_AMOUNT, MIN_DEPOSIT_AMOUNT, ) from staking_deposit.utils.crypto import SHA256 @@ -113,7 +112,7 @@ class Credential: @property def deposit_message(self) -> DepositMessage: - if not MIN_DEPOSIT_AMOUNT <= self.amount <= MAX_DEPOSIT_AMOUNT: + if not MIN_DEPOSIT_AMOUNT <= self.amount <= self.chain_setting.MAX_DEPOSIT_AMOUNT: raise ValidationError(f"{self.amount / ETH2GWEI} ETH deposits are not within the bounds of this cli.") return DepositMessage( pubkey=self.signing_pk, diff --git a/staking_deposit/settings.py b/staking_deposit/settings.py index 9cd24d9..2c291be 100644 --- a/staking_deposit/settings.py +++ b/staking_deposit/settings.py @@ -1,5 +1,9 @@ from typing import Dict, NamedTuple from eth_utils import decode_hex +from utils.constants import ( + MAX_DEPOSIT_AMOUNT, + PULSECHAIN_MAX_DEPOSIT_AMOUNT, +) DEPOSIT_CLI_VERSION = '2.5.0' @@ -9,12 +13,20 @@ class BaseChainSetting(NamedTuple): GENESIS_FORK_VERSION: bytes GENESIS_VALIDATORS_ROOT: bytes + @property + def MAX_DEPOSIT_AMOUNT(self): + if self.NETWORK_NAME.lower().startswith('pulsechain'): + return PULSECHAIN_MAX_DEPOSIT_AMOUNT + return MAX_DEPOSIT_AMOUNT MAINNET = 'mainnet' GOERLI = 'goerli' PRATER = 'prater' SEPOLIA = 'sepolia' ZHEJIANG = 'zhejiang' +PULSECHAIN_DEVNET = 'pulsechain-devnet' +PULSECHAIN_TESTNET_V4 = 'pulsechain-testnet-v4' + # Mainnet setting MainnetSetting = BaseChainSetting( @@ -32,7 +44,16 @@ SepoliaSetting = BaseChainSetting( ZhejiangSetting = BaseChainSetting( NETWORK_NAME=ZHEJIANG, GENESIS_FORK_VERSION=bytes.fromhex('00000069'), GENESIS_VALIDATORS_ROOT=bytes.fromhex('53a92d8f2bb1d85f62d16a156e6ebcd1bcaba652d0900b2c2f387826f3481f6f')) - +# PulseChain Devnet +PulseDevnetSetting = BaseChainSetting( + NETWORK_NAME=PULSECHAIN_DEVNET, + GENESIS_FORK_VERSION=bytes.fromhex('20000089'), + GENESIS_VALIDATORS_ROOT=bytes.fromhex('4aedc10744730347aa6c22010bd781a4f32e8369e06c788da4bfdadd11c816fe')) +# PulseChain Testnet V4 +PulseTestnetV4Setting = BaseChainSetting( + NETWORK_NAME=PULSECHAIN_TESTNET_V4, + GENESIS_FORK_VERSION=bytes.fromhex('00000943'), + GENESIS_VALIDATORS_ROOT=bytes.fromhex('d81664ba97279a6fa0832041b4aee6009172b4750a99467ff670a9faf3a34e64')) ALL_CHAINS: Dict[str, BaseChainSetting] = { MAINNET: MainnetSetting, @@ -40,6 +61,8 @@ ALL_CHAINS: Dict[str, BaseChainSetting] = { PRATER: GoerliSetting, # Prater is the old name of the Prater/Goerli testnet SEPOLIA: SepoliaSetting, ZHEJIANG: ZhejiangSetting, + PULSECHAIN_DEVNET: PulseDevnetSetting, + PULSECHAIN_TESTNET_V4: PulseTestnetV4Setting, } diff --git a/staking_deposit/utils/constants.py b/staking_deposit/utils/constants.py index cd64ecd..757b62b 100644 --- a/staking_deposit/utils/constants.py +++ b/staking_deposit/utils/constants.py @@ -16,6 +16,7 @@ ETH1_ADDRESS_WITHDRAWAL_PREFIX = bytes.fromhex('01') ETH2GWEI = 10 ** 9 MIN_DEPOSIT_AMOUNT = 2 ** 0 * ETH2GWEI MAX_DEPOSIT_AMOUNT = 2 ** 5 * ETH2GWEI +PULSECHAIN_MAX_DEPOSIT_AMOUNT = 2 ** 5 * 10 ** 15 # File/folder constants diff --git a/staking_deposit/utils/validation.py b/staking_deposit/utils/validation.py index ab6f984..f78c102 100644 --- a/staking_deposit/utils/validation.py +++ b/staking_deposit/utils/validation.py @@ -25,7 +25,6 @@ from staking_deposit.credentials import ( Credential, ) from staking_deposit.utils.constants import ( - MAX_DEPOSIT_AMOUNT, MIN_DEPOSIT_AMOUNT, BLS_WITHDRAWAL_PREFIX, ETH1_ADDRESS_WITHDRAWAL_PREFIX, @@ -85,7 +84,7 @@ def validate_deposit(deposit_data_dict: Dict[str, Any], credential: Credential) return False # Verify deposit amount - if not MIN_DEPOSIT_AMOUNT < amount <= MAX_DEPOSIT_AMOUNT: + if not MIN_DEPOSIT_AMOUNT < amount <= credential.chain_setting.MAX_DEPOSIT_AMOUNT: return False # Verify deposit signature && pubkey