From 237210093e7c19e0077fb1a36a26c250b142bb1f Mon Sep 17 00:00:00 2001 From: Jesse Lee Date: Wed, 28 Jun 2023 18:05:08 -0400 Subject: [PATCH] push --- cmd/loadtest/loadtest.go | 29 +++++++++++++++++++++++++---- cmd/rpcfuzz/rpcfuzz.go | 11 ++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/cmd/loadtest/loadtest.go b/cmd/loadtest/loadtest.go index 8bd8e630..1d0df26d 100644 --- a/cmd/loadtest/loadtest.go +++ b/cmd/loadtest/loadtest.go @@ -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) @@ -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: @@ -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 @@ -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 := ðtypes.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 { diff --git a/cmd/rpcfuzz/rpcfuzz.go b/cmd/rpcfuzz/rpcfuzz.go index 97cb825a..9da5a5c4 100644 --- a/cmd/rpcfuzz/rpcfuzz.go +++ b/cmd/rpcfuzz/rpcfuzz.go @@ -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" @@ -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 (