Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction generator contract updates #85

Merged
merged 17 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
concordium-rust-sdk = { path = "../deps/concordium-rust-sdk", version = "*" }
clap = {version = "4", features = ["derive", "color"] }
clap = { version = "4", features = ["derive", "color"] }
anyhow = "1"
chrono = {version = "0.4", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] }
rand = "0.7"
tokio = {version = "1.27", features = ["rt-multi-thread", "macros", "time"]}
tonic = {version = "0.8", features = ["tls", "tls-roots"]} # Use system trust roots.
tokio = { version = "1.27", features = ["rt-multi-thread", "macros", "time"] }
tonic = { version = "0.8", features = [
"tls",
"tls-roots",
] } # Use system trust roots.
lassemoldrup marked this conversation as resolved.
Show resolved Hide resolved
futures = "0.3.28"
http = "0.2.9"
serde_json = "1.0.96"
41 changes: 37 additions & 4 deletions generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ different configurations.
## Build

To build it

- make sure to check out git submodules
```console
git submodule update --init --recursive
Expand All @@ -20,9 +21,22 @@ This will produce a single binary `./target/release/generator`.
## Using the generator

The generator connects to the node and sends transactions. The number of
transactions sent is configured using the `--tps` flag.
transactions sent is configured using the `--tps` flag. The `--sender` flag specifies the path to the sender account credentials.

Both TLS and unencrypted connection to the node are supported. Use `https` as
the node address scheme to connect via TLS.

The tool supports multiple kinds of transactions that are given with subcommands. E.g. to mint 5 NFTs a second you would use the command

The transactions are sent to
```console
./generator --tps 5 --sender path/to/keys.json mint-nfts
```

The supported transactions are listed below.

### `ccd`

The transactions are regular CCD transfers sent to

- either accounts specified using the `--receivers` argument which should point
to a file with a list of account addresses.
Expand All @@ -39,5 +53,24 @@ amount of accounts. The generator must be connected to a baker, and it is only
sending to the accounts from `i`'th element of the partition, where `i` is the
baker id.

Both TLS and unencrypted connection to the node are supported. Use `https` as
the node address scheme to connect via TLS.
### `mint-nfts`

The tool first deploys and initializes the [`cis2-nft`](https://github.com/Concordium/concordium-rust-smart-contracts/tree/fcc668d87207aaf07b43f5a3b02b6d0a634368d0/examples/cis2-nft) example contract. The transactions are then simply `mint` updates on the contract, where NFTs are minted for the sender.

### `transfer-cis2`

The tool first deploys and initializes the [`cis2-multi`](https://github.com/Concordium/concordium-rust-smart-contracts/tree/fcc668d87207aaf07b43f5a3b02b6d0a634368d0/examples/cis2-nft) example contract. It then mints a bunch of CIS2 tokens (`u64::MAX` to be precise) for the sender. The transactions are then transfers of these tokens to a list of receivers that is either
lassemoldrup marked this conversation as resolved.
Show resolved Hide resolved

- accounts specified using the `--receivers` argument which should point
to a file with a list of account addresses,
- or every account on the chain if `--receivers` is not specified.

The transactions are sent in a round robin fashion.

### `wccd`

The tool first deploys and initializes the [`cis2-wccd`](https://github.com/Concordium/concordium-rust-smart-contracts/tree/fcc668d87207aaf07b43f5a3b02b6d0a634368d0/examples/cis2-wccd) example contract. It then mints 1 (micro) wCCD for each account on the chain in order to increase the size of the state of the contract. The transactions alternate between wrapping, transferring, and unwrapping wCCD. In each case the receiver is the sender, since it is simple and there is no special handling of this in the contract.

### `register-credentials`

The tool first deploys and initializes the [`credential-registry`](https://github.com/Concordium/concordium-rust-smart-contracts/tree/fcc668d87207aaf07b43f5a3b02b6d0a634368d0/examples/credential-registry) example contract. Each transaction is simply an issuance of a credential with dummy values.
Binary file added generator/resources/cis2_multi.wasm.v1
Binary file not shown.
Binary file added generator/resources/cis2_nft.wasm.v1
Binary file not shown.
Binary file added generator/resources/cis2_wccd.wasm.v1
Binary file not shown.
Binary file added generator/resources/credential_registry.wasm.v1
Binary file not shown.
Loading
Loading