-
Notifications
You must be signed in to change notification settings - Fork 468
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: update block-generator to use conduit binary #5306
Changes from all commits
4fcbd3a
4cd3fe1
0f7285b
e6a45f9
d9d8b67
1980571
32ad557
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ type GenerationConfig struct { | |
GenesisAccountInitialBalance uint64 `yaml:"genesis_account_balance"` | ||
|
||
// Block generation | ||
TxnPerBlock uint64 `mapstructure:"tx_per_block"` | ||
TxnPerBlock uint64 `yaml:"tx_per_block"` | ||
|
||
// TX Distribution | ||
PaymentTransactionFraction float32 `yaml:"tx_pay_fraction"` | ||
|
@@ -120,7 +120,7 @@ func MakeGenerator(config GenerationConfig) (Generator, error) { | |
genesisHash: [32]byte{}, | ||
genesisID: "blockgen-test", | ||
prevBlockHash: "", | ||
round: 1, | ||
round: 0, | ||
txnCounter: 0, | ||
timestamp: 0, | ||
rewardsLevel: 0, | ||
|
@@ -312,7 +312,9 @@ func (g *generator) WriteGenesis(output io.Writer) error { | |
FeeSink: g.feeSink.String(), | ||
Timestamp: g.timestamp, | ||
} | ||
return json.NewEncoder(output).Encode(gen) | ||
|
||
_, err := output.Write(protocol.EncodeJSON(gen)) | ||
return err | ||
} | ||
|
||
func getTransactionOptions() []interface{} { | ||
|
@@ -357,12 +359,28 @@ func (g *generator) finishRound(txnCount uint64) { | |
|
||
// WriteBlock generates a block full of new transactions and writes it to the writer. | ||
func (g *generator) WriteBlock(output io.Writer, round uint64) error { | ||
|
||
if round != g.round { | ||
fmt.Printf("Generator only supports sequential block access. Expected %d but received request for %d.\n", g.round, round) | ||
} | ||
|
||
numTxnForBlock := g.txnForRound(round) | ||
|
||
// return genesis block | ||
if round == 0 { | ||
// write the msgpack bytes for a block | ||
block, err := rpcs.RawBlockBytes(g.ledger, basics.Round(round)) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = output.Write(block) | ||
if err != nil { | ||
return err | ||
} | ||
g.finishRound(numTxnForBlock) | ||
return nil | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. postgresql exporter adds blocks starting from round 0. |
||
|
||
header := bookkeeping.BlockHeader{ | ||
Round: basics.Round(g.round), | ||
Branch: bookkeeping.BlockHash{}, | ||
|
@@ -414,15 +432,19 @@ func (g *generator) WriteBlock(output io.Writer, round uint64) error { | |
Certificate: agreement.Certificate{}, | ||
} | ||
|
||
err := json.NewEncoder(output).Encode(cert) | ||
err := g.ledger.AddBlock(cert.Block, cert.Certificate) | ||
if err != nil { | ||
return err | ||
} | ||
// write the msgpack bytes for a block | ||
block, err := rpcs.RawBlockBytes(g.ledger, basics.Round(round)) | ||
if err != nil { | ||
return err | ||
} | ||
err = g.ledger.AddBlock(cert.Block, agreement.Certificate{}) | ||
_, err = output.Write(block) | ||
if err != nil { | ||
return err | ||
} | ||
g.ledger.WaitForCommit(basics.Round(g.round)) | ||
g.finishRound(numTxnForBlock) | ||
return nil | ||
} | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
CONNECTION_STRING="" | ||
INDEXER_BINARY="" | ||
CONDUIT_BINARY="" | ||
REPORT_DIR="" | ||
DURATION="1h" | ||
LOG_LEVEL="error" | ||
|
@@ -17,7 +17,7 @@ help() { | |
echo " -r|--report-dir directory where the report should be written." | ||
echo " -d|--duration test duration." | ||
echo " -l|--level log level to pass to Indexer." | ||
echo " -g|--generator use a different indexer binary to run the generator." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it's no longer part of the indexer binary, this should be required. Mark as required on line 79 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. |
||
echo " -g|--generator block-generator binary to run the generator." | ||
exit | ||
} | ||
|
||
|
@@ -34,7 +34,7 @@ while :; do | |
shift | ||
;; | ||
-i | --indexer) | ||
INDEXER_BINARY="${2-}" | ||
CONDUIT_BINARY="${2-}" | ||
shift | ||
;; | ||
-r | --report-dir) | ||
|
@@ -66,7 +66,7 @@ if [ -z "$CONNECTION_STRING" ]; then | |
exit 1 | ||
fi | ||
|
||
if [ -z "$INDEXER_BINARY" ]; then | ||
if [ -z "$CONDUIT_BINARY" ]; then | ||
echo "Missing required indexer binary parameter (-i / --indexer)." | ||
exit 1 | ||
fi | ||
|
@@ -77,18 +77,17 @@ if [ -z "$SCENARIOS" ]; then | |
fi | ||
|
||
if [ -z "$GENERATOR_BINARY" ]; then | ||
echo "Using indexer binary for generator, override with (-g / --generator)." | ||
GENERATOR_BINARY="$INDEXER_BINARY" | ||
echo "path to block-generator binary is required" | ||
exit 1 | ||
fi | ||
|
||
echo "Running with binary: $INDEXER_BINARY" | ||
echo "Running with binary: $CONDUIT_BINARY" | ||
echo "Report directory: $REPORT_DIR" | ||
echo "Duration: $DURATION" | ||
echo "Log Level: $LOG_LEVEL" | ||
|
||
"$GENERATOR_BINARY" \ | ||
util block-generator runner \ | ||
-i "$INDEXER_BINARY" \ | ||
"$GENERATOR_BINARY" runner \ | ||
-i "$CONDUIT_BINARY" \ | ||
-s "$SCENARIOS" \ | ||
-d "$DURATION" \ | ||
-c "$CONNECTION_STRING" \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
genesis response needs to be msgp encoded.