def __init__(self, params: Parameter):
        self.tag = util.tag_from_path(__file__, self.__class__.__name__)
        self.params = params
        self.password = params.ela_params.password
        self.key_message_saved_dir = ""
        self.stables_path = ""

        self.special_accounts = list()
        self.owner_accounts = list()
        self.node_accounts = list()
        self.arbiter_accounts = list()
        self.origin_arbiter_accounts = list()
        self.sub1_accounts = list()
        self.sub2_accounts = list()
        self.sub3_accounts = list()
        self.sub4_accounts = list()
        self.category_dict = dict()
        self.crc_public_keys = list()

        self._init_category_dict()

        self._init_key_stores()

        self.foundation_account = self.special_accounts[self.INDEX_FOUNDATION]
        self.main_miner_account = self.special_accounts[self.INDEX_MAIN_MINER]
        self.side_miner_account = self.special_accounts[self.INDEX_SIDE_MINER]
        self.tap_account = self.special_accounts[self.INDEX_TAP]
        self.cross_did_account = self.special_accounts[self.INDEX_CROSS_DID]
        self.cross_token_account = self.special_accounts[
            self.INDEX_CROSS_TOKEN]
        self.cross_neo_account = self.special_accounts[self.INDEX_CROSS_NEO1]
        self.cross_eth_account = self.special_accounts[self.INDEX_CROSS_ETH]

        self._gen_crc_pubkeys()
    def __init__(self):
        self.tag = util.tag_from_path(__file__, self.__class__.__name__)
        self.home_path = self.get_env_path("HOME")
        self.go_path = self.get_env_path("GOPATH")
        print("go path: ", self.go_path)
        self.elastos_path = os.path.join(self.go_path,
                                         "src/github.com/elastos")
        print("elastos path: ", self.elastos_path)
        self.test_path = os.path.join(self.home_path, "TestingWork")
        self.current_date_time = time.strftime('%Y-%m-%d_%H:%M:%S',
                                               time.localtime())

        self.src_path_dict = {
            "ela": "Elastos.ELA",
            "arbiter": "Elastos.ELA.Arbiter",
            "did": "Elastos.ELA.SideChain.ID",
            "token": "Elastos.ELA.SideChain.Token",
            "neo": "Elastos.ELA.SideChain.NeoVM"
        }

        self.config_dict = {
            "ela": Parameter.default_ela_config(),
            "arbiter": Parameter.default_arbiter_config(),
            "did": Parameter.default_did_config(),
            "token": Parameter.default_token_config(),
            "neo": Parameter.default_neo_config()
        }
Exemplo n.º 3
0
    def __init__(self, params: Parameter, env_manager: EnvManager,
                 keystore_manager: KeyStoreManager):
        self.tag = util.tag_from_path(__file__, self.__class__.__name__)
        self.params = params
        self.env_manager = env_manager
        self.keystore_manager = keystore_manager
        self.log_file_path = ""
        self.ela_nodes = []
        self.later_start_nodes = []
        self.arbiter_nodes = []
        self.did_nodes = []
        self.token_nodes = []
        self.neo_nodes = []
        self.eth_nodes = []
        self.address_name_dict = dict()
        self.owner_pubkey_name_dict = dict()
        self.node_pubkey_name_dict = dict()

        self.foundation_address = self.keystore_manager.foundation_account.address(
        )
        self.main_miner_address = self.keystore_manager.main_miner_account.address(
        )
        self.side_miner_address = self.keystore_manager.side_miner_account.address(
        )
        self.tap_address = self.keystore_manager.tap_account.address()
        self.nodes_dict = {
            "ela": self.ela_nodes,
            "arbiter": self.arbiter_nodes,
            "did": self.did_nodes,
            "token": self.token_nodes,
            "neo": self.neo_nodes,
            "geth": self.eth_nodes
        }
