diff --git a/0g-storage-contracts b/0g-storage-contracts index d466311..f816ade 160000 --- a/0g-storage-contracts +++ b/0g-storage-contracts @@ -1 +1 @@ -Subproject commit d466311abb6f629a6489450f2e684b2c6e7b1089 +Subproject commit f816ade101f590a2a4c8818c878e0d8432c08efa diff --git a/tests/mine_test.py b/tests/mine_test.py index 481727d..fa88690 100755 --- a/tests/mine_test.py +++ b/tests/mine_test.py @@ -15,6 +15,9 @@ class MineTest(TestFramework): "miner_id": MINER_ID, "miner_key": GENESIS_PRIV_KEY, } + self.mine_config = { + "init_rate": 8000 / 60, + } def submit_data(self, item, size): submissions_before = self.contract.num_submissions() @@ -34,9 +37,6 @@ class MineTest(TestFramework): self.log.info("flow address: %s", self.contract.address()) self.log.info("mine address: %s", self.mine_contract.address()) - quality = int(2**256 / 40960) - self.mine_contract.set_quality(quality) - self.log.info("Submit the first data chunk") self.submit_data(b"\x11", 2000) diff --git a/tests/mine_with_market_test.py b/tests/mine_with_market_test.py index 2bef35d..9345476 100755 --- a/tests/mine_with_market_test.py +++ b/tests/mine_with_market_test.py @@ -18,8 +18,11 @@ class MineTest(TestFramework): "miner_id": MINER_ID, "miner_key": GENESIS_PRIV_KEY, } - self.enable_market = True - self.mine_period = 150 + self.mine_config = { + "enable_market": True, + "mine_period": 150, + "init_rate": 800 / 60, + } def submit_data(self, item, size, no_submit = False): submissions_before = self.contract.num_submissions() @@ -41,9 +44,6 @@ class MineTest(TestFramework): self.log.info("flow address: %s", self.contract.address()) self.log.info("mine address: %s", self.mine_contract.address()) - quality = int(2**256 / 4096) - self.mine_contract.set_quality(quality) - SECTORS_PER_PRICING = int(8 * ( 2 ** 30 ) / 256) self.log.info("Submit the actual data chunk (256 MB)") diff --git a/tests/test_framework/blockchain_node.py b/tests/test_framework/blockchain_node.py index 8c0e79b..4f8cc30 100644 --- a/tests/test_framework/blockchain_node.py +++ b/tests/test_framework/blockchain_node.py @@ -248,9 +248,13 @@ class BlockchainNode(TestNode): def wait_for_transaction_receipt(self, w3, tx_hash, timeout=120, parent_hash=None): return w3.eth.wait_for_transaction_receipt(tx_hash, timeout) - def setup_contract(self, enable_market, mine_period): + def setup_contract(self, mine_config): w3 = Web3(HTTPProvider(self.rpc_url)) + enable_market = mine_config.get("enable_market", False) + mine_period = mine_config.get("mine_period", 100) + init_rate = int(mine_config.get("init_rate", 1024)) + account1 = w3.eth.account.from_key(GENESIS_PRIV_KEY) account2 = w3.eth.account.from_key(GENESIS_PRIV_KEY1) w3.middleware_onion.add( @@ -298,11 +302,11 @@ class BlockchainNode(TestNode): flow_contract, flow_contract_hash = deploy_contract("Flow", [book.address, mine_period, 0]) self.log.debug("Flow deployed") - mine_contract, _ = deploy_contract("PoraMineTest", [book.address, 3]) + mine_contract, _ = deploy_contract("PoraMine", [book.address, 1, 1, 7]) self.log.debug("Mine deployed") self.log.info("All contracts deployed") - tx_hash = mine_contract.functions.setMiner(decode_hex(MINER_ID)).transact(TX_PARAMS) + tx_hash = mine_contract.functions.registMiner(decode_hex(MINER_ID)).transact(TX_PARAMS) self.wait_for_transaction_receipt(w3, tx_hash) dummy_reward_contract = w3.eth.contract( @@ -324,14 +328,14 @@ class BlockchainNode(TestNode): book, _ = deploy_contract("AddressBook", [flowAddress, marketAddress, rewardAddress, mineAddress]); self.log.debug("AddressBook deployed") - mine_contract, _ = deploy_contract("PoraMineTest", [book.address, 3]) + mine_contract, _ = deploy_contract("PoraMine", [book.address, init_rate, 20, 3]) deploy_contract("FixedPrice", [book.address, LIFETIME_MONTH]) reward_contract, _ =deploy_contract("OnePoolReward", [book.address, LIFETIME_MONTH]) flow_contract, flow_contract_hash = deploy_contract("FixedPriceFlow", [book.address, mine_period, 0]) self.log.info("All contracts deployed") - tx_hash = mine_contract.functions.setMiner(decode_hex(MINER_ID)).transact(TX_PARAMS) + tx_hash = mine_contract.functions.registMiner(decode_hex(MINER_ID)).transact(TX_PARAMS) self.wait_for_transaction_receipt(w3, tx_hash) return flow_contract, flow_contract_hash, mine_contract, reward_contract diff --git a/tests/test_framework/contract_proxy.py b/tests/test_framework/contract_proxy.py index f898dd1..6eaf152 100644 --- a/tests/test_framework/contract_proxy.py +++ b/tests/test_framework/contract_proxy.py @@ -87,8 +87,8 @@ class MineContractProxy(ContractProxy): def last_mined_epoch(self, node_idx=0): return self._call("lastMinedEpoch", node_idx) - def set_quality(self, quality, node_idx=0): - return self._send("setQuality", node_idx, _targetQuality=quality) + # def set_quality(self, quality, node_idx=0): + # return self._send("setQuality", node_idx, _targetQuality=quality) diff --git a/tests/test_framework/test_framework.py b/tests/test_framework/test_framework.py index d5e94e3..228087b 100644 --- a/tests/test_framework/test_framework.py +++ b/tests/test_framework/test_framework.py @@ -46,8 +46,7 @@ class TestFramework: self.blockchain_node_configs = {} self.zgs_node_configs = {} self.blockchain_node_type = blockchain_node_type - self.enable_market = False - self.mine_period = 100 + self.mine_config = {} binary_ext = ".exe" if is_windows_platform() else "" tests_dir = os.path.dirname(__file_path__) @@ -140,7 +139,7 @@ class TestFramework: connect_sample_nodes(self.blockchain_nodes, self.log) sync_blocks(self.blockchain_nodes) - contract, tx_hash, mine_contract, reward_contract = self.blockchain_nodes[0].setup_contract(self.enable_market, self.mine_period) + contract, tx_hash, mine_contract, reward_contract = self.blockchain_nodes[0].setup_contract(self.mine_config) self.contract = FlowContractProxy(contract, self.blockchain_nodes) self.mine_contract = MineContractProxy(mine_contract, self.blockchain_nodes) self.reward_contract = IRewardContractProxy(reward_contract, self.blockchain_nodes)