Exemple #1
0
def make_normal(tx_count):
    accounts = []

    for _ in range(0, tx_count):
        a = Account(400000)

        # make tx signatures invalid
        a.pk = '0x' + pad_left(
            str(randrange(0, 2**160)), padder='0', chunk_size=64)

        accounts.append(a)

    # make tx package
    txs = []
    for a in accounts:
        tx = Transaction(a.addr, "0xDEADBEEF00000000000000000000000000000000",
                         "", 0, 0, 1, 400000)
        txs.append(tx)

    tx_pkg = make_routine(SEND_TXS, list(map(lambda x: x.as_obj(), txs)))

    routines = [
        tx_pkg,
    ]

    return make_fixture(accounts, routines, height=10000, wait_time=60)
Exemple #2
0
def make(gas_limit, block_limit=BLOCK_LIMIT):
    loops = (gas_limit - BASE_GAS) // LOOP_GAS
    max_txs = block_limit // (BASE_GAS + LOOP_GAS)

    accounts = []
    for i in range(0, max_txs):
        accounts.append(ContractAccount(DEPLOYER, i, AA_CODE, 999999999))

    # make blocks to set nonce to non-zero value
    txs = []
    for a in accounts:
        tx = AATransaction(a.addr, 0, 1, True, 1).as_tx(42500)
        txs.append(tx)

    init1 = make_routine(SEND_BLOCK, list(map(lambda x: x.as_obj(),
                                              txs[0:188])))
    init2 = make_routine(SEND_BLOCK, list(map(lambda x: x.as_obj(),
                                              txs[188:])))

    # make block to invalidate mempool
    txs = []
    for a in accounts:
        tx = AATransaction(a.addr, 1, 1, True, 1).as_tx(27500)
        txs.append(tx)

    invalidator = make_routine(SEND_BLOCK, list(map(lambda x: x.as_obj(),
                                                    txs)))

    # make tx package
    txs = []
    for a in accounts:
        tx = AATransaction(a.addr, 1, loops, True, 1).as_tx(gas_limit)
        txs.append(tx)

    tx_pkg = make_routine(SEND_TXS, list(map(lambda x: x.as_obj(), txs)))

    routines = [
        init1, init2,
        make_routine(SLEEP, duration=2), tx_pkg,
        make_routine(SLEEP, duration=2), invalidator
    ]

    return make_fixture(accounts, routines)
Exemple #3
0
def make(tx_count, gl=400000):
    loops = (gl - BASE_GAS_NEW) // LOOP_GAS

    accounts = []

    for i in range(0, tx_count):
        accounts.append(ContractAccount(DEPLOYER, i, AA_CODE, 400000))

    # make tx package
    txs = []
    for a in accounts:
        tx = AATransaction(a.addr, 0, loops, False, 1).as_tx(gl)
        txs.append(tx)

    tx_pkg = make_routine(SEND_TXS, list(map(lambda x: x.as_obj(), txs)))

    routines = [
        tx_pkg,
    ]

    return make_fixture(accounts, routines, height=10000, wait_time=180)
Exemple #4
0
def make_valid_normal(tx_count):
    accounts = []

    for _ in range(0, tx_count):
        a = Account(0)
        accounts.append(a)

    # make tx package
    txs = []
    for a in accounts:
        tx = Transaction(a.addr, "0xDEADBEEF00000000000000000000000000000000",
                         "", 0, 1, 1, 25000)
        txs.append(tx)

    tx_pkg = make_routine(SEND_TXS, list(map(lambda x: x.as_obj(), txs)))

    routines = [
        tx_pkg,
    ]

    return make_fixture(accounts, routines, height=10000)
Exemple #5
0
def make_multiple_normal(count, tx_count):
    accounts = []

    for _ in range(0, count * tx_count):
        a = Account(400000)

        # make tx signatures invalid
        a.pk = '0x' + pad_left(
            str(randrange(0, 2**160)), padder='0', chunk_size=64)

        accounts.append(a)

    print(len(accounts))

    # make tx package
    bundle = []
    txs = []
    for (i, a) in enumerate(accounts):
        tx = Transaction(a.addr, "0xDEADBEEF00000000000000000000000000000000",
                         "", 0, 0, 1, 400000)

        if i != 0 and (i % tx_count) == 0:
            bundle.append(txs)
            txs = []

        txs.append(tx)

    # capture last iteration
    bundle.append(txs)

    routines = []

    for b in bundle:
        tx_pkg = make_routine(SEND_TXS, list(map(lambda x: x.as_obj(), b)))
        routines.append(tx_pkg)

    print(len(routines))

    return make_fixture(accounts, routines, height=10000, wait_time=180)