Exemplo n.º 4
0
 def __init__(self, port: int):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.fee = 10000
     self.rpc_port = port
     self.register_cr_list = list()
     self.cancel_producers_list = list()
     self.crc_proposal_list = list()
    def __init__(self, up_config: dict):
        self.tag = util.tag_from_path(__file__, Controller.__name__)

        # set config
        self.up_config = up_config
        self.root_path = os.path.abspath(
            os.path.join(os.path.abspath(__file__), "../../../"))
        self.config = util.read_config_file(
            os.path.join(self.root_path, "config.json"))
        self.node_types = ["ela", "arbiter", "did", "token", "neo", "geth"]
        self.reset_config(up_config)

        self.params = Parameter(self.config, self.root_path)
        self.check_params()
        self.env_manager = EnvManager()
        self.keystore_manager = KeyStoreManager(self.params)

        self.node_manager = NodeManager(self.params, self.env_manager,
                                        self.keystore_manager)
        self.tx_manager = TransactionManager(self.node_manager)
        # init tap amount and register amount(unit: ELA)
        self.tap_amount = 20000000
        self.register_amount = 6000
        self.node_amount = 5000
        self.backup_amount = 5000
        # necessary keystore
        self.foundation_account = self.keystore_manager.foundation_account
        self.tap_account = self.keystore_manager.tap_account

        self.init_for_testing()
        self.later_nodes = self.node_manager.ela_nodes[(
            self.params.ela_params.number -
            self.params.ela_params.later_start_number + 1):]

        self.dpos_votes_dict = dict()
Exemplo n.º 6
0
 def __init__(self, config: dict):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.magic = constant.CONFIG_MAGIC_DID
     self.spv_magic = constant.CONFIG_MAGIC_ELA
     self.enable = config["enable"]
     self.number = config["number"]
     # self.genesis_hash = "2a10656cef15a9e86ff8ec37302237c2a1472ddb74c5ba5fd80956dc8d7aca94"
     self.genesis_hash = "ccc2729da527d3473828d3d1e888456db79145ef26d451755e401f6d763f2b79"
Exemplo n.º 7
0
 def __init__(self, config, root_path):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.top_config = config
     self.root_path = root_path
     self.ela_params = ElaParams(config["ela"])
     self.arbiter_params = ArbiterParams(config["arbiter"], self.ela_params)
     self.did_params = DidParams(config["did"])
     self.token_params = TokenParams(config["token"])
     self.neo_params = NeoParams(config["neo"])
     self.eth_params = EthParams(config["geth"])
     self.check_params()
Exemplo n.º 8
0
 def __init__(self, index, config, params: TokenParams, keystore_manager: KeyStoreManager, cwd_dir: str):
     Node.__init__(self, config)
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.index = index
     self.params = params
     self.keystore_manager = keystore_manager
     self.cwd_dir = cwd_dir
     self.rpc_port = self.reset_port(index, "token", "json_port")
     self.err_output = open(os.path.join(self.cwd_dir, "error.log"), 'w')
     self.process = None
     self.running = False
    def __init__(self, node_manager: NodeManager):
        self.tag = util.tag_from_path(__file__, self.__class__.__name__)
        self.node_manager = node_manager
        self.params = self.node_manager.params
        self.fee = 10000
        self.rpc_port = rpc.DEFAULT_PORT
        self.register_producers_list = list()
        self.cancel_producers_list = list()

        self.tap_account = self.node_manager.keystore_manager.tap_account
        self.backup_accounts = self.node_manager.keystore_manager.backup_accounts
Exemplo n.º 10
0
 def __init__(self, password: str, ecc_key=None):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.password = password
     self.private_key = None
     self.ecc_public_key = None
     self.public_key = None
     self.sign_script = None
     self.program_hash = None
     self.address = None
     self.create_keystore(ecc_key)
     self.keystore_dat = self.gen_keystore_dat(self.password)
Exemplo n.º 11
0
 def __init__(self, config: dict):
     self.tag = util.tag_from_path(__file__, TxControl.__name__)
     self._init_config(config)
     self.tap_account = Account(private_key_str=self.tap_private_key)
     self.pressure_account = Account(
         private_key_str=self.pressure_private_key)
     self.register_amount = 6000
     self.node_amount = 5000
     self.dpos_votes_dict = dict()
     self.producers_list = list()
     self.cr_list = list()
     self.tx_manager = TxManager(self.rpc_port)
