Skip to content

Commit

Permalink
some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bharath-123 committed May 17, 2024
1 parent 274d4e5 commit c7b4a70
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Required (at least one of):
-t, --throughput uint Number of blob transactions to send per slot
Optional:
--basefee uint Max fee per gas to use in large transactions (in gwei) (default 20)
--basefee uint Max fee per gas to use in gasburner transactions (in gwei) (default 20)
--gas-units-to-burn uint The number of gas units for each tx to cost (default 2000000)
--max-pending uint Maximum number of pending transactions
--max-wallets uint Maximum number of child wallets to use
Expand All @@ -93,7 +93,7 @@ Optional:
-h, --rpchost stringArray The RPC host to send transactions to.
--rpchost-file string File with a list of RPC hosts to send transactions to.
-s, --seed string The child wallet seed.
--tipfee uint Max tip per gas to use in large transactions (in gwei) (default 2)
--tipfee uint Max tip per gas to use in gasburner transactions (in gwei) (default 2)
--trace Run the script with tracing output
-v, --verbose Run the script with verbose output
```
Expand Down
26 changes: 10 additions & 16 deletions scenarios/gasburnertx/gasburnertx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
gasburnertx "github.com/ethpandaops/spamoor/scenarios/gasburnertx/contracts"
"github.com/ethpandaops/spamoor/utils"
"math/big"
"sync"
Expand Down Expand Up @@ -50,13 +49,13 @@ func NewScenario() scenariotypes.Scenario {
}

func (s *Scenario) Flags(flags *pflag.FlagSet) error {
flags.Uint64VarP(&s.options.TotalCount, "count", "c", 0, "Total number of large transactions to send")
flags.Uint64VarP(&s.options.Throughput, "throughput", "t", 0, "Number of large transactions to send per slot")
flags.Uint64VarP(&s.options.TotalCount, "count", "c", 0, "Total number of gasburner transactions to send")
flags.Uint64VarP(&s.options.Throughput, "throughput", "t", 0, "Number of gasburner transactions to send per slot")
flags.Uint64Var(&s.options.MaxPending, "max-pending", 0, "Maximum number of pending transactions")
flags.Uint64Var(&s.options.MaxWallets, "max-wallets", 0, "Maximum number of child wallets to use")
flags.Uint64Var(&s.options.Rebroadcast, "rebroadcast", 120, "Number of seconds to wait before re-broadcasting a transaction")
flags.Uint64Var(&s.options.BaseFee, "basefee", 20, "Max fee per gas to use in large transactions (in gwei)")
flags.Uint64Var(&s.options.TipFee, "tipfee", 2, "Max tip per gas to use in large transactions (in gwei)")
flags.Uint64Var(&s.options.BaseFee, "basefee", 20, "Max fee per gas to use in gasburner transactions (in gwei)")
flags.Uint64Var(&s.options.TipFee, "tipfee", 2, "Max tip per gas to use in gasburner transactions (in gwei)")
flags.Uint64Var(&s.options.GasUnitsToBurn, "gas-units-to-burn", 2000000, "The number of gas units for each tx to cost")

return nil
Expand Down Expand Up @@ -90,8 +89,8 @@ func (s *Scenario) Init(testerCfg *tester.TesterConfig) error {
return nil
}

func (s *Scenario) Run(testerCfg *tester.Tester) error {
s.tester = testerCfg
func (s *Scenario) Run(tester *tester.Tester) error {
s.tester = tester
txIdxCounter := uint64(0)
counterMutex := sync.Mutex{}
waitGroup := sync.WaitGroup{}
Expand Down Expand Up @@ -177,7 +176,7 @@ func (s *Scenario) DeployGasBurnerContract() (*types.Receipt, *txbuilder.Client,
return nil, nil, err
}

_, deployTx, _, err := gasburnertx.DeployGasBurner(transactor, client.GetEthClient())
_, deployTx, _, err := DeployGasBurner(transactor, client.GetEthClient())
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -356,12 +355,7 @@ func (s *Scenario) awaitTx(txIdx uint64, tx *types.Transaction, client *txbuilde
gweiBaseFee := new(big.Int).Div(effectiveGasPrice, big.NewInt(1000000000))
gweiBlobFee := new(big.Int).Div(blobGasPrice, big.NewInt(1000000000))

txStatus := "failure"
if receipt.Status == 1 {
txStatus = "success"
}

s.logger.WithField("client", client.GetName()).Infof(" transaction %d confirmed in block #%v with %s. total gas units: %d, total fee: %v gwei (base: %v, blob: %v)", txIdx+1, blockNum, txStatus, receipt.GasUsed, gweiTotalFee, gweiBaseFee, gweiBlobFee)
s.logger.WithField("client", client.GetName()).Infof(" transaction %d confirmed in block #%v. total gas units: %d, total fee: %v gwei (base: %v, blob: %v)", txIdx+1, blockNum, receipt.GasUsed, gweiTotalFee, gweiBaseFee, gweiBlobFee)
}

func (s *Scenario) delayedResend(txIdx uint64, tx *types.Transaction, awaitConfirmation *bool) {
Expand Down Expand Up @@ -390,7 +384,7 @@ func (s *Scenario) GetTransactor(wallet *txbuilder.Wallet, noSend bool, value *b
return transactor, nil
}

func (s *Scenario) GetGasBurner() (*gasburnertx.GasBurner, error) {
func (s *Scenario) GetGasBurner() (*GasBurner, error) {
client := s.tester.GetClient(tester.SelectByIndex, 0)
return gasburnertx.NewGasBurner(s.gasBurnerContractAddr, client.GetEthClient())
return NewGasBurner(s.gasBurnerContractAddr, client.GetEthClient())
}

0 comments on commit c7b4a70

Please sign in to comment.