diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..0b1ccdfa --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ +## Effects + +- [ ] Soft update +- [ ] Breaking change +- [ ] Chain fork related + + +## Major Reviewer + + + +## Background + + + +## Summary + + + + + +## Checklist + +- [ ] Backward compatible? +- [ ] Test enough in your local environment? +- [ ] Add related test cases? diff --git a/.github/release-drafter-config.yaml b/.github/release-drafter-config.yaml new file mode 100644 index 00000000..94ca09aa --- /dev/null +++ b/.github/release-drafter-config.yaml @@ -0,0 +1,37 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: '🚀 Features' + label: 'enhancement' + label: 'feature' + + - title: '⚙️ Fixes' + label: 'fix' + label: 'bug' + label: 'hotfix' + + - title: 'Dependency upgrades (Tendermint, Cosmos SDK, EvmOS, etc)' + label: 'dependency' + +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +template: | + ## EFFECTS + + - [ ] Soft update + - [ ] Chain fork related + + ## CHANGES + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml new file mode 100644 index 00000000..1007a680 --- /dev/null +++ b/.github/workflows/go.yaml @@ -0,0 +1,32 @@ +name: Go + +on: + push: + branches: [ "main", "cube", "hypercube", "tesseract", "release/*" ] + pull_request: + branches: [ "*" ] + +jobs: + + build: + runs-on: ubuntu-latest + + strategy: + matrix: + go-version: [1.18.x, 1.19.x] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + + - name: Protogen test + run: make proto-gen + + - name: Test + run: | + go mod tidy + make test diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml new file mode 100644 index 00000000..a611d0a8 --- /dev/null +++ b/.github/workflows/integration-test.yaml @@ -0,0 +1,33 @@ +name: Integration test + +on: + push: + branches: [ "main", "cube", "hypercube", "tesseract", "release/*" ] + pull_request: + branches: [ "*" ] + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup network + run: | + mkdir ~/genesis + cd integration_test && docker-compose up -d + docker ps + sleep 10 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.x + + - name: Integration test + run: cd integration_test && go test + + - name: Teardown + run: cd integration_test && docker-compose down diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 00000000..3a53e336 --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,13 @@ +name: Release Drafter +on: + push: + branches: [ "main", "cube", "hypercube", "tesseract" ] + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + + with: + config-name: release-drafter-config.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d7ffe8b2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +# +# xpla localnet +# +# build: +# docker build --force-rm -t xpladev/xpla . +# run: +# docker run --rm -it --env-file=path/to/.env --name xpla-localnet xpladev/xpla + +### BUILD +FROM golang:1.18-alpine AS build +WORKDIR /localnet + +# Create appuser. +RUN adduser -D -g '' valiuser +# Install required binaries +RUN apk add --update --no-cache zip git make cmake build-base linux-headers musl-dev libc-dev + +# Copy source files +COPY . /localnet/ + +ENV LIBWASMVM_VERSION=v1.0.0 + +RUN git clone --depth 1 https://github.com/microsoft/mimalloc; cd mimalloc; mkdir build; cd build; cmake ..; make -j$(nproc); make install +ENV MIMALLOC_RESERVE_HUGE_OS_PAGES=4 + +# See https://github.com/CosmWasm/wasmvm/releases +ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASMVM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a +ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASMVM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a +RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc +RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 + +# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` +RUN cp /lib/libwasmvm_muslc.`uname -m`.a /lib/libwasmvm_muslc.a + +# Build executable +RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS='-linkmode=external -extldflags "-L/localnet/mimalloc/build -lmimalloc -Wl,-z,muldefs -static"' make build + +# -------------------------------------------------------- +FROM alpine:3.15 AS runtime + +WORKDIR /opt +RUN [ "mkdir", "-p", "/opt/integration_test" ] + +COPY --from=build /localnet/build/xplad /usr/bin/xplad +COPY --from=build /localnet/integration_test /opt/integration_test + +# Expose Cosmos ports +EXPOSE 9090 +EXPOSE 8545 +EXPOSE 26656 +#EXPOSE 26657 + +# Set entry point +CMD [ "/usr/bin/xplad", "version" ] diff --git a/Makefile b/Makefile index 8199325b..2db75ff7 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,13 @@ all: install install: go.sum go install -mod=readonly $(BUILD_FLAGS) ./cmd/xplad +build: go.sum + go build -mod=readonly $(BUILD_FLAGS) -o build/xplad ./cmd/xplad + +.PHONY: test +test: go.sum + go test -short ./... + go.sum: go.mod @go mod verify @go mod tidy diff --git a/ante/ante_test.go b/ante/ante_test.go index 5db269b9..ed372036 100644 --- a/ante/ante_test.go +++ b/ante/ante_test.go @@ -2,6 +2,7 @@ package ante_test import ( "fmt" + "math/rand" "testing" "github.com/cosmos/cosmos-sdk/client" @@ -13,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx/signing" xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/stretchr/testify/suite" - tmrand "github.com/tendermint/tendermint/libs/rand" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" xplaapp "github.com/xpladev/xpla/app" @@ -35,9 +35,11 @@ func TestIntegrationTestSuite(t *testing.T) { } func (s *IntegrationTestSuite) SetupTest() { - app := xplahelpers.Setup(s.T(), false, 1) + chainId := fmt.Sprintf("test_%d-%d", rand.Intn(1000), rand.Intn(10)) + + app := xplahelpers.Setup(s.T(), chainId, false, 1) ctx := app.BaseApp.NewContext(false, tmproto.Header{ - ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)), + ChainID: chainId, Height: 1, }) diff --git a/app/helpers/test_helpers.go b/app/helpers/test_helpers.go index 523c722a..bd36d6e9 100644 --- a/app/helpers/test_helpers.go +++ b/app/helpers/test_helpers.go @@ -43,7 +43,7 @@ type EmptyAppOptions struct{} func (EmptyAppOptions) Get(o string) interface{} { return nil } -func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *xplaapp.XplaApp { +func Setup(t *testing.T, chainId string, isCheckTx bool, invCheckPeriod uint) *xplaapp.XplaApp { t.Helper() app, genesisState := setup(!isCheckTx, invCheckPeriod) @@ -55,6 +55,7 @@ func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *xplaapp.XplaApp { // Initialize the chain app.InitChain( abci.RequestInitChain{ + ChainId: chainId, Validators: []abci.ValidatorUpdate{}, ConsensusParams: DefaultConsensusParams, AppStateBytes: stateBytes, diff --git a/go.mod b/go.mod index 25aaeff8..97737656 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.12.2 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.5.0 @@ -120,7 +121,6 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.34.0 // indirect diff --git a/integration_test/.env b/integration_test/.env new file mode 100644 index 00000000..19b820cb --- /dev/null +++ b/integration_test/.env @@ -0,0 +1,2 @@ +# only for integration test purpose! +XPLAHOME=/opt/.xpla diff --git a/integration_test/README.md b/integration_test/README.md new file mode 100644 index 00000000..35da89a6 --- /dev/null +++ b/integration_test/README.md @@ -0,0 +1,48 @@ +# Integration Test + +This module is basically for the automated integration test. But if you want to execute by yourself for testing (test testing) purpose, this tests are also executable on your local. Please follow the step below: + +## Prerequisites + +- Docker >= 20.10 +- Docker compose >= 2.12 + +## How to run + +```bash +# 1. From the repo root, move to the integration_test, and execute docker compose +cd integration_test +docker-compose up -d + +# 2. Wait for building. Once done without error, you may check the nodes running +docker ps + +#CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +#648b7146ce8c integration_test-node1 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 0.0.0.0:8545->8545/tcp, 0.0.0.0:9090->9090/tcp, 0.0.0.0:26656->26656/tcp xpla-localnet-validator1 +#97279d567135 integration_test-node2 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 8545/tcp, 9090/tcp, 0.0.0.0:9100->9100/tcp, 26656/tcp, 0.0.0.0:26666->26666/tcp xpla-localnet-validator2 +#f604f68c3f82 integration_test-node3 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 8545/tcp, 9090/tcp, 0.0.0.0:9110->9110/tcp, 26656/tcp, 0.0.0.0:26676->26676/tcp xpla-localnet-validator3 +#c3d0d9daefd2 integration_test-node4 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 8545/tcp, 9090/tcp, 0.0.0.0:9120->9120/tcp, 26656/tcp, 0.0.0.0:26686->26686/tcp xpla-localnet-validator4 + +# 3. Execute tests +go test + +# Do not execute short mode +# (X) go test -short + +# ... +# PASS +# ok github.com/xpladev/xpla/integration_test 29.365s + +# If you see the pass sign, you may down the nodes +docker-compose down +``` + +## Test scenario + +### WASM + +- Send `delegation` tx +- Upload the contract binary and get a code ID +- With the code ID above, try to instantiate the contract +- Execute the contract +- Assert from querying the contract in each test step by assertion diff --git a/integration_test/docker-compose.yml b/integration_test/docker-compose.yml new file mode 100644 index 00000000..578071d6 --- /dev/null +++ b/integration_test/docker-compose.yml @@ -0,0 +1,101 @@ +version: "3.7" +services: + node1: + container_name: xpla-localnet-validator1 + + build: + context: ../. + target: runtime + + volumes: + - ~/genesis:/genesis:rw + + ports: + - "8545:8545" + - "9090:9090" + - "26656:26656" + + entrypoint: sh -c "MONIKER=validator1 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_master.sh" + + networks: + vpcbr: + ipv4_address: 192.167.100.1 + + node2: + container_name: xpla-localnet-validator2 + + volumes: + - ~/genesis:/genesis:ro + + depends_on: + - node1 + + build: + context: ../. + target: runtime + + ports: + - "8555:8555" + - "9100:9100" + - "26666:26666" + + entrypoint: sh -c "MONIKER=validator2 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh" + + networks: + vpcbr: + ipv4_address: 192.167.100.2 + + node3: + container_name: xpla-localnet-validator3 + + volumes: + - ~/genesis:/genesis:ro + + depends_on: + - node1 + + build: + context: ../. + target: runtime + + ports: + - "8565:8565" + - "9110:9110" + - "26676:26676" + + entrypoint: sh -c "MONIKER=validator3 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh" + + networks: + vpcbr: + ipv4_address: 192.167.100.3 + + node4: + container_name: xpla-localnet-validator4 + + volumes: + - ~/genesis:/genesis:ro + + depends_on: + - node1 + + build: + context: ../. + target: runtime + + ports: + - "8575:8575" + - "9120:9120" + - "26686:26686" + + entrypoint: sh -c "MONIKER=validator4 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh" + + networks: + vpcbr: + ipv4_address: 192.167.100.4 + +networks: + vpcbr: + driver: bridge + ipam: + config: + - subnet: 192.167.0.0/16 diff --git a/integration_test/entrypoint.sh b/integration_test/entrypoint.sh new file mode 100644 index 00000000..862deb1f --- /dev/null +++ b/integration_test/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh + +# 1. chain init +/usr/bin/xplad init $MONIKER --chain-id localtest_1-1 --home $XPLAHOME + +# 2. copy the node setting files to the node home dir +cp -r /opt/integration_test/$MONIKER/* /opt/.xpla/config + +# 3. register my validator & users keyfile +/usr/bin/xplad keys add validator1 --recover --home $XPLAHOME < /opt/integration_test/test_keys/$MONIKER.mnemonics +/usr/bin/xplad keys add user1 --recover --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics +/usr/bin/xplad keys add user2 --recover --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics + +# 4. check genesis.json +/usr/bin/xplad validate-genesis --home $XPLAHOME + +# 5. start daemon +/usr/bin/xplad start --home=$XPLAHOME diff --git a/integration_test/entrypoint_master.sh b/integration_test/entrypoint_master.sh new file mode 100644 index 00000000..7644c1fd --- /dev/null +++ b/integration_test/entrypoint_master.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh + +# File is not atomic and somestimes secondary nodes copies the existing old genesisfile +# It should be cleared +rm -f /genesis/* + +# 1. chain init +/usr/bin/xplad init $MONIKER --chain-id localtest_1-1 --home $XPLAHOME + +# 2. Register the keys +# xpla1z2k85n48ydfvzslrugwzl4j2u7vtdyf3xvucmc +/usr/bin/xplad keys add validator1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator1.mnemonics +# xpla16wx7ye3ce060tjvmmpu8lm0ak5xr7gm2dp0kpt +/usr/bin/xplad keys add validator2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator2.mnemonics +# xpla1pe9mc2q72u94sn2gg52ramrt26x5efw6hr5gt4 +/usr/bin/xplad keys add validator3 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator3.mnemonics +# xpla1luqjvjyns9e92h06tq6zqtw76k8xtegfcerzjr +/usr/bin/xplad keys add validator4 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator4.mnemonics +# xpla1y6gnay0pv49asun56la09jcmhg2kc949mpftvt +/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics +# xpla1u27snswkjpenlscgvszcfjmz8uy2y5qacx0826 +/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics + +# 3. Add the genesis accounts +/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator1 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME +/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator2 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME +/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator3 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME +/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator4 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME +/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show user1 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME +/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show user2 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME + +# 4. Get the node keys and create gentxs +for IDX in 1 2 3 4 +do + # 1) Copy the credentials + cp /opt/integration_test/validator$IDX/node_key.json $XPLAHOME/config + cp /opt/integration_test/validator$IDX/priv_validator_key.json $XPLAHOME/config + + # 2) Execute a gentx + /usr/bin/xplad gentx validator$IDX 2000000000000000000axpla \ + --chain-id="localtest_1-1" \ + --pubkey=$(xplad tendermint show-validator --home $XPLAHOME) \ + --min-self-delegation=1 \ + --moniker=validator$IDX \ + --commission-rate=0.1 \ + --commission-max-rate=0.2 \ + --commission-max-change-rate=0.01 \ + --ip="192.167.100.$IDX" \ + --keyring-backend test \ + --home $XPLAHOME + +done + +# 5. Do collect gentxs +/usr/bin/xplad collect-gentxs --home $XPLAHOME + +# 6. Replace staking denom +sed -i 's/"bond_denom": "stake"/"bond_denom": "axpla"/g' $XPLAHOME/config/genesis.json +sed -i 's/"evm_denom": "aphoton",/"evm_denom": "axpla",/g' $XPLAHOME/config/genesis.json +sed -i 's/"mint_denom": "stake",/"mint_denom": "axpla",/g' $XPLAHOME/config/genesis.json +sed -i 's/"denom": "stake",/"denom": "axpla",/g' $XPLAHOME/config/genesis.json +sed -i 's/"max_gas": "-1",/"max_gas": "5000000",/g' $XPLAHOME/config/genesis.json +sed -i 's/"no_base_fee": false,/"no_base_fee": true,/g' $XPLAHOME/config/genesis.json +sed -i 's/"inflation": "0.130000000000000000",/"inflation": "0.000000000000000000",/g' $XPLAHOME/config/genesis.json +sed -i 's/"inflation_rate_change": "0.130000000000000000",/"inflation_rate_change": "0.000000000000000000",/g' $XPLAHOME/config/genesis.json +sed -i 's/"inflation_min": "0.070000000000000000",/"inflation_min": "0.000000000000000000",/g' $XPLAHOME/config/genesis.json + +/usr/bin/xplad validate-genesis --home $XPLAHOME + +# 7. Copy to the shared folder +cp $XPLAHOME/config/genesis.json /genesis + +### ALL DONE FOR GENESIS CONFIG +### followings are for validator setting + +# 1. Copy the node setting files to the node home dir +cp -r /opt/integration_test/$MONIKER/* $XPLAHOME/config + +# 2. Get genesis.json from the shared +cp /genesis/genesis.json $XPLAHOME/config + +# 4. check genesis.json +/usr/bin/xplad validate-genesis --home $XPLAHOME +cat $XPLAHOME/config/genesis.json + +# 5. start daemon +/usr/bin/xplad tendermint unsafe-reset-all --home=$XPLAHOME +/usr/bin/xplad start --home=$XPLAHOME diff --git a/integration_test/entrypoint_secondary.sh b/integration_test/entrypoint_secondary.sh new file mode 100644 index 00000000..740c557f --- /dev/null +++ b/integration_test/entrypoint_secondary.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh + +# 1. chain init +/usr/bin/xplad init $MONIKER --chain-id localtest_1-1 --home $XPLAHOME + +# 2. copy the node setting files to the node home dir +cp -r /opt/integration_test/$MONIKER/* $XPLAHOME/config + +# 3. register my validator & users keyfile +/usr/bin/xplad keys add $MONIKER --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/$MONIKER.mnemonics +/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics +/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics + +# 4. get genesis.json from the shared folder +# "depends_on" in docker-compose.yml means that it depends on Dockerfile image, not completely wait for the entrypoint exeuction. +sleep 10s +cp /genesis/genesis.json $XPLAHOME/config + +# 4. check genesis.json +/usr/bin/xplad validate-genesis --home $XPLAHOME + +# 5. start daemon +/usr/bin/xplad tendermint unsafe-reset-all --home=$XPLAHOME +/usr/bin/xplad start --home=$XPLAHOME diff --git a/integration_test/grpcclient_test.go b/integration_test/grpcclient_test.go new file mode 100644 index 00000000..2d88b7bb --- /dev/null +++ b/integration_test/grpcclient_test.go @@ -0,0 +1,148 @@ +package integrationtest + +import ( + "context" + "crypto/tls" + "crypto/x509" + "strconv" + "strings" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/backoff" + "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/credentials" +) + +const BACK_OFF_MAX_DELAY = 3 * time.Second + +type ServiceDesc struct { + Destination string + DestinationPort int + BackoffMaxDelay time.Duration + NoTLS bool + + ServiceConn *grpc.ClientConn +} + +func NewServiceDesc(dest string, port int, backoffDelayBySec int, noTls bool) *ServiceDesc { + serv := &ServiceDesc{ + Destination: dest, + DestinationPort: port, + BackoffMaxDelay: time.Second * time.Duration(backoffDelayBySec), + NoTLS: noTls, + } + + serv.GetConnectionWithContext(context.Background()) + + return serv +} + +func (desc *ServiceDesc) GetServiceDesc() *ServiceDesc { + return desc +} + +// GetConnectionWithContext returns gRPC client connection with context +func (desc *ServiceDesc) GetConnectionWithContext(ctx context.Context, opts ...grpc.DialOption) *grpc.ClientConn { + if desc.ServiceConn != nil { + return desc.ServiceConn + } + + dest := desc.Destination + // Assemble port + dest = strings.Join([]string{dest, strconv.Itoa(desc.DestinationPort)}, ":") + + options := opts + if !desc.NoTLS { + // FIXME: it is very slow procedure, we should have cert in local filesystem or cache it + conn, err := tls.Dial("tcp", dest, &tls.Config{ + InsecureSkipVerify: true, + }) + + if err != nil { + logger.Fatalln("cannot dial to TLS enabled server:", err) + return nil + } + + certs := conn.ConnectionState().PeerCertificates + err = conn.Close() + if err != nil { + logger.Fatalln("cannot close TLS connection:", err) + } + + pool := x509.NewCertPool() + pool.AddCert(certs[0]) + + clientCert := credentials.NewClientTLSFromCert(pool, "") + options = append(options, grpc.WithTransportCredentials(clientCert)) + } else { + options = append(options, grpc.WithInsecure()) + } + + backoff := backoff.DefaultConfig + // We apply backoff max delay (3 seconds by default) + backoff.MaxDelay = func() time.Duration { + delay := desc.BackoffMaxDelay + if delay != 0 { + return delay + } + return BACK_OFF_MAX_DELAY + }() + + options = append(options, grpc.WithConnectParams(grpc.ConnectParams{ + Backoff: backoff, + })) + + logger.Println("dial ", dest) + conn, err := grpc.DialContext(ctx, dest, options...) + if err != nil { + // It is very likely unreachable code under non-blocking dialing + logger.Panic("cannot connect to gRPC server:", err) + } + desc.ServiceConn = conn + + // State change logger + go func() { + isReady := false + + for { + s := conn.GetState() + if s == connectivity.Shutdown { + logger.Println("connection state: ", s) + break + } else if isReady && s == connectivity.TransientFailure { + logger.Println("connection state : ", s) + isReady = false + } + + if !conn.WaitForStateChange(ctx, s) { + // Logging last state just after ctx expired + // Even this can miss last "shutdown" state. very unlikely. + last := conn.GetState() + if s != last { + logger.Println("connection state: ", last) + } + break + } + } + }() + + return desc.ServiceConn +} + +// CloseConnection closes existing connection +func (desc *ServiceDesc) CloseConnection() error { + if desc.ServiceConn == nil { + // Very unlikely + logger.Fatalln("connection is already closed or not connected yet") + return nil + } + + err := desc.ServiceConn.Close() + if err != nil { + return err + } + + desc.ServiceConn = nil + return nil +} diff --git a/integration_test/init_test.go b/integration_test/init_test.go new file mode 100644 index 00000000..3401cb9d --- /dev/null +++ b/integration_test/init_test.go @@ -0,0 +1,25 @@ +package integrationtest + +import ( + "log" + "os" + + xplatype "github.com/xpladev/xpla/types" +) + +const ( + xplaGeneralGasLimit int64 = 240000 + xplaCodeGasLimit int64 = 5000000 + xplaGasPrice = "8500000000" +) + +var ( + logger *log.Logger + desc *ServiceDesc +) + +func init() { + logger = log.New(os.Stderr, "base network", 0) + + xplatype.SetConfig() +} diff --git a/integration_test/integration_test.go b/integration_test/integration_test.go new file mode 100644 index 00000000..77bf1638 --- /dev/null +++ b/integration_test/integration_test.go @@ -0,0 +1,581 @@ +package integrationtest + +import ( + "context" + "encoding/hex" + "encoding/json" + "fmt" + "math/big" + "os" + "path/filepath" + "testing" + "time" + + wasmtype "github.com/CosmWasm/wasmd/x/wasm/types" + sdktypes "github.com/cosmos/cosmos-sdk/types" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" + stakingtype "github.com/cosmos/cosmos-sdk/x/staking/types" + + // evmtypes "github.com/evmos/ethermint/x/evm/types" + + abibind "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethcommon "github.com/ethereum/go-ethereum/common" + ethcrypto "github.com/ethereum/go-ethereum/crypto" + web3 "github.com/ethereum/go-ethereum/ethclient" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +func TestWasmContractAndTx(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + testSuite := &WASMIntegrationTestSuite{} + suite.Run(t, testSuite) +} + +type WASMIntegrationTestSuite struct { + suite.Suite + + TokenAddress string + + UserWallet1 *WalletInfo + UserWallet2 *WalletInfo + ValidatorWallet1 *WalletInfo +} + +func (i *WASMIntegrationTestSuite) SetupSuite() { + desc = NewServiceDesc("127.0.0.1", 9090, 10, true) + + i.UserWallet1, i.UserWallet2, i.ValidatorWallet1 = walletSetup() +} + +func (i *WASMIntegrationTestSuite) SetupTest() { + i.UserWallet1, i.UserWallet2, i.ValidatorWallet1 = walletSetup() + + i.UserWallet1.RefreshSequence() + i.UserWallet2.RefreshSequence() + i.ValidatorWallet1.RefreshSequence() +} + +func (i *WASMIntegrationTestSuite) TearDownTest() {} + +func (u *WASMIntegrationTestSuite) TearDownSuite() { + desc.CloseConnection() +} + +// Test strategy +// 1. Simple delegation +// 2. Contract upload +// 3. Contract initiate +// 4. Contract execute + +func (t *WASMIntegrationTestSuite) Test01_SimpleDelegation() { + amt := sdktypes.NewInt(100000000000000) + coin := &sdktypes.Coin{ + Denom: "axpla", + Amount: amt, + } + + delegationMsg := stakingtype.NewMsgDelegate( + t.UserWallet1.ByteAddress, + t.ValidatorWallet1.ByteAddress.Bytes(), + *coin, + ) + + feeAmt := sdktypes.NewDec(xplaGeneralGasLimit).Mul(sdktypes.MustNewDecFromStr(xplaGasPrice)) + fee := sdktypes.Coin{ + Denom: "axpla", + Amount: feeAmt.Ceil().RoundInt(), + } + + txhash, err := t.UserWallet1.SendTx(ChainID, delegationMsg, fee, xplaGeneralGasLimit, false) + assert.NoError(t.T(), err) + assert.NotNil(t.T(), txhash) + + err = txCheck(txhash) + assert.NoError(t.T(), err) + + queryClient := stakingtype.NewQueryClient(desc.GetConnectionWithContext(context.Background())) + + queryDelegatorMsg := &stakingtype.QueryDelegatorDelegationsRequest{ + DelegatorAddr: t.UserWallet1.StringAddress, + } + + delegationResp, err := queryClient.DelegatorDelegations(context.Background(), queryDelegatorMsg) + assert.NoError(t.T(), err) + + delegatedList := delegationResp.GetDelegationResponses() + + expected := []stakingtype.DelegationResponse{ + stakingtype.NewDelegationResp( + t.UserWallet1.ByteAddress, + t.ValidatorWallet1.ByteAddress.Bytes(), + sdktypes.NewDecFromInt(amt), + sdktypes.Coin{ + Denom: "axpla", + Amount: amt, + }, + ), + } + + assert.Equal(t.T(), expected, delegatedList) +} + +func (t *WASMIntegrationTestSuite) Test02_StoreCode() { + contractBytes, err := os.ReadFile(filepath.Join(".", "misc", "token.wasm")) + if err != nil { + panic(err) + } + + storeMsg := &wasmtype.MsgStoreCode{ + Sender: t.UserWallet1.StringAddress, + WASMByteCode: contractBytes, + } + + feeAmt := sdktypes.NewDec(xplaCodeGasLimit).Mul(sdktypes.MustNewDecFromStr(xplaGasPrice)) + + fee := sdktypes.Coin{ + Denom: "axpla", + Amount: feeAmt.Ceil().RoundInt(), + } + + txhash, err := t.UserWallet1.SendTx(ChainID, storeMsg, fee, xplaCodeGasLimit, false) + + assert.NoError(t.T(), err) + assert.NotNil(t.T(), txhash) + + err = txCheck(txhash) + assert.NoError(t.T(), err) + + queryClient := wasmtype.NewQueryClient(desc.GetConnectionWithContext(context.Background())) + + queryCodeMsg := &wasmtype.QueryCodeRequest{ + CodeId: 1, + } + + resp, err := queryClient.Code(context.Background(), queryCodeMsg) + + assert.NoError(t.T(), err) + assert.NotNil(t.T(), resp) +} + +func (t *WASMIntegrationTestSuite) Test03_InstantiateContract() { + initMsg := []byte(fmt.Sprintf(` + { + "name": "testtoken", + "symbol": "TKN", + "decimals": 6, + "initial_balances": [ + { + "address": "%s", + "amount": "100000000" + } + ] + } + `, t.UserWallet2.StringAddress)) + + instantiateMsg := &wasmtype.MsgInstantiateContract{ + Sender: t.UserWallet2.StringAddress, + Admin: t.UserWallet2.StringAddress, + CodeID: 1, + Label: "Integration test purpose", + Msg: initMsg, + } + + feeAmt := sdktypes.NewDec(xplaGeneralGasLimit).Mul(sdktypes.MustNewDecFromStr(xplaGasPrice)) + fee := sdktypes.Coin{ + Denom: "axpla", + Amount: feeAmt.Ceil().RoundInt(), + } + + txhash, err := t.UserWallet2.SendTx(ChainID, instantiateMsg, fee, xplaGeneralGasLimit, false) + assert.NoError(t.T(), err) + assert.NotNil(t.T(), txhash) + + err = txCheck(txhash) + assert.NoError(t.T(), err) + + queryClient := txtypes.NewServiceClient(desc.GetConnectionWithContext(context.Background())) + resp, err := queryClient.GetTx(context.Background(), &txtypes.GetTxRequest{ + Hash: txhash, + }) + + assert.NoError(t.T(), err) + +ATTR: + for _, val := range resp.TxResponse.Events { + for _, attr := range val.Attributes { + if string(attr.Key) == "_contract_address" { + t.TokenAddress = string(attr.Value) + break ATTR + } + } + } + + queryTokenAmtClient := wasmtype.NewQueryClient(desc.GetConnectionWithContext(context.Background())) + + queryStr := []byte(fmt.Sprintf(`{ + "balance": { + "address": "%s" + } + }`, t.UserWallet2.StringAddress)) + + tokenResp, err := queryTokenAmtClient.SmartContractState(context.Background(), &wasmtype.QuerySmartContractStateRequest{ + Address: t.TokenAddress, + QueryData: queryStr, + }) + + assert.NoError(t.T(), err) + assert.NotNil(t.T(), tokenResp) + + type AmtResp struct { + Balance string `json:"balance"` + } + + amtResp := &AmtResp{} + err = json.Unmarshal(tokenResp.Data.Bytes(), amtResp) + assert.NoError(t.T(), err) + + assert.Equal(t.T(), "100000000", amtResp.Balance) +} + +func (t *WASMIntegrationTestSuite) Test04_ContractExecution() { + transferMsg := []byte(fmt.Sprintf(` + { + "transfer": { + "recipient": "%s", + "amount": "50000000" + } + } + `, t.UserWallet1.StringAddress)) + + contractExecMsg := &wasmtype.MsgExecuteContract{ + Sender: t.UserWallet2.StringAddress, + Contract: t.TokenAddress, + Msg: transferMsg, + } + + feeAmt := sdktypes.NewDec(xplaGeneralGasLimit).Mul(sdktypes.MustNewDecFromStr(xplaGasPrice)) + fee := sdktypes.Coin{ + Denom: "axpla", + Amount: feeAmt.Ceil().RoundInt(), + } + + txhash, err := t.UserWallet2.SendTx(ChainID, contractExecMsg, fee, xplaGeneralGasLimit, false) + assert.NoError(t.T(), err) + assert.NotNil(t.T(), txhash) + + err = txCheck(txhash) + assert.NoError(t.T(), err) + + queryTokenAmtClient := wasmtype.NewQueryClient(desc.GetConnectionWithContext(context.Background())) + + queryStr := []byte(fmt.Sprintf(`{ + "balance": { + "address": "%s" + } + }`, t.UserWallet2.StringAddress)) + + tokenResp, err := queryTokenAmtClient.SmartContractState(context.Background(), &wasmtype.QuerySmartContractStateRequest{ + Address: t.TokenAddress, + QueryData: queryStr, + }) + + assert.NoError(t.T(), err) + assert.NotNil(t.T(), tokenResp) + + type AmtResp struct { + Balance string `json:"balance"` + } + + amtResp := &AmtResp{} + err = json.Unmarshal(tokenResp.Data.Bytes(), amtResp) + assert.NoError(t.T(), err) + + assert.Equal(t.T(), "50000000", amtResp.Balance) +} + +// Test strategy +// 1. Check balance +// 2. Contract upload & initiate +// 3. Contract execute +// 4. Contract execute by Cosmos SDK Tx -> available from ethermint v0.20 + +func TestEVMContractAndTx(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + if os.Getenv("GITHUB_BASE_REF") != "hypercube" { + t.Skip("EVM is only available on hypercube!") + } + + testSuite := &EVMIntegrationTestSuite{} + suite.Run(t, testSuite) +} + +type EVMIntegrationTestSuite struct { + suite.Suite + + EthClient *web3.Client + + Coinbase string + TokenAddress ethcommon.Address + + UserWallet1 *EVMWalletInfo + UserWallet2 *EVMWalletInfo + ValidatorWallet1 *EVMWalletInfo +} + +func (t *EVMIntegrationTestSuite) SetupSuite() { + desc = NewServiceDesc("127.0.0.1", 9090, 10, true) + + var err error + t.EthClient, err = web3.Dial("http://localhost:8545") + if err != nil { + panic(err) + } + + t.UserWallet1, t.UserWallet2, t.ValidatorWallet1 = evmWalletSetup() +} + +func (t *EVMIntegrationTestSuite) TearDownSuite() { + desc.CloseConnection() + t.EthClient.Close() +} + +func (t *EVMIntegrationTestSuite) SetupTest() { + t.UserWallet1.GetNonce(t.EthClient) + t.UserWallet2.GetNonce(t.EthClient) + t.ValidatorWallet1.GetNonce(t.EthClient) + + t.UserWallet1.CosmosWalletInfo.RefreshSequence() + t.UserWallet2.CosmosWalletInfo.RefreshSequence() + t.ValidatorWallet1.CosmosWalletInfo.RefreshSequence() +} + +func (i *EVMIntegrationTestSuite) TeardownTest() {} + +func (t *EVMIntegrationTestSuite) Test01_CheckBalance() { + resp, err := t.EthClient.BalanceAt(context.Background(), t.UserWallet1.EthAddress, nil) + + assert.NoError(t.T(), err) + + expectedInt := new(big.Int) + expectedInt, _ = expectedInt.SetString("99000000000000000000", 10) + assert.GreaterOrEqual(t.T(), 1, resp.Cmp(expectedInt)) + + expectedInt, _ = expectedInt.SetString("100000000000000000000", 10) + assert.LessOrEqual(t.T(), -1, resp.Cmp(expectedInt)) +} + +func (t *EVMIntegrationTestSuite) Test02_DeployTokenContract() { + // Prepare parameters + networkId, err := t.EthClient.NetworkID(context.Background()) + assert.NoError(t.T(), err) + + ethPrivkey, _ := ethcrypto.ToECDSA(t.UserWallet1.CosmosWalletInfo.PrivKey.Bytes()) + auth, err := abibind.NewKeyedTransactorWithChainID(ethPrivkey, networkId) + assert.NoError(t.T(), err) + + auth.GasLimit = uint64(1300000) + auth.GasPrice, _ = new(big.Int).SetString(xplaGasPrice, 10) + + strbin, err := os.ReadFile(filepath.Join(".", "misc", "token.sol.bin")) + assert.NoError(t.T(), err) + + binbyte, _ := hex.DecodeString(string(strbin)) + + parsedAbi, err := TokenInterfaceMetaData.GetAbi() + assert.NoError(t.T(), err) + assert.NotNil(t.T(), parsedAbi) + + // Actual deploy + address, tx, _, err := abibind.DeployContract(auth, *parsedAbi, binbyte, t.EthClient, "Example Token", "XPLAERC") + assert.NoError(t.T(), err) + fmt.Println("Tx hash: ", tx.Hash().String()) + + time.Sleep(time.Second * 7) + + fmt.Println("Token address: ", address.String()) + t.TokenAddress = address +} + +func (t *EVMIntegrationTestSuite) Test03_ExecuteTokenContractAndQueryOnEvmJsonRpc() { + // Prepare parameters + networkId, err := t.EthClient.NetworkID(context.Background()) + assert.NoError(t.T(), err) + + store, err := NewTokenInterface(t.TokenAddress, t.EthClient) + assert.NoError(t.T(), err) + + // 10^18 + multiplier, _ := new(big.Int).SetString("1000000000000000000", 10) + amt := new(big.Int).Mul(big.NewInt(10), multiplier) + + ethPrivkey, _ := ethcrypto.ToECDSA(t.UserWallet1.CosmosWalletInfo.PrivKey.Bytes()) + auth, err := abibind.NewKeyedTransactorWithChainID(ethPrivkey, networkId) + assert.NoError(t.T(), err) + + auth.GasLimit = uint64(300000) + auth.GasPrice, _ = new(big.Int).SetString(xplaGasPrice, 10) + + // try to transfer + tx, err := store.Transfer(auth, t.UserWallet2.EthAddress, amt) + assert.NoError(t.T(), err) + fmt.Println("Sent as ", tx.Hash().String()) + + time.Sleep(time.Second * 7) + + // query & assert + callOpt := &abibind.CallOpts{} + resp, err := store.BalanceOf(callOpt, t.UserWallet2.EthAddress) + assert.NoError(t.T(), err) + + assert.Equal(t.T(), amt, resp) +} + +// Wrote and tried to test triggering EVM by MsgEthereumTx +// But there is a collision between tx msg caching <> ethermint antehandler +// MsgEthereumTx.From kept left <> ethermint antehandler checks and passes only MsgEthereumTx.From is empty +// It resolves from ethermint v0.20 +// Before that, EVM can only be triggered by 8545 + +// func (t *EVMIntegrationTestSuite) Test04_ExecuteTokenContractAndQueryOnCosmos() { +// store, err := NewTokenInterface(t.TokenAddress, t.EthClient) +// assert.NoError(t.T(), err) + +// networkId, err := t.EthClient.NetworkID(context.Background()) +// assert.NoError(t.T(), err) + +// multiplier, _ := new(big.Int).SetString("1000000000000000000", 10) +// amt := new(big.Int).Mul(big.NewInt(10), multiplier) + +// ethPrivkey, _ := ethcrypto.ToECDSA(t.UserWallet1.CosmosWalletInfo.PrivKey.Bytes()) +// auth, err := abibind.NewKeyedTransactorWithChainID(ethPrivkey, networkId) +// assert.NoError(t.T(), err) + +// auth.NoSend = true +// auth.GasLimit = uint64(xplaGeneralGasLimit) +// auth.GasPrice, _ = new(big.Int).SetString(xplaGasPrice, 10) + +// unsentTx, err := store.Transfer(auth, t.UserWallet2.EthAddress, amt) +// assert.NoError(t.T(), err) + +// msg := &evmtypes.MsgEthereumTx{} +// err = msg.FromEthereumTx(unsentTx) +// assert.NoError(t.T(), err) + +// feeAmt := sdktypes.NewDec(xplaGeneralGasLimit).Mul(sdktypes.MustNewDecFromStr(xplaGasPrice)) +// fee := sdktypes.Coin{ +// Denom: "axpla", +// Amount: feeAmt.Ceil().RoundInt(), +// } + +// txHash, err := t.UserWallet1.CosmosWalletInfo.SendTx(ChainID, msg, fee, xplaGeneralGasLimit, true) +// assert.NoError(t.T(), err) + +// err = txCheck(txHash) +// assert.NoError(t.T(), err) + +// // check +// callOpt := &abibind.CallOpts{} +// resp, err := store.BalanceOf(callOpt, t.UserWallet2.EthAddress) +// assert.NoError(t.T(), err) + +// fmt.Println(resp.String()) + +// assert.Equal(t.T(), new(big.Int).Add(amt, amt), resp) +// } + +func walletSetup() (userWallet1, userWallet2, validatorWallet1 *WalletInfo) { + var err error + + user1Mnemonics, err := os.ReadFile(filepath.Join(".", "test_keys", "user1.mnemonics")) + if err != nil { + panic(err) + } + + userWallet1, err = NewWalletInfo(string(user1Mnemonics)) + if err != nil { + panic(err) + } + + user2Mnemonics, err := os.ReadFile(filepath.Join(".", "test_keys", "user2.mnemonics")) + if err != nil { + panic(err) + } + + userWallet2, err = NewWalletInfo(string(user2Mnemonics)) + if err != nil { + panic(err) + } + + validator1Mnemonics, err := os.ReadFile(filepath.Join(".", "test_keys", "validator1.mnemonics")) + if err != nil { + panic(err) + } + + validatorWallet1, err = NewWalletInfo(string(validator1Mnemonics)) + if err != nil { + panic(err) + } + + return +} + +func evmWalletSetup() (userWallet1, userWallet2, validatorWallet1 *EVMWalletInfo) { + var err error + + user1Mnemonics, err := os.ReadFile(filepath.Join(".", "test_keys", "user1.mnemonics")) + if err != nil { + panic(err) + } + + userWallet1, err = NewEVMWalletInfo(string(user1Mnemonics)) + if err != nil { + panic(err) + } + + user2Mnemonics, err := os.ReadFile(filepath.Join(".", "test_keys", "user2.mnemonics")) + if err != nil { + panic(err) + } + + userWallet2, err = NewEVMWalletInfo(string(user2Mnemonics)) + if err != nil { + panic(err) + } + + validator1Mnemonics, err := os.ReadFile(filepath.Join(".", "test_keys", "validator1.mnemonics")) + if err != nil { + panic(err) + } + + validatorWallet1, err = NewEVMWalletInfo(string(validator1Mnemonics)) + if err != nil { + panic(err) + } + + return +} + +func txCheck(txHash string) error { + var err error + + for i := 0; i < 20; i++ { + txClient := txtypes.NewServiceClient(desc.GetConnectionWithContext(context.Background())) + _, err = txClient.GetTx(context.Background(), &txtypes.GetTxRequest{Hash: txHash}) + + if err == nil { + return nil + } + + time.Sleep(time.Second / 2) + } + + return err +} diff --git a/integration_test/misc/token.sol b/integration_test/misc/token.sol new file mode 100644 index 00000000..424decb5 --- /dev/null +++ b/integration_test/misc/token.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.0.0/contracts/token/ERC20/ERC20.sol"; + +contract MyToken is ERC20 { + constructor(string memory name, string memory symbol) ERC20(name, symbol) { + // Mint 100 tokens to msg.sender + // Similar to how + // 1 dollar = 100 cents + // 1 token = 1 * (10 ** decimals) + _mint(msg.sender, 100 * 10**uint(decimals())); + } +} diff --git a/integration_test/misc/token.sol.abi b/integration_test/misc/token.sol.abi new file mode 100644 index 00000000..23bff8b0 --- /dev/null +++ b/integration_test/misc/token.sol.abi @@ -0,0 +1,288 @@ +[ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/integration_test/misc/token.sol.bin b/integration_test/misc/token.sol.bin new file mode 100644 index 00000000..2571981f --- /dev/null +++ b/integration_test/misc/token.sol.bin @@ -0,0 +1 @@ +60806040523480156200001157600080fd5b5060405162001c9e38038062001c9e833981810160405281019062000037919062000474565b818181600390805190602001906200005192919062000227565b5080600490805190602001906200006a92919062000227565b505050620000ad3362000082620000b560201b60201c565b60ff16600a62000093919062000686565b6064620000a19190620006d7565b620000be60201b60201c565b5050620008aa565b60006012905090565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160362000130576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620001279062000799565b60405180910390fd5b62000144600083836200022260201b60201c565b8060026000828254620001589190620007bb565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254620001af9190620007bb565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405162000216919062000829565b60405180910390a35050565b505050565b828054620002359062000875565b90600052602060002090601f016020900481019282620002595760008555620002a5565b82601f106200027457805160ff1916838001178555620002a5565b82800160010185558215620002a5579182015b82811115620002a457825182559160200191906001019062000287565b5b509050620002b49190620002b8565b5090565b5b80821115620002d3576000816000905550600101620002b9565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200034082620002f5565b810181811067ffffffffffffffff8211171562000362576200036162000306565b5b80604052505050565b600062000377620002d7565b905062000385828262000335565b919050565b600067ffffffffffffffff821115620003a857620003a762000306565b5b620003b382620002f5565b9050602081019050919050565b60005b83811015620003e0578082015181840152602081019050620003c3565b83811115620003f0576000848401525b50505050565b60006200040d62000407846200038a565b6200036b565b9050828152602081018484840111156200042c576200042b620002f0565b5b62000439848285620003c0565b509392505050565b600082601f830112620004595762000458620002eb565b5b81516200046b848260208601620003f6565b91505092915050565b600080604083850312156200048e576200048d620002e1565b5b600083015167ffffffffffffffff811115620004af57620004ae620002e6565b5b620004bd8582860162000441565b925050602083015167ffffffffffffffff811115620004e157620004e0620002e6565b5b620004ef8582860162000441565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008160011c9050919050565b6000808291508390505b600185111562000587578086048111156200055f576200055e620004f9565b5b60018516156200056f5780820291505b80810290506200057f8562000528565b94506200053f565b94509492505050565b600082620005a2576001905062000675565b81620005b2576000905062000675565b8160018114620005cb5760028114620005d6576200060c565b600191505062000675565b60ff841115620005eb57620005ea620004f9565b5b8360020a915084821115620006055762000604620004f9565b5b5062000675565b5060208310610133831016604e8410600b8410161715620006465782820a90508381111562000640576200063f620004f9565b5b62000675565b62000655848484600162000535565b925090508184048111156200066f576200066e620004f9565b5b81810290505b9392505050565b6000819050919050565b600062000693826200067c565b9150620006a0836200067c565b9250620006cf7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848462000590565b905092915050565b6000620006e4826200067c565b9150620006f1836200067c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156200072d576200072c620004f9565b5b828202905092915050565b600082825260208201905092915050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b600062000781601f8362000738565b91506200078e8262000749565b602082019050919050565b60006020820190508181036000830152620007b48162000772565b9050919050565b6000620007c8826200067c565b9150620007d5836200067c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156200080d576200080c620004f9565b5b828201905092915050565b62000823816200067c565b82525050565b600060208201905062000840600083018462000818565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200088e57607f821691505b602082108103620008a457620008a362000846565b5b50919050565b6113e480620008ba6000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c39190610c45565b60405180910390f35b6100e660048036038101906100e19190610d00565b610308565b6040516100f39190610d5b565b60405180910390f35b610104610326565b6040516101119190610d85565b60405180910390f35b610134600480360381019061012f9190610da0565b610330565b6040516101419190610d5b565b60405180910390f35b610152610431565b60405161015f9190610e0f565b60405180910390f35b610182600480360381019061017d9190610d00565b61043a565b60405161018f9190610d5b565b60405180910390f35b6101b260048036038101906101ad9190610e2a565b6104e6565b6040516101bf9190610d85565b60405180910390f35b6101d061052e565b6040516101dd9190610c45565b60405180910390f35b61020060048036038101906101fb9190610d00565b6105c0565b60405161020d9190610d5b565b60405180910390f35b610230600480360381019061022b9190610d00565b6106b4565b60405161023d9190610d5b565b60405180910390f35b610260600480360381019061025b9190610e57565b6106d2565b60405161026d9190610d85565b60405180910390f35b60606003805461028590610ec6565b80601f01602080910402602001604051908101604052809291908181526020018280546102b190610ec6565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600061031c610315610759565b8484610761565b6001905092915050565b6000600254905090565b600061033d84848461092a565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610388610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ff90610f69565b60405180910390fd5b61042585610414610759565b85846104209190610fb8565b610761565b60019150509392505050565b60006012905090565b60006104dc610447610759565b848460016000610455610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104d79190610fec565b610761565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461053d90610ec6565b80601f016020809104026020016040519081016040528092919081815260200182805461056990610ec6565b80156105b65780601f1061058b576101008083540402835291602001916105b6565b820191906000526020600020905b81548152906001019060200180831161059957829003601f168201915b5050505050905090565b600080600160006105cf610759565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561068c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610683906110b4565b60405180910390fd5b6106a9610697610759565b8585846106a49190610fb8565b610761565b600191505092915050565b60006106c86106c1610759565b848461092a565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036107d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c790611146565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361083f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610836906111d8565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161091d9190610d85565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610999576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109909061126a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ff906112fc565b60405180910390fd5b610a13838383610ba7565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610a99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a909061138e565b60405180910390fd5b8181610aa59190610fb8565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b359190610fec565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b999190610d85565b60405180910390a350505050565b505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610be6578082015181840152602081019050610bcb565b83811115610bf5576000848401525b50505050565b6000601f19601f8301169050919050565b6000610c1782610bac565b610c218185610bb7565b9350610c31818560208601610bc8565b610c3a81610bfb565b840191505092915050565b60006020820190508181036000830152610c5f8184610c0c565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610c9782610c6c565b9050919050565b610ca781610c8c565b8114610cb257600080fd5b50565b600081359050610cc481610c9e565b92915050565b6000819050919050565b610cdd81610cca565b8114610ce857600080fd5b50565b600081359050610cfa81610cd4565b92915050565b60008060408385031215610d1757610d16610c67565b5b6000610d2585828601610cb5565b9250506020610d3685828601610ceb565b9150509250929050565b60008115159050919050565b610d5581610d40565b82525050565b6000602082019050610d706000830184610d4c565b92915050565b610d7f81610cca565b82525050565b6000602082019050610d9a6000830184610d76565b92915050565b600080600060608486031215610db957610db8610c67565b5b6000610dc786828701610cb5565b9350506020610dd886828701610cb5565b9250506040610de986828701610ceb565b9150509250925092565b600060ff82169050919050565b610e0981610df3565b82525050565b6000602082019050610e246000830184610e00565b92915050565b600060208284031215610e4057610e3f610c67565b5b6000610e4e84828501610cb5565b91505092915050565b60008060408385031215610e6e57610e6d610c67565b5b6000610e7c85828601610cb5565b9250506020610e8d85828601610cb5565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680610ede57607f821691505b602082108103610ef157610ef0610e97565b5b50919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b6000610f53602883610bb7565b9150610f5e82610ef7565b604082019050919050565b60006020820190508181036000830152610f8281610f46565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610fc382610cca565b9150610fce83610cca565b925082821015610fe157610fe0610f89565b5b828203905092915050565b6000610ff782610cca565b915061100283610cca565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561103757611036610f89565b5b828201905092915050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b600061109e602583610bb7565b91506110a982611042565b604082019050919050565b600060208201905081810360008301526110cd81611091565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000611130602483610bb7565b915061113b826110d4565b604082019050919050565b6000602082019050818103600083015261115f81611123565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006111c2602283610bb7565b91506111cd82611166565b604082019050919050565b600060208201905081810360008301526111f1816111b5565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000611254602583610bb7565b915061125f826111f8565b604082019050919050565b6000602082019050818103600083015261128381611247565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006112e6602383610bb7565b91506112f18261128a565b604082019050919050565b60006020820190508181036000830152611315816112d9565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000611378602683610bb7565b91506113838261131c565b604082019050919050565b600060208201905081810360008301526113a78161136b565b905091905056fea2646970667358221220822fa68f8c77dc634d100694a7df3741413a0ed1a514fc66fb87bda633d83af064736f6c634300080d0033 \ No newline at end of file diff --git a/integration_test/misc/token.wasm b/integration_test/misc/token.wasm new file mode 100644 index 00000000..c43419c6 Binary files /dev/null and b/integration_test/misc/token.wasm differ diff --git a/integration_test/test_keys/user1.mnemonics b/integration_test/test_keys/user1.mnemonics new file mode 100644 index 00000000..22b13582 --- /dev/null +++ b/integration_test/test_keys/user1.mnemonics @@ -0,0 +1 @@ +bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty \ No newline at end of file diff --git a/integration_test/test_keys/user2.mnemonics b/integration_test/test_keys/user2.mnemonics new file mode 100644 index 00000000..6a11452a --- /dev/null +++ b/integration_test/test_keys/user2.mnemonics @@ -0,0 +1 @@ +second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal \ No newline at end of file diff --git a/integration_test/test_keys/validator1.mnemonics b/integration_test/test_keys/validator1.mnemonics new file mode 100644 index 00000000..7731d93f --- /dev/null +++ b/integration_test/test_keys/validator1.mnemonics @@ -0,0 +1 @@ +satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn \ No newline at end of file diff --git a/integration_test/test_keys/validator2.mnemonics b/integration_test/test_keys/validator2.mnemonics new file mode 100644 index 00000000..186e76d9 --- /dev/null +++ b/integration_test/test_keys/validator2.mnemonics @@ -0,0 +1 @@ +notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius \ No newline at end of file diff --git a/integration_test/test_keys/validator3.mnemonics b/integration_test/test_keys/validator3.mnemonics new file mode 100644 index 00000000..cf7dad62 --- /dev/null +++ b/integration_test/test_keys/validator3.mnemonics @@ -0,0 +1 @@ +quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty \ No newline at end of file diff --git a/integration_test/test_keys/validator4.mnemonics b/integration_test/test_keys/validator4.mnemonics new file mode 100644 index 00000000..c30d6dce --- /dev/null +++ b/integration_test/test_keys/validator4.mnemonics @@ -0,0 +1 @@ +symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb \ No newline at end of file diff --git a/integration_test/token_test.go b/integration_test/token_test.go new file mode 100644 index 00000000..19f60f7f --- /dev/null +++ b/integration_test/token_test.go @@ -0,0 +1,779 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package integrationtest + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// TokenInterfaceMetaData contains all meta data concerning the TokenInterface contract. +var TokenInterfaceMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// TokenInterfaceABI is the input ABI used to generate the binding from. +// Deprecated: Use TokenInterfaceMetaData.ABI instead. +var TokenInterfaceABI = TokenInterfaceMetaData.ABI + +// TokenInterface is an auto generated Go binding around an Ethereum contract. +type TokenInterface struct { + TokenInterfaceCaller // Read-only binding to the contract + TokenInterfaceTransactor // Write-only binding to the contract + TokenInterfaceFilterer // Log filterer for contract events +} + +// TokenInterfaceCaller is an auto generated read-only Go binding around an Ethereum contract. +type TokenInterfaceCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TokenInterfaceTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TokenInterfaceTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TokenInterfaceFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TokenInterfaceFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TokenInterfaceSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type TokenInterfaceSession struct { + Contract *TokenInterface // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TokenInterfaceCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type TokenInterfaceCallerSession struct { + Contract *TokenInterfaceCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// TokenInterfaceTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type TokenInterfaceTransactorSession struct { + Contract *TokenInterfaceTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TokenInterfaceRaw is an auto generated low-level Go binding around an Ethereum contract. +type TokenInterfaceRaw struct { + Contract *TokenInterface // Generic contract binding to access the raw methods on +} + +// TokenInterfaceCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TokenInterfaceCallerRaw struct { + Contract *TokenInterfaceCaller // Generic read-only contract binding to access the raw methods on +} + +// TokenInterfaceTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TokenInterfaceTransactorRaw struct { + Contract *TokenInterfaceTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewTokenInterface creates a new instance of TokenInterface, bound to a specific deployed contract. +func NewTokenInterface(address common.Address, backend bind.ContractBackend) (*TokenInterface, error) { + contract, err := bindTokenInterface(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &TokenInterface{TokenInterfaceCaller: TokenInterfaceCaller{contract: contract}, TokenInterfaceTransactor: TokenInterfaceTransactor{contract: contract}, TokenInterfaceFilterer: TokenInterfaceFilterer{contract: contract}}, nil +} + +// NewTokenInterfaceCaller creates a new read-only instance of TokenInterface, bound to a specific deployed contract. +func NewTokenInterfaceCaller(address common.Address, caller bind.ContractCaller) (*TokenInterfaceCaller, error) { + contract, err := bindTokenInterface(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &TokenInterfaceCaller{contract: contract}, nil +} + +// NewTokenInterfaceTransactor creates a new write-only instance of TokenInterface, bound to a specific deployed contract. +func NewTokenInterfaceTransactor(address common.Address, transactor bind.ContractTransactor) (*TokenInterfaceTransactor, error) { + contract, err := bindTokenInterface(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &TokenInterfaceTransactor{contract: contract}, nil +} + +// NewTokenInterfaceFilterer creates a new log filterer instance of TokenInterface, bound to a specific deployed contract. +func NewTokenInterfaceFilterer(address common.Address, filterer bind.ContractFilterer) (*TokenInterfaceFilterer, error) { + contract, err := bindTokenInterface(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &TokenInterfaceFilterer{contract: contract}, nil +} + +// bindTokenInterface binds a generic wrapper to an already deployed contract. +func bindTokenInterface(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(TokenInterfaceABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_TokenInterface *TokenInterfaceRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TokenInterface.Contract.TokenInterfaceCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_TokenInterface *TokenInterfaceRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TokenInterface.Contract.TokenInterfaceTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TokenInterface *TokenInterfaceRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TokenInterface.Contract.TokenInterfaceTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_TokenInterface *TokenInterfaceCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TokenInterface.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_TokenInterface *TokenInterfaceTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TokenInterface.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TokenInterface *TokenInterfaceTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TokenInterface.Contract.contract.Transact(opts, method, params...) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_TokenInterface *TokenInterfaceCaller) Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) { + var out []interface{} + err := _TokenInterface.contract.Call(opts, &out, "allowance", owner, spender) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_TokenInterface *TokenInterfaceSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _TokenInterface.Contract.Allowance(&_TokenInterface.CallOpts, owner, spender) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_TokenInterface *TokenInterfaceCallerSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _TokenInterface.Contract.Allowance(&_TokenInterface.CallOpts, owner, spender) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_TokenInterface *TokenInterfaceCaller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { + var out []interface{} + err := _TokenInterface.contract.Call(opts, &out, "balanceOf", account) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_TokenInterface *TokenInterfaceSession) BalanceOf(account common.Address) (*big.Int, error) { + return _TokenInterface.Contract.BalanceOf(&_TokenInterface.CallOpts, account) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_TokenInterface *TokenInterfaceCallerSession) BalanceOf(account common.Address) (*big.Int, error) { + return _TokenInterface.Contract.BalanceOf(&_TokenInterface.CallOpts, account) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_TokenInterface *TokenInterfaceCaller) Decimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _TokenInterface.contract.Call(opts, &out, "decimals") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_TokenInterface *TokenInterfaceSession) Decimals() (uint8, error) { + return _TokenInterface.Contract.Decimals(&_TokenInterface.CallOpts) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_TokenInterface *TokenInterfaceCallerSession) Decimals() (uint8, error) { + return _TokenInterface.Contract.Decimals(&_TokenInterface.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_TokenInterface *TokenInterfaceCaller) Name(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _TokenInterface.contract.Call(opts, &out, "name") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_TokenInterface *TokenInterfaceSession) Name() (string, error) { + return _TokenInterface.Contract.Name(&_TokenInterface.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_TokenInterface *TokenInterfaceCallerSession) Name() (string, error) { + return _TokenInterface.Contract.Name(&_TokenInterface.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_TokenInterface *TokenInterfaceCaller) Symbol(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _TokenInterface.contract.Call(opts, &out, "symbol") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_TokenInterface *TokenInterfaceSession) Symbol() (string, error) { + return _TokenInterface.Contract.Symbol(&_TokenInterface.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_TokenInterface *TokenInterfaceCallerSession) Symbol() (string, error) { + return _TokenInterface.Contract.Symbol(&_TokenInterface.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_TokenInterface *TokenInterfaceCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _TokenInterface.contract.Call(opts, &out, "totalSupply") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_TokenInterface *TokenInterfaceSession) TotalSupply() (*big.Int, error) { + return _TokenInterface.Contract.TotalSupply(&_TokenInterface.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_TokenInterface *TokenInterfaceCallerSession) TotalSupply() (*big.Int, error) { + return _TokenInterface.Contract.TotalSupply(&_TokenInterface.CallOpts) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceTransactor) Approve(opts *bind.TransactOpts, spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.contract.Transact(opts, "approve", spender, amount) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceSession) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.Approve(&_TokenInterface.TransactOpts, spender, amount) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceTransactorSession) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.Approve(&_TokenInterface.TransactOpts, spender, amount) +} + +// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. +// +// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) +func (_TokenInterface *TokenInterfaceTransactor) DecreaseAllowance(opts *bind.TransactOpts, spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { + return _TokenInterface.contract.Transact(opts, "decreaseAllowance", spender, subtractedValue) +} + +// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. +// +// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) +func (_TokenInterface *TokenInterfaceSession) DecreaseAllowance(spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.DecreaseAllowance(&_TokenInterface.TransactOpts, spender, subtractedValue) +} + +// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. +// +// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) +func (_TokenInterface *TokenInterfaceTransactorSession) DecreaseAllowance(spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.DecreaseAllowance(&_TokenInterface.TransactOpts, spender, subtractedValue) +} + +// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. +// +// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) +func (_TokenInterface *TokenInterfaceTransactor) IncreaseAllowance(opts *bind.TransactOpts, spender common.Address, addedValue *big.Int) (*types.Transaction, error) { + return _TokenInterface.contract.Transact(opts, "increaseAllowance", spender, addedValue) +} + +// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. +// +// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) +func (_TokenInterface *TokenInterfaceSession) IncreaseAllowance(spender common.Address, addedValue *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.IncreaseAllowance(&_TokenInterface.TransactOpts, spender, addedValue) +} + +// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. +// +// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) +func (_TokenInterface *TokenInterfaceTransactorSession) IncreaseAllowance(spender common.Address, addedValue *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.IncreaseAllowance(&_TokenInterface.TransactOpts, spender, addedValue) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceTransactor) Transfer(opts *bind.TransactOpts, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.contract.Transact(opts, "transfer", recipient, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceSession) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.Transfer(&_TokenInterface.TransactOpts, recipient, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceTransactorSession) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.Transfer(&_TokenInterface.TransactOpts, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceTransactor) TransferFrom(opts *bind.TransactOpts, sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.contract.Transact(opts, "transferFrom", sender, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceSession) TransferFrom(sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.TransferFrom(&_TokenInterface.TransactOpts, sender, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) +func (_TokenInterface *TokenInterfaceTransactorSession) TransferFrom(sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _TokenInterface.Contract.TransferFrom(&_TokenInterface.TransactOpts, sender, recipient, amount) +} + +// TokenInterfaceApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the TokenInterface contract. +type TokenInterfaceApprovalIterator struct { + Event *TokenInterfaceApproval // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TokenInterfaceApprovalIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TokenInterfaceApproval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TokenInterfaceApproval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TokenInterfaceApprovalIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TokenInterfaceApprovalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TokenInterfaceApproval represents a Approval event raised by the TokenInterface contract. +type TokenInterfaceApproval struct { + Owner common.Address + Spender common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_TokenInterface *TokenInterfaceFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*TokenInterfaceApprovalIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _TokenInterface.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return &TokenInterfaceApprovalIterator{contract: _TokenInterface.contract, event: "Approval", logs: logs, sub: sub}, nil +} + +// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_TokenInterface *TokenInterfaceFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *TokenInterfaceApproval, owner []common.Address, spender []common.Address) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _TokenInterface.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TokenInterfaceApproval) + if err := _TokenInterface.contract.UnpackLog(event, "Approval", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_TokenInterface *TokenInterfaceFilterer) ParseApproval(log types.Log) (*TokenInterfaceApproval, error) { + event := new(TokenInterfaceApproval) + if err := _TokenInterface.contract.UnpackLog(event, "Approval", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// TokenInterfaceTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the TokenInterface contract. +type TokenInterfaceTransferIterator struct { + Event *TokenInterfaceTransfer // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TokenInterfaceTransferIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TokenInterfaceTransfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TokenInterfaceTransfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TokenInterfaceTransferIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TokenInterfaceTransferIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TokenInterfaceTransfer represents a Transfer event raised by the TokenInterface contract. +type TokenInterfaceTransfer struct { + From common.Address + To common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_TokenInterface *TokenInterfaceFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*TokenInterfaceTransferIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _TokenInterface.contract.FilterLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return &TokenInterfaceTransferIterator{contract: _TokenInterface.contract, event: "Transfer", logs: logs, sub: sub}, nil +} + +// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_TokenInterface *TokenInterfaceFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *TokenInterfaceTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _TokenInterface.contract.WatchLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TokenInterfaceTransfer) + if err := _TokenInterface.contract.UnpackLog(event, "Transfer", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_TokenInterface *TokenInterfaceFilterer) ParseTransfer(log types.Log) (*TokenInterfaceTransfer, error) { + event := new(TokenInterfaceTransfer) + if err := _TokenInterface.contract.UnpackLog(event, "Transfer", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/integration_test/validator1/app.toml b/integration_test/validator1/app.toml new file mode 100644 index 00000000..d8c5c73d --- /dev/null +++ b/integration_test/validator1/app.toml @@ -0,0 +1,293 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Base Configuration ### +############################################################################### + +# The minimum gas prices a validator is willing to accept for processing a +# transaction. A transaction's fees must meet the minimum of any denomination +# specified in this config (e.g. 0.25token1;0.0001token2). +minimum-gas-prices = "8500000000axpla" + +# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals +# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +# everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals +# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval' +pruning = "default" + +# These are applied if and only if the pruning strategy is custom. +pruning-keep-recent = "0" +pruning-keep-every = "0" +pruning-interval = "0" + +# HaltHeight contains a non-zero block height at which a node will gracefully +# halt and shutdown that can be used to assist upgrades and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-height = 0 + +# HaltTime contains a non-zero minimum block time (in Unix seconds) at which +# a node will gracefully halt and shutdown that can be used to assist upgrades +# and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-time = 0 + +# MinRetainBlocks defines the minimum block height offset from the current +# block being committed, such that all blocks past this offset are pruned +# from Tendermint. It is used as part of the process of determining the +# ResponseCommit.RetainHeight value during ABCI Commit. A value of 0 indicates +# that no blocks should be pruned. +# +# This configuration value is only responsible for pruning Tendermint blocks. +# It has no bearing on application state pruning which is determined by the +# "pruning-*" configurations. +# +# Note: Tendermint block pruning is dependant on this parameter in conunction +# with the unbonding (safety threshold) period, state pruning and state sync +# snapshot parameters to determine the correct minimum value of +# ResponseCommit.RetainHeight. +min-retain-blocks = 0 + +# InterBlockCache enables inter-block caching. +inter-block-cache = true + +# IndexEvents defines the set of events in the form {eventType}.{attributeKey}, +# which informs Tendermint what to index. If empty, all events will be indexed. +# +# Example: +# ["message.sender", "message.recipient"] +index-events = [] + +# IavlCacheSize set the size of the iavl tree cache. +# Default cache size is 50mb. +iavl-cache-size = 781250 + +# IAVLDisableFastNode enables or disables the fast node feature of IAVL. +# Default is true. +iavl-disable-fastnode = true + +############################################################################### +### Telemetry Configuration ### +############################################################################### + +[telemetry] + +# Prefixed with keys to separate services. +service-name = "" + +# Enabled enables the application telemetry functionality. When enabled, +# an in-memory sink is also enabled by default. Operators may also enabled +# other sinks such as Prometheus. +enabled = false + +# Enable prefixing gauge values with hostname. +enable-hostname = false + +# Enable adding hostname to labels. +enable-hostname-label = false + +# Enable adding service to labels. +enable-service-label = false + +# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink. +prometheus-retention-time = 0 + +# GlobalLabels defines a global set of name/value label tuples applied to all +# metrics emitted using the wrapper functions defined in telemetry package. +# +# Example: +# [["chain_id", "cosmoshub-1"]] +global-labels = [ +] + +############################################################################### +### API Configuration ### +############################################################################### + +[api] + +# Enable defines if the API server should be enabled. +enable = false + +# Swagger defines if swagger documentation should automatically be registered. +swagger = false + +# Address defines the API server to listen on. +address = "tcp://0.0.0.0:1317" + +# MaxOpenConnections defines the number of maximum open connections. +max-open-connections = 1000 + +# RPCReadTimeout defines the Tendermint RPC read timeout (in seconds). +rpc-read-timeout = 10 + +# RPCWriteTimeout defines the Tendermint RPC write timeout (in seconds). +rpc-write-timeout = 0 + +# RPCMaxBodyBytes defines the Tendermint maximum response body (in bytes). +rpc-max-body-bytes = 1000000 + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enabled-unsafe-cors = false + +############################################################################### +### Rosetta Configuration ### +############################################################################### + +[rosetta] + +# Enable defines if the Rosetta API server should be enabled. +enable = false + +# Address defines the Rosetta API server to listen on. +address = ":8080" + +# Network defines the name of the blockchain that will be returned by Rosetta. +blockchain = "app" + +# Network defines the name of the network that will be returned by Rosetta. +network = "network" + +# Retries defines the number of retries when connecting to the node before failing. +retries = 3 + +# Offline defines if Rosetta server should run in offline mode. +offline = false + +############################################################################### +### gRPC Configuration ### +############################################################################### + +[grpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the gRPC server address to bind to. +address = "0.0.0.0:9090" + +############################################################################### +### gRPC Web Configuration ### +############################################################################### + +[grpc-web] + +# GRPCWebEnable defines if the gRPC-web should be enabled. +# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op. +enable = true + +# Address defines the gRPC-web server address to bind to. +address = "0.0.0.0:9091" + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enable-unsafe-cors = false + +############################################################################### +### State Sync Configuration ### +############################################################################### + +# State sync snapshots allow other nodes to rapidly join the network without replaying historical +# blocks, instead downloading and applying a snapshot of the application state at a given height. +[state-sync] + +# snapshot-interval specifies the block interval at which local state sync snapshots are +# taken (0 to disable). Must be a multiple of pruning-keep-every. +snapshot-interval = 1000 + +# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). +snapshot-keep-recent = 10 + +############################################################################### +### EVM Configuration ### +############################################################################### + +[evm] + +# Tracer defines the 'vm.Tracer' type that the EVM will use when the node is run in +# debug mode. To enable tracing use the '--evm.tracer' flag when starting your node. +# Valid types are: json|struct|access_list|markdown +tracer = "" + +# MaxTxGasWanted defines the gas wanted for each eth tx returned in ante handler in check tx mode. +max-tx-gas-wanted = 0 + +############################################################################### +### JSON RPC Configuration ### +############################################################################### + +[json-rpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the EVM RPC HTTP server address to bind to. +address = "0.0.0.0:8545" + +# Address defines the EVM WebSocket server address to bind to. +ws-address = "0.0.0.0:8546" + +# API defines a list of JSON-RPC namespaces that should be enabled +# Example: "eth,txpool,personal,net,debug,web3" +api = "eth,net,web3" + +# GasCap sets a cap on gas that can be used in eth_call/estimateGas (0=infinite). Default: 25,000,000. +gas-cap = 25000000 + +# EVMTimeout is the global timeout for eth_call. Default: 5s. +evm-timeout = "5s" + +# TxFeeCap is the global tx-fee cap for send transaction. Default: 1eth. +txfee-cap = 1 + +# FilterCap sets the global cap for total number of filters that can be created +filter-cap = 200 + +# FeeHistoryCap sets the global cap for total number of blocks that can be fetched +feehistory-cap = 100 + +# LogsCap defines the max number of results can be returned from single 'eth_getLogs' query. +logs-cap = 10000 + +# BlockRangeCap defines the max block range allowed for 'eth_getLogs' query. +block-range-cap = 10000 + +# HTTPTimeout is the read/write timeout of http json-rpc server. +http-timeout = "30s" + +# HTTPIdleTimeout is the idle timeout of http json-rpc server. +http-idle-timeout = "2m0s" + +# AllowUnprotectedTxs restricts unprotected (non EIP155 signed) transactions to be submitted via +# the node's RPC when the global parameter is disabled. +allow-unprotected-txs = false + +# MaxOpenConnections sets the maximum number of simultaneous connections +# for the server listener. +max-open-connections = 0 + +# EnableIndexer enables the custom transaction indexer for the EVM (ethereum transactions). +enable-indexer = false + +############################################################################### +### TLS Configuration ### +############################################################################### + +[tls] + +# Certificate path defines the cert.pem file path for the TLS configuration. +certificate-path = "" + +# Key path defines the key.pem file path for the TLS configuration. +key-path = "" + +############################################################################### +### Custom Xpla Configuration ### +############################################################################### +# bypass-min-fee-msg-types defines custom message types the operator may set that +# will bypass minimum fee checks during CheckTx. +# +# Example: +# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", ...] +bypass-min-fee-msg-types = ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient", ] diff --git a/integration_test/validator1/client.toml b/integration_test/validator1/client.toml new file mode 100644 index 00000000..bb2e8e1d --- /dev/null +++ b/integration_test/validator1/client.toml @@ -0,0 +1,17 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Client Configuration ### +############################################################################### + +# The network chain ID +chain-id = "" +# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) +keyring-backend = "test" +# CLI output format (text|json) +output = "text" +# : to Tendermint RPC interface for this chain +node = "tcp://localhost:26657" +# Transaction broadcasting mode (sync|async|block) +broadcast-mode = "sync" diff --git a/integration_test/validator1/config.toml b/integration_test/validator1/config.toml new file mode 100644 index 00000000..62b4395d --- /dev/null +++ b/integration_test/validator1/config.toml @@ -0,0 +1,465 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or +# relative to the home directory (e.g. "data"). The home directory is +# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable +# or --home cmd flag. + +####################################################################### +### Main Base Config Options ### +####################################################################### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the Tendermint binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "validator1" + +# If this node is many blocks behind the tip of the chain, FastSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +fast_sync = true + +# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +# * rocksdb (uses github.com/tecbot/gorocksdb) +# - EXPERIMENTAL +# - requires gcc +# - use rocksdb build tag (go build -tags rocksdb) +# * badgerdb (uses github.com/dgraph-io/badger) +# - EXPERIMENTAL +# - use badgerdb build tag (go build -tags badgerdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "info" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for Tendermint to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + + +####################################################################### +### Advanced Configuration Options ### +####################################################################### + +####################################################### +### RPC Server Configuration Options ### +####################################################### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26657" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = false + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# Experimental parameter to specify the maximum number of events a node will +# buffer, per subscription, before returning an error and closing the +# subscription. Must be set to at least 100, but higher values will accommodate +# higher event throughput rates (and will use more memory). +experimental_subscription_buffer_size = 200 + +# Experimental parameter to specify the maximum number of RPC responses that +# can be buffered per WebSocket client. If clients cannot read from the +# WebSocket endpoint fast enough, they will be disconnected, so increasing this +# parameter may reduce the chances of them being disconnected (but will cause +# the node to use more memory). +# +# Must be at least the same as "experimental_subscription_buffer_size", +# otherwise connections could be dropped unnecessarily. This value should +# ideally be somewhat higher than "experimental_subscription_buffer_size" to +# accommodate non-subscription-related RPC responses. +experimental_websocket_write_buffer_size = 200 + +# If a WebSocket client cannot read fast enough, at present we may +# silently drop events instead of generating an error or disconnecting the +# client. +# +# Enabling this experimental parameter will cause the WebSocket connection to +# be closed instead if it cannot read fast enough, allowing for greater +# predictability in subscription behaviour. +experimental_close_on_slow_client = false + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_key_file = "" + +# pprof listen address (https://golang.org/pkg/net/http/pprof) +pprof_laddr = "localhost:6060" + +####################################################### +### P2P Configuration Options ### +####################################################### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26656" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. ip and port are required +# example: 159.89.10.97:26656 +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "472e2e1552a9d0c9dade1f33d31e8f691ab9077b@192.167.100.2:26666,609384b9304c4c84973fe49ebaa83a3dd4d6b894@192.167.100.4:26686,c077002350aa59d772759ee14fb7e4219bbd8115@192.167.100.3:26676" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# List of node IDs, to which a connection will be (re)established ignoring any existing limits +unconditional_peer_ids = "" + +# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) +persistent_peers_max_dial_period = "0s" + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +####################################################### +### Mempool Configuration Option ### +####################################################### +[mempool] + +# Mempool version to use: +# 1) "v0" - (default) FIFO mempool. +# 2) "v1" - prioritized mempool. +version = "v0" + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Do not remove invalid transactions from the cache (default: false) +# Set to true if it's not possible for any invalid transaction to become valid +# again in the future. +keep-invalid-txs-in-cache = false + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. +max_tx_bytes = 1048576 + +# Maximum size of a batch of transactions to send to a peer +# Including space needed by encoding (one varint per transaction). +# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 +max_batch_bytes = 0 + +# ttl-duration, if non-zero, defines the maximum amount of time a transaction +# can exist for in the mempool. +# +# Note, if ttl-num-blocks is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if it's +# insertion time into the mempool is beyond ttl-duration. +ttl-duration = "0s" + +# ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction +# can exist for in the mempool. +# +# Note, if ttl-duration is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if +# it's insertion time into the mempool is beyond ttl-duration. +ttl-num-blocks = 0 + +####################################################### +### State Sync Configuration Options ### +####################################################### +[statesync] +# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine +# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in +# the network to take and serve state machine snapshots. State sync is not attempted if the node +# has any local state (LastBlockHeight > 0). The node will have a truncated block history, +# starting from the height of the snapshot. +enable = false + +# RPC servers (comma-separated) for light client verification of the synced state machine and +# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding +# header hash obtained from a trusted source, and a period during which validators can be trusted. +# +# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 +# weeks) during which they can be financially punished (slashed) for misbehavior. +rpc_servers = "" +trust_height = 0 +trust_hash = "" +trust_period = "168h0m0s" + +# Time to spend discovering snapshots before initiating a restore. +discovery_time = "15s" + +# Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). +# Will create a new, randomly named directory within, and remove it when done. +temp_dir = "" + +# The timeout duration before re-requesting a chunk, possibly from a different +# peer (default: 1 minute). +chunk_request_timeout = "10s" + +# The number of concurrent chunk fetchers to run (default: 1). +chunk_fetchers = "4" + +####################################################### +### Fast Sync Configuration Connections ### +####################################################### +[fastsync] + +# Fast Sync version to use: +# 1) "v0" (default) - the legacy fast sync implementation +# 2) "v1" - refactor of v0 version for better testability +# 2) "v2" - complete redesign of v0, optimized for testability & readability +version = "v0" + +####################################################### +### Consensus Configuration Options ### +####################################################### +[consensus] + +wal_file = "data/cs.wal/wal" + +# How long we wait for a proposal block before prevoting nil +timeout_propose = "3s" +# How much timeout_propose increases with each round +timeout_propose_delta = "500ms" +# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) +timeout_prevote = "1s" +# How much the timeout_prevote increases with each round +timeout_prevote_delta = "500ms" +# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) +timeout_precommit = "1s" +# How much the timeout_precommit increases with each round +timeout_precommit_delta = "500ms" +# How long we wait after committing a block, before starting on the new +# height (this gives us a chance to receive some more precommits, even +# though we already have +2/3). +timeout_commit = "5s" + +# How many blocks to look back to check existence of the node's consensus votes before joining consensus +# When non-zero, the node will panic upon restart +# if the same consensus key was used to sign {double_sign_check_height} last blocks. +# So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. +double_sign_check_height = 0 + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +####################################################### +### Storage Configuration Options ### +####################################################### + +# Set to true to discard ABCI responses from the state store, which can save a +# considerable amount of disk space. Set to false to ensure ABCI responses are +# persisted. ABCI responses are required for /block_results RPC queries, and to +# reindex events in the command-line tool. +discard_abci_responses = false + +####################################################### +### Transaction Indexer Configuration Options ### +####################################################### +[tx_index] + +# What indexer to use for transactions +# +# The application will set which txs to index. In some cases a node operator will be able +# to decide which txs to index based on configuration set in the application. +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +# - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. +# 3) "psql" - the indexer services backed by PostgreSQL. +# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. +indexer = "kv" + +# The PostgreSQL connection configuration, the connection format: +# postgresql://:@:/? +psql-conn = "" + +####################################################### +### Instrumentation Configuration Options ### +####################################################### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "tendermint" diff --git a/integration_test/validator1/node_key.json b/integration_test/validator1/node_key.json new file mode 100644 index 00000000..1766e4af --- /dev/null +++ b/integration_test/validator1/node_key.json @@ -0,0 +1 @@ +{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"dmVuYdM3dmaUr6gFEao3I8kzxES01cfbgaLFG9ZuW8UXgkwWgZYsKl3BSZWWgyW/0pD7kLUeqzRTkqVhmOc0pA=="}} \ No newline at end of file diff --git a/integration_test/validator1/priv_validator_key.json b/integration_test/validator1/priv_validator_key.json new file mode 100644 index 00000000..88a96e6d --- /dev/null +++ b/integration_test/validator1/priv_validator_key.json @@ -0,0 +1,11 @@ +{ + "address": "216FF96CAB9F9F1EFC6133F60011F943D70D4215", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "2pCb4SP75tIfyRH7IzKiBkSiCm41tFf/YqiMR/YDOaQ=" + }, + "priv_key": { + "type": "tendermint/PrivKeyEd25519", + "value": "o5l2sDbg1BQRcyycKfQEZMvraK3eNlOKkOvbt0jpWJTakJvhI/vm0h/JEfsjMqIGRKIKbjW0V/9iqIxH9gM5pA==" + } +} \ No newline at end of file diff --git a/integration_test/validator2/app.toml b/integration_test/validator2/app.toml new file mode 100644 index 00000000..0f3ad952 --- /dev/null +++ b/integration_test/validator2/app.toml @@ -0,0 +1,293 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Base Configuration ### +############################################################################### + +# The minimum gas prices a validator is willing to accept for processing a +# transaction. A transaction's fees must meet the minimum of any denomination +# specified in this config (e.g. 0.25token1;0.0001token2). +minimum-gas-prices = "8500000000axpla" + +# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals +# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +# everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals +# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval' +pruning = "default" + +# These are applied if and only if the pruning strategy is custom. +pruning-keep-recent = "0" +pruning-keep-every = "0" +pruning-interval = "0" + +# HaltHeight contains a non-zero block height at which a node will gracefully +# halt and shutdown that can be used to assist upgrades and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-height = 0 + +# HaltTime contains a non-zero minimum block time (in Unix seconds) at which +# a node will gracefully halt and shutdown that can be used to assist upgrades +# and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-time = 0 + +# MinRetainBlocks defines the minimum block height offset from the current +# block being committed, such that all blocks past this offset are pruned +# from Tendermint. It is used as part of the process of determining the +# ResponseCommit.RetainHeight value during ABCI Commit. A value of 0 indicates +# that no blocks should be pruned. +# +# This configuration value is only responsible for pruning Tendermint blocks. +# It has no bearing on application state pruning which is determined by the +# "pruning-*" configurations. +# +# Note: Tendermint block pruning is dependant on this parameter in conunction +# with the unbonding (safety threshold) period, state pruning and state sync +# snapshot parameters to determine the correct minimum value of +# ResponseCommit.RetainHeight. +min-retain-blocks = 0 + +# InterBlockCache enables inter-block caching. +inter-block-cache = true + +# IndexEvents defines the set of events in the form {eventType}.{attributeKey}, +# which informs Tendermint what to index. If empty, all events will be indexed. +# +# Example: +# ["message.sender", "message.recipient"] +index-events = [] + +# IavlCacheSize set the size of the iavl tree cache. +# Default cache size is 50mb. +iavl-cache-size = 781250 + +# IAVLDisableFastNode enables or disables the fast node feature of IAVL. +# Default is true. +iavl-disable-fastnode = true + +############################################################################### +### Telemetry Configuration ### +############################################################################### + +[telemetry] + +# Prefixed with keys to separate services. +service-name = "" + +# Enabled enables the application telemetry functionality. When enabled, +# an in-memory sink is also enabled by default. Operators may also enabled +# other sinks such as Prometheus. +enabled = false + +# Enable prefixing gauge values with hostname. +enable-hostname = false + +# Enable adding hostname to labels. +enable-hostname-label = false + +# Enable adding service to labels. +enable-service-label = false + +# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink. +prometheus-retention-time = 0 + +# GlobalLabels defines a global set of name/value label tuples applied to all +# metrics emitted using the wrapper functions defined in telemetry package. +# +# Example: +# [["chain_id", "cosmoshub-1"]] +global-labels = [ +] + +############################################################################### +### API Configuration ### +############################################################################### + +[api] + +# Enable defines if the API server should be enabled. +enable = false + +# Swagger defines if swagger documentation should automatically be registered. +swagger = false + +# Address defines the API server to listen on. +address = "tcp://0.0.0.0:1317" + +# MaxOpenConnections defines the number of maximum open connections. +max-open-connections = 1000 + +# RPCReadTimeout defines the Tendermint RPC read timeout (in seconds). +rpc-read-timeout = 10 + +# RPCWriteTimeout defines the Tendermint RPC write timeout (in seconds). +rpc-write-timeout = 0 + +# RPCMaxBodyBytes defines the Tendermint maximum response body (in bytes). +rpc-max-body-bytes = 1000000 + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enabled-unsafe-cors = false + +############################################################################### +### Rosetta Configuration ### +############################################################################### + +[rosetta] + +# Enable defines if the Rosetta API server should be enabled. +enable = false + +# Address defines the Rosetta API server to listen on. +address = ":8080" + +# Network defines the name of the blockchain that will be returned by Rosetta. +blockchain = "app" + +# Network defines the name of the network that will be returned by Rosetta. +network = "network" + +# Retries defines the number of retries when connecting to the node before failing. +retries = 3 + +# Offline defines if Rosetta server should run in offline mode. +offline = false + +############################################################################### +### gRPC Configuration ### +############################################################################### + +[grpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the gRPC server address to bind to. +address = "0.0.0.0:9100" + +############################################################################### +### gRPC Web Configuration ### +############################################################################### + +[grpc-web] + +# GRPCWebEnable defines if the gRPC-web should be enabled. +# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op. +enable = true + +# Address defines the gRPC-web server address to bind to. +address = "0.0.0.0:9091" + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enable-unsafe-cors = false + +############################################################################### +### State Sync Configuration ### +############################################################################### + +# State sync snapshots allow other nodes to rapidly join the network without replaying historical +# blocks, instead downloading and applying a snapshot of the application state at a given height. +[state-sync] + +# snapshot-interval specifies the block interval at which local state sync snapshots are +# taken (0 to disable). Must be a multiple of pruning-keep-every. +snapshot-interval = 1000 + +# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). +snapshot-keep-recent = 10 + +############################################################################### +### EVM Configuration ### +############################################################################### + +[evm] + +# Tracer defines the 'vm.Tracer' type that the EVM will use when the node is run in +# debug mode. To enable tracing use the '--evm.tracer' flag when starting your node. +# Valid types are: json|struct|access_list|markdown +tracer = "" + +# MaxTxGasWanted defines the gas wanted for each eth tx returned in ante handler in check tx mode. +max-tx-gas-wanted = 0 + +############################################################################### +### JSON RPC Configuration ### +############################################################################### + +[json-rpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the EVM RPC HTTP server address to bind to. +address = "0.0.0.0:8555" + +# Address defines the EVM WebSocket server address to bind to. +ws-address = "0.0.0.0:8556" + +# API defines a list of JSON-RPC namespaces that should be enabled +# Example: "eth,txpool,personal,net,debug,web3" +api = "eth,net,web3" + +# GasCap sets a cap on gas that can be used in eth_call/estimateGas (0=infinite). Default: 25,000,000. +gas-cap = 25000000 + +# EVMTimeout is the global timeout for eth_call. Default: 5s. +evm-timeout = "5s" + +# TxFeeCap is the global tx-fee cap for send transaction. Default: 1eth. +txfee-cap = 1 + +# FilterCap sets the global cap for total number of filters that can be created +filter-cap = 200 + +# FeeHistoryCap sets the global cap for total number of blocks that can be fetched +feehistory-cap = 100 + +# LogsCap defines the max number of results can be returned from single 'eth_getLogs' query. +logs-cap = 10000 + +# BlockRangeCap defines the max block range allowed for 'eth_getLogs' query. +block-range-cap = 10000 + +# HTTPTimeout is the read/write timeout of http json-rpc server. +http-timeout = "30s" + +# HTTPIdleTimeout is the idle timeout of http json-rpc server. +http-idle-timeout = "2m0s" + +# AllowUnprotectedTxs restricts unprotected (non EIP155 signed) transactions to be submitted via +# the node's RPC when the global parameter is disabled. +allow-unprotected-txs = false + +# MaxOpenConnections sets the maximum number of simultaneous connections +# for the server listener. +max-open-connections = 0 + +# EnableIndexer enables the custom transaction indexer for the EVM (ethereum transactions). +enable-indexer = false + +############################################################################### +### TLS Configuration ### +############################################################################### + +[tls] + +# Certificate path defines the cert.pem file path for the TLS configuration. +certificate-path = "" + +# Key path defines the key.pem file path for the TLS configuration. +key-path = "" + +############################################################################### +### Custom Xpla Configuration ### +############################################################################### +# bypass-min-fee-msg-types defines custom message types the operator may set that +# will bypass minimum fee checks during CheckTx. +# +# Example: +# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", ...] +bypass-min-fee-msg-types = ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient", ] diff --git a/integration_test/validator2/client.toml b/integration_test/validator2/client.toml new file mode 100644 index 00000000..bb2e8e1d --- /dev/null +++ b/integration_test/validator2/client.toml @@ -0,0 +1,17 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Client Configuration ### +############################################################################### + +# The network chain ID +chain-id = "" +# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) +keyring-backend = "test" +# CLI output format (text|json) +output = "text" +# : to Tendermint RPC interface for this chain +node = "tcp://localhost:26657" +# Transaction broadcasting mode (sync|async|block) +broadcast-mode = "sync" diff --git a/integration_test/validator2/config.toml b/integration_test/validator2/config.toml new file mode 100644 index 00000000..c7de040c --- /dev/null +++ b/integration_test/validator2/config.toml @@ -0,0 +1,465 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or +# relative to the home directory (e.g. "data"). The home directory is +# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable +# or --home cmd flag. + +####################################################################### +### Main Base Config Options ### +####################################################################### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the Tendermint binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "validator1" + +# If this node is many blocks behind the tip of the chain, FastSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +fast_sync = true + +# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +# * rocksdb (uses github.com/tecbot/gorocksdb) +# - EXPERIMENTAL +# - requires gcc +# - use rocksdb build tag (go build -tags rocksdb) +# * badgerdb (uses github.com/dgraph-io/badger) +# - EXPERIMENTAL +# - use badgerdb build tag (go build -tags badgerdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "info" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for Tendermint to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + + +####################################################################### +### Advanced Configuration Options ### +####################################################################### + +####################################################### +### RPC Server Configuration Options ### +####################################################### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26667" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = false + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# Experimental parameter to specify the maximum number of events a node will +# buffer, per subscription, before returning an error and closing the +# subscription. Must be set to at least 100, but higher values will accommodate +# higher event throughput rates (and will use more memory). +experimental_subscription_buffer_size = 200 + +# Experimental parameter to specify the maximum number of RPC responses that +# can be buffered per WebSocket client. If clients cannot read from the +# WebSocket endpoint fast enough, they will be disconnected, so increasing this +# parameter may reduce the chances of them being disconnected (but will cause +# the node to use more memory). +# +# Must be at least the same as "experimental_subscription_buffer_size", +# otherwise connections could be dropped unnecessarily. This value should +# ideally be somewhat higher than "experimental_subscription_buffer_size" to +# accommodate non-subscription-related RPC responses. +experimental_websocket_write_buffer_size = 200 + +# If a WebSocket client cannot read fast enough, at present we may +# silently drop events instead of generating an error or disconnecting the +# client. +# +# Enabling this experimental parameter will cause the WebSocket connection to +# be closed instead if it cannot read fast enough, allowing for greater +# predictability in subscription behaviour. +experimental_close_on_slow_client = false + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_key_file = "" + +# pprof listen address (https://golang.org/pkg/net/http/pprof) +pprof_laddr = "localhost:6070" + +####################################################### +### P2P Configuration Options ### +####################################################### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26666" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. ip and port are required +# example: 159.89.10.97:26656 +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "1ccf9b507c0b83a0ce1eb35d51cbbdf05ee71c35@192.167.100.1:26656,609384b9304c4c84973fe49ebaa83a3dd4d6b894@192.167.100.4:26686,c077002350aa59d772759ee14fb7e4219bbd8115@192.167.100.3:26676" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# List of node IDs, to which a connection will be (re)established ignoring any existing limits +unconditional_peer_ids = "" + +# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) +persistent_peers_max_dial_period = "0s" + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +####################################################### +### Mempool Configuration Option ### +####################################################### +[mempool] + +# Mempool version to use: +# 1) "v0" - (default) FIFO mempool. +# 2) "v1" - prioritized mempool. +version = "v0" + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Do not remove invalid transactions from the cache (default: false) +# Set to true if it's not possible for any invalid transaction to become valid +# again in the future. +keep-invalid-txs-in-cache = false + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. +max_tx_bytes = 1048576 + +# Maximum size of a batch of transactions to send to a peer +# Including space needed by encoding (one varint per transaction). +# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 +max_batch_bytes = 0 + +# ttl-duration, if non-zero, defines the maximum amount of time a transaction +# can exist for in the mempool. +# +# Note, if ttl-num-blocks is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if it's +# insertion time into the mempool is beyond ttl-duration. +ttl-duration = "0s" + +# ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction +# can exist for in the mempool. +# +# Note, if ttl-duration is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if +# it's insertion time into the mempool is beyond ttl-duration. +ttl-num-blocks = 0 + +####################################################### +### State Sync Configuration Options ### +####################################################### +[statesync] +# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine +# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in +# the network to take and serve state machine snapshots. State sync is not attempted if the node +# has any local state (LastBlockHeight > 0). The node will have a truncated block history, +# starting from the height of the snapshot. +enable = false + +# RPC servers (comma-separated) for light client verification of the synced state machine and +# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding +# header hash obtained from a trusted source, and a period during which validators can be trusted. +# +# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 +# weeks) during which they can be financially punished (slashed) for misbehavior. +rpc_servers = "" +trust_height = 0 +trust_hash = "" +trust_period = "168h0m0s" + +# Time to spend discovering snapshots before initiating a restore. +discovery_time = "15s" + +# Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). +# Will create a new, randomly named directory within, and remove it when done. +temp_dir = "" + +# The timeout duration before re-requesting a chunk, possibly from a different +# peer (default: 1 minute). +chunk_request_timeout = "10s" + +# The number of concurrent chunk fetchers to run (default: 1). +chunk_fetchers = "4" + +####################################################### +### Fast Sync Configuration Connections ### +####################################################### +[fastsync] + +# Fast Sync version to use: +# 1) "v0" (default) - the legacy fast sync implementation +# 2) "v1" - refactor of v0 version for better testability +# 2) "v2" - complete redesign of v0, optimized for testability & readability +version = "v0" + +####################################################### +### Consensus Configuration Options ### +####################################################### +[consensus] + +wal_file = "data/cs.wal/wal" + +# How long we wait for a proposal block before prevoting nil +timeout_propose = "3s" +# How much timeout_propose increases with each round +timeout_propose_delta = "500ms" +# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) +timeout_prevote = "1s" +# How much the timeout_prevote increases with each round +timeout_prevote_delta = "500ms" +# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) +timeout_precommit = "1s" +# How much the timeout_precommit increases with each round +timeout_precommit_delta = "500ms" +# How long we wait after committing a block, before starting on the new +# height (this gives us a chance to receive some more precommits, even +# though we already have +2/3). +timeout_commit = "5s" + +# How many blocks to look back to check existence of the node's consensus votes before joining consensus +# When non-zero, the node will panic upon restart +# if the same consensus key was used to sign {double_sign_check_height} last blocks. +# So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. +double_sign_check_height = 0 + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +####################################################### +### Storage Configuration Options ### +####################################################### + +# Set to true to discard ABCI responses from the state store, which can save a +# considerable amount of disk space. Set to false to ensure ABCI responses are +# persisted. ABCI responses are required for /block_results RPC queries, and to +# reindex events in the command-line tool. +discard_abci_responses = false + +####################################################### +### Transaction Indexer Configuration Options ### +####################################################### +[tx_index] + +# What indexer to use for transactions +# +# The application will set which txs to index. In some cases a node operator will be able +# to decide which txs to index based on configuration set in the application. +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +# - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. +# 3) "psql" - the indexer services backed by PostgreSQL. +# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. +indexer = "kv" + +# The PostgreSQL connection configuration, the connection format: +# postgresql://:@:/? +psql-conn = "" + +####################################################### +### Instrumentation Configuration Options ### +####################################################### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "tendermint" diff --git a/integration_test/validator2/node_key.json b/integration_test/validator2/node_key.json new file mode 100644 index 00000000..f5c21ede --- /dev/null +++ b/integration_test/validator2/node_key.json @@ -0,0 +1 @@ +{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"TRMciGxfrF5mbBVvo4UTz6HNlUYzo0VFKccU5z4HR8kMhHCzBW5R7pLyCFmdoTeJRsuspKuWnhqlCqON2YmzYw=="}} \ No newline at end of file diff --git a/integration_test/validator2/priv_validator_key.json b/integration_test/validator2/priv_validator_key.json new file mode 100644 index 00000000..181cb139 --- /dev/null +++ b/integration_test/validator2/priv_validator_key.json @@ -0,0 +1,11 @@ +{ + "address": "BDB9751AAF507CBAFA6746FC641A3047653E6192", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "2Ux2KGFJzRFQjXw3SVow1nvfz1SixgsBx+2zFaHGel4=" + }, + "priv_key": { + "type": "tendermint/PrivKeyEd25519", + "value": "mZ0D17lS4AXojD5EP6xTNsIGFK9F/8p+fp0GUO2vQMbZTHYoYUnNEVCNfDdJWjDWe9/PVKLGCwHH7bMVocZ6Xg==" + } +} \ No newline at end of file diff --git a/integration_test/validator3/app.toml b/integration_test/validator3/app.toml new file mode 100644 index 00000000..f31fad25 --- /dev/null +++ b/integration_test/validator3/app.toml @@ -0,0 +1,293 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Base Configuration ### +############################################################################### + +# The minimum gas prices a validator is willing to accept for processing a +# transaction. A transaction's fees must meet the minimum of any denomination +# specified in this config (e.g. 0.25token1;0.0001token2). +minimum-gas-prices = "8500000000axpla" + +# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals +# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +# everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals +# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval' +pruning = "default" + +# These are applied if and only if the pruning strategy is custom. +pruning-keep-recent = "0" +pruning-keep-every = "0" +pruning-interval = "0" + +# HaltHeight contains a non-zero block height at which a node will gracefully +# halt and shutdown that can be used to assist upgrades and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-height = 0 + +# HaltTime contains a non-zero minimum block time (in Unix seconds) at which +# a node will gracefully halt and shutdown that can be used to assist upgrades +# and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-time = 0 + +# MinRetainBlocks defines the minimum block height offset from the current +# block being committed, such that all blocks past this offset are pruned +# from Tendermint. It is used as part of the process of determining the +# ResponseCommit.RetainHeight value during ABCI Commit. A value of 0 indicates +# that no blocks should be pruned. +# +# This configuration value is only responsible for pruning Tendermint blocks. +# It has no bearing on application state pruning which is determined by the +# "pruning-*" configurations. +# +# Note: Tendermint block pruning is dependant on this parameter in conunction +# with the unbonding (safety threshold) period, state pruning and state sync +# snapshot parameters to determine the correct minimum value of +# ResponseCommit.RetainHeight. +min-retain-blocks = 0 + +# InterBlockCache enables inter-block caching. +inter-block-cache = true + +# IndexEvents defines the set of events in the form {eventType}.{attributeKey}, +# which informs Tendermint what to index. If empty, all events will be indexed. +# +# Example: +# ["message.sender", "message.recipient"] +index-events = [] + +# IavlCacheSize set the size of the iavl tree cache. +# Default cache size is 50mb. +iavl-cache-size = 781250 + +# IAVLDisableFastNode enables or disables the fast node feature of IAVL. +# Default is true. +iavl-disable-fastnode = true + +############################################################################### +### Telemetry Configuration ### +############################################################################### + +[telemetry] + +# Prefixed with keys to separate services. +service-name = "" + +# Enabled enables the application telemetry functionality. When enabled, +# an in-memory sink is also enabled by default. Operators may also enabled +# other sinks such as Prometheus. +enabled = false + +# Enable prefixing gauge values with hostname. +enable-hostname = false + +# Enable adding hostname to labels. +enable-hostname-label = false + +# Enable adding service to labels. +enable-service-label = false + +# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink. +prometheus-retention-time = 0 + +# GlobalLabels defines a global set of name/value label tuples applied to all +# metrics emitted using the wrapper functions defined in telemetry package. +# +# Example: +# [["chain_id", "cosmoshub-1"]] +global-labels = [ +] + +############################################################################### +### API Configuration ### +############################################################################### + +[api] + +# Enable defines if the API server should be enabled. +enable = false + +# Swagger defines if swagger documentation should automatically be registered. +swagger = false + +# Address defines the API server to listen on. +address = "tcp://0.0.0.0:1317" + +# MaxOpenConnections defines the number of maximum open connections. +max-open-connections = 1000 + +# RPCReadTimeout defines the Tendermint RPC read timeout (in seconds). +rpc-read-timeout = 10 + +# RPCWriteTimeout defines the Tendermint RPC write timeout (in seconds). +rpc-write-timeout = 0 + +# RPCMaxBodyBytes defines the Tendermint maximum response body (in bytes). +rpc-max-body-bytes = 1000000 + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enabled-unsafe-cors = false + +############################################################################### +### Rosetta Configuration ### +############################################################################### + +[rosetta] + +# Enable defines if the Rosetta API server should be enabled. +enable = false + +# Address defines the Rosetta API server to listen on. +address = ":8080" + +# Network defines the name of the blockchain that will be returned by Rosetta. +blockchain = "app" + +# Network defines the name of the network that will be returned by Rosetta. +network = "network" + +# Retries defines the number of retries when connecting to the node before failing. +retries = 3 + +# Offline defines if Rosetta server should run in offline mode. +offline = false + +############################################################################### +### gRPC Configuration ### +############################################################################### + +[grpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the gRPC server address to bind to. +address = "0.0.0.0:9110" + +############################################################################### +### gRPC Web Configuration ### +############################################################################### + +[grpc-web] + +# GRPCWebEnable defines if the gRPC-web should be enabled. +# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op. +enable = true + +# Address defines the gRPC-web server address to bind to. +address = "0.0.0.0:9111" + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enable-unsafe-cors = false + +############################################################################### +### State Sync Configuration ### +############################################################################### + +# State sync snapshots allow other nodes to rapidly join the network without replaying historical +# blocks, instead downloading and applying a snapshot of the application state at a given height. +[state-sync] + +# snapshot-interval specifies the block interval at which local state sync snapshots are +# taken (0 to disable). Must be a multiple of pruning-keep-every. +snapshot-interval = 1000 + +# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). +snapshot-keep-recent = 10 + +############################################################################### +### EVM Configuration ### +############################################################################### + +[evm] + +# Tracer defines the 'vm.Tracer' type that the EVM will use when the node is run in +# debug mode. To enable tracing use the '--evm.tracer' flag when starting your node. +# Valid types are: json|struct|access_list|markdown +tracer = "" + +# MaxTxGasWanted defines the gas wanted for each eth tx returned in ante handler in check tx mode. +max-tx-gas-wanted = 0 + +############################################################################### +### JSON RPC Configuration ### +############################################################################### + +[json-rpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the EVM RPC HTTP server address to bind to. +address = "0.0.0.0:8565" + +# Address defines the EVM WebSocket server address to bind to. +ws-address = "0.0.0.0:8566" + +# API defines a list of JSON-RPC namespaces that should be enabled +# Example: "eth,txpool,personal,net,debug,web3" +api = "eth,net,web3" + +# GasCap sets a cap on gas that can be used in eth_call/estimateGas (0=infinite). Default: 25,000,000. +gas-cap = 25000000 + +# EVMTimeout is the global timeout for eth_call. Default: 5s. +evm-timeout = "5s" + +# TxFeeCap is the global tx-fee cap for send transaction. Default: 1eth. +txfee-cap = 1 + +# FilterCap sets the global cap for total number of filters that can be created +filter-cap = 200 + +# FeeHistoryCap sets the global cap for total number of blocks that can be fetched +feehistory-cap = 100 + +# LogsCap defines the max number of results can be returned from single 'eth_getLogs' query. +logs-cap = 10000 + +# BlockRangeCap defines the max block range allowed for 'eth_getLogs' query. +block-range-cap = 10000 + +# HTTPTimeout is the read/write timeout of http json-rpc server. +http-timeout = "30s" + +# HTTPIdleTimeout is the idle timeout of http json-rpc server. +http-idle-timeout = "2m0s" + +# AllowUnprotectedTxs restricts unprotected (non EIP155 signed) transactions to be submitted via +# the node's RPC when the global parameter is disabled. +allow-unprotected-txs = false + +# MaxOpenConnections sets the maximum number of simultaneous connections +# for the server listener. +max-open-connections = 0 + +# EnableIndexer enables the custom transaction indexer for the EVM (ethereum transactions). +enable-indexer = false + +############################################################################### +### TLS Configuration ### +############################################################################### + +[tls] + +# Certificate path defines the cert.pem file path for the TLS configuration. +certificate-path = "" + +# Key path defines the key.pem file path for the TLS configuration. +key-path = "" + +############################################################################### +### Custom Xpla Configuration ### +############################################################################### +# bypass-min-fee-msg-types defines custom message types the operator may set that +# will bypass minimum fee checks during CheckTx. +# +# Example: +# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", ...] +bypass-min-fee-msg-types = ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient", ] diff --git a/integration_test/validator3/client.toml b/integration_test/validator3/client.toml new file mode 100644 index 00000000..bb2e8e1d --- /dev/null +++ b/integration_test/validator3/client.toml @@ -0,0 +1,17 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Client Configuration ### +############################################################################### + +# The network chain ID +chain-id = "" +# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) +keyring-backend = "test" +# CLI output format (text|json) +output = "text" +# : to Tendermint RPC interface for this chain +node = "tcp://localhost:26657" +# Transaction broadcasting mode (sync|async|block) +broadcast-mode = "sync" diff --git a/integration_test/validator3/config.toml b/integration_test/validator3/config.toml new file mode 100644 index 00000000..25c3a1ef --- /dev/null +++ b/integration_test/validator3/config.toml @@ -0,0 +1,465 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or +# relative to the home directory (e.g. "data"). The home directory is +# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable +# or --home cmd flag. + +####################################################################### +### Main Base Config Options ### +####################################################################### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the Tendermint binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "validator3" + +# If this node is many blocks behind the tip of the chain, FastSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +fast_sync = true + +# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +# * rocksdb (uses github.com/tecbot/gorocksdb) +# - EXPERIMENTAL +# - requires gcc +# - use rocksdb build tag (go build -tags rocksdb) +# * badgerdb (uses github.com/dgraph-io/badger) +# - EXPERIMENTAL +# - use badgerdb build tag (go build -tags badgerdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "info" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for Tendermint to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + + +####################################################################### +### Advanced Configuration Options ### +####################################################################### + +####################################################### +### RPC Server Configuration Options ### +####################################################### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26677" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = false + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# Experimental parameter to specify the maximum number of events a node will +# buffer, per subscription, before returning an error and closing the +# subscription. Must be set to at least 100, but higher values will accommodate +# higher event throughput rates (and will use more memory). +experimental_subscription_buffer_size = 200 + +# Experimental parameter to specify the maximum number of RPC responses that +# can be buffered per WebSocket client. If clients cannot read from the +# WebSocket endpoint fast enough, they will be disconnected, so increasing this +# parameter may reduce the chances of them being disconnected (but will cause +# the node to use more memory). +# +# Must be at least the same as "experimental_subscription_buffer_size", +# otherwise connections could be dropped unnecessarily. This value should +# ideally be somewhat higher than "experimental_subscription_buffer_size" to +# accommodate non-subscription-related RPC responses. +experimental_websocket_write_buffer_size = 200 + +# If a WebSocket client cannot read fast enough, at present we may +# silently drop events instead of generating an error or disconnecting the +# client. +# +# Enabling this experimental parameter will cause the WebSocket connection to +# be closed instead if it cannot read fast enough, allowing for greater +# predictability in subscription behaviour. +experimental_close_on_slow_client = false + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_key_file = "" + +# pprof listen address (https://golang.org/pkg/net/http/pprof) +pprof_laddr = "localhost:6080" + +####################################################### +### P2P Configuration Options ### +####################################################### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26676" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. ip and port are required +# example: 159.89.10.97:26656 +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "472e2e1552a9d0c9dade1f33d31e8f691ab9077b@192.167.100.2:26666,609384b9304c4c84973fe49ebaa83a3dd4d6b894@192.167.100.4:26686,1ccf9b507c0b83a0ce1eb35d51cbbdf05ee71c35@192.167.100.1:26656" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# List of node IDs, to which a connection will be (re)established ignoring any existing limits +unconditional_peer_ids = "" + +# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) +persistent_peers_max_dial_period = "0s" + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +####################################################### +### Mempool Configuration Option ### +####################################################### +[mempool] + +# Mempool version to use: +# 1) "v0" - (default) FIFO mempool. +# 2) "v1" - prioritized mempool. +version = "v0" + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Do not remove invalid transactions from the cache (default: false) +# Set to true if it's not possible for any invalid transaction to become valid +# again in the future. +keep-invalid-txs-in-cache = false + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. +max_tx_bytes = 1048576 + +# Maximum size of a batch of transactions to send to a peer +# Including space needed by encoding (one varint per transaction). +# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 +max_batch_bytes = 0 + +# ttl-duration, if non-zero, defines the maximum amount of time a transaction +# can exist for in the mempool. +# +# Note, if ttl-num-blocks is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if it's +# insertion time into the mempool is beyond ttl-duration. +ttl-duration = "0s" + +# ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction +# can exist for in the mempool. +# +# Note, if ttl-duration is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if +# it's insertion time into the mempool is beyond ttl-duration. +ttl-num-blocks = 0 + +####################################################### +### State Sync Configuration Options ### +####################################################### +[statesync] +# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine +# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in +# the network to take and serve state machine snapshots. State sync is not attempted if the node +# has any local state (LastBlockHeight > 0). The node will have a truncated block history, +# starting from the height of the snapshot. +enable = false + +# RPC servers (comma-separated) for light client verification of the synced state machine and +# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding +# header hash obtained from a trusted source, and a period during which validators can be trusted. +# +# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 +# weeks) during which they can be financially punished (slashed) for misbehavior. +rpc_servers = "" +trust_height = 0 +trust_hash = "" +trust_period = "168h0m0s" + +# Time to spend discovering snapshots before initiating a restore. +discovery_time = "15s" + +# Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). +# Will create a new, randomly named directory within, and remove it when done. +temp_dir = "" + +# The timeout duration before re-requesting a chunk, possibly from a different +# peer (default: 1 minute). +chunk_request_timeout = "10s" + +# The number of concurrent chunk fetchers to run (default: 1). +chunk_fetchers = "4" + +####################################################### +### Fast Sync Configuration Connections ### +####################################################### +[fastsync] + +# Fast Sync version to use: +# 1) "v0" (default) - the legacy fast sync implementation +# 2) "v1" - refactor of v0 version for better testability +# 2) "v2" - complete redesign of v0, optimized for testability & readability +version = "v0" + +####################################################### +### Consensus Configuration Options ### +####################################################### +[consensus] + +wal_file = "data/cs.wal/wal" + +# How long we wait for a proposal block before prevoting nil +timeout_propose = "3s" +# How much timeout_propose increases with each round +timeout_propose_delta = "500ms" +# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) +timeout_prevote = "1s" +# How much the timeout_prevote increases with each round +timeout_prevote_delta = "500ms" +# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) +timeout_precommit = "1s" +# How much the timeout_precommit increases with each round +timeout_precommit_delta = "500ms" +# How long we wait after committing a block, before starting on the new +# height (this gives us a chance to receive some more precommits, even +# though we already have +2/3). +timeout_commit = "5s" + +# How many blocks to look back to check existence of the node's consensus votes before joining consensus +# When non-zero, the node will panic upon restart +# if the same consensus key was used to sign {double_sign_check_height} last blocks. +# So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. +double_sign_check_height = 0 + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +####################################################### +### Storage Configuration Options ### +####################################################### + +# Set to true to discard ABCI responses from the state store, which can save a +# considerable amount of disk space. Set to false to ensure ABCI responses are +# persisted. ABCI responses are required for /block_results RPC queries, and to +# reindex events in the command-line tool. +discard_abci_responses = false + +####################################################### +### Transaction Indexer Configuration Options ### +####################################################### +[tx_index] + +# What indexer to use for transactions +# +# The application will set which txs to index. In some cases a node operator will be able +# to decide which txs to index based on configuration set in the application. +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +# - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. +# 3) "psql" - the indexer services backed by PostgreSQL. +# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. +indexer = "kv" + +# The PostgreSQL connection configuration, the connection format: +# postgresql://:@:/? +psql-conn = "" + +####################################################### +### Instrumentation Configuration Options ### +####################################################### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "tendermint" diff --git a/integration_test/validator3/node_key.json b/integration_test/validator3/node_key.json new file mode 100644 index 00000000..6bb40958 --- /dev/null +++ b/integration_test/validator3/node_key.json @@ -0,0 +1 @@ +{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"O44ld2k2jYPK85yCQRk8UMh3AvbHNKIJwUGd3fsbj2caE979OU7i4n2AjJrNppXUxZmUW9eWH8NSbobjCdvsuQ=="}} \ No newline at end of file diff --git a/integration_test/validator3/priv_validator_key.json b/integration_test/validator3/priv_validator_key.json new file mode 100644 index 00000000..9b7eb334 --- /dev/null +++ b/integration_test/validator3/priv_validator_key.json @@ -0,0 +1,11 @@ +{ + "address": "596694884B62CF8E5248EDC5D7B6BEC41F1AA96C", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "0QDBKo/xijJMQ9XyqxGjNeFv6SgYJZB8+pUWQ6A+20c=" + }, + "priv_key": { + "type": "tendermint/PrivKeyEd25519", + "value": "zvThF7vS7z8aDoFY8J9s0L08T6wbjWGvMBBOD+7ujqXRAMEqj/GKMkxD1fKrEaM14W/pKBglkHz6lRZDoD7bRw==" + } +} \ No newline at end of file diff --git a/integration_test/validator4/app.toml b/integration_test/validator4/app.toml new file mode 100644 index 00000000..f98c17ee --- /dev/null +++ b/integration_test/validator4/app.toml @@ -0,0 +1,294 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Base Configuration ### +############################################################################### + +# The minimum gas prices a validator is willing to accept for processing a +# transaction. A transaction's fees must meet the minimum of any denomination +# specified in this config (e.g. 0.25token1;0.0001token2). +minimum-gas-prices = "8500000000axpla" + +# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals +# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +# everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals +# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval' +pruning = "default" + +# These are applied if and only if the pruning strategy is custom. +pruning-keep-recent = "0" +pruning-keep-every = "0" +pruning-interval = "0" + +# HaltHeight contains a non-zero block height at which a node will gracefully +# halt and shutdown that can be used to assist upgrades and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-height = 0 + +# HaltTime contains a non-zero minimum block time (in Unix seconds) at which +# a node will gracefully halt and shutdown that can be used to assist upgrades +# and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-time = 0 + +# MinRetainBlocks defines the minimum block height offset from the current +# block being committed, such that all blocks past this offset are pruned +# from Tendermint. It is used as part of the process of determining the +# ResponseCommit.RetainHeight value during ABCI Commit. A value of 0 indicates +# that no blocks should be pruned. +# +# This configuration value is only responsible for pruning Tendermint blocks. +# It has no bearing on application state pruning which is determined by the +# "pruning-*" configurations. +# +# Note: Tendermint block pruning is dependant on this parameter in conunction +# with the unbonding (safety threshold) period, state pruning and state sync +# snapshot parameters to determine the correct minimum value of +# ResponseCommit.RetainHeight. +min-retain-blocks = 0 + +# InterBlockCache enables inter-block caching. +inter-block-cache = true + +# IndexEvents defines the set of events in the form {eventType}.{attributeKey}, +# which informs Tendermint what to index. If empty, all events will be indexed. +# +# Example: +# ["message.sender", "message.recipient"] +index-events = [] + +# IavlCacheSize set the size of the iavl tree cache. +# Default cache size is 50mb. +iavl-cache-size = 781250 + +# IAVLDisableFastNode enables or disables the fast node feature of IAVL. +# Default is true. +iavl-disable-fastnode = true + +############################################################################### +### Telemetry Configuration ### +############################################################################### + +[telemetry] + +# Prefixed with keys to separate services. +service-name = "" + +# Enabled enables the application telemetry functionality. When enabled, +# an in-memory sink is also enabled by default. Operators may also enabled +# other sinks such as Prometheus. +enabled = false + +# Enable prefixing gauge values with hostname. +enable-hostname = false + +# Enable adding hostname to labels. +enable-hostname-label = false + +# Enable adding service to labels. +enable-service-label = false + +# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink. +prometheus-retention-time = 0 + +# GlobalLabels defines a global set of name/value label tuples applied to all +# metrics emitted using the wrapper functions defined in telemetry package. +# +# Example: +# [["chain_id", "cosmoshub-1"]] +global-labels = [ +] + +############################################################################### +### API Configuration ### +############################################################################### + +[api] + +# Enable defines if the API server should be enabled. +enable = false + +# Swagger defines if swagger documentation should automatically be registered. +swagger = false + +# Address defines the API server to listen on. +address = "tcp://0.0.0.0:1317" + +# MaxOpenConnections defines the number of maximum open connections. +max-open-connections = 1000 + +# RPCReadTimeout defines the Tendermint RPC read timeout (in seconds). +rpc-read-timeout = 10 + +# RPCWriteTimeout defines the Tendermint RPC write timeout (in seconds). +rpc-write-timeout = 0 + +# RPCMaxBodyBytes defines the Tendermint maximum response body (in bytes). +rpc-max-body-bytes = 1000000 + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enabled-unsafe-cors = false + +############################################################################### +### Rosetta Configuration ### +############################################################################### + +[rosetta] + +# Enable defines if the Rosetta API server should be enabled. +enable = false + +# Address defines the Rosetta API server to listen on. +address = ":8080" + +# Network defines the name of the blockchain that will be returned by Rosetta. +blockchain = "app" + +# Network defines the name of the network that will be returned by Rosetta. +network = "network" + +# Retries defines the number of retries when connecting to the node before failing. +retries = 3 + +# Offline defines if Rosetta server should run in offline mode. +offline = false + +############################################################################### +### gRPC Configuration ### +############################################################################### + +[grpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the gRPC server address to bind to. +address = "0.0.0.0:9120" + +############################################################################### +### gRPC Web Configuration ### +############################################################################### + +[grpc-web] + +# GRPCWebEnable defines if the gRPC-web should be enabled. +# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op. +enable = true + +# Address defines the gRPC-web server address to bind to. +address = "0.0.0.0:9121" + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enable-unsafe-cors = false + +############################################################################### +### State Sync Configuration ### +############################################################################### + +# State sync snapshots allow other nodes to rapidly join the network without replaying historical +# blocks, instead downloading and applying a snapshot of the application state at a given height. +[state-sync] + +# snapshot-interval specifies the block interval at which local state sync snapshots are +# taken (0 to disable). Must be a multiple of pruning-keep-every. +snapshot-interval = 1000 + +# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). +snapshot-keep-recent = 10 + +############################################################################### +### EVM Configuration ### +############################################################################### + +[evm] + +# Tracer defines the 'vm.Tracer' type that the EVM will use when the node is run in +# debug mode. To enable tracing use the '--evm.tracer' flag when starting your node. +# Valid types are: json|struct|access_list|markdown +tracer = "" + +# MaxTxGasWanted defines the gas wanted for each eth tx returned in ante handler in check tx mode. +max-tx-gas-wanted = 0 + +############################################################################### +### JSON RPC Configuration ### +############################################################################### + +[json-rpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the EVM RPC HTTP server address to bind to. +address = "0.0.0.0:8575" + +# Address defines the EVM WebSocket server address to bind to. +ws-address = "0.0.0.0:8576" + +# API defines a list of JSON-RPC namespaces that should be enabled +# Example: "eth,txpool,personal,net,debug,web3" +api = "eth,net,web3" + +# GasCap sets a cap on gas that can be used in eth_call/estimateGas (0=infinite). Default: 25,000,000. +gas-cap = 25000000 + +# EVMTimeout is the global timeout for eth_call. Default: 5s. +evm-timeout = "5s" + +# TxFeeCap is the global tx-fee cap for send transaction. Default: 1eth. +txfee-cap = 1 + +# FilterCap sets the global cap for total number of filters that can be created +filter-cap = 200 + +# FeeHistoryCap sets the global cap for total number of blocks that can be fetched +feehistory-cap = 100 + +# LogsCap defines the max number of results can be returned from single 'eth_getLogs' query. +logs-cap = 10000 + +# BlockRangeCap defines the max block range allowed for 'eth_getLogs' query. +block-range-cap = 10000 + +# HTTPTimeout is the read/write timeout of http json-rpc server. +http-timeout = "30s" + +# HTTPIdleTimeout is the idle timeout of http json-rpc server. +http-idle-timeout = "2m0s" + +# AllowUnprotectedTxs restricts unprotected (non EIP155 signed) transactions to be submitted via +# the node's RPC when the global parameter is disabled. +allow-unprotected-txs = false + +# MaxOpenConnections sets the maximum number of simultaneous connections +# for the server listener. +max-open-connections = 0 + +# EnableIndexer enables the custom transaction indexer for the EVM (ethereum transactions). +enable-indexer = false + +############################################################################### +### TLS Configuration ### +############################################################################### + +[tls] + +# Certificate path defines the cert.pem file path for the TLS configuration. +certificate-path = "" + +# Key path defines the key.pem file path for the TLS configuration. +key-path = "" + + +############################################################################### +### Custom Xpla Configuration ### +############################################################################### +# bypass-min-fee-msg-types defines custom message types the operator may set that +# will bypass minimum fee checks during CheckTx. +# +# Example: +# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", ...] +bypass-min-fee-msg-types = ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient", ] diff --git a/integration_test/validator4/client.toml b/integration_test/validator4/client.toml new file mode 100644 index 00000000..bb2e8e1d --- /dev/null +++ b/integration_test/validator4/client.toml @@ -0,0 +1,17 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Client Configuration ### +############################################################################### + +# The network chain ID +chain-id = "" +# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) +keyring-backend = "test" +# CLI output format (text|json) +output = "text" +# : to Tendermint RPC interface for this chain +node = "tcp://localhost:26657" +# Transaction broadcasting mode (sync|async|block) +broadcast-mode = "sync" diff --git a/integration_test/validator4/config.toml b/integration_test/validator4/config.toml new file mode 100644 index 00000000..f38aad0e --- /dev/null +++ b/integration_test/validator4/config.toml @@ -0,0 +1,465 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or +# relative to the home directory (e.g. "data"). The home directory is +# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable +# or --home cmd flag. + +####################################################################### +### Main Base Config Options ### +####################################################################### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the Tendermint binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "validator4" + +# If this node is many blocks behind the tip of the chain, FastSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +fast_sync = true + +# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +# * rocksdb (uses github.com/tecbot/gorocksdb) +# - EXPERIMENTAL +# - requires gcc +# - use rocksdb build tag (go build -tags rocksdb) +# * badgerdb (uses github.com/dgraph-io/badger) +# - EXPERIMENTAL +# - use badgerdb build tag (go build -tags badgerdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "info" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for Tendermint to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + + +####################################################################### +### Advanced Configuration Options ### +####################################################################### + +####################################################### +### RPC Server Configuration Options ### +####################################################### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26687" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = false + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# Experimental parameter to specify the maximum number of events a node will +# buffer, per subscription, before returning an error and closing the +# subscription. Must be set to at least 100, but higher values will accommodate +# higher event throughput rates (and will use more memory). +experimental_subscription_buffer_size = 200 + +# Experimental parameter to specify the maximum number of RPC responses that +# can be buffered per WebSocket client. If clients cannot read from the +# WebSocket endpoint fast enough, they will be disconnected, so increasing this +# parameter may reduce the chances of them being disconnected (but will cause +# the node to use more memory). +# +# Must be at least the same as "experimental_subscription_buffer_size", +# otherwise connections could be dropped unnecessarily. This value should +# ideally be somewhat higher than "experimental_subscription_buffer_size" to +# accommodate non-subscription-related RPC responses. +experimental_websocket_write_buffer_size = 200 + +# If a WebSocket client cannot read fast enough, at present we may +# silently drop events instead of generating an error or disconnecting the +# client. +# +# Enabling this experimental parameter will cause the WebSocket connection to +# be closed instead if it cannot read fast enough, allowing for greater +# predictability in subscription behaviour. +experimental_close_on_slow_client = false + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_key_file = "" + +# pprof listen address (https://golang.org/pkg/net/http/pprof) +pprof_laddr = "localhost:6090" + +####################################################### +### P2P Configuration Options ### +####################################################### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26686" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. ip and port are required +# example: 159.89.10.97:26656 +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "472e2e1552a9d0c9dade1f33d31e8f691ab9077b@192.167.100.2:26666,1ccf9b507c0b83a0ce1eb35d51cbbdf05ee71c35@192.167.100.1:26656,c077002350aa59d772759ee14fb7e4219bbd8115@192.167.100.3:26676" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# List of node IDs, to which a connection will be (re)established ignoring any existing limits +unconditional_peer_ids = "" + +# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) +persistent_peers_max_dial_period = "0s" + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +####################################################### +### Mempool Configuration Option ### +####################################################### +[mempool] + +# Mempool version to use: +# 1) "v0" - (default) FIFO mempool. +# 2) "v1" - prioritized mempool. +version = "v0" + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Do not remove invalid transactions from the cache (default: false) +# Set to true if it's not possible for any invalid transaction to become valid +# again in the future. +keep-invalid-txs-in-cache = false + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. +max_tx_bytes = 1048576 + +# Maximum size of a batch of transactions to send to a peer +# Including space needed by encoding (one varint per transaction). +# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 +max_batch_bytes = 0 + +# ttl-duration, if non-zero, defines the maximum amount of time a transaction +# can exist for in the mempool. +# +# Note, if ttl-num-blocks is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if it's +# insertion time into the mempool is beyond ttl-duration. +ttl-duration = "0s" + +# ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction +# can exist for in the mempool. +# +# Note, if ttl-duration is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if +# it's insertion time into the mempool is beyond ttl-duration. +ttl-num-blocks = 0 + +####################################################### +### State Sync Configuration Options ### +####################################################### +[statesync] +# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine +# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in +# the network to take and serve state machine snapshots. State sync is not attempted if the node +# has any local state (LastBlockHeight > 0). The node will have a truncated block history, +# starting from the height of the snapshot. +enable = false + +# RPC servers (comma-separated) for light client verification of the synced state machine and +# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding +# header hash obtained from a trusted source, and a period during which validators can be trusted. +# +# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 +# weeks) during which they can be financially punished (slashed) for misbehavior. +rpc_servers = "" +trust_height = 0 +trust_hash = "" +trust_period = "168h0m0s" + +# Time to spend discovering snapshots before initiating a restore. +discovery_time = "15s" + +# Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). +# Will create a new, randomly named directory within, and remove it when done. +temp_dir = "" + +# The timeout duration before re-requesting a chunk, possibly from a different +# peer (default: 1 minute). +chunk_request_timeout = "10s" + +# The number of concurrent chunk fetchers to run (default: 1). +chunk_fetchers = "4" + +####################################################### +### Fast Sync Configuration Connections ### +####################################################### +[fastsync] + +# Fast Sync version to use: +# 1) "v0" (default) - the legacy fast sync implementation +# 2) "v1" - refactor of v0 version for better testability +# 2) "v2" - complete redesign of v0, optimized for testability & readability +version = "v0" + +####################################################### +### Consensus Configuration Options ### +####################################################### +[consensus] + +wal_file = "data/cs.wal/wal" + +# How long we wait for a proposal block before prevoting nil +timeout_propose = "3s" +# How much timeout_propose increases with each round +timeout_propose_delta = "500ms" +# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) +timeout_prevote = "1s" +# How much the timeout_prevote increases with each round +timeout_prevote_delta = "500ms" +# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) +timeout_precommit = "1s" +# How much the timeout_precommit increases with each round +timeout_precommit_delta = "500ms" +# How long we wait after committing a block, before starting on the new +# height (this gives us a chance to receive some more precommits, even +# though we already have +2/3). +timeout_commit = "5s" + +# How many blocks to look back to check existence of the node's consensus votes before joining consensus +# When non-zero, the node will panic upon restart +# if the same consensus key was used to sign {double_sign_check_height} last blocks. +# So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. +double_sign_check_height = 0 + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +####################################################### +### Storage Configuration Options ### +####################################################### + +# Set to true to discard ABCI responses from the state store, which can save a +# considerable amount of disk space. Set to false to ensure ABCI responses are +# persisted. ABCI responses are required for /block_results RPC queries, and to +# reindex events in the command-line tool. +discard_abci_responses = false + +####################################################### +### Transaction Indexer Configuration Options ### +####################################################### +[tx_index] + +# What indexer to use for transactions +# +# The application will set which txs to index. In some cases a node operator will be able +# to decide which txs to index based on configuration set in the application. +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +# - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. +# 3) "psql" - the indexer services backed by PostgreSQL. +# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. +indexer = "kv" + +# The PostgreSQL connection configuration, the connection format: +# postgresql://:@:/? +psql-conn = "" + +####################################################### +### Instrumentation Configuration Options ### +####################################################### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "tendermint" diff --git a/integration_test/validator4/node_key.json b/integration_test/validator4/node_key.json new file mode 100644 index 00000000..28c5f4cd --- /dev/null +++ b/integration_test/validator4/node_key.json @@ -0,0 +1 @@ +{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"PBXy6AQShnACm9EewBwZpx3Eg7dARPYPcFMJtc7L5JvvwZSWtLD+IyZuijNqyB7rp3vrlpYiVitoI6EFHgTjQw=="}} \ No newline at end of file diff --git a/integration_test/validator4/priv_validator_key.json b/integration_test/validator4/priv_validator_key.json new file mode 100644 index 00000000..ae36f2da --- /dev/null +++ b/integration_test/validator4/priv_validator_key.json @@ -0,0 +1,11 @@ +{ + "address": "7CE1A8A75A80660402E23328DCBE56F117F74325", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "xErK7sfIbEFo5XYhs3EVWAqQJVufmbZCAZEypO8QIEE=" + }, + "priv_key": { + "type": "tendermint/PrivKeyEd25519", + "value": "cp6bmBrB3etdnbazN/aYldfxxyoyia7s8EFf/sQzhjvESsrux8hsQWjldiGzcRVYCpAlW5+ZtkIBkTKk7xAgQQ==" + } +} \ No newline at end of file diff --git a/integration_test/wallet_cosmos_test.go b/integration_test/wallet_cosmos_test.go new file mode 100644 index 00000000..a84d3cb0 --- /dev/null +++ b/integration_test/wallet_cosmos_test.go @@ -0,0 +1,269 @@ +package integrationtest + +import ( + "context" + "encoding/json" + "os" + "sync" + + "github.com/pkg/errors" + "google.golang.org/grpc" + + cosmwasmtype "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/cosmos/cosmos-sdk/client/tx" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/simapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + "github.com/cosmos/cosmos-sdk/types" + sdktype "github.com/cosmos/cosmos-sdk/types" + txtype "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + ethhd "github.com/evmos/ethermint/crypto/hd" + evmtypes "github.com/evmos/ethermint/x/evm/types" +) + +const ( + Prefix = "xpla" + ChainID = "localtest_1-1" +) + +type WalletInfo struct { + sync.Mutex + + IsSrc bool + ChainId string + Prefix string + StringAddress string + ByteAddress sdktype.AccAddress + PrivKey cryptotypes.PrivKey + PubKey cryptotypes.PubKey + AccountNumber uint64 + Sequence uint64 + EncCfg simappparams.EncodingConfig +} + +func NewWalletInfo(mnemonics string) (*WalletInfo, error) { + // derive key + fullFundraiserPath := "m/44'/60'/0'/0/0" + + var privKey cryptotypes.PrivKey + var pubKey cryptotypes.PubKey + var byteAddress types.AccAddress + var stringAddress string + + devFunc := ethhd.EthSecp256k1.Derive() + privBytes, err := devFunc(mnemonics, "", fullFundraiserPath) + if err != nil { + err = errors.Wrap(err, "NewWalletInfo, derive mnemonics -> rootkey") + return nil, err + } + + genFunc := ethhd.EthSecp256k1.Generate() + privKey = genFunc(privBytes) + if err != nil { + err = errors.Wrap(err, "NewWalletInfo, rootkey -> privkey") + return nil, err + } + pubKey = privKey.PubKey() + + byteAddress = types.AccAddress(pubKey.Address()) + stringAddress, err = types.Bech32ifyAddressBytes(Prefix, pubKey.Address()) + if err != nil { + err = errors.Wrap(err, "NewWalletInfo, create bech32 address from byte") + return nil, err + } + + encCfg := simapp.MakeTestEncodingConfig() + + accountNumber, seq, err := GetAccountNumber(desc.ServiceConn, ChainID, stringAddress) + if err != nil { + err = errors.Wrap(err, "NewWalletInfo, get account info") + return nil, err + } + + ret := &WalletInfo{ + ChainId: ChainID, + Prefix: Prefix, + ByteAddress: byteAddress, + StringAddress: stringAddress, + PrivKey: privKey, + PubKey: pubKey, + AccountNumber: accountNumber, + Sequence: seq, + EncCfg: encCfg, + } + + return ret, nil +} + +func (w *WalletInfo) SendTx(chainId string, msg types.Msg, fee types.Coin, gasLimit int64, isEVM bool) (string, error) { + w.Lock() + defer w.Unlock() + var err error + + txBuilder := w.EncCfg.TxConfig.NewTxBuilder() + txBuilder.SetMemo("") + + if !isEVM { + err = txBuilder.SetMsgs(msg) + if err != nil { + err = errors.Wrap(err, "SendTx, set msgs") + return "", err + } + + txBuilder.SetGasLimit(uint64(gasLimit)) + txBuilder.SetFeeAmount(types.NewCoins(fee)) + } else { + convertedMsg := msg.(*evmtypes.MsgEthereumTx) + + _, err = convertedMsg.BuildTx(txBuilder, "axpla") + if err != nil { + err = errors.Wrap(err, "SendTx, build evm tx") + return "", err + } + } + + sigV2 := signing.SignatureV2{ + PubKey: w.PrivKey.PubKey(), + Data: &signing.SingleSignatureData{ + SignMode: w.EncCfg.TxConfig.SignModeHandler().DefaultMode(), + Signature: nil, + }, + Sequence: w.Sequence, + } + + err = txBuilder.SetSignatures(sigV2) + if err != nil { + err = errors.Wrap(err, "SendTx, SetSignatures") + return "", err + } + + signerData := xauthsigning.SignerData{ + ChainID: chainId, + AccountNumber: w.AccountNumber, + Sequence: w.Sequence, + } + + sigV2, err = tx.SignWithPrivKey( + w.EncCfg.TxConfig.SignModeHandler().DefaultMode(), signerData, txBuilder, w.PrivKey, w.EncCfg.TxConfig, w.Sequence) + if err != nil { + err = errors.Wrap(err, "SendTx, do sign") + return "", err + } + + err = txBuilder.SetSignatures(sigV2) + if err != nil { + err = errors.Wrap(err, "SendTx, set signatures") + return "", err + } + + txBytes, err := w.EncCfg.TxConfig.TxEncoder()(txBuilder.GetTx()) + if err != nil { + err = errors.Wrap(err, "SendTx, tx byte encode") + return "", err + } + + txHash, err := BroadcastTx(desc.ServiceConn, w.ChainId, txBytes, txtype.BroadcastMode_BROADCAST_MODE_ASYNC) + if err != nil { + err = errors.Wrap(err, "SendTx, tx broadcast") + return "", err + } + + w.Sequence += 1 + + return txHash, nil +} + +func (w *WalletInfo) RefreshSequence() error { + w.Lock() + defer w.Unlock() + + accountNumber, seq, err := GetAccountNumber(desc.ServiceConn, w.ChainId, w.StringAddress) + if err != nil { + err = errors.Wrap(err, "RefreshSequence, get account info") + return err + } + + w.AccountNumber = accountNumber + w.Sequence = seq + + return nil +} + +func GRPCQueryContractStore(conn *grpc.ClientConn, chainId, contractAddress, param string) (*json.RawMessage, error) { + client := cosmwasmtype.NewQueryClient(desc.ServiceConn) + res, err := client.SmartContractState(context.Background(), &cosmwasmtype.QuerySmartContractStateRequest{ + Address: contractAddress, + QueryData: []byte(param), + }) + + if err != nil { + err = errors.Wrap(err, "GRPCQueryContractStore") + return nil, err + } + + resData := json.RawMessage(res.Data.Bytes()) + + return &resData, nil +} + +func GenerateContractExecMessage(senderAddress, contractAddress string, param []byte, coins sdktype.Coins) *cosmwasmtype.MsgExecuteContract { + return &cosmwasmtype.MsgExecuteContract{ + Sender: senderAddress, + Contract: contractAddress, + Msg: param, + Funds: coins, + } + +} + +func GetAccountNumber(conn *grpc.ClientConn, chainId, address string) (uint64, uint64, error) { + client := authtypes.NewQueryClient(desc.GetConnectionWithContext(context.Background())) + + res, err := client.Account(context.Background(), &authtypes.QueryAccountRequest{Address: address}) + if err != nil { + err = errors.Wrap(err, "GetAccountNumber") + return 0, 0, err + } + + var baseAccount authtypes.ModuleAccount + err = baseAccount.Unmarshal(res.Account.Value) + if err != nil { + err = errors.Wrap(err, "GetAccountNumber, unmarshalling") + return 0, 0, err + } + + return baseAccount.GetAccountNumber(), baseAccount.GetSequence(), nil +} + +func BroadcastTx(conn *grpc.ClientConn, chainId string, txBytes []byte, mode txtype.BroadcastMode) (string, error) { + queryTxClient := txtype.NewServiceClient(desc.GetConnectionWithContext(context.Background())) + + _, err := queryTxClient.Simulate(context.Background(), &txtype.SimulateRequest{ + TxBytes: txBytes, + }) + + if err != nil { + return "", err + } + + client := txtype.NewServiceClient(desc.ServiceConn) + + if currtestingenv := os.Getenv("GOLANG_TESTING"); currtestingenv != "true" { + res, err := client.BroadcastTx(context.Background(), &txtype.BroadcastTxRequest{ + TxBytes: txBytes, + Mode: mode, + }) + + if err != nil { + err = errors.Wrap(err, "broadcastTx") + return "", err + } + + return res.TxResponse.TxHash, nil + } + + return "", nil +} diff --git a/integration_test/wallet_evm_test.go b/integration_test/wallet_evm_test.go new file mode 100644 index 00000000..14dacb73 --- /dev/null +++ b/integration_test/wallet_evm_test.go @@ -0,0 +1,110 @@ +package integrationtest + +import ( + "context" + "math/big" + "strconv" + + "github.com/pkg/errors" + + ethcommon "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + ethcrypto "github.com/ethereum/go-ethereum/crypto" + web3 "github.com/ethereum/go-ethereum/ethclient" +) + +const ( + CodeOK = 0 + + ErrStatusUnauthorized = "rest: unauthorized" + ErrUnknown = "rest: unknown error" + + HeaderContentType = "Content-Type" + HeaderContentTypeJson = "application/json" + + GET = "GET" + POST = "POST" + PUT = "PUT" + DELETE = "DELETE" + + REST_TIMEOUT = 2 // in sec +) + +type EVMWalletInfo struct { + CosmosWalletInfo *WalletInfo + + EthAddress ethcommon.Address + StringAddress string + Nonce uint64 +} + +type Method string + +func NewEVMWalletInfo(mnemonics string) (*EVMWalletInfo, error) { + cosmosWalletInfo, err := NewWalletInfo(mnemonics) + if err != nil { + err = errors.Wrap(err, "NewEVMWalletInfo, from NewWalletInfo") + return nil, err + } + + ethAddress := ethcommon.BytesToAddress(cosmosWalletInfo.PubKey.Address().Bytes()) + stringAddress := ethAddress.String() + + ret := &EVMWalletInfo{ + CosmosWalletInfo: cosmosWalletInfo, + EthAddress: ethAddress, + StringAddress: stringAddress, + } + + return ret, nil +} + +func (e *EVMWalletInfo) GetNonce(client *web3.Client) (uint64, error) { + nonce, err := client.NonceAt(context.Background(), e.EthAddress, nil) + if err != nil { + err = errors.Wrap(err, "GetNonce") + return 0, err + } + + e.Nonce = nonce + return nonce, nil +} + +func (e *EVMWalletInfo) SendTx(client *web3.Client, to ethcommon.Address, ethAmount *big.Int, txData []byte) (ethcommon.Hash, error) { + xplaGasPriceInt, err := strconv.ParseUint(xplaGasPrice, 10, 64) + if err != nil { + err = errors.Wrap(err, "SendTx, Sign") + return ethcommon.Hash{}, err + } + + chainId, err := client.NetworkID(context.Background()) + if err != nil { + err = errors.Wrap(err, "SendTx, Network ID") + return ethcommon.Hash{}, err + } + + txStruct := ðtypes.LegacyTx{ + Nonce: e.Nonce, + GasPrice: big.NewInt(int64(xplaGasPriceInt)), + Gas: uint64(xplaCodeGasLimit), + Value: big.NewInt(0), + Data: txData, + } + + tx := ethtypes.NewTx(txStruct) + + ethPrivkey, _ := ethcrypto.ToECDSA(e.CosmosWalletInfo.PrivKey.Bytes()) + signedTx, err := ethtypes.SignTx(tx, ethtypes.NewEIP155Signer(chainId), ethPrivkey) + if err != nil { + err = errors.Wrap(err, "SendTx, Sign") + return ethcommon.Hash{}, err + } + + err = client.SendTransaction(context.Background(), signedTx) + if err != nil { + err = errors.Wrap(err, "SendTx, SendTransaction") + return ethcommon.Hash{}, err + } + + return signedTx.Hash(), nil +}