Skip to content

Commit

Permalink
tools: block generator apps. Part 2: boxes (#5478)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzaffi committed Jun 27, 2023
1 parent 068b375 commit 74b5f19
Show file tree
Hide file tree
Showing 19 changed files with 1,238 additions and 289 deletions.
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
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
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")
--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`
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"

// 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
Loading

0 comments on commit 74b5f19

Please sign in to comment.