-
Notifications
You must be signed in to change notification settings - Fork 15
Transaction Generator
Generating a transaction is selecting inputs (UTxO), outputs, and amounts to transfer. (+ digitally signed)
The input selection is only valid on the set of unspent transaction outputs (UTxO). The transaction will create new UTxO that can be reused in future transactions. Some amount will be spent for the transaction costs and will reduce the available coins in the UTxO. (can we control tx costs? or set to zero?)
We receive (at least) 3 signing keys from CLI argument --sig-key
. These keys will be used to create 3 addresses:
-
genesisAddress
- an address we send an initial (genesis) funds to. This is the very first transaction. -
sourceAddress
- an address we use as a source for all further transactions. -
recepientAddress
- an address we use as a recipient for all further transactions.
Genesis UTxO is generated from genesis signing key, in extractGenesisFunds
function. Currently it's 1.4 billion ADA. Then we prepare initial funds using prepareInitialFunds
function: we perform the very first transaction to move all initial funds from genesisAddress
to sourceAddress
.
Since sourceAddress
(after initial transaction) contains all genesis funds, we have one single UTxO entry with 1.4 billion ADA. Now we have to split this amount to required number of UTxO entries, i.e.:
1 UTxO entry (
sourceAddress
and amountX
) ->N
UTxO entries (sourceAddress
and amountX/N
).
So we perform M
splitting transactions in createMoreFundCoins
function, where M
is calculated as N/60
. 60 is a number of outputs per 1 splitting transaction (technically 60 is near the upper bound but not exceed the transaction size limit).
The number N
of UTxO entries is equal to (or more than) the number of transaction we want to generate (this number is taken from CLI argument --num-of-txs
).
After we performed splitting transactions, we have N
of UTxO entries. All these entries is storing in availableFunds
. And when we prepare an input for a new transaction, we just find the first available output that contains sufficient amount of ADA. After we found it, it will be removed from availableFunds
.
After we prepared required number of UTxO entries, we generate defined number of transactions.
All these transactions has the same output(s): recipientAddress
and amount A
, where A
is fixed amount of ADA. Currently A
is hardcoded, probably it should be taken from CLI argument.
We receive TPS rate from CLI argument --tps
. Submitter part is controlling TPS rate.
Transaction generator is using following CLI arguments:
-
--num-of-txs
- number of transaction we want to generate. -
--outputs-per-tx
- number of outputs per transaction. -
--tx-fee
- fee per transaction (in Lovelaces). -
--tps
- TPS rate. -
--sig-key
- path to the signing key file. Can be used multiple times.
Transaction generator is a part of cardano-cli
executable (generate-txs
command). It can be launched using scripts/generator.sh
script. Example of command:
$ ./scripts/generator.sh -n 0
where 0
is an id of a node we will send transaction to.
Please make sure that local cluster is already launched (for example, using scripts/shelley-testnet.sh
script).