respond to RFCs in PR #3315

pull/3322/head
Kieran Prasch 2023-10-30 17:33:40 +01:00 committed by KPrasch
parent 0c528eaa7a
commit 3bbc951ea5
5 changed files with 41 additions and 47 deletions

View File

@ -1,8 +1,9 @@
import time
from collections import defaultdict
from decimal import Decimal
from typing import DefaultDict, Dict, List, Optional, Set, Tuple, Union
import maya
import time
from decimal import Decimal
from eth_typing import ChecksumAddress
from hexbytes import HexBytes
from nucypher_core import (
@ -22,12 +23,10 @@ from nucypher_core.ferveo import (
Transcript,
Validator,
)
from typing import DefaultDict, Dict, List, Optional, Set, Tuple, Union
from web3 import HTTPProvider, Web3
from web3.types import TxReceipt
from nucypher.acumen.nicknames import Nickname
from nucypher.blockchain.eth import domains
from nucypher.blockchain.eth.agents import (
ContractAgency,
CoordinatorAgent,
@ -39,9 +38,7 @@ from nucypher.blockchain.eth.constants import NULL_ADDRESS
from nucypher.blockchain.eth.decorators import validate_checksum_address
from nucypher.blockchain.eth.domains import TACoDomain
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
from nucypher.blockchain.eth.registry import (
ContractRegistry,
)
from nucypher.blockchain.eth.registry import ContractRegistry
from nucypher.blockchain.eth.signers import Signer
from nucypher.blockchain.eth.trackers import dkg
from nucypher.blockchain.eth.trackers.bonding import OperatorBondedTracker

View File

@ -1,8 +1,9 @@
from pathlib import Path
from typing import ClassVar, Dict, List, Optional, Union
from constant_sorrow.constants import NO_NICKNAME, NO_SIGNING_POWER, STRANGER
from eth_utils import to_canonical_address
from nucypher_core.umbral import PublicKey
from pathlib import Path
from typing import ClassVar, Dict, List, Optional, Union
from nucypher.acumen.nicknames import Nickname
from nucypher.blockchain.eth import domains
@ -78,7 +79,6 @@ class Character(Learner):
represented by zero Characters or by more than one Character.
"""
self.domain = domains.get_domain(str(domain))
#
@ -128,11 +128,15 @@ class Character(Learner):
)
# Learner
Learner.__init__(self,
network_middleware=self.network_middleware,
node_class=known_node_class,
include_self_in_the_state=include_self_in_the_state,
*args, **kwargs)
Learner.__init__(
self,
domain=self.domain,
network_middleware=self.network_middleware,
node_class=known_node_class,
include_self_in_the_state=include_self_in_the_state,
*args,
**kwargs,
)
self.checksum_address = checksum_address

View File

@ -106,7 +106,7 @@ from nucypher.crypto.utils import keccak_digest
from nucypher.network.decryption import ThresholdDecryptionClient
from nucypher.network.exceptions import NodeSeemsToBeDown
from nucypher.network.middleware import RestMiddleware
from nucypher.network.nodes import TEACHER_NODES, NodeSprout, Teacher
from nucypher.network.nodes import NodeSprout, Teacher
from nucypher.network.protocols import parse_node_uri
from nucypher.network.retrieval import PRERetrievalClient
from nucypher.network.server import ProxyRESTServer, make_rest_app
@ -1177,17 +1177,6 @@ class Ursula(Teacher, Character, Operator):
seed_uri = f"{seednode_metadata.checksum_address}@{seednode_metadata.rest_host}:{seednode_metadata.rest_port}"
return cls.from_seed_and_stake_info(seed_uri=seed_uri, *args, **kwargs)
@classmethod
def seednode_for_domain(cls, domain: str, eth_endpoint: str) -> "Ursula":
"""Returns a default seednode ursula for a given network."""
try:
url = TEACHER_NODES[domain][0]
except KeyError:
raise ValueError(f'"{domain}" is not a known domain.')
except IndexError:
raise ValueError(f'No default seednodes available for "{domain}".')
ursula = cls.from_seed_and_stake_info(seed_uri=url, eth_endpoint=eth_endpoint)
return ursula
@classmethod
def from_teacher_uri(

View File

@ -1,6 +1,11 @@
import json
import re
from abc import ABC, abstractmethod
from decimal import Decimal
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Callable, List, Optional, Union
from constant_sorrow.constants import (
DEVELOPMENT_CONFIGURATION,
LIVE_CONFIGURATION,
@ -9,11 +14,7 @@ from constant_sorrow.constants import (
UNINITIALIZED_CONFIGURATION,
UNKNOWN_VERSION,
)
from decimal import Decimal
from eth_utils.address import is_checksum_address
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Callable, List, Optional, Union
from nucypher.blockchain.eth import domains
from nucypher.blockchain.eth.interfaces import BlockchainInterfaceFactory
@ -832,7 +833,7 @@ class CharacterConfiguration(BaseConfiguration):
if pre_payment_class.ONCHAIN:
# on-chain payment strategies require a blockchain connection
pre_payment_strategy = pre_payment_class(
domain=str(self.domain),
domain=self.domain,
blockchain_endpoint=self.polygon_endpoint,
registry=self.registry,
)

View File

@ -29,6 +29,7 @@ from nucypher.acumen.perception import FleetSensor
from nucypher.blockchain.eth import domains
from nucypher.blockchain.eth.agents import ContractAgency, TACoApplicationAgent
from nucypher.blockchain.eth.constants import NULL_ADDRESS
from nucypher.blockchain.eth.domains import TACoDomain
from nucypher.blockchain.eth.registry import ContractRegistry
from nucypher.config.constants import SeednodeMetadata
from nucypher.config.storages import ForgetfulNodeStorage
@ -250,22 +251,24 @@ class Learner:
it does not have the proper attributes for learning or verification.
"""
def __init__(self,
node_class: object = None,
network_middleware: RestMiddleware = None,
start_learning_now: bool = False,
learn_on_same_thread: bool = False,
known_nodes: tuple = None,
seed_nodes: Tuple[tuple] = None,
node_storage=None,
save_metadata: bool = False,
abort_on_learning_error: bool = False,
lonely: bool = False,
verify_node_bonding: bool = True,
include_self_in_the_state: bool = False,
) -> None:
def __init__(
self,
domain: TACoDomain,
node_class: object = None,
network_middleware: RestMiddleware = None,
start_learning_now: bool = False,
learn_on_same_thread: bool = False,
known_nodes: tuple = None,
seed_nodes: Tuple[tuple] = None,
node_storage=None,
save_metadata: bool = False,
abort_on_learning_error: bool = False,
lonely: bool = False,
verify_node_bonding: bool = True,
include_self_in_the_state: bool = False,
) -> None:
self.log = Logger("learning-loop") # type: Logger
self.domain = domain
self.learning_deferred = Deferred()
default_middleware = self.__DEFAULT_MIDDLEWARE_CLASS(