github.com/platonnetwork/platon-go@v0.7.6/cases/tests/ppos/test_punishment_related.py (about)

     1  import time
     2  import pytest
     3  import rlp
     4  
     5  from common.key import mock_duplicate_sign, generate_key
     6  from common.log import log
     7  from tests.lib import (
     8      EconomicConfig,
     9      StakingConfig,
    10      check_node_in_list,
    11      assert_code, von_amount,
    12      get_governable_parameter_value,
    13      Client,
    14      update_param_by_dict,
    15      get_param_by_dict,
    16      get_the_dynamic_parameter_gas_fee
    17      )
    18  
    19  
    20  def penalty_proportion_and_income(client):
    21      # view Pledge amount
    22      candidate_info1 = client.ppos.getCandidateInfo(client.node.node_id)
    23      pledge_amount1 = candidate_info1['Ret']['Released']
    24      # view Parameter value before treatment
    25      penalty_ratio = get_governable_parameter_value(client, 'slashFractionDuplicateSign')
    26      proportion_ratio = get_governable_parameter_value(client, 'duplicateSignReportReward')
    27      return pledge_amount1, int(penalty_ratio), int(proportion_ratio)
    28  
    29  
    30  def verification_duplicate_sign(client, evidence_type, reporting_type, report_address, report_block):
    31      if report_block < 41:
    32          report_block = 41
    33      # Obtain evidence of violation
    34      report_information = mock_duplicate_sign(evidence_type, client.node.nodekey,
    35                                               client.node.blsprikey,
    36                                               report_block)
    37      log.info("Report information: {}".format(report_information))
    38      result = client.duplicatesign.reportDuplicateSign(reporting_type, report_information, report_address)
    39      return result
    40  
    41  
    42  @pytest.mark.P0
    43  @pytest.mark.parametrize('repor_type', [1, 2, 3])
    44  def test_VP_PV_001_to_003(client_consensus, repor_type, reset_environment):
    45      """
    46      举报验证人区块双签:VP_PV_001 prepareBlock类型
    47                      VP_PV_002 prepareVote类型
    48                      VP_PV_003 viewChange类型
    49      :param client_consensus:
    50      :param repor_type:
    51      :param reset_environment:
    52      :return:
    53      """
    54      client = client_consensus
    55      economic = client.economic
    56      node = client.node
    57      client.economic.env.deploy_all()
    58      # Obtain penalty proportion and income
    59      pledge_amount1, penalty_ratio, proportion_ratio = penalty_proportion_and_income(client)
    60      # create report address
    61      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
    62      # view report amount
    63      report_amount1 = node.eth.getBalance(report_address)
    64      log.info("report account amount:{} ".format(report_amount1))
    65      # view Incentive pool account
    66      incentive_pool_account1 = node.eth.getBalance(EconomicConfig.INCENTIVEPOOL_ADDRESS)
    67      log.info("incentive pool account1 amount:{} ".format(incentive_pool_account1))
    68      # Wait for the consensus round to end
    69      economic.wait_consensus_blocknum(node)
    70      # Get current block height
    71      current_block = node.eth.blockNumber
    72      log.info("Current block height: {}".format(current_block))
    73      result = verification_duplicate_sign(client, repor_type, repor_type, report_address, current_block)
    74      assert_code(result, 0)
    75      # view Amount of penalty
    76      proportion_reward, incentive_pool_reward = economic.get_report_reward(pledge_amount1, penalty_ratio,
    77                                                                            proportion_ratio)
    78      # view report amount again
    79      report_amount2 = node.eth.getBalance(report_address)
    80      log.info("report account amount:{} ".format(report_amount2))
    81      # view Incentive pool account again
    82      incentive_pool_account2 = node.eth.getBalance(EconomicConfig.INCENTIVEPOOL_ADDRESS)
    83      log.info("incentive pool account1 amount:{} ".format(incentive_pool_account2))
    84      # assert account reward
    85      assert report_amount1 + proportion_reward - report_amount2 < node.web3.toWei(1,
    86                                                                                   'ether'), "ErrMsg:report amount {}".format(
    87          report_amount2)
    88      assert incentive_pool_account2 == incentive_pool_account1 + incentive_pool_reward + (
    89          report_amount1 + proportion_reward - report_amount2), "ErrMsg:Incentive pool account {}".format(
    90          incentive_pool_account2)
    91  
    92  
    93  @pytest.fixture(scope='class')
    94  def initial_report(global_test_env):
    95      """
    96      Report a non consensus node prepareBlock
    97      :param global_test_env:
    98      :return:
    99      """
   100      cfg = StakingConfig("11111", "faker", "www.baidu.com", "how much")
   101      clients_consensus = []
   102      consensus_node_obj_list = global_test_env.consensus_node_list
   103      for node_obj in consensus_node_obj_list:
   104          clients_consensus.append(Client(global_test_env, node_obj, cfg))
   105      client = clients_consensus[0]
   106      economic = client.economic
   107      node = client.node
   108      # create report address
   109      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   110      # Wait for the consensus round to end
   111      economic.wait_consensus_blocknum(node, 2)
   112      # Get current block height
   113      current_block = node.eth.blockNumber
   114      log.info("Current block height: {}".format(current_block))
   115      result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
   116      assert_code(result, 0)
   117      yield clients_consensus, economic, node, report_address, current_block
   118      log.info("case execution completed")
   119      global_test_env.deploy_all()
   120      time.sleep(3)
   121  
   122  
   123  class TestMultipleReports:
   124      @pytest.mark.P1
   125      def test_VP_PV_004(self, initial_report):
   126          """
   127          举报双签-同一验证人同一块高不同类型
   128          :param initial_report:
   129          :return:
   130          """
   131          clients_consensus, economic, node, report_address, current_block = initial_report
   132          # duplicate sign
   133          result = verification_duplicate_sign(clients_consensus[0], 2, 2, report_address, current_block)
   134          assert_code(result, 0)
   135  
   136      @pytest.mark.P1
   137      def test_VP_PV_005(self, initial_report):
   138          """
   139          举报双签-同一验证人不同块高同一类型
   140          :param initial_report:
   141          :return:
   142          """
   143          clients_consensus, economic, node, report_address, current_block = initial_report
   144          # duplicate sign
   145          result = verification_duplicate_sign(clients_consensus[0], 1, 1, report_address, current_block - 1)
   146          assert_code(result, 0)
   147  
   148      @pytest.mark.P1
   149      def test_VP_PV_006(self, initial_report):
   150          """
   151          举报双签-同一验证人不同块高不同类型
   152          :param initial_report:
   153          :return:
   154          """
   155          clients_consensus, economic, node, report_address, current_block = initial_report
   156          # duplicate sign
   157          result = verification_duplicate_sign(clients_consensus[0], 2, 2, report_address, current_block - 1)
   158          assert_code(result, 0)
   159  
   160      @pytest.mark.P1
   161      def test_VP_PV_007(self, initial_report):
   162          """
   163          举报双签-不同验证人同一块高同一类型
   164          :param initial_report:
   165          :return:
   166          """
   167          clients_consensus, economic, node, report_address, current_block = initial_report
   168          # create account
   169          report_address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   170          # duplicate sign
   171          result = verification_duplicate_sign(clients_consensus[1], 1, 1, report_address, current_block)
   172          assert_code(result, 0)
   173  
   174      @pytest.mark.P1
   175      def test_VP_PV_008(self, initial_report):
   176          """
   177          举报双签-不同验证人同一块高不同类型
   178          :param initial_report:
   179          :return:
   180          """
   181          clients_consensus, economic, node, report_address, current_block = initial_report
   182          # create account
   183          report_address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   184          # duplicate sign
   185          result = verification_duplicate_sign(clients_consensus[1], 2, 2, report_address, current_block)
   186          assert_code(result, 0)
   187  
   188      @pytest.mark.P1
   189      def test_VP_PV_009(self, initial_report):
   190          """
   191          举报双签-不同验证人不同块高不同类型
   192          :param initial_report:
   193          :return:
   194          """
   195          clients_consensus, economic, node, report_address, current_block = initial_report
   196          # create account
   197          report_address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   198          # duplicate sign
   199          result = verification_duplicate_sign(clients_consensus[1], 2, 2, report_address, current_block - 1)
   200          assert_code(result, 0)
   201  
   202      @pytest.mark.P1
   203      def test_VP_PR_001(self, initial_report):
   204          """
   205          重复举报-同一举报人
   206          :param initial_report:
   207          :return:
   208          """
   209          clients_consensus, economic, node, report_address, current_block = initial_report
   210          # duplicate sign
   211          result = verification_duplicate_sign(clients_consensus[0], 1, 1, report_address, current_block)
   212          assert_code(result, 303001)
   213  
   214      @pytest.mark.P1
   215      def test_VP_PR_002(self, initial_report):
   216          """
   217          重复举报 - 不同举报人
   218          :param initial_report:
   219          :return:
   220          """
   221          clients_consensus, economic, node, report_address, current_block = initial_report
   222          # create account
   223          report_address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   224          # duplicate sign
   225          result = verification_duplicate_sign(clients_consensus[0], 1, 1, report_address2, current_block)
   226          assert_code(result, 303001)
   227  
   228  
   229  def obtaining_evidence_information(economic, node):
   230      # Wait for the consensus round to end
   231      economic.wait_consensus_blocknum(node, 1)
   232      # Get current block height
   233      current_block = node.eth.blockNumber
   234      log.info("Current block height: {}".format(current_block))
   235      if current_block < 41:
   236          current_block = 41
   237      # Obtain evidence of violation
   238      report_information = mock_duplicate_sign(1, node.nodekey, node.blsprikey, current_block)
   239      log.info("Report information: {}".format(report_information))
   240      return report_information, current_block
   241  
   242  
   243  @pytest.mark.P1
   244  @pytest.mark.parametrize('first_key, second_key, value',
   245                           [('epoch', None, 1), ('viewNumber', None, 1), ('blockIndex', None, 1),
   246                            ('validateNode', 'index', 1)])
   247  def test_VP_PV_010_011_014_015(client_consensus, first_key, second_key, value):
   248      """
   249      VP_PV_010:举报双签-双签证据epoch不一致
   250      VP_PV_011:举报双签-双签证据view_number不一致
   251      VP_PV_014:举报双签-双签证据block_index不一致
   252      VP_PV_015:举报双签-双签证据validate_node-index不一致
   253      :param client_consensus:
   254      :param first_key:
   255      :param second_key:
   256      :param value:
   257      :return:
   258      """
   259      client = client_consensus
   260      economic = client.economic
   261      node = client.node
   262      # create report address
   263      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   264      # Obtain information of report evidence
   265      report_information, current_block = obtaining_evidence_information(economic, node)
   266      # Modification of evidence
   267      jsondata = update_param_by_dict(report_information, 'prepareA', first_key, second_key, value)
   268      log.info("Evidence information: {}".format(jsondata))
   269      # Report verifier Duplicate Sign
   270      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   271      return result
   272  
   273  
   274  @pytest.mark.P1
   275  def test_VP_PV_012(client_consensus):
   276      """
   277      举报双签-双签证据block_number不一致
   278      :param client_consensus:
   279      :return:
   280      """
   281      client = client_consensus
   282      economic = client.economic
   283      node = client.node
   284      # create report address
   285      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   286      # Obtain information of report evidence
   287      report_information, current_block = obtaining_evidence_information(economic, node)
   288      # Modification of evidence
   289      jsondata = update_param_by_dict(report_information, 'prepareA', 'blockNumber', None, current_block - 1)
   290      log.info("Evidence information: {}".format(jsondata))
   291      # Report verifier Duplicate Sign
   292      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   293      assert_code(result, 303000)
   294  
   295  
   296  @pytest.mark.P1
   297  def test_VP_PV_013(client_consensus):
   298      """
   299      举报双签-双签证据block_hash一致
   300      :param client_consensus:
   301      :return:
   302      """
   303      client = client_consensus
   304      economic = client.economic
   305      node = client.node
   306      # create report address
   307      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   308      # Obtain information of report evidence
   309      report_information, current_block = obtaining_evidence_information(economic, node)
   310      # Modification of evidence
   311      evidence_parameter = get_param_by_dict(report_information, 'prepareB', 'blockHash')
   312      jsondata = update_param_by_dict(report_information, 'prepareA', 'blockHash', None, evidence_parameter)
   313      log.info("Evidence information: {}".format(jsondata))
   314      # Report verifier Duplicate Sign
   315      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   316      assert_code(result, 303000)
   317  
   318  
   319  @pytest.mark.P1
   320  def test_VP_PV_016(client_consensus):
   321      """
   322      举报双签-双签证据address不一致
   323      :param client_consensus:
   324      :return:
   325      """
   326      client = client_consensus
   327      economic = client.economic
   328      node = client.node
   329      # create report address
   330      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   331      # Obtain information of report evidence
   332      report_information, current_block = obtaining_evidence_information(economic, node)
   333      # Modification of evidence
   334      jsondata = update_param_by_dict(report_information, 'prepareA', 'validateNode', 'address',
   335                                      economic.account.account_with_money['address'])
   336      log.info("Evidence information: {}".format(jsondata))
   337      # Report verifier Duplicate Sign
   338      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   339      assert_code(result, 303000)
   340  
   341  
   342  @pytest.mark.P1
   343  def test_VP_PV_017(clients_consensus):
   344      """
   345      举报双签-NodeID不一致举报双签
   346      :param clients_consensus:
   347      :return:
   348      """
   349      client = clients_consensus[0]
   350      economic = client.economic
   351      node = client.node
   352      # create report address
   353      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   354      # Obtain information of report evidence
   355      report_information, current_block = obtaining_evidence_information(economic, node)
   356      # Modification of evidence
   357      jsondata = update_param_by_dict(report_information, 'prepareA', 'validateNode', 'nodeId',
   358                                      clients_consensus[1].node.node_id)
   359      log.info("Evidence information: {}".format(jsondata))
   360      # Report verifier Duplicate Sign
   361      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   362      assert_code(result, 303000)
   363  
   364  
   365  @pytest.mark.P1
   366  def test_VP_PV_018(clients_consensus):
   367      """
   368      举报双签-blsPubKey不一致举报双签
   369      :param clients_consensus:
   370      :return:
   371      """
   372      client = clients_consensus[0]
   373      economic = client.economic
   374      node = client.node
   375      # create report address
   376      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   377      # Obtain information of report evidence
   378      report_information, current_block = obtaining_evidence_information(economic, node)
   379      # Modification of evidence
   380      jsondata = update_param_by_dict(report_information, 'prepareA', 'validateNode', 'blsPubKey',
   381                                      clients_consensus[1].node.blspubkey)
   382      log.info("Evidence information: {}".format(jsondata))
   383      # Report verifier Duplicate Sign
   384      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   385      assert_code(result, 303000)
   386  
   387  
   388  @pytest.mark.P1
   389  def test_VP_PV_019(clients_consensus):
   390      """
   391      举报双签-signature一致举报双签
   392      :param clients_consensus:
   393      :return:
   394      """
   395      client = clients_consensus[0]
   396      economic = client.economic
   397      node = client.node
   398      # create report address
   399      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   400      # Obtain information of report evidence
   401      report_information, current_block = obtaining_evidence_information(economic, node)
   402      # Modification of evidence
   403      evidence_parameter = get_param_by_dict(report_information, 'prepareB', 'signature')
   404      jsondata = update_param_by_dict(report_information, 'prepareA', 'signature', None, evidence_parameter)
   405      log.info("Evidence information: {}".format(jsondata))
   406      # Report verifier Duplicate Sign
   407      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   408      assert_code(result, 303000)
   409  
   410  
   411  @pytest.mark.P1
   412  @pytest.mark.parametrize("value", [{"epoch": 1}, {"view_number": 1}, {"block_index": 1}, {"index": 1}])
   413  def test_VP_PV_020_to_023(clients_consensus, value):
   414      """
   415      VP_PV_020:举报双签-伪造合法signature情况下伪造epoch
   416      VP_PV_021:举报双签-伪造合法signature情况下伪造viewNumber
   417      VP_PV_022:举报双签-伪造合法signature情况下伪造blockIndex
   418      VP_PV_023:举报双签-伪造合法signature情况下伪造index
   419      :param clients_consensus:
   420      :return:
   421      """
   422      client = clients_consensus[0]
   423      economic = client.economic
   424      node = client.node
   425      # create report address
   426      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   427      # Obtain information of report evidence
   428      report_information, current_block = obtaining_evidence_information(economic, node)
   429      # Obtain evidence of violation
   430      report_information1 = mock_duplicate_sign(1, node.nodekey, node.blsprikey, current_block, **value)
   431      log.info("Report information: {}".format(report_information))
   432      # Modification of evidence
   433      evidence_parameter = get_param_by_dict(report_information1, 'prepareB', 'signature')
   434      jsondata = update_param_by_dict(report_information, 'prepareA', 'signature', None, evidence_parameter)
   435      log.info("Evidence information: {}".format(jsondata))
   436      # Report verifier Duplicate Sign
   437      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   438      assert_code(result, 303000)
   439  
   440  
   441  @pytest.mark.P1
   442  def test_VP_PV_024(clients_consensus):
   443      """
   444      举报双签-伪造合法signature情况下伪造blockNumber
   445      :param clients_consensus:
   446      :return:
   447      """
   448      client = clients_consensus[0]
   449      economic = client.economic
   450      node = client.node
   451      # create report address
   452      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   453      # Obtain information of report evidence
   454      report_information, current_block = obtaining_evidence_information(economic, node)
   455      # Obtain evidence of violation
   456      report_information1 = mock_duplicate_sign(1, node.nodekey, node.blsprikey, current_block + 1)
   457      log.info("Report information: {}".format(report_information))
   458      # Modification of evidence
   459      evidence_parameter = get_param_by_dict(report_information1, 'prepareB', 'signature')
   460      jsondata = update_param_by_dict(report_information, 'prepareA', 'signature', None, evidence_parameter)
   461      log.info("Evidence information: {}".format(jsondata))
   462      # Report verifier Duplicate Sign
   463      result = client.duplicatesign.reportDuplicateSign(1, jsondata, report_address)
   464      assert_code(result, 303000)
   465  
   466  
   467  @pytest.mark.P1
   468  def test_VP_PV_025(client_consensus):
   469      """
   470      举报接口参数测试:举报人账户错误
   471      :param client_consensus:
   472      :return:
   473      """
   474      client = client_consensus
   475      economic = client.economic
   476      node = client.node
   477      # create report address
   478      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   479      # create nodekey
   480      privatekey, _ = generate_key()
   481      # Wait for the consensus round to end
   482      economic.wait_consensus_blocknum(node, 1)
   483      # Get current block height
   484      current_block = node.eth.blockNumber
   485      log.info("Current block height: {}".format(current_block))
   486      # Obtain evidence of violation
   487      report_information = mock_duplicate_sign(1, privatekey, node.blsprikey, current_block)
   488      log.info("Report information: {}".format(report_information))
   489      # Report verifier Duplicate Sign
   490      result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   491      assert_code(result, 303004)
   492  
   493  
   494  @pytest.mark.P1
   495  def test_VP_PV_026(clients_consensus):
   496      """
   497      链存在的id,blskey不匹配
   498      :param clients_consensus:
   499      :return:
   500      """
   501      client = clients_consensus[0]
   502      economic = client.economic
   503      node = client.node
   504      # create report address
   505      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   506      # Wait for the consensus round to end
   507      economic.wait_consensus_blocknum(node, 1)
   508      # Get current block height
   509      current_block = node.eth.blockNumber
   510      log.info("Current block height: {}".format(current_block))
   511      # Obtain evidence of violation
   512      report_information = mock_duplicate_sign(1, node.nodekey, clients_consensus[1].node.blsprikey, current_block)
   513      log.info("Report information: {}".format(report_information))
   514      # Report verifier Duplicate Sign
   515      result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   516      assert_code(result, 303007)
   517  
   518  
   519  @pytest.mark.P1
   520  def test_VP_PV_027(client_new_node):
   521      """
   522      举报候选人
   523      :param client_new_node:
   524      :return:
   525      """
   526      client = client_new_node
   527      economic = client.economic
   528      node = client.node
   529      # create pledge address
   530      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
   531      # create report address
   532      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   533      # create staking
   534      result = client.staking.create_staking(0, pledge_address, pledge_address)
   535      assert_code(result, 0)
   536      # Wait for the settlement round to end
   537      economic.wait_settlement_blocknum(node)
   538      for i in range(4):
   539          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   540          log.info("Current node in consensus list status:{}".format(result))
   541          if not result:
   542              # Get current block height
   543              current_block = node.eth.blockNumber
   544              log.info("Current block height: {}".format(current_block))
   545              # Report verifier Duplicate Sign
   546              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
   547              assert_code(result, 303009)
   548          else:
   549              # wait consensus block
   550              economic.wait_consensus_blocknum(node)
   551  
   552  
   553  @pytest.mark.P1
   554  def test_VP_PV_028(client_consensus):
   555      """
   556      举报有效期之前的双签行为
   557      :param client_consensus:
   558      :return:
   559      """
   560      client = client_consensus
   561      economic = client.economic
   562      node = client.node
   563      # create report address
   564      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   565      # Waiting for the end of the settlement cycle
   566      economic.wait_settlement_blocknum(node, 1)
   567      # Get current block height
   568      current_block = node.eth.blockNumber
   569      log.info("Current block height: {}".format(current_block))
   570      # Obtain evidence of violation
   571      report_information = mock_duplicate_sign(1, node.nodekey, node.blsprikey, 41)
   572      log.info("Report information: {}".format(report_information))
   573      # Report verifier Duplicate Sign
   574      result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   575      assert_code(result, 303003)
   576  
   577  
   578  @pytest.mark.P1
   579  def test_VP_PV_028(client_consensus):
   580      """
   581      举报有效期之后的双签行为
   582      :param client_consensus:
   583      :return:
   584      """
   585      client = client_consensus
   586      economic = client.economic
   587      node = client.node
   588      # create report address
   589      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   590      # Obtain evidence of violation
   591      report_information = mock_duplicate_sign(1, node.nodekey, node.blsprikey, 1000000)
   592      log.info("Report information: {}".format(report_information))
   593      # Report verifier Duplicate Sign
   594      result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   595      assert_code(result, 303002)
   596  
   597  
   598  @pytest.mark.P2
   599  def test_VP_PV_030(client_consensus, reset_environment):
   600      """
   601      举报签名Gas费
   602      :param client_consensus:
   603      :return:
   604      """
   605      client = client_consensus
   606      economic = client.economic
   607      node = client.node
   608      client.economic.env.deploy_all()
   609      # create report address
   610      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   611      # Obtain information of report evidence
   612      report_information, current_block = obtaining_evidence_information(economic, node)
   613      # Obtain penalty proportion and income
   614      pledge_amount1, penalty_ratio, proportion_ratio = penalty_proportion_and_income(client)
   615      # view Amount of penalty
   616      proportion_reward, incentive_pool_reward = economic.get_report_reward(pledge_amount1, penalty_ratio,
   617                                                                            proportion_ratio)
   618      data = rlp.encode([rlp.encode(int(3000)), rlp.encode(1), rlp.encode(report_information)])
   619      dynamic_gas = get_the_dynamic_parameter_gas_fee(data)
   620      gas_total = 21000 + 21000 + 21000 + 21000 + dynamic_gas
   621      log.info("Call contract to create a lockout plan consumption contract:{}".format(gas_total))
   622      balance = node.eth.getBalance(report_address)
   623      log.info("balance: {}".format(balance))
   624      # Report verifier
   625      result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   626      assert_code(result, 0)
   627      balance1 = node.eth.getBalance(report_address)
   628      log.info("balance1: {}".format(balance1))
   629      log.info("proportion reward: {}".format(proportion_reward))
   630      transaction_fees = gas_total * node.eth.gasPrice
   631      assert balance + proportion_reward - balance1 == transaction_fees, "ErrMsg:transaction fees {}".format(
   632          transaction_fees)
   633  
   634  
   635  @pytest.mark.P1
   636  def test_VP_PV_031(client_consensus):
   637      """
   638      举报的gas费不足
   639      :param client_consensus:
   640      :return:
   641      """
   642      client = client_consensus
   643      economic = client.economic
   644      node = client.node
   645      status = True
   646      # create report address
   647      report_address, _ = economic.account.generate_account(node.web3, 0)
   648      # Obtain information of report evidence
   649      report_information, current_block = obtaining_evidence_information(economic, node)
   650      try:
   651          # Report verifier Duplicate Sign
   652          result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   653          log.info("result: {}".format(result))
   654          status = False
   655      except Exception as e:
   656          log.info("Use case success, exception information:{} ".format(str(e)))
   657      assert status, "ErrMsg:Report verifier status {}".format(status)
   658  
   659  
   660  @pytest.mark.P1
   661  def test_VP_PR_003(client_new_node, reset_environment):
   662      """
   663      举报被处罚退出状态中的验证人
   664      :param client_new_node:
   665      :return:
   666      """
   667      client = client_new_node
   668      economic = client.economic
   669      node = client.node
   670      # create pledge address
   671      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
   672      # create report address
   673      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   674      # create staking
   675      result = client.staking.create_staking(0, pledge_address, pledge_address)
   676      assert_code(result, 0)
   677      # view Pledge node information
   678      candidate_info = client.ppos.getCandidateInfo(node.node_id)
   679      log.info("Pledge node information: {}".format(candidate_info))
   680      # Wait for the settlement round to end
   681      economic.wait_settlement_blocknum(node)
   682      # Obtain penalty proportion and income
   683      pledge_amount1, penalty_ratio, proportion_ratio = penalty_proportion_and_income(client)
   684      # view Amount of penalty
   685      proportion_reward, incentive_pool_reward = economic.get_report_reward(pledge_amount1, penalty_ratio,
   686                                                                            proportion_ratio)
   687      for i in range(4):
   688          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   689          log.info("Current node in consensus list status:{}".format(result))
   690          if result:
   691              # Application for return of pledge
   692              result = client.staking.withdrew_staking(pledge_address)
   693              assert_code(result, 0)
   694              # Get current block height
   695              current_block = node.eth.blockNumber
   696              log.info("Current block height: {}".format(current_block))
   697              # Report verifier Duplicate Sign
   698              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
   699              assert_code(result, 0)
   700              # view Pledge node information
   701              candidate_info = client.ppos.getCandidateInfo(node.node_id)
   702              log.info("Pledge node information: {}".format(candidate_info))
   703              log.info("Pledge node amount: {}".format(pledge_amount1))
   704              log.info("proportion_reward + incentive_pool_reward: {}".format(proportion_reward + incentive_pool_reward))
   705              info = candidate_info['Ret']
   706              assert info['Released'] == pledge_amount1 - (
   707                  proportion_reward + incentive_pool_reward), "ErrMsg:Pledge amount {}".format(
   708                  info['Released'])
   709              break
   710          else:
   711              # wait consensus block
   712              economic.wait_consensus_blocknum(node)
   713  
   714  
   715  @pytest.mark.P1
   716  def test_VP_PR_004(client_new_node):
   717      """
   718      举报已完成退出的验证人
   719      :param client_new_node:
   720      :return:
   721      """
   722      client = client_new_node
   723      economic = client.economic
   724      node = client.node
   725      # create pledge address
   726      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
   727      # create report address
   728      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   729      # create staking
   730      result = client.staking.create_staking(0, pledge_address, pledge_address)
   731      assert_code(result, 0)
   732      # Wait for the settlement round to end
   733      economic.wait_settlement_blocknum(node)
   734      for i in range(4):
   735          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   736          log.info("Current node in consensus list status:{}".format(result))
   737          if result:
   738              # Application for return of pledge
   739              result = client.staking.withdrew_staking(pledge_address)
   740              assert_code(result, 0)
   741              # Waiting for the end of the 2 settlement cycle
   742              economic.wait_settlement_blocknum(node, 2)
   743              # Get current block height
   744              current_block = node.eth.blockNumber
   745              log.info("Current block height: {}".format(current_block))
   746              # Report verifier Duplicate Sign
   747              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
   748              assert_code(result, 303004)
   749              break
   750          else:
   751              # wait consensus block
   752              economic.wait_consensus_blocknum(node)
   753  
   754  
   755  @pytest.mark.P1
   756  def test_VP_PR_005(client_new_node, reset_environment):
   757      """
   758      举报人和被举报人为同一个人
   759      :param client_new_node:
   760      :return:
   761      """
   762      client = client_new_node
   763      economic = client.economic
   764      node = client.node
   765      # create pledge address
   766      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
   767      # create staking
   768      result = client.staking.create_staking(0, pledge_address, pledge_address)
   769      assert_code(result, 0)
   770      # Wait for the settlement round to end
   771      economic.wait_settlement_blocknum(node)
   772      for i in range(4):
   773          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   774          log.info("Current node in consensus list status:{}".format(result))
   775          if result:
   776              # Application for return of pledge
   777              result = client.staking.withdrew_staking(pledge_address)
   778              assert_code(result, 0)
   779              # Get current block height
   780              current_block = node.eth.blockNumber
   781              log.info("Current block height: {}".format(current_block))
   782              # Report verifier Duplicate Sign
   783              result = verification_duplicate_sign(client, 1, 1, pledge_address, current_block)
   784              assert_code(result, 303010)
   785              break
   786          else:
   787              # wait consensus block
   788              economic.wait_consensus_blocknum(node)
   789  
   790  
   791  @pytest.mark.P1
   792  def test_VP_PVF_001(client_consensus, reset_environment):
   793      """
   794      查询已成功的举报
   795      :param client_consensus:
   796      :return:
   797      """
   798      client = client_consensus
   799      economic = client.economic
   800      node = client.node
   801      # create report address
   802      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   803      # Wait for the consensus round to end
   804      economic.wait_consensus_blocknum(node, 1)
   805      # Get current block height
   806      current_block = node.eth.blockNumber
   807      log.info("Current block height: {}".format(current_block))
   808      # Obtain evidence of violation
   809      report_information = mock_duplicate_sign(1, node.nodekey, node.blsprikey, current_block)
   810      log.info("Report information: {}".format(report_information))
   811      result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   812      assert_code(result, 0)
   813      # Query and report violation records
   814      evidence_parameter = get_param_by_dict(report_information, 'prepareA', 'validateNode', 'address')
   815      result = client.ppos.checkDuplicateSign(1, evidence_parameter, current_block)
   816      assert_code(result, 0)
   817      assert result['Ret'] is not None, "ErrMsg:Query results {}".format(result['Ret'])
   818  
   819  
   820  @pytest.mark.P1
   821  def test_VP_PVF_002(client_consensus):
   822      """
   823      查询未成功的举报记录
   824      :param client_consensus:
   825      :return:
   826      """
   827      client = client_consensus
   828      economic = client.economic
   829      node = client.node
   830      # create report address
   831      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   832      # Wait for the consensus round to end
   833      economic.wait_consensus_blocknum(node, 1)
   834      # Get current block height
   835      current_block = node.eth.blockNumber
   836      log.info("Current block height: {}".format(current_block))
   837      # Obtain evidence of violation
   838      report_information = mock_duplicate_sign(1, node.nodekey, node.blsprikey, 100000)
   839      log.info("Report information: {}".format(report_information))
   840      result = client.duplicatesign.reportDuplicateSign(1, report_information, report_address)
   841      assert_code(result, 303002)
   842      # create account
   843      report_address2, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   844      # Query and report violation records
   845      evidence_parameter = get_param_by_dict(report_information, 'prepareA', 'validateNode', 'address')
   846      result = client.ppos.checkDuplicateSign(1, evidence_parameter, current_block)
   847      assert_code(result, 0)
   848      assert result['Ret'] == "", "ErrMsg:Query results {}".format(result['Ret'])
   849  
   850  
   851  @pytest.mark.P1
   852  def test_VP_PVF_003(client_new_node, reset_environment):
   853      """
   854      被系统剔除出验证人与候选人名单,节点可继续完成轮的出块及验证工作
   855      :param client_new_node:
   856      :return:
   857      """
   858      client = client_new_node
   859      economic = client.economic
   860      node = client.node
   861      time.sleep(5)
   862      # create pledge address
   863      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
   864      # create report address
   865      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   866      # create staking
   867      result = client.staking.create_staking(0, pledge_address, pledge_address)
   868      assert_code(result, 0)
   869      # Wait for the settlement round to end
   870      economic.wait_settlement_blocknum(node)
   871      for i in range(4):
   872          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   873          log.info("Current node in consensus list status:{}".format(result))
   874          if result:
   875              # Get current block height
   876              current_block = node.eth.blockNumber
   877              log.info("Current block height: {}".format(current_block))
   878              # Report verifier Duplicate Sign
   879              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
   880              assert_code(result, 0)
   881              result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   882              log.info("Current node in consensus list status:{}".format(result))
   883              assert result, "ErrMsg:Node current status {}".format(result)
   884              # Wait for the settlement round to end
   885              economic.wait_consensus_blocknum(node, 2)
   886              result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   887              log.info("Current node in consensus list status:{}".format(result))
   888              assert not result, "ErrMsg:Node current status {}".format(result)
   889              break
   890          else:
   891              # wait consensus block
   892              economic.wait_consensus_blocknum(node)
   893  
   894  
   895  @pytest.mark.P1
   896  def test_VP_PVF_004(client_new_node, reset_environment):
   897      """
   898      验证人在共识轮第230区块前被举报并被处罚
   899      :param client_new_node:
   900      :return:
   901      """
   902      client = client_new_node
   903      economic = client.economic
   904      node = client.node
   905      # create pledge address
   906      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
   907      # create report address
   908      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   909      # create staking
   910      result = client.staking.create_staking(0, pledge_address, pledge_address)
   911      assert_code(result, 0)
   912      # Wait for the settlement round to end
   913      economic.wait_settlement_blocknum(node)
   914      endtime = int(time.time()) + 120
   915      while int(time.time()) < endtime:
   916          time.sleep(1)
   917          current_block = node.eth.blockNumber
   918          log.info("current block: {}".format(current_block))
   919          block = current_block % economic.consensus_size
   920          log.info("block: {}".format(block))
   921          log.info("Current block height: {}, block of current consensus round: {}".format(current_block, block))
   922          if block < 20:
   923              break
   924      for i in range(4):
   925          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   926          log.info("Current node in consensus list status:{}".format(result))
   927          if result:
   928              # Get current block height
   929              current_block = node.eth.blockNumber
   930              log.info("Current block height: {}".format(current_block))
   931              # Report verifier Duplicate Sign
   932              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
   933              assert_code(result, 0)
   934              result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   935              log.info("Current node in consensus list status:{}".format(result))
   936              assert result, "ErrMsg:Node current status {}".format(result)
   937              # Wait for the settlement round to end
   938              economic.wait_consensus_blocknum(node)
   939              result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   940              log.info("Current node in consensus list status:{}".format(result))
   941              assert not result, "ErrMsg:Node current status {}".format(result)
   942              break
   943          else:
   944              # wait consensus block
   945              economic.wait_consensus_blocknum(node)
   946  
   947  
   948  @pytest.mark.P1
   949  def test_VP_PVF_005(client_new_node, reset_environment):
   950      """
   951      验证人在共识轮第230区块后举报并被处罚
   952      :param client_new_node:
   953      :return:
   954      """
   955      client = client_new_node
   956      economic = client.economic
   957      node = client.node
   958      # create pledge address
   959      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
   960      # create report address
   961      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
   962      # create staking
   963      result = client.staking.create_staking(0, pledge_address, pledge_address)
   964      assert_code(result, 0)
   965      # Wait for the settlement round to end
   966      economic.wait_settlement_blocknum(node)
   967      endtime = int(time.time()) + 120
   968      while int(time.time()) < endtime:
   969          time.sleep(1)
   970          current_block = node.eth.blockNumber
   971          log.info("current block: {}".format(current_block))
   972          block = current_block % economic.consensus_size
   973          log.info("block: {}".format(block))
   974          log.info("Current block height: {}, block of current consensus round: {}".format(current_block, block))
   975          if block > 19:
   976              break
   977      for i in range(4):
   978          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   979          log.info("Current node in consensus list status:{}".format(result))
   980          if result:
   981              # Get current block height
   982              current_block = node.eth.blockNumber
   983              log.info("Current block height: {}".format(current_block))
   984              # Report verifier Duplicate Sign
   985              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
   986              assert_code(result, 0)
   987              result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
   988              log.info("Current node in consensus list status:{}".format(result))
   989              assert result, "ErrMsg:Node current status {}".format(result)
   990              break
   991          else:
   992              # wait consensus block
   993              economic.wait_consensus_blocknum(node)
   994  
   995  
   996  @pytest.mark.P2
   997  def test_VP_PVF_006(client_new_node, reset_environment):
   998      """
   999      移出PlatON验证人与候选人名单,验证人申请退回质押金
  1000      :param client_new_node:
  1001      :return:
  1002      """
  1003      client = client_new_node
  1004      economic = client.economic
  1005      node = client.node
  1006      # create pledge address
  1007      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 2))
  1008      # create report address
  1009      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
  1010      # create staking
  1011      result = client.staking.create_staking(0, pledge_address, pledge_address)
  1012      assert_code(result, 0)
  1013      # Wait for the settlement round to end
  1014      economic.wait_settlement_blocknum(node)
  1015      for i in range(4):
  1016          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
  1017          log.info("Current node in consensus list status:{}".format(result))
  1018          if result:
  1019              # Get current block height
  1020              current_block = node.eth.blockNumber
  1021              log.info("Current block height: {}".format(current_block))
  1022              # Report verifier Duplicate Sign
  1023              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
  1024              assert_code(result, 0)
  1025              # Application for return of pledge
  1026              result = client.staking.withdrew_staking(pledge_address)
  1027              assert_code(result, 301103)
  1028              break
  1029          else:
  1030              # wait consensus block
  1031              economic.wait_consensus_blocknum(node)
  1032  
  1033  
  1034  @pytest.mark.P2
  1035  def test_VP_PVF_007(client_new_node, reset_environment):
  1036      """
  1037      节点被处罚后马上重新质押(双签)
  1038      :param client_new_node:
  1039      :return:
  1040      """
  1041      client = client_new_node
  1042      economic = client.economic
  1043      node = client.node
  1044      # create pledge address
  1045      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 3))
  1046      # create report address
  1047      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
  1048      # create staking
  1049      result = client.staking.create_staking(0, pledge_address, pledge_address)
  1050      assert_code(result, 0)
  1051      # Wait for the settlement round to end
  1052      economic.wait_settlement_blocknum(node)
  1053      for i in range(4):
  1054          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
  1055          log.info("Current node in consensus list status:{}".format(result))
  1056          if result:
  1057              # Get current block height
  1058              current_block = node.eth.blockNumber
  1059              log.info("Current block height: {}".format(current_block))
  1060              # Report verifier Duplicate Sign
  1061              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
  1062              assert_code(result, 0)
  1063              # create staking
  1064              result = client.staking.create_staking(0, pledge_address, pledge_address)
  1065              assert_code(result, 301101)
  1066              break
  1067          else:
  1068              # wait consensus block
  1069              economic.wait_consensus_blocknum(node)
  1070  
  1071  
  1072  @pytest.mark.P2
  1073  def test_VP_PVF_008(client_new_node, reset_environment):
  1074      """
  1075      节点被处罚后马上重新增持质押(双签)
  1076      :param client_new_node:
  1077      :return:
  1078      """
  1079      client = client_new_node
  1080      economic = client.economic
  1081      node = client.node
  1082      # create pledge address
  1083      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 3))
  1084      # create report address
  1085      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
  1086      # create staking
  1087      result = client.staking.create_staking(0, pledge_address, pledge_address)
  1088      assert_code(result, 0)
  1089      # Wait for the settlement round to end
  1090      economic.wait_settlement_blocknum(node)
  1091      for i in range(4):
  1092          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
  1093          log.info("Current node in consensus list status:{}".format(result))
  1094          if result:
  1095              # Get current block height
  1096              current_block = node.eth.blockNumber
  1097              log.info("Current block height: {}".format(current_block))
  1098              # Report verifier Duplicate Sign
  1099              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
  1100              assert_code(result, 0)
  1101              # increase staking
  1102              result = client.staking.increase_staking(0, pledge_address)
  1103              assert_code(result, 301103)
  1104              break
  1105          else:
  1106              # wait consensus block
  1107              economic.wait_consensus_blocknum(node)
  1108  
  1109  
  1110  @pytest.mark.P2
  1111  def test_VP_PVF_009(client_new_node, reset_environment):
  1112      """
  1113      移出PlatON验证人与候选人名单,委托人可在处罚所在结算周期,申请赎回全部委托金
  1114      :param client_new_node:
  1115      :return:
  1116      """
  1117      client = client_new_node
  1118      economic = client.economic
  1119      node = client.node
  1120      # create pledge address
  1121      pledge_address, _ = economic.account.generate_account(node.web3, von_amount(economic.create_staking_limit, 3))
  1122      # create report address
  1123      report_address, _ = economic.account.generate_account(node.web3, node.web3.toWei(1000, 'ether'))
  1124      # create staking
  1125      result = client.staking.create_staking(0, pledge_address, pledge_address)
  1126      assert_code(result, 0)
  1127      # Additional pledge
  1128      result = client.delegate.delegate(0, report_address)
  1129      assert_code(result, 0)
  1130      # Wait for the settlement round to end
  1131      economic.wait_settlement_blocknum(node)
  1132      for i in range(4):
  1133          result = check_node_in_list(node.node_id, client.ppos.getValidatorList)
  1134          log.info("Current node in consensus list status:{}".format(result))
  1135          if result:
  1136              # Get current block height
  1137              current_block = node.eth.blockNumber
  1138              log.info("Current block height: {}".format(current_block))
  1139              # Report verifier Duplicate Sign
  1140              result = verification_duplicate_sign(client, 1, 1, report_address, current_block)
  1141              assert_code(result, 0)
  1142              time.sleep(3)
  1143              # Access to pledge information
  1144              candidate_info = client.ppos.getCandidateInfo(node.node_id)
  1145              info = candidate_info['Ret']
  1146              staking_blocknum = info['StakingBlockNum']
  1147              # To view the entrusted account balance
  1148              report_balance = node.eth.getBalance(report_address)
  1149              log.info("report address balance: {}".format(report_balance))
  1150              # withdrew delegate
  1151              result = client.delegate.withdrew_delegate(staking_blocknum, report_address)
  1152              assert_code(result, 0)
  1153              # To view the entrusted account balance
  1154              report_balance1 = node.eth.getBalance(report_address)
  1155              log.info("report address balance: {}".format(report_balance1))
  1156              assert report_balance + economic.delegate_limit - report_balance1 < node.web3.toWei(1,
  1157                                                                                                  'ether'), "ErrMsg:Ireport balance {}".format(
  1158                  report_balance1)
  1159              break
  1160          else:
  1161              # wait consensus block
  1162              economic.wait_consensus_blocknum(node)