From c40a2cebd4de6977e2b1e9a531bbbf97c8d7d098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Thu, 1 Jun 2023 12:07:20 +0200 Subject: [PATCH] fix: remove replace directive in `go.mod` (#71) * fix: remove replace directive in `go.mod` * chore: bump version to `go 1.19` * fix: unknown field 'AppID' issue * fix: makefile `loadtest` cmd * chore: remove aval's `AppID` * chore: add `avail-loadtest` cmd to `Makefile` * chore: remove typo * chore: use custom fork instead of `centrifuge` * chore: move `--data-avail` flag at the end of the cmd * chore: merge with main branch * chore: increase the sleep interval between funding the acount and starting the load test to avoid issues * Revert "chore: use custom fork instead of `centrifuge`" This reverts commit b7c5a1cc229444820db15a8b0eeceb53ab063868. --- Makefile | 39 +++++++++++++++++++++++++++------------ cmd/loadtest/loadtest.go | 10 +--------- go.mod | 4 +--- go.sum | 4 ++-- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 02f2f2c7..cd715b62 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ INSTALL_DIR:=~/go/bin +BIN_DIR=./bin BIN_NAME:=polycli BUILD_DIR:=./out @@ -22,7 +23,7 @@ help: ## Display this help. ##@ Build .PHONY: $(BUILD_DIR) -$(BUILD_DIR): ## Create the binary folder. +$(BUILD_DIR): ## Create the build folder. mkdir -p $(BUILD_DIR) .PHONY: generate @@ -84,6 +85,21 @@ golangci-lint: ## Run golangci-lint against code. .PHONY: lint lint: tidy vet golangci-lint ## Run all the linter tools against code. +##@ Clients +PORT?=8545 + +.PHONY: $(BIN_DIR) +$(BIN_DIR): ## Create the binary folder. + mkdir -p $(BIN_DIR) + +.PHONY: geth +geth: $(BIN_DIR) ## Start a local geth node. + geth --dev --dev.period 2 --http --http.addr localhost --http.port $(PORT) --http.api admin,debug,web3,eth,txpool,personal,miner,net --verbosity 5 --rpc.gascap 50000000 --rpc.txfeecap 0 --miner.gaslimit 10 --miner.gasprice 1 --gpo.blocks 1 --gpo.percentile 1 --gpo.maxprice 10 --gpo.ignoreprice 2 --dev.gaslimit 50000000 + +.PHONY: avail +avail: $(BIN_DIR) ## Start a local avail node. + avail --dev --rpc-port $(PORT) + ##@ Test .PHONY: test @@ -91,17 +107,16 @@ test: ## Run tests. go test ./... -coverprofile=coverage.out go tool cover -func coverage.out -.PHONY: geth -geth: ## Start geth. - geth --dev --dev.period 2 --http --http.addr localhost --http.port 8545 --http.api admin,debug,web3,eth,txpool,personal,miner,net --verbosity 5 --rpc.gascap 50000000 --rpc.txfeecap 0 --miner.gaslimit 10 --miner.gasprice 1 --gpo.blocks 1 --gpo.percentile 1 --gpo.maxprice 10 --gpo.ignoreprice 2 --dev.gaslimit 50000000 - LOADTEST_ACCOUNT=0x85da99c8a7c2c95964c8efd687e95e632fc533d6 LOADTEST_FUNDING_AMOUNT_ETH=5000 -eth_coinbase := $(shell curl -s -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": 2, "method": "eth_coinbase", "params": []}' http://127.0.0.1:8545 | jq -r ".result") +eth_coinbase := $(shell curl -s -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": 2, "method": "eth_coinbase", "params": []}' http://127.0.0.1:${PORT} | jq -r ".result") hex_funding_amount := $(shell echo "obase=16; ${LOADTEST_FUNDING_AMOUNT_ETH}*10^18" | bc) - -.PHONY: loadtest -loadtest: build ## Fund test account with 5k ETH and run loadtest. - curl -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "method":"eth_sendTransaction", "params":[{"from": "${eth_coinbase}","to": "${LOADTEST_ACCOUNT}","value": "0x${hex_funding_amount}"}], "id":1}' http://127.0.0.1:8545 - $(BUILD_DIR)/$(BIN_NAME) loadtest --verbosity 700 --chain-id 1337 --concurrency 1 --requests 1000 --rate-limit 5 --mode c http://127.0.0.1:8545 - +.PHONY: geth-loadtest +geth-loadtest: build ## Fund test account with 5k ETH and run loadtest against an EVM/Geth chain. + curl -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "method":"eth_sendTransaction", "params":[{"from": "${eth_coinbase}","to": "${LOADTEST_ACCOUNT}","value": "0x${hex_funding_amount}"}], "id":1}' http://127.0.0.1:${PORT} + sleep 5 + $(BUILD_DIR)/$(BIN_NAME) loadtest --verbosity 700 --chain-id 1337 --concurrency 1 --requests 1000 --rate-limit 5 --mode c http://127.0.0.1:$(PORT) + +.PHONY: avail-loadtest +avail-loadtest: build ## Run loadtest against an Avail chain. + $(BUILD_DIR)/$(BIN_NAME) loadtest --verbosity 700 --chain-id 1256 --concurrency 1 --requests 1000 --rate-limit 5 --mode t --data-avail http://127.0.0.1:$(PORT) \ No newline at end of file diff --git a/cmd/loadtest/loadtest.go b/cmd/loadtest/loadtest.go index 1c3b5471..614d4e12 100644 --- a/cmd/loadtest/loadtest.go +++ b/cmd/loadtest/loadtest.go @@ -257,7 +257,6 @@ type ( ByteCount *uint64 Seed *int64 IsAvail *bool - AvailAppID *uint32 LtAddress *string DelAddress *string ContractCallNumberOfBlocksToWaitFor *uint64 @@ -326,7 +325,6 @@ r - random modes ltp.ByteCount = LoadtestCmd.PersistentFlags().Uint64P("byte-count", "b", 1024, "If we're in store mode, this controls how many bytes we'll try to store in our contract") ltp.Seed = LoadtestCmd.PersistentFlags().Int64("seed", 123456, "A seed for generating random values and addresses") ltp.IsAvail = LoadtestCmd.PersistentFlags().Bool("data-avail", false, "Is this a test of avail rather than an EVM / Geth Chain") - ltp.AvailAppID = LoadtestCmd.PersistentFlags().Uint32("app-id", 0, "The AppID used for avail") ltp.LtAddress = LoadtestCmd.PersistentFlags().String("lt-address", "", "A pre-deployed load test contract address") ltp.DelAddress = LoadtestCmd.PersistentFlags().String("del-address", "", "A pre-deployed delegator contract address") ltp.ContractCallNumberOfBlocksToWaitFor = LoadtestCmd.PersistentFlags().Uint64("contract-call-nb-blocks-to-wait-for", 30, "The number of blocks to wait for before giving up on a contract call") @@ -1432,11 +1430,7 @@ func loadtestAvailTransfer(ctx context.Context, c *gsrpc.SubstrateAPI, nonce uin // For some reason weren't able to read the random data log.Error().Msg("Sending to random is not implemented for substrate yet") } else { - toAddr, err = gstypes.NewMultiAddressFromAccountID(pk) - if err != nil { - log.Error().Msg("Unable to create an address from the account id") - return - } + toAddr = gstypes.NewMultiAddressFromAccountID(pk) } } @@ -1458,7 +1452,6 @@ func loadtestAvailTransfer(ctx context.Context, c *gsrpc.SubstrateAPI, nonce uin SpecVersion: rv.SpecVersion, Tip: gstypes.NewUCompactFromUInt(0), TransactionVersion: rv.TransactionVersion, - AppID: gstypes.NewUCompactFromUInt(uint64(*ltp.AvailAppID)), } err = ext.Sign(kp, o) @@ -1501,7 +1494,6 @@ func loadtestAvailStore(ctx context.Context, c *gsrpc.SubstrateAPI, nonce uint64 SpecVersion: rv.SpecVersion, Tip: gstypes.NewUCompactFromUInt(100), TransactionVersion: rv.TransactionVersion, - AppID: gstypes.NewUCompactFromUInt(uint64(*ltp.AvailAppID)), } // Sign the transaction using Alice's default account err = ext.Sign(kp, o) diff --git a/go.mod b/go.mod index b17798b0..d371fe1d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/maticnetwork/polygon-cli -go 1.18 +go 1.19 require ( github.com/0xPolygon/polygon-edge v0.8.0 @@ -256,5 +256,3 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.1.7 // indirect ) - -replace github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/availproject/go-substrate-rpc-client/v4 v4.0.12-avail-1.4.0-rc1-5e286e3 diff --git a/go.sum b/go.sum index 8d7b52b3..d8ee7a51 100644 --- a/go.sum +++ b/go.sum @@ -107,8 +107,6 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/availproject/go-substrate-rpc-client/v4 v4.0.12-avail-1.4.0-rc1-5e286e3 h1:9bPK0/Vd+uOQul3vEBSemRXO+rwqi+UXDAvFzNUlG8A= -github.com/availproject/go-substrate-rpc-client/v4 v4.0.12-avail-1.4.0-rc1-5e286e3/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE= github.com/aws/aws-sdk-go v1.44.61 h1:NcpLSS3Z0MiVQIYugx4I40vSIEEAXT0baO684ExNRco= github.com/aws/aws-sdk-go v1.44.61/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -144,6 +142,8 @@ github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QH github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M= github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.6 h1:Il7zBKEvRwiWN/GHogUjmHzaXfp9TvbbhVAOQ1vVBBQ= +github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.6/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=