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

tools: block generator apps. Part 2: boxes #5478

Merged
merged 8 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 25 additions & 10 deletions tools/block-generator/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
SCENARIO = scenarios/config.app.create.yml # test_config.yml
SCENARIO = scenarios/config.allmixed.small.yml
SKIP = --skip-runner
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
RESETDB = --reset-db
REPORTS = ../../tmp/RUN_RUNNER_OUTPUTS
DURATION = 30s
VERBOSE = # --verbose

block-generator: clean-generator
go build

clean-generator:
rm -f block-generator

debug-blockgen:
python run_runner.py \
Expand All @@ -13,24 +20,32 @@ debug-blockgen:
--test-duration $(DURATION) \
$(RESETDB)

clean-reports:
rm -rf $(REPORTS)

cleanup: clean-reports
python run_runner.py --purge

enter-pg:
docker exec -it generator-test-container psql -U algorand -d generator_db

run-runner:
clean-docker:
docker rm -f generator-test-container

run-runner: block-generator
./block-generator runner --conduit-binary ./conduit \
--log-level trace \
--keep-data-dir \
--test-duration $(DURATION) \
--log-level trace \
--conduit-log-level trace \
--postgres-connection-string "host=localhost user=algorand password=algorand dbname=generator_db port=15432 sslmode=disable" \
--scenario $(SCENARIO) \
$(RESETDB) \
$(VERBOSE) \
--report-directory $(REPORTS)

clean-reports:
rm -rf $(REPORTS)

pre-git-push:
mv _go.mod go.mod
mv _go.sum go.sum
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
cd ../../ && make tidy

post-git-push:
mv go.mod _go.mod
mv go.sum _go.sum
cd ../../ && make tidy && go get github.com/lib/pq
13 changes: 8 additions & 5 deletions tools/block-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,21 @@ Usage:

Flags:
-i, --conduit-binary string Path to conduit binary.
--cpuprofile string Path where conduit writes its CPU profile.
-l, --conduit-log-level string LogLevel to use when starting Conduit. [panic, fatal, error, warn, info, debug, trace] (default "error")
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
--cpuprofile string Path where Conduit writes its CPU profile.
-f, --genesis-file string file path to the genesis associated with the db snapshot
-h, --help help for runner
-k, --keep-data-dir If set the validator will not delete the data directory after tests complete.
-l, --log-level string LogLevel to use when starting conduit. [panic, fatal, error, warn, info, debug, trace] (default "error")
-p, --metrics-port uint Port to start the metrics server at. (default 9999)
-c, --postgres-connection-string string Postgres connection string.
-r, --report-directory string Location to place test reports.
--reset If set any existing report directory will be deleted before running tests.
--reset-db If set database will be deleted before running tests.
--reset-report-dir If set any existing report directory will be deleted before running tests.
-s, --scenario string Directory containing scenarios, or specific scenario file.
-d, --test-duration duration Duration to use for each scenario. (default 5m0s)
--validate If set the validator will run after test-duration has elapsed to verify data is correct. An extra line in each report indicates validator success or failure.
```
-v, --verbose If set the runner will print debugging information from the generator and ledger.
```

## Example Run using Conduit and Postgres in **bash** via `run_runner.sh`

Expand Down Expand Up @@ -180,5 +183,5 @@ Then you can execute the following command to run the scenario:

### Scenario Report

If all goes well, the run will generate a directory `tmp/OUTPUT_RUN_RUNNER_TEST`
If all goes well, the run will generate a directory `../../tmp/OUTPUT_RUN_RUNNER_TEST`
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
and in that directory you can see the statistics of the run in `scenario.report`.
50 changes: 46 additions & 4 deletions tools/block-generator/generator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,19 @@ const (
appBoxesClose TxTypeID = "app_boxes_close"
appBoxesClear TxTypeID = "app_boxes_clear"

// TODO: consider an app that creates/destroys an app during opup
// Special TxTypeID's recording effects of higher level transactions
effectPaymentTxSibling TxTypeID = "effect_payment_sibling"
effectInnerTx TxTypeID = "effect_inner_tx"
Comment on lines +73 to +75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these configurable? I believe the TxTypeID was previously used for the different types of transactions that would be chosen according to the ratios. This seems more like something that would be in GenerationConfig like tx_per_block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right that it's better to keep TxTypeID for types of transactions that can actually be chosen. I'll work to carve out a separate types for these effects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, one issue here is that I do need to record the effects and these get stored in a type Report map[TxTypeID]TxData whose key is of type TxTypeID. So it does complicates things a bit. If we relax Report to have keys of type string, I still ought to be able to separate it out. I'll keep you posted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original concern will be addressed in a follow up PR. Here's a commit: tzaffi@291d30f


// Defaults
defaultGenesisAccountsCount uint64 = 1000
defaultGenesisAccountInitialBalance uint64 = 1000000000000
defaultGenesisAccountInitialBalance uint64 = 1_000_000_000000 // 1 million algos per account

assetTotal uint64 = 100000000000000000
assetTotal uint64 = 100_000_000_000_000_000 // 100 billion units per asset

consensusTimeMilli int64 = 3300
consensusTimeMilli int64 = 3300

// TODO: do we still need this as can get it from the Ledger?
startingTxnCounter uint64 = 1000
)

Expand All @@ -89,6 +93,18 @@ const (
appKindBoxes
)

func (a appKind) String() string {
switch a {
case appKindSwap:
return "swap"
case appKindBoxes:
return "boxes"
default:
// Return a default value for unknown kinds.
return "Unknown"
}
}

type appTxType uint8

const (
Expand All @@ -101,6 +117,28 @@ const (
appTxTypeClear
)

func (a appTxType) String() string {
switch a {
case appTxTypeCreate:
return "create"
case appTxTypeUpdate:
return "update"
case appTxTypeDelete:
return "delete"
case appTxTypeOptin:
return "optin"
case appTxTypeCall:
return "call"
case appTxTypeClose:
return "close"
case appTxTypeClear:
return "clear"
default:
// Return a default value for unknown types.
return "Unknown"
}
}

func parseAppTxType(txType TxTypeID) (isApp bool, kind appKind, tx appTxType, err error) {
parts := strings.Split(string(txType), "_")

Expand Down Expand Up @@ -149,6 +187,10 @@ func parseAppTxType(txType TxTypeID) (isApp bool, kind appKind, tx appTxType, er
return
}

func getAppTxType(kind appKind, appType appTxType) TxTypeID {
return TxTypeID(fmt.Sprintf("app_%s_%s", kind, appType))
}

// GenerationConfig defines the tunable parameters for block generation.
type GenerationConfig struct {
Name string `yaml:"name"`
Expand Down