diff --git a/.github/workflows/on-main.yml b/.github/workflows/on-main.yml index d6066eb..21373f9 100644 --- a/.github/workflows/on-main.yml +++ b/.github/workflows/on-main.yml @@ -17,9 +17,9 @@ jobs: - name: Run docker build run: make docker-build - name: Tag docker image - run: docker tag vulcanize/tx_spammer docker.pkg.github.com/vulcanize/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} + run: docker tag cerc-io/tx_spammer git.vdb.to/cerc-io/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} - name: Docker Login - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://git.vdb.to -u cerc-io --password-stdin - name: Docker Push - run: docker push docker.pkg.github.com/vulcanize/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} + run: docker push git.vdb.to/cerc-io/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f669d52..cdebf1b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,13 +13,13 @@ jobs: echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) - name: Docker Login to Github Registry - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://git.vdb.to -u vulcanize --password-stdin - name: Docker Pull - run: docker pull docker.pkg.github.com/vulcanize/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} + run: docker pull git.vdb.to/cerc-io/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} - name: Docker Login to Docker Registry run: echo ${{ secrets.VULCANIZEJENKINS_PAT }} | docker login -u vulcanizejenkins --password-stdin - name: Tag docker image - run: docker tag docker.pkg.github.com/vulcanize/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} vulcanize/tx_spammer:${{steps.vars.outputs.tag}} + run: docker tag git.vdb.to/cerc-io/tx_spammer/tx_spammer:${{steps.vars.outputs.sha}} cerc-io/tx_spammer:${{steps.vars.outputs.tag}} - name: Docker Push to Docker Hub - run: docker push vulcanize/tx_spammer:${{steps.vars.outputs.tag}} + run: docker push cerc-io/tx_spammer:${{steps.vars.outputs.tag}} diff --git a/.gitignore b/.gitignore index 94bfd9d..c4d2f50 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ .idea/ -tx_spammer +tx-spammer diff --git a/Dockerfile b/Dockerfile index 647e94a..2af67b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,10 @@ RUN apk --update --no-cache add make git g++ linux-headers # DEBUG RUN apk add busybox-extras -# Get and build tx_spammer -ADD . /go/src/github.com/vulcanize/tx_spammer -WORKDIR /go/src/github.com/vulcanize/tx_spammer -RUN GO111MODULE=on GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o tx_spammer . +# Get and build tx-spammer +ADD . /go/src/github.com/cerc-io/tx-spammer +WORKDIR /go/src/github.com/cerc-io/tx-spammer +RUN GO111MODULE=on GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o tx-spammer . # app container FROM alpine @@ -22,11 +22,12 @@ USER $USER # chown first so dir is writable # note: using $USER is merged, but not in the stable release yet -COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/tx_spammer/$CONFIG_FILE config.toml -COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/tx_spammer/startup_script.sh . +COPY --chown=5000:5000 --from=builder /go/src/github.com/cerc-io/tx-spammer/$CONFIG_FILE config.toml +COPY --chown=5000:5000 --from=builder /go/src/github.com/cerc-io/tx-spammer/startup_script.sh . # keep binaries immutable -COPY --from=builder /go/src/github.com/vulcanize/tx_spammer/tx_spammer tx_spammer -COPY --from=builder /go/src/github.com/vulcanize/tx_spammer/environments environments +COPY --from=builder /go/src/github.com/cerc-io/tx-spammer/tx-spammer tx-spammer +COPY --from=builder /go/src/github.com/cerc-io/tx-spammer/environments environments +COPY --from=builder /go/src/github.com/cerc-io/tx-spammer/sol sol ENTRYPOINT ["/app/startup_script.sh"] diff --git a/Makefile b/Makefile index 2fe7ad9..78aa7c3 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ ## Build docker image .PHONY: docker-build docker-build: - docker build -t vulcanize/tx_spammer -f Dockerfile . + docker build -t cerc/tx-spammer -f Dockerfile . .PHONY: build build: - GO111MODULE=on go build -o tx_spammer . + GO111MODULE=on go build -o tx-spammer . .PHONY: contract contract: diff --git a/README.md b/README.md index 0642dd7..177c1ca 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# tx_spammer +# tx-spammer Tools to enable the semi-reproducible growth of a large and complex chain over RPC, for testing and benchmarking purposes Usage: -`./tx_spammer autoSend --config=./environments/gen.toml` +`./tx-spammer autoSend --config=./environments/gen.toml` The `autoSend` command takes as input a .toml config of the below format, the fields can be overridden with the env variables in the comments. It uses the provided key pairs and configuraiton parameters to generate and deploy a number of contracts with a simple interface for `Put`ing to a dynamic data structure. diff --git a/cmd/autoSend.go b/cmd/autoSend.go index 19c0afa..2c5deff 100644 --- a/cmd/autoSend.go +++ b/cmd/autoSend.go @@ -21,7 +21,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "github.com/vulcanize/tx_spammer/pkg/auto" + "github.com/cerc-io/tx-spammer/pkg/auto" ) // autoSendCmd represents the autoSend command diff --git a/cmd/root.go b/cmd/root.go index a7bef78..9dab48f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -33,7 +33,7 @@ var ( ) var rootCmd = &cobra.Command{ - Use: "tx_spammer", + Use: "tx-spammer", PersistentPreRun: initFuncs, } diff --git a/cmd/sendTxs.go b/cmd/sendTxs.go index e8428a0..1efc24a 100644 --- a/cmd/sendTxs.go +++ b/cmd/sendTxs.go @@ -22,7 +22,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "github.com/vulcanize/tx_spammer/pkg/manual" + "github.com/cerc-io/tx-spammer/pkg/manual" ) // sendTxsCmd represents the sendTxs command diff --git a/environments/example.toml b/environments/example.toml index d1b4384..673c3b0 100644 --- a/environments/example.toml +++ b/environments/example.toml @@ -1,65 +1,30 @@ [eth] - txs = ["L2ContractDeployment", "L2ContractPutCall", "L2ContractGetCall"] # $ETH_TX_LIST - addrLogPath = "" # ETH_ADDR_LOG + keyDirPath = "./keys/" # path to the directory with all of the key pairs to use - env: $ETH_KEY_DIR_PATH + httpPath = "http://localhost:8545" # http url for the node we wish to send all our transactions to - env: $ETH_HTTP_PATH -[L2ContractDeployment] - type = "L2" - httpPath = "" - chainID = 420 - to = "" - amount = "0" - gasLimit = 0 - gasPrice = "0" - data = "" - senderKeyPath = "" - writeSenderPath = "" - writeDeploymentAddrPath = "" - frequency = 1 - totalNumber = 1 - delay = 0 - l1Sender = "" - l1RollupTxId = 0 - sigHashType = 0 - queueOrigin = 0 +[deployment] + number = 1 # number of contracts we will deploy for each key at keyPath - env: $ETH_DEPLOYMENT_NUMBER + binPath = "sol/build/Test.bin" # hex data for the contracts we will deploy - env: $ETH_DEPLOYMENT_BIN_PATH + gasLimit = 100000 # gasLimit to use for the deployment txs - env: $ETH_DEPLOYMENT_GAS_LIMIT + gasTipCap = "1000000000" # gasTipCap to use for the deployment txs - env: $ETH_DEPLOYMENT_GAS_TIP_CAP + gasFeeCap = "1000000007" # gasFeeCap to use for the deployment txs - env: $ETH_DEPLOYMENT_GAS_FEE_CAP -[L2ContractPutCall] - type = "L2" - httpPath = "" - chainID = 420 - to = "" - amount = "0" - gasLimit = 0 - gasPrice = "0" - data = "" - senderKeyPath = "" - writeSenderPath = "" - frequency = 15 - totalNumber = 1 - delay = 60 - l1Sender = "" - l1RollupTxId = 0 - sigHashType = 0 - queueOrigin = 0 +[contractSpammer] + frequency = -1 # how often to send a transaction (in milliseconds, -1 for no delay) - env: $ETH_CALL_FREQ + totalNumber = -1 # total number of transactions to send (per sender, -1 for unlimited) - env: $ETH_CALL_TOTAL_NUMBER + abiPath = "sol/build/Test.abi" # path to the abi file for the contract we are calling - env: $ETH_CALL_ABI_PATH + # NOTE: we expect to be calling a method such as Put(address addr, uint256 val) where the first argument is an + # integer than we can increment to store values at new locations in the contract trie (to grow it) and + # the second argument is an integer value that we store at these positions + methodName = "Put" # the method name we are calling - env: $ETH_CALL_METHOD_NAME + gasLimit = 42000 # gasLimit to use for the eth call txs - env: $ETH_CALL_GAS_LIMIT + gasTipCap = "1000000000" # gasTipCap to use for the eth call txs - env: $ETH_CALL_GAS_TIP_CAP + gasFeeCap = "1000000007" # gasFeeCap to use for the eth call txs - env: $ETH_CALL_GAS_FEE_CAP -[L2ContractGetCall] - type = "L2" - httpPath = "" - chainID = 420 - to = "" - amount = "0" - gasLimit = 0 - gasPrice = "0" - data = "" - senderKeyPath = "" - writeSenderPath = "" - frequency = 60 - totalNumber = 2 - delay = 30 - l1Sender = "" - l1RollupTxId = 0 - sigHashType = 0 - queueOrigin = 0 - -[log] - level = "info" - file = "" +[sendSpammer] + frequency = -1 # how often to send a transaction (in milliseconds, -1 for no delay) - env: $ETH_SEND_FREQ + totalNumber = -1 # total number of transactions to send (per sender, -1 for unlimited) - env: $ETH_SEND_TOTAL_NUMBER + amount = "10000" # amount of wei (1x10^-18 ETH) to send in each tx (be mindful of the genesis allocations) - env: $ETH_SEND_AMOUNT + gasLimit = 21000 # gasLimit to use for the eth transfer txs - env: $ETH_SEND_GAS_LIMIT + gasTipCap = "1000000000" # gasTipCap to use for the eth transfer txs - env: $ETH_SEND_GAS_TIP_CAP + gasFeeCap = "1000000007" # gasFeeCap to use for the eth transfer txs - env: $ETH_SEND_GAS_FEE_CAP diff --git a/environments/gen.toml b/environments/gen.toml deleted file mode 100644 index 673c3b0..0000000 --- a/environments/gen.toml +++ /dev/null @@ -1,30 +0,0 @@ -[eth] - keyDirPath = "./keys/" # path to the directory with all of the key pairs to use - env: $ETH_KEY_DIR_PATH - httpPath = "http://localhost:8545" # http url for the node we wish to send all our transactions to - env: $ETH_HTTP_PATH - -[deployment] - number = 1 # number of contracts we will deploy for each key at keyPath - env: $ETH_DEPLOYMENT_NUMBER - binPath = "sol/build/Test.bin" # hex data for the contracts we will deploy - env: $ETH_DEPLOYMENT_BIN_PATH - gasLimit = 100000 # gasLimit to use for the deployment txs - env: $ETH_DEPLOYMENT_GAS_LIMIT - gasTipCap = "1000000000" # gasTipCap to use for the deployment txs - env: $ETH_DEPLOYMENT_GAS_TIP_CAP - gasFeeCap = "1000000007" # gasFeeCap to use for the deployment txs - env: $ETH_DEPLOYMENT_GAS_FEE_CAP - -[contractSpammer] - frequency = -1 # how often to send a transaction (in milliseconds, -1 for no delay) - env: $ETH_CALL_FREQ - totalNumber = -1 # total number of transactions to send (per sender, -1 for unlimited) - env: $ETH_CALL_TOTAL_NUMBER - abiPath = "sol/build/Test.abi" # path to the abi file for the contract we are calling - env: $ETH_CALL_ABI_PATH - # NOTE: we expect to be calling a method such as Put(address addr, uint256 val) where the first argument is an - # integer than we can increment to store values at new locations in the contract trie (to grow it) and - # the second argument is an integer value that we store at these positions - methodName = "Put" # the method name we are calling - env: $ETH_CALL_METHOD_NAME - gasLimit = 42000 # gasLimit to use for the eth call txs - env: $ETH_CALL_GAS_LIMIT - gasTipCap = "1000000000" # gasTipCap to use for the eth call txs - env: $ETH_CALL_GAS_TIP_CAP - gasFeeCap = "1000000007" # gasFeeCap to use for the eth call txs - env: $ETH_CALL_GAS_FEE_CAP - -[sendSpammer] - frequency = -1 # how often to send a transaction (in milliseconds, -1 for no delay) - env: $ETH_SEND_FREQ - totalNumber = -1 # total number of transactions to send (per sender, -1 for unlimited) - env: $ETH_SEND_TOTAL_NUMBER - amount = "10000" # amount of wei (1x10^-18 ETH) to send in each tx (be mindful of the genesis allocations) - env: $ETH_SEND_AMOUNT - gasLimit = 21000 # gasLimit to use for the eth transfer txs - env: $ETH_SEND_GAS_LIMIT - gasTipCap = "1000000000" # gasTipCap to use for the eth transfer txs - env: $ETH_SEND_GAS_TIP_CAP - gasFeeCap = "1000000007" # gasFeeCap to use for the eth transfer txs - env: $ETH_SEND_GAS_FEE_CAP diff --git a/go.mod b/go.mod index 35b4b0f..02654d1 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/vulcanize/tx_spammer +module github.com/cerc-io/tx-spammer go 1.13 diff --git a/main.go b/main.go index ed5f364..883bf5c 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ package main -import "github.com/vulcanize/tx_spammer/cmd" +import "github.com/cerc-io/tx-spammer/cmd" func main() { cmd.Execute() diff --git a/pkg/auto/config.go b/pkg/auto/config.go index 0638be1..3c978c6 100644 --- a/pkg/auto/config.go +++ b/pkg/auto/config.go @@ -35,7 +35,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/spf13/viper" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) var ( diff --git a/pkg/auto/deployer.go b/pkg/auto/deployer.go index cad40f0..672cda1 100644 --- a/pkg/auto/deployer.go +++ b/pkg/auto/deployer.go @@ -23,7 +23,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rpc" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) const ( diff --git a/pkg/auto/sender.go b/pkg/auto/sender.go index ccca587..e1b157b 100644 --- a/pkg/auto/sender.go +++ b/pkg/auto/sender.go @@ -20,7 +20,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" "github.com/sirupsen/logrus" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) // EthSender sends eth value transfer txs diff --git a/pkg/auto/service.go b/pkg/auto/service.go index f277d9b..8679a34 100644 --- a/pkg/auto/service.go +++ b/pkg/auto/service.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/sirupsen/logrus" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) // Spammer underlying struct type for spamming service diff --git a/pkg/auto/tx_generator.go b/pkg/auto/tx_generator.go index e40d38a..7ba8662 100644 --- a/pkg/auto/tx_generator.go +++ b/pkg/auto/tx_generator.go @@ -28,7 +28,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) // TxGenerator generates and signs txs diff --git a/pkg/manual/sender.go b/pkg/manual/sender.go index 629076d..073a3c5 100644 --- a/pkg/manual/sender.go +++ b/pkg/manual/sender.go @@ -23,7 +23,7 @@ import ( "github.com/sirupsen/logrus" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) // TxSender type for diff --git a/pkg/manual/service.go b/pkg/manual/service.go index 78713db..deccb1d 100644 --- a/pkg/manual/service.go +++ b/pkg/manual/service.go @@ -18,7 +18,7 @@ package manual import ( "github.com/sirupsen/logrus" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) type Spammer struct { diff --git a/pkg/manual/tx_generator.go b/pkg/manual/tx_generator.go index 0ee509e..d3f40b4 100644 --- a/pkg/manual/tx_generator.go +++ b/pkg/manual/tx_generator.go @@ -22,7 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" - "github.com/vulcanize/tx_spammer/pkg/shared" + "github.com/cerc-io/tx-spammer/pkg/shared" ) // TxGenerator generates and signs txs diff --git a/startup_script.sh b/startup_script.sh old mode 100644 new mode 100755 index f32ec6a..21baa7b --- a/startup_script.sh +++ b/startup_script.sh @@ -1,16 +1,35 @@ #!/bin/sh -set -e -set +x -test $SPAMMER_COMMAND set +e +if [ -z "$SPAMMER_COMMAND" ]; then + echo "SPAMMER_COMMAND env value is required!" + exit 2 +fi + +if [ -z "$LOG_LEVEL" ]; then + LOG_LEVEL="debug" +fi + +if [ ! -z "$ACCOUNTS_CSV_URL" ] && [ ! -d "keys" ]; then + mkdir keys + wget -O accounts.csv $ACCOUNTS_CSV_URL + i=0 + for line in `cat accounts.csv`; do + echo $line | cut -d',' -f3 | sed 's/^0x//' > keys/$i.key + i=$((i + 1)) + done +fi + +if [ ! -d "accounts/addresses" ]; then + mkdir -p "accounts/addresses" +fi echo "Running tx spammer" -./tx_spammer ${SPAMMER_COMMAND} --config=config.toml --log-file=${LOG_FILE} --log-level=${LOG_LEVEL} +./tx-spammer ${SPAMMER_COMMAND} --config=config.toml --log-level=${LOG_LEVEL} if [ $? -eq 0 ]; then echo "tx spammer ran successfully" else echo "tx spammer ran with error. Is the config file correct?" exit 1 -fi \ No newline at end of file +fi