vechain / thor

A general purpose blockchain highly compatible with Ethereum's ecosystem
GNU Lesser General Public License v3.0
795 stars 248 forks source link

feat: remove account + delegation limit #715

Closed darrenvechain closed 2 months ago

darrenvechain commented 2 months ago

Description

This PR removes the account & delegators transaction limit in the pool

https://github.com/vechain/protocol-board-repo/issues/144

Type of change

How Has This Been Tested?

Checklist:

const {ThorClient} = require('@vechain/sdk-network');
const {HDNode} = require('@vechain/sdk-core');

const client = ThorClient.fromUrl("http://localhost:8669");
const words = "denial kitchen pet squirrel other broom bar gas better priority spoil cross";
const hdNode = HDNode.fromMnemonic(words.split(" "));
const account1 = hdNode.derive(1);

const clauses = [
    {
        to: '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed',
        value: 1,
        data: '0x'
    }
]

const start = async () => {
    const rawTransactions = [];

    for (let index = 0; index < 100; index++) {

        const gas = await client.gas.estimateGas(clauses)
        const txBody = await client.transactions.buildTransactionBody(clauses, gas.totalGas, {expiration: 1000})
        const signedTx = await client.transactions.signTransaction(txBody, account1.privateKey)
        rawTransactions.push(`0x${signedTx.encoded.toString('hex')}`)
    }

    const startBlock = await client.blocks.getBestBlockCompressed();
    console.log("Start block: ", startBlock.number + 1)

    // Wait for a block to get mined so we have a full 10 seconds to send all the transactions
    await client.blocks.waitForBlockCompressed(startBlock.number + 1)

    const txIds = await Promise.all(rawTransactions.map(async (rawTx) => {
        return (await client.transactions.sendRawTransaction(rawTx)).id
    }));

    const txsSentBlock = await client.blocks.getBestBlockCompressed();
    console.log("All TXs Sent: ", txsSentBlock.number)

    const receipts = await Promise.all(txIds.map(async (txId) => {
        return await client.transactions.waitForTransaction(txId)
    }));

    // Record<blockNumber, TX Count>
    const txCounts = {}
    for (const receipt of receipts) {
        const block = `block-${receipt.meta.blockNumber}`
        if (txCounts[block]) {
            txCounts[block] += 1
        } else {
            txCounts[block] = 1
        }
    }

    console.table(txCounts)
}

start()

/**
0x435933c8064b4Ae76bE665428e0307eF2cCFBD68
Start block:  13
All TXs Sent:  13
┌──────────┬────────┐
│ (index)  │ Values │
├──────────┼────────┤
│ block-14 │ 100    │
└──────────┴────────┘
*/
codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 61.19%. Comparing base (b83a007) to head (a107b5d).

Files Patch % Lines
txpool/tx_pool.go 0.00% 0 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #715 +/- ## ========================================== - Coverage 61.25% 61.19% -0.06% ========================================== Files 194 194 Lines 18207 18185 -22 ========================================== - Hits 11152 11129 -23 Misses 5973 5973 - Partials 1082 1083 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.