Skip to content

Commit

Permalink
feat: Add LUKSO network support
Browse files Browse the repository at this point in the history
  • Loading branch information
richtera committed Dec 2, 2022
1 parent cf57d55 commit 4b8acfe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
14 changes: 10 additions & 4 deletions staking_deposit/cli/generate_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
)
from staking_deposit.settings import (
ALL_CHAINS,
MAINNET,
LUKSO,
PRATER,
get_chain_setting,
)
Expand Down Expand Up @@ -83,7 +83,7 @@ def generate_keys_arguments_decorator(function: Callable[..., Any]) -> Callable[
list(ALL_CHAINS.keys())
),
),
default=MAINNET,
default=LUKSO,
help=lambda: load_text(['chain', 'help'], func='generate_keys_arguments_decorator'),
param_decls='--chain',
prompt=choice_prompt_func(
Expand Down Expand Up @@ -111,6 +111,12 @@ def generate_keys_arguments_decorator(function: Callable[..., Any]) -> Callable[
help=lambda: load_text(['eth1_withdrawal_address', 'help'], func='generate_keys_arguments_decorator'),
param_decls='--eth1_withdrawal_address',
),
jit_option(
callback=lambda ctx,param,x: int(x),
default=MAX_DEPOSIT_AMOUNT,
help=('Amount to use in all deposit data files.'),
param_decls='--amount',
),
]
for decorator in reversed(decorators):
function = decorator(function)
Expand All @@ -121,10 +127,10 @@ def generate_keys_arguments_decorator(function: Callable[..., Any]) -> Callable[
@click.pass_context
def generate_keys(ctx: click.Context, validator_start_index: int,
num_validators: int, folder: str, chain: str, keystore_password: str,
eth1_withdrawal_address: HexAddress, **kwargs: Any) -> None:
amount: int, eth1_withdrawal_address: HexAddress, **kwargs: Any) -> None:
mnemonic = ctx.obj['mnemonic']
mnemonic_password = ctx.obj['mnemonic_password']
amounts = [MAX_DEPOSIT_AMOUNT] * num_validators
amounts = [amount] * num_validators
folder = os.path.join(folder, DEFAULT_VALIDATOR_KEYS_FOLDER_NAME)
chain_setting = get_chain_setting(chain)
if not os.path.exists(folder):
Expand Down
30 changes: 22 additions & 8 deletions staking_deposit/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,41 @@ class BaseChainSetting(NamedTuple):
GENESIS_FORK_VERSION: bytes


MAINNET = 'mainnet'
LUKSO = 'lukso'
LUKSO_L16 = 'l16'
MAINNET = 'ethereum'
ROPSTEN = 'ropsten'
GOERLI = 'goerli'
PRATER = 'prater'
KILN = 'kiln'
SEPOLIA = 'sepolia'


# Mainnet setting
MainnetSetting = BaseChainSetting(NETWORK_NAME=MAINNET, GENESIS_FORK_VERSION=bytes.fromhex('00000000'))
# LUKSO mainnet setting
LUKSOSetting = BaseChainSetting(
NETWORK_NAME=LUKSO, GENESIS_FORK_VERSION=bytes.fromhex('38380001'))
# LUKSO L16 testnet setting
LUKSOL16Setting = BaseChainSetting(
NETWORK_NAME=LUKSO_L16, GENESIS_FORK_VERSION=bytes.fromhex('60000069'))
# Ethereum Mainnet setting
MainnetSetting = BaseChainSetting(
NETWORK_NAME=MAINNET, GENESIS_FORK_VERSION=bytes.fromhex('00000000'))
# Ropsten setting
RopstenSetting = BaseChainSetting(NETWORK_NAME=ROPSTEN, GENESIS_FORK_VERSION=bytes.fromhex('80000069'))
RopstenSetting = BaseChainSetting(
NETWORK_NAME=ROPSTEN, GENESIS_FORK_VERSION=bytes.fromhex('80000069'))
# Goerli setting
GoerliSetting = BaseChainSetting(NETWORK_NAME=GOERLI, GENESIS_FORK_VERSION=bytes.fromhex('00001020'))
GoerliSetting = BaseChainSetting(
NETWORK_NAME=GOERLI, GENESIS_FORK_VERSION=bytes.fromhex('00001020'))
# Merge Testnet (spec v1.1.9)
KilnSetting = BaseChainSetting(NETWORK_NAME=KILN, GENESIS_FORK_VERSION=bytes.fromhex('70000069'))
KilnSetting = BaseChainSetting(
NETWORK_NAME=KILN, GENESIS_FORK_VERSION=bytes.fromhex('70000069'))
# Sepolia setting
SepoliaSetting = BaseChainSetting(NETWORK_NAME=SEPOLIA, GENESIS_FORK_VERSION=bytes.fromhex('90000069'))

SepoliaSetting = BaseChainSetting(
NETWORK_NAME=SEPOLIA, GENESIS_FORK_VERSION=bytes.fromhex('90000069'))

ALL_CHAINS: Dict[str, BaseChainSetting] = {
LUKSO: LUKSOSetting, # Due to change when mainnet is launched
LUKSO_L16: LUKSOL16Setting,
MAINNET: MainnetSetting,
ROPSTEN: RopstenSetting,
GOERLI: GoerliSetting,
Expand Down

0 comments on commit 4b8acfe

Please sign in to comment.