Example #1
0
def init_tx_builders(env, kps, sequences):
    """Initialize transaction builders for each given seed."""
    builders = []
    for i, kp in enumerate(kps):
        client = KinClient(env)
        builder = Builder(env.name, client.horizon, MIN_FEE, kp.secret_seed)
        builder.sequence = sequences[i]
        builders.append(builder)
    return builders
Example #2
0
def next_builder(b: Builder) -> Builder:
    """Reimplementation of kin.blockchain.Builder.next() that returns a new builder."""
    next_builder = Builder(network=b.network,
                           horizon=b.horizon,
                           fee=b.fee,
                           secret=b.keypair.seed().decode(),
                           address=b.address)

    next_builder.keypair = b.keypair
    next_builder.sequence = str(int(b.sequence)+1)

    return next_builder
Example #3
0
async def main():
    """Create accounts and print their seeds to stdout."""
    args = parse_args()
    env = Environment(NETWORK_NAME, (args.horizon)[0], args.passphrase)
    builder = Builder(NETWORK_NAME,
                      KinClient(env).horizon, MIN_FEE,
                      root_account_seed(args.passphrase))
    builder.sequence = builder.get_sequence()
    kps = await create_accounts(builder, args.horizon, args.accounts,
                                STARTING_BALANCE)

    for kp in kps:
        print(kp.secret_seed)
async def init_channel_builders(channel_seeds_file, passphrase, horizon):
    env = Environment(NETWORK_NAME, (horizon)[0], passphrase)

    channel_kps = load_accounts(channel_seeds_file)
    sequences = await get_sequences_multiple_endpoints(horizon, [kp.public_address for kp in channel_kps])

    channel_builders = []
    for i, kp in enumerate(channel_kps):
        b = Builder(NETWORK_NAME, KinClient(env).horizon, MIN_FEE, kp.secret_seed)
        b.sequence = str(sequences[i])
        channel_builders.append(b)

    return channel_builders
Example #5
0
async def generate_builders(kps: List[Keypair], env_name, horizon) -> List[Builder]:
    """Receive Keypair list and return Builder list with updated sequence numbers."""
    # fetch sequence numbers asynchronously for all created accounts
    sequences = await get_sequences_multiple_endpoints([horizon], [kp.public_address for kp in kps])

    # create tx builders with up-to-date sequence number
    builders = []
    for i, kp in enumerate(kps):
        builder = Builder(env_name, horizon, MIN_FEE, kp.secret_seed)
        builder.sequence = sequences[i]
        builders.append(builder)

    for b in builders:
        logging.debug('created builder %s', b.address)

    return builders
Example #6
0
async def main():
    args = parse_args()

    # setup network
    Environment(NETWORK_NAME, args.horizon[0], args.passphrase)

    logging.info('loading prioritizer accounts')
    prioritizer_kps = [kp for kp in load_accounts(args.prioritizer_seeds_file)]
    logging.info('%d prioritizer accounts loaded', len(prioritizer_kps))

    logging.info('loading spammer accounts')
    spam_kps = load_accounts(args.spammer_seeds_file)
    logging.info('%d spammer accounts loaded', len(spam_kps))

    logging.info('fetching sequence number for spammer accounts')
    spam_sequences = await get_sequences_multiple_endpoints(args.horizon, [kp.public_address for kp in spam_kps])

    logging.info('generating spammer builders')
    spam_builders = []

    # we're not submitting using the builder - just generating the xdr,
    # so each builder's horizon instance is irrelevant
    stub_horizon = args.horizon[0]
    for kp, seq in zip(spam_kps, spam_sequences):
        b = Builder(NETWORK_NAME, stub_horizon, MIN_FEE, kp.secret_seed)
        b.sequence = str(seq)
        spam_builders.append(b)

    logging.info('sleeping for %ds to let horizon cool down after get sequence request surge', COOL_DOWN_AFTER_GET_SEQ)
    time.sleep(COOL_DOWN_AFTER_GET_SEQ)

    logging.info('starting spam')
    results = await spam(args.horizon, prioritizer_kps, spam_builders, args.length, args.txs_per_ledger)
    logging.info('done spamming')

    logging.info('writing transaction results to file')
    with open(args.out, 'w') as f:
        for spam_round in results:
            for tx in spam_round:
                f.write('{}\n'.format(json.dumps(tx)))

    logging.info('done')
Example #7
0
async def main():
    args = parse_args()

    # setup network
    Environment(NETWORK_NAME, args.horizon[0], args.passphrase)

    logging.info('loading prioritizer accounts')
    prioritizer_kps = [kp for kp in load_accounts(args.prioritizer_seeds_file)]
    logging.info('%d prioritizer accounts loaded', len(prioritizer_kps))

    logging.info('loading spammer accounts')
    spam_kps = load_accounts(args.spammer_seeds_file)
    logging.info('%d spammer accounts loaded', len(spam_kps))

    logging.info('fetching sequence number for spammer accounts')
    spam_sequences = await get_sequences_multiple_endpoints(args.horizon, [kp.public_address for kp in spam_kps])

    logging.info('generating spammer builders')
    spam_builders = []

    # we're not submitting using the builder - just generating the xdr,
    # so each builder's horizon instance is irrelevant
    stub_horizon = args.horizon[0]
    for kp, seq in zip(spam_kps, spam_sequences):
        b = Builder(NETWORK_NAME, stub_horizon, MIN_FEE, kp.secret_seed)
        b.sequence = str(seq)
        spam_builders.append(b)

    logging.info('generating spam transaction xdrs')
    spam_rounds = await generate_spam_tx_xdrs(prioritizer_kps, spam_builders, args.length, args.txs_per_ledger, args.avg_block_time)
    logging.info('done generating spam transaction xdrs')

    logging.info('writing transaction xdrs to file %s', args.out)
    with open(args.out, 'w') as f:
        for rnd in spam_rounds:
            f.write('{}\n'.format(json.dumps(rnd)))

    logging.info('done')