コード例 #1
0
ファイル: skip_epoch.py プロジェクト: xunppchen/nearcore
config = {'local': True, 'near_root': '../target/debug/'}
near_root, node_dirs = init_cluster(
    2, 1, 2, config, [["max_inflation_rate", 0], ["epoch_length", 7],
                      ["validator_kickout_threshold", 80]],
    {2: {
        "tracked_shards": [0, 1]
    }})

started = time.time()

boot_node = spin_up_node(config, near_root, node_dirs[0], 0, None, None)
#node1 = spin_up_node(config, near_root, node_dirs[1], 1, boot_node.node_key.pk, boot_node.addr())
observer = spin_up_node(config, near_root, node_dirs[2], 2,
                        boot_node.node_key.pk, boot_node.addr())

ctx = TxContext([0, 0, 0], [boot_node, None, observer])

initial_balances = ctx.get_balances()
total_supply = sum(initial_balances)

print("Initial balances: %s\nTotal supply: %s" %
      (initial_balances, total_supply))

seen_boot_heights = set()
sent_txs = False
largest_height = 0

# 1. Make the first node get to height 25. The second epoch will end around height 15-16,
#    which would already result in a stall if the first node can't sync the state from the
#    observer for the shard it doesn't care about
while True:
コード例 #2
0
from cluster import init_cluster, spin_up_node, load_config
from utils import TxContext, LogTracker

START_AT_BLOCK = int(sys.argv[2])
TIMEOUT = 150 + START_AT_BLOCK * 10

config = load_config()
near_root, node_dirs = init_cluster(2, 1, 1, config, [["min_gas_price", 0], ["max_inflation_rate", [0, 1]], ["epoch_length", 10], ["block_producer_kickout_threshold", 80]], {2: {"tracked_shards": [0]}})

started = time.time()

boot_node = spin_up_node(config, near_root, node_dirs[0], 0, None, None)
node1 = spin_up_node(config, near_root, node_dirs[1], 1, boot_node.node_key.pk, boot_node.addr())

ctx = TxContext([0, 0], [boot_node, node1])

sent_txs = False

observed_height = 0
while observed_height < START_AT_BLOCK:
    assert time.time() - started < TIMEOUT
    status = boot_node.get_status()
    new_height = status['sync_info']['latest_block_height']
    hash_ = status['sync_info']['latest_block_hash']
    if new_height > observed_height:
        observed_height = new_height
        print("Boot node got to height %s" % new_height);

    if mode == 'onetx' and not sent_txs:
        ctx.send_moar_txs(hash_, 3, False)
コード例 #3
0
from cluster import start_cluster
from utils import TxContext
from transaction import sign_payment_tx

TIMEOUT = 240

nodes = start_cluster(4, 0, 4, {
    'local': True,
    'near_root': '../target/debug/'
}, [["epoch_length", 10], ["validator_kickout_threshold", 70]], {})

started = time.time()

act_to_val = [3, 2, 0, 3]

ctx = TxContext(act_to_val, nodes)

last_balances = [x for x in ctx.expected_balances]

step = 0
sent_height = -1

while True:
    assert time.time() - started < TIMEOUT
    status = nodes[3].get_status()

    height = status['sync_info']['latest_block_height']
    hash_ = status['sync_info']['latest_block_hash']

    if step == 0:
        if height >= 1:
コード例 #4
0
from cluster import start_cluster
from utils import TxContext
from transaction import sign_payment_tx

TIMEOUT = 240


# give more stake to the bootnode so that it can produce the blocks alone
nodes = start_cluster(2, 1, 8, None, [["num_block_producer_seats", 199], ["num_block_producer_seats_per_shard", [24, 25, 25, 25, 25, 25, 25, 25]], ["min_gas_price", 0], ["max_inflation_rate", [0, 1]], ["epoch_length", 10], ["block_producer_kickout_threshold", 70], ["validators", 0, "amount", "60000000000000000000000000000000"], ["records", 0, "Account", "account", "locked", "60000000000000000000000000000000"]], {})
time.sleep(3)
nodes[1].kill()

started = time.time()

act_to_val = [0, 0, 0]
ctx = TxContext(act_to_val, nodes)

last_balances = [x for x in ctx.expected_balances]

max_height = 0
sent_height = -1
caught_up_times = 0

while True:
    assert time.time() - started < TIMEOUT
    status = nodes[0].get_status()

    height = status['sync_info']['latest_block_height']
    hash_ = status['sync_info']['latest_block_hash']

    if height > max_height:
コード例 #5
0
# First observer
node2 = spin_up_node(config, near_root, node_dirs[2], 2, None, None)
# Boot from observer since block producer will blacklist third observer
boot_node = node2

# Second observer
node3 = spin_up_node(config, near_root, node_dirs[3], 3, boot_node.node_key.pk,
                     boot_node.addr())

# Spin up validators
node0 = spin_up_node(config, near_root, node_dirs[0], 0, boot_node.node_key.pk,
                     boot_node.addr(), [4])
node1 = spin_up_node(config, near_root, node_dirs[1], 1, boot_node.node_key.pk,
                     boot_node.addr(), [4])

ctx = TxContext([0, 0], [node0, node1])

sent_txs = False

observed_height = 0
while observed_height < START_AT_BLOCK:
    assert time.time() - started < TIMEOUT
    status = boot_node.get_status()
    new_height = status['sync_info']['latest_block_height']
    hash_ = status['sync_info']['latest_block_hash']
    if new_height > observed_height:
        observed_height = new_height
        print("Boot node got to height %s" % new_height)

    if mode == 'onetx' and not sent_txs:
        ctx.send_moar_txs(hash_, 3, False)
コード例 #6
0
                 }
             })

started = time.time()

boot_node = spin_up_node(config, near_root, node_dirs[0], 0, None, None)
boot_node.stop_checking_store()
node3 = spin_up_node(config, near_root, node_dirs[2], 2, boot_node.node_key.pk,
                     boot_node.addr())
node4 = spin_up_node(config, near_root, node_dirs[3], 3, boot_node.node_key.pk,
                     boot_node.addr())
observer = spin_up_node(config, near_root, node_dirs[4], 4,
                        boot_node.node_key.pk, boot_node.addr())
observer.stop_checking_store()

ctx = TxContext([4, 4, 4, 4, 4], [boot_node, None, node3, node4, observer])
initial_balances = ctx.get_balances()
total_supply = sum(initial_balances)

logger.info("Initial balances: %s\nTotal supply: %s" %
            (initial_balances, total_supply))

seen_boot_heights = set()
sent_txs = False
largest_height = 0

# 1. Make the first node get to height 35. The second epoch will end around height 24-25,
#    which would already result in a stall if the first node can't sync the state from the
#    observer for the shard it doesn't care about
while True:
    assert time.time() - started < TIMEOUT