Exemplo n.º 12
0
 def __init__(self, private_key: bytes, owner_public_key: bytes,
              node_public_key: bytes, nickname: str, url: str,
              location: int, net_address: str):
     Payload.__init__(self, self.DEFAULT_VERSION)
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.private_key = private_key
     self.owner_public_key = owner_public_key
     self.node_public_key = node_public_key
     self.nickname = nickname
     self.url = url
     self.location = location
     self.net_address = net_address
     self.signature = self.gen_signature()
Exemplo n.º 13
0
 def __init__(self, config: dict):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.magic = constant.CONFIG_MAGIC_NEO
     self.spv_magic = constant.CONFIG_MAGIC_ELA
     self.enable = config["enable"]
     self.number = config["number"]
     self.active_net = config["active_net"]
     self.instant_block = config["instant_block"]
     self.mining_enable = config["mining_enable"]
     self.disable_dns = config["disable_dns"]
     self.log_level = config["log_level"]
     self.spv_disable_dns = config["spv_disable_dns"]
     self.rest_port_enable = config["rest_port_enable"]
     self.ws_port_enable = config["ws_port_enable"]
     self.rpc_port_enable = config["rpc_port_enable"]
 def __init__(self, config: dict):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.magic = constant.CONFIG_MAGIC_ELA
     self.enable = config["enable"]
     self.arbiter_enable = config["arbiter_enable"]
     self.number = config["number"]
     self.password = config["password"]
     self.crc_number = config["crc_number"]
     self.active_net = config["active_net"]
     self.later_start_number = config["later_start_number"]
     self.disable_dns = config["disable_dns"]
     self.ip_address = config["ip_address"]
     self.print_level = config["print_level"]
     self.auto_mining = config["auto_mining"]
     self.instant_block = config["instant_block"]
     self.pre_connect_offset = config["pre_connect_offset"]
     self.check_address_height = config["check_address_height"]
     self.vote_start_height = config["vote_start_height"]
     self.crc_dpos_height = config["crc_dpos_height"]
     self.public_dpos_height = config["public_dpos_height"]
     self.max_inactivate_rounds = config["max_inactivate_rounds"]
     self.inactive_penalty = config["inactive_penalty"]
     self.emergency_inactive_penalty = config["emergency_inactive_penalty"]
     self.cr_check_reward_height = config["cr_check_reward_height"]
     self.cr_voting_start_height = config["cr_voting_start_height"]
     self.cr_committee_start_height = config["cr_committee_start_height"]
     self.member_count = config["member_count"]
     self.cr_voting_period = config["cr_voting_period"]
     self.cr_duty_period = config["cr_duty_period"]
     self.max_node_per_host = config["max_node_per_host"]
     self.voting_period = config["voting_period"]
     self.duty_period = config["duty_period"]
     self.deposit_lockup_blocks = config["deposit_lockup_blocks"]
     self.crc_appropriate_percentage = config["crc_appropriate_percentage"]
     self.max_committee_proposal_count = config[
         "max_committee_proposal_count"]
     self.max_proposal_tracking_count = config[
         "max_proposal_tracking_count"]
     self.proposal_cr_voting_period = config["proposal_cr_voting_period"]
     self.proposal_public_voting_period = config[
         "proposal_public_voting_period"]
     self.cr_agreement_count = config["cr_agreement_count"]
     self.voter_reject_percentage = config["voter_reject_percentage"]
     self.register_cr_by_did_height = config["register_cr_by_did_height"]
     self.cr_claim_dpos_node_start_height = config[
         "cr_claim_dpos_node_start_height"]
Exemplo n.º 15
0
 def __init__(self, config: dict, ela_params: ElaParams):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.magic = constant.CONFIG_MAGIC_ARBITER
     self.spv_magic = constant.CONFIG_MAGIC_ELA
     self.enable = config["enable"]
     self.number = config["number"]
     self.active_net = config["active_net"]
     self.pow_chain = config["pow_chain"]
     self.print_level = config["print_level"]
     self.spv_print_level = config["spv_print_level"]
     self.crc_number = ela_params.crc_number
     self.crc_dpos_only_height = ela_params.crc_dpos_height
     self.side_chain_genesis_hash = ""
     self.recharge_address = ""
     self.withdraw_address = ""
     self.side_info = dict()
     self.password = ela_params.password
