Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
gatsbyz committed Jun 28, 2023
1 parent 08423e3 commit 577534e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
29 changes: 25 additions & 4 deletions cmd/loadtest/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@ func mainLoop(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Client) erro
var retryForNonce bool = false
var myNonceValue uint64

header, err := c.HeaderByNumber(ctx, nil)
if err != nil {
log.Error().Err(err).Msg("Unable to get head")
return
}

for j = 0; j < requests; j = j + 1 {
if rl != nil {
err = rl.Wait(ctx)
Expand Down Expand Up @@ -820,7 +826,7 @@ func mainLoop(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Client) erro
}
switch localMode {
case loadTestModeTransaction:
startReq, endReq, err = loadtestTransaction(ctx, c, myNonceValue)
startReq, endReq, err = loadtestTransaction(ctx, c, myNonceValue, header)
case loadTestModeDeploy:
startReq, endReq, err = loadtestDeploy(ctx, c, myNonceValue)
case loadTestModeCall:
Expand Down Expand Up @@ -956,7 +962,7 @@ func blockUntilSuccessful(ctx context.Context, c *ethclient.Client, f func() err
}
}

func loadtestTransaction(ctx context.Context, c *ethclient.Client, nonce uint64) (t1 time.Time, t2 time.Time, err error) {
func loadtestTransaction(ctx context.Context, c *ethclient.Client, nonce uint64, header *ethtypes.Header) (t1 time.Time, t2 time.Time, err error) {
ltp := inputLoadTestParams

gasPrice := ltp.CurrentGas
Expand All @@ -976,8 +982,23 @@ func loadtestTransaction(ctx context.Context, c *ethclient.Client, nonce uint64)
log.Error().Err(err).Msg("Unable to get head")
return
}

tx = ethtypes.NewTransaction(nonce, *to, amount, gasLimit, gasPrice, nil)
if *ltp.LegacyTransactionMode {
tx = ethtypes.NewTransaction(nonce, *to, amount, gasLimit, gasPrice, nil)
} else {
gasTipCap := ltp.CurrentGasTipCap
gasFeeCap := new(big.Int).Add(gasTipCap, header.BaseFee)
dynamicFeeTx := &ethtypes.DynamicFeeTx{
ChainID: chainID,
Nonce: nonce,
To: to,
Gas: gasLimit,
GasFeeCap: gasFeeCap,
GasTipCap: gasTipCap,
Data: nil,
Value: amount,
}
tx = ethtypes.NewTx(dynamicFeeTx)
}

tops, err := bind.NewKeyedTransactorWithChainID(privateKey, chainID)
if err != nil {
Expand Down
11 changes: 6 additions & 5 deletions cmd/rpcfuzz/rpcfuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"math/big"
"regexp"
"strings"
"sync"
"time"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand All @@ -28,11 +34,6 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/xeipuuv/gojsonschema"
"math/big"
"regexp"
"strings"
"sync"
"time"
)

type (
Expand Down

0 comments on commit 577534e

Please sign in to comment.