Skip to content

Commit

Permalink
Load test runner implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Apr 10, 2024
1 parent aca4572 commit b2328fc
Show file tree
Hide file tree
Showing 11 changed files with 1,136 additions and 10 deletions.
23 changes: 21 additions & 2 deletions command/bridge/fund/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/0xPolygon/polygon-edge/command/bridge/helper"
cmdHelper "github.com/0xPolygon/polygon-edge/command/helper"
polybftsecrets "github.com/0xPolygon/polygon-edge/command/secrets/init"
"github.com/0xPolygon/polygon-edge/jsonrpc"
"github.com/0xPolygon/polygon-edge/txrelayer"
"github.com/0xPolygon/polygon-edge/types"
)
Expand Down Expand Up @@ -78,8 +79,18 @@ func runCommand(cmd *cobra.Command, _ []string) {
outputter := command.InitializeOutputter(cmd)
defer outputter.WriteOutput()

txRelayer, err := txrelayer.NewTxRelayer(txrelayer.WithIPAddress(params.jsonRPCAddress),
txrelayer.WithReceiptsTimeout(params.txTimeout))
client, err := jsonrpc.NewEthClient(params.jsonRPCAddress)
if err != nil {
outputter.SetError(fmt.Errorf("failed to initialize eth client: %w", err))

return
}

txRelayer, err := txrelayer.NewTxRelayer(
txrelayer.WithClient(client),
txrelayer.WithReceiptsTimeout(params.txTimeout),
txrelayer.WithoutNonceGet(),
)
if err != nil {
outputter.SetError(fmt.Errorf("failed to initialize tx relayer: %w", err))

Expand All @@ -93,6 +104,13 @@ func runCommand(cmd *cobra.Command, _ []string) {
return
}

senderNonce, err := client.GetNonce(deployerKey.Address(), jsonrpc.PendingBlockNumberOrHash)
if err != nil {
outputter.SetError(fmt.Errorf("failed to get deployer nonce: %w", err))

return
}

results := make([]command.CommandResult, len(params.addresses))
g, ctx := errgroup.WithContext(cmd.Context())

Expand All @@ -107,6 +125,7 @@ func runCommand(cmd *cobra.Command, _ []string) {
default:
fundAddr := params.addresses[i]
txn := helper.CreateTransaction(types.ZeroAddress, &fundAddr, nil, params.amountValues[i], true)
txn.SetNonce(senderNonce + uint64(i))

var (
receipt *ethgo.Receipt
Expand Down
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
github.com/libp2p/go-libp2p-kbucket v0.6.3
github.com/libp2p/go-libp2p-pubsub v0.10.0
github.com/multiformats/go-multiaddr v0.12.3
github.com/olekukonko/tablewriter v0.0.5
github.com/prometheus/client_golang v1.19.0
github.com/quasilyte/go-ruleguard v0.4.2
github.com/quasilyte/go-ruleguard/dsl v0.3.22
Expand All @@ -53,6 +54,11 @@ require (
pgregory.net/rapid v1.1.0
)

require (
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
)

require (
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
Expand Down Expand Up @@ -481,6 +484,8 @@ github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
Expand Down Expand Up @@ -570,6 +575,9 @@ github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtB
github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU=
github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 h1:Qp27Idfgi6ACvFQat5+VJvlYToylpM/hcyLBI3WaKPA=
github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052/go.mod h1:uvX/8buq8uVeiZiFht+0lqSLBHF+uGV8BrTv8W/SIwk=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
Expand Down
14 changes: 14 additions & 0 deletions jsonrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,17 @@ func (e *EthClient) GetLogs(filter *ethgo.LogFilter) ([]*ethgo.Log, error) {

return out, nil
}

// Status returns the transaction pool status (pending and queued transactions)
func (e *EthClient) Status() (*StatusResponse, error) {
var out StatusResponse
if err := e.client.Call("txpool_status", &out); err != nil {
return nil, err
}

return &out, nil
}

func (e *EthClient) Close() error {
return e.client.Close()
}
Loading

0 comments on commit b2328fc

Please sign in to comment.