mirror of
https://gitlab.com/pulsechaincom/staking-deposit-cli.git
synced 2025-01-03 01:27:39 +00:00
Add support for PulseChain
This commit is contained in:
parent
d7b530442d
commit
e371434a3c
@ -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
|
||||
|
2
Makefile
2
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"
|
||||
|
@ -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()
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user