Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anusha-ctrl committed Jul 19, 2023
1 parent f7d3850 commit c81454e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/simulator/load/funder.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func DistributeFunds(ctx context.Context, client ethclient.Client, keys []*key.K
return nil, fmt.Errorf("failed to generate fund distribution sequence from %s of length %d", maxFundsKey.Address, len(needFundsAddrs))
}
worker := NewSingleAddressTxWorker(ctx, client, maxFundsKey.Address)
txFunderAgent := txs.NewIssueNAgent[txs.TimedTx](txSequence, worker, numTxs)
txFunderAgent := txs.NewIssueNAgent[*types.Transaction](txSequence, worker, numTxs)

reg := prometheus.NewRegistry()
m := metrics.NewMetrics(reg)
Expand Down
2 changes: 1 addition & 1 deletion cmd/simulator/load/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func ExecuteLoader(ctx context.Context, config config.Config) error {
log.Info("Constructing tx agents...", "numAgents", config.Workers)
agents := make([]txs.Agent[*types.Transaction], 0, config.Workers)
for i := 0; i < config.Workers; i++ {
agents = append(agents, txs.NewIssueNAgent[txs.TimedTx](txSequences[i], NewSingleAddressTxWorker(ctx, clients[i], senders[i]), config.BatchSize))
agents = append(agents, txs.NewIssueNAgent[*types.Transaction](txSequences[i], NewSingleAddressTxWorker(ctx, clients[i], senders[i]), config.BatchSize))
}

reg := prometheus.NewRegistry()
Expand Down
8 changes: 3 additions & 5 deletions cmd/simulator/load/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"time"

"github.com/ava-labs/subnet-evm/cmd/simulator/txs"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/ethclient"
"github.com/ava-labs/subnet-evm/interfaces"
Expand Down Expand Up @@ -45,17 +44,16 @@ func NewSingleAddressTxWorker(ctx context.Context, client ethclient.Client, addr
return tw
}

func (tw *singleAddressTxWorker) IssueTx(ctx context.Context, timedTx txs.TimedTx) error {
err := tw.client.SendTransaction(ctx, timedTx.Tx)
func (tw *singleAddressTxWorker) IssueTx(ctx context.Context, tx *types.Transaction) error {
err := tw.client.SendTransaction(ctx, tx)
if err != nil {
return err
}

return nil
}

func (tw *singleAddressTxWorker) ConfirmTx(ctx context.Context, timedTx txs.TimedTx) error {
tx := timedTx.Tx
func (tw *singleAddressTxWorker) ConfirmTx(ctx context.Context, tx *types.Transaction) error {
txNonce := tx.Nonce()

for {
Expand Down
4 changes: 2 additions & 2 deletions cmd/simulator/txs/tx_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var _ TxSequence[*types.Transaction] = (*txSequence)(nil)
type CreateTx func(key *ecdsa.PrivateKey, nonce uint64) (*types.Transaction, error)

// GenerateTxSequence fetches the current nonce of key and calls [generator] [numTxs] times sequentially to generate a sequence of transactions.
func GenerateTxSequence(ctx context.Context, generator CreateTx, client ethclient.Client, key *ecdsa.PrivateKey, numTxs uint64) (TxSequence[TimedTx], error) {
func GenerateTxSequence(ctx context.Context, generator CreateTx, client ethclient.Client, key *ecdsa.PrivateKey, numTxs uint64) (TxSequence[*types.Transaction], error) {
address := ethcrypto.PubkeyToAddress(key.PublicKey)
startingNonce, err := client.NonceAt(ctx, address, nil)
if err != nil {
Expand All @@ -36,7 +36,7 @@ func GenerateTxSequence(ctx context.Context, generator CreateTx, client ethclien
return ConvertTxSliceToSequence(txs), nil
}

func GenerateTxSequences(ctx context.Context, generator CreateTx, client ethclient.Client, keys []*ecdsa.PrivateKey, txsPerKey uint64) ([]TxSequence[TimedTx], error) {
func GenerateTxSequences(ctx context.Context, generator CreateTx, client ethclient.Client, keys []*ecdsa.PrivateKey, txsPerKey uint64) ([]TxSequence[*types.Transaction], error) {
txSequences := make([]TxSequence[*types.Transaction], len(keys))
for i, key := range keys {
txs, err := GenerateTxSequence(ctx, generator, client, key, txsPerKey)
Expand Down
4 changes: 1 addition & 3 deletions scripts/run_simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ run_simulator() {
--timeout=30s \
--workers=1 \
--max-fee-cap=300 \
--max-tip-cap=100 \
--blockchain-id-str=$BLOCKCHAIN_ID \
--metrics-endpoints=$METRICS_ENDPOINTS
--max-tip-cap=100
}

run_simulator

0 comments on commit c81454e

Please sign in to comment.