How to use the raiden.exceptions.RaidenUnrecoverableError function in raiden

To help you get started, we’ve selected a few raiden examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raiden-network / raiden / raiden / network / proxies / token_network_registry.py View on Github external
)

            if settlement_timeout_min == 0:
                raise RaidenUnrecoverableError(
                    "The minimum settlement timeout for the token network "
                    "should be larger than zero."
                )

            if settlement_timeout_min == 0:
                raise RaidenUnrecoverableError(
                    "The minimum settlement timeout for the token network "
                    "should be larger than zero."
                )

            if settlement_timeout_max <= settlement_timeout_min:
                raise RaidenUnrecoverableError(
                    "The maximum settlement timeout for the token network "
                    "should be larger than the minimum settlement timeout."
                )

            if self.get_token_network(token_address, failed_at_blocknumber):
                raise RaidenRecoverableError("Token already registered")

            # At this point, the TokenNetworkRegistry fails to instantiate
            # a new TokenNetwork.
            raise RaidenUnrecoverableError("createERC20TokenNetwork failed for an unknown reason")
        return token_network_address
github raiden-network / raiden / raiden / network / proxies / token_network.py View on Github external
if expiration_block <= given_block_number:
                    msg = (
                        f"The current block number {given_block_number} is "
                        f"already at expiration block {expiration_block} or "
                        "later."
                    )
                    raise BrokenPreconditionError(msg)

                if participant_signature == EMPTY_SIGNATURE:
                    msg = "set_total_withdraw requires a valid participant signature"
                    raise RaidenUnrecoverableError(msg)

                if partner_signature == EMPTY_SIGNATURE:
                    msg = "set_total_withdraw requires a valid partner signature"
                    raise RaidenUnrecoverableError(msg)

                canonical_identifier = CanonicalIdentifier(
                    chain_identifier=self.proxy.contract.functions.chain_id().call(),
                    token_network_address=self.address,
                    channel_identifier=channel_identifier,
                )
                participant_signed_data = pack_withdraw(
                    participant=participant,
                    total_withdraw=total_withdraw,
                    canonical_identifier=canonical_identifier,
                    expiration_block=expiration_block,
                )
                try:
                    participant_recovered_address = recover(
                        data=participant_signed_data, signature=participant_signature
                    )
github raiden-network / raiden / raiden / network / proxies / token_network.py View on Github external
partner=receiver,
                block_identifier=failed_at_blockhash,
            )

            if detail.state < ChannelState.SETTLED:
                msg = (
                    f"cannot call unlock on a channel that has not been settled yet. "
                    f"current_state={detail.state}"
                )
                raise RaidenUnrecoverableError(msg)

            is_unlock_done = sender_details.locksroot == LOCKSROOT_OF_NO_LOCKS
            if is_unlock_done:
                raise RaidenRecoverableError("The locks are already unlocked ")

            raise RaidenUnrecoverableError("unlock failed for an unknown reason")
github raiden-network / raiden / raiden / storage / restore.py View on Github external
storage=raiden.wal.storage,
        state_change_identifier=state_change_identifier,
        node_address=raiden.address,
    )

    msg = "There is a state change, therefore the state must not be None"
    assert wal.state_manager.current_state is not None, msg

    chain_state = wal.state_manager.current_state

    channel_state = views.get_channelstate_by_canonical_identifier(
        chain_state=chain_state, canonical_identifier=canonical_identifier
    )

    if not channel_state:
        raise RaidenUnrecoverableError(
            f"Channel was not found before state_change {state_change_identifier}"
        )

    return channel_state
github raiden-network / raiden / raiden / network / proxies / token_network.py View on Github external
def update_transfer(
        self,
        channel_identifier: ChannelID,
        partner: Address,
        balance_hash: BalanceHash,
        nonce: Nonce,
        additional_hash: AdditionalHash,
        closing_signature: Signature,
        non_closing_signature: Signature,
        given_block_identifier: BlockSpecification,
    ) -> None:
        if balance_hash is EMPTY_HASH:
            raise RaidenUnrecoverableError("update_transfer called with an empty balance_hash")

        if nonce <= 0 or nonce > UINT256_MAX:
            raise RaidenUnrecoverableError("update_transfer called with an invalid nonce")

        canonical_identifier = CanonicalIdentifier(
            chain_identifier=self.proxy.contract.functions.chain_id().call(),
            token_network_address=self.address,
            channel_identifier=channel_identifier,
        )

        partner_signed_data = pack_balance_proof(
            nonce=nonce,
            balance_hash=balance_hash,
            additional_hash=additional_hash,
            canonical_identifier=canonical_identifier,
        )
github raiden-network / raiden / raiden / network / proxies / token_network.py View on Github external
chain_identifier=self.proxy.contract.functions.chain_id().call(),
                    token_network_address=self.address,
                    channel_identifier=channel_identifier,
                )
                participant_signed_data = pack_withdraw(
                    participant=participant,
                    total_withdraw=total_withdraw,
                    canonical_identifier=canonical_identifier,
                    expiration_block=expiration_block,
                )
                try:
                    participant_recovered_address = recover(
                        data=participant_signed_data, signature=participant_signature
                    )
                except Exception:  # pylint: disable=broad-except
                    raise RaidenUnrecoverableError(
                        "Couldn't verify the participant withdraw signature"
                    )
                else:
                    if participant_recovered_address != participant:
                        raise RaidenUnrecoverableError("Invalid withdraw participant signature")

                partner_signed_data = pack_withdraw(
                    participant=participant,
                    total_withdraw=total_withdraw,
                    canonical_identifier=canonical_identifier,
                    expiration_block=expiration_block,
                )
                try:
                    partner_recovered_address = recover(
                        data=partner_signed_data, signature=partner_signature
                    )
github raiden-network / raiden / raiden / raiden_service.py View on Github external
(
                state_change_qty_snapshot,
                state_change_qty_pending,
                restore_wal,
            ) = wal.restore_to_state_change(
                transition_function=node.state_transition,
                storage=storage,
                state_change_identifier=sqlite.HIGH_STATECHANGE_ULID,
                node_address=self.address,
            )

            self.wal = restore_wal
            self.state_change_qty_snapshot = state_change_qty_snapshot
            self.state_change_qty = state_change_qty_snapshot + state_change_qty_pending
        except SerializationError:
            raise RaidenUnrecoverableError(
                "Could not restore state. "
                "It seems like the existing database is incompatible with "
                "the current version of Raiden. Consider using a stable "
                "version of the Raiden client."
            )

        if self.wal.state_manager.current_state is None:
            print(
                "This is the first time Raiden is being used with this address. "
                "Processing all the events may take some time. Please wait ..."
            )
            log.debug(
                "No recoverable state available, creating initial state.",
                node=to_checksum_address(self.address),
            )
github raiden-network / raiden / raiden / network / proxies / token_network.py View on Github external
# channel.

            if channel_onchain_detail.state != ChannelState.CLOSED:
                msg = (
                    f"The channel was not closed at the provided block "
                    f"({given_block_identifier}). This call should never have "
                    f"been attempted."
                )
                raise RaidenUnrecoverableError(msg)

            if channel_onchain_detail.settle_block_number < given_block_number:
                msg = (
                    "update transfer cannot be called after the settlement "
                    "period, this call should never have been attempted."
                )
                raise RaidenUnrecoverableError(msg)

            if closer_details.nonce == nonce:
                msg = (
                    "update transfer was already done, this call should never "
                    "have been attempted."
                )
                raise RaidenRecoverableError(msg)

        log_details = {
            "contract": to_checksum_address(self.address),
            "node": to_checksum_address(self.node_address),
            "partner": to_checksum_address(partner),
            "nonce": nonce,
            "balance_hash": encode_hex(balance_hash),
            "additional_hash": encode_hex(additional_hash),
            "closing_signature": encode_hex(closing_signature),
github raiden-network / raiden / raiden / network / proxies / token_network.py View on Github external
# If `given_block_identifier` has been pruned the checks cannot be
            # performed.
            pass
        except BadFunctionCallOutput:
            raise_on_call_returned_empty(given_block_identifier)
        else:
            onchain_channel_identifier = channel_onchain_detail.channel_identifier
            if onchain_channel_identifier != channel_identifier:
                msg = (
                    f"The provided channel identifier does not match the value "
                    f"on-chain at the provided block ({given_block_identifier}). "
                    f"This call should never have been attempted. "
                    f"provided_channel_identifier={channel_identifier}, "
                    f"onchain_channel_identifier={channel_onchain_detail.channel_identifier}"
                )
                raise RaidenUnrecoverableError(msg)

            if channel_onchain_detail.state != ChannelState.OPENED:
                msg = (
                    f"The channel was not open at the provided block "
                    f"({given_block_identifier}). This call should never have "
                    f"been attempted."
                )
                raise RaidenUnrecoverableError(msg)

        log_details = {
            "node": to_checksum_address(self.node_address),
            "contract": to_checksum_address(self.address),
            "partner": to_checksum_address(partner),
            "nonce": nonce,
            "balance_hash": encode_hex(balance_hash),
            "additional_hash": encode_hex(additional_hash),