Exemplo n.º 16
0
 def __init__(self, index: int, config, params: ElaParams, keystore_manager: KeyStoreManager,
              cwd_dir: str, ela_type: str):
     Node.__init__(self, config)
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.index = index
     self.params = params
     self.keystore_manager = keystore_manager
     self.name = ""
     self.type = ela_type
     self.owner_account = keystore_manager.owner_accounts[self.index]
     self.node_account = keystore_manager.node_accounts[self.index]
     self.cwd_dir = cwd_dir
     self.password = self.params.password
     self.rpc_port = self.reset_port(self.index, "ela", "json_port")
     self.arbiter_node_port = self.reset_port(self.index, "ela", "arbiter_node_port")
     self.err_output = open(os.path.join(self.cwd_dir, "error.log"), 'w')
     self.arbiter_enable = False
     self.process = None
     self.running = False
     self.set_name()
Exemplo n.º 17
0
    def __init__(self, config):
        self.tag = util.tag_from_path(__file__, self.__class__.__name__)
        self.config = config
        self.dev_null = open(os.devnull, 'w')

        self.node_type_dict = {
            "ela": 10,
            "arbiter": 20,
            "did": 30,
            "token": 40,
            "neo": 50
        }

        self.port_type_dict = {
            "info_port": 3,
            "rest_port": 4,
            "ws_port": 5,
            "json_port": 6,
            "node_port": 8,
            "arbiter_node_port": 9
        }
Exemplo n.º 18
0
 def __init__(self, config: dict):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.magic = constant.CONFIG_MAGIC_ELA
     self.enable = config["enable"]
     self.arbiter_enable = config["arbiter_enable"]
     self.number = config["number"]
     self.password = config["password"]
     self.crc_number = config["crc_number"]
     self.active_net = config["active_net"]
     self.later_start_number = config["later_start_number"]
     self.disable_dns = config["disable_dns"]
     self.ip_address = config["ip_address"]
     self.print_level = config["print_level"]
     self.auto_mining = config["auto_mining"]
     self.min_cross_fee = config["min_cross_fee"]
     self.instant_block = config["instant_block"]
     self.pre_connect_offset = config["pre_connect_offset"]
     self.check_address_height = config["check_address_height"]
     self.vote_start_height = config["vote_start_height"]
     self.crc_dpos_height = config["crc_dpos_height"]
     self.public_dpos_height = config["public_dpos_height"]
     self.max_inactivate_rounds = config["max_inactivate_rounds"]
     self.inactive_penalty = config["inactive_penalty"]
     self.emergency_inactive_penalty = config["emergency_inactive_penalty"]
Exemplo n.º 19
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# date: 2019/1/23 2:38 PM
# author: liteng

import requests
from requests.adapters import HTTPAdapter
from urllib3 import Retry

from src.tools import util
from src.tools.log import Logger

tag = util.tag_from_path(__file__, "")


def get_request(url):
    try:
        Logger.debug("{} get request url: {}".format(tag, url))
        response = requests.get(url)
        resp = response.json()
        if resp["Desc"] == "Success":
            return resp["Result"]
        else:
            return None
    except requests.exceptions.RequestException as e:
        Logger.error("{} get request error: {}".format(tag, e))
        return False


def post_request(url, method, params):
    try:
 def __init__(self, vote_type: int, candidates: list):
     self.tag = util.tag_from_path(__file__, VoteContent.__name__)
     self.vote_type = vote_type
     self.candidates = candidates
Exemplo n.º 21
0
 def __init__(self, version: int, vote_contents: list):
     self.tag = util.tag_from_path(__file__, VoteInfo.__name__)
     self.version = version
     self.contents = vote_contents
Exemplo n.º 22
0
 def __init__(self):
     self.tag = util.tag_from_path(__file__, self.__class__.__name__)
     self.host = "http://127.0.0.1"
     self.port = 10012