def convert_deposit_log_to_deposit_data(
        deposit_log: DepositLog) -> DepositData:
    return DepositData.create(
        pubkey=deposit_log.pubkey,
        withdrawal_credentials=deposit_log.withdrawal_credentials,
        amount=deposit_log.amount,
        signature=deposit_log.signature,
    )
Пример #2
0
 def _process_logs(self, logs: Sequence[DepositLog],
                   block_number: BlockNumber) -> None:
     """
     Store deposit data from the log in database, and increase the corresponding block's
     `deposit_count`.
     """
     seq_deposit_data = tuple(
         DepositData.create(
             pubkey=log.pubkey,
             withdrawal_credentials=log.withdrawal_credentials,
             amount=log.amount,
             signature=log.signature,
         ) for log in logs)
     self._db.add_deposit_data_batch(seq_deposit_data, block_number)
Пример #3
0
def create_mock_deposit_data(*,
                             config: Eth2Config,
                             pubkey: BLSPubkey,
                             privkey: int,
                             withdrawal_credentials: Hash32,
                             amount: Gwei = None) -> DepositData:
    if amount is None:
        amount = config.MAX_EFFECTIVE_BALANCE

    data = DepositData.create(pubkey=pubkey,
                              withdrawal_credentials=withdrawal_credentials,
                              amount=amount)
    signature = sign_proof_of_possession(deposit_data=data, privkey=privkey)
    return data.set("signature", signature)
Пример #4
0
def create_deposit_data(
    public_key: BLSPubkey,
    private_key: int,
    withdrawal_credentials: Hash32,
    amount: Gwei,
) -> DepositData:
    message = DepositMessage.create(
        pubkey=public_key, withdrawal_credentials=withdrawal_credentials, amount=amount
    )
    signature = sign_proof_of_possession(deposit_message=message, privkey=private_key)
    return DepositData.create(
        pubkey=public_key,
        withdrawal_credentials=withdrawal_credentials,
        amount=amount,
        signature=signature,
    )
Пример #5
0
def sample_deposit_params(sample_deposit_data_params, deposit_contract_tree_depth):
    return {
        "proof": (b"\x22" * 32,) * (deposit_contract_tree_depth + 1),
        "data": DepositData.create(**sample_deposit_data_params),
    }
Пример #6
0
def test_defaults(sample_deposit_data_params):
    deposit_data = DepositData.create(**sample_deposit_data_params)

    assert deposit_data.pubkey == sample_deposit_data_params["pubkey"]
    assert deposit_data.amount == sample_deposit_data_params["amount"]