Skip to content

Commit

Permalink
fix(mocknet): Only have up to 4 rpc nodes on mocknet (#2973)
Browse files Browse the repository at this point in the history
* Originally mocknet was 50% non-validating nodes (this configuration was inherited from devnet)
* We want mostly validating nodes since non-validating nodes are less interesting for testing (contribute less to failure modes, e.g. block production)
* We need at least some non-validating nodes to test code paths when the node is not a block producer
* We settled on 4 as a reasonable number.
* The number of nodes in the mocknet needed to be increased to 54 as a result because the current validator "seat" model did not allow 46 genesis validators, but does allow 50. Note this problem will no longer exist when near/NEPs#83 is implemented.
* The timeouts on transactions are also increased to be less sensitive to missing blocks due to offline validators (this is important for the outage test in particular, where we want a test failure to really mean that the network stalled, not just that several blocks in a row were skipped since that is an expected outcome from losing 25% of validators)
  • Loading branch information
birchmd authored Jul 10, 2020
1 parent 8b15d8b commit 86e4397
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pytest/lib/mocknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from rc import run, pmap

NUM_SECONDS_PER_YEAR = 3600 * 24 * 365
NUM_NODES = 50
NUM_NODES = 54
NODE_BASE_NAME = 'mocknet-node'
NODE_USERNAME = 'ubuntu'
NODE_SSH_KEY_PATH = '~/.ssh/near_ops'
Expand Down Expand Up @@ -133,7 +133,7 @@ def get_metrics(node):

# Sends the transaction to the network via `node` and checks for success.
# Some retrying is done when the node returns a Timeout error.
def send_transaction(node, tx, tx_hash, account_id, timeout=60):
def send_transaction(node, tx, tx_hash, account_id, timeout=120):
response = node.send_tx_and_wait(tx, timeout)
loop_start = time.time()
missing_count = 0
Expand All @@ -143,15 +143,15 @@ def send_transaction(node, tx, tx_hash, account_id, timeout=60):
print(
f'WARN: transaction {tx_hash} returned Timout, checking status again.'
)
time.sleep(2)
time.sleep(5)
response = node.get_tx(tx_hash, account_id)
elif "doesn't exist" in error_data:
missing_count += 1
print(
f'WARN: transaction {tx_hash} falied to be recieved by the node, checking again.'
)
if missing_count < 20:
time.sleep(2)
time.sleep(5)
response = node.get_tx(tx_hash, account_id)
else:
print(f'WARN: re-sending transaction {tx_hash}.')
Expand Down
3 changes: 2 additions & 1 deletion pytest/tests/mocknet/outage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# Get the list of current validators, sorted by node index
validators = sorted(nodes[0].get_validators()['result']['current_validators'],
key=lambda v: int(v['account_id'][4:]))
assert len(validators) == (mocknet.NUM_NODES // 2)
num_rpc_nodes = min(mocknet.NUM_NODES // 2, 4)
assert len(validators) == mocknet.NUM_NODES - num_rpc_nodes

# Take down ~25% of stake.
total_stake = sum(map(lambda v: int(v['stake']), validators))
Expand Down

0 comments on commit 86e4397

Please sign in to